Skip to content

refactor(deps): reduce direct dependency surface - #161

Merged
rsonghuster merged 3 commits into
masterfrom
codex/cleanup-dependencies
Aug 7, 2026
Merged

refactor(deps): reduce direct dependency surface#161
rsonghuster merged 3 commits into
masterfrom
codex/cleanup-dependencies

Conversation

@rsonghuster

@rsonghuster rsonghuster commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Replace temp-dir, ip, rimraf, and shell helpers with Node APIs. Remove unused download and trigger-template code, declare runtime dependencies explicitly, and add Node 16 type checking.

Summary by CodeRabbit

  • Changes

    • Removed the trigger-template command and its sample event templates.
    • Improved local development support for temporary directories and local IP detection.
    • Updated compatibility requirements to Node.js 16 or newer.
    • Preserved command-line output formatting while improving runtime compatibility.
  • Tests

    • Added TypeScript type checking to the Linux validation workflow.
    • Streamlined test configuration and retired obsolete coverage.
  • Documentation

    • Updated architecture and testing documentation to reflect current functionality.

Replace temp-dir, ip, rimraf, and shell helpers with Node APIs. Remove unused download and trigger-template code, declare runtime dependencies explicitly, and add Node 16 type checking.
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 706958cd-ba26-448d-b311-934ea143a0cd

📥 Commits

Reviewing files that changed from the base of the PR and between acd6fb3 and ebd8d71.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • jestconfig.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • jestconfig.json

📝 Walkthrough

Walkthrough

The PR adds CI type checking, replaces temporary-directory and IP dependencies with shared utilities, removes obsolete utilities and trigger templates, updates Jest and npm configuration, and standardizes Chalk imports.

Changes

Utility and tooling cleanup

