fix(cli): prepublish tagstyle flag (#1863)
This commit is contained in:
parent
9211660c72
commit
0faf752c02
4 changed files with 47 additions and 41 deletions
|
@ -11,7 +11,8 @@ export interface OptionSchema {
|
||||||
description: string
|
description: string
|
||||||
required?: boolean
|
required?: boolean
|
||||||
default?: any
|
default?: any
|
||||||
short?: string
|
short?: string[]
|
||||||
|
alias?: string[]
|
||||||
long?: string
|
long?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,14 +43,14 @@ const NEW_OPTIONS: CommandSchema = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description:
|
description:
|
||||||
'The name of the project, default to the name of the directory if not provided',
|
'The name of the project, default to the name of the directory if not provided',
|
||||||
short: 'n',
|
short: ['n'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'minNodeApiVersion',
|
name: 'minNodeApiVersion',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'The minimum Node-API version to support',
|
description: 'The minimum Node-API version to support',
|
||||||
default: 4,
|
default: 4,
|
||||||
short: 'v',
|
short: ['v'],
|
||||||
long: 'min-node-api',
|
long: 'min-node-api',
|
||||||
},
|
},
|
||||||
// will support it later
|
// will support it later
|
||||||
|
@ -63,14 +64,14 @@ const NEW_OPTIONS: CommandSchema = {
|
||||||
name: 'license',
|
name: 'license',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'License for open-sourced project',
|
description: 'License for open-sourced project',
|
||||||
short: 'l',
|
short: ['l'],
|
||||||
default: "'MIT'",
|
default: "'MIT'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'targets',
|
name: 'targets',
|
||||||
type: 'string[]',
|
type: 'string[]',
|
||||||
description: 'All targets the crate will be compiled for.',
|
description: 'All targets the crate will be compiled for.',
|
||||||
short: 't',
|
short: ['t'],
|
||||||
default: '[]',
|
default: '[]',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -117,7 +118,7 @@ const BUILD_OPTIONS: CommandSchema = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description:
|
description:
|
||||||
'Build for the target triple, bypassed to `cargo build --target`',
|
'Build for the target triple, bypassed to `cargo build --target`',
|
||||||
short: 't',
|
short: ['t'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'cwd',
|
name: 'cwd',
|
||||||
|
@ -134,7 +135,7 @@ const BUILD_OPTIONS: CommandSchema = {
|
||||||
name: 'configPath',
|
name: 'configPath',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'Path to `napi` config json file',
|
description: 'Path to `napi` config json file',
|
||||||
short: 'c',
|
short: ['c'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'packageJsonPath',
|
name: 'packageJsonPath',
|
||||||
|
@ -152,7 +153,7 @@ const BUILD_OPTIONS: CommandSchema = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description:
|
description:
|
||||||
'Path to where all the built files would be put. Default to the crate folder',
|
'Path to where all the built files would be put. Default to the crate folder',
|
||||||
short: 'o',
|
short: ['o'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'platform',
|
name: 'platform',
|
||||||
|
@ -207,19 +208,19 @@ const BUILD_OPTIONS: CommandSchema = {
|
||||||
name: 'strip',
|
name: 'strip',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Whether strip the library to achieve the minimum file size',
|
description: 'Whether strip the library to achieve the minimum file size',
|
||||||
short: 's',
|
short: ['s'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'release',
|
name: 'release',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Build in release mode',
|
description: 'Build in release mode',
|
||||||
short: 'r',
|
short: ['r'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'verbose',
|
name: 'verbose',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Verbosely log build command trace',
|
description: 'Verbosely log build command trace',
|
||||||
short: 'v',
|
short: ['v'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'bin',
|
name: 'bin',
|
||||||
|
@ -230,7 +231,7 @@ const BUILD_OPTIONS: CommandSchema = {
|
||||||
name: 'package',
|
name: 'package',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'Build the specified library or the one at cwd',
|
description: 'Build the specified library or the one at cwd',
|
||||||
short: 'p',
|
short: ['p'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'profile',
|
name: 'profile',
|
||||||
|
@ -242,7 +243,7 @@ const BUILD_OPTIONS: CommandSchema = {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description:
|
description:
|
||||||
'[experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform',
|
'[experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform',
|
||||||
short: 'x',
|
short: ['x'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'useCross',
|
name: 'useCross',
|
||||||
|
@ -261,13 +262,13 @@ const BUILD_OPTIONS: CommandSchema = {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description:
|
description:
|
||||||
'watch the crate changes and build continuously with `cargo-watch` crates',
|
'watch the crate changes and build continuously with `cargo-watch` crates',
|
||||||
short: 'w',
|
short: ['w'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'features',
|
name: 'features',
|
||||||
type: 'string[]',
|
type: 'string[]',
|
||||||
description: 'Space-separated list of features to activate',
|
description: 'Space-separated list of features to activate',
|
||||||
short: 'F',
|
short: ['F'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'allFeatures',
|
name: 'allFeatures',
|
||||||
|
@ -299,7 +300,7 @@ const ARTIFACTS_OPTIONS: CommandSchema = {
|
||||||
name: 'configPath',
|
name: 'configPath',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'Path to `napi` config json file',
|
description: 'Path to `napi` config json file',
|
||||||
short: 'c',
|
short: ['c'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'packageJsonPath',
|
name: 'packageJsonPath',
|
||||||
|
@ -312,7 +313,7 @@ const ARTIFACTS_OPTIONS: CommandSchema = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description:
|
description:
|
||||||
'Path to the folder where all built `.node` files put, same as `--output-dir` of build command',
|
'Path to the folder where all built `.node` files put, same as `--output-dir` of build command',
|
||||||
short: 'o',
|
short: ['o'],
|
||||||
default: "'./artifacts'",
|
default: "'./artifacts'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -340,7 +341,7 @@ const CREATE_NPM_DIRS_OPTIONS: CommandSchema = {
|
||||||
name: 'configPath',
|
name: 'configPath',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'Path to `napi` config json file',
|
description: 'Path to `napi` config json file',
|
||||||
short: 'c',
|
short: ['c'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'packageJsonPath',
|
name: 'packageJsonPath',
|
||||||
|
@ -379,7 +380,7 @@ const RENAME_OPTIONS: CommandSchema = {
|
||||||
name: 'configPath',
|
name: 'configPath',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'Path to `napi` config json file',
|
description: 'Path to `napi` config json file',
|
||||||
short: 'c',
|
short: ['c'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'packageJsonPath',
|
name: 'packageJsonPath',
|
||||||
|
@ -397,13 +398,13 @@ const RENAME_OPTIONS: CommandSchema = {
|
||||||
name: 'name',
|
name: 'name',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'The new name of the project',
|
description: 'The new name of the project',
|
||||||
short: 'n',
|
short: ['n'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'binaryName',
|
name: 'binaryName',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'The new binary name *.node files',
|
description: 'The new binary name *.node files',
|
||||||
short: 'b',
|
short: ['b'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'packageName',
|
name: 'packageName',
|
||||||
|
@ -445,7 +446,7 @@ const UNIVERSALIZE_OPTIONS: CommandSchema = {
|
||||||
name: 'configPath',
|
name: 'configPath',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'Path to `napi` config json file',
|
description: 'Path to `napi` config json file',
|
||||||
short: 'c',
|
short: ['c'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'packageJsonPath',
|
name: 'packageJsonPath',
|
||||||
|
@ -458,7 +459,7 @@ const UNIVERSALIZE_OPTIONS: CommandSchema = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description:
|
description:
|
||||||
'Path to the folder where all built `.node` files put, same as `--output-dir` of build command',
|
'Path to the folder where all built `.node` files put, same as `--output-dir` of build command',
|
||||||
short: 'o',
|
short: ['o'],
|
||||||
default: "'./'",
|
default: "'./'",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -480,7 +481,7 @@ const VERSION_OPTIONS: CommandSchema = {
|
||||||
name: 'configPath',
|
name: 'configPath',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'Path to `napi` config json file',
|
description: 'Path to `napi` config json file',
|
||||||
short: 'c',
|
short: ['c'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'packageJsonPath',
|
name: 'packageJsonPath',
|
||||||
|
@ -515,7 +516,7 @@ const PRE_PUBLISH_OPTIONS: CommandSchema = {
|
||||||
name: 'configPath',
|
name: 'configPath',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'Path to `napi` config json file',
|
description: 'Path to `napi` config json file',
|
||||||
short: 'c',
|
short: ['c'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'packageJsonPath',
|
name: 'packageJsonPath',
|
||||||
|
@ -528,13 +529,15 @@ const PRE_PUBLISH_OPTIONS: CommandSchema = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'Path to the folder where the npm packages put',
|
description: 'Path to the folder where the npm packages put',
|
||||||
default: "'npm'",
|
default: "'npm'",
|
||||||
|
short: ['p'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'tagStyle',
|
name: 'tagStyle',
|
||||||
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',
|
alias: ['tagstyle'],
|
||||||
|
short: ['t'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ghRelease',
|
name: 'ghRelease',
|
||||||
|
|
|
@ -67,8 +67,11 @@ function generateOptionsDef(command: CommandSchema) {
|
||||||
|
|
||||||
function getOptionDescriptor(opt: OptionSchema) {
|
function getOptionDescriptor(opt: OptionSchema) {
|
||||||
let desc = `--${opt.long ?? kebabCase(opt.name)}`
|
let desc = `--${opt.long ?? kebabCase(opt.name)}`
|
||||||
|
if (opt.alias) {
|
||||||
|
desc += `,${opt.alias.map((alias) => `--${alias}`).join(',')}`
|
||||||
|
}
|
||||||
if (opt.short) {
|
if (opt.short) {
|
||||||
desc += `,-${opt.short}`
|
desc += `,${opt.short.map((short) => `-${short}`).join(',')}`
|
||||||
}
|
}
|
||||||
|
|
||||||
return desc
|
return desc
|
||||||
|
|
|
@ -22,15 +22,15 @@ new NapiCli().prePublish({
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
| Options | CLI Options | type | required | default | description |
|
| Options | CLI Options | type | required | default | description |
|
||||||
| --------------- | ------------------- | ---------------- | -------- | -------------- | ------------------------------------------------------------------------------------------------------------------ |
|
| --------------- | ------------------------- | ---------------- | -------- | -------------- | ------------------------------------------------------------------------------------------------------------------ |
|
||||||
| | --help,-h | | | | get help |
|
| | --help,-h | | | | get help |
|
||||||
| cwd | --cwd | string | false | process.cwd() | The working directory of where napi command will be executed in, all other paths options are relative to this path |
|
| cwd | --cwd | string | false | process.cwd() | The working directory of where napi command will be executed in, all other paths options are relative to this path |
|
||||||
| 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,-p | string | false | 'npm' | Path to the folder where the npm packages put |
|
||||||
| tagStyle | --tag-style,-t | 'npm' \| 'lerna' | false | 'lerna' | git tag style, `npm` or `lerna` |
|
| tagStyle | --tag-style,--tagstyle,-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 |
|
||||||
| dryRun | --dry-run | boolean | false | false | Dry run without touching file system |
|
| dryRun | --dry-run | boolean | false | false | Dry run without touching file system |
|
||||||
|
|
|
@ -23,11 +23,11 @@ export abstract class BasePrePublishCommand extends Command {
|
||||||
description: 'Path to `package.json`',
|
description: 'Path to `package.json`',
|
||||||
})
|
})
|
||||||
|
|
||||||
npmDir = Option.String('--npm-dir', 'npm', {
|
npmDir = Option.String('--npm-dir,-p', 'npm', {
|
||||||
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,-t', 'lerna', {
|
tagStyle = Option.String('--tag-style,--tagstyle,-t', 'lerna', {
|
||||||
description: 'git tag style, `npm` or `lerna`',
|
description: 'git tag style, `npm` or `lerna`',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue