feat: update package.json again in prepublish
This commit is contained in:
parent
b61629cf34
commit
15cb7e5765
2 changed files with 16 additions and 12 deletions
|
@ -9,6 +9,7 @@ import { debugFactory } from './debug'
|
||||||
import { spawn } from './spawn'
|
import { spawn } from './spawn'
|
||||||
import { updatePackageJson } from './update-package'
|
import { updatePackageJson } from './update-package'
|
||||||
import { readFileAsync, writeFileAsync } from './utils'
|
import { readFileAsync, writeFileAsync } from './utils'
|
||||||
|
import { VersionCommand } from './version'
|
||||||
|
|
||||||
const debug = debugFactory('prepublish')
|
const debug = debugFactory('prepublish')
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ export class PrePublishCommand extends Command {
|
||||||
} = getNapiConfig(this.configFileName)
|
} = getNapiConfig(this.configFileName)
|
||||||
debug(`Update optionalDependencies in [${packageJsonPath}]`)
|
debug(`Update optionalDependencies in [${packageJsonPath}]`)
|
||||||
if (!this.isDryRun) {
|
if (!this.isDryRun) {
|
||||||
|
await VersionCommand.updatePackageJson(this.prefix, this.configFileName)
|
||||||
await updatePackageJson(packageJsonPath, {
|
await updatePackageJson(packageJsonPath, {
|
||||||
optionalDependencies: platforms.reduce(
|
optionalDependencies: platforms.reduce(
|
||||||
(acc: Record<string, string>, cur: NodeJS.Platform) => {
|
(acc: Record<string, string>, cur: NodeJS.Platform) => {
|
||||||
|
|
|
@ -11,19 +11,10 @@ import { updatePackageJson } from './update-package'
|
||||||
const debug = debugFactory('version')
|
const debug = debugFactory('version')
|
||||||
|
|
||||||
export class VersionCommand extends Command {
|
export class VersionCommand extends Command {
|
||||||
@Command.String(`-p,--prefix`)
|
static async updatePackageJson(prefix: string, configFileName?: string) {
|
||||||
prefix = 'npm'
|
const { muslPlatforms, version, platforms } = getNapiConfig(configFileName)
|
||||||
|
|
||||||
@Command.String('-c,--config')
|
|
||||||
configFileName?: string
|
|
||||||
|
|
||||||
@Command.Path('version')
|
|
||||||
async execute() {
|
|
||||||
const { muslPlatforms, version, platforms } = getNapiConfig(
|
|
||||||
this.configFileName,
|
|
||||||
)
|
|
||||||
for (const name of [...platforms, ...muslPlatforms]) {
|
for (const name of [...platforms, ...muslPlatforms]) {
|
||||||
const pkgDir = join(process.cwd(), this.prefix, name)
|
const pkgDir = join(process.cwd(), prefix, name)
|
||||||
debug(
|
debug(
|
||||||
`Update version to ${chalk.greenBright(
|
`Update version to ${chalk.greenBright(
|
||||||
version,
|
version,
|
||||||
|
@ -33,6 +24,17 @@ export class VersionCommand extends Command {
|
||||||
version,
|
version,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command.String(`-p,--prefix`)
|
||||||
|
prefix = 'npm'
|
||||||
|
|
||||||
|
@Command.String('-c,--config')
|
||||||
|
configFileName?: string
|
||||||
|
|
||||||
|
@Command.Path('version')
|
||||||
|
async execute() {
|
||||||
|
await VersionCommand.updatePackageJson(this.prefix, this.configFileName)
|
||||||
await spawn('git add .')
|
await spawn('git add .')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue