fix(cli): prepublish command (#1860)

This commit is contained in:
LongYinan 2023-12-15 22:36:16 +08:00 committed by GitHub
parent 5cab2bc57b
commit f825972b75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 9 deletions

View file

@ -531,6 +531,7 @@ const PRE_PUBLISH_OPTIONS: CommandSchema = {
type: "'npm' | 'lerna'",
description: 'git tag style, `npm` or `lerna`',
default: "'lerna'",
short: 't',
},
{
name: 'ghRelease',

View file

@ -29,7 +29,7 @@ new NapiCli().prePublish({
| configPath | --config-path,-c | string | false | | Path to `napi` config json file |
| packageJsonPath | --package-json-path | string | false | 'package.json' | Path to `package.json` |
| npmDir | --npm-dir | string | false | 'npm' | Path to the folder where the npm packages put |
| tagStyle | --tag-style | 'npm' \| 'lerna' | false | 'lerna' | git tag style, `npm` or `lerna` |
| tagStyle | --tag-style,-t | 'npm' \| 'lerna' | false | 'lerna' | git tag style, `npm` or `lerna` |
| ghRelease | --gh-release | boolean | false | true | Whether create GitHub release |
| ghReleaseName | --gh-release-name | string | false | | GitHub release name |
| ghReleaseId | --gh-release-id | string | false | | Existing GitHub release id |

View file

@ -1,6 +1,6 @@
import { execSync } from 'child_process'
import { existsSync, statSync } from 'fs'
import { join, relative, resolve } from 'path'
import { join, resolve } from 'path'
import { Octokit } from '@octokit/rest'
@ -31,14 +31,13 @@ export async function prePublish(userOptions: PrePublishOptions) {
const options = applyDefaultPrePublishOptions(userOptions)
const configPath = relative(
options.cwd,
options.configPath ?? options.packageJsonPath,
)
const packageJsonPath = relative(options.cwd, options.packageJsonPath)
const packageJsonPath = resolve(options.cwd, options.packageJsonPath)
const { packageJson, targets, packageName, binaryName, npmClient } =
await readNapiConfig(configPath, configPath)
await readNapiConfig(
packageJsonPath,
options.configPath ? resolve(options.cwd, options.configPath) : undefined,
)
async function createGhRelease(packageName: string, version: string) {
if (!options.ghRelease) {

View file

@ -27,7 +27,7 @@ export abstract class BasePrePublishCommand extends Command {
description: 'Path to the folder where the npm packages put',
})
tagStyle = Option.String('--tag-style', 'lerna', {
tagStyle = Option.String('--tag-style,-t', 'lerna', {
description: 'git tag style, `npm` or `lerna`',
})