Skip to content

Make ocean-cli globally installable as @oceanprotocol/cli#164

Open
alexcos20 wants to merge 11 commits into
feature/servicesfrom
feature/cli_global
Open

Make ocean-cli globally installable as @oceanprotocol/cli#164
alexcos20 wants to merge 11 commits into
feature/servicesfrom
feature/cli_global

Conversation

@alexcos20

@alexcos20 alexcos20 commented Jul 24, 2026

Copy link
Copy Markdown
Member

Closes #50

Make ocean-cli globally installable as @oceanprotocol/cli

Publishes the CLI to npm so users can install it once and run ocean-cli from
anywhere, instead of only from a checkout via npm run cli:

npm install -g @oceanprotocol/cli
ocean-cli h
ocean-cli publish metadata/simpleDownloadDataset.json
  • Package name: @oceanprotocol/cli (scoped, published with public access).
  • Bin name: ocean-cli (unchanged user-facing command; independent of the package name).
  • REPL stays the default — running ocean-cli runs the command you pass (if any) and then keeps reading further commands interactively, Claude-Code-style. Exit with exit/quit, ESC, or CTRL-C. AVOID_LOOP_RUN=true still forces one-shot mode for CI/scripting.

Why

The compiled CLI could only run from the project root, had no npm bin, no
publish whitelist, a taken unscoped name, and it hard-crashed on --help when no
env vars were set — none of which is acceptable for a globally installed tool.

Changes

Code — location independence & packaging

  • src/helpers.ts — the ERC20 template ABI was read from a cwd-relative
    ./node_modules/... path at module load, crashing with ENOENT from any other
    directory. Now resolved through the module system
    (createRequire(import.meta.url).resolve(...)) so it's found inside the installed
    package tree regardless of cwd. This also fixes a latent bug: the value was a raw
    string but is used as ERC20Template.abi — it's now JSON.parsed, so .abi
    actually resolves.
  • src/index.ts — added the #!/usr/bin/env node shebang (line 1) so npm's
    bin produces a working executable (tsc preserves it into dist/index.js).
  • package.jsonname@oceanprotocol/cli; added bin
    (ocean-clidist/index.js), files (dist, metadata, README.md),
    repository, publishConfig.access: public, and a prepublishOnly: npm run build
    so every tarball ships a fresh dist/.
  • ESM .js extension fixessrc/policyServerHelper.ts and
    src/interactiveFlow.ts imported relative modules without the mandatory .js
    extension. The policyServerInterfaces one emitted a runtime import that made the
    compiled CLI fail to load under Node (ERR_MODULE_NOT_FOUND) — masked in dev
    because tsx is extension-lenient, but fatal for a global install. Both fixed.

Code — first-run UX & version

  • src/cli.ts — env-var validation and the P2P/libp2p bootstrap are now
    skipped for pure help/version invocations (--help/-h/--version/-V/h/help),
    detected from process.argv. Every real command still validates, with the three
    error messages and their order byte-identical (keys → RPC → NODE_URL), as
    asserted by test/setup.test.ts. The CLI --version now reads from
    package.json (createRequire(...)("../package.json").version) instead of a
    hardcoded "2.0.0", so it can't drift.
  • src/index.ts--version/-V now print and exit cleanly (alongside the
    existing --help handling) rather than dropping into the REPL.

Code — REPL polish (default behavior unchanged)

  • stripNpmPrefix now also strips a leading ocean-cli token, so examples pasted
    from either the contributor docs (npm run cli …) or the global-install docs
    (ocean-cli …) work verbatim in interactive mode.
  • ESC now exits the loop on a TTY (via a keypress listener, guarded by
    input.isTTY so piped stdin in tests/scripts is unaffected). exit/quit/\q/EOF
    and CTRL-C continue to work. The prompt text was updated to mention ESC, and the
    synced copy in test/replMenu.test.ts updated to match.

Dependencies

  • Added chalk (^4.1.2) as a direct dependency — it was imported directly but
    only resolved transitively via hoisting, which is fragile in a global install.
  • Removed dev-only tooling from runtime dependencies: deleted esm (unused),
    moved ts-node to devDependencies (mocha's ts-node/esm loader needs it), and
    removed the duplicate tsx (already in devDependencies).

Docs

  • README.md — global install is now the primary path
    (npm i -g @oceanprotocol/cliocean-cli <command>); the from-source
    npm run cli path is kept for contributors with a note that the two forms are
    interchangeable. Documented the interactive-by-default behavior + ESC/CTRL-C exit,
    and corrected the stale INDEXING_* defaults (now 120 retries × 4000 ms).
  • CLAUDE.md — updated package/bin name, the global-install equivalence, the
    help/version validation skip, and the ABI-resolution description.

CI & release automation

  • .github/workflows/ci.yml — new pack_smoke job (runs on every PR, no
    Barge): build → npm pack → assert the tarball ships dist//metadata//README.md
    and not src//test/npm i -g the tarball → run ocean-cli --version,
    --help, -h, -V from a foreign cwd with no env vars. This permanently guards
    the global-install contract (broken bin, cwd-dependent loading, env-gated help).
  • Release flow mirrors @oceanprotocol/lib (ocean.js): a local
    npm run release (release-it --non-interactive) bumps the version, builds,
    regenerates the changelog (auto-changelog), commits, tags v${version},
    pushes, and cuts a GitHub Release — but does not publish to npm
    (release-it config: npm.publish: false). Added release/changelog scripts,
    the release-it config block, and release-it/auto-changelog devDeps.
  • .github/workflows/publish.yml (new, replaces the earlier release.yml) —
    triggered by pushing a git tag (on: push: tags), exactly like ocean.js's
    publish.yml. Runs npm ci then npm publish with
    NODE_AUTH_TOKEN=${{ secrets.NPM_TOKEN }}: a tag containing next publishes to
    the next dist-tag, otherwise latest. Uses --provenance --access public
    (id-token: write); prepublishOnly rebuilds dist/ during publish.

Verification

Built with Node 22 and exercised from a foreign cwd with no env vars:

$ npm run build            # clean
$ npm run lint             # 0 errors (pre-existing `any` warnings only)

# from /tmp, no PRIVATE_KEY/RPC/NODE_URL:
$ node <repo>/dist/index.js --version   # → 2.0.0, exit 0
$ node <repo>/dist/index.js --help      # → help, exit 0   (-h / -V likewise)
$ AVOID_LOOP_RUN=true node <repo>/dist/index.js h   # → help, exit 0

# env validation still fires for real commands, strings unchanged:
only RPC        → "Have you forgot to set MNEMONIC or PRIVATE_KEY?"
only PRIVATE_KEY→ "Have you forgot to set env RPC?"
keys+RPC, noURL → "Have you forgot to set env NODE_URL?"

Packaging + real global install (isolated --prefix):

$ npm pack        # oceanprotocol-cli-2.0.0.tgz — dist/**, metadata/**, README.md,
                  # package.json; NO src/ or test/
$ npm i -g --prefix <tmp> ./oceanprotocol-cli-2.0.0.tgz
$ ocean-cli --version    # → 2.0.0 (from /tmp, no env)
$ ocean-cli h            # → help

Infra-free tests (Node 22):

test/resolveComputeInputs.test.ts   11 passing
test/setup.test.ts                   4 passing   (help output + env error strings)
test/replMenu.test.ts                9 passing   (REPL incl. prefix-strip)

Full npm run test:system still requires a running Barge stack.

Cutting a release

npm run release            # release-it: bump + build + changelog + commit + tag + GitHub Release
                           # (does NOT publish to npm)
# pushing the v<version> tag triggers .github/workflows/publish.yml → npm publish

Prerequisites:

  • Add an NPM_TOKEN repo secret — an npm automation token with publish rights
    on the @oceanprotocol org. publish.yml reads it as NODE_AUTH_TOKEN.
  • release-it needs a GitHub token for the Release step (GITHUB_TOKEN /
    GH_TOKEN) when run in CI; locally it uses your gh/git credentials.
  • --provenance requires the repository field (added here) to match this repo.

Summary by CodeRabbit

  • New Features

    • Added global installation support for the scoped @oceanprotocol/cli package.
    • Added direct ocean-cli execution with help and version commands.
    • Improved interactive mode, including ESC-based exit handling and one-shot execution support.
    • CLI version information now reflects the packaged release version.
  • Bug Fixes

    • Improved global-install compatibility when loading bundled assets.
    • Help and version commands no longer require environment configuration.
  • Documentation

    • Expanded installation, usage, interactive mode, and release guidance.
    • Added release changelog information.
  • Chores

    • Added package validation and tag/version checks to automated release workflows.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f26f8e3f-74ef-4743-9ea4-3f7a2c5d5d9c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The CLI is configured as the scoped @oceanprotocol/cli package with global-install support, release automation, tag/version validation, package smoke tests, cwd-independent artifact loading, and updated help, version, and interactive REPL behavior.

Changes

CLI distribution and runtime

Layer / File(s) Summary
Package release configuration
package.json, CHANGELOG.md, CLAUDE.md
Package metadata, published file rules, release scripts, dependencies, changelog, and release guidance are updated for scoped npm publication.
Publication and package smoke checks
.github/workflows/ci.yml, .github/workflows/publish.yml
CI validates packed contents and global CLI execution; publishing is restricted to v* tags and verifies the tag matches package.json before publishing.
CLI startup and interactive execution
src/cli.ts, src/index.ts, src/warnings.ts, test/replMenu.test.ts
Version loading, help/version early exits, direct execution, command-prefix stripping, ESC-based REPL termination, warning filtering, and prompt expectations are updated.
Runtime resolution and usage guidance
src/helpers.ts, src/interactiveFlow.ts, src/policyServerHelper.ts, README.md, CLAUDE.md
Contract artifacts resolve through module lookup, ESM imports use explicit extensions, and documentation covers global installation and interactive behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ocean-cli
  participant createCLI
  participant P2PBootstrap
  User->>ocean-cli: invoke help, version, or command
  ocean-cli->>ocean-cli: inspect process.argv
  alt help or version
    ocean-cli-->>User: print output and exit
  else command
    ocean-cli->>createCLI: initialize CLI
    createCLI->>P2PBootstrap: bootstrap when NODE_URL is a P2P address
    ocean-cli-->>User: execute command or enter REPL
  end
Loading

Possibly related PRs

Suggested reviewers: bogdanfazakas, giurgiur99, andreip136

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: making the CLI globally installable under @oceanprotocol/cli.
Linked Issues check ✅ Passed The PR implements issue #50 by adding npm publishing metadata, a global bin, and release/publish workflow support.
Out of Scope Changes check ✅ Passed The additional docs, tests, CI, and release automation changes are all supporting the npm publishing goal.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/cli_global

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@alexcos20 alexcos20 linked an issue Jul 24, 2026 that may be closed by this pull request
@alexcos20

Copy link
Copy Markdown
Member Author

/run-security-scan

@alexcos20 alexcos20 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI automated code review (Gemini 3).

Overall risk: low

Summary:
This PR excellently prepares ocean-cli for global distribution via npm. The addition of the smoke test for tarball contents, NPM provenance for supply chain security, and the move to module-based resolution for ABI files are great architectural improvements. LGTM!

Comments:
• [INFO][style] Since you have instantiated a require function, you can load and parse the JSON file in a single, native step instead of using readFileSync and JSON.parse. This is cleaner and matches what you did in src/cli.ts.

-const ERC20Template = JSON.parse(
-	readFileSync(
-		require.resolve(
-			"@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json"
-		),
-		"utf8"
-	)
-);
+const ERC20Template = require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json");

• [INFO][other] The addition of this pack_smoke job is excellent. Verifying the tarball contents in CI before publishing prevents shipping unwanted directories (like src/ and test/) and ensures the binary is globally installable without regressions.
• [INFO][security] Great job including id-token: write and --provenance. This strongly enhances the supply chain security of the package by linking the published artifact to its build execution.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (1)
test/replMenu.test.ts (1)

12-12: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Test Escape exit behavior in a TTY.

This only updates the prompt assertion. runRepl() uses piped stdin, so it cannot exercise the new input.isTTY Escape handler. Add a pseudo-TTY test (or extract the handler for unit testing) that sends \x1b and asserts a clean exit.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/replMenu.test.ts` at line 12, Add coverage for the TTY-specific Escape
exit path in runRepl, which is not exercised by the existing piped-stdin test.
Use a pseudo-TTY or extract and unit-test the input.isTTY handler, send \x1b,
and assert that the REPL exits cleanly.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 43-51: Update the CI workflow permissions for the pack_smoke job
to explicitly grant only contents: read, and configure the actions/checkout step
to disable persisted credentials. Keep the existing checkout behavior and
smoke-job steps unchanged.

In @.github/workflows/publish.yml:
- Around line 3-6: Restrict the publish workflow’s push trigger to tags matching
v*. Before publishing, add a validation step that compares the triggering tag’s
version with the version in package.json and stop the workflow when they differ,
ensuring only matching validated release tags publish.
- Around line 15-16: Remove the job-level NODE_AUTH_TOKEN declaration and add it
only to each step that runs npm publish in the workflow, preserving the existing
secret reference and leaving npm ci steps without access to the publishing
credential.

In `@README.md`:
- Around line 100-115: Update the README environment-variable documentation by
correcting “miliseconds” to “milliseconds” and adding the bash language label to
each of the three fenced shell snippets for INDEXING_MAX_RETRIES,
INDEXING_RETRY_INTERVAL, and AVOID_LOOP_RUN.

In `@src/index.ts`:
- Around line 63-73: Reformat the changed TypeScript with Prettier using 2-space
indentation, single quotes, and semicolons: update stripNpmPrefix and the
related changed block in src/index.ts (lines 63-73), the changed code and module
literal in src/cli.ts (line 5), the affected block in src/helpers.ts (lines
28-42), and the import in src/policyServerHelper.ts (line 2).
- Around line 184-194: Update the help-handling condition in the CLI startup
flow to also recognize the positional commands “h” and “help”, matching
createCLI()’s configuration-free behavior. Ensure all supported help forms call
program.outputHelp() and return before the REPL initialization, while leaving
version handling unchanged.

---

Nitpick comments:
In `@test/replMenu.test.ts`:
- Line 12: Add coverage for the TTY-specific Escape exit path in runRepl, which
is not exercised by the existing piped-stdin test. Use a pseudo-TTY or extract
and unit-test the input.isTTY handler, send \x1b, and assert that the REPL exits
cleanly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 70335b8a-0e88-4a95-9c2f-17b16bb8d3db

📥 Commits

Reviewing files that changed from the base of the PR and between 0bbe0c1 and 61d2874.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (11)
  • .github/workflows/ci.yml
  • .github/workflows/publish.yml
  • CLAUDE.md
  • README.md
  • package.json
  • src/cli.ts
  • src/helpers.ts
  • src/index.ts
  • src/interactiveFlow.ts
  • src/policyServerHelper.ts
  • test/replMenu.test.ts

Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Outdated
Comment thread README.md
Comment thread src/index.ts
Comment on lines +63 to +73
* Strip an optional leading `npm run cli` or `ocean-cli` prefix so that a pasted
* example command (from either the contributor docs or the global-install docs)
* behaves identically to the bare command form.
*/
function stripNpmPrefix(tokens: string[]): string[] {
if (tokens[0] === "npm" && tokens[1] === "run" && tokens[2] === "cli") {
return tokens.slice(3)
}
if (tokens[0] === "ocean-cli") {
return tokens.slice(1)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Format the changed TypeScript with Prettier.

The changed files share the same formatting drift from the required 2-space, single-quote, semicolon style.

  • src/index.ts#L63-L73: Reformat this and the remaining changed blocks with Prettier.
  • src/cli.ts#L5-L5: Use a single-quoted module literal and format the related changed code.
  • src/helpers.ts#L28-L42: Apply the required indentation, quote, and semicolon style.
  • src/policyServerHelper.ts#L2-L2: Use single quotes and terminate the import with a semicolon.

As per coding guidelines, **/*.{ts,tsx,js} must use Prettier with 2-space indentation, single quotes, and semicolons.

📍 Affects 4 files
  • src/index.ts#L63-L73 (this comment)
  • src/cli.ts#L5-L5
  • src/helpers.ts#L28-L42
  • src/policyServerHelper.ts#L2-L2
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/index.ts` around lines 63 - 73, Reformat the changed TypeScript with
Prettier using 2-space indentation, single quotes, and semicolons: update
stripNpmPrefix and the related changed block in src/index.ts (lines 63-73), the
changed code and module literal in src/cli.ts (line 5), the affected block in
src/helpers.ts (lines 28-42), and the import in src/policyServerHelper.ts (line
2).

Source: Coding guidelines

Comment thread src/index.ts
@alexcos20

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/cli.ts (1)

68-79: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Separate environment bypass from output/exiting behavior.

createCLI() lets any --help / -h / --version / -V anywhere bypass environment validation, but src/index.ts only exits to print root help/version for bare ./bin calls. For a command subpath like ocean-cli publish --help, src/index.ts never receives that argv because process.argv is [node, bin], so Commander only parses the remaining program argv and may render the root help. Handle subcommand help/version through Commander’s exit-override handling, while keeping only the no-init flag at cli.ts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli.ts` around lines 68 - 79, Update the argv bypass logic in createCLI
so it only skips environment validation and P2P bootstrap for the no-init
invocation handled by src/index.ts, rather than for help/version flags anywhere
in the command line. Move subcommand help/version output and exiting into
Commander’s exit-override handling, ensuring commands such as publish --help
render the subcommand output while preserving bare root help/version behavior.
🧹 Nitpick comments (1)
src/index.ts (1)

2-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Run Prettier on all changed TypeScript.

  • src/index.ts#L2-L2: format the side-effect import with the repository’s quote and semicolon rules.
  • src/index.ts#L187-L194: format the help/version branch.
  • src/index.ts#L214-L220: format the initial-help branch.
  • src/warnings.ts#L18-L29: format the warning-filter module.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/index.ts` at line 2, Run Prettier on the changed TypeScript. Format the
side-effect import and the help/version and initial-help branches in
src/index.ts at lines 2-2, 187-194, and 214-220, plus the warning-filter module
in src/warnings.ts at lines 18-29; make no behavioral changes.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Line 46: Remove the duplicate jobs mapping and move the pack_smoke job
definition under the existing top-level jobs block. Preserve pack_smoke’s
configuration while ensuring the workflow contains only one jobs key.

In `@CHANGELOG.md`:
- Line 35: Correct the typo in the changelog entry by replacing “downaloded”
with “downloaded,” without changing the surrounding text or commit link.

In `@src/warnings.ts`:
- Around line 20-29: Update the warning-handler setup around
process.on("warning") to preserve existing process warning listeners instead of
clearing them with process.removeAllListeners("warning"). Save and retain any
pre-existing listeners, or replace only the default printer while ensuring
custom preload, instrumentation, and observability handlers continue to run.

---

Outside diff comments:
In `@src/cli.ts`:
- Around line 68-79: Update the argv bypass logic in createCLI so it only skips
environment validation and P2P bootstrap for the no-init invocation handled by
src/index.ts, rather than for help/version flags anywhere in the command line.
Move subcommand help/version output and exiting into Commander’s exit-override
handling, ensuring commands such as publish --help render the subcommand output
while preserving bare root help/version behavior.

---

Nitpick comments:
In `@src/index.ts`:
- Line 2: Run Prettier on the changed TypeScript. Format the side-effect import
and the help/version and initial-help branches in src/index.ts at lines 2-2,
187-194, and 214-220, plus the warning-filter module in src/warnings.ts at lines
18-29; make no behavioral changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1bc6932c-a496-4a58-aac6-19b1c29165b3

📥 Commits

Reviewing files that changed from the base of the PR and between 61d2874 and dca9a55.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • .github/workflows/ci.yml
  • .github/workflows/publish.yml
  • CHANGELOG.md
  • README.md
  • package.json
  • src/cli.ts
  • src/index.ts
  • src/warnings.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

Comment thread .github/workflows/ci.yml Outdated
permissions:
contents: read

jobs:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Merge pack_smoke into the existing jobs mapping.

jobs is already declared at Line 6. Adding another jobs key at Line 46 makes the workflow invalid YAML, preventing GitHub Actions from loading the workflow. Define pack_smoke under the original jobs: block instead.

🧰 Tools
🪛 actionlint (1.7.12)

[error] 46-46: key "jobs" is duplicated in "workflow" section. previously defined at line:6,col:1

(syntax-check)

🪛 YAMLlint (1.37.1)

[error] 46-46: duplication of key "jobs" in mapping

(key-duplicates)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml at line 46, Remove the duplicate jobs mapping and
move the pack_smoke job definition under the existing top-level jobs block.
Preserve pack_smoke’s configuration while ensuring the workflow contains only
one jobs key.

Source: Linters/SAST tools

Comment thread CHANGELOG.md
- use latest ocean.js [`#147`](https://github.com/oceanprotocol/ocean-cli/pull/147)
- chore: add example metadata [`#132`](https://github.com/oceanprotocol/ocean-cli/pull/132)
- chore: buy v5 [`bc2b222`](https://github.com/oceanprotocol/ocean-cli/commit/bc2b2227c08620a63e171ab9e8d1660a3190bd4a)
- fix: removed file downaloded [`c99c066`](https://github.com/oceanprotocol/ocean-cli/commit/c99c06639dd6ad3a4c2f93ba01f5163bc77ec24f)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the changelog typo.

Change downaloded to downloaded.

🧰 Tools
🪛 LanguageTool

[grammar] ~35-~35: Ensure spelling is correct
Context: ...b9e8d1660a3190bd4a) - fix: removed file downaloded [c99c066](https://github.com/oceanpro...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGELOG.md` at line 35, Correct the typo in the changelog entry by
replacing “downaloded” with “downloaded,” without changing the surrounding text
or commit link.

Source: Linters/SAST tools

Comment thread src/warnings.ts
Comment on lines +20 to +29
process.removeAllListeners("warning");

process.on("warning", (warning: Error & { code?: string }) => {
if (SILENCED.has(warning.name)) return;
// Reproduce Node's default one-line format for everything else.
const code = warning.code ? ` [${warning.code}]` : "";
console.error(
`(node:${process.pid})${code} ${warning.stack ?? `${warning.name}: ${warning.message}`}`
);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== locate warnings.ts =="
fd -a 'warnings\.ts$' . || true

echo "== file contents =="
for f in $(fd 'warnings\.ts$' .); do
  echo "--- $f"
  wc -l "$f"
  cat -n "$f"
done

echo "== usages of warnings/removeAllListeners/warning listener =="
rg -n "removeAllListeners|on\\(\"warning\"|warning|Warnings|warnings" src package.json 2>/dev/null || true

echo "== Node version and listener behavior probe =="
node -v
node - <<'JS'
const listeners = ['default', 'custom-telemetry'];
// Node's own warning listener is an emitted custom handler under the hood;
// emulate a handler installed earlier.
process.on('warning', (warn) => console.log('custom handler saw', warn.code || warn.name));

// Simulate this module's guard: remove warning listeners, then replace with a filter.
process.removeAllListeners('warning');

process.on('warning', (warning) => {
  if (warning.name === 'DeprecationWarning') return;
  const code = warning.code ? ` [${warning.code}]` : '';
  console.error(`(node:${process.pid})${code} ${warning.stack ?? `${warning.name}: ${warning.message}`}`);
});

const emitted = new Error('example');
emitted.name = 'CustomWarning';
emitted.code = 'CUST1';
process.emitWarning(emitted, 'CustomWarning', 'CUST1');

console.log('remaining warning listener count after removeAllListeners + replace:', process.listenerCount('warning'));
JS

Repository: oceanprotocol/ocean-cli

Length of output: 3681


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== package/node engine =="
cat package.json | sed -n '1,120p'

echo "== inspect Node 22 if present =="
if command -v node22 >/dev/null 2>&1 || command -v /usr/bin/node22 >/dev/null 2>&1; then
  node22 -v || true
else
  echo "node22 binary not found"
fi

echo "== Node listener semantics via public API =="
node - <<'JS'
const emittedRef = [];
process.on('warning', (w) => emittedRef.push('custom:' + w.name));
process.emitWarning(new Error('p1'), 'P1');
const before = process.getEventListeners('warning').length;
process.removeAllListeners('warning');
const after = process.getEventListeners('warning').length;
process.on('warning', (w) => emittedRef.push('custom2:' + w.name));

const emitted = new Error('p2');
emitted.name = 'P2';
process.emitWarning(emitted, 'P2');

console.log(JSON.stringify({
 beforeCount: before,
 afterCount: after,
 emitted: emittedRef
}));
JS

echo "== diff context =="
git diff -- src/warnings.ts src/index.ts --stat 2>/dev/null || true

Repository: oceanprotocol/ocean-cli

Length of output: 3907


Preserve existing warning listeners.

process.removeAllListeners("warning") clears every warning listener, including handlers added by preload scripts, instrumentation, or observability tooling. Re-register any custom listeners that should continue to run, or avoid removing the default printer by replacing it only after saving existing listeners.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/warnings.ts` around lines 20 - 29, Update the warning-handler setup
around process.on("warning") to preserve existing process warning listeners
instead of clearing them with process.removeAllListeners("warning"). Save and
retain any pre-existing listeners, or replace only the default printer while
ensuring custom preload, instrumentation, and observability handlers continue to
run.

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.

Publish CLI on npm

1 participant