@contentstack/cli-cm-import 1.32.0-beta.0 → 1.32.0-beta.1
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
CHANGED
|
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
|
|
|
47
47
|
$ csdx COMMAND
|
|
48
48
|
running command...
|
|
49
49
|
$ csdx (--version)
|
|
50
|
-
@contentstack/cli-cm-import/1.32.0-beta.
|
|
50
|
+
@contentstack/cli-cm-import/1.32.0-beta.1 linux-x64 node-v22.22.1
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -6,6 +6,7 @@ export default class ImportCustomRoles extends BaseClass {
|
|
|
6
6
|
private customRolesUidMapperPath;
|
|
7
7
|
private envUidMapperFolderPath;
|
|
8
8
|
private entriesUidMapperFolderPath;
|
|
9
|
+
private assetsUidMapperFolderPath;
|
|
9
10
|
private createdCustomRolesPath;
|
|
10
11
|
private customRolesFailsPath;
|
|
11
12
|
private customRolesConfig;
|
|
@@ -17,6 +18,8 @@ export default class ImportCustomRoles extends BaseClass {
|
|
|
17
18
|
private environmentsUidMap;
|
|
18
19
|
private entriesUidMap;
|
|
19
20
|
private localesUidMap;
|
|
21
|
+
private assetsUidMap;
|
|
22
|
+
private assetsFolderUidMap;
|
|
20
23
|
targetLocalesMap: Record<string, unknown>;
|
|
21
24
|
sourceLocalesMap: Record<string, unknown>;
|
|
22
25
|
constructor({ importConfig, stackAPIClient }: ModuleClassParams);
|
|
@@ -12,7 +12,7 @@ class ImportCustomRoles extends base_class_1.default {
|
|
|
12
12
|
constructor({ importConfig, stackAPIClient }) {
|
|
13
13
|
super({ importConfig, stackAPIClient });
|
|
14
14
|
this.getTransformUidsFactory = (rule) => {
|
|
15
|
-
var _a, _b, _c;
|
|
15
|
+
var _a, _b, _c, _d, _e;
|
|
16
16
|
cli_utilities_1.log.debug(`Transforming UIDs for rule module: ${rule.module}`, this.importConfig.context);
|
|
17
17
|
if (rule.module === 'environment') {
|
|
18
18
|
if (!(0, isEmpty_1.default)(this.environmentsUidMap)) {
|
|
@@ -44,6 +44,27 @@ class ImportCustomRoles extends base_class_1.default {
|
|
|
44
44
|
cli_utilities_1.log.debug('No entry UID mappings available for transformation.', this.importConfig.context);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
else if (rule.module === 'asset') {
|
|
48
|
+
if (!(0, isEmpty_1.default)(this.assetsUidMap)) {
|
|
49
|
+
const originalAssets = ((_d = rule.assets) === null || _d === void 0 ? void 0 : _d.length) || 0;
|
|
50
|
+
rule.assets = (0, lodash_1.map)(rule.assets, (uid) => { var _a; return (_a = this.assetsUidMap[uid]) !== null && _a !== void 0 ? _a : uid; });
|
|
51
|
+
cli_utilities_1.log.debug(`Transformed ${originalAssets} asset UIDs for rule`, this.importConfig.context);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
cli_utilities_1.log.debug('No asset UID mappings available for transformation.', this.importConfig.context);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (rule.module === 'folder') {
|
|
58
|
+
if (!(0, isEmpty_1.default)(this.assetsFolderUidMap)) {
|
|
59
|
+
const originalFolders = ((_e = rule.folders) === null || _e === void 0 ? void 0 : _e.length) || 0;
|
|
60
|
+
rule.folders = (0, lodash_1.map)(rule.folders, (uid) => { var _a; return (_a = this.assetsFolderUidMap[uid]) !== null && _a !== void 0 ? _a : uid; });
|
|
61
|
+
rule.heirarchy = (0, lodash_1.map)(rule.heirarchy, (uid) => { var _a; return (_a = this.assetsFolderUidMap[uid]) !== null && _a !== void 0 ? _a : uid; });
|
|
62
|
+
cli_utilities_1.log.debug(`Transformed ${originalFolders} folder UIDs for rule`, this.importConfig.context);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
cli_utilities_1.log.debug('No asset folder UID mappings available for transformation.', this.importConfig.context);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
47
68
|
return rule;
|
|
48
69
|
};
|
|
49
70
|
this.importConfig.context.module = 'custom-roles';
|
|
@@ -53,6 +74,7 @@ class ImportCustomRoles extends base_class_1.default {
|
|
|
53
74
|
this.customRolesUidMapperPath = (0, node_path_1.join)(this.customRolesMapperPath, 'uid-mapping.json');
|
|
54
75
|
this.envUidMapperFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', 'environments');
|
|
55
76
|
this.entriesUidMapperFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', 'entries');
|
|
77
|
+
this.assetsUidMapperFolderPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', 'assets');
|
|
56
78
|
this.createdCustomRolesPath = (0, node_path_1.join)(this.customRolesMapperPath, 'success.json');
|
|
57
79
|
this.customRolesFailsPath = (0, node_path_1.join)(this.customRolesMapperPath, 'fails.json');
|
|
58
80
|
this.customRoles = {};
|
|
@@ -63,6 +85,8 @@ class ImportCustomRoles extends base_class_1.default {
|
|
|
63
85
|
this.environmentsUidMap = {};
|
|
64
86
|
this.entriesUidMap = {};
|
|
65
87
|
this.localesUidMap = {};
|
|
88
|
+
this.assetsUidMap = {};
|
|
89
|
+
this.assetsFolderUidMap = {};
|
|
66
90
|
}
|
|
67
91
|
/**
|
|
68
92
|
* @method start
|
|
@@ -96,6 +120,14 @@ class ImportCustomRoles extends base_class_1.default {
|
|
|
96
120
|
this.entriesUidMap = utils_1.fileHelper.fileExistsSync(this.entriesUidMapperFolderPath)
|
|
97
121
|
? utils_1.fsUtil.readFile((0, node_path_1.join)(this.entriesUidMapperFolderPath, 'uid-mapping.json'), true) || {}
|
|
98
122
|
: {};
|
|
123
|
+
cli_utilities_1.log.debug('Loading assets UID data...', this.importConfig.context);
|
|
124
|
+
this.assetsUidMap = utils_1.fileHelper.fileExistsSync(this.assetsUidMapperFolderPath)
|
|
125
|
+
? utils_1.fsUtil.readFile((0, node_path_1.join)(this.assetsUidMapperFolderPath, 'uid-mapping.json'), true) || {}
|
|
126
|
+
: {};
|
|
127
|
+
cli_utilities_1.log.debug('Loading asset folders UID data...', this.importConfig.context);
|
|
128
|
+
this.assetsFolderUidMap = utils_1.fileHelper.fileExistsSync(this.assetsUidMapperFolderPath)
|
|
129
|
+
? utils_1.fsUtil.readFile((0, node_path_1.join)(this.assetsUidMapperFolderPath, 'folder-mapping.json'), true) || {}
|
|
130
|
+
: {};
|
|
99
131
|
if (this.customRolesUidMapper && Object.keys(this.customRolesUidMapper || {}).length > 0) {
|
|
100
132
|
const customRolesUidCount = Object.keys(this.customRolesUidMapper || {}).length;
|
|
101
133
|
cli_utilities_1.log.debug(`Loaded existing custom roles UID data: ${customRolesUidCount} items`, this.importConfig.context);
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-import",
|
|
3
3
|
"description": "Contentstack CLI plugin to import content into stack",
|
|
4
|
-
"version": "1.32.0-beta.
|
|
4
|
+
"version": "1.32.0-beta.1",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-audit": "~1.19.0-beta.
|
|
9
|
-
"@contentstack/cli-command": "~1.8.0-beta.
|
|
10
|
-
"@contentstack/cli-utilities": "~1.
|
|
11
|
-
"@contentstack/cli-variants": "~1.4.0-beta.
|
|
8
|
+
"@contentstack/cli-audit": "~1.19.0-beta.1",
|
|
9
|
+
"@contentstack/cli-command": "~1.8.0-beta.1",
|
|
10
|
+
"@contentstack/cli-utilities": "~1.19.0-beta.0",
|
|
11
|
+
"@contentstack/cli-variants": "~1.4.0-beta.1",
|
|
12
12
|
"@oclif/core": "^4.3.0",
|
|
13
13
|
"big-json": "^3.2.0",
|
|
14
14
|
"bluebird": "^3.7.2",
|
|
@@ -94,4 +94,4 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"repository": "https://github.com/contentstack/cli"
|
|
97
|
-
}
|
|
97
|
+
}
|