Skip to content

Commit

Permalink
Merge branch 'feat/audit-fix' into fix/removed-commits
Browse files Browse the repository at this point in the history
  • Loading branch information
antonyagustine committed Oct 6, 2023
2 parents c4ca3e1 + 0b52f13 commit 66352fb
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 131 deletions.
6 changes: 3 additions & 3 deletions packages/contentstack-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ npm install -g @contentstack/cli-audit
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-audit/0.0.0-alpha darwin-arm64 node-v16.19.0
@contentstack/cli-audit/0.0.0-alpha darwin-arm64 node-v20.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -127,7 +127,7 @@ EXAMPLES
$ csdx audit:fix --report-path=<path> --filter="name=<filter-value>"
$ csdx audit:fix --report-path=<path> --modules=content-types --filter="name="<filter-value>"
$ csdx audit:fix --report-path=<path> --modules=content-types --filter="name="<filter-value>" --copy-dir --backup-dir=<path>
```

## `csdx cm:stacks:audit`
Expand Down Expand Up @@ -214,7 +214,7 @@ EXAMPLES
$ csdx cm:stacks:audit:fix --report-path=<path> --filter="name=<filter-value>"
$ csdx cm:stacks:audit:fix --report-path=<path> --modules=content-types --filter="name="<filter-value>"
$ csdx cm:stacks:audit:fix --report-path=<path> --modules=content-types --filter="name="<filter-value>" --copy-dir --backup-dir=<path>
```

_See code: [src/commands/cm/stacks/audit/fix.ts](https://github.com/contentstack/audit/blob/main/packages/contentstack-audit/src/commands/cm/stacks/audit/fix.ts)_
Expand Down
20 changes: 12 additions & 8 deletions packages/contentstack-audit/src/audit-base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,26 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma

if (modules.includes('content-types')) {
if (!existsSync(ctPath)) {
throw new Error(this.$t(auditMsg.NOT_VALID_PATH, { path: ctPath }));
this.log(this.$t(auditMsg.NOT_VALID_PATH, { path: ctPath }), 'error');
}
}

if (modules.includes('global-fields')) {
if (!existsSync(gfPath)) {
throw new Error(this.$t(auditMsg.NOT_VALID_PATH, { path: ctPath }));
this.log(this.$t(auditMsg.NOT_VALID_PATH, { path: ctPath }), 'error');
}
}

let gfSchema = JSON.parse(
readFileSync(join(gfPath, this.sharedConfig.moduleConfig['global-fields'].fileName), 'utf-8'),
) as ContentTypeStruct[];
let ctSchema = JSON.parse(
readFileSync(join(ctPath, this.sharedConfig.moduleConfig['content-types'].fileName), 'utf-8'),
) as ContentTypeStruct[];
let gfSchema = existsSync(gfPath)
? (JSON.parse(
readFileSync(join(gfPath, this.sharedConfig.moduleConfig['global-fields'].fileName), 'utf-8'),
) as ContentTypeStruct[])
: [];
let ctSchema = existsSync(ctPath)
? (JSON.parse(
readFileSync(join(ctPath, this.sharedConfig.moduleConfig['content-types'].fileName), 'utf-8'),
) as ContentTypeStruct[])
: [];

return { ctSchema, gfSchema };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class AuditFix extends AuditBaseCommand {
'$ <%= config.bin %> <%= command.id %> --report-path=<path> --copy-dir',
'$ <%= config.bin %> <%= command.id %> --report-path=<path> --copy-dir --csv',
'$ <%= config.bin %> <%= command.id %> --report-path=<path> --filter="name=<filter-value>"',
'$ <%= config.bin %> <%= command.id %> --report-path=<path> --modules=content-types --filter="name="<filter-value>"',
'$ <%= config.bin %> <%= command.id %> --report-path=<path> --modules=content-types --filter="name="<filter-value>" --copy-dir --backup-dir=<path>',
];

static flags: FlagInput = {
Expand Down
Loading

0 comments on commit 66352fb

Please sign in to comment.