From 7929aea323d8c68eff701d25e4635f6a05f46851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Wed, 30 Apr 2025 12:32:58 +0800 Subject: [PATCH 1/6] fix: format package.json --- packages/cli/index.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/cli/index.ts b/packages/cli/index.ts index eb29494c..7af438e0 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -253,7 +253,6 @@ const main = defineCommand({ const restore = await writeDeps( templateDir, - pJsonContents, pJson, deps, realDeps, @@ -336,7 +335,7 @@ const main = defineCommand({ restoreMap.set( p, - await writeDeps(p, pJsonContents, pJson, deps, realDeps), + await writeDeps(p, pJson, deps, realDeps), ); } @@ -554,7 +553,6 @@ async function resolveTarball(pm: "npm" | "pnpm", p: string) { async function writeDeps( p: string, - pJsonContents: string, pJson: PackageJson, deps: Map, realDeps: Map | null, @@ -569,9 +567,9 @@ async function writeDeps( hijackDeps(realDeps, pJson.peerDependencies); } - await writePackageJSON(pJsonPath, pJson); - - return () => fs.writeFile(pJsonPath, pJsonContents); + + const res = await writePackageJSON(pJsonPath, pJson); + return ()=> res; } function hijackDeps( From a6ce80e67c9ec0e2fe4344d7def54d02b6e69162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Wed, 30 Apr 2025 12:36:23 +0800 Subject: [PATCH 2/6] chore: fix lint --- packages/cli/index.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/cli/index.ts b/packages/cli/index.ts index 7af438e0..3a8a180c 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -251,12 +251,7 @@ const main = defineCommand({ console.warn("preparing template:", pJson.name); - const restore = await writeDeps( - templateDir, - pJson, - deps, - realDeps, - ); + const restore = await writeDeps(templateDir, pJson, deps, realDeps); const gitignorePath = path.join(templateDir, ".gitignore"); const ig = ignore().add("node_modules").add(".git"); @@ -333,10 +328,7 @@ const main = defineCommand({ continue; } - restoreMap.set( - p, - await writeDeps(p, pJson, deps, realDeps), - ); + restoreMap.set(p, await writeDeps(p, pJson, deps, realDeps)); } const shasums: Record = {}; @@ -567,9 +559,8 @@ async function writeDeps( hijackDeps(realDeps, pJson.peerDependencies); } - const res = await writePackageJSON(pJsonPath, pJson); - return ()=> res; + return () => res; } function hijackDeps( From 9b3c83d4b196f8d35a1960de52ad9ce2afe59eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Wed, 30 Apr 2025 13:57:23 +0800 Subject: [PATCH 3/6] fix --- packages/cli/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/cli/index.ts b/packages/cli/index.ts index 3a8a180c..dd4a8f57 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -18,7 +18,7 @@ import { glob } from "tinyglobby"; import ignore from "ignore"; import "./environments"; import { isBinaryFile } from "isbinaryfile"; -import { writePackageJSON, type PackageJson } from "pkg-types"; +import { type PackageJson } from "pkg-types"; import pkg from "./package.json" with { type: "json" }; import { createDefaultTemplate } from "./template"; @@ -543,7 +543,7 @@ async function resolveTarball(pm: "npm" | "pnpm", p: string) { return { filename, shasum }; } -async function writeDeps( + function writeDeps( p: string, pJson: PackageJson, deps: Map, @@ -559,8 +559,7 @@ async function writeDeps( hijackDeps(realDeps, pJson.peerDependencies); } - const res = await writePackageJSON(pJsonPath, pJson); - return () => res; + return ()=> fs.writeFile(pJsonPath, JSON.stringify(pJson,null,2)) } function hijackDeps( From 7764c35cd087309eccb188f52914957d4d857280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Wed, 30 Apr 2025 14:00:28 +0800 Subject: [PATCH 4/6] lint --- packages/cli/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/index.ts b/packages/cli/index.ts index dd4a8f57..592f58ae 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -543,7 +543,7 @@ async function resolveTarball(pm: "npm" | "pnpm", p: string) { return { filename, shasum }; } - function writeDeps( +function writeDeps( p: string, pJson: PackageJson, deps: Map, @@ -559,7 +559,7 @@ async function resolveTarball(pm: "npm" | "pnpm", p: string) { hijackDeps(realDeps, pJson.peerDependencies); } - return ()=> fs.writeFile(pJsonPath, JSON.stringify(pJson,null,2)) + return () => fs.writeFile(pJsonPath, JSON.stringify(pJson, null, 2)); } function hijackDeps( From c14b5356c47bda147a26a2645798743862274bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Wed, 30 Apr 2025 14:15:13 +0800 Subject: [PATCH 5/6] fix --- packages/cli/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cli/index.ts b/packages/cli/index.ts index 592f58ae..c2660229 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -18,7 +18,7 @@ import { glob } from "tinyglobby"; import ignore from "ignore"; import "./environments"; import { isBinaryFile } from "isbinaryfile"; -import { type PackageJson } from "pkg-types"; +import type { PackageJson } from "pkg-types"; import pkg from "./package.json" with { type: "json" }; import { createDefaultTemplate } from "./template"; @@ -251,7 +251,7 @@ const main = defineCommand({ console.warn("preparing template:", pJson.name); - const restore = await writeDeps(templateDir, pJson, deps, realDeps); + const restore = writeDeps(templateDir, pJson, deps, realDeps); const gitignorePath = path.join(templateDir, ".gitignore"); const ig = ignore().add("node_modules").add(".git"); @@ -559,7 +559,8 @@ function writeDeps( hijackDeps(realDeps, pJson.peerDependencies); } - return () => fs.writeFile(pJsonPath, JSON.stringify(pJson, null, 2)); + return async () => + await fs.writeFile(pJsonPath, JSON.stringify(pJson, null, 2)); } function hijackDeps( From 1f1d128f28fae3b95918ad8b96a5fd3d7384dd0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Wed, 30 Apr 2025 16:31:50 +0800 Subject: [PATCH 6/6] lint --- packages/cli/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/cli/index.ts b/packages/cli/index.ts index c2660229..9f5c80a1 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -559,8 +559,7 @@ function writeDeps( hijackDeps(realDeps, pJson.peerDependencies); } - return async () => - await fs.writeFile(pJsonPath, JSON.stringify(pJson, null, 2)); + return () => fs.writeFile(pJsonPath, JSON.stringify(pJson, null, 2)); } function hijackDeps(