Skip to content

Commit 49d0c45

Browse files
Merge pull request #122 from contentstack/staging
DX | 19-01-2026 | Release
2 parents 45b1c72 + 786f106 commit 49d0c45

File tree

10 files changed

+1411
-1262
lines changed

10 files changed

+1411
-1262
lines changed

.talismanrc

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
fileignoreconfig:
2-
- filename: .github/workflows/secrets-scan.yml
3-
ignore_detectors:
4-
- filecontent
5-
- filename: package-lock.json
6-
checksum: e78fc9c4b8032c8a0fd0c0fef9b0b85808aa51e0c3a9c291f8c6227e116705a6
7-
- filename: src/typings/@contentstack/cli-command.d.ts
8-
checksum: 8a91f44817d08d0289f754ff02bd53b106bf89b3a8082bdfe1500a3297f25805
2+
- filename: .github/workflows/secrets-scan.yml
3+
ignore_detectors:
4+
- filecontent
5+
- filename: package-lock.json
6+
checksum: 68fe962edf95215cf8cd675aa61032cb3b1f26d9a855a0cc47d2da7f60118fbf
7+
- filename: src/typings/@contentstack/cli-command.d.ts
8+
checksum: 8a91f44817d08d0289f754ff02bd53b106bf89b3a8082bdfe1500a3297f25805
9+
- filename: src/core/command.ts
10+
checksum: 9deaa9b6edc6698caf2f469263252b83d4f84b2dde7154d78f6340282d136754
11+
- filename: src/commands/content-type/audit.ts
12+
checksum: df9f0768c90f8e3a15cd70cbb1765a6c6f0dc5a8e4e7e74e42bfa8ca2ebf3bc9
13+
- filename: src/commands/content-type/details.ts
14+
checksum: db30263b288e1686d1fc8ff593a2e33c727a8d130ca7a943c28277c0985f00ff
15+
- filename: src/commands/content-type/diagram.ts
16+
checksum: 276a57c16a4aa434ede1058134517feaf190c9c5db2c12116904daed82996303
17+
- filename: src/commands/content-type/compare.ts
18+
checksum: 2d650febfa3f4671f716e79bb1f6446273046d7041f980733e5ac306a13f447d
19+
- filename: src/commands/content-type/list.ts
20+
checksum: e7623d46577a9f5c209fd8d0d5abd0da0a2140f6cce30f68cfe81b29e292585c
21+
- filename: src/commands/content-type/compare-remote.ts
22+
checksum: 151b32699500c465378c4088240c5a25266141150261313434068740862949a1
923
version: "1.0"

package-lock.json

