Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
fileignoreconfig:
- filename: .github/workflows/secrets-scan.yml
ignore_detectors:
- filecontent
- filename: package-lock.json
checksum: e78fc9c4b8032c8a0fd0c0fef9b0b85808aa51e0c3a9c291f8c6227e116705a6
- filename: src/typings/@contentstack/cli-command.d.ts
checksum: 8a91f44817d08d0289f754ff02bd53b106bf89b3a8082bdfe1500a3297f25805
- filename: .github/workflows/secrets-scan.yml
ignore_detectors:
- filecontent
- filename: package-lock.json
checksum: 68fe962edf95215cf8cd675aa61032cb3b1f26d9a855a0cc47d2da7f60118fbf
- filename: src/typings/@contentstack/cli-command.d.ts
checksum: 8a91f44817d08d0289f754ff02bd53b106bf89b3a8082bdfe1500a3297f25805
- filename: src/core/command.ts
checksum: 9deaa9b6edc6698caf2f469263252b83d4f84b2dde7154d78f6340282d136754
- filename: src/commands/content-type/audit.ts
checksum: df9f0768c90f8e3a15cd70cbb1765a6c6f0dc5a8e4e7e74e42bfa8ca2ebf3bc9
- filename: src/commands/content-type/details.ts
checksum: db30263b288e1686d1fc8ff593a2e33c727a8d130ca7a943c28277c0985f00ff
- filename: src/commands/content-type/diagram.ts
checksum: 276a57c16a4aa434ede1058134517feaf190c9c5db2c12116904daed82996303
- filename: src/commands/content-type/compare.ts
checksum: 2d650febfa3f4671f716e79bb1f6446273046d7041f980733e5ac306a13f447d
- filename: src/commands/content-type/list.ts
checksum: e7623d46577a9f5c209fd8d0d5abd0da0a2140f6cce30f68cfe81b29e292585c
- filename: src/commands/content-type/compare-remote.ts
checksum: 151b32699500c465378c4088240c5a25266141150261313434068740862949a1
version: "1.0"
1,960 changes: 997 additions & 963 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "contentstack-cli-content-type",
"description": "Retrieve information about Content Types in a Stack.",
"version": "1.3.3",
"version": "1.4.0",
"author": "Contentstack Developer",
"bugs": "https://github.com/contentstack/contentstack-cli-content-type/issues",
"dependencies": {
Expand All @@ -28,11 +28,11 @@
"@types/jest": "^29.5.14",
"@types/node": "^22.19.3",
"eslint": "^8.57.1",
"eslint-config-oclif": "^6.0.62",
"eslint-config-oclif": "^6.0.129",
"eslint-config-oclif-typescript": "^3.1.14",
"globby": "^10.0.2",
"jest": "^29.7.0",
"oclif": "^4.22.59",
"oclif": "^4.22.63",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.2",
"typescript": "^4.9.5"
Expand Down
96 changes: 54 additions & 42 deletions src/commands/content-type/audit.ts
Original file line number Diff line number Diff line change
@@ -1,77 +1,89 @@
import Command from '../../core/command'
import { flags, FlagInput, managementSDKClient, cliux, printFlagDeprecation } from '@contentstack/cli-utilities'
import buildOutput from '../../core/content-type/audit'
import { getStack, getUsers, getContentType } from '../../utils'
import Command from "../../core/command";
import {
flags,
managementSDKClient,
cliux,
printFlagDeprecation,
} from "@contentstack/cli-utilities";
import buildOutput from "../../core/content-type/audit";
import { getStack, getUsers, getContentType } from "../../utils";

export default class AuditCommand extends Command {
static description = 'Display recent changes to a Content Type'
static description = "Display recent changes to a Content Type";

static examples = [
'$ csdx content-type:audit --stack-api-key "xxxxxxxxxxxxxxxxxxx" --content-type "home_page"',
'$ csdx content-type:audit --alias "management token" --content-type "home_page"'
]
'$ csdx content-type:audit --alias "management token" --content-type "home_page"',
];

static flags: any = {
stack: flags.string({
char: 's',
description: 'Stack UID',
exclusive: ['token-alias', 'alias'],
parse: printFlagDeprecation(['-s', '--stack'], ['-k', '--stack-api-key'])
char: "s",
description: "Stack UID",
exclusive: ["token-alias", "alias"],
parse: printFlagDeprecation(["-s", "--stack"], ["-k", "--stack-api-key"]),
}),

'stack-api-key': flags.string({
char: 'k',
description: 'Stack API Key',
exclusive: ['token-alias', 'alias']
"stack-api-key": flags.string({
char: "k",
description: "Stack API Key",
exclusive: ["token-alias", "alias"],
}),

'token-alias': flags.string({
char: 'a',
description: 'Management token alias',
parse: printFlagDeprecation(['--token-alias'], ['-a', '--alias'])
"token-alias": flags.string({
char: "a",
description: "Management token alias",
parse: printFlagDeprecation(["--token-alias"], ["-a", "--alias"]),
}),

alias: flags.string({
char: 'a',
description: 'Alias of the management token'
char: "a",
description: "Alias of the management token",
}),

'content-type': flags.string({
char: 'c',
description: 'Content Type UID',
"content-type": flags.string({
char: "c",
description: "Content Type UID",
required: true,
parse: printFlagDeprecation(['-c'], ['--content-type'])
})
}
parse: printFlagDeprecation(["-c"], ["--content-type"]),
}),
};

async run() {
try {
const { flags } = await this.parse(AuditCommand)
this.setup(flags)
const { flags } = await this.parse(AuditCommand);
await this.setup(flags);

this.contentTypeManagementClient = await managementSDKClient({
host: this.cmaHost,
'X-CS-CLI': this.context?.analyticsInfo
})
"X-CS-CLI": this.context?.analyticsInfo,
});

const spinner = cliux.loaderV2(Command.RequestDataMessage)
const spinner = cliux.loaderV2(Command.RequestDataMessage);
await getContentType({
managementSdk: this.contentTypeManagementClient,
apiKey: this.apiKey,
uid: flags['content-type'],
spinner
uid: flags["content-type"],
spinner,
});
const [stack, audit, users] = await Promise.all([
getStack(this.contentTypeManagementClient, this.apiKey, spinner),
this.client.getContentTypeAuditLogs(this.apiKey, flags['content-type'], spinner),
getUsers(this.contentTypeManagementClient, this.apiKey, spinner)
])
cliux.loaderV2('', spinner)
this.client.getContentTypeAuditLogs(
this.apiKey,
flags["content-type"],
spinner
),
getUsers(this.contentTypeManagementClient, this.apiKey, spinner),
]);
cliux.loaderV2("", spinner);

const output = buildOutput(audit.logs, users)
this.printOutput(output, 'Audit Logs', flags['content-type'], stack.name)
const output = buildOutput(audit.logs, users);
this.printOutput(output, "Audit Logs", flags["content-type"], stack.name);
} catch (error: any) {
this.error(error?.message || 'An error occurred.', { exit: 1, suggestions: error.suggestions })
this.error(error?.message || "An error occurred.", {
exit: 1,
suggestions: error.suggestions,
});
}
}
}
109 changes: 67 additions & 42 deletions src/commands/content-type/compare-remote.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,106 @@
import Command from '../../core/command'
import { flags, FlagInput, managementSDKClient, cliux, printFlagDeprecation } from '@contentstack/cli-utilities'
import buildOutput from '../../core/content-type/compare'
import { getStack, getContentType } from '../../utils'
import Command from "../../core/command";
import {
flags,
FlagInput,
managementSDKClient,
cliux,
printFlagDeprecation,
} from "@contentstack/cli-utilities";
import buildOutput from "../../core/content-type/compare";
import { getStack, getContentType } from "../../utils";

