From 2b7a6348f6f3e7b426fb5ea235c44891a85c4c71 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sat, 16 Dec 2023 14:14:59 +0800 Subject: [PATCH] fix(cli): make prepublish as pre-publish alias (#1861) --- cli/codegen/commands.ts | 3 +++ cli/codegen/index.ts | 9 ++++++++- cli/src/def/pre-publish.ts | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cli/codegen/commands.ts b/cli/codegen/commands.ts index 120c8bad..e4b82259 100644 --- a/cli/codegen/commands.ts +++ b/cli/codegen/commands.ts @@ -17,6 +17,7 @@ export interface OptionSchema { export interface CommandSchema { name: string + alias?: string[] description: string args: ArgSchema[] options: OptionSchema[] @@ -500,6 +501,8 @@ const PRE_PUBLISH_OPTIONS: CommandSchema = { name: 'prePublish', description: 'Update package.json and copy addons into per platform packages', args: [], + // compatible with old command name + alias: ['prepublish'], options: [ { name: 'cwd', diff --git a/cli/codegen/index.ts b/cli/codegen/index.ts index 55ea0721..eca5d203 100644 --- a/cli/codegen/index.ts +++ b/cli/codegen/index.ts @@ -85,9 +85,16 @@ function generateCommandDef(command: CommandSchema) { const prepare: string[] = [] const cmdLines: string[] = [] + let paths = `[['${commandPath}']]` + + if (command.alias) { + command.alias.unshift(commandPath) + paths = `[['${command.alias.join(', ')}']]` + } + cmdLines.push(` export abstract class Base${PascalCase(command.name)}Command extends Command { - static paths = [['${commandPath}']] + static paths = ${paths} static usage = Command.Usage({ description: '${command.description}', diff --git a/cli/src/def/pre-publish.ts b/cli/src/def/pre-publish.ts index d2770735..5bc2326b 100644 --- a/cli/src/def/pre-publish.ts +++ b/cli/src/def/pre-publish.ts @@ -3,7 +3,7 @@ import { Command, Option } from 'clipanion' export abstract class BasePrePublishCommand extends Command { - static paths = [['pre-publish']] + static paths = [['pre-publish, prepublish']] static usage = Command.Usage({ description: