Skip to content

Commit

Permalink
Deprecate unsupported commands
Browse files Browse the repository at this point in the history
  • Loading branch information
David Dooling committed Aug 30, 2019
1 parent b9bd1ff commit b338934
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
9 changes: 6 additions & 3 deletions lib/cli/invocation/command/addBootstrapCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ export function addBootstrapCommands(yargs: YargBuilder): void {
addEnableLocalSupport(yargs);
}

function addExtensionPackGenerator(yargs: YargBuilder): void {
const name = "extensionPack";
function addExtensionPackGenerator(yargs: YargBuilder, deprecated?: boolean): void {
const name = deprecated ? "extensionPackDeprecated" : "extensionPack";
addEmbeddedCommand(yargs, {
name,
cliCommand: "create extension pack",
cliCommand: deprecated ? "create extension pack" : "create extension-pack",
cliDescription: "Create an Atomist extension pack",
configurer: async () => sdm => sdm.addGeneratorCommand({
name,
Expand All @@ -74,6 +74,7 @@ function addExtensionPackGenerator(yargs: YargBuilder): void {
infoMessage("Add your new extension pack to any SDM you please!\n");
},
}],
deprecated,
});
}

Expand Down Expand Up @@ -172,6 +173,7 @@ function addSuperforkGenerator(yargs: YargBuilder): void {
infoMessage("Superfork complete\n");
},
}],
deprecated: true,
});
}

Expand All @@ -194,5 +196,6 @@ function addEnableLocalSupport(yargs: YargBuilder): void {
adviceDoc("docs/runLocally.md");
},
}],
deprecated: true,
});
}
4 changes: 3 additions & 1 deletion lib/cli/invocation/command/addStartSdmDeliveryMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { startEmbeddedMachine } from "../../embedded/embeddedMachine";
import {
infoMessage,
logExceptionsToConsole,
warningMessage,
} from "../../ui/consoleOutput";
import { renderClientInfo } from "../../ui/renderClientInfo";
import { YargBuilder } from "./support/yargBuilder";
Expand All @@ -35,7 +36,7 @@ export const DefaultSdmCdPort = 2901;
export function addStartSdmDeliveryMachine(yargs: YargBuilder): void {
yargs.command({
command: "deliver",
describe: "Start SDM delivery machine",
describe: "DEPRECATED Start SDM delivery machine",
builder: args => {
return args.option("port", {
required: false,
Expand All @@ -50,6 +51,7 @@ export function addStartSdmDeliveryMachine(yargs: YargBuilder): void {
});
},
handler: argv => {
warningMessage(`The 'deliver' command is DEPRECATED and will be removed in a future release.\n`);
return logExceptionsToConsole(async () => {
const client = await startSdmMachine(argv.port, argv.base);
infoMessage("Started local SDM delivery machine \n\t%s\n",
Expand Down
11 changes: 8 additions & 3 deletions lib/cli/invocation/command/support/embeddedCommandExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
errorMessage,
infoMessage,
logExceptionsToConsole,
warningMessage,
} from "../../../ui/consoleOutput";
import { fetchMetadataFromAutomationClient } from "../../http/fetchMetadataFromAutomationClient";
import {
Expand Down Expand Up @@ -61,6 +62,8 @@ export interface EmbeddedCommandSpec {
*/
configurer: (argv: Arguments<any>) => Promise<ConfigureMachine>;

/** Is this command deprecated? */
deprecated?: boolean;
}

/**
Expand All @@ -71,11 +74,10 @@ export interface EmbeddedCommandSpec {
* being exposed as optional command parameters.
* @param {yargs.Argv} yargs
*/
export function addEmbeddedCommand(yargs: YargBuilder,
spec: EmbeddedCommandSpec): void {
export function addEmbeddedCommand(yargs: YargBuilder, spec: EmbeddedCommandSpec): void {
yargs.command({
command: spec.cliCommand,
describe: spec.cliDescription,
describe: (spec.deprecated ? "DEPRECATED " : "") + spec.cliDescription,
builder: ra => {
// Always require the repositoryOwnerParentDirectory, as
// we cannot create an embedded SDM otherwise
Expand All @@ -102,6 +104,9 @@ export function addEmbeddedCommand(yargs: YargBuilder,
return ra;
},
handler: async argv => {
if (spec.deprecated) {
warningMessage(`The '${spec.cliCommand}' command is DEPRECATED and will be removed in a future release.\n`);
}
return logExceptionsToConsole(async () => {
await runCommandOnEmbeddedMachine(
argv.repositoryOwnerParentDirectory,
Expand Down
21 changes: 2 additions & 19 deletions lib/cli/invocation/command/support/yargBuilder/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@
* limitations under the License.
*/

import { ConflictResolution } from "./interfaces";
/*
* Copyright © 2018 Atomist, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {
Arguments,
Argv as yargsArgv,
Expand All @@ -41,6 +24,7 @@ import {
} from "yargs";
import { CommandLine } from "./commandLine";
import { HandleInstructions } from "./handleInstruction";
import { ConflictResolution } from "./interfaces";

export { PositionalOptions, PositionalOptionsType, Choices, ParameterOptions, Arguments };

Expand Down Expand Up @@ -82,8 +66,7 @@ export interface YargBuilder extends BuildYargs {
* once we aren't using it, we could remove it
* @param params
*/
option(parameterName: string,
params: ParameterOptions): YargBuilder;
option(parameterName: string, params: ParameterOptions): YargBuilder;

/**
* This exists to be compatible with yargs syntax
Expand Down

0 comments on commit b338934

Please sign in to comment.