fix(cli): prepublish command (#1860)
This commit is contained in:
parent
5cab2bc57b
commit
f825972b75
4 changed files with 9 additions and 9 deletions
|
@ -531,6 +531,7 @@ const PRE_PUBLISH_OPTIONS: CommandSchema = {
|
||||||
type: "'npm' | 'lerna'",
|
type: "'npm' | 'lerna'",
|
||||||
description: 'git tag style, `npm` or `lerna`',
|
description: 'git tag style, `npm` or `lerna`',
|
||||||
default: "'lerna'",
|
default: "'lerna'",
|
||||||
|
short: 't',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ghRelease',
|
name: 'ghRelease',
|
||||||
|
|
|
@ -29,7 +29,7 @@ new NapiCli().prePublish({
|
||||||
| configPath | --config-path,-c | string | false | | Path to `napi` config json file |
|
| configPath | --config-path,-c | string | false | | Path to `napi` config json file |
|
||||||
| packageJsonPath | --package-json-path | string | false | 'package.json' | Path to `package.json` |
|
| 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 |
|
| 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 |
|
| ghRelease | --gh-release | boolean | false | true | Whether create GitHub release |
|
||||||
| ghReleaseName | --gh-release-name | string | false | | GitHub release name |
|
| ghReleaseName | --gh-release-name | string | false | | GitHub release name |
|
||||||
| ghReleaseId | --gh-release-id | string | false | | Existing GitHub release id |
|
| ghReleaseId | --gh-release-id | string | false | | Existing GitHub release id |
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { execSync } from 'child_process'
|
import { execSync } from 'child_process'
|
||||||
import { existsSync, statSync } from 'fs'
|
import { existsSync, statSync } from 'fs'
|
||||||
import { join, relative, resolve } from 'path'
|
import { join, resolve } from 'path'
|
||||||
|
|
||||||
import { Octokit } from '@octokit/rest'
|
import { Octokit } from '@octokit/rest'
|
||||||
|
|
||||||
|
@ -31,14 +31,13 @@ export async function prePublish(userOptions: PrePublishOptions) {
|
||||||
|
|
||||||
const options = applyDefaultPrePublishOptions(userOptions)
|
const options = applyDefaultPrePublishOptions(userOptions)
|
||||||
|
|
||||||
const configPath = relative(
|
const packageJsonPath = resolve(options.cwd, options.packageJsonPath)
|
||||||
options.cwd,
|
|
||||||
options.configPath ?? options.packageJsonPath,
|
|
||||||
)
|
|
||||||
const packageJsonPath = relative(options.cwd, options.packageJsonPath)
|
|
||||||
|
|
||||||
const { packageJson, targets, packageName, binaryName, npmClient } =
|
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) {
|
async function createGhRelease(packageName: string, version: string) {
|
||||||
if (!options.ghRelease) {
|
if (!options.ghRelease) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ export abstract class BasePrePublishCommand extends Command {
|
||||||
description: 'Path to the folder where the npm packages put',
|
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`',
|
description: 'git tag style, `npm` or `lerna`',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue