Skip to content

[ts-command-line] Remove deprecations and perform updates planned for the next major bump. #5203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/api-documenter/src/cli/BaseAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export abstract class BaseAction extends CommandLineAction {
protected constructor(options: ICommandLineActionOptions) {
super(options);

// override
this._inputFolderParameter = this.defineStringParameter({
parameterLongName: '--input-folder',
parameterShortName: '-i',
Expand Down
3 changes: 1 addition & 2 deletions apps/api-documenter/src/cli/GenerateAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export class GenerateAction extends BaseAction {
});
}

protected async onExecute(): Promise<void> {
// override
protected override async onExecuteAsync(): Promise<void> {
// Look for the config file under the current folder

let configFilePath: string = path.join(process.cwd(), DocumenterConfig.FILENAME);
Expand Down
3 changes: 1 addition & 2 deletions apps/api-documenter/src/cli/MarkdownAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export class MarkdownAction extends BaseAction {
});
}

protected async onExecute(): Promise<void> {
// override
protected override async onExecuteAsync(): Promise<void> {
const { apiModel, outputFolder } = this.buildApiModel();

const markdownDocumenter: MarkdownDocumenter = new MarkdownDocumenter({
Expand Down
3 changes: 1 addition & 2 deletions apps/api-documenter/src/cli/YamlAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ export class YamlAction extends BaseAction {
});
}

protected async onExecute(): Promise<void> {
// override
protected override async onExecuteAsync(): Promise<void> {
const { apiModel, inputFolder, outputFolder } = this.buildApiModel();

const yamlDocumenter: YamlDocumenter = this._officeParameter.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export class OfficeYamlDocumenter extends YamlDocumenter {

/** @override */
protected onGetTocRoot(): IYamlTocItem {
// override
return {
name: 'API reference',
href: 'overview.md',
Expand Down
13 changes: 7 additions & 6 deletions apps/api-extractor/src/cli/ApiExtractorCommandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,22 @@ export class ApiExtractorCommandLine extends CommandLineParser {
});
}

protected onExecute(): Promise<void> {
// override
protected override async onExecuteAsync(): Promise<void> {
if (this._debugParameter.value) {
InternalError.breakInDebugger = true;
}

return super.onExecute().catch((error) => {
process.exitCode = 1;
try {
await super.onExecuteAsync();
process.exitCode = 0;
} catch (error) {
if (this._debugParameter.value) {
console.error(os.EOL + error.stack);
} else {
console.error(os.EOL + Colorize.red('ERROR: ' + error.message.trim()));
}

process.exitCode = 1;
});
}
}

private _populateActions(): void {
Expand Down
3 changes: 1 addition & 2 deletions apps/api-extractor/src/cli/InitAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export class InitAction extends CommandLineAction {
});
}

protected async onExecute(): Promise<void> {
// override
protected override async onExecuteAsync(): Promise<void> {
const inputFilePath: string = path.resolve(__dirname, '../schemas/api-extractor-template.json');
const outputFilePath: string = path.resolve(ExtractorConfig.FILENAME);

Expand Down
3 changes: 1 addition & 2 deletions apps/api-extractor/src/cli/RunAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ export class RunAction extends CommandLineAction {
});
}

protected async onExecute(): Promise<void> {
// override
protected override async onExecuteAsync(): Promise<void> {
const lookup: PackageJsonLookup = new PackageJsonLookup();
let configFilename: string;

Expand Down
2 changes: 1 addition & 1 deletion apps/cpu-profile-summarizer/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class CpuProfileSummarizerCommandLineParser extends CommandLineParser {
});
}

protected async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
const input: readonly string[] = this._inputParameter.values;
const output: string = this._outputParameter.value;

Expand Down
6 changes: 3 additions & 3 deletions apps/heft/src/cli/HeftCommandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class HeftCommandLineParser extends CommandLineParser {
}
}

protected async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
try {
const selectedAction: CommandLineAction | undefined = this.selectedAction;

Expand All @@ -196,7 +196,7 @@ export class HeftCommandLineParser extends CommandLineParser {
commandName,
unaliasedCommandName
};
await super.onExecute();
await super.onExecuteAsync();
} catch (e) {
await this._reportErrorAndSetExitCodeAsync(e as Error);
}
Expand Down Expand Up @@ -228,7 +228,7 @@ export class HeftCommandLineParser extends CommandLineParser {
// try to evaluate any parameters. This is to ensure that the
// `--debug` flag is defined correctly before we do this not-so-rigorous
// parameter parsing.
throw new InternalError('onDefineParameters() has not yet been called.');
throw new InternalError('parameters have not yet been defined.');
}

const toolParameters: Set<string> = getToolParameterNamesFromArgs(args);
Expand Down
4 changes: 2 additions & 2 deletions apps/heft/src/cli/actions/AliasAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class AliasAction extends AliasCommandLineAction {
this._terminal = options.terminal;
}

protected async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
const toolFilename: string = this._toolFilename;
const actionName: string = this.actionName;
const targetAction: CommandLineAction = this.targetAction;
Expand All @@ -34,6 +34,6 @@ export class AliasAction extends AliasCommandLineAction {
`${defaultParametersString ? ` ${defaultParametersString}` : ''}".`
);

await super.onExecute();
await super.onExecuteAsync();
}
}
2 changes: 1 addition & 1 deletion apps/heft/src/cli/actions/CleanAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class CleanAction extends CommandLineAction implements IHeftAction {
return this._selectedPhases;
}

protected async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
const { heftConfiguration } = this._internalHeftSession;
const abortSignal: AbortSignal = ensureCliAbortSignal(this._terminal);

Expand Down
2 changes: 1 addition & 1 deletion apps/heft/src/cli/actions/PhaseAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class PhaseAction extends CommandLineAction implements IHeftAction {
return this._selectedPhases;
}

protected async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
await this._actionRunner.executeAsync();
}
}
2 changes: 1 addition & 1 deletion apps/heft/src/cli/actions/RunAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class RunAction extends ScopedCommandLineAction implements IHeftAction {
this._actionRunner.defineParameters(scopedParameterProvider);
}

protected async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
await this._actionRunner.executeAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class ExplorerCommandLineParser extends CommandLineParser {
return this._debugParameter.value;
}

protected async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
const lockfileExplorerProjectRoot: string = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname)!;
const lockfileExplorerPackageJson: IPackageJson = JsonFile.load(
`${lockfileExplorerProjectRoot}/package.json`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class LintCommandLineParser extends CommandLineParser {
this._populateActions();
}

protected override async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
const lockfileExplorerProjectRoot: string = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname)!;
const lockfileExplorerPackageJson: IPackageJson = JsonFile.load(
`${lockfileExplorerProjectRoot}/package.json`
Expand All @@ -37,7 +37,7 @@ export class LintCommandLineParser extends CommandLineParser {
Colorize.bold(`\nRush Lockfile Lint ${appVersion}`) + Colorize.cyan(' - https://lfx.rushstack.io/\n')
);

await super.onExecute();
await super.onExecuteAsync();
}

