Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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