Skip to content

Commit e22e8b6

Browse files
authored
Merge pull request #261 from contentstack/fix/DX-9363
fix(flags): normalize short flag consistency across cli-cm-regex-validate, tsgen, migration, and apps-cli
2 parents efaaf46 + 5410870 commit e22e8b6

11 files changed

Lines changed: 44 additions & 40 deletions

File tree

.github/workflows/unit-test.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ jobs:
5555
working-directory: ./packages/contentstack-bootstrap
5656
run: npm run test
5757

58-
# - name: Run tests for Contentstack Import Setup
59-
# working-directory: ./packages/contentstack-import-setup
60-
# run: npm run test:unit
61-
6258
- name: Run tests for Contentstack Branches
6359
working-directory: ./packages/contentstack-branches
6460
run: npm run test:unit
@@ -86,7 +82,20 @@ jobs:
8682
- name: Run tests for Contentstack Bulk Operations
8783
working-directory: ./packages/contentstack-bulk-operations
8884
run: npm test
89-
85+
9086
- name: Run tests for Contentstack Variants
9187
working-directory: ./packages/contentstack-variants
9288
run: npm run test
89+
90+
- name: Run tests for Contentstack Asset Management
91+
working-directory: ./packages/contentstack-asset-management
92+
run: npm run test:unit
93+
94+
- name: Run tests for Contentstack Clone
95+
working-directory: ./packages/contentstack-clone
96+
run: npm run test:unit
97+
98+
# - name: Run tests for Contentstack External Migrate
99+
# working-directory: ./packages/contentstack-external-migrate
100+
# run: npm test
101+

