Skip to content

Commit 64446e0

Browse files
authored
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

Lines changed: 5 additions & 2 deletions
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

Lines changed: 2 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy