-
Notifications
You must be signed in to change notification settings - Fork 65
fix(webpack-plugin-kintone-plugin): use cli-kintone for pack plugin #3584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates @kintone/webpack-plugin-kintone-plugin from the deprecated @kintone/plugin-packer to @kintone/cli by executing cli-kintone's plugin commands as child processes.
Changes:
- Replaced
@kintone/plugin-packerdependency with@kintone/cli - Introduced
cli-runner.tsto execute cli-kintone commands via child processes - Updated plugin generation logic to use temporary files and asynchronous operations
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updated dependency from @kintone/plugin-packer to @kintone/cli |
| cli-runner.ts | New module providing wrappers for cli-kintone plugin commands |
| plugin.ts | Refactored generatePlugin to use cli-kintone via child process with temp file handling |
| index.ts | Updated to pass private key path instead of reading file content |
| vitest.config.ts | Disabled file parallelism to prevent test fixture conflicts |
| README.md | Added documentation for private key generation using cli-kintone |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (fs.existsSync(tempOutputPath)) { | ||
| fs.unlinkSync(tempOutputPath); |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using synchronous file operations (fs.existsSync and fs.unlinkSync) in a finally block after async operations can cause issues if multiple plugin generations run concurrently. Use fs.promises.unlink with error handling instead to avoid blocking and potential race conditions.
| if (fs.existsSync(tempOutputPath)) { | |
| fs.unlinkSync(tempOutputPath); | |
| try { | |
| await fs.promises.unlink(tempOutputPath); | |
| } catch (error) { | |
| if ((error as NodeJS.ErrnoException).code !== "ENOENT") { | |
| throw error; | |
| } |
| // Note: cli-kintone skips actual packing when NODE_ENV=test, | ||
| // so we need to override it to ensure the pack command runs. | ||
| // ref: https://github.com/kintone/cli-kintone/blob/a17e3a2c0f1b0c5eef55f61ab652d01ae8c5f791/src/cli/plugin/pack.ts#L53-L57 | ||
| const env = { ...process.env, NODE_ENV: "production" }; |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overriding NODE_ENV to 'production' for all pack operations may have unintended side effects if the host application or other tooling relies on the original NODE_ENV value. Consider documenting this behavior or using a more targeted environment variable specific to cli-kintone if available.
| const env = { ...process.env, NODE_ENV: "production" }; | |
| const env = { | |
| ...process.env, | |
| ...(process.env.NODE_ENV === "test" ? { NODE_ENV: "production" } : {}), | |
| }; |
| } catch { | ||
| throw new Error(`Failed to parse plugin info JSON: ${stdout}`); |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch block silently discards the original parsing error. Preserve the original error for better debugging by capturing it in the catch clause (e.g., catch (error)) and including it in the thrown error message.
| } catch { | |
| throw new Error(`Failed to parse plugin info JSON: ${stdout}`); | |
| } catch (error) { | |
| const originalError = error instanceof Error ? `${error.name}: ${error.message}` : String(error); | |
| throw new Error( | |
| `Failed to parse plugin info JSON: ${stdout}\nOriginal error: ${originalError}`, | |
| ); |
| export const getPluginInfo = async ( | ||
| pluginZipPath: string, | ||
| ): Promise<PluginInfo> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nameless-mc
現状idしか使用してなさそうですが、今後nameなど他のプロパティを使うケースって出てきそうですかね?
もしなければidだけ返すメソッドでいいかなと思いました。
Why
With the CLI integration,
@kintone/plugin-packerwill reach EOL.Since
@kintone/webpack-plugin-kintone-plugininternally usesplugin-packer, it needs to be replaced with@kintone/cli.What
@kintone/plugin-packerwith@kintone/clicli-runner.tsto execute cli-kintone'splugin packcommand as a child processgeneratePluginfunction to use cli-kintonekeygencommand for private key generationNote
An alternative approach would be to modularize cli-kintone's plugin-related functionality, but that would require significant effort. As an interim solution, this implementation uses child process invocation.
How to test
pnpm --filter @kintone/webpack-plugin-kintone-plugin testand verify all tests passChecklist
pnpm lintandpnpm teston the root directory.