Skip to content

Conversation

@nameless-mc
Copy link
Contributor

Why

With the CLI integration, @kintone/plugin-packer will reach EOL.
Since @kintone/webpack-plugin-kintone-plugin internally uses plugin-packer, it needs to be replaced with @kintone/cli.

What

  • Replace @kintone/plugin-packer with @kintone/cli
  • Add cli-runner.ts to execute cli-kintone's plugin pack command as a child process
  • Update generatePlugin function to use cli-kintone
  • Add documentation in README to use the keygen command for private key generation
  • Disable file parallelism in tests to avoid file conflicts in shared fixtures

Note

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

  • Run pnpm --filter @kintone/webpack-plugin-kintone-plugin test and verify all tests pass
  • Verify plugin build works correctly in a sample project

Checklist

  • Read CONTRIBUTING.md
  • Updated documentation if it is required.
  • Added tests if it is required.
  • Passed pnpm lint and pnpm test on the root directory.

@nameless-mc nameless-mc self-assigned this Jan 28, 2026
@nameless-mc nameless-mc requested a review from a team as a code owner January 28, 2026 05:44
@nameless-mc nameless-mc requested review from chihiro-adachi, Copilot and tasshi-me and removed request for a team January 28, 2026 05:44
@github-actions github-actions bot added the pkg: webpack-plugin-kintone-plugin @kintone/webpack-plugin-kintone-plugin label Jan 28, 2026
Copy link
Contributor

Copilot AI left a 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-packer dependency with @kintone/cli
  • Introduced cli-runner.ts to 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.

Comment on lines +79 to +80
if (fs.existsSync(tempOutputPath)) {
fs.unlinkSync(tempOutputPath);
Copy link

Copilot AI Jan 28, 2026

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.

Suggested change
if (fs.existsSync(tempOutputPath)) {
fs.unlinkSync(tempOutputPath);
try {
await fs.promises.unlink(tempOutputPath);
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
throw error;
}

Copilot uses AI. Check for mistakes.
// 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" };
Copy link

Copilot AI Jan 28, 2026

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.

Suggested change
const env = { ...process.env, NODE_ENV: "production" };
const env = {
...process.env,
...(process.env.NODE_ENV === "test" ? { NODE_ENV: "production" } : {}),
};

Copilot uses AI. Check for mistakes.
Comment on lines +86 to +87
} catch {
throw new Error(`Failed to parse plugin info JSON: ${stdout}`);
Copy link

Copilot AI Jan 28, 2026

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.

Suggested change
} 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}`,
);

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +74
export const getPluginInfo = async (
pluginZipPath: string,
): Promise<PluginInfo> => {
Copy link
Member

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だけ返すメソッドでいいかなと思いました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: webpack-plugin-kintone-plugin @kintone/webpack-plugin-kintone-plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants