fix(cli): make prepublish as pre-publish alias (#1861)

This commit is contained in:
LongYinan 2023-12-16 14:14:59 +08:00 committed by GitHub
parent c7189a68c2
commit 2b7a6348f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View file

@ -17,6 +17,7 @@ export interface OptionSchema {
export interface CommandSchema { export interface CommandSchema {
name: string name: string
alias?: string[]
description: string description: string
args: ArgSchema[] args: ArgSchema[]
options: OptionSchema[] options: OptionSchema[]
@ -500,6 +501,8 @@ const PRE_PUBLISH_OPTIONS: CommandSchema = {
name: 'prePublish', name: 'prePublish',
description: 'Update package.json and copy addons into per platform packages', description: 'Update package.json and copy addons into per platform packages',
args: [], args: [],
// compatible with old command name
alias: ['prepublish'],
options: [ options: [
{ {
name: 'cwd', name: 'cwd',

View file

@ -85,9 +85,16 @@ function generateCommandDef(command: CommandSchema) {
const prepare: string[] = [] const prepare: string[] = []
const cmdLines: string[] = [] const cmdLines: string[] = []
let paths = `[['${commandPath}']]`
if (command.alias) {
command.alias.unshift(commandPath)
paths = `[['${command.alias.join(', ')}']]`
}
cmdLines.push(` cmdLines.push(`
export abstract class Base${PascalCase(command.name)}Command extends Command { export abstract class Base${PascalCase(command.name)}Command extends Command {
static paths = [['${commandPath}']] static paths = ${paths}
static usage = Command.Usage({ static usage = Command.Usage({
description: '${command.description}', description: '${command.description}',

View file

@ -3,7 +3,7 @@
import { Command, Option } from 'clipanion' import { Command, Option } from 'clipanion'
export abstract class BasePrePublishCommand extends Command { export abstract class BasePrePublishCommand extends Command {
static paths = [['pre-publish']] static paths = [['pre-publish, prepublish']]
static usage = Command.Usage({ static usage = Command.Usage({
description: description: