| 1 | import { join } from 'node:path' |
| 2 | import { objectMap } from '@antfu/utils' |
| 3 | import { fs } from 'zx' |
| 4 | |
| 5 | const templates = [ |
| 6 | 'packages/create-app/template', |
| 7 | 'packages/create-theme/template', |
| 8 | ] |
| 9 | |
| 10 | const { version } = await fs.readJSON('package.json') |
| 11 | |
| 12 | for (const template of templates) { |
| 13 | const path = join(template, 'package.json') |
| 14 | const pkg = await fs.readJSON(path) |
| 15 | const deps = ['dependencies', 'devDependencies'] |
| 16 | for (const name of deps) { |
| 17 | if (!pkg[name]) |
| 18 | continue |
| 19 | pkg[name] = objectMap(pkg[name], (k, v) => { |
| 20 | if (k.startsWith('@slidev/') && !k.startsWith('@slidev/theme')) |
| 21 | return [k, `^${version}`] |
| 22 | return [k, v] |
| 23 | }) |
| 24 | } |
| 25 | await fs.writeJSON(path, pkg, { spaces: 2 }) |
| 26 | } |
| 27 |