| 17 | } |
| 18 | |
| 19 | export function addPackageJSONScripts(scripts: Record<string, string>) { |
| 20 | const packageJsonPath = path.resolve("./package.json"); |
| 21 | const packageJson = fs.readJSONSync(packageJsonPath) as PackageJson; |
| 22 | |
| 23 | const newPackageJson = { |
| 24 | ...packageJson, |
| 25 | scripts: { |
| 26 | ...packageJson.scripts |
| 27 | } |
| 28 | }; |
| 29 | for (const key of Object.keys(scripts)) { |
| 30 | if (!newPackageJson.scripts[key]) { |
| 31 | newPackageJson.scripts[key] = scripts[key]; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | return fs.writeJSONSync(packageJsonPath, newPackageJson, { |
| 36 | spaces: 2, |
| 37 | EOL: "\n" |
| 38 | }); |
| 39 | } |
| 40 | |
| 41 | export async function getPackageManager(): Promise< |
| 42 | "yarn" | "pnpm" | "bun" | "npm" |