Lines changed: 997 additions & 963 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "contentstack-cli-content-type",
33
"description": "Retrieve information about Content Types in a Stack.",
4-
"version": "1.3.3",
4+
"version": "1.4.0",
55
"author": "Contentstack Developer",
66
"bugs": "https://github.com/contentstack/contentstack-cli-content-type/issues",
77
"dependencies": {
@@ -28,11 +28,11 @@
2828
"@types/jest": "^29.5.14",
2929
"@types/node": "^22.19.3",
3030
"eslint": "^8.57.1",
31-
"eslint-config-oclif": "^6.0.62",
31+
"eslint-config-oclif": "^6.0.129",
3232
"eslint-config-oclif-typescript": "^3.1.14",
3333
"globby": "^10.0.2",
3434
"jest": "^29.7.0",
35-
"oclif": "^4.22.59",
35+
"oclif": "^4.22.63",
3636
"ts-jest": "^29.4.6",
3737
"ts-node": "^10.9.2",
3838
"typescript": "^4.9.5"

src/commands/content-type/audit.ts

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,89 @@
1-
import Command from '../../core/command'
2-
import { flags, FlagInput, managementSDKClient, cliux, printFlagDeprecation } from '@contentstack/cli-utilities'
3-
import buildOutput from '../../core/content-type/audit'
4-
import { getStack, getUsers, getContentType } from '../../utils'
1+
import Command from "../../core/command";
2+
import {
3+
flags,
4+
managementSDKClient,
5+
cliux,
6+
printFlagDeprecation,
7+
} from "@contentstack/cli-utilities";
8+
import buildOutput from "../../core/content-type/audit";
9+
import { getStack, getUsers, getContentType } from "../../utils";
510

611
export default class AuditCommand extends Command {
7-
static description = 'Display recent changes to a Content Type'
12+
static description = "Display recent changes to a Content Type";
813

914
static examples = [
1015
'$ csdx content-type:audit --stack-api-key "xxxxxxxxxxxxxxxxxxx" --content-type "home_page"',
11-
'$ csdx content-type:audit --alias "management token" --content-type "home_page"'
12-
]
16+
'$ csdx content-type:audit --alias "management token" --content-type "home_page"',
17+
];
1318

1419
static flags: any = {
1520
stack: flags.string({
16-
char: 's',
17-
description: 'Stack UID',
18-
exclusive: ['token-alias', 'alias'],
19-
parse: printFlagDeprecation(['-s', '--stack'], ['-k', '--stack-api-key'])
21+
char: "s",
22+
description: "Stack UID",
23+
exclusive: ["token-alias", "alias"],
24+
parse: printFlagDeprecation(["-s", "--stack"], ["-k", "--stack-api-key"]),
2025
}),
2126

22-
'stack-api-key': flags.string({
23-
char: 'k',
24-
description: 'Stack API Key',
25-
exclusive: ['token-alias', 'alias']
27+
"stack-api-key": flags.string({
28+
char: "k",
29+
description: "Stack API Key",
30+
exclusive: ["token-alias", "alias"],
2631
}),
2732

28-
'token-alias': flags.string({
29-
char: 'a',
30-
description: 'Management token alias',
31-
parse: printFlagDeprecation(['--token-alias'], ['-a', '--alias'])
33+
"token-alias": flags.string({
34+
char: "a",
35+
description: "Management token alias",
36+
parse: printFlagDeprecation(["--token-alias"], ["-a", "--alias"]),
3237
}),
3338

3439
alias: flags.string({
35-
char: 'a',
36-
description: 'Alias of the management token'
40+
char: "a",
41+
description: "Alias of the management token",
3742
}),
3843

39-
'content-type': flags.string({
40-
char: 'c',
41-
description: 'Content Type UID',
44+
"content-type": flags.string({
45+
char: "c",
46+
description: "Content Type UID",
4247
required: true,
43-
parse: printFlagDeprecation(['-c'], ['--content-type'])
44-
})
45-
}
48+
parse: printFlagDeprecation(["-c"], ["--content-type"]),
49+
}),
50+
};
4651

4752
async run() {
4853
try {
49-
const { flags } = await this.parse(AuditCommand)
50-
this.setup(flags)
51-
54+
const { flags } = await this.parse(AuditCommand);
55+
await this.setup(flags);
56+
5257
this.contentTypeManagementClient = await managementSDKClient({
5358
host: this.cmaHost,
54-
'X-CS-CLI': this.context?.analyticsInfo
55-
})
59+
"X-CS-CLI": this.context?.analyticsInfo,
60+
});
5661

57-
const spinner = cliux.loaderV2(Command.RequestDataMessage)
62+
const spinner = cliux.loaderV2(Command.RequestDataMessage);
5863
await getContentType({
5964
managementSdk: this.contentTypeManagementClient,
6065
apiKey: this.apiKey,
61-
uid: flags['content-type'],
62-
spinner
66+
uid: flags["content-type"],
67+
spinner,
6368
});
6469
const [stack, audit, users] = await Promise.all([
6570
getStack(this.contentTypeManagementClient, this.apiKey, spinner),
66-
this.client.getContentTypeAuditLogs(this.apiKey, flags['content-type'], spinner),
67-
getUsers(this.contentTypeManagementClient, this.apiKey, spinner)
68-
])
69-
cliux.loaderV2('', spinner)
71+
this.client.getContentTypeAuditLogs(
72+
this.apiKey,
73+
flags["content-type"],
74+
spinner
75+
),
76+
getUsers(this.contentTypeManagementClient, this.apiKey, spinner),
77+
]);
78+
cliux.loaderV2("", spinner);
7079

71-
const output = buildOutput(audit.logs, users)
72-
this.printOutput(output, 'Audit Logs', flags['content-type'], stack.name)
80+
const output = buildOutput(audit.logs, users);
81+
this.printOutput(output, "Audit Logs", flags["content-type"], stack.name);
7382
} catch (error: any) {
74-
this.error(error?.message || 'An error occurred.', { exit: 1, suggestions: error.suggestions })
83+
this.error(error?.message || "An error occurred.", {
84+
exit: 1,
85+
suggestions: error.suggestions,
86+
});
7587
}
7688
}
7789
}
Lines changed: 67 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,106 @@
1-
import Command from '../../core/command'
2-
import { flags, FlagInput, managementSDKClient, cliux, printFlagDeprecation } from '@contentstack/cli-utilities'
3-
import buildOutput from '../../core/content-type/compare'
4-
import { getStack, getContentType } from '../../utils'
1+
import Command from "../../core/command";
2+
import {
3+
flags,
4+
FlagInput,
5+
managementSDKClient,
6+
cliux,
7+
printFlagDeprecation,
8+
} from "@contentstack/cli-utilities";
9+
import buildOutput from "../../core/content-type/compare";
10+
import { getStack, getContentType } from "../../utils";
511

612
export default class CompareRemoteCommand extends Command {
7-
static description = 'compare two Content Types on different Stacks'
13+
static description = "compare two Content Types on different Stacks";
814

915
static examples = [
10-
'$ csdx content-type:compare-remote --origin-stack "xxxxxxxxxxxxxxxxxxx" --remote-stack "xxxxxxxxxxxxxxxxxxx" -content-type "home_page"'
11-
]
16+
'$ csdx content-type:compare-remote --origin-stack "xxxxxxxxxxxxxxxxxxx" --remote-stack "xxxxxxxxxxxxxxxxxxx" -content-type "home_page"',
17+
];
1218

