Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Add workspace operations #441

Merged
merged 2 commits into from
Sep 17, 2024
Merged

feat(cli): Add workspace operations #441

merged 2 commits into from
Sep 17, 2024

Conversation

rajdip-b
Copy link
Member

@rajdip-b rajdip-b commented Sep 17, 2024

User description

Description

  • Add functions to do CRUD operation on workspaces using CLI
  • Made a few changes to API Client package
  • Misc updates to scripts and configs

PR Type

enhancement, documentation


Description

  • Implemented a suite of CLI commands for managing workspaces, including create, delete, export, get, list, search, and update functionalities.
  • Enhanced the base command class to include headers for API requests and initialized a controller instance.
  • Introduced a ControllerInstance class to manage API controllers using a singleton pattern.
  • Added JSDoc comments for better documentation of the decrypt function.
  • Updated API client to export the WorkspaceRoleController.
  • Added ESLint configuration for the API client package.

Changes walkthrough 📝

Relevant files
Enhancement
13 files
base.command.ts
Enhance base command with headers and controller initialization

apps/cli/src/commands/base.command.ts

  • Added headers for API requests.
  • Initialized ControllerInstance.
  • Updated getVersion method to return '1'.
  • +23/-5   
    workspace.command.ts
    Add WorkspaceCommand with subcommands for CLI                       

    apps/cli/src/commands/workspace.command.ts

  • Introduced WorkspaceCommand class.
  • Added subcommands for workspace management.
  • +30/-0   
    create.workspace.ts
    Implement CreateWorkspace command for CLI                               

    apps/cli/src/commands/workspace/create.workspace.ts

  • Added CreateWorkspace command.
  • Implemented workspace creation logic.
  • +71/-0   
    delete.workspace.ts
    Implement DeleteWorkspace command for CLI                               

    apps/cli/src/commands/workspace/delete.workspace.ts

  • Added DeleteWorkspace command.
  • Implemented workspace deletion logic.
  • +44/-0   
    export.workspace.ts
    Implement ExportWorkspace command for CLI                               

    apps/cli/src/commands/workspace/export.workspace.ts

  • Added ExportWorkspace command.
  • Implemented workspace export logic.
  • +68/-0   
    get.workspace.ts
    Implement GetWorkspace command for CLI                                     

    apps/cli/src/commands/workspace/get.workspace.ts

  • Added GetWorkspace command.
  • Implemented logic to fetch workspace details.
  • +50/-0   
    list.workspace.ts
    Implement ListWorkspace command for CLI                                   

    apps/cli/src/commands/workspace/list.workspace.ts

  • Added ListWorkspace command.
  • Implemented logic to list all accessible workspaces.
  • +31/-0   
    search.workspace.ts
    Implement SearchWorkspace command for CLI                               

    apps/cli/src/commands/workspace/search.workspace.ts

  • Added SearchWorkspace command.
  • Implemented full-text search logic for workspace.
  • +79/-0   
    update.workspace.ts
    Implement UpdateWorkspace command for CLI                               

    apps/cli/src/commands/workspace/update.workspace.ts

  • Added UpdateWorkspace command.
  • Implemented logic to update workspace details.
  • +73/-0   
    index.ts
    Register WorkspaceCommand in CLI                                                 

    apps/cli/src/index.ts

    • Added WorkspaceCommand to the CLI commands list.
    +2/-0     
    controller-instance.ts
    Add ControllerInstance for managing API controllers           

    apps/cli/src/util/controller-instance.ts

  • Introduced ControllerInstance class.
  • Added initialization and singleton pattern for controllers.
  • +110/-0 
    index.ts
    Export WorkspaceRoleController in API client                         

    packages/api-client/src/index.ts

    • Added WorkspaceRoleController export.
    +4/-2     
    environment.types.d.ts
    Export Environment interface                                                         

    packages/api-client/src/types/environment.types.d.ts

    • Exported Environment interface.
    +1/-1     
    Documentation
    1 files
    decrypt.ts
    Document decrypt function with JSDoc                                         

    apps/cli/src/util/decrypt.ts

    • Added JSDoc comments for decrypt function.
    +8/-0     
    Configuration changes
    1 files
    .eslintrc.cjs
    Add ESLint configuration for API client                                   

    packages/api-client/.eslintrc.cjs

    • Added ESLint configuration for API client.
    +27/-1   

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Error Handling
    The error message from the API is directly logged without any additional context or user-friendly message.

    Type Safety
    The workspace object is typed as any, which loses type safety. Consider using a more specific type.

    Error Handling
    The error messages for uninitialized controllers are all the same. Consider providing more specific error messages for each controller.

    Copy link
    Contributor

    CI Failure Feedback 🧐

    Action: Validate Cli

    Failed stage: Lint [❌]

    Failed test name: cli#lint

    Failure summary:

    The action failed due to multiple issues:

  • Compilation errors occurred during the installation of the secp256k1 and eccrypto packages. These
    errors were related to the use of deprecated or incompatible functions and types in the nan library
    and OpenSSL 3.0.
  • A linting error was detected in the file src/commands/scan.command.ts due to an unsafe argument of
    type any being assigned to a parameter of a specific type, violating the
    @typescript-eslint/no-unsafe-argument rule.

  • Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    192:  .../node_modules/@sentry/cli postinstall$ node ./scripts/install.js
    193:  .../sharp@0.33.5/node_modules/sharp install$ node install/check
    194:  .../node_modules/@sentry/profiling-node install$ node scripts/check-build.js
    195:  .../node_modules/@swc/core postinstall: Done
    196:  .../node_modules/@nestjs/core postinstall$ opencollective || exit 0
    197:  .../node_modules/nice-napi install: Done
    198:  .../node_modules/@sentry/cli postinstall: Done
    199:  .../node_modules/@prisma/engines postinstall$ node scripts/postinstall.js
    200:  .../node_modules/secp256k1 install$ npm run rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."
    ...
    
    249:  .../node_modules/secp256k1 install: gyp info spawn args '-Goutput_dir=.'
    250:  .../node_modules/secp256k1 install: gyp info spawn args ]
    251:  .../node_modules/secp256k1 install: gyp info spawn make
    252:  .../node_modules/secp256k1 install: gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    253:  .../node_modules/secp256k1 install: make: Entering directory '/home/runner/work/keyshade/keyshade/node_modules/.pnpm/secp256k1@3.7.1/node_modules/secp256k1/build'
    254:  .../node_modules/secp256k1 install:   CXX(target) Release/obj.target/secp256k1/src/addon.o
    255:  .../node_modules/secp256k1 install: In file included from ../../../../nan@2.14.0/node_modules/nan/nan.h:174,
    256:  .../node_modules/secp256k1 install:                  from ../src/addon.cc:2:
    257:  .../node_modules/secp256k1 install: ../../../../nan@2.14.0/node_modules/nan/nan_callbacks.h:55:23: error: ‘AccessorSignature’ is not a member of ‘v8’
    258:  .../node_modules/secp256k1 install:    55 | typedef v8::Local<v8::AccessorSignature> Sig;
    259:  .../node_modules/secp256k1 install:       |                       ^~~~~~~~~~~~~~~~~
    260:  .../node_modules/secp256k1 install: ../../../../nan@2.14.0/node_modules/nan/nan_callbacks.h:55:40: error: template argument 1 is invalid
    261:  .../node_modules/secp256k1 install:    55 | typedef v8::Local<v8::AccessorSignature> Sig;
    262:  .../node_modules/secp256k1 install:       |                                        ^
    263:  .../node_modules/secp256k1 install: In file included from ../src/addon.cc:2:
    264:  .../node_modules/secp256k1 install: ../../../../nan@2.14.0/node_modules/nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
    265:  .../node_modules/secp256k1 install: ../../../../nan@2.14.0/node_modules/nan/nan.h:2298:7: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
    266:  .../node_modules/secp256k1 install:  2298 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
    267:  .../node_modules/secp256k1 install:       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    268:  .../node_modules/secp256k1 install: ../../../../nan@2.14.0/node_modules/nan/nan.h: In function ‘void Nan::SetAccessor(v8::Local<v8::ObjectTemplate>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, Nan::imp::Sig)’:
    269:  .../node_modules/secp256k1 install: ../../../../nan@2.14.0/node_modules/nan/nan.h:2536:19: error: no matching function for call to ‘v8::ObjectTemplate::SetAccessor(v8::Local<v8::String>&, void (*&)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&), void (*&)(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&), v8::Local<v8::Object>&, v8::AccessControl&, v8::PropertyAttribute&, Nan::imp::Sig&)’
    ...
    
    297:  .../node_modules/secp256k1 install:   816 |   void SetAccessor(
    298:  .../node_modules/secp256k1 install:       |        ^~~~~~~~~~~
    299:  .../node_modules/secp256k1 install: /home/runner/.cache/node-gyp/20.17.0/include/node/v8-template.h:821:22: note:   no known conversion for argument 7 from ‘Nan::imp::Sig’ {aka ‘int’} to ‘v8::SideEffectType’
    300:  .../node_modules/secp256k1 install:   821 |       SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
    301:  .../node_modules/secp256k1 install:       |       ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    302:  .../node_modules/secp256k1 install: In file included from ../../../../nan@2.14.0/node_modules/nan/nan.h:2884,
    303:  .../node_modules/secp256k1 install:                  from ../src/addon.cc:2:
    304:  .../node_modules/secp256k1 install: ../../../../nan@2.14.0/node_modules/nan/nan_typedarray_contents.h: In constructor ‘Nan::TypedArrayContents<T>::TypedArrayContents(v8::Local<v8::Value>)’:
    305:  .../node_modules/secp256k1 install: ../../../../nan@2.14.0/node_modules/nan/nan_typedarray_contents.h:34:43: error: ‘class v8::ArrayBuffer’ has no member named ‘GetContents’
    ...
    
    311:  .../node_modules/secp256k1 install:  1232 |       (node::addon_register_func) (regfunc),                          \
    312:  .../node_modules/secp256k1 install:       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    313:  .../node_modules/secp256k1 install: /home/runner/.cache/node-gyp/20.17.0/include/node/node.h:1266:3: note: in expansion of macro ‘NODE_MODULE_X’
    314:  .../node_modules/secp256k1 install:  1266 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
    315:  .../node_modules/secp256k1 install:       |   ^~~~~~~~~~~~~
    316:  .../node_modules/secp256k1 install: ../src/addon.cc:50:1: note: in expansion of macro ‘NODE_MODULE’
    317:  .../node_modules/secp256k1 install:    50 | NODE_MODULE(secp256k1, Init)
    318:  .../node_modules/secp256k1 install:       | ^~~~~~~~~~~
    319:  .../node_modules/secp256k1 install: make: *** [secp256k1.target.mk:160: Release/obj.target/secp256k1/src/addon.o] Error 1
    320:  .../node_modules/secp256k1 install: make: Leaving directory '/home/runner/work/keyshade/keyshade/node_modules/.pnpm/secp256k1@3.7.1/node_modules/secp256k1/build'
    321:  .../node_modules/secp256k1 install: gyp ERR! build error 
    322:  .../node_modules/secp256k1 install: gyp ERR! stack Error: `make` failed with exit code: 2
    323:  .../node_modules/secp256k1 install: gyp ERR! stack at ChildProcess.<anonymous> (/home/runner/work/keyshade/keyshade/node_modules/.pnpm/npm@10.8.3/node_modules/npm/node_modules/node-gyp/lib/build.js:216:23)
    324:  .../node_modules/secp256k1 install: gyp ERR! System Linux 6.5.0-1025-azure
    325:  .../node_modules/secp256k1 install: gyp ERR! command "/opt/hostedtoolcache/node/20.17.0/x64/bin/node" "/home/runner/work/keyshade/keyshade/node_modules/.pnpm/npm@10.8.3/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    326:  .../node_modules/secp256k1 install: gyp ERR! cwd /home/runner/work/keyshade/keyshade/node_modules/.pnpm/secp256k1@3.7.1/node_modules/secp256k1
    327:  .../node_modules/secp256k1 install: gyp ERR! node -v v20.17.0
    328:  .../node_modules/secp256k1 install: gyp ERR! node-gyp -v v10.2.0
    329:  .../node_modules/secp256k1 install: gyp ERR! not ok 
    330:  .../node_modules/secp256k1 install: Secp256k1 bindings compilation fail. Pure JS implementation will be used.
    ...
    
    362:  .../eccrypto@1.1.6/node_modules/eccrypto install: gyp info spawn args '-Goutput_dir=.'
    363:  .../eccrypto@1.1.6/node_modules/eccrypto install: gyp info spawn args ]
    364:  .../eccrypto@1.1.6/node_modules/eccrypto install: gyp info spawn make
    365:  .../eccrypto@1.1.6/node_modules/eccrypto install: gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    366:  .../eccrypto@1.1.6/node_modules/eccrypto install: make: Entering directory '/home/runner/work/keyshade/keyshade/node_modules/.pnpm/eccrypto@1.1.6/node_modules/eccrypto/build'
    367:  .../eccrypto@1.1.6/node_modules/eccrypto install:   CXX(target) Release/obj.target/ecdh/ecdh.o
    368:  .../eccrypto@1.1.6/node_modules/eccrypto install: In file included from ../../../../nan@2.14.0/node_modules/nan/nan.h:174,
    369:  .../eccrypto@1.1.6/node_modules/eccrypto install:                  from ../ecdh.cc:2:
    370:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../../../../nan@2.14.0/node_modules/nan/nan_callbacks.h:55:23: error: ‘AccessorSignature’ is not a member of ‘v8’
    371:  .../eccrypto@1.1.6/node_modules/eccrypto install:    55 | typedef v8::Local<v8::AccessorSignature> Sig;
    372:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |                       ^~~~~~~~~~~~~~~~~
    373:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../../../../nan@2.14.0/node_modules/nan/nan_callbacks.h:55:40: error: template argument 1 is invalid
    374:  .../eccrypto@1.1.6/node_modules/eccrypto install:    55 | typedef v8::Local<v8::AccessorSignature> Sig;
    375:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |                                        ^
    376:  .../eccrypto@1.1.6/node_modules/eccrypto install: In file included from ../ecdh.cc:2:
    377:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../../../../nan@2.14.0/node_modules/nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
    378:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../../../../nan@2.14.0/node_modules/nan/nan.h:2298:7: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
    379:  .../eccrypto@1.1.6/node_modules/eccrypto install:  2298 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
    380:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    381:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../../../../nan@2.14.0/node_modules/nan/nan.h: In function ‘void Nan::SetAccessor(v8::Local<v8::ObjectTemplate>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, Nan::imp::Sig)’:
    382:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../../../../nan@2.14.0/node_modules/nan/nan.h:2536:19: error: no matching function for call to ‘v8::ObjectTemplate::SetAccessor(v8::Local<v8::String>&, void (*&)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&), void (*&)(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&), v8::Local<v8::Object>&, v8::AccessControl&, v8::PropertyAttribute&, Nan::imp::Sig&)’
    ...
    
    410:  .../eccrypto@1.1.6/node_modules/eccrypto install:   816 |   void SetAccessor(
    411:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |        ^~~~~~~~~~~
    412:  .../eccrypto@1.1.6/node_modules/eccrypto install: /home/runner/.cache/node-gyp/20.17.0/include/node/v8-template.h:821:22: note:   no known conversion for argument 7 from ‘Nan::imp::Sig’ {aka ‘int’} to ‘v8::SideEffectType’
    413:  .../eccrypto@1.1.6/node_modules/eccrypto install:   821 |       SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
    414:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |       ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    415:  .../eccrypto@1.1.6/node_modules/eccrypto install: In file included from ../../../../nan@2.14.0/node_modules/nan/nan.h:2884,
    416:  .../eccrypto@1.1.6/node_modules/eccrypto install:                  from ../ecdh.cc:2:
    417:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../../../../nan@2.14.0/node_modules/nan/nan_typedarray_contents.h: In constructor ‘Nan::TypedArrayContents<T>::TypedArrayContents(v8::Local<v8::Value>)’:
    418:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../../../../nan@2.14.0/node_modules/nan/nan_typedarray_contents.h:34:43: error: ‘class v8::ArrayBuffer’ has no member named ‘GetContents’
    419:  .../eccrypto@1.1.6/node_modules/eccrypto install:    34 |       data   = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
    420:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |                                           ^~~~~~~~~~~
    421:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc: In function ‘int derive(const uint8_t*, const uint8_t*, uint8_t*)’:
    422:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc:37:41: warning: ‘EC_KEY* EC_KEY_new_by_curve_name(int)’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
    423:  .../eccrypto@1.1.6/node_modules/eccrypto install:    37 |   CHECK((pkey = EC_KEY_new_by_curve_name(NID_secp256k1)) != NULL);
    424:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |                 ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
    425:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc:14:32: note: in definition of macro ‘CHECK’
    426:  .../eccrypto@1.1.6/node_modules/eccrypto install:    14 | #define CHECK(cond) do { if (!(cond)) goto error; } while (0)
    ...
    
    428:  .../eccrypto@1.1.6/node_modules/eccrypto install: In file included from ../ecdh.cc:4:
    429:  .../eccrypto@1.1.6/node_modules/eccrypto install: /home/runner/.cache/node-gyp/20.17.0/include/node/openssl/ec.h:998:31: note: declared here
    430:  .../eccrypto@1.1.6/node_modules/eccrypto install:   998 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_by_curve_name(int nid);
    431:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |                               ^~~~~~~~~~~~~~~~~~~~~~~~
    432:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc:38:31: warning: ‘int EC_KEY_set_private_key(EC_KEY*, const BIGNUM*)’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
    433:  .../eccrypto@1.1.6/node_modules/eccrypto install:    38 |   CHECK(EC_KEY_set_private_key(pkey, pkey_bn) == 1);
    434:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
    435:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc:14:32: note: in definition of macro ‘CHECK’
    436:  .../eccrypto@1.1.6/node_modules/eccrypto install:    14 | #define CHECK(cond) do { if (!(cond)) goto error; } while (0)
    ...
    
    438:  .../eccrypto@1.1.6/node_modules/eccrypto install: In file included from ../ecdh.cc:4:
    439:  .../eccrypto@1.1.6/node_modules/eccrypto install: /home/runner/.cache/node-gyp/20.17.0/include/node/openssl/ec.h:1056:27: note: declared here
    440:  .../eccrypto@1.1.6/node_modules/eccrypto install:  1056 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
    441:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |                           ^~~~~~~~~~~~~~~~~~~~~~
    442:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc:40:29: warning: ‘int EVP_PKEY_set1_EC_KEY(EVP_PKEY*, ec_key_st*)’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
    443:  .../eccrypto@1.1.6/node_modules/eccrypto install:    40 |   CHECK(EVP_PKEY_set1_EC_KEY(evp_pkey, pkey) == 1);
    444:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |         ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
    445:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc:14:32: note: in definition of macro ‘CHECK’
    446:  .../eccrypto@1.1.6/node_modules/eccrypto install:    14 | #define CHECK(cond) do { if (!(cond)) goto error; } while (0)
    ...
    
    448:  .../eccrypto@1.1.6/node_modules/eccrypto install: In file included from ../ecdh.cc:3:
    449:  .../eccrypto@1.1.6/node_modules/eccrypto install: /home/runner/.cache/node-gyp/20.17.0/include/node/openssl/evp.h:1372:5: note: declared here
    450:  .../eccrypto@1.1.6/node_modules/eccrypto install:  1372 | int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);
    451:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |     ^~~~~~~~~~~~~~~~~~~~
    452:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc:43:44: warning: ‘EC_KEY* EC_KEY_new_by_curve_name(int)’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
    453:  .../eccrypto@1.1.6/node_modules/eccrypto install:    43 |   CHECK((peerkey = EC_KEY_new_by_curve_name(NID_secp256k1)) != NULL);
    454:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |                    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
    455:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc:14:32: note: in definition of macro ‘CHECK’
    456:  .../eccrypto@1.1.6/node_modules/eccrypto install:    14 | #define CHECK(cond) do { if (!(cond)) goto error; } while (0)
    ...
    
    491:  .../eccrypto@1.1.6/node_modules/eccrypto install: In file included from ../ecdh.cc:4:
    492:  .../eccrypto@1.1.6/node_modules/eccrypto install: /home/runner/.cache/node-gyp/20.17.0/include/node/openssl/ec.h:1122:27: note: declared here
    493:  .../eccrypto@1.1.6/node_modules/eccrypto install:  1122 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key,
    494:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    495:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc:69:29: warning: ‘int EVP_PKEY_set1_EC_KEY(EVP_PKEY*, ec_key_st*)’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
    496:  .../eccrypto@1.1.6/node_modules/eccrypto install:    69 |   CHECK(EVP_PKEY_set1_EC_KEY(evp_peerkey, peerkey) == 1);
    497:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |         ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
    498:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc:14:32: note: in definition of macro ‘CHECK’
    499:  .../eccrypto@1.1.6/node_modules/eccrypto install:    14 | #define CHECK(cond) do { if (!(cond)) goto error; } while (0)
    ...
    
    522:  .../eccrypto@1.1.6/node_modules/eccrypto install:  1232 |       (node::addon_register_func) (regfunc),                          \
    523:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    524:  .../eccrypto@1.1.6/node_modules/eccrypto install: /home/runner/.cache/node-gyp/20.17.0/include/node/node.h:1266:3: note: in expansion of macro ‘NODE_MODULE_X’
    525:  .../eccrypto@1.1.6/node_modules/eccrypto install:  1266 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
    526:  .../eccrypto@1.1.6/node_modules/eccrypto install:       |   ^~~~~~~~~~~~~
    527:  .../eccrypto@1.1.6/node_modules/eccrypto install: ../ecdh.cc:131:1: note: in expansion of macro ‘NODE_MODULE’
    528:  .../eccrypto@1.1.6/node_modules/eccrypto install:   131 | NODE_MODULE(ecdh, InitAll)
    529:  .../eccrypto@1.1.6/node_modules/eccrypto install:       | ^~~~~~~~~~~
    530:  .../eccrypto@1.1.6/node_modules/eccrypto install: make: *** [ecdh.target.mk:114: Release/obj.target/ecdh/ecdh.o] Error 1
    531:  .../eccrypto@1.1.6/node_modules/eccrypto install: make: Leaving directory '/home/runner/work/keyshade/keyshade/node_modules/.pnpm/eccrypto@1.1.6/node_modules/eccrypto/build'
    532:  .../eccrypto@1.1.6/node_modules/eccrypto install: gyp ERR! build error 
    533:  .../eccrypto@1.1.6/node_modules/eccrypto install: gyp ERR! stack Error: `make` failed with exit code: 2
    ...
    
    605:  This information is used to shape the Turborepo roadmap and prioritize features.
    606:  You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
    607:  https://turbo.build/repo/docs/telemetry
    608:  • Packages in scope: cli
    609:  • Running lint in 1 packages
    610:  • Remote caching disabled
    611:  �[;31mcli:lint�[;0m
    612:  cache miss, executing 896bac958183f1cd
    613:  ##[error]cli#lint: command (/home/runner/work/keyshade/keyshade/apps/cli) /home/runner/setup-pnpm/node_modules/.bin/pnpm run lint exited (1)
    614:  > cli@1.0.0 lint /home/runner/work/keyshade/keyshade/apps/cli
    615:  > eslint "src/**/*.ts" --fix
    616:  /home/runner/work/keyshade/keyshade/apps/cli/src/commands/scan.command.ts
    617:  ##[error]  88:40  error  Unsafe argument of type `any` assigned to a parameter of type `{ [Symbol.match](string: string): RegExpMatchArray; }`  @typescript-eslint/no-unsafe-argument
    618:  ✖ 1 problem (1 error, 0 warnings)
    619:  ELIFECYCLE  Command failed with exit code 1.
    620:  [ERROR] command finished with error: command (/home/runner/work/keyshade/keyshade/apps/cli) /home/runner/setup-pnpm/node_modules/.bin/pnpm run lint exited (1)
    621:  Tasks:    0 successful, 1 total
    622:  Cached:    0 cached, 1 total
    623:  Time:    5.426s 
    624:  Failed:    cli#lint
    625:  ERROR  run failed: command  exited (1)
    626:  ELIFECYCLE  Command failed with exit code 1.
    627:  ##[error]Process completed with exit code 1.
    

    ✨ CI feedback usage guide:

    The CI feedback tool (/checks) automatically triggers when a PR has a failed check.
    The tool analyzes the failed checks and provides several feedbacks:

    • Failed stage
    • Failed test name
    • Failure summary
    • Relevant error logs

    In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:

    /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"
    

    where {repo_name} is the name of the repository, {run_number} is the run number of the failed check, and {job_number} is the job number of the failed check.

    Configuration options

    • enable_auto_checks_feedback - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
    • excluded_checks_list - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
    • enable_help_text - if set to true, the tool will provide a help message with the feedback. Default is true.
    • persistent_comment - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.
    • final_update_message - if persistent_comment is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true.

    See more information about the checks tool in the docs.

    Copy link
    Contributor

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Error handling
    Add error handling for file writing operations

    Consider adding error handling for file writing operations to handle potential
    issues like permission errors or disk space limitations.

    apps/cli/src/commands/workspace/export.workspace.ts [54-63]

     if (saveToFile) {
       const filePath = saveToFile
       const fileContent = JSON.stringify(data, null, 2)
     
    -  writeFileSync(saveToFile, fileContent)
    -
    -  Logger.info(`Workspace exported to file: ${filePath}`)
    +  try {
    +    writeFileSync(saveToFile, fileContent)
    +    Logger.info(`Workspace exported to file: ${filePath}`)
    +  } catch (error) {
    +    Logger.error(`Failed to write to file: ${error.message}`)
    +  }
     } else {
       Logger.info(JSON.stringify(data))
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: Implementing error handling for file writing operations is crucial to prevent application crashes and provide informative feedback to users in case of issues like permission errors or disk space limitations.

    9
    Enhancement
    Implement pagination for listing workspaces

    Consider adding pagination support to handle potentially large lists of workspaces
    more efficiently.

    apps/cli/src/commands/workspace/list.workspace.ts [17-29]

    -const { success, data, error } =
    -  await ControllerInstance.getInstance().workspaceController.getWorkspacesOfUser(
    -    {},
    -    this.headers
    -  )
    +const pageSize = 10 // Or any other suitable page size
    +let page = 1
    +let hasMore = true
     
    -if (success) {
    -  data.items.forEach((workspace: any) => {
    -    Logger.info(`- ${workspace.name} (${workspace.slug})`)
    -  })
    -} else {
    -  Logger.error(`Failed fetching workspaces: ${error.message}`)
    +while (hasMore) {
    +  const { success, data, error } =
    +    await ControllerInstance.getInstance().workspaceController.getWorkspacesOfUser(
    +      { page, pageSize },
    +      this.headers
    +    )
    +
    +  if (success) {
    +    data.items.forEach((workspace: any) => {
    +      Logger.info(`- ${workspace.name} (${workspace.slug})`)
    +    })
    +    hasMore = data.items.length === pageSize
    +    page++
    +  } else {
    +    Logger.error(`Failed fetching workspaces: ${error.message}`)
    +    break
    +  }
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding pagination support is important for efficiently handling large datasets, improving performance, and enhancing user experience by preventing overwhelming amounts of data being processed at once.

    8
    Add input validation for the workspace name

    Consider adding input validation for the workspace name to ensure it meets any
    required criteria (e.g., length, allowed characters).

    apps/cli/src/commands/workspace/create.workspace.ts [63-67]

     if (!name) {
       name = await text({
         message: 'Enter the name of the Workspace',
    -    placeholder: 'My Workspace'
    +    placeholder: 'My Workspace',
    +    validate: (input) => {
    +      if (input.length < 3 || input.length > 50) {
    +        return 'Workspace name must be between 3 and 50 characters'
    +      }
    +      if (!/^[a-zA-Z0-9\s-]+$/.test(input)) {
    +        return 'Workspace name can only contain alphanumeric characters, spaces, and hyphens'
    +      }
    +      return true
    +    }
       })
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Adding input validation for the workspace name improves user experience by preventing invalid inputs and ensuring data consistency. This is a useful enhancement but not critical for functionality.

    7
    Add a check for empty search results

    Consider adding a check for empty search results and provide a user-friendly message
    in such cases.

    apps/cli/src/commands/workspace/search.workspace.ts [44-75]

     if (success) {
    -  Logger.info('Search results:')
    +  const totalResults = data.projects.length + data.environments.length + data.variables.length + data.secrets.length
     
    -  Logger.info('')
    +  if (totalResults === 0) {
    +    Logger.info('No results found for the given search term.')
    +  } else {
    +    Logger.info('Search results:')
     
    -  Logger.info(`Projects (${data.projects.length})`)
    -  data.projects.forEach((project) => {
    -    Logger.info(`- ${project.name} (${project.id})`)
    -  })
    +    Logger.info('')
     
    -  Logger.info('')
    +    Logger.info(`Projects (${data.projects.length})`)
    +    data.projects.forEach((project) => {
    +      Logger.info(`- ${project.name} (${project.id})`)
    +    })
     
    -  Logger.info(`Environments (${data.environments.length})`)
    -  data.environments.forEach((environment) => {
    -    Logger.info(`- ${environment.name} (${environment.id})`)
    -  })
    +    Logger.info('')
     
    -  Logger.info('')
    +    Logger.info(`Environments (${data.environments.length})`)
    +    data.environments.forEach((environment) => {
    +      Logger.info(`- ${environment.name} (${environment.id})`)
    +    })
     
    -  Logger.info(`Variables (${data.variables.length})`)
    -  data.variables.forEach((variable) => {
    -    Logger.info(`- ${variable.name} (${variable.id})`)
    -  })
    +    Logger.info('')
     
    -  Logger.info('')
    +    Logger.info(`Variables (${data.variables.length})`)
    +    data.variables.forEach((variable) => {
    +      Logger.info(`- ${variable.name} (${variable.id})`)
    +    })
     
    -  Logger.info(`Secrets (${data.secrets.length})`)
    -  data.secrets.forEach((secret) => {
    -    Logger.info(`- ${secret.name} (${secret.id})`)
    -  })
    +    Logger.info('')
     
    -  Logger.info('')
    +    Logger.info(`Secrets (${data.secrets.length})`)
    +    data.secrets.forEach((secret) => {
    +      Logger.info(`- ${secret.name} (${secret.id})`)
    +    })
    +
    +    Logger.info('')
    +  }
     } else {
       Logger.error(`Failed searching in workspace: ${error.message}`)
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: Providing a user-friendly message for empty search results enhances user experience by clearly communicating the outcome of their search, although it does not impact the core functionality of the search feature.

    6

    💡 Need additional feedback ? start a PR chat

    @rajdip-b rajdip-b merged commit ed38d22 into develop Sep 17, 2024
    5 checks passed
    @rajdip-b rajdip-b deleted the cli/workspace branch September 17, 2024 15:09
    Kiranchaudhary537 pushed a commit to Kiranchaudhary537/keyshade that referenced this pull request Oct 13, 2024
    rajdip-b pushed a commit that referenced this pull request Oct 24, 2024
    ## [2.6.0](v2.5.0...v2.6.0) (2024-10-24)
    
    ### 🚀 Features
    
    * **api:**  Add icon and remove description field from workspace ([#435](#435)) ([a99c0db](a99c0db))
    * **api-client:** Added workspace-membership and related tests ([#452](#452)) ([6a1c091](6a1c091))
    * **api-client:** Create controller for User module ([#484](#484)) ([f9d8e83](f9d8e83))
    * **api:** Add prod env schema in env file ([#436](#436)) ([21c3004](21c3004))
    * **api:** Add resend otp implementation ([#445](#445)) ([4dc6aa1](4dc6aa1))
    * **api:** Fetch total count of environments, [secure]s and variables in project ([#434](#434)) ([0c9e50a](0c9e50a))
    * **api:** Replace `projectId` with `name` and `slug` in workspace-role response.  ([#432](#432)) ([af06071](af06071))
    * **cli:** Add functionality to operate on Secrets ([#504](#504)) ([1b4bf2f](1b4bf2f))
    * **cli:** Add project command ([#451](#451)) ([70448e1](70448e1))
    * **cli:** Add workspace operations ([#441](#441)) ([ed38d22](ed38d22))
    * **cli:** implement commands to get, list, update, and delete, workspace roles ([#469](#469)) ([957ea8d](957ea8d))
    * **cli:** Implemented pagination support ([#453](#453)) ([feb1806](feb1806))
    * **cli:** Secret scan ([#438](#438)) ([85cb8ab](85cb8ab))
    * **cli:** Update environment command outputs ([f4af874](f4af874))
    * **platform:** Clearing email field after waitlisting the user email ([#481](#481)) ([256d659](256d659))
    * Remove project IDs from workspace role export data and update tests ([#448](#448)) ([8fdb328](8fdb328))
    * **web:** Configured extra check for waitlisted users already in the list and created toast message for them ([#492](#492)) ([2ddd0ef](2ddd0ef))
    * **web:** show the toast only when email add successfully ([#490](#490)) ([783c411](783c411))
    
    ### 🐛 Bug Fixes
    
    * **api,api-client:** Add environmentSlug in multiple places across the variable module ([#468](#468)) ([d970aff](d970aff))
    * **api:** Replace the id with slug in the global-search service ([#455](#455)) ([74804b1](74804b1))
    * **platform:** Fixed duplicate Google Logo UI fix  ([#450](#450)) ([fb0d6f7](fb0d6f7))
    * resolve footer website name cut-off or overlap issue ([#444](#444)) ([fe03ba2](fe03ba2))
    * **web:** Horizontal Scrolling issue on the website ([#440](#440)) ([655177b](655177b))
    
    ### 📚 Documentation
    
    * Add documentation for environment in CLI ([#462](#462)) ([dad7394](dad7394))
    * Add documentation for project in CLI ([#466](#466)) ([341fb32](341fb32))
    * Add documentation for scan in CLI ([#461](#461)) ([72281e6](72281e6))
    * Add documentation for workspace command ([#464](#464)) ([4aad8a2](4aad8a2))
    * Add instructions for resetting the local Prisma database ([#495](#495)) ([#501](#501)) ([b07ea17](b07ea17))
    * Added docker support documentation ([#465](#465)) ([bc04be4](bc04be4))
    * Added documentation for running the platform ([#473](#473)) ([8b8386b](8b8386b))
    * Added missing mappings to pages ([5de9fd8](5de9fd8))
    * Fix Documentation Hyperlink and update expired Discord invite link ([#496](#496)) ([5a10e39](5a10e39))
    * Updated CLI docs ([#460](#460)) ([c7e0f13](c7e0f13))
    
    ### 🔧 Miscellaneous Chores
    
    * Add more logging to Sentry init ([#470](#470)) ([de4925d](de4925d))
    * **api:** Optimise API docker image size ([#360](#360)) ([ea40dc1](ea40dc1))
    * **api:** Updated lockfile ([a968e78](a968e78))
    * **CI:** Add [secure] scan validation ([f441262](f441262))
    * **cli:** Update controller invocation in environment commands ([#477](#477)) ([596bd1a](596bd1a))
    * Minor changes to variables ([fe01ca6](fe01ca6))
    * **[secure]-scan:** Failing lint issues ([#507](#507)) ([48f45df](48f45df))
    * **[secure]-scan:** Formatted files ([5884833](5884833))
    * Update .env.example ([70ad4f7](70ad4f7))
    * Updated scripts ([9eb76a7](9eb76a7))
    * **web:** email validation ([#487](#487)) ([e8e737a](e8e737a))
    @rajdip-b
    Copy link
    Member Author

    🎉 This PR is included in version 2.6.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant