1
1
/**
2
2
* modified from https://github.com/vuejs/core/blob/master/scripts/release.js
3
3
*/
4
- import { existsSync , readFileSync , readdirSync , writeFileSync } from 'fs'
4
+ import { existsSync , readdirSync , writeFileSync } from 'fs'
5
5
import path from 'path'
6
6
import colors from 'picocolors'
7
7
import type { Options as ExecaOptions } from 'execa'
8
8
import execa from 'execa'
9
9
import type { ReleaseType } from 'semver'
10
10
import semver from 'semver'
11
+ import fs from 'fs-extra'
12
+ import minimist from 'minimist'
11
13
12
- export const args = require ( ' minimist' ) ( process . argv . slice ( 2 ) )
14
+ export const args = minimist ( process . argv . slice ( 2 ) )
13
15
14
16
export const isDryRun = ! ! args . dry
15
17
@@ -136,7 +138,7 @@ export function getVersionChoices(currentVersion: string) {
136
138
}
137
139
138
140
export function updateVersion ( pkgPath : string , version : string ) : void {
139
- const pkg = JSON . parse ( readFileSync ( pkgPath , 'utf-8' ) )
141
+ const pkg = fs . readJSONSync ( pkgPath )
140
142
pkg . version = version
141
143
writeFileSync ( pkgPath , JSON . stringify ( pkg , null , 2 ) + '\n' )
142
144
}
@@ -195,7 +197,8 @@ export async function logRecentCommits(pkgName: string) {
195
197
}
196
198
197
199
export async function updateTemplateVersions ( ) {
198
- const viteVersion = require ( '../packages/vite/package.json' ) . version
200
+ const viteVersion = ( await fs . readJSON ( '../packages/vite/package.json' ) )
201
+ . version
199
202
if ( / b e t a | a l p h a | r c / . test ( viteVersion ) ) return
200
203
201
204
const dir = path . resolve ( __dirname , '../packages/create-vite' )
@@ -209,7 +212,7 @@ export async function updateTemplateVersions() {
209
212
pkg . devDependencies . vite = `^` + viteVersion
210
213
if ( template . startsWith ( 'template-vue' ) ) {
211
214
pkg . devDependencies [ '@vitejs/plugin-vue' ] =
212
- `^` + require ( '../packages/plugin-vue/package.json' ) . version
215
+ `^` + ( await fs . readJSON ( '../packages/plugin-vue/package.json' ) ) . version
213
216
}
214
217
writeFileSync ( pkgPath , JSON . stringify ( pkg , null , 2 ) + '\n' )
215
218
}
0 commit comments