-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
413 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,37 @@ | ||
{ | ||
"extends": [ | ||
{ | ||
"extends": [ | ||
"oclif", | ||
"oclif-typescript" | ||
], | ||
"rules": { | ||
"unicorn/no-abusive-eslint-disable": "off", | ||
"@typescript-eslint/no-use-before-define": "off", | ||
"@typescript-eslint/ban-ts-ignore": "off" | ||
"@typescript-eslint/ban-ts-ignore": "off", | ||
"object-curly-spacing": "off", | ||
"no-useless-constructor": "off", | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
"args": "none" | ||
} | ||
], | ||
"@typescript-eslint/prefer-namespace-keyword": "error", | ||
"@typescript-eslint/quotes": [ | ||
"error", | ||
"single", | ||
{ | ||
"avoidEscape": true, | ||
"allowTemplateLiterals": true | ||
} | ||
], | ||
"semi": "off", | ||
"indent": "off", | ||
"comma-dangle": "off", | ||
"unicorn/consistent-function-scoping": "off", | ||
"max-params": "off", | ||
"no-return-await":"off", | ||
"no-process-exit":"off", | ||
"no-trailing-spaces":"off", | ||
"unicorn/no-process-exit":"off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,70 @@ | ||
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 } from "../../utils/index"; | ||
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 } 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 -k "xxxxxxxxxxxxxxxxxxx" -c "home_page"', | ||
'$ csdx content-type:audit -a "management token" -c "home_page"', | ||
]; | ||
'$ csdx content-type:audit -a "management token" -c "home_page"' | ||
] | ||
|
||
static flags: FlagInput = { | ||
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', | ||
description: 'Alias of the management token' | ||
}), | ||
|
||
"content-type": flags.string({ | ||
char: "c", | ||
description: "Content Type UID", | ||
required: true, | ||
}), | ||
}; | ||
'content-type': flags.string({ | ||
char: 'c', | ||
description: 'Content Type UID', | ||
required: true | ||
}) | ||
} | ||
|
||
async run() { | ||
try { | ||
const { flags } = await this.parse(AuditCommand); | ||
this.setup(flags); | ||
const { flags } = await this.parse(AuditCommand) | ||
this.setup(flags) | ||
this.contentTypeManagementClient = await managementSDKClient({ | ||
host: this.cmaHost, | ||
}); | ||
host: this.cmaHost | ||
}) | ||
|
||
const spinner = cliux.loaderV2(Command.RequestDataMessage); | ||
const spinner = cliux.loaderV2(Command.RequestDataMessage) | ||
|
||
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), | ||
]); | ||
this.client.getContentTypeAuditLogs(this.apiKey, flags['content-type'], spinner), | ||
getUsers(this.contentTypeManagementClient, this.apiKey, spinner) | ||
]) | ||
|
||
cliux.loaderV2("", 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, { exit: 1, suggestions: error.suggestions }); | ||
this.error(error, { exit: 1, suggestions: error.suggestions }) | ||
} | ||
} | ||
} |
Oops, something went wrong.