feat(upgrade): prevent changing the structure of package.json file during upgrade (#7167)

Co-authored-by: blzsaa <blzsaa@users.noreply.github.com>
This commit is contained in:
blzsaa
2022-06-16 13:49:31 +08:00
committed by GitHub
co-authored by blzsaa
parent 27dba1ac6d
commit 64446e035d
2 changed files with 7 additions and 3 deletions
+5 -2
View File
@@ -192,7 +192,8 @@ module.exports = class Generator {
async generate ({
extractConfigFiles = false,
checkExisting = false
checkExisting = false,
sortPackageJson = true
} = {}) {
await this.initPlugins()
@@ -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)
+2 -1
View File
@@ -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