Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
457 changes: 336 additions & 121 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions packages/contentstack-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-audit/1.8.0 darwin-arm64 node-v23.6.0
@contentstack/cli-audit/1.9.0 darwin-arm64 node-v23.6.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -269,7 +269,7 @@ EXAMPLES
$ csdx plugins
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/index.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/index.ts)_

## `csdx plugins:add PLUGIN`

Expand Down Expand Up @@ -343,7 +343,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/inspect.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/inspect.ts)_

## `csdx plugins:install PLUGIN`

Expand Down Expand Up @@ -392,7 +392,7 @@ EXAMPLES
$ csdx plugins:install someuser/someplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/install.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/install.ts)_

## `csdx plugins:link PATH`

Expand Down Expand Up @@ -423,7 +423,7 @@ EXAMPLES
$ csdx plugins:link myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/link.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/link.ts)_

## `csdx plugins:remove [PLUGIN]`

Expand Down Expand Up @@ -464,7 +464,7 @@ FLAGS
--reinstall Reinstall all plugins after uninstalling.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/reset.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/reset.ts)_

## `csdx plugins:uninstall [PLUGIN]`

Expand Down Expand Up @@ -492,7 +492,7 @@ EXAMPLES
$ csdx plugins:uninstall myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/uninstall.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/uninstall.ts)_

## `csdx plugins:unlink [PLUGIN]`

Expand Down Expand Up @@ -536,5 +536,5 @@ DESCRIPTION
Update installed plugins.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/update.ts)_
<!-- commandsstop -->
2 changes: 1 addition & 1 deletion packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "1.8.0",
"version": "1.9.0",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand Down
4 changes: 3 additions & 1 deletion packages/contentstack-audit/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const config = {
'entry_uid',
'publish_locale',
'publish_environment',
'asset_uid'
'asset_uid',
'selectedValue'
],
ReportTitleForEntries: {
Entries_Select_feild: 'Entries_Select_feild',
Expand All @@ -103,6 +104,7 @@ const config = {
Entry_Missing_Locale_and_Env_in_Publish_Details: 'Entry_Missing_Locale_and_Env_in_Publish_Details'
},
feild_level_modules: ['Entries_Title_feild', 'Entries_Mandatory_feild', 'Entries_Select_feild', 'Entry_Missing_Locale_and_Env_in_Publish_Details'],
fixSelectField: false
};

export default config;
15 changes: 13 additions & 2 deletions packages/contentstack-audit/src/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ export default class Entries {
field: ContentTypeStruct | GlobalFieldDataType | ModularBlockType | GroupFieldDataType,
entry: EntryFieldType,
) {

if (this.fix) {
entry = this.runFixOnSchema(tree, field.schema as ContentTypeSchemaType[], entry);
}
Expand Down Expand Up @@ -846,11 +847,14 @@ export default class Entries {
* @returns
*/
fixSelectField(tree: Record<string, unknown>[], field: SelectFeildStruct, entry: any) {
if(!this.config.fixSelectField) {
return entry;
}
const { enum: selectOptions, multiple, min_instance, display_type, display_name, uid } = field;

let missingCTSelectFieldValues;
let isMissingValuePresent = false;

let selectedValue: unknown = '';
if (multiple) {
let obj = this.findNotPresentSelectField(entry, selectOptions);
let { notPresent, filteredFeild } = obj;
Expand All @@ -868,13 +872,15 @@ export default class Entries {
.slice(0, missingInstances)
.map((choice) => choice.value);
entry.push(...newValues);
selectedValue = newValues;
this.log($t(auditFixMsg.ENTRY_SELECT_FIELD_FIX, { value: newValues.join(' '), uid }), 'error');
}
} else {
if (entry.length === 0) {
isMissingValuePresent = true;
const defaultValue = selectOptions.choices.length > 0 ? selectOptions.choices[0].value : null;
entry.push(defaultValue);
selectedValue = defaultValue;
this.log($t(auditFixMsg.ENTRY_SELECT_FIELD_FIX, { value: defaultValue as string, uid }), 'error');
}
}
Expand All @@ -885,6 +891,7 @@ export default class Entries {
isMissingValuePresent = true;
let defaultValue = selectOptions.choices.length > 0 ? selectOptions.choices[0].value : null;
entry = defaultValue;
selectedValue = defaultValue;
this.log($t(auditFixMsg.ENTRY_SELECT_FIELD_FIX, { value: defaultValue as string, uid }), 'error');
}
}
Expand All @@ -895,6 +902,7 @@ export default class Entries {
display_name,
display_type,
missingCTSelectFieldValues,
selectedValue,
min_instance: min_instance ?? 'NA',
tree,
treeStr: tree
Expand All @@ -909,7 +917,7 @@ export default class Entries {

validateMandatoryFields(tree: Record<string, unknown>[], fieldStructure: any, entry: any) {
const { display_name, multiple, data_type, mandatory, field_metadata, uid } = fieldStructure;

const isJsonRteEmpty = () => {
const jsonNode = multiple
? entry[uid]?.[0]?.children?.[0]?.children?.[0]?.text
Expand All @@ -922,6 +930,9 @@ export default class Entries {
if (data_type === 'number' && !multiple) {
fieldValue = entry[uid] || entry[uid] === 0 ? true : false;
}
if (data_type === 'text' && !multiple) {
fieldValue = entry[uid] || entry[uid] === 0 ? true : false;
}
if (Array.isArray(entry[uid]) && data_type === 'reference') {
fieldValue = entry[uid]?.length ? true : false;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/contentstack-audit/src/types/content-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ enum OutputColumn {
'entry_uid' = 'entry_uid',
'publish_locale' = 'publish_locale',
'publish_environment' = 'publish_environment',
'asset_uid' = 'asset_uid'
'asset_uid' = 'asset_uid',
'selectedValue' = 'selectedValue',
'fixStatus' = 'fixStatus'
}

export {
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-audit": "~1.8.0",
"@contentstack/cli-audit": "~1.9.0",
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-utilities": "~1.8.4",
"@contentstack/management": "~1.18.4",
Expand Down
40 changes: 22 additions & 18 deletions packages/contentstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli/1.36.0 darwin-x64 node-v22.14.0
@contentstack/cli/1.36.0 darwin-arm64 node-v23.6.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -129,12 +129,12 @@ Perform audits and find possible errors in the exported Contentstack data
```
USAGE
$ csdx audit [--report-path <value>] [--modules
content-types|global-fields|entries|extensions|workflows|custom-roles...] [--columns <value> | ] [--sort <value>]
[--filter <value>] [--csv | --no-truncate]
content-types|global-fields|entries|extensions|workflows|custom-roles|assets...] [--columns <value> | ] [--sort
<value>] [--filter <value>] [--csv | --no-truncate]

FLAGS
--modules=<option>... Provide the list of modules to be audited
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
--report-path=<value> Path to store the audit reports

TABLE FLAGS
Expand Down Expand Up @@ -170,7 +170,7 @@ Perform audits and fix possible errors in the exported Contentstack data.
```
USAGE
$ csdx audit:fix [--report-path <value>] [--modules
content-types|global-fields|entries|extensions|workflows|custom-roles...] [--copy-path <value> --copy-dir]
content-types|global-fields|entries|extensions|workflows|custom-roles|assets...] [--copy-path <value> --copy-dir]
[--fix-only reference|global_field|json:rte|json:extension|blocks|group|content_types...] [--columns <value> | ]
[--sort <value>] [--filter <value>] [--csv | --no-truncate]

Expand All @@ -180,7 +180,7 @@ FLAGS
--fix-only=<option>... Provide the list of fix options
<options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
--modules=<option>... Provide the list of modules to be audited
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
--report-path=<value> Path to store the audit reports

TABLE FLAGS
Expand Down Expand Up @@ -2346,7 +2346,9 @@ FLAGS
--personalize-project-name=<value> (optional) Provide a unique name for the Personalize project.
--replace-existing Replaces the existing module in the target stack.
--skip-app-recreation (optional) Skips the recreation of private apps if they already exist.
--skip-assets-publish Skips asset publishing during the import process.
--skip-audit Skips the audit fix that occurs during an import operation.
--skip-entries-publish Skips entry publishing during the import process
--skip-existing Skips the module exists warning messages.

DESCRIPTION
Expand Down Expand Up @@ -2608,12 +2610,12 @@ Perform audits and find possible errors in the exported Contentstack data
```
USAGE
$ csdx cm:stacks:audit [--report-path <value>] [--modules
content-types|global-fields|entries|extensions|workflows|custom-roles...] [--columns <value> | ] [--sort <value>]
[--filter <value>] [--csv | --no-truncate]
content-types|global-fields|entries|extensions|workflows|custom-roles|assets...] [--columns <value> | ] [--sort
<value>] [--filter <value>] [--csv | --no-truncate]

FLAGS
--modules=<option>... Provide the list of modules to be audited
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
--report-path=<value> Path to store the audit reports

TABLE FLAGS
Expand Down Expand Up @@ -2651,7 +2653,7 @@ Perform audits and fix possible errors in the exported Contentstack data.
```
USAGE
$ csdx cm:stacks:audit:fix [--report-path <value>] [--modules
content-types|global-fields|entries|extensions|workflows|custom-roles...] [--copy-path <value> --copy-dir]
content-types|global-fields|entries|extensions|workflows|custom-roles|assets...] [--copy-path <value> --copy-dir]
[--fix-only reference|global_field|json:rte|json:extension|blocks|group|content_types...] [--columns <value> | ]
[--sort <value>] [--filter <value>] [--csv | --no-truncate]

Expand All @@ -2661,7 +2663,7 @@ FLAGS
--fix-only=<option>... Provide the list of fix options
<options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
--modules=<option>... Provide the list of modules to be audited
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
--report-path=<value> Path to store the audit reports

TABLE FLAGS
Expand Down Expand Up @@ -2837,7 +2839,9 @@ FLAGS
--personalize-project-name=<value> (optional) Provide a unique name for the Personalize project.
--replace-existing Replaces the existing module in the target stack.
--skip-app-recreation (optional) Skips the recreation of private apps if they already exist.
--skip-assets-publish Skips asset publishing during the import process.
--skip-audit Skips the audit fix that occurs during an import operation.
--skip-entries-publish Skips entry publishing during the import process
--skip-existing Skips the module exists warning messages.

DESCRIPTION
Expand Down Expand Up @@ -3899,7 +3903,7 @@ EXAMPLES
$ csdx plugins
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/index.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/index.ts)_

## `csdx plugins:add PLUGIN`

Expand Down Expand Up @@ -3973,7 +3977,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/inspect.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/inspect.ts)_

## `csdx plugins:install PLUGIN`

Expand Down Expand Up @@ -4022,7 +4026,7 @@ EXAMPLES
$ csdx plugins:install someuser/someplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/install.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/install.ts)_

## `csdx plugins:link PATH`

Expand Down Expand Up @@ -4053,7 +4057,7 @@ EXAMPLES
$ csdx plugins:link myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/link.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/link.ts)_

## `csdx plugins:remove [PLUGIN]`

Expand Down Expand Up @@ -4094,7 +4098,7 @@ FLAGS
--reinstall Reinstall all plugins after uninstalling.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/reset.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/reset.ts)_

## `csdx plugins:uninstall [PLUGIN]`

Expand Down Expand Up @@ -4122,7 +4126,7 @@ EXAMPLES
$ csdx plugins:uninstall myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/uninstall.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/uninstall.ts)_

## `csdx plugins:unlink [PLUGIN]`

Expand Down Expand Up @@ -4166,7 +4170,7 @@ DESCRIPTION
Update installed plugins.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/update.ts)_

## `csdx tokens`

Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"prepack": "pnpm compile && oclif manifest && oclif readme"
},
"dependencies": {
"@contentstack/cli-audit": "~1.8.0",
"@contentstack/cli-audit": "~1.9.0",
"@contentstack/cli-auth": "~1.3.24",
"@contentstack/cli-cm-bootstrap": "~1.13.2",
"@contentstack/cli-cm-branches": "~1.3.0",
Expand Down
Loading
Loading