1319
static flags: any = {
14-
'origin-stack': flags.string({
15-
char: 'o',
16-
description: 'Origin Stack API Key',
20+
"origin-stack": flags.string({
21+
char: "o",
22+
description: "Origin Stack API Key",
1723
required: true,
18-
dependsOn: ['remote-stack'],
19-
parse: printFlagDeprecation(['-o'], ['--remote-stack'])
24+
dependsOn: ["remote-stack"],
25+
parse: printFlagDeprecation(["-o"], ["--remote-stack"]),
2026
}),
2127

22-
'remote-stack': flags.string({
23-
char: 'r',
24-
description: 'Remote Stack API Key',
28+
"remote-stack": flags.string({
29+
char: "r",
30+
description: "Remote Stack API Key",
2531
required: true,
26-
dependsOn: ['origin-stack'],
27-
parse: printFlagDeprecation(['-r'], ['--remote-stack'])
32+
dependsOn: ["origin-stack"],
33+
parse: printFlagDeprecation(["-r"], ["--remote-stack"]),
2834
}),
2935

30-
'content-type': flags.string({
31-
char: 'c',
32-
description: 'Content Type UID',
36+
"content-type": flags.string({
37+
char: "c",
38+
description: "Content Type UID",
3339
required: true,
34-
parse: printFlagDeprecation(['-c'], ['--content-type'])
35-
})
36-
}
40+
parse: printFlagDeprecation(["-c"], ["--content-type"]),
41+
}),
42+
};
3743

3844
async run() {
3945
try {
40-
const { flags } = await this.parse(CompareRemoteCommand)
41-
this.setup({ alias: undefined, stack: flags['origin-stack'] })
46+
const { flags } = await this.parse(CompareRemoteCommand);
47+
await this.setup({ alias: undefined, stack: flags["origin-stack"] });
4248
this.contentTypeManagementClient = await managementSDKClient({
4349
host: this.cmaHost,
44-
'X-CS-CLI': this.context?.analyticsInfo
45-
})
50+
"X-CS-CLI": this.context?.analyticsInfo,
51+
});
4652

47-
const originStackApi = flags['origin-stack'] as string
48-
const remoteStackApi = flags['remote-stack'] as string
53+
const originStackApi = flags["origin-stack"] as string;
54+
const remoteStackApi = flags["remote-stack"] as string;
4955

5056
if (originStackApi === remoteStackApi) {
51-
this.warn('You cannot compare the same stack. Please choose different stacks to compare.')
57+
this.warn(
58+
"You cannot compare the same stack. Please choose different stacks to compare."
59+
);
5260
}
5361

54-
const spinner = cliux.loaderV2(Command.RequestDataMessage)
62+
const spinner = cliux.loaderV2(Command.RequestDataMessage);
5563

56-
const [originStackResp, remoteStackResp, originContentTypeResp, remoteContentTypeResp] = await Promise.all([
64+
const [
65+
originStackResp,
66+
remoteStackResp,
67+
originContentTypeResp,
68+
remoteContentTypeResp,
69+
] = await Promise.all([
5770
getStack(this.contentTypeManagementClient, originStackApi, spinner),
5871
getStack(this.contentTypeManagementClient, remoteStackApi, spinner),
5972
getContentType({
6073
managementSdk: this.contentTypeManagementClient,
6174
apiKey: originStackApi,
62-
uid: flags['content-type'],
63-
spinner
75+
uid: flags["content-type"],
76+
spinner,
6477
}),
6578
getContentType({
6679
managementSdk: this.contentTypeManagementClient,
6780
apiKey: remoteStackApi,
68-
uid: flags['content-type'],
69-
spinner
70-
})
71-
])
81+
uid: flags["content-type"],
82+
spinner,
83+
}),
84+
]);
7285

73-
cliux.loaderV2('', spinner)
86+
cliux.loaderV2("", spinner);
7487

75-
const output = await buildOutput(flags['content-type'], originContentTypeResp, remoteContentTypeResp)
76-
this.printOutput(output, 'changes', flags['content-type'], `${originStackResp.name} <-> ${remoteStackResp.name}`)
88+
const output = await buildOutput(
89+
flags["content-type"],
90+
originContentTypeResp,
91+
remoteContentTypeResp
92+
);
93+
this.printOutput(
94+
output,
95+
"changes",
96+
flags["content-type"],
97+
`${originStackResp.name} <-> ${remoteStackResp.name}`
98+
);
7799
} catch (error: any) {
78-
this.error(error?.message || 'An error occurred.', { exit: 1, suggestions: error.suggestions })
100+
this.error(error?.message || "An error occurred.", {
101+
exit: 1,
102+
suggestions: error.suggestions,
103+
});
79104
}
80105
}
81106
}

0 commit comments

Comments
 (0)