Skip to content

Commit

Permalink
feat(cli): Deprecated flags/commands (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-cahill authored Oct 19, 2022
1 parent df07091 commit 4961854
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 101 deletions.
47 changes: 19 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"bugs": "https://github.com/architect-team/architect-cli/issues",
"dependencies": {
"@kubernetes/client-node": "^0.17.1",
"@oclif/core": "1.9.0",
"@oclif/core": "1.19.0",
"@oclif/plugin-autocomplete": "1.2.0",
"@oclif/plugin-help": "5.1.11",
"@oclif/plugin-not-found": "2.3.1",
Expand Down Expand Up @@ -51,6 +51,7 @@
"tmp": "^0.2.1",
"tslib": "2.3.1",
"typescript-json": "^3.3.10",
"typescript-memoize": "^1.1.1",
"untildify": "4.0.0",
"which": "^2.0.2",
"ws": "^8.4.0"
Expand Down
20 changes: 20 additions & 0 deletions patches/@oclif+core+1.19.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/node_modules/@oclif/core/lib/interfaces/parser.d.ts b/node_modules/@oclif/core/lib/interfaces/parser.d.ts
index f533dcc..29deae0 100644
--- a/node_modules/@oclif/core/lib/interfaces/parser.d.ts
+++ b/node_modules/@oclif/core/lib/interfaces/parser.d.ts
@@ -140,6 +140,7 @@ export declare type FlagProps = {
* List of flags that cannot be used with this flag.
*/
exclusive?: string[];
+ sensitive?: boolean;
/**
* Exactly one of these flags must be provided.
*/
@@ -159,7 +160,6 @@ export declare type FlagProps = {
};
export declare type BooleanFlagProps = FlagProps & {
type: 'boolean';
- allowNo: boolean;
};
export declare type OptionFlagProps = FlagProps & {
type: 'option';
12 changes: 0 additions & 12 deletions patches/@oclif+core+1.9.0.patch

This file was deleted.

14 changes: 4 additions & 10 deletions src/base-command.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { Command, Config, Interfaces } from '@oclif/core';
import '@sentry/tracing';
import chalk from 'chalk';
import { Memoize } from 'typescript-memoize';
import { Dictionary, ValidationErrors } from '.';
import AppService from './app-config/service';
import { prettyValidationErrors } from './common/dependency-manager/validation';
import LoginRequiredError from './common/errors/login-required';
import { isBooleanStringFlag } from './common/utils/oclif';
import SentryService from './sentry';

const DEPRECATED_LABEL = '[deprecated]';

export default abstract class BaseCommand extends Command {
static readonly DEPRECATED: string = DEPRECATED_LABEL;

app: AppService;
sentry: SentryService;

Expand Down Expand Up @@ -55,10 +52,10 @@ export default abstract class BaseCommand extends Command {
await this.sentry.startSentryTransaction();
}

// Move all args to the front of the argv to get around: https://github.com/oclif/oclif/issues/190
async parse<F, A extends {
@Memoize()
async parse<F, A extends { // Move all args to the front of the argv to get around: https://github.com/oclif/oclif/issues/190
[name: string]: any;
}>(options?: Interfaces.Input<F>, argv = this.argv): Promise<Interfaces.ParserOutput<F, A>> {
}>(options?: Interfaces.Input<F, A>, argv = this.argv): Promise<Interfaces.ParserOutput<F, A>> {
const flag_definitions = this.getClass().flags;

const flags_map: Dictionary<Interfaces.CompletableFlag<any> | undefined> = {};
Expand Down Expand Up @@ -95,9 +92,6 @@ export default abstract class BaseCommand extends Command {

if (is_flag) {
const flag_obj = flags_map[arg.split('=', 1)[0]];
if (flag_obj?.description?.startsWith(DEPRECATED_LABEL)) {
this.warn(`Flag ${arg.split('=', 1)[0]} is deprecated.${flag_obj.description.split(DEPRECATED_LABEL)[1]}`);
}
flag_option = flag_obj?.type === 'option' && !arg.includes('=');
} else {
flag_option = false;
Expand Down
43 changes: 31 additions & 12 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ export abstract class DeployCommand extends BaseCommand {
...BaseCommand.flags,
auto_approve: booleanString({
exclusive: ['compose-file', 'compose_file'],
description: `${BaseCommand.DEPRECATED} Please use --auto-approve.`,
description: `Please use --auto-approve.`,
hidden: true,
sensitive: false,
default: false,
default: undefined,
deprecated: {
to: 'auto-approve',
},
}),
'auto-approve': booleanString({
exclusive: ['compose-file', 'compose_file'],
Expand All @@ -34,7 +37,7 @@ export abstract class DeployCommand extends BaseCommand {

async parse<F, A extends {
[name: string]: any;
}>(options?: Interfaces.Input<F>, argv = this.argv): Promise<Interfaces.ParserOutput<F, A>> {
}>(options?: Interfaces.Input<F, A>, argv = this.argv): Promise<Interfaces.ParserOutput<F, A>> {
const parsed = await super.parse(options, argv) as Interfaces.ParserOutput<F, A>;
const flags: any = parsed.flags;

Expand Down Expand Up @@ -85,23 +88,30 @@ export default class Deploy extends DeployCommand {
...EnvironmentUtils.flags,
local: booleanString({
char: 'l',
description: `${BaseCommand.DEPRECATED} Deploy the stack locally instead of via Architect Cloud`,
description: `Deploy the stack locally instead of via Architect Cloud`,
exclusive: ['account', 'auto-approve', 'auto_approve', 'refresh'],
hidden: true,
sensitive: false,
default: false,
default: undefined,
deprecated: true,
}),
production: booleanString({
description: `${BaseCommand.DEPRECATED} Please use --environment.`,
description: `Please use --environment.`,
dependsOn: ['local'],
sensitive: false,
default: undefined,
deprecated: {
to: 'environment',
},
}),
compose_file: Flags.string({
description: `${BaseCommand.DEPRECATED} Please use --compose-file.`,
description: `Please use --compose-file.`,
exclusive: ['account', 'environment', 'auto-approve', 'auto_approve', 'refresh'],
hidden: true,
sensitive: false,
deprecated: {
to: 'compose-file',
},
}),
'compose-file': Flags.string({
char: 'o',
Expand All @@ -119,9 +129,12 @@ export default class Deploy extends DeployCommand {
}),
parameter: Flags.string({
char: 'p',
description: `${BaseCommand.DEPRECATED} Please use --secret.`,
description: `Please use --secret.`,
multiple: true,
hidden: true,
deprecated: {
to: 'secret',
},
}),
interface: Flags.string({
char: 'i',
Expand All @@ -136,9 +149,12 @@ export default class Deploy extends DeployCommand {
default: [],
}),
secrets: Flags.string({
description: `${BaseCommand.DEPRECATED} Please use --secret-file.`,
description: `Please use --secret-file.`,
multiple: true,
hidden: true,
deprecated: {
to: 'secret-file',
},
}),
secret: Flags.string({
char: 's',
Expand All @@ -150,7 +166,10 @@ export default class Deploy extends DeployCommand {
char: 'v',
hidden: true,
multiple: true,
description: `${BaseCommand.DEPRECATED} Please use --secret-file.`,
description: `Please use --secret-file.`,
deprecated: {
to: 'secret-file',
},
}),
'deletion-protection': booleanString({
default: true,
Expand Down Expand Up @@ -186,7 +205,7 @@ export default class Deploy extends DeployCommand {
// overrides the oclif default parse to allow for configs_or_components to be a list of components
async parse<F, A extends {
[name: string]: any;
}>(options?: Interfaces.Input<F>, argv = this.argv): Promise<Interfaces.ParserOutput<F, A>> {
}>(options?: Interfaces.Input<F, A>, argv = this.argv): Promise<Interfaces.ParserOutput<F, A>> {
if (!options) {
return super.parse(options, argv);
}
Expand All @@ -210,7 +229,7 @@ export default class Deploy extends DeployCommand {
const interfaces_map = DeployUtils.getInterfacesMap(flags.interface);
const all_secret_file_values = [...(flags['secret-file'] || []), ...(flags.secrets || [])]; // TODO: 404: remove
const component_secrets = DeployUtils.getComponentSecrets(flags.secret, all_secret_file_values); // TODO: 404: update
const component_parameters = DeployUtils.getComponentSecrets(flags.parameter, all_secret_file_values); // TODO: 404: remove
const component_parameters = DeployUtils.getComponentSecrets(flags.parameter || [], all_secret_file_values); // TODO: 404: remove
const all_secrets = { ...component_parameters, ...component_secrets }; // TODO: 404: remove

const account = await AccountUtils.getAccount(this.app, flags.account);
Expand Down
Loading

0 comments on commit 4961854

Please sign in to comment.