Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aman19K committed Jun 15, 2023
1 parent 7e22666 commit dce7c8f
Show file tree
Hide file tree
Showing 14 changed files with 413 additions and 455 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/lib
32 changes: 29 additions & 3 deletions .eslintrc
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"
}
}
67 changes: 39 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ Display recent changes to a Content Type

```
USAGE
$ csdx content-type:audit -c <value> [-k <value> | -a <value>]
$ csdx content-type:audit -c <value> [-s <value> | -a <value> | -a <value>] [-k <value> | | ]
FLAGS
-a, --token-alias=<value> Management token alias
-c, --content-type=<value> (required) Content Type UID
-k, --stack=<value> Stack API Key
-a, --alias=<value> Alias of the management token
-a, --token-alias=<value> Management token alias
-c, --content-type=<value> (required) Content Type UID
-k, --stack-api-key=<value> Stack API Key
-s, --stack=<value> Stack UID
DESCRIPTION
Display recent changes to a Content Type
Expand All @@ -92,14 +94,16 @@ Compare two Content Type versions

```
USAGE
$ csdx content-type:compare -c <value> [-k <value> | -a <value>] [-l <value> -r <value>]
$ csdx content-type:compare -c <value> [-s <value> | -a <value>] [-k <value> | ] [-a <value>] [-l <value> -r <value>]
FLAGS
-a, --token-alias=<value> Management token alias
-c, --content-type=<value> (required) Content Type UID
-k, --stack=<value> Stack API Key
-l, --left=<value> Content Type version, i.e. prev version
-r, --right=<value> Content Type version, i.e. later version
-a, --alias=<value> Alias of the management token
-a, --token-alias=<value> Management token alias
-c, --content-type=<value> (required) Content Type UID
-k, --stack-api-key=<value> Stack API Key
-l, --left=<value> Content Type version, i.e. prev version
-r, --right=<value> Content Type version, i.e. later version
-s, --stack=<value> Stack UID
DESCRIPTION
Compare two Content Type versions
Expand Down Expand Up @@ -142,13 +146,15 @@ Display Content Type details

```
USAGE
$ csdx content-type:details -c <value> [-k <value> | -a <value>] [-p]
$ csdx content-type:details -c <value> [-s <value> | -a <value>] [-k <value> | ] [-a <value>] [-p]
FLAGS
-a, --token-alias=<value> Management token alias
-c, --content-type=<value> (required) Content Type UID
-k, --stack=<value> Stack API Key
-p, --[no-]path show path column
-a, --alias=<value> Alias of the management token
-a, --token-alias=<value> Management token alias
-c, --content-type=<value> (required) Content Type UID
-k, --stack-api-key=<value> Stack API Key
-p, --[no-]path show path column
-s, --stack=<value> Stack UID
DESCRIPTION
Display Content Type details
Expand All @@ -169,16 +175,19 @@ Create a visual diagram of a Stack's Content Types

```
USAGE
$ csdx content-type:diagram -o <value> -d portrait|landscape -t svg|dot [-k <value> | -a <value>]
$ csdx content-type:diagram -o <value> -d portrait|landscape -t svg|dot [-s <value> | -a <value> | -a <value>] [-k
<value> | | ]
FLAGS
-a, --token-alias=<value> Management token alias
-d, --direction=<option> (required) [default: portrait] graph orientation
<options: portrait|landscape>
-k, --stack=<value> Stack API Key
-o, --output=<value> (required) full path to output
-t, --type=<option> (required) [default: svg] graph output file type
<options: svg|dot>
-a, --alias=<value> Alias of the management token
-a, --token-alias=<value> Management token alias
-d, --direction=<option> (required) [default: portrait] graph orientation
<options: portrait|landscape>
-k, --stack-api-key=<value> Stack API Key
-o, --output=<value> (required) full path to output
-s, --stack=<value> Stack UID
-t, --type=<option> (required) [default: svg] graph output file type
<options: svg|dot>
DESCRIPTION
Create a visual diagram of a Stack's Content Types
Expand All @@ -201,13 +210,15 @@ List all Content Types in a Stack

```
USAGE
$ csdx content-type:list [-k <value> | -a <value>] [-o title|modified]
$ csdx content-type:list [-s <value> | -a <value> | -a <value>] [-k <value> | | ] [-o title|modified]
FLAGS
-a, --token-alias=<value> Management token alias
-k, --stack=<value> Stack API Key
-o, --order=<option> [default: title] order by column
<options: title|modified>
-a, --alias=<value> Alias of the management token
-a, --token-alias=<value> Management token alias
-k, --stack-api-key=<value> Stack API Key
-o, --order=<option> [default: title] order by column
<options: title|modified>
-s, --stack=<value> Stack UID
DESCRIPTION
List all Content Types in a Stack
Expand Down
82 changes: 38 additions & 44 deletions src/commands/content-type/audit.ts
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 })
}
}
}
Loading

0 comments on commit dce7c8f

Please sign in to comment.