packages/contentstack-apps-cli/src/commands/app/create.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export default class Create extends BaseCommand<typeof Create> {
6262

6363
static flags: FlagInput = {
6464
name: flags.string({
65-
char: "n",
6665
description: appCreate.NAME_DESCRIPTION,
6766
}),
6867
"app-type": flags.string({

packages/contentstack-apps-cli/src/commands/app/install.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default class Install extends AppCLIBaseCommand {
2626
description: commonMsg.APP_UID,
2727
}),
2828
"stack-api-key": flags.string({
29+
char: "k",
2930
description: commonMsg.STACK_API_KEY,
3031
}),
3132
...AppCLIBaseCommand.baseFlags,

packages/contentstack-apps-cli/src/commands/app/reinstall.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default class Reinstall extends AppCLIBaseCommand {
2525
description: commonMsg.APP_UID,
2626
}),
2727
"stack-api-key": flags.string({
28+
char: "k",
2829
description: commonMsg.STACK_API_KEY,
2930
}),
3031
...AppCLIBaseCommand.baseFlags,

packages/contentstack-cli-cm-regex-validate/src/commands/cm/stacks/validate-regex.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,24 @@ export default class ValidateRegex extends Command {
1010
static examples = [
1111
'$ csdx cm:stacks:validate-regex',
1212
'$ csdx cm:stacks:validate-regex -a <management_token_alias>',
13-
'$ csdx cm:stacks:validate-regex -c',
14-
'$ csdx cm:stacks:validate-regex -g',
15-
'$ csdx cm:stacks:validate-regex -f <path/to/the/directory>',
16-
'$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g',
17-
'$ csdx cm:stacks:validate-regex -a <management_token_alias> -c -g -f <path/to/the/directory>',
13+
'$ csdx cm:stacks:validate-regex --contentType',
14+
'$ csdx cm:stacks:validate-regex --globalField',
15+
'$ csdx cm:stacks:validate-regex --filePath <path/to/the/directory>',
16+
'$ csdx cm:stacks:validate-regex -a <management_token_alias> --contentType --globalField',
17+
'$ csdx cm:stacks:validate-regex -a <management_token_alias> --contentType --globalField --filePath <path/to/the/directory>',
1818
]
1919
static flags: any = {
2020
alias: flags.string({
2121
char: 'a',
2222
description: regexMessages.command.alias,
2323
}),
2424
contentType: flags.boolean({
25-
char: 'c',
2625
description: regexMessages.command.contentTypes,
2726
}),
2827
filePath: flags.string({
29-
char: 'f',
3028
description: regexMessages.command.filePath,
3129
}),
3230
globalField: flags.boolean({
33-
char: 'g',
3431
description: regexMessages.command.globalFields,
3532
}),
3633
}

packages/contentstack-cli-tsgen/src/commands/tsgen.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
2323
static description = "Generate TypeScript typings from a Stack";
2424

2525
static examples = [
26-
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts"',
27-
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" -p "I"',
28-
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --no-doc',
29-
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --include-referenced-entry',
30-
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --api-type graphql',
31-
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --api-type graphql --namespace "GraphQL" ',
26+
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts"',
27+
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --prefix "I"',
28+
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --no-doc',
29+
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --include-referenced-entry',
30+
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --api-type graphql',
31+
'$ csdx tsgen -a "delivery token alias" --output "contentstack/generated.d.ts" --api-type graphql --namespace "GraphQL" ',
3232
];
3333

3434
// Check if a region is a default Contentstack region
@@ -46,7 +46,7 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
4646
}
4747

4848
static flags: FlagInput = {
49-
"token-alias": flags.string({
49+
alias: flags.string({
5050
char: "a",
5151
description: "delivery token alias",
5252
hidden: false,
@@ -55,15 +55,13 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
5555
}),
5656

5757
output: flags.string({
58-
char: "o",
5958
description: "full path to output",
6059
hidden: false,
6160
multiple: false,
6261
required: true,
6362
}),
6463

6564
prefix: flags.string({
66-
char: "p",
6765
description: 'interface prefix, e.g. "I"',
6866
hidden: false,
6967
multiple: false,
@@ -72,7 +70,6 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
7270
}),
7371

7472
doc: flags.boolean({
75-
char: "d",
7673
description: "include documentation comments",
7774
default: true,
7875
allowNo: true,
@@ -118,7 +115,7 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
118115
try {
119116
const { flags } = await this.parse(TypeScriptCodeGeneratorCommand);
120117

121-
const token = this.getToken(flags["token-alias"]);
118+
const token = this.getToken(flags["alias"]);
122119
const prefix = flags.prefix;
123120
const includeDocumentation = flags.doc;
124121
const filePath = flags.output;

packages/contentstack-cli-tsgen/tests/integration/tsgen.integration.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Integration Test for tsgen command", () => {
2424
// Test case 1: Generate TypeScript types with default flags
2525
it("should generate TypeScript types with the default flags", () => {
2626
const cmd = "csdx";
27-
const args = ["tsgen", "-a", tokenAlias!, "-o", outputFilePath];
27+
const args = ["tsgen", "-a", tokenAlias!, "--output", outputFilePath];
2828

2929
const result = spawnSync(cmd, args, { encoding: "utf-8" });
3030

@@ -44,9 +44,9 @@ describe("Integration Test for tsgen command", () => {
4444
"tsgen",
4545
"-a",
4646
tokenAlias!,
47-
"-o",
47+
"--output",
4848
outputFilePath,
49-
"-p",
49+
"--prefix",
5050
prefix,
5151
];
5252

@@ -72,7 +72,7 @@ describe("Integration Test for tsgen command", () => {
7272
// Test case 3: Generate TypeScript types without documentation comments
7373
it("should generate TypeScript types without documentation", () => {
7474
const cmd = "csdx";
75-
const args = ["tsgen", "-a", tokenAlias!, "-o", outputFilePath, "--no-doc"];
75+
const args = ["tsgen", "-a", tokenAlias!, "--output", outputFilePath, "--no-doc"];
7676

7777
const result = spawnSync(cmd, args, { encoding: "utf-8" });
7878

@@ -90,7 +90,7 @@ describe("Integration Test for tsgen command", () => {
9090
"tsgen",
9191
"-a",
9292
tokenAlias!,
93-
"-o",
93+
"--output",
9494
outputFilePath,
9595
"--include-system-fields",
9696
];
@@ -108,7 +108,7 @@ describe("Integration Test for tsgen command", () => {
108108
// Test case 5: Handling of invalid token alias
109109
it("should fail with an invalid token alias", () => {
110110
const cmd = "csdx";
111-
const args = ["tsgen", "-a", "invalid_alias", "-o", outputFilePath];
111+
const args = ["tsgen", "-a", "invalid_alias", "--output", outputFilePath];
112112

113113
const result = spawnSync(cmd, args, { encoding: "utf-8" });
114114

@@ -124,7 +124,7 @@ describe("Integration Test for tsgen command", () => {
124124
"tsgen",
125125
"-a",
126126
tokenAlias!,
127-
"-o",
127+
"--output",
128128
outputFilePath,
129129
"--api-type",
130130
"graphql",
@@ -147,7 +147,7 @@ describe("Integration Test for tsgen command", () => {
147147
"tsgen",
148148
"-a",
149149
tokenAlias!,
150-
"-o",
150+
"--output",
151151
outputFilePath,
152152
"--api-type",
153153
"graphql",
@@ -171,7 +171,7 @@ describe("Integration Test for tsgen command", () => {
171171
"tsgen",
172172
"-a",
173173
"invalid_alias",
174-
"-o",
174+
"--output",
175175
outputFilePath,
176176
"--api-type",
177177
"graphql",

packages/contentstack-external-migrate/src/commands/migrate/convert.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class MigrateConvert extends Command {
88

99
static examples = [
1010
'$ csdx migrate:convert --legacy contentful --input ./export.json --output ./contentstack-import',
11-
'$ csdx migrate:convert -l contentful -i ../references/contentful-export-*.json -o ./contentstack-import -m en-US',
11+
'$ csdx migrate:convert -l contentful -i ../references/contentful-export-*.json --output ./contentstack-import --master-locale en-US',
1212
];
1313
static hidden = true;
1414
static flags: FlagInput = {
@@ -23,16 +23,13 @@ export default class MigrateConvert extends Command {
2323
description: 'Path to legacy export JSON (e.g. Contentful export)',
2424
}),
2525
output: flags.string({
26-
char: 'o',
2726
description: 'Parent output directory; bundle written to <output>/bundle',
2827
default: './contentstack-import',
2928
}),
3029
'master-locale': flags.string({
31-
char: 'm',
3230
description: 'Destination master locale code',
3331
}),
3432
affix: flags.string({
35-
char: 'a',
3633
description: 'Content-type UID prefix',
3734
default: '',
3835
}),

packages/contentstack-external-migrate/src/commands/migrate/export.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export default class MigrateExport extends Command {
2626
description: 'Contentful CMA token (prefer CONTENTFUL_MANAGEMENT_TOKEN env)',
2727
}),
2828
output: flags.string({
29-
char: 'o',
3029
description: 'Migration workspace root (writes export.json here)',
3130
default: './migration-workspace',
3231
}),

packages/contentstack-migration/src/commands/cm/stacks/migration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export default class MigrationCommand extends Command {
8282

8383
// To be deprecated
8484
'api-key': flags.string({
85-
char: 'k',
8685
description: 'With this flag add the API key of your stack.',
8786
// dependsOn: ['authtoken'],
8887
exclusive: ['alias'],

0 commit comments

Comments
 (0)