Skip to content
/ vue-cli Public
  • Sponsor vuejs/vue-cli

  • Notifications You must be signed in to change notification settings
  • Fork 6.3k

Commit 64446e0

Browse files
authoredJun 16, 2022
feat(upgrade): prevent changing the structure of package.json file during upgrade (#7167)
Co-authored-by: blzsaa <blzsaa@users.noreply.github.com>
1 parent 27dba1a commit 64446e0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
 

‎packages/@vue/cli/lib/Generator.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ module.exports = class Generator {
192192

193193
async generate ({
194194
extractConfigFiles = false,
195-
checkExisting = false
195+
checkExisting = false,
196+
sortPackageJson = true
196197
} = {}) {
197198
await this.initPlugins()
198199

@@ -203,7 +204,9 @@ module.exports = class Generator {
203204
// wait for file resolve
204205
await this.resolveFiles()
205206
// set package.json
206-
this.sortPkg()
207+
if (sortPackageJson) {
208+
this.sortPkg()
209+
}
207210
this.files['package.json'] = JSON.stringify(this.pkg, null, 2) + '\n'
208211
// write/update file tree to disk
209212
await writeFileTree(this.context, this.files, initialFiles, this.filesModifyRecord)

‎packages/@vue/cli/lib/migrate.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ async function runMigrator (context, plugin, pkg = getPkg(context)) {
3131
log(`🚀 Running migrator of ${plugin.id}`)
3232
await migrator.generate({
3333
extractConfigFiles: true,
34-
checkExisting: true
34+
checkExisting: true,
35+
sortPackageJson: false
3536
})
3637

3738
const newDeps = migrator.pkg.dependencies

0 commit comments

Comments
 (0)