From 6a3e8ea29ea632104c18eff0c55076c46ad268c9 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sat, 7 Feb 2026 22:42:55 +0800 Subject: [PATCH 1/2] fix: `commentWithDev` option apply template --- packages/cli/index.ts | 1 + packages/cli/template.ts | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/cli/index.ts b/packages/cli/index.ts index 470763e1..86d97b03 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -381,6 +381,7 @@ const main = defineCommand({ if (!noDefaultTemplate && templates.length === 0) { const project = createDefaultTemplate( Object.fromEntries(deps.entries()), + isCommentWithDev, ); for (const filePath of Object.keys(project)) { diff --git a/packages/cli/template.ts b/packages/cli/template.ts index 29102686..c0918b30 100644 --- a/packages/cli/template.ts +++ b/packages/cli/template.ts @@ -1,5 +1,6 @@ export const createDefaultTemplate = ( dependencies: Record, + isCommentWithDev: boolean, ) => ({ "index.js": "", "README.md": ` @@ -17,7 +18,7 @@ ${Object.values(dependencies) .map( (url) => ` \`\`\`sh -npm i ${url} +npm i ${url + (isCommentWithDev ? " -D" : "")} \`\`\` `, ) @@ -28,7 +29,7 @@ npm i ${url} To use this feature as a maintainer, you can run the following command: \`\`\`sh -npx pkg-pr-new publish './packages/A' --template './examples/*' +npx pkg-pr-new publish './packages/A' --template './examples/*'${isCommentWithDev ? " --dev" : ""} \`\`\` ## Benefits @@ -43,7 +44,7 @@ npx pkg-pr-new publish './packages/A' --template './examples/*' version: "1.0.0", description: "generated by pkg.pr.new", main: "index.js", - dependencies, + [isCommentWithDev ? "devDependencies" : "dependencies"]: dependencies, keywords: [], author: "pkg.pr.new", license: "ISC", From 5060fd42506f220fa2f90a3e5616668148d9d1e9 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sat, 7 Feb 2026 22:44:54 +0800 Subject: [PATCH 2/2] fix: update --- packages/cli/template.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/template.ts b/packages/cli/template.ts index c0918b30..ed4d0e36 100644 --- a/packages/cli/template.ts +++ b/packages/cli/template.ts @@ -29,7 +29,7 @@ npm i ${url + (isCommentWithDev ? " -D" : "")} To use this feature as a maintainer, you can run the following command: \`\`\`sh -npx pkg-pr-new publish './packages/A' --template './examples/*'${isCommentWithDev ? " --dev" : ""} +npx pkg-pr-new publish './packages/A' --template './examples/*'${isCommentWithDev ? " --commentWithDev" : ""} \`\`\` ## Benefits