Skip to content

Commit

Permalink
feat(upgrade): prevent changing the structure of package.json file du…
Browse files Browse the repository at this point in the history
…ring upgrade (#7167)

Co-authored-by: blzsaa <blzsaa@users.noreply.github.com>
  • Loading branch information
blzsaa and blzsaa committed Jun 16, 2022
1 parent 27dba1a commit 64446e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/@vue/cli/lib/Generator.js
Expand Up @@ -192,7 +192,8 @@ module.exports = class Generator {

async generate ({
extractConfigFiles = false,
checkExisting = false
checkExisting = false,
sortPackageJson = true
} = {}) {
await this.initPlugins()

Expand All @@ -203,7 +204,9 @@ module.exports = class Generator {
// wait for file resolve
await this.resolveFiles()
// set package.json
this.sortPkg()
if (sortPackageJson) {
this.sortPkg()
}
this.files['package.json'] = JSON.stringify(this.pkg, null, 2) + '\n'
// write/update file tree to disk
await writeFileTree(this.context, this.files, initialFiles, this.filesModifyRecord)
Expand Down
3 changes: 2 additions & 1 deletion packages/@vue/cli/lib/migrate.js
Expand Up @@ -31,7 +31,8 @@ async function runMigrator (context, plugin, pkg = getPkg(context)) {
log(`🚀 Running migrator of ${plugin.id}`)
await migrator.generate({
extractConfigFiles: true,
checkExisting: true
checkExisting: true,
sortPackageJson: false
})

const newDeps = migrator.pkg.dependencies
Expand Down

0 comments on commit 64446e0

Please sign in to comment.