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

refactor(cli): use individual Command instances instead of global program #1130

Merged
merged 3 commits into from
Feb 23, 2023

Conversation

mirceanis
Copy link
Member

@mirceanis mirceanis commented Feb 21, 2023

What issue is this PR fixing

This PR refactors the way commander.js is used in the CLI package.
Instead of a global program command being mutated by different imports, each subcommand is created as an independent instance of a Command object.

The main purpose is to simplify testing, however due to incompatibilities between jest/ESM/chalk/typeorm the tests can't actually be performed using the same testing harness.

A custom jest config would be needed that must only be used on the CLI tests. When enabling the workaround in jestjs/jest#12270 (comment) any tests using typeorm in any way will fail.
This means we'd also need to only use JSON storage or memory storage configs in these CLI tests.

This PR also exports some of the methods used to configure the CLI through yaml.

Quality

Check all that apply:

  • I want these changes to be integrated
  • I successfully ran pnpm i, pnpm build, pnpm test, pnpm test:browser locally.
  • I allow my PR to be updated by the reviewers (to speed up the review process).
  • I added unit tests... but they are skipped for now.
  • I added integration tests.

@codecov
Copy link

codecov bot commented Feb 22, 2023

Codecov Report

Base: 80.25% // Head: 85.45% // Increases project coverage by +5.20% 🎉

Coverage data is based on head (941693a) compared to base (125bf42).
Patch coverage: 83.82% of modified lines in pull request are covered.

❗ Current head 941693a differs from pull request most recent head 85041ef. Consider uploading reports for the commit 85041ef to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #1130      +/-   ##
==========================================
+ Coverage   80.25%   85.45%   +5.20%     
==========================================
  Files         118      145      +27     
  Lines        4056    14906   +10850     
  Branches      875     1561     +686     
==========================================
+ Hits         3255    12738    +9483     
- Misses        798     2168    +1370     
+ Partials        3        0       -3     
Impacted Files Coverage Δ
packages/core-types/src/coreEvents.ts 100.00% <ø> (ø)
...s/credential-ld/src/module-types/jsonld/index.d.ts 0.00% <0.00%> (ø)
packages/data-store-json/src/types.ts 0.00% <0.00%> (ø)
packages/did-comm/src/didcomm.ts 83.26% <ø> (+10.12%) ⬆️
packages/did-comm/src/index.ts 100.00% <ø> (ø)
packages/did-comm/src/message-handler.ts 72.10% <ø> (+12.64%) ⬆️
.../protocols/coordinate-mediation-message-handler.ts 89.63% <ø> (ø)
packages/did-comm/src/protocols/index.ts 100.00% <ø> (ø)
...omm/src/protocols/messagepickup-message-handler.ts 91.25% <ø> (ø)
.../did-comm/src/protocols/routing-message-handler.ts 89.65% <ø> (ø)
... and 209 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mirceanis mirceanis marked this pull request as ready for review February 23, 2023 13:39
@mirceanis mirceanis merged commit 9c73d98 into next Feb 23, 2023
@mirceanis mirceanis deleted the refactor-cli branch February 23, 2023 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants