fix(plugins): bundle official plugins#1627
Conversation
📝 WalkthroughWalkthroughThis PR introduces a reusable "official plugins" bundling infrastructure that generalizes plugin packaging beyond CUA to support Feishu/Lark plugins across Windows, Linux, and macOS. A new discovery and bundling script orchestrates manifest scanning, artifact naming, packaging, and verification; package.json and CI workflows wire this infrastructure into development and release pipelines; and updated documentation and tests validate the behavior. ChangesOfficial Plugins Bundling System
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@scripts/ensure-official-plugins.mjs`:
- Around line 45-47: The CLI currently assumes a value follows the --out flag
and resolves argv[index + 1] even when missing, which can make --clean
dangerous; update the argument parsing around arg/argv/index so that when arg
=== '--out' you first validate argv[index + 1] exists, is not another flag
(doesn't start with '-') and is non-empty before calling path.resolve(rootDir,
...), otherwise exit with a clear error and non-zero status; additionally,
before performing the clean operation that uses args.outDir (the --clean logic),
validate that args.outDir is a subpath of rootDir and not equal to rootDir (or
outside it) and refuse to run clean if that check fails to prevent recursive
deletion of the workspace.
🪄 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
Run ID: 8d6d3556-7f44-4968-8d04-5ed6321f4f86
📒 Files selected for processing (10)
.github/workflows/build.yml.github/workflows/release.ymldocs/guides/plugin-packaging.mddocs/issues/feishu-plugin-bundling/plan.mddocs/issues/feishu-plugin-bundling/spec.mddocs/issues/feishu-plugin-bundling/tasks.mdelectron-builder.ymlpackage.jsonscripts/ensure-official-plugins.mjstest/main/presenter/pluginPresenter.test.ts
| if (arg === '--out') { | ||
| args.outDir = path.resolve(rootDir, argv[index + 1] || '') | ||
| index += 1 |
There was a problem hiding this comment.
Validate required flag values before resolving paths and cleaning.
Line 46 currently treats a missing --out value as '', which resolves to the repo root; with --clean (Line 224) this can recursively delete the workspace. Please fail fast on missing values and block unsafe clean targets.
Suggested fix
+function readRequiredValue(argv, index, flag) {
+ const value = argv[index + 1]
+ if (!value || value.startsWith('--')) {
+ throw new Error(`${flag} requires a value`)
+ }
+ return value
+}
+
function parseArgs(argv) {
@@
if (arg === '--out') {
- args.outDir = path.resolve(rootDir, argv[index + 1] || '')
+ const outValue = readRequiredValue(argv, index, '--out')
+ args.outDir = path.resolve(rootDir, outValue)
index += 1
continue
}
@@
if (arg === '--plugin-root') {
- args.pluginRoot = path.resolve(rootDir, argv[index + 1] || '')
+ const pluginRootValue = readRequiredValue(argv, index, '--plugin-root')
+ args.pluginRoot = path.resolve(rootDir, pluginRootValue)
index += 1
continue
}
@@
if (args.verify) {
verifyPlugins(args)
} else {
if (args.clean) {
+ const resolvedOutDir = path.resolve(args.outDir)
+ const fsRoot = path.parse(resolvedOutDir).root
+ if (resolvedOutDir === rootDir || resolvedOutDir === fsRoot) {
+ throw new Error(`Refusing to clean unsafe output directory: ${resolvedOutDir}`)
+ }
fs.rmSync(args.outDir, { recursive: true, force: true })
}Also applies to: 55-57, 223-225
🤖 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 `@scripts/ensure-official-plugins.mjs` around lines 45 - 47, The CLI currently
assumes a value follows the --out flag and resolves argv[index + 1] even when
missing, which can make --clean dangerous; update the argument parsing around
arg/argv/index so that when arg === '--out' you first validate argv[index + 1]
exists, is not another flag (doesn't start with '-') and is non-empty before
calling path.resolve(rootDir, ...), otherwise exit with a clear error and
non-zero status; additionally, before performing the clean operation that uses
args.outDir (the --clean logic), validate that args.outDir is a subpath of
rootDir and not equal to rootDir (or outside it) and refuse to run clean if that
check fails to prevent recursive deletion of the workspace.
Summary
Tests
Summary by CodeRabbit
Release Notes
New Features
Chores