From 84e2fcf0f0d856261463f215e6232ac93bbde80a Mon Sep 17 00:00:00 2001 From: NIL2000 Date: Fri, 20 Sep 2024 13:17:05 +0530 Subject: [PATCH 1/7] feat(cli): Implemented pagination support --- apps/cli/package.json | 3 +- .../commands/environment/list.environment.ts | 39 ++++- .../src/commands/workspace/list.workspace.ts | 44 ++++- pnpm-lock.yaml | 156 ++---------------- 4 files changed, 92 insertions(+), 150 deletions(-) diff --git a/apps/cli/package.json b/apps/cli/package.json index dfc859ca..89d3bf42 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -28,7 +28,8 @@ "nodemon": "^3.1.4", "@keyshade/secret-scan": "workspace:*", "socket.io-client": "^4.7.5", - "typescript": "^5.5.2" + "typescript": "^5.5.2", + "@keyshade/api-client": "workspace:*" }, "devDependencies": { "@swc/cli": "^0.4.0", diff --git a/apps/cli/src/commands/environment/list.environment.ts b/apps/cli/src/commands/environment/list.environment.ts index 1ec3dcba..9bf0e48a 100644 --- a/apps/cli/src/commands/environment/list.environment.ts +++ b/apps/cli/src/commands/environment/list.environment.ts @@ -1,6 +1,7 @@ import BaseCommand from '../base.command' -import { EnvironmentController } from '@keyshade/api-client' +import { EnvironmentController } from '@keyshade/api-client/src' import { + CommandOption, type CommandActionData, type CommandArgument } from 'src/types/command/command.types' @@ -24,9 +25,39 @@ export class ListEnvironment extends BaseCommand { ] } - async action({ args }: CommandActionData): Promise { + getOptions(): CommandOption[] { + return [ + { + short: '-p', + long: '--page ', + description: 'Index of the page.' + }, + { + short: '-l', + long: '--limit ', + description: 'Total number of items per page.' + }, + { + short: '-o', + long: '--order ', + description: + 'Order to sort by - either ascending (ASC) or descending (DESC).' + }, + { + short: '--sort', + long: '--sort ', + description: 'Field to sort by.' + }, + { + short: '-s', + long: '--search ', + description: 'Search term.' + } + ] + } + async action({ args, options }: CommandActionData): Promise { const [projectSlug] = args - + const { page, limit, order, sort, search } = options if (!projectSlug) { Logger.error('Project slug is required') return @@ -44,7 +75,7 @@ export class ListEnvironment extends BaseCommand { data: environments, error } = await environmentController.getAllEnvironmentsOfProject( - { projectSlug }, + { projectSlug, page, limit, order, sort, search }, headers ) diff --git a/apps/cli/src/commands/workspace/list.workspace.ts b/apps/cli/src/commands/workspace/list.workspace.ts index 401138f3..2adaaca2 100644 --- a/apps/cli/src/commands/workspace/list.workspace.ts +++ b/apps/cli/src/commands/workspace/list.workspace.ts @@ -1,6 +1,7 @@ import BaseCommand from '@/commands/base.command' import { Logger } from '@/util/logger' import ControllerInstance from '@/util/controller-instance' +import { CommandActionData, CommandOption } from '@/types/command/command.types' export default class ListWorkspace extends BaseCommand { getName(): string { @@ -11,12 +12,51 @@ export default class ListWorkspace extends BaseCommand { return 'Fetches all the workspace you have access to' } - async action(): Promise { + getOptions(): CommandOption[] { + return [ + { + short: '-p', + long: '--page ', + description: 'Index of the page.' + }, + { + short: '-l', + long: '--limit ', + description: 'Total number of items per page.' + }, + { + short: '-o', + long: '--order ', + description: + 'Order to sort by - either ascending (ASC) or descending (DESC).' + }, + { + short: '--sort', + long: '--sort ', + description: 'Field to sort by.' + }, + { + short: '-s', + long: '--search ', + description: 'Search term.' + } + ] + } + + async action({ options }: CommandActionData): Promise { Logger.info('Fetching all workspaces...') + const { page, limit, order, sort, search } = options + const { success, data, error } = await ControllerInstance.getInstance().workspaceController.getWorkspacesOfUser( - {}, + { + page, + limit, + order, + sort, + search + }, this.headers ) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 059f2704..e80a6125 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -252,10 +252,10 @@ importers: version: 7.4.2 jest: specifier: ^29.5.0 - version: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) + version: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)) jest-mock-extended: specifier: ^3.0.5 - version: 3.0.7(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)))(typescript@5.3.3) + version: 3.0.7(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)))(typescript@5.3.3) prettier: specifier: ^3.0.0 version: 3.3.3 @@ -273,7 +273,7 @@ importers: version: 6.3.4 ts-jest: specifier: ^29.1.0 - version: 29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)))(typescript@5.3.3) + version: 29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)))(typescript@5.3.3) ts-loader: specifier: ^9.4.3 version: 9.5.1(typescript@5.3.3)(webpack@5.94.0(@swc/core@1.7.26)) @@ -286,6 +286,9 @@ importers: '@clack/prompts': specifier: ^0.7.0 version: 0.7.0 + '@keyshade/api-client': + specifier: workspace:* + version: link:../../packages/api-client '@keyshade/secret-scan': specifier: workspace:* version: link:../../packages/secret-scan @@ -325,7 +328,7 @@ importers: devDependencies: '@swc/cli': specifier: ^0.4.0 - version: 0.4.0(@swc/core@1.7.26(@swc/helpers@0.5.2))(chokidar@3.6.0) + version: 0.4.0(@swc/core@1.7.26)(chokidar@3.6.0) '@swc/core': specifier: ^1.6.13 version: 1.7.26(@swc/helpers@0.5.2) @@ -10290,41 +10293,6 @@ snapshots: jest-util: 29.7.0 slash: 3.0.0 - '@jest/core@29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3))': - dependencies: - '@jest/console': 29.7.0 - '@jest/reporters': 29.7.0 - '@jest/test-result': 29.7.0 - '@jest/transform': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 20.16.5 - ansi-escapes: 4.3.2 - chalk: 4.1.2 - ci-info: 3.9.0 - exit: 0.1.2 - graceful-fs: 4.2.11 - jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - jest-haste-map: 29.7.0 - jest-message-util: 29.7.0 - jest-regex-util: 29.6.3 - jest-resolve: 29.7.0 - jest-resolve-dependencies: 29.7.0 - jest-runner: 29.7.0 - jest-runtime: 29.7.0 - jest-snapshot: 29.7.0 - jest-util: 29.7.0 - jest-validate: 29.7.0 - jest-watcher: 29.7.0 - micromatch: 4.0.8 - pretty-format: 29.7.0 - slash: 3.0.0 - strip-ansi: 6.0.1 - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - - ts-node - '@jest/core@29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2))': dependencies: '@jest/console': 29.7.0 @@ -10597,7 +10565,7 @@ snapshots: webpack: 5.94.0(@swc/core@1.7.26) webpack-node-externals: 3.0.0 optionalDependencies: - '@swc/cli': 0.4.0(@swc/core@1.7.26(@swc/helpers@0.5.2))(chokidar@3.6.0) + '@swc/cli': 0.4.0(@swc/core@1.7.26)(chokidar@3.6.0) '@swc/core': 1.7.26(@swc/helpers@0.5.2) transitivePeerDependencies: - esbuild @@ -11987,7 +11955,7 @@ snapshots: - supports-color - typescript - '@swc/cli@0.4.0(@swc/core@1.7.26(@swc/helpers@0.5.2))(chokidar@3.6.0)': + '@swc/cli@0.4.0(@swc/core@1.7.26)(chokidar@3.6.0)': dependencies: '@mole-inc/bin-wrapper': 8.0.1 '@swc/core': 1.7.26(@swc/helpers@0.5.2) @@ -13672,21 +13640,6 @@ snapshots: sha.js: 2.4.11 optional: true - create-jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)): - dependencies: - '@jest/types': 29.6.3 - chalk: 4.1.2 - exit: 0.1.2 - graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - jest-util: 29.7.0 - prompts: 2.4.2 - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - create-jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)): dependencies: '@jest/types': 29.6.3 @@ -15765,25 +15718,6 @@ snapshots: - babel-plugin-macros - supports-color - jest-cli@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)): - dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - '@jest/test-result': 29.7.0 - '@jest/types': 29.6.3 - chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - exit: 0.1.2 - import-local: 3.2.0 - jest-config: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - jest-util: 29.7.0 - jest-validate: 29.7.0 - yargs: 17.7.2 - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - jest-cli@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)): dependencies: '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)) @@ -15803,37 +15737,6 @@ snapshots: - supports-color - ts-node - jest-config@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)): - dependencies: - '@babel/core': 7.25.2 - '@jest/test-sequencer': 29.7.0 - '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@7.25.2) - chalk: 4.1.2 - ci-info: 3.9.0 - deepmerge: 4.3.1 - glob: 7.2.3 - graceful-fs: 4.2.11 - jest-circus: 29.7.0 - jest-environment-node: 29.7.0 - jest-get-type: 29.6.3 - jest-regex-util: 29.6.3 - jest-resolve: 29.7.0 - jest-runner: 29.7.0 - jest-util: 29.7.0 - jest-validate: 29.7.0 - micromatch: 4.0.8 - parse-json: 5.2.0 - pretty-format: 29.7.0 - slash: 3.0.0 - strip-json-comments: 3.1.1 - optionalDependencies: - '@types/node': 20.16.5 - ts-node: 10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3) - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - jest-config@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)): dependencies: '@babel/core': 7.25.2 @@ -15935,9 +15838,9 @@ snapshots: slash: 3.0.0 stack-utils: 2.0.6 - jest-mock-extended@3.0.7(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)))(typescript@5.3.3): + jest-mock-extended@3.0.7(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)))(typescript@5.3.3): dependencies: - jest: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) + jest: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)) ts-essentials: 10.0.2(typescript@5.3.3) typescript: 5.3.3 @@ -16092,18 +15995,6 @@ snapshots: merge-stream: 2.0.0 supports-color: 8.1.1 - jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)): - dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - '@jest/types': 29.6.3 - import-local: 3.2.0 - jest-cli: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)): dependencies: '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)) @@ -18544,12 +18435,12 @@ snapshots: ts-interface-checker@0.1.13: {} - ts-jest@29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)))(typescript@5.3.3): + ts-jest@29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)))(typescript@5.3.3): dependencies: bs-logger: 0.2.6 ejs: 3.1.10 fast-json-stable-stringify: 2.1.0 - jest: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3)) + jest: 29.7.0(@types/node@20.16.5)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2)) jest-util: 29.7.0 json5: 2.2.3 lodash.memoize: 4.1.2 @@ -18592,27 +18483,6 @@ snapshots: typescript: 5.3.3 webpack: 5.94.0(@swc/core@1.7.26) - ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.3.3): - dependencies: - '@cspotcode/source-map-support': 0.8.1 - '@tsconfig/node10': 1.0.11 - '@tsconfig/node12': 1.0.11 - '@tsconfig/node14': 1.0.3 - '@tsconfig/node16': 1.0.4 - '@types/node': 20.16.5 - acorn: 8.12.1 - acorn-walk: 8.3.4 - arg: 4.1.3 - create-require: 1.1.1 - diff: 4.0.2 - make-error: 1.3.6 - typescript: 5.3.3 - v8-compile-cache-lib: 3.0.1 - yn: 3.1.1 - optionalDependencies: - '@swc/core': 1.7.26(@swc/helpers@0.5.2) - optional: true - ts-node@10.9.2(@swc/core@1.7.26)(@types/node@20.16.5)(typescript@5.6.2): dependencies: '@cspotcode/source-map-support': 0.8.1 From 7e6da58f1cc6c5ef9e4042371c4c89ae63ca9300 Mon Sep 17 00:00:00 2001 From: NIL2000 Date: Fri, 20 Sep 2024 13:26:56 +0530 Subject: [PATCH 2/7] Build errors may be fixed --- apps/cli/src/commands/environment/list.environment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/cli/src/commands/environment/list.environment.ts b/apps/cli/src/commands/environment/list.environment.ts index 9bf0e48a..4e8af358 100644 --- a/apps/cli/src/commands/environment/list.environment.ts +++ b/apps/cli/src/commands/environment/list.environment.ts @@ -1,5 +1,5 @@ import BaseCommand from '../base.command' -import { EnvironmentController } from '@keyshade/api-client/src' +import { EnvironmentController } from '@keyshade/api-client' import { CommandOption, type CommandActionData, From 7d790625d56dc3ee2d485a4c2232dd68664cca68 Mon Sep 17 00:00:00 2001 From: NIL2000 Date: Fri, 20 Sep 2024 15:47:24 +0530 Subject: [PATCH 3/7] Refactor done --- apps/cli/package.json | 3 +- .../commands/environment/list.environment.ts | 35 +++-------------- .../src/commands/workspace/list.workspace.ts | 38 ++----------------- apps/cli/src/util/pagination-options.ts | 32 ++++++++++++++++ 4 files changed, 41 insertions(+), 67 deletions(-) create mode 100644 apps/cli/src/util/pagination-options.ts diff --git a/apps/cli/package.json b/apps/cli/package.json index 89d3bf42..dfc859ca 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -28,8 +28,7 @@ "nodemon": "^3.1.4", "@keyshade/secret-scan": "workspace:*", "socket.io-client": "^4.7.5", - "typescript": "^5.5.2", - "@keyshade/api-client": "workspace:*" + "typescript": "^5.5.2" }, "devDependencies": { "@swc/cli": "^0.4.0", diff --git a/apps/cli/src/commands/environment/list.environment.ts b/apps/cli/src/commands/environment/list.environment.ts index 4e8af358..c480366a 100644 --- a/apps/cli/src/commands/environment/list.environment.ts +++ b/apps/cli/src/commands/environment/list.environment.ts @@ -6,6 +6,7 @@ import { type CommandArgument } from 'src/types/command/command.types' import { Logger } from '@/util/logger' +import { getPaginationOptions } from '@/util/pagination-options' export class ListEnvironment extends BaseCommand { getName(): string { @@ -26,38 +27,12 @@ export class ListEnvironment extends BaseCommand { } getOptions(): CommandOption[] { - return [ - { - short: '-p', - long: '--page ', - description: 'Index of the page.' - }, - { - short: '-l', - long: '--limit ', - description: 'Total number of items per page.' - }, - { - short: '-o', - long: '--order ', - description: - 'Order to sort by - either ascending (ASC) or descending (DESC).' - }, - { - short: '--sort', - long: '--sort ', - description: 'Field to sort by.' - }, - { - short: '-s', - long: '--search ', - description: 'Search term.' - } - ] + return getPaginationOptions() } + async action({ args, options }: CommandActionData): Promise { const [projectSlug] = args - const { page, limit, order, sort, search } = options + if (!projectSlug) { Logger.error('Project slug is required') return @@ -75,7 +50,7 @@ export class ListEnvironment extends BaseCommand { data: environments, error } = await environmentController.getAllEnvironmentsOfProject( - { projectSlug, page, limit, order, sort, search }, + { projectSlug, ...options }, headers ) diff --git a/apps/cli/src/commands/workspace/list.workspace.ts b/apps/cli/src/commands/workspace/list.workspace.ts index 2adaaca2..6239c896 100644 --- a/apps/cli/src/commands/workspace/list.workspace.ts +++ b/apps/cli/src/commands/workspace/list.workspace.ts @@ -2,6 +2,7 @@ import BaseCommand from '@/commands/base.command' import { Logger } from '@/util/logger' import ControllerInstance from '@/util/controller-instance' import { CommandActionData, CommandOption } from '@/types/command/command.types' +import { getPaginationOptions } from '@/util/pagination-options' export default class ListWorkspace extends BaseCommand { getName(): string { @@ -13,49 +14,16 @@ export default class ListWorkspace extends BaseCommand { } getOptions(): CommandOption[] { - return [ - { - short: '-p', - long: '--page ', - description: 'Index of the page.' - }, - { - short: '-l', - long: '--limit ', - description: 'Total number of items per page.' - }, - { - short: '-o', - long: '--order ', - description: - 'Order to sort by - either ascending (ASC) or descending (DESC).' - }, - { - short: '--sort', - long: '--sort ', - description: 'Field to sort by.' - }, - { - short: '-s', - long: '--search ', - description: 'Search term.' - } - ] + return getPaginationOptions() } async action({ options }: CommandActionData): Promise { Logger.info('Fetching all workspaces...') - const { page, limit, order, sort, search } = options - const { success, data, error } = await ControllerInstance.getInstance().workspaceController.getWorkspacesOfUser( { - page, - limit, - order, - sort, - search + ...options }, this.headers ) diff --git a/apps/cli/src/util/pagination-options.ts b/apps/cli/src/util/pagination-options.ts new file mode 100644 index 00000000..7104e683 --- /dev/null +++ b/apps/cli/src/util/pagination-options.ts @@ -0,0 +1,32 @@ +import { CommandOption } from '@/types/command/command.types' + +export const getPaginationOptions = (): CommandOption[] => { + return [ + { + short: '-p', + long: '--page ', + description: 'Index of the page.' + }, + { + short: '-l', + long: '--limit ', + description: 'Total number of items per page.' + }, + { + short: '-o', + long: '--order ', + description: + 'Order to sort by - either ascending (ASC) or descending (DESC).' + }, + { + short: '--sort', + long: '--sort ', + description: 'Field to sort by.' + }, + { + short: '-s', + long: '--search ', + description: 'Search term.' + } + ] +} From b91049c776c07038ab7b3c136226145391a0005c Mon Sep 17 00:00:00 2001 From: NIL2000 Date: Fri, 20 Sep 2024 15:56:00 +0530 Subject: [PATCH 4/7] Fixed pnpm-lock.yml file --- pnpm-lock.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e80a6125..a9028fe9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -286,9 +286,6 @@ importers: '@clack/prompts': specifier: ^0.7.0 version: 0.7.0 - '@keyshade/api-client': - specifier: workspace:* - version: link:../../packages/api-client '@keyshade/secret-scan': specifier: workspace:* version: link:../../packages/secret-scan From 20cc20c25e0954948c8f654d935e6a2a1694c066 Mon Sep 17 00:00:00 2001 From: NIL2000 Date: Fri, 20 Sep 2024 20:35:40 +0530 Subject: [PATCH 5/7] Optimized pagination-options --- .../commands/environment/list.environment.ts | 4 +- .../src/commands/workspace/list.workspace.ts | 4 +- apps/cli/src/util/pagination-options.ts | 60 +++++++++---------- 3 files changed, 32 insertions(+), 36 deletions(-) diff --git a/apps/cli/src/commands/environment/list.environment.ts b/apps/cli/src/commands/environment/list.environment.ts index c480366a..454f9b80 100644 --- a/apps/cli/src/commands/environment/list.environment.ts +++ b/apps/cli/src/commands/environment/list.environment.ts @@ -6,7 +6,7 @@ import { type CommandArgument } from 'src/types/command/command.types' import { Logger } from '@/util/logger' -import { getPaginationOptions } from '@/util/pagination-options' +import { PAGINATION_OPTION } from '@/util/pagination-options' export class ListEnvironment extends BaseCommand { getName(): string { @@ -27,7 +27,7 @@ export class ListEnvironment extends BaseCommand { } getOptions(): CommandOption[] { - return getPaginationOptions() + return PAGINATION_OPTION } async action({ args, options }: CommandActionData): Promise { diff --git a/apps/cli/src/commands/workspace/list.workspace.ts b/apps/cli/src/commands/workspace/list.workspace.ts index 6239c896..1de6e3cc 100644 --- a/apps/cli/src/commands/workspace/list.workspace.ts +++ b/apps/cli/src/commands/workspace/list.workspace.ts @@ -2,7 +2,7 @@ import BaseCommand from '@/commands/base.command' import { Logger } from '@/util/logger' import ControllerInstance from '@/util/controller-instance' import { CommandActionData, CommandOption } from '@/types/command/command.types' -import { getPaginationOptions } from '@/util/pagination-options' +import { PAGINATION_OPTION } from '@/util/pagination-options' export default class ListWorkspace extends BaseCommand { getName(): string { @@ -14,7 +14,7 @@ export default class ListWorkspace extends BaseCommand { } getOptions(): CommandOption[] { - return getPaginationOptions() + return PAGINATION_OPTION } async action({ options }: CommandActionData): Promise { diff --git a/apps/cli/src/util/pagination-options.ts b/apps/cli/src/util/pagination-options.ts index 7104e683..56ef82f0 100644 --- a/apps/cli/src/util/pagination-options.ts +++ b/apps/cli/src/util/pagination-options.ts @@ -1,32 +1,28 @@ -import { CommandOption } from '@/types/command/command.types' - -export const getPaginationOptions = (): CommandOption[] => { - return [ - { - short: '-p', - long: '--page ', - description: 'Index of the page.' - }, - { - short: '-l', - long: '--limit ', - description: 'Total number of items per page.' - }, - { - short: '-o', - long: '--order ', - description: - 'Order to sort by - either ascending (ASC) or descending (DESC).' - }, - { - short: '--sort', - long: '--sort ', - description: 'Field to sort by.' - }, - { - short: '-s', - long: '--search ', - description: 'Search term.' - } - ] -} +export const PAGINATION_OPTION = [ + { + short: '-p', + long: '--page ', + description: 'Index of the page.' + }, + { + short: '-l', + long: '--limit ', + description: 'Total number of items per page.' + }, + { + short: '-o', + long: '--order ', + description: + 'Order to sort by - either ascending (ASC) or descending (DESC).' + }, + { + short: '--sort', + long: '--sort ', + description: 'Field to sort by.' + }, + { + short: '-s', + long: '--search ', + description: 'Search term.' + } +] From f65fc609cd86f659b7f3d65c447e0a1a56b3cce8 Mon Sep 17 00:00:00 2001 From: NIL2000 Date: Sat, 21 Sep 2024 10:55:39 +0530 Subject: [PATCH 6/7] Small changes made in pagination-opotions --- apps/cli/src/util/pagination-options.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/cli/src/util/pagination-options.ts b/apps/cli/src/util/pagination-options.ts index 56ef82f0..5c920191 100644 --- a/apps/cli/src/util/pagination-options.ts +++ b/apps/cli/src/util/pagination-options.ts @@ -1,4 +1,6 @@ -export const PAGINATION_OPTION = [ +import { CommandOption } from '@/types/command/command.types' + +export const PAGINATION_OPTION: CommandOption[] = [ { short: '-p', long: '--page ', From 5d0e27f6e7ce3a78a436c6d8be6c90551f8797f1 Mon Sep 17 00:00:00 2001 From: NIL2000 Date: Sat, 21 Sep 2024 19:01:27 +0530 Subject: [PATCH 7/7] Added choice field --- apps/cli/src/util/pagination-options.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/cli/src/util/pagination-options.ts b/apps/cli/src/util/pagination-options.ts index 5c920191..d7f50440 100644 --- a/apps/cli/src/util/pagination-options.ts +++ b/apps/cli/src/util/pagination-options.ts @@ -15,7 +15,8 @@ export const PAGINATION_OPTION: CommandOption[] = [ short: '-o', long: '--order ', description: - 'Order to sort by - either ascending (ASC) or descending (DESC).' + 'Order to sort by - either ascending (ASC) or descending (DESC).', + choices: ['ASC', 'DESC'] }, { short: '--sort',