avancement planning
This commit is contained in:
+26
-16
@@ -5,7 +5,7 @@ const parseJSON = require('json-parse-even-better-errors')
|
||||
const updateDeps = require('./update-dependencies.js')
|
||||
const updateScripts = require('./update-scripts.js')
|
||||
const updateWorkspaces = require('./update-workspaces.js')
|
||||
const normalize = require('./normalize.js')
|
||||
const { normalize, syncNormalize } = require('./normalize.js')
|
||||
const { read, parse } = require('./read-package.js')
|
||||
const { packageSort } = require('./sort.js')
|
||||
|
||||
@@ -25,6 +25,18 @@ const knownKeys = new Set([
|
||||
])
|
||||
|
||||
class PackageJson {
|
||||
// npm pkg fix
|
||||
static fixSteps = Object.freeze([
|
||||
'binRefs',
|
||||
'bundleDependencies',
|
||||
'fixName',
|
||||
'fixVersionField',
|
||||
'fixRepositoryField',
|
||||
'fixDependencies',
|
||||
'devDependencies',
|
||||
'scriptpath',
|
||||
])
|
||||
|
||||
static normalizeSteps = Object.freeze([
|
||||
'_id',
|
||||
'_attributes',
|
||||
@@ -34,20 +46,7 @@ class PackageJson {
|
||||
'scripts',
|
||||
'funding',
|
||||
'bin',
|
||||
])
|
||||
|
||||
// npm pkg fix
|
||||
static fixSteps = Object.freeze([
|
||||
'binRefs',
|
||||
'bundleDependencies',
|
||||
'bundleDependenciesFalse',
|
||||
'fixName',
|
||||
'fixNameField',
|
||||
'fixVersionField',
|
||||
'fixRepositoryField',
|
||||
'fixDependencies',
|
||||
'devDependencies',
|
||||
'scriptpath',
|
||||
'binDir',
|
||||
])
|
||||
|
||||
static prepareSteps = Object.freeze([
|
||||
@@ -164,7 +163,11 @@ class PackageJson {
|
||||
return this
|
||||
}
|
||||
|
||||
// Manually set data from an existing object
|
||||
fromContent (data) {
|
||||
if (!data || typeof data !== 'object') {
|
||||
throw new Error('Content data must be an object')
|
||||
}
|
||||
this.#manifest = data
|
||||
this.#canSave = false
|
||||
return this
|
||||
@@ -222,7 +225,7 @@ class PackageJson {
|
||||
this.#manifest = step({ content, originalContent: this.content })
|
||||
}
|
||||
|
||||
// unknown properties will just be overwitten
|
||||
// unknown properties will just be overwritten
|
||||
for (const [key, value] of Object.entries(content)) {
|
||||
if (!knownKeys.has(key)) {
|
||||
this.content[key] = value
|
||||
@@ -259,6 +262,13 @@ class PackageJson {
|
||||
}
|
||||
}
|
||||
|
||||
// steps is NOT overrideable here because this is a legacy function that's not being used in new places
|
||||
syncNormalize (opts = {}) {
|
||||
opts.steps = this.constructor.normalizeSteps.filter(s => s !== '_attributes')
|
||||
syncNormalize(this, opts)
|
||||
return this
|
||||
}
|
||||
|
||||
async normalize (opts = {}) {
|
||||
if (!opts.steps) {
|
||||
opts.steps = this.constructor.normalizeSteps
|
||||
|
||||
Reference in New Issue
Block a user