Skip to content

publish-ci#606

Merged
yaacov merged 1 commit intomainfrom
publish-ci
Mar 20, 2026
Merged

publish-ci#606
yaacov merged 1 commit intomainfrom
publish-ci

Conversation

@yaacov
Copy link
Copy Markdown
Owner

@yaacov yaacov commented Mar 20, 2026

Summary by CodeRabbit

  • New Features

    • Published TypeScript type definitions for improved IDE support and type checking.
  • Documentation

    • Added documentation clarifying that serialport is optional; TCP/UDP network modes work without it.
    • Updated serial port discovery API return type.
  • Chores

    • Moved serialport to optional dependencies, reducing installation requirements for TCP/UDP-only users.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6a481423-1d33-4a5b-9d01-5f3727f7d2a8

📥 Commits

Reviewing files that changed from the base of the PR and between 73a9f0b and 456962e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • ModbusRTU.d.ts
  • README.md
  • ServerSerial.d.ts
  • index.d.ts
  • package.json
✅ Files skipped from review due to trivial changes (3)
  • ServerSerial.d.ts
  • README.md
  • index.d.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

📝 Walkthrough

Walkthrough

This PR transitions serialport from a required to an optional dependency, introduces a new ModbusSerialPortListEntry type for the getPorts() method, adds TypeScript documentation clarifying optional dependency behavior, and configures the package to properly publish type definitions.

Changes

Cohort / File(s) Summary
Type Definition Updates
ModbusRTU.d.ts, ServerSerial.d.ts, index.d.ts
Added new ModbusSerialPortListEntry interface with path and optional device identification fields; updated getPorts() return type from PortInfo[] to ModbusSerialPortListEntry[]; added TSDoc/JSDoc comments documenting serialport as optional and guidance for type-checking with skipLibCheck or devDependency installation.
Documentation
README.md
Added section documenting serialport as an optional install, listing which serial APIs/exports fail at runtime when serialport is absent, and clarifying TypeScript type-checking requirements for serial-related declarations.
Package Configuration
package.json
Moved serialport from dependencies to optionalDependencies; added types field declaring index.d.ts; added files array restricting published contents to include JS entrypoint, source directories, and .d.ts files; updated package description to note optional serialport dependency.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 With serialport now optional and free,
TCP hops along, happy as can be,
Types now shine bright with ModbusSerialPortListEntry,
Documentation guides each curious friend,
A flexible library, no burden at the end! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'publish-ci' is vague and does not clearly convey the main changes in this pull request. The PR primarily makes serialport an optional dependency and adds TypeScript type declarations to the package configuration, but the title provides no indication of these substantial changes. Use a more descriptive title that summarizes the main change, such as 'Make serialport optional dependency and publish TypeScript types' or 'Add TypeScript typings and make serialport optional'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch publish-ci
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Signed-off-by: yaacov <kobi.zamir@gmail.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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)
scripts/stage-npm-flavor.js (1)

56-58: Add existence check for .d.ts files for consistency.

Unlike rootFiles (lines 43-45), the .d.ts file copy loop doesn't verify file existence before copying. If any .d.ts file is missing, fs.copyFileSync will throw a cryptic ENOENT error rather than a clear diagnostic message.

♻️ Proposed fix for consistent error handling
     for (const f of dtsFiles) {
+        const src = path.join(root, f);
+        if (!fs.existsSync(src)) {
+            throw new Error(`Missing required .d.ts file: ${f}`);
+        }
-        fs.copyFileSync(path.join(root, f), path.join(destDir, f));
+        fs.copyFileSync(src, path.join(destDir, f));
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/stage-npm-flavor.js` around lines 56 - 58, The .d.ts copy loop lacks
an existence check and will raise an opaque ENOENT if a file is missing; update
the loop that iterates over dtsFiles to mirror the rootFiles behavior by
checking fs.existsSync(path.join(root, f)) before calling fs.copyFileSync, and
if the file is missing, throw or log a clear diagnostic referencing the file and
destDir so callers get a helpful error instead of a raw ENOENT; keep using the
same variables (dtsFiles, root, destDir, fs.copyFileSync, path.join) for
consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/stage-npm-flavor.js`:
- Around line 28-37: In copyPublishTree, the dirs array used to build the
package tree (in function copyPublishTree) is missing the "worker" directory
which causes apis/worker.js (which requires "../worker/index") to fail at
runtime; update the dirs array (in the same function) to include "worker" so
that the worker/index files are copied into the published package and the
require("./apis/worker") from index.js resolves correctly.

---

Nitpick comments:
In `@scripts/stage-npm-flavor.js`:
- Around line 56-58: The .d.ts copy loop lacks an existence check and will raise
an opaque ENOENT if a file is missing; update the loop that iterates over
dtsFiles to mirror the rootFiles behavior by checking
fs.existsSync(path.join(root, f)) before calling fs.copyFileSync, and if the
file is missing, throw or log a clear diagnostic referencing the file and
destDir so callers get a helpful error instead of a raw ENOENT; keep using the
same variables (dtsFiles, root, destDir, fs.copyFileSync, path.join) for
consistency.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 93d6d11d-ab6e-4aa4-9647-534228d1a0cb

📥 Commits

Reviewing files that changed from the base of the PR and between 8b7ff06 and 73a9f0b.

📒 Files selected for processing (9)
  • .gitignore
  • ModbusRTU.d.ts
  • README.md
  • ServerSerial.d.ts
  • index.d.ts
  • package.json
  • scripts/clean.js
  • scripts/package-no-serial-port.json
  • scripts/stage-npm-flavor.js

Comment thread scripts/stage-npm-flavor.js Outdated
Comment on lines +28 to +37
function copyPublishTree(destDir) {
const dirs = ["apis", "ports", "servers", "utils"];
const rootFiles = ["index.js", "README.md", "LICENSE"];
const dtsFiles = [
"index.d.ts",
"ModbusRTU.d.ts",
"ServerTCP.d.ts",
"ServerSerial.d.ts",
"TestPort.d.ts"
];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Missing worker directory will break published packages at runtime.

The dirs array omits the worker directory, but apis/worker.js requires ../worker/index (see apis/worker.js:1). Since index.js loads this API via require("./apis/worker"), both published package flavors will fail at runtime with a "module not found" error when the Worker class is accessed.

🐛 Proposed fix to include the worker directory
 function copyPublishTree(destDir) {
-    const dirs = ["apis", "ports", "servers", "utils"];
+    const dirs = ["apis", "ports", "servers", "utils", "worker"];
     const rootFiles = ["index.js", "README.md", "LICENSE"];
📝 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
function copyPublishTree(destDir) {
const dirs = ["apis", "ports", "servers", "utils"];
const rootFiles = ["index.js", "README.md", "LICENSE"];
const dtsFiles = [
"index.d.ts",
"ModbusRTU.d.ts",
"ServerTCP.d.ts",
"ServerSerial.d.ts",
"TestPort.d.ts"
];
function copyPublishTree(destDir) {
const dirs = ["apis", "ports", "servers", "utils", "worker"];
const rootFiles = ["index.js", "README.md", "LICENSE"];
const dtsFiles = [
"index.d.ts",
"ModbusRTU.d.ts",
"ServerTCP.d.ts",
"ServerSerial.d.ts",
"TestPort.d.ts"
];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/stage-npm-flavor.js` around lines 28 - 37, In copyPublishTree, the
dirs array used to build the package tree (in function copyPublishTree) is
missing the "worker" directory which causes apis/worker.js (which requires
"../worker/index") to fail at runtime; update the dirs array (in the same
function) to include "worker" so that the worker/index files are copied into the
published package and the require("./apis/worker") from index.js resolves
correctly.

@yaacov yaacov merged commit 3461fab into main Mar 20, 2026
4 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