private _populateActions(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class CheckAction extends CommandLineAction {
}
}

protected async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
const rushConfiguration: RushConfiguration | undefined = RushConfiguration.tryLoadFromDefaultLocation();
if (!rushConfiguration) {
throw new Error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class InitAction extends CommandLineAction {
this._terminal = parser.globalTerminal;
}

protected async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
const rushConfiguration: RushConfiguration | undefined = RushConfiguration.tryLoadFromDefaultLocation();
if (!rushConfiguration) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion apps/rundown/src/cli/InspectAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class InspectAction extends BaseReportAction {
});
}

protected async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
const rundown: Rundown = new Rundown();
await rundown.invokeAsync(
this.scriptParameter.value,
Expand Down
2 changes: 1 addition & 1 deletion apps/rundown/src/cli/SnapshotAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class SnapshotAction extends BaseReportAction {
});
}

protected async onExecute(): Promise<void> {
protected override async onExecuteAsync(): Promise<void> {
const rundown: Rundown = new Rundown();
await rundown.invokeAsync(
this.scriptParameter.value,
Expand Down
3 changes: 1 addition & 2 deletions apps/trace-import/src/TraceImportCommandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ export class TraceImportCommandLineParser extends CommandLineParser {
});
}

protected async onExecute(): Promise<void> {
// override
protected override async onExecuteAsync(): Promise<void> {
if (this._debugParameter.value) {
InternalError.breakInDebugger = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.51.1"
"packageVersion": "7.52.4"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/api-documenter",
"comment": "",
"type": "none"
}
],
"packageName": "@microsoft/api-documenter"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/api-extractor",
"comment": "",
"type": "none"
}
],
"packageName": "@microsoft/api-extractor"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/cpu-profile-summarizer",
"comment": "",
"type": "none"
}
],
"packageName": "@rushstack/cpu-profile-summarizer"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft",
"comment": "",
"type": "none"
}
],
"packageName": "@rushstack/heft"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/lockfile-explorer",
"comment": "",
"type": "none"
}
],
"packageName": "@rushstack/lockfile-explorer"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/node-core-library",
"comment": "",
"type": "none"
}
],
"packageName": "@rushstack/node-core-library"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/package-extractor",
"comment": "",
"type": "none"
}
],
"packageName": "@rushstack/package-extractor"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/rundown",
"comment": "",
"type": "none"
}
],
"packageName": "@rushstack/rundown"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/trace-import",
"comment": "",
"type": "none"
}
],
"packageName": "@rushstack/trace-import"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/ts-command-line",
"comment": "Remove the deprecated `onDefineParameters`, `execute`, `executeWithoutErrorHandling`, and `onDefineUnscopedParameters` functions.",
"type": "major"
}
],
"packageName": "@rushstack/ts-command-line"
}
Loading
Loading