export default class CompareRemoteCommand extends Command {
static description = 'compare two Content Types on different Stacks'
static description = "compare two Content Types on different Stacks";

static examples = [
'$ csdx content-type:compare-remote --origin-stack "xxxxxxxxxxxxxxxxxxx" --remote-stack "xxxxxxxxxxxxxxxxxxx" -content-type "home_page"'
]
'$ csdx content-type:compare-remote --origin-stack "xxxxxxxxxxxxxxxxxxx" --remote-stack "xxxxxxxxxxxxxxxxxxx" -content-type "home_page"',
];

static flags: any = {
'origin-stack': flags.string({
char: 'o',
description: 'Origin Stack API Key',
"origin-stack": flags.string({
char: "o",
description: "Origin Stack API Key",
required: true,
dependsOn: ['remote-stack'],
parse: printFlagDeprecation(['-o'], ['--remote-stack'])
dependsOn: ["remote-stack"],
parse: printFlagDeprecation(["-o"], ["--remote-stack"]),
}),

'remote-stack': flags.string({
char: 'r',
description: 'Remote Stack API Key',
"remote-stack": flags.string({
char: "r",
description: "Remote Stack API Key",
required: true,
dependsOn: ['origin-stack'],
parse: printFlagDeprecation(['-r'], ['--remote-stack'])
dependsOn: ["origin-stack"],
parse: printFlagDeprecation(["-r"], ["--remote-stack"]),
}),

'content-type': flags.string({
char: 'c',
description: 'Content Type UID',
"content-type": flags.string({
char: "c",
description: "Content Type UID",
required: true,
parse: printFlagDeprecation(['-c'], ['--content-type'])
})
}
parse: printFlagDeprecation(["-c"], ["--content-type"]),
}),
};

async run() {
try {
const { flags } = await this.parse(CompareRemoteCommand)
this.setup({ alias: undefined, stack: flags['origin-stack'] })
const { flags } = await this.parse(CompareRemoteCommand);
await this.setup({ alias: undefined, stack: flags["origin-stack"] });
this.contentTypeManagementClient = await managementSDKClient({
host: this.cmaHost,
'X-CS-CLI': this.context?.analyticsInfo
})
"X-CS-CLI": this.context?.analyticsInfo,
});

const originStackApi = flags['origin-stack'] as string
const remoteStackApi = flags['remote-stack'] as string
const originStackApi = flags["origin-stack"] as string;
const remoteStackApi = flags["remote-stack"] as string;

if (originStackApi === remoteStackApi) {
this.warn('You cannot compare the same stack. Please choose different stacks to compare.')
this.warn(
"You cannot compare the same stack. Please choose different stacks to compare."
);
}

const spinner = cliux.loaderV2(Command.RequestDataMessage)
const spinner = cliux.loaderV2(Command.RequestDataMessage);

const [originStackResp, remoteStackResp, originContentTypeResp, remoteContentTypeResp] = await Promise.all([
const [
originStackResp,
remoteStackResp,
originContentTypeResp,
remoteContentTypeResp,
] = await Promise.all([
getStack(this.contentTypeManagementClient, originStackApi, spinner),
getStack(this.contentTypeManagementClient, remoteStackApi, spinner),
getContentType({
managementSdk: this.contentTypeManagementClient,
apiKey: originStackApi,
uid: flags['content-type'],
spinner
uid: flags["content-type"],
spinner,
}),
getContentType({
managementSdk: this.contentTypeManagementClient,
apiKey: remoteStackApi,
uid: flags['content-type'],
spinner
})
])
uid: flags["content-type"],
spinner,
}),
]);

cliux.loaderV2('', spinner)
cliux.loaderV2("", spinner);

const output = await buildOutput(flags['content-type'], originContentTypeResp, remoteContentTypeResp)
this.printOutput(output, 'changes', flags['content-type'], `${originStackResp.name} <-> ${remoteStackResp.name}`)
const output = await buildOutput(
flags["content-type"],
originContentTypeResp,
remoteContentTypeResp
);
this.printOutput(
output,
"changes",
flags["content-type"],
`${originStackResp.name} <-> ${remoteStackResp.name}`
);
} catch (error: any) {
this.error(error?.message || 'An error occurred.', { exit: 1, suggestions: error.suggestions })
this.error(error?.message || "An error occurred.", {
exit: 1,
suggestions: error.suggestions,
});
}
}
}
Loading