Skip to content

Migrate to @oclif/core v4 and drop deprecated @oclif packages - #49

Open
paulgnz wants to merge 1 commit into
XPRNetwork:masterfrom
paulgnz:chore/oclif-v4
Open

paulgnz wants to merge 1 commit into
XPRNetwork:masterfrom
paulgnz:chore/oclif-v4

Conversation

@paulgnz

@paulgnz paulgnz commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Moves the CLI from the deprecated @oclif/command / @oclif/config / @oclif/parser (oclif v1) to @oclif/core v4. It also fixes the test suite, which doesn't load on Node 22+ because @oclif/test@1 relies on module.parent.

This is the second of the smaller PRs replacing #41, rebased onto current master including the #45/#46 msig work.

Commands

  • Every command now uses v4 APIs: Args.* / Flags.* in object form, and await this.parse(...).
  • CliUx.ux.* calls go through src/utils/ux.ts, which keeps the old methods (log, styledJSON, prompt, confirm, url, table) so command bodies barely change.
  • 13 commands that never called this.parse now do. v4 expects it and otherwise warns in dev/test runs.
  • bin/dev now uses execute({development: true}). bin/run is unchanged and works as-is.

Packaging

  • @oclif/plugin-help is bumped to v6 and kept in dependencies, since it's listed in oclif.plugins.
  • engines.node is >=18, matching @oclif/core v4.

Tests: the existing test bodies are unchanged.

  • @oclif/test@1 was fancy-test plus a .command() plugin, and @oclif/test@4 drops that chainable API. test/helpers/oclif.ts re-registers .command() on v4 (pinned to fancy-test@1 so .stub() behaves the same), and the 7 test files only change their import.
  • Two --level assertions now match v4's wording ("Nonexistent flag: --level" instead of "Unexpected argument"). The behavior is the same.
  • permission.test.ts stubs prompt on the ux module instead of CliUx.ux.

Lint: .eslintrc adds @oclif/core to allowModules for node/no-missing-import. eslint-plugin-node@11 doesn't read package exports, and @oclif/core v4 has no main. The default tryExtensions are kept.

Testing

  • nyc mocha "test/**/*.test.ts": 82 passing on Node 18, 20 and 22. On master, Node 22 fails to load the suite at all.
  • Combined with Add behavior tests for key commands and reveal-password storage #48's tests: 98 passing on Node 22. The two PRs don't depend on each other's merge order.
  • npm run build, npm pack, then a clean install of the tarball. Ran version, --help, help msig, key:list, msig:approve --help and chain:list from the installed binary with NODE_ENV unset; all exit 0.
  • Deprecation warnings on a clean install: 17 → 8, and 9 → 0 from @oclif/*. The remaining 8 come through @proton/api, @proton/js and nyc.
  • tsc --noEmit is clean. Hand-migrated files lint with 0 errors. Repo-wide posttest lint still fails as it does on master, from pre-existing issues.

Notes

  • I didn't regenerate the README. npm run build rewrites it with v4's help formatting (~250 lines), and the next version bump will do that anyway.
  • Args use help:, which both v1 and v4 ignore, so argument descriptions have never appeared in --help. Switching to description: would fix that, but it's left for a follow-up to keep this PR a pure migration.

@oclif/command, @oclif/config and @oclif/parser are deprecated, and
@oclif/test@1 can't load on Node 22+ (module.parent is undefined), so
the test suite only ran on Node 20 and below.

- All commands move to @oclif/core v4: args use Args.*, flags use
  Flags.*, and parse is awaited. CliUx.ux calls go through a small
  src/utils/ux.ts module that keeps the old method surface
  (log, styledJSON, prompt, confirm, url, table).
- Commands that never called this.parse now do, which v4 expects.
- bin/dev uses @oclif/core's execute({development: true}).
- @oclif/plugin-help v6 stays a runtime dependency (it's in
  oclif.plugins); engines.node is >=18 to match @oclif/core v4.
- Tests: @oclif/test@1 was fancy-test plus a .command() plugin.
  test/helpers/oclif.ts re-registers .command() on top of v4 with
  fancy-test@1, so the existing tests only change their import.
  Two --level assertions match v4's "Nonexistent flag" wording, and
  the permission test stubs the ux module's prompt.
- .eslintrc: allow @oclif/core in node/no-missing-import, since
  eslint-plugin-node@11 doesn't read package "exports".

Claude-Session: https://claude.ai/code/session_01PsSVdfBGzbRD6i9BwVosdN
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.

1 participant