@contentstack/cli-audit 1.6.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -34
- package/bin/dev.js +6 -0
- package/bin/run.js +7 -0
- package/lib/audit-base-command.js +43 -36
- package/lib/messages/index.js +6 -1
- package/lib/modules/content-types.d.ts +1 -0
- package/lib/modules/content-types.js +8 -2
- package/lib/modules/entries.d.ts +1 -0
- package/lib/modules/entries.js +8 -2
- package/lib/modules/extensions.d.ts +1 -0
- package/lib/modules/extensions.js +8 -2
- package/lib/modules/workflows.d.ts +1 -0
- package/lib/modules/workflows.js +8 -2
- package/oclif.manifest.json +1 -33
- package/package.json +4 -4
- package/bin/dev +0 -5
- package/bin/run +0 -5
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
|
|
|
19
19
|
$ csdx COMMAND
|
|
20
20
|
running command...
|
|
21
21
|
$ csdx (--version|-v)
|
|
22
|
-
@contentstack/cli-audit/1.6.
|
|
22
|
+
@contentstack/cli-audit/1.6.2 linux-x64 node-v18.20.3
|
|
23
23
|
$ csdx --help [COMMAND]
|
|
24
24
|
USAGE
|
|
25
25
|
$ csdx COMMAND
|
|
@@ -52,19 +52,14 @@ Perform audits and find possible errors in the exported Contentstack data
|
|
|
52
52
|
|
|
53
53
|
```
|
|
54
54
|
USAGE
|
|
55
|
-
$ csdx audit [
|
|
56
|
-
|
|
57
|
-
[--csv | --no-truncate]
|
|
55
|
+
$ csdx audit [--report-path <value>] [--modules content-types|global-fields|entries|extensions|workflows]
|
|
56
|
+
[--columns <value> | ] [--sort <value>] [--filter <value>] [--csv | --no-truncate]
|
|
58
57
|
|
|
59
58
|
FLAGS
|
|
60
59
|
--modules=<option>... Provide the list of modules to be audited
|
|
61
60
|
<options: content-types|global-fields|entries|extensions|workflows>
|
|
62
61
|
--report-path=<value> Path to store the audit reports
|
|
63
62
|
|
|
64
|
-
COMMON FLAGS
|
|
65
|
-
-c, --config=<value> Path of the external config
|
|
66
|
-
-d, --data-dir=<value> Path where the data is stored
|
|
67
|
-
|
|
68
63
|
TABLE FLAGS
|
|
69
64
|
--columns=<value> Show only the specified columns (comma-separated)
|
|
70
65
|
--csv The output is in the CSV format [alias: --output=csv]
|
|
@@ -97,8 +92,8 @@ Perform audits and fix possible errors in the exported Contentstack data.
|
|
|
97
92
|
|
|
98
93
|
```
|
|
99
94
|
USAGE
|
|
100
|
-
$ csdx audit:fix [
|
|
101
|
-
|
|
95
|
+
$ csdx audit:fix [--report-path <value>] [--modules content-types|global-fields|entries|extensions|workflows]
|
|
96
|
+
[--copy-path <value> --copy-dir] [--fix-only
|
|
102
97
|
reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ] [--sort <value>]
|
|
103
98
|
[--filter <value>] [--csv | --no-truncate]
|
|
104
99
|
|
|
@@ -111,10 +106,6 @@ FLAGS
|
|
|
111
106
|
<options: content-types|global-fields|entries|extensions|workflows>
|
|
112
107
|
--report-path=<value> Path to store the audit reports
|
|
113
108
|
|
|
114
|
-
COMMON FLAGS
|
|
115
|
-
-c, --config=<value> Path of the external config
|
|
116
|
-
-d, --data-dir=<value> Path where the data is stored
|
|
117
|
-
|
|
118
109
|
TABLE FLAGS
|
|
119
110
|
--columns=<value> Show only the specified columns (comma-separated)
|
|
120
111
|
--csv The output is in the CSV format [alias: --output=csv]
|
|
@@ -149,19 +140,14 @@ Perform audits and find possible errors in the exported Contentstack data
|
|
|
149
140
|
|
|
150
141
|
```
|
|
151
142
|
USAGE
|
|
152
|
-
$ csdx cm:stacks:audit [
|
|
153
|
-
|
|
154
|
-
[--csv | --no-truncate]
|
|
143
|
+
$ csdx cm:stacks:audit [--report-path <value>] [--modules content-types|global-fields|entries|extensions|workflows]
|
|
144
|
+
[--columns <value> | ] [--sort <value>] [--filter <value>] [--csv | --no-truncate]
|
|
155
145
|
|
|
156
146
|
FLAGS
|
|
157
147
|
--modules=<option>... Provide the list of modules to be audited
|
|
158
148
|
<options: content-types|global-fields|entries|extensions|workflows>
|
|
159
149
|
--report-path=<value> Path to store the audit reports
|
|
160
150
|
|
|
161
|
-
COMMON FLAGS
|
|
162
|
-
-c, --config=<value> Path of the external config
|
|
163
|
-
-d, --data-dir=<value> Path where the data is stored
|
|
164
|
-
|
|
165
151
|
TABLE FLAGS
|
|
166
152
|
--columns=<value> Show only the specified columns (comma-separated)
|
|
167
153
|
--csv The output is in the CSV format [alias: --output=csv]
|
|
@@ -196,8 +182,8 @@ Perform audits and fix possible errors in the exported Contentstack data.
|
|
|
196
182
|
|
|
197
183
|
```
|
|
198
184
|
USAGE
|
|
199
|
-
$ csdx cm:stacks:audit:fix [
|
|
200
|
-
|
|
185
|
+
$ csdx cm:stacks:audit:fix [--report-path <value>] [--modules content-types|global-fields|entries|extensions|workflows]
|
|
186
|
+
[--copy-path <value> --copy-dir] [--fix-only
|
|
201
187
|
reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ] [--sort <value>]
|
|
202
188
|
[--filter <value>] [--csv | --no-truncate]
|
|
203
189
|
|
|
@@ -210,10 +196,6 @@ FLAGS
|
|
|
210
196
|
<options: content-types|global-fields|entries|extensions|workflows>
|
|
211
197
|
--report-path=<value> Path to store the audit reports
|
|
212
198
|
|
|
213
|
-
COMMON FLAGS
|
|
214
|
-
-c, --config=<value> Path of the external config
|
|
215
|
-
-d, --data-dir=<value> Path where the data is stored
|
|
216
|
-
|
|
217
199
|
TABLE FLAGS
|
|
218
200
|
--columns=<value> Show only the specified columns (comma-separated)
|
|
219
201
|
--csv The output is in the CSV format [alias: --output=csv]
|
|
@@ -285,7 +267,7 @@ EXAMPLES
|
|
|
285
267
|
$ csdx plugins
|
|
286
268
|
```
|
|
287
269
|
|
|
288
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.
|
|
270
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.2/src/commands/plugins/index.ts)_
|
|
289
271
|
|
|
290
272
|
## `csdx plugins:add PLUGIN`
|
|
291
273
|
|
|
@@ -359,7 +341,7 @@ EXAMPLES
|
|
|
359
341
|
$ csdx plugins:inspect myplugin
|
|
360
342
|
```
|
|
361
343
|
|
|
362
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.
|
|
344
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.2/src/commands/plugins/inspect.ts)_
|
|
363
345
|
|
|
364
346
|
## `csdx plugins:install PLUGIN`
|
|
365
347
|
|
|
@@ -408,7 +390,7 @@ EXAMPLES
|
|
|
408
390
|
$ csdx plugins:install someuser/someplugin
|
|
409
391
|
```
|
|
410
392
|
|
|
411
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.
|
|
393
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.2/src/commands/plugins/install.ts)_
|
|
412
394
|
|
|
413
395
|
## `csdx plugins:link PATH`
|
|
414
396
|
|
|
@@ -438,7 +420,7 @@ EXAMPLES
|
|
|
438
420
|
$ csdx plugins:link myplugin
|
|
439
421
|
```
|
|
440
422
|
|
|
441
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.
|
|
423
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.2/src/commands/plugins/link.ts)_
|
|
442
424
|
|
|
443
425
|
## `csdx plugins:remove [PLUGIN]`
|
|
444
426
|
|
|
@@ -479,7 +461,7 @@ FLAGS
|
|
|
479
461
|
--reinstall Reinstall all plugins after uninstalling.
|
|
480
462
|
```
|
|
481
463
|
|
|
482
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.
|
|
464
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.2/src/commands/plugins/reset.ts)_
|
|
483
465
|
|
|
484
466
|
## `csdx plugins:uninstall [PLUGIN]`
|
|
485
467
|
|
|
@@ -507,7 +489,7 @@ EXAMPLES
|
|
|
507
489
|
$ csdx plugins:uninstall myplugin
|
|
508
490
|
```
|
|
509
491
|
|
|
510
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.
|
|
492
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.2/src/commands/plugins/uninstall.ts)_
|
|
511
493
|
|
|
512
494
|
## `csdx plugins:unlink [PLUGIN]`
|
|
513
495
|
|
|
@@ -551,5 +533,5 @@ DESCRIPTION
|
|
|
551
533
|
Update installed plugins.
|
|
552
534
|
```
|
|
553
535
|
|
|
554
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.
|
|
536
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.2/src/commands/plugins/update.ts)_
|
|
555
537
|
<!-- commandsstop -->
|
package/bin/dev.js
ADDED
package/bin/run.js
ADDED
|
@@ -317,7 +317,7 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
317
317
|
(0, fs_1.mkdirSync)(this.sharedConfig.reportPath, { recursive: true });
|
|
318
318
|
}
|
|
319
319
|
// NOTE write int json
|
|
320
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(this.sharedConfig.reportPath, `${moduleName}.json`), JSON.stringify(listOfMissingRefs));
|
|
320
|
+
(0, fs_1.writeFileSync)((0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.sharedConfig.reportPath), `${(0, cli_utilities_1.sanitizePath)(moduleName)}.json`), JSON.stringify(listOfMissingRefs));
|
|
321
321
|
// NOTE write into CSV
|
|
322
322
|
return this.prepareCSV(moduleName, listOfMissingRefs);
|
|
323
323
|
}
|
|
@@ -332,44 +332,51 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
332
332
|
* @returns The function `prepareCSV` returns a Promise that resolves to `void`.
|
|
333
333
|
*/
|
|
334
334
|
prepareCSV(moduleName, listOfMissingRefs) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
335
|
+
if (Object.keys(config_1.default.moduleConfig).includes(moduleName)) {
|
|
336
|
+
const csvPath = (0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.sharedConfig.reportPath), `${(0, cli_utilities_1.sanitizePath)(moduleName)}.csv`);
|
|
337
|
+
return new Promise((resolve, reject) => {
|
|
338
|
+
// file deepcode ignore MissingClose: Will auto close once csv stream end
|
|
339
|
+
const ws = (0, fs_1.createWriteStream)(csvPath).on('error', reject);
|
|
340
|
+
const defaultColumns = Object.keys(types_1.OutputColumn);
|
|
341
|
+
const userDefinedColumns = this.sharedConfig.flags.columns ? this.sharedConfig.flags.columns.split(',') : null;
|
|
342
|
+
let missingRefs = Object.values(listOfMissingRefs).flat();
|
|
343
|
+
const columns = userDefinedColumns
|
|
344
|
+
? [...userDefinedColumns, ...defaultColumns.filter((val) => !userDefinedColumns.includes(val))]
|
|
345
|
+
: defaultColumns;
|
|
346
|
+
if (this.sharedConfig.flags.filter) {
|
|
347
|
+
const [column, value] = this.sharedConfig.flags.filter.split('=');
|
|
348
|
+
// Filter the missingRefs array
|
|
349
|
+
missingRefs = missingRefs.filter((row) => {
|
|
350
|
+
if (types_1.OutputColumn[column] in row) {
|
|
351
|
+
const rowKey = types_1.OutputColumn[column];
|
|
352
|
+
return row[rowKey] === value;
|
|
353
|
+
}
|
|
354
|
+
return false;
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
const rowData = [];
|
|
358
|
+
for (const issue of missingRefs) {
|
|
359
|
+
let row = {};
|
|
360
|
+
for (const column of columns) {
|
|
361
|
+
if (Object.keys(issue).includes(types_1.OutputColumn[column])) {
|
|
362
|
+
const issueKey = types_1.OutputColumn[column];
|
|
363
|
+
row[column] = issue[issueKey];
|
|
364
|
+
row[column] = typeof row[column] === 'object' ? JSON.stringify(row[column]) : row[column];
|
|
365
|
+
}
|
|
352
366
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
const rowData = [];
|
|
357
|
-
for (const issue of missingRefs) {
|
|
358
|
-
let row = {};
|
|
359
|
-
for (const column of columns) {
|
|
360
|
-
if (Object.keys(issue).includes(types_1.OutputColumn[column])) {
|
|
361
|
-
const issueKey = types_1.OutputColumn[column];
|
|
362
|
-
row[column] = issue[issueKey];
|
|
363
|
-
row[column] = typeof row[column] === 'object' ? JSON.stringify(row[column]) : row[column];
|
|
367
|
+
if (this.currentCommand === 'cm:stacks:audit:fix') {
|
|
368
|
+
row['Fix status'] = row.fixStatus;
|
|
364
369
|
}
|
|
370
|
+
rowData.push(row);
|
|
365
371
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
372
|
+
csv.write(rowData, { headers: true }).pipe(ws).on('error', reject).on('finish', resolve);
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
return new Promise((reject) => {
|
|
377
|
+
return reject();
|
|
378
|
+
});
|
|
379
|
+
}
|
|
373
380
|
}
|
|
374
381
|
}
|
|
375
382
|
exports.AuditBaseCommand = AuditBaseCommand;
|
package/lib/messages/index.js
CHANGED
|
@@ -69,7 +69,12 @@ function $t(msg, args) {
|
|
|
69
69
|
return '';
|
|
70
70
|
for (const key of Object.keys(args)) {
|
|
71
71
|
const escapedKey = (0, cli_utilities_1.escapeRegExp)(key);
|
|
72
|
-
|
|
72
|
+
const escapedKeyRegex = new RegExp(`{${escapedKey}}`, 'g');
|
|
73
|
+
let { status } = (0, cli_utilities_1.validateRegex)(escapedKeyRegex);
|
|
74
|
+
if (status === 'safe') {
|
|
75
|
+
const sanitizedValue = args[key] ? (0, cli_utilities_1.escapeRegExp)(args[key]) : '';
|
|
76
|
+
msg = msg.replace(escapedKeyRegex, sanitizedValue || escapedKey);
|
|
77
|
+
}
|
|
73
78
|
}
|
|
74
79
|
return msg;
|
|
75
80
|
});
|
|
@@ -16,6 +16,7 @@ export default class ContentType {
|
|
|
16
16
|
protected missingRefs: Record<string, any>;
|
|
17
17
|
moduleName: keyof typeof auditConfig.moduleConfig;
|
|
18
18
|
constructor({ log, fix, config, moduleName, ctSchema, gfSchema }: ModuleConstructorParam & CtConstructorParam);
|
|
19
|
+
validateModules(moduleName: keyof typeof auditConfig.moduleConfig, moduleConfig: Record<string, unknown>): keyof typeof auditConfig.moduleConfig;
|
|
19
20
|
/**
|
|
20
21
|
* The `run` function checks if a folder path exists, sets the schema based on the module name,
|
|
21
22
|
* iterates over the schema and looks for references, and returns a list of missing references.
|
|
@@ -21,9 +21,15 @@ class ContentType {
|
|
|
21
21
|
this.fix = fix !== null && fix !== void 0 ? fix : false;
|
|
22
22
|
this.ctSchema = ctSchema;
|
|
23
23
|
this.gfSchema = gfSchema;
|
|
24
|
-
this.moduleName = moduleName
|
|
24
|
+
this.moduleName = this.validateModules(moduleName, this.config.moduleConfig);
|
|
25
25
|
this.fileName = config.moduleConfig[this.moduleName].fileName;
|
|
26
|
-
this.folderPath = (0, path_1.resolve)(config.basePath, config.moduleConfig[this.moduleName].dirName);
|
|
26
|
+
this.folderPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(config.basePath), (0, cli_utilities_1.sanitizePath)(config.moduleConfig[this.moduleName].dirName));
|
|
27
|
+
}
|
|
28
|
+
validateModules(moduleName, moduleConfig) {
|
|
29
|
+
if (Object.keys(moduleConfig).includes(moduleName)) {
|
|
30
|
+
return moduleName;
|
|
31
|
+
}
|
|
32
|
+
return 'content-types';
|
|
27
33
|
}
|
|
28
34
|
/**
|
|
29
35
|
* The `run` function checks if a folder path exists, sets the schema based on the module name,
|
package/lib/modules/entries.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export default class Entries {
|
|
|
20
20
|
moduleName: keyof typeof auditConfig.moduleConfig;
|
|
21
21
|
isEntryWithoutTitleField: boolean;
|
|
22
22
|
constructor({ log, fix, config, moduleName, ctSchema, gfSchema }: ModuleConstructorParam & CtConstructorParam);
|
|
23
|
+
validateModules(moduleName: keyof typeof auditConfig.moduleConfig, moduleConfig: Record<string, unknown>): keyof typeof auditConfig.moduleConfig;
|
|
23
24
|
/**
|
|
24
25
|
* The `run` function checks if a folder path exists, sets the schema based on the module name,
|
|
25
26
|
* iterates over the schema and looks for references, and returns a list of missing references.
|
package/lib/modules/entries.js
CHANGED
|
@@ -26,9 +26,15 @@ class Entries {
|
|
|
26
26
|
this.fix = fix !== null && fix !== void 0 ? fix : false;
|
|
27
27
|
this.ctSchema = ctSchema;
|
|
28
28
|
this.gfSchema = gfSchema;
|
|
29
|
-
this.moduleName = moduleName
|
|
29
|
+
this.moduleName = this.validateModules(moduleName, this.config.moduleConfig);
|
|
30
30
|
this.fileName = config.moduleConfig[this.moduleName].fileName;
|
|
31
|
-
this.folderPath = (0, path_1.resolve)(config.basePath, config.moduleConfig.entries.dirName);
|
|
31
|
+
this.folderPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(config.basePath), (0, cli_utilities_1.sanitizePath)(config.moduleConfig.entries.dirName));
|
|
32
|
+
}
|
|
33
|
+
validateModules(moduleName, moduleConfig) {
|
|
34
|
+
if (Object.keys(moduleConfig).includes(moduleName)) {
|
|
35
|
+
return moduleName;
|
|
36
|
+
}
|
|
37
|
+
return 'entries';
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
34
40
|
* The `run` function checks if a folder path exists, sets the schema based on the module name,
|
|
@@ -14,6 +14,7 @@ export default class Extensions {
|
|
|
14
14
|
missingCts: Set<string>;
|
|
15
15
|
extensionsPath: string;
|
|
16
16
|
constructor({ log, fix, config, moduleName, ctSchema, }: ModuleConstructorParam & Pick<CtConstructorParam, 'ctSchema'>);
|
|
17
|
+
validateModules(moduleName: keyof typeof auditConfig.moduleConfig, moduleConfig: Record<string, unknown>): keyof typeof auditConfig.moduleConfig;
|
|
17
18
|
run(): Promise<{}>;
|
|
18
19
|
fixExtensionsScope(missingCtInExtensions: Extension[]): Promise<void>;
|
|
19
20
|
writeFixContent(fixedExtensions: Record<string, Extension>): Promise<void>;
|
|
@@ -14,14 +14,20 @@ class Extensions {
|
|
|
14
14
|
this.fix = fix !== null && fix !== void 0 ? fix : false;
|
|
15
15
|
this.ctSchema = ctSchema;
|
|
16
16
|
this.extensionsSchema = [];
|
|
17
|
-
this.moduleName = moduleName
|
|
17
|
+
this.moduleName = this.validateModules(moduleName, this.config.moduleConfig);
|
|
18
18
|
this.fileName = config.moduleConfig[this.moduleName].fileName;
|
|
19
|
-
this.folderPath = (0, path_1.resolve)(config.basePath, config.moduleConfig[this.moduleName].dirName);
|
|
19
|
+
this.folderPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(config.basePath), (0, cli_utilities_1.sanitizePath)(config.moduleConfig[this.moduleName].dirName));
|
|
20
20
|
this.ctUidSet = new Set(['$all']);
|
|
21
21
|
this.missingCtInExtensions = [];
|
|
22
22
|
this.missingCts = new Set();
|
|
23
23
|
this.extensionsPath = '';
|
|
24
24
|
}
|
|
25
|
+
validateModules(moduleName, moduleConfig) {
|
|
26
|
+
if (Object.keys(moduleConfig).includes(moduleName)) {
|
|
27
|
+
return moduleName;
|
|
28
|
+
}
|
|
29
|
+
return 'extensions';
|
|
30
|
+
}
|
|
25
31
|
async run() {
|
|
26
32
|
if (!(0, fs_1.existsSync)(this.folderPath)) {
|
|
27
33
|
this.log(`Skipping ${this.moduleName} audit`, 'warn');
|
|
@@ -15,6 +15,7 @@ export default class Workflows {
|
|
|
15
15
|
workflowPath: string;
|
|
16
16
|
isBranchFixDone: boolean;
|
|
17
17
|
constructor({ log, fix, config, moduleName, ctSchema, }: ModuleConstructorParam & Pick<CtConstructorParam, 'ctSchema'>);
|
|
18
|
+
validateModules(moduleName: keyof typeof auditConfig.moduleConfig, moduleConfig: Record<string, unknown>): keyof typeof auditConfig.moduleConfig;
|
|
18
19
|
/**
|
|
19
20
|
* Check whether the given path for the workflow exists or not
|
|
20
21
|
* If path exist read
|
package/lib/modules/workflows.js
CHANGED
|
@@ -13,15 +13,21 @@ class Workflows {
|
|
|
13
13
|
this.fix = fix !== null && fix !== void 0 ? fix : false;
|
|
14
14
|
this.ctSchema = ctSchema;
|
|
15
15
|
this.workflowSchema = [];
|
|
16
|
-
this.moduleName = moduleName
|
|
16
|
+
this.moduleName = this.validateModules(moduleName, this.config.moduleConfig);
|
|
17
17
|
this.fileName = config.moduleConfig[this.moduleName].fileName;
|
|
18
|
-
this.folderPath = (0, path_1.resolve)(config.basePath, config.moduleConfig[this.moduleName].dirName);
|
|
18
|
+
this.folderPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(config.basePath), (0, cli_utilities_1.sanitizePath)(config.moduleConfig[this.moduleName].dirName));
|
|
19
19
|
this.ctUidSet = new Set(['$all']);
|
|
20
20
|
this.missingCtInWorkflows = [];
|
|
21
21
|
this.missingCts = new Set();
|
|
22
22
|
this.workflowPath = '';
|
|
23
23
|
this.isBranchFixDone = false;
|
|
24
24
|
}
|
|
25
|
+
validateModules(moduleName, moduleConfig) {
|
|
26
|
+
if (Object.keys(moduleConfig).includes(moduleName)) {
|
|
27
|
+
return moduleName;
|
|
28
|
+
}
|
|
29
|
+
return 'workflows';
|
|
30
|
+
}
|
|
25
31
|
/**
|
|
26
32
|
* Check whether the given path for the workflow exists or not
|
|
27
33
|
* If path exist read
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.6.
|
|
2
|
+
"version": "1.6.2",
|
|
3
3
|
"commands": {
|
|
4
4
|
"cm:stacks:audit:fix": {
|
|
5
5
|
"id": "cm:stacks:audit:fix",
|
|
@@ -22,22 +22,6 @@
|
|
|
22
22
|
"$ <%= config.bin %> <%= command.id %> --report-path=<path> --modules=content-types --filter=\"name=\"<filter-value>\" --copy-dir --copy-path=<path>"
|
|
23
23
|
],
|
|
24
24
|
"flags": {
|
|
25
|
-
"config": {
|
|
26
|
-
"name": "config",
|
|
27
|
-
"type": "option",
|
|
28
|
-
"char": "c",
|
|
29
|
-
"description": "Path of the external config",
|
|
30
|
-
"helpGroup": "COMMON",
|
|
31
|
-
"multiple": false
|
|
32
|
-
},
|
|
33
|
-
"data-dir": {
|
|
34
|
-
"name": "data-dir",
|
|
35
|
-
"type": "option",
|
|
36
|
-
"char": "d",
|
|
37
|
-
"description": "Path where the data is stored",
|
|
38
|
-
"helpGroup": "COMMON",
|
|
39
|
-
"multiple": false
|
|
40
|
-
},
|
|
41
25
|
"report-path": {
|
|
42
26
|
"name": "report-path",
|
|
43
27
|
"type": "option",
|
|
@@ -176,22 +160,6 @@
|
|
|
176
160
|
"$ <%= config.bin %> <%= command.id %> --report-path=<path> --modules=content-types --filter=\"name=\"<filter-value>\""
|
|
177
161
|
],
|
|
178
162
|
"flags": {
|
|
179
|
-
"config": {
|
|
180
|
-
"name": "config",
|
|
181
|
-
"type": "option",
|
|
182
|
-
"char": "c",
|
|
183
|
-
"description": "Path of the external config",
|
|
184
|
-
"helpGroup": "COMMON",
|
|
185
|
-
"multiple": false
|
|
186
|
-
},
|
|
187
|
-
"data-dir": {
|
|
188
|
-
"name": "data-dir",
|
|
189
|
-
"type": "option",
|
|
190
|
-
"char": "d",
|
|
191
|
-
"description": "Path where the data is stored",
|
|
192
|
-
"helpGroup": "COMMON",
|
|
193
|
-
"multiple": false
|
|
194
|
-
},
|
|
195
163
|
"report-path": {
|
|
196
164
|
"name": "report-path",
|
|
197
165
|
"type": "option",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-audit",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Contentstack audit plugin",
|
|
5
5
|
"author": "Contentstack CLI",
|
|
6
6
|
"homepage": "https://github.com/contentstack/cli",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"main": "./lib/index.js",
|
|
9
9
|
"types": "./lib/index.d.ts",
|
|
10
10
|
"bin": {
|
|
11
|
-
"audit": "./bin/run"
|
|
11
|
+
"audit": "./bin/run.js"
|
|
12
12
|
},
|
|
13
13
|
"repository": "contentstack/audit",
|
|
14
14
|
"files": [
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"/oclif.manifest.json"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@contentstack/cli-command": "~1.2.
|
|
22
|
-
"@contentstack/cli-utilities": "~1.6.
|
|
21
|
+
"@contentstack/cli-command": "~1.2.18",
|
|
22
|
+
"@contentstack/cli-utilities": "~1.6.2",
|
|
23
23
|
"@oclif/plugin-help": "^5",
|
|
24
24
|
"@oclif/plugin-plugins": "^5.0.0",
|
|
25
25
|
"chalk": "^4.1.2",
|
package/bin/dev
DELETED