Layer / File(s) Summary
Tooling and dependency configuration
.github/workflows/ci_node16.yaml, package.json, jestconfig.json, patches/ali-oss+6.18.1.patch
CI runs type checking. npm scripts, dependencies, Node.js requirements, Jest discovery, and the ali-oss patch are updated.
Shared utility migration
src/utils/index.ts, src/subCommands/build/..., src/subCommands/local/..., __tests__/ut/local/impl/baseLocal_test.ts, docs/architecture.md
Build and local execution paths use getTempDir() and getLocalIpAddress(). Temporary cleanup uses fs.rmSync().
Obsolete utility and template removal
src/subCommands/local/impl/utils.ts, src/subCommands/trigger-template/*, src/subCommands/trigger-template/event-template/*, __tests__/ut/..., docs/testing-plan.md
downloadFile() and getTimeZone() are removed with their tests. The trigger-template command and event fixtures are deleted.
Chalk import standardization
src/subCommands/build/index.ts, src/subCommands/deploy/impl/function.ts, src/subCommands/invoke/index.ts, src/subCommands/model/index.ts, src/utils/verify.ts
Named Chalk imports are replaced with the default namespace. Existing message formatting calls are updated.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 dependency refactoring and removal of unnecessary direct dependencies.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/cleanup-dependencies

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.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@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: 1

🧹 Nitpick comments (1)
__tests__/ut/local/impl/baseLocal_test.ts (1)

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

Exercise the migrated temporary-directory paths.

The suite mocks getTempDir(), but it does not call getCodeUri() or tryUnzip(). Add archive extraction tests that assert both paths use the mocked temporary directory and UUID suffix.

🤖 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 `@__tests__/ut/local/impl/baseLocal_test.ts` around lines 35 - 36, Extend the
tests around the existing getTempDir mock to invoke getCodeUri() and tryUnzip()
with archive inputs, covering both temporary-directory paths. Assert each
generated path uses the mocked /tmp directory and includes the expected UUID
suffix, while preserving the existing test setup.
🤖 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 `@src/subCommands/local/impl/baseLocal.ts`:
- Line 471: Update the cleanup call in the after() method to configure fs.rmSync
with recursive and force enabled plus a positive maxRetries value, ensuring
transient EBUSY, EPERM, and ENOTEMPTY errors are retried without changing the
existing target path.

---

Nitpick comments:
In `@__tests__/ut/local/impl/baseLocal_test.ts`:
- Around line 35-36: Extend the tests around the existing getTempDir mock to
invoke getCodeUri() and tryUnzip() with archive inputs, covering both
temporary-directory paths. Assert each generated path uses the mocked /tmp
directory and includes the expected UUID suffix, while preserving the existing
test setup.
🪄 Autofix

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: 9f5ddff9-57f1-466a-9d12-8bdf4d396813

📥 Commits

Reviewing files that changed from the base of the PR and between 5cec9a1 and acd6fb3.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (34)
  • .github/workflows/ci_node16.yaml
  • __tests__/ut/core/downloadFile_test.ts
  • __tests__/ut/local/impl/baseLocal_test.ts
  • __tests__/ut/local/impl/utils_test.ts
  • __tests__/ut/utils/utils_functions_test.ts
  • __tests__/ut/utils/utils_test.ts
  • docs/architecture.md
  • docs/testing-plan.md
  • jestconfig.json
  • package.json
  • patches/ali-oss+6.18.1.patch
  • src/subCommands/build/impl/defaultBuilder.ts
  • src/subCommands/build/index.ts
  • src/subCommands/deploy/impl/function.ts
  • src/subCommands/invoke/index.ts
  • src/subCommands/local/impl/baseLocal.ts
  • src/subCommands/local/impl/invoke/phpLocalInvoke.ts
  • src/subCommands/local/impl/start/phpLocalStart.ts
  • src/subCommands/local/impl/utils.ts
  • src/subCommands/model/index.ts
  • src/subCommands/trigger-template/event-template/cdn-CachedObjectsRefreshed.json
  • src/subCommands/trigger-template/event-template/cdn-CdnDomainAdded.json
  • src/subCommands/trigger-template/event-template/cdn-CdnDomainStarted.json
  • src/subCommands/trigger-template/event-template/cdn-LogFileCreated.json
  • src/subCommands/trigger-template/event-template/http.json
  • src/subCommands/trigger-template/event-template/mns-stream.json
  • src/subCommands/trigger-template/event-template/mns-with-MessageAttributes.json
  • src/subCommands/trigger-template/event-template/mns-without-MessageAttributes.json
  • src/subCommands/trigger-template/event-template/oss.json
  • src/subCommands/trigger-template/event-template/sls.json
  • src/subCommands/trigger-template/event-template/tablestore.json
  • src/subCommands/trigger-template/index.ts
  • src/utils/index.ts
  • src/utils/verify.ts
💤 Files with no reviewable changes (17)
  • src/subCommands/trigger-template/event-template/cdn-CdnDomainStarted.json
  • src/subCommands/trigger-template/event-template/tablestore.json
  • src/subCommands/trigger-template/event-template/sls.json
  • src/subCommands/trigger-template/event-template/mns-stream.json
  • src/subCommands/trigger-template/event-template/mns-with-MessageAttributes.json
  • src/subCommands/trigger-template/event-template/cdn-CachedObjectsRefreshed.json
  • tests/ut/core/downloadFile_test.ts
  • src/subCommands/trigger-template/event-template/http.json
  • src/subCommands/trigger-template/index.ts
  • src/subCommands/trigger-template/event-template/mns-without-MessageAttributes.json
  • src/subCommands/trigger-template/event-template/cdn-LogFileCreated.json
  • src/subCommands/trigger-template/event-template/oss.json
  • patches/ali-oss+6.18.1.patch
  • src/subCommands/trigger-template/event-template/cdn-CdnDomainAdded.json
  • docs/testing-plan.md
  • src/subCommands/local/impl/utils.ts
  • tests/ut/utils/utils_test.ts

logger.debug('after ...');
if (this.unzippedCodeDir) {
rimraf.sync(this.unzippedCodeDir);
fs.rmSync(this.unzippedCodeDir, { recursive: true, force: true });

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 | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate and inspect the relevant file and cleanup call.
if [ -f src/subCommands/local/impl/baseLocal.ts ]; then
  echo "FOUND src/subCommands/local/impl/baseLocal.ts ($(wc -l < src/subCommands/local/impl/baseLocal.ts) lines)"
  sed -n '440,490p' src/subCommands/local/_impl/baseLocal.ts 2>/dev/null || sed -n '440,490p' src/subCommands/local/impl/baseLocal.ts
else
  echo "Missing expected file; searching for baseLocal.ts"
  fd -a 'baseLocal\.ts$' .
fi

echo
echo "Search for temp cleanup patterns:"
rg -n "fs\.rmSync|unzippedCodeDir|after\\(|force: true|maxRetries|retryDelay" src/subCommands/local/impl/baseLocal.ts src || true

echo
echo "Node fs.rmSync option defaults/behavior probe:"
node - <<'JS'
const fs = require('fs');
const path = require('path');

const dir = fs.mkdtempSync('/tmp/local-cleanup-probe-');
fs.mkdirSync(path.join(dir, 'nested'), { recursive: true });
fs.writeFileSync(path.join(dir, 'nested', 'file'), 'x');

let thrown = false;
let err;
try {
  fs.rmSync(dir, { recursive: true, force: true });
} catch (e) {
  thrown = true;
  err = e;
}
console.log(JSON.stringify({
  thrownAtFirstCall: thrown,
  errorCode: err && err.code,
  remainingAfterFirstCall: fs.existsSync(dir),
  currentFsRmSyncInvariants: {
    nodeVersion: process.version,
    rmSyncSupportsOptions: typeof fs.rmSync === 'function',
    rmSyncSupportsRetryOptions: fs.rmSync.length === 2,
  }
}, null, 2));
JS

Repository: devsapp/fc3

Length of output: 9024


🌐 Web query:

Node.js fs.rmSync options maxRetries default EBUSY EPERM documentation

💡 Result:

In Node.js, the fs.rmSync method is used to remove files and directories [1]. Regarding the maxRetries option, the following points apply: Default Value: The default value for the maxRetries option is 0 [1][2]. Functionality: If an EBUSY, EMFILE, ENFILE, ENOTEMPTY, or EPERM error is encountered, Node.js will retry the operation if maxRetries is greater than 0 [1][2]. The operation is retried with a linear backoff wait of retryDelay milliseconds longer on each successive try [1][2]. Requirements: The maxRetries option is ignored unless the recursive option is also set to true [1][2]. Historical Note: In earlier versions of Node.js (specifically prior to v13.3.0), this option was known as maxBusyTries [1][3]. The retry logic is designed to handle transient errors during recursive directory removal [1][2]. If recursive mode is not enabled, the maxRetries setting has no effect [1][2].

Citations:


Retry recursive temp-directory cleanup.

force only ignores missing paths, and fs.rmSync() retries EBUSY/EPERM/ENOTEMPTY paths only when maxRetries > 0. Set recursive, force, and maxRetries so after() does not fail the command on transient cleanup errors.

Proposed fix
-      fs.rmSync(this.unzippedCodeDir, { recursive: true, force: true });
+      fs.rmSync(this.unzippedCodeDir, {
+        recursive: true,
+        force: true,
+        maxRetries: 3,
+        retryDelay: 100,
+      });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fs.rmSync(this.unzippedCodeDir, { recursive: true, force: true });
fs.rmSync(this.unzippedCodeDir, {
recursive: true,
force: true,
maxRetries: 3,
retryDelay: 100,
});
🤖 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/subCommands/local/impl/baseLocal.ts` at line 471, Update the cleanup call
in the after() method to configure fs.rmSync with recursive and force enabled
plus a positive maxRetries value, ensuring transient EBUSY, EPERM, and ENOTEMPTY
errors are retried without changing the existing target path.

Removing patch-package (which rewrote ali-oss's process.browser) made
ts-jest type-check ali-oss's bundled .ts source and fail with TS2339,
breaking npm test on all CI platforms. transformIgnorePatterns does not
exclude node_modules, so ts-jest compiles the imported .ts.

Scope ts-jest diagnostics to exclude node_modules, keeping type-checking
for our own code while ignoring third-party .ts type errors. npm build
and typecheck were unaffected (they resolve ali-oss's .js entry).
Resolved URLs pointed to registry.npmmirror.com, which GitHub
runners time out reaching during npm install (ERR_SOCKET_TIMEOUT).
@rsonghuster
rsonghuster merged commit e22227e into master Aug 7, 2026
8 of 9 checks passed
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