Skip to content

Commit 74edda5

Browse files
author
naman-contentstack
committed
Merge branch 'development' into feat/DX-2346
2 parents 4e2ff8d + f5107a4 commit 74edda5

File tree

26 files changed

+1366
-934
lines changed

26 files changed

+1366
-934
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,5 @@ jobs:
303303
id: create_release
304304
env:
305305
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
306-
run: gh release create v${{ steps.publish-core.outputs.version }} --title "Release ${{ steps.publish-core.outputs.version }}" --generate-notes
306+
VERSION: ${{ steps.publish-to-npm.outputs.version }}
307+
run: gh release create v"$VERSION" --title "Release $VERSION" --generate-notes

package-lock.json

Lines changed: 327 additions & 182 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-audit/README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
1919
$ csdx COMMAND
2020
running command...
2121
$ csdx (--version|-v)
22-
@contentstack/cli-audit/1.10.0 darwin-arm64 node-v22.13.1
22+
@contentstack/cli-audit/1.10.0 darwin-arm64 node-v22.14.0
2323
$ csdx --help [COMMAND]
2424
USAGE
2525
$ csdx COMMAND
@@ -53,12 +53,13 @@ Perform audits and find possible errors in the exported Contentstack data
5353
```
5454
USAGE
5555
$ csdx audit [-c <value>] [-d <value>] [--report-path <value>] [--modules
56-
content-types|global-fields|entries|extensions|workflows|custom-roles|assets...] [--columns <value>] [--sort
57-
<value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]
56+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules...] [--columns <value>]
57+
[--sort <value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]
5858
5959
FLAGS
6060
--modules=<option>... Provide the list of modules to be audited
61-
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
61+
<options:
62+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules>
6263
--report-path=<value> Path to store the audit reports
6364
6465
COMMON FLAGS
@@ -101,17 +102,18 @@ Perform audits and fix possible errors in the exported Contentstack data.
101102
```
102103
USAGE
103104
$ csdx audit:fix [-c <value>] [-d <value>] [--report-path <value>] [--modules
104-
content-types|global-fields|entries|extensions|workflows|custom-roles|assets...] [--copy-path <value> --copy-dir]
105-
[--fix-only reference|global_field|json:rte|json:extension|blocks|group|content_types...] [--columns <value>]
106-
[--sort <value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]
105+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules...] [--copy-path <value>
106+
--copy-dir] [--fix-only reference|global_field|json:rte|json:extension|blocks|group|content_types...] [--columns
107+
<value>] [--sort <value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]
107108
108109
FLAGS
109110
--copy-dir Create backup from the original data.
110111
--copy-path=<value> Provide the path to backup the copied data
111112
--fix-only=<option>... Provide the list of fix options
112113
<options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
113114
--modules=<option>... Provide the list of modules to be audited
114-
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
115+
<options:
116+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules>
115117
--report-path=<value> Path to store the audit reports
116118
117119
COMMON FLAGS
@@ -156,12 +158,13 @@ Perform audits and find possible errors in the exported Contentstack data
156158
```
157159
USAGE
158160
$ csdx cm:stacks:audit [-c <value>] [-d <value>] [--report-path <value>] [--modules
159-
content-types|global-fields|entries|extensions|workflows|custom-roles|assets...] [--columns <value>] [--sort
160-
<value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]
161+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules...] [--columns <value>]
162+
[--sort <value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]
161163
162164
FLAGS
163165
--modules=<option>... Provide the list of modules to be audited
164-
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
166+
<options:
167+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules>
165168
--report-path=<value> Path to store the audit reports
166169
167170
COMMON FLAGS
@@ -206,17 +209,18 @@ Perform audits and fix possible errors in the exported Contentstack data.
206209
```
207210
USAGE
208211
$ csdx cm:stacks:audit:fix [-c <value>] [-d <value>] [--report-path <value>] [--modules
209-
content-types|global-fields|entries|extensions|workflows|custom-roles|assets...] [--copy-path <value> --copy-dir]
210-
[--fix-only reference|global_field|json:rte|json:extension|blocks|group|content_types...] [--columns <value>]
211-
[--sort <value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]
212+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules...] [--copy-path <value>
213+
--copy-dir] [--fix-only reference|global_field|json:rte|json:extension|blocks|group|content_types...] [--columns
214+
<value>] [--sort <value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]
212215
213216
FLAGS
214217
--copy-dir Create backup from the original data.
215218
--copy-path=<value> Provide the path to backup the copied data
216219
--fix-only=<option>... Provide the list of fix options
217220
<options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
218221
--modules=<option>... Provide the list of modules to be audited
219-
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
222+
<options:
223+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules>
220224
--report-path=<value> Path to store the audit reports
221225
222226
COMMON FLAGS

packages/contentstack-audit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/cli-audit",
3-
"version": "1.10.0",
3+
"version": "1.11.0",
44
"description": "Contentstack audit plugin",
55
"author": "Contentstack CLI",
66
"homepage": "https://github.com/contentstack/cli",
@@ -70,7 +70,7 @@
7070
"postpack": "shx rm -f oclif.manifest.json",
7171
"posttest": "npm run lint",
7272
"compile": "shx rm -rf lib && tsc -b",
73-
"prepack": "npm run build && oclif manifest && oclif readme",
73+
"prepack": "pnpm compile && oclif manifest && oclif readme",
7474
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
7575
"version": "oclif readme && git add README.md",
7676
"clean": "rm -rf ./lib ./node_modules tsconfig.tsbuildinfo oclif.manifest.json",

packages/contentstack-audit/src/modules/field_rules.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,11 @@ export default class FieldRule {
7575
* iterates over the schema and looks for references, and returns a list of missing references.
7676
* @returns the `missingRefs` object.
7777
*/
78-
async run(returnFixSchema = false) {
79-
this.inMemoryFix = returnFixSchema;
80-
78+
async run() {
8179
if (!existsSync(this.folderPath)) {
8280
this.log(`Skipping ${this.moduleName} audit`, 'warn');
8381
this.log($t(auditMsg.NOT_VALID_PATH, { path: this.folderPath }), { color: 'yellow' });
84-
return returnFixSchema ? [] : {};
82+
return {};
8583
}
8684

8785
this.schema = this.moduleName === 'content-types' ? this.ctSchema : this.gfSchema;
@@ -282,7 +280,7 @@ export default class FieldRule {
282280
async writeFixContent(): Promise<void> {
283281
let canWrite = true;
284282

285-
if (!this.inMemoryFix && this.fix) {
283+
if (this.fix) {
286284
if (!this.config.flags['copy-dir'] && !this.config.flags['external-config']?.skipConfirm) {
287285
canWrite = this.config.flags.yes ?? (await cliux.confirm(commonMsg.FIX_CONFIRMATION));
288286
}
@@ -381,7 +379,7 @@ export default class FieldRule {
381379

382380
const entriesFolderPath = resolve(sanitizePath(this.config.basePath), 'entries');
383381
for (const { code } of this.locales) {
384-
for (const { uid } of this.ctSchema) {
382+
for (const { uid } of this.ctSchema??[]) {
385383
let basePath = join(entriesFolderPath, uid, code);
386384
let fsUtility = new FsUtility({ basePath, indexFileName: 'index.json' });
387385
let indexer = fsUtility.indexFileContent;

packages/contentstack-audit/test/unit/mock/contents/content_types/schema.json

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
}
1616
],
1717
"description": "",
18-
"options": { "is_page": false, "singleton": false, "sub_title": [], "title": "title" }
18+
"options": { "is_page": false, "singleton": false, "sub_title": [], "title": "title" },
19+
"field_rules": [
20+
{
21+
"conditions": [{ "operand_field": "title", "operator": "equals", "value": "Test" }],
22+
"actions": [{ "action": "show", "target_field": "desc" }],
23+
"rule_type": "entry"
24+
}
25+
]
1926
},
2027
{
2128
"title": "Page 3",
@@ -33,7 +40,14 @@
3340
}
3441
],
3542
"description": "",
36-
"options": { "is_page": false, "singleton": false, "sub_title": [], "title": "title" }
43+
"options": { "is_page": false, "singleton": false, "sub_title": [], "title": "title" },
44+
"field_rules": [
45+
{
46+
"conditions": [{ "operand_field": "global.gf_text", "operator": "equals", "value": "Global" }],
47+
"actions": [{ "action": "hide", "target_field": "global.missing" }],
48+
"rule_type": "entry"
49+
}
50+
]
3751
},
3852
{
3953
"title": "Page 4",
@@ -51,7 +65,27 @@
5165
}
5266
],
5367
"description": "",
54-
"options": { "is_page": false, "singleton": false, "sub_title": [], "title": "title" }
68+
"options": { "is_page": false, "singleton": false, "sub_title": [], "title": "title" },
69+
"field_rules": [
70+
{
71+
"conditions": [{ "operand_field": "name", "operator": "equals", "value": "Test" }],
72+
"actions": [
73+
{ "action": "show", "target_field": "group.group_text" },
74+
{ "action": "hide", "target_field": "missing_field" }
75+
],
76+
"rule_type": "entry"
77+
},
78+
{
79+
"conditions": [{ "operand_field": "blocks.block_1.block_text", "operator": "equals", "value": "Block" }],
80+
"actions": [{ "action": "show", "target_field": "invalid_block_field" }],
81+
"rule_type": "entry"
82+
},
83+
{
84+
"conditions": [{ "operand_field": "invalid_condition", "operator": "equals", "value": "Test" }],
85+
"actions": [{ "action": "show", "target_field": "name" }],
86+
"rule_type": "entry"
87+
}
88+
]
5589
},
5690
{
5791
"title": "Page 1",
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"page_2": [
3+
{
4+
"action": {
5+
"action": "show",
6+
"target_field": "desc"
7+
},
8+
"ctUid": "page_2"
9+
},
10+
{
11+
"action": {
12+
"operand_field": "title",
13+
"operator": "equals",
14+
"value": "Test"
15+
},
16+
"ctUid": "page_2"
17+
}
18+
],
19+
"page_3": [
20+
{
21+
"action": {
22+
"action": "hide",
23+
"target_field": "global.missing"
24+
},
25+
"ctUid": "page_3"
26+
},
27+
{
28+
"action": {
29+
"operand_field": "global.gf_text",
30+
"operator": "equals",
31+
"value": "Global"
32+
},
33+
"ctUid": "page_3"
34+
}
35+
],
36+
"page_4": [
37+
{
38+
"action": {
39+
"action": "show",
40+
"target_field": "group.group_text"
41+
},
42+
"ctUid": "page_4"
43+
},
44+
{
45+
"action": {
46+
"action": "hide",
47+
"target_field": "missing_field"
48+
},
49+
"ctUid": "page_4"
50+
},
51+
{
52+
"action": {
53+
"operand_field": "name",
54+
"operator": "equals",
55+
"value": "Test"
56+
},
57+
"ctUid": "page_4"
58+
},
59+
{
60+
"action": {
61+
"action": "show",
62+
"target_field": "invalid_block_field"
63+
},
64+
"ctUid": "page_4"
65+
},
66+
{
67+
"action": {
68+
"operand_field": "blocks.block_1.block_text",
69+
"operator": "equals",
70+
"value": "Block"
71+
},
72+
"ctUid": "page_4"
73+
},
74+
{
75+
"action": {
76+
"action": "show",
77+
"target_field": "name"
78+
},
79+
"ctUid": "page_4"
80+
},
81+
{
82+
"action": {
83+
"operand_field": "invalid_condition",
84+
"operator": "equals",
85+
"value": "Test"
86+
},
87+
"ctUid": "page_4"
88+
}
89+
]
90+
}

0 commit comments

Comments
 (0)