Skip to content

Commit 73dc361

Browse files
goldbezakshbhu
authored andcommitted
fix: enable help for category statuses (#12216)
* fix: enable help for category statuses * test: add e2e test for status with help
1 parent f3c9a16 commit 73dc361

File tree

5 files changed

+127
-7
lines changed

5 files changed

+127
-7
lines changed

packages/amplify-cli-core/src/help/commands-info.ts

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,17 +374,71 @@ export const commandsInfo: Array<CommandInfo> = [
374374
],
375375
subCommands: [
376376
{
377-
subCommand: '[category]',
378-
subCommandDescription: 'Shows the state of local resources not yet pushed to the cloud',
379-
subCommandUsage: 'amplify status [category] [-v | --verbose]',
377+
subCommand: 'notifications',
378+
subCommandDescription: 'Lists the enabled/disabled statuses of the available notification channels',
379+
subCommandUsage: 'amplify notifications status',
380+
subCommandFlags: [],
381+
},
382+
{
383+
subCommand: 'api',
384+
subCommandDescription: 'Displays the current status of your API',
385+
subCommandUsage: 'amplify api status [-acm <table-name>]',
380386
subCommandFlags: [
381387
{
382-
short: 'v',
383-
long: 'verbose',
384-
flagDescription: 'Shows verbose details, including cloudformation differences',
388+
short: 'acm',
389+
long: '',
390+
flagDescription: 'Displays the access control matrix',
385391
},
386392
],
387393
},
394+
{
395+
subCommand: 'auth',
396+
subCommandDescription: 'Displays the current status of your auth resource',
397+
subCommandUsage: 'amplify auth status',
398+
subCommandFlags: [],
399+
},
400+
{
401+
subCommand: 'custom',
402+
subCommandDescription: 'Displays the current status of your custom resource',
403+
subCommandUsage: 'amplify custom status',
404+
subCommandFlags: [],
405+
},
406+
{
407+
subCommand: 'storage',
408+
subCommandDescription: 'Displays the current status of your storage resource',
409+
subCommandUsage: 'amplify storage status',
410+
subCommandFlags: [],
411+
},
412+
{
413+
subCommand: 'analytics',
414+
subCommandDescription: 'Displays the current status of your analytics resource',
415+
subCommandUsage: 'amplify analytics status',
416+
subCommandFlags: [],
417+
},
418+
{
419+
subCommand: 'function',
420+
subCommandDescription: 'Displays the current status of your function resource',
421+
subCommandUsage: 'amplify function status',
422+
subCommandFlags: [],
423+
},
424+
{
425+
subCommand: 'hosting',
426+
subCommandDescription: 'Displays the current status of your hosting',
427+
subCommandUsage: 'amplify hosting status',
428+
subCommandFlags: [],
429+
},
430+
{
431+
subCommand: 'interactions',
432+
subCommandDescription: 'Displays the current status of your interactions resource',
433+
subCommandUsage: 'amplify interactions status',
434+
subCommandFlags: [],
435+
},
436+
{
437+
subCommand: 'predictions',
438+
subCommandDescription: 'Displays the current status of your predictions resource',
439+
subCommandUsage: 'amplify predictions status',
440+
subCommandFlags: [],
441+
},
388442
],
389443
},
390444
{

packages/amplify-cli/src/input-manager.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// normalize command line arguments, allow verb / noun place switch
2-
import { constants, PluginPlatform, pathManager, stateManager } from 'amplify-cli-core';
2+
import { constants, PluginPlatform, pathManager, stateManager, commandsInfo } from 'amplify-cli-core';
33
import { getPluginsWithName, getAllPluginNames } from './plugin-manager';
44
import { InputVerificationResult } from './domain/input-verification-result';
55
import { insertAmplifyIgnore } from './extensions/amplify-helpers/git-manager';
@@ -84,6 +84,21 @@ function preserveHelpInformation(input: CLIInput): CLIInput {
8484
subCommands.unshift(input.plugin);
8585
}
8686
}
87+
88+
if (input.command == 'status' && input.options) {
89+
const statusSubcommands = commandsInfo
90+
.find((commandInfo) => commandInfo.command == 'status')
91+
?.subCommands.map((subCommandInfo) => subCommandInfo.subCommand);
92+
const potentialStatusSubcommands: Array<string> = statusSubcommands ? statusSubcommands : [];
93+
const optionKeys = Object.keys(input.options);
94+
for (const potentialSubcommand of potentialStatusSubcommands) {
95+
if (optionKeys.includes(potentialSubcommand)) {
96+
subCommands.push(potentialSubcommand);
97+
break;
98+
}
99+
}
100+
}
101+
87102
if (input.options) {
88103
input.options[constants.HELP] = true;
89104
delete input.options[constants.HELP_SHORT];
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { getCLIPath, nspawn as spawn } from '..';
2+
3+
export const statusWithHelp = async (cwd: string, expectedContents: Array<string>): Promise<void> => {
4+
const chain = spawn(getCLIPath(), ['status', '-h'], { cwd, stripColors: true });
5+
for (const expectedLine of expectedContents) {
6+
chain.wait(expectedLine);
7+
}
8+
await chain.runAsync();
9+
};
10+
11+
export const statusForCategoryWithHelp = async (cwd: string, category: string, expectedContents: Array<string>): Promise<void> => {
12+
const chain = spawn(getCLIPath(), ['status', category, '-h'], { cwd, stripColors: true });
13+
for (const expectedLine of expectedContents) {
14+
chain.wait(expectedLine);
15+
}
16+
await chain.runAsync();
17+
};

packages/amplify-e2e-core/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export * from './transformConfig';
2727
export * from './admin-ui';
2828
export * from './hooks';
2929
export * from './git-operations';
30+
export * from './help';
3031

3132
/**
3233
* Whether the current environment is CircleCI or not
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {
2+
createNewProjectDir,
3+
initJSProjectWithProfile,
4+
deleteProject,
5+
deleteProjectDir,
6+
statusWithHelp,
7+
statusForCategoryWithHelp,
8+
addS3AndAuthWithAuthOnlyAccess,
9+
amplifyPushAuth,
10+
} from '@aws-amplify/amplify-e2e-core';
11+
12+
describe('help happy paths', () => {
13+
let projRoot: string;
14+
beforeAll(async () => {
15+
projRoot = await createNewProjectDir('help-happy-paths');
16+
await initJSProjectWithProfile(projRoot, {});
17+
await addS3AndAuthWithAuthOnlyAccess(projRoot);
18+
await amplifyPushAuth(projRoot);
19+
});
20+
21+
afterAll(async () => {
22+
await deleteProject(projRoot);
23+
deleteProjectDir(projRoot);
24+
});
25+
26+
test('amplify status', async () => {
27+
await statusWithHelp(projRoot, ['USAGE', 'amplify status [-v | --verbose]']);
28+
});
29+
30+
test('amplify status storage', async () => {
31+
await statusForCategoryWithHelp(projRoot, 'storage', ['USAGE', 'amplify storage status']);
32+
});
33+
});

0 commit comments

Comments
 (0)