@contentstack/cli-cm-import 1.30.2 → 1.31.0
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 +1 -1
- package/lib/config/index.js +1 -1
- package/lib/import/modules/composable-studio.d.ts +1 -0
- package/lib/import/modules/composable-studio.js +7 -0
- package/lib/import/modules/content-types.d.ts +2 -0
- package/lib/import/modules/content-types.js +31 -0
- package/lib/import/modules/entries.d.ts +2 -0
- package/lib/import/modules/entries.js +31 -0
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
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.
|
|
50
|
+
@contentstack/cli-cm-import/1.31.0 linux-x64 node-v22.21.1
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
package/lib/config/index.js
CHANGED
|
@@ -33,6 +33,7 @@ const config = {
|
|
|
33
33
|
'stack',
|
|
34
34
|
'assets',
|
|
35
35
|
'taxonomies',
|
|
36
|
+
'composable-studio',
|
|
36
37
|
'extensions',
|
|
37
38
|
'marketplace-apps',
|
|
38
39
|
'global-fields',
|
|
@@ -44,7 +45,6 @@ const config = {
|
|
|
44
45
|
'variant-entries',
|
|
45
46
|
'labels',
|
|
46
47
|
'webhooks',
|
|
47
|
-
'composable-studio',
|
|
48
48
|
],
|
|
49
49
|
locales: {
|
|
50
50
|
dirName: 'locales',
|
|
@@ -12,6 +12,7 @@ class ImportComposableStudio {
|
|
|
12
12
|
this.composableStudioConfig = importConfig.modules['composable-studio'];
|
|
13
13
|
// Setup paths
|
|
14
14
|
this.composableStudioPath = (0, node_path_1.join)(this.importConfig.backupDir, this.composableStudioConfig.dirName);
|
|
15
|
+
this.projectMapperPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', this.composableStudioConfig.dirName);
|
|
15
16
|
this.composableStudioFilePath = (0, node_path_1.join)(this.composableStudioPath, this.composableStudioConfig.fileName);
|
|
16
17
|
this.envUidMapperPath = (0, node_path_1.join)(this.importConfig.backupDir, 'mapper', 'environments', 'uid-mapping.json');
|
|
17
18
|
this.envUidMapper = {};
|
|
@@ -179,6 +180,12 @@ class ImportComposableStudio {
|
|
|
179
180
|
if (response.status >= 200 && response.status < 300) {
|
|
180
181
|
projectCreated = true;
|
|
181
182
|
cli_utilities_1.log.debug(`Project created successfully with UID: ${(_c = response.data) === null || _c === void 0 ? void 0 : _c.uid}`, this.importConfig.context);
|
|
183
|
+
// Create mapper directory if it doesn't exist
|
|
184
|
+
await utils_1.fsUtil.makeDirectory(this.projectMapperPath);
|
|
185
|
+
// write the project to file
|
|
186
|
+
const projectFileSuccessPath = (0, node_path_1.join)(this.projectMapperPath, this.composableStudioConfig.fileName);
|
|
187
|
+
utils_1.fsUtil.writeFile(projectFileSuccessPath, response.data);
|
|
188
|
+
cli_utilities_1.log.debug(`Project written to: ${projectFileSuccessPath}`, this.importConfig.context);
|
|
182
189
|
}
|
|
183
190
|
else {
|
|
184
191
|
throw new Error(`API call failed with status ${response.status}: ${JSON.stringify(response.data)}`);
|
|
@@ -34,6 +34,8 @@ export default class ContentTypesImport extends BaseClass {
|
|
|
34
34
|
taxonomies: Record<string, unknown>;
|
|
35
35
|
private extPendingPath;
|
|
36
36
|
private isExtensionsUpdate;
|
|
37
|
+
private composableStudioSuccessPath;
|
|
38
|
+
private composableStudioExportPath;
|
|
37
39
|
constructor({ importConfig, stackAPIClient }: ModuleClassParams);
|
|
38
40
|
start(): Promise<any>;
|
|
39
41
|
seedCTs(): Promise<any>;
|
|
@@ -34,6 +34,15 @@ class ContentTypesImport extends base_class_1.default {
|
|
|
34
34
|
['schema.json', 'true'],
|
|
35
35
|
['.DS_Store', 'true'],
|
|
36
36
|
]);
|
|
37
|
+
// Initialize composable studio paths if config exists
|
|
38
|
+
if (this.importConfig.modules['composable-studio']) {
|
|
39
|
+
this.composableStudioSuccessPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.data), 'mapper', this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
|
|
40
|
+
this.composableStudioExportPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.data), this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.composableStudioSuccessPath = '';
|
|
44
|
+
this.composableStudioExportPath = '';
|
|
45
|
+
}
|
|
37
46
|
this.cTs = [];
|
|
38
47
|
this.createdCTs = [];
|
|
39
48
|
this.titleToUIdMap = new Map();
|
|
@@ -59,6 +68,28 @@ class ContentTypesImport extends base_class_1.default {
|
|
|
59
68
|
return;
|
|
60
69
|
}
|
|
61
70
|
cli_utilities_1.log.debug(`Found ${this.cTs.length} content types to import`, this.importConfig.context);
|
|
71
|
+
// If success file doesn't exist but export file does, skip the composition content type
|
|
72
|
+
// Only check if composable studio paths are configured
|
|
73
|
+
if (this.composableStudioSuccessPath &&
|
|
74
|
+
this.composableStudioExportPath &&
|
|
75
|
+
!utils_1.fileHelper.fileExistsSync(this.composableStudioSuccessPath) &&
|
|
76
|
+
utils_1.fileHelper.fileExistsSync(this.composableStudioExportPath)) {
|
|
77
|
+
const exportedProject = utils_1.fileHelper.readFileSync(this.composableStudioExportPath);
|
|
78
|
+
if (exportedProject === null || exportedProject === void 0 ? void 0 : exportedProject.contentTypeUid) {
|
|
79
|
+
const originalCount = this.cTs.length;
|
|
80
|
+
this.cTs = this.cTs.filter((ct) => {
|
|
81
|
+
const shouldSkip = ct.uid === exportedProject.contentTypeUid;
|
|
82
|
+
if (shouldSkip) {
|
|
83
|
+
cli_utilities_1.log.info(`Skipping content type '${ct.uid}' as Composable Studio project was not created successfully`, this.importConfig.context);
|
|
84
|
+
}
|
|
85
|
+
return !shouldSkip;
|
|
86
|
+
});
|
|
87
|
+
const skippedCount = originalCount - this.cTs.length;
|
|
88
|
+
if (skippedCount > 0) {
|
|
89
|
+
cli_utilities_1.log.debug(`Filtered out ${skippedCount} composition content type(s) from import`, this.importConfig.context);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
62
93
|
await utils_1.fsUtil.makeDirectory(this.cTsMapperPath);
|
|
63
94
|
cli_utilities_1.log.debug('Created content types mapper directory.', this.importConfig.context);
|
|
64
95
|
this.installedExtensions = (utils_1.fsUtil.readFile(this.marketplaceAppMapperPath) || { extension_uid: {} }).extension_uid;
|
|
@@ -38,6 +38,8 @@ export default class EntriesImport extends BaseClass {
|
|
|
38
38
|
locale: string;
|
|
39
39
|
entry_uid: string;
|
|
40
40
|
}>;
|
|
41
|
+
private composableStudioSuccessPath;
|
|
42
|
+
private composableStudioExportPath;
|
|
41
43
|
constructor({ importConfig, stackAPIClient }: ModuleClassParams);
|
|
42
44
|
start(): Promise<any>;
|
|
43
45
|
/**
|
|
@@ -31,6 +31,15 @@ class EntriesImport extends base_class_1.default {
|
|
|
31
31
|
this.entriesPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.data), (0, cli_utilities_1.sanitizePath)(this.entriesConfig.dirName));
|
|
32
32
|
this.cTsPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.data), (0, cli_utilities_1.sanitizePath)(importConfig.modules['content-types'].dirName));
|
|
33
33
|
this.localesPath = path.resolve((0, cli_utilities_1.sanitizePath)(importConfig.data), (0, cli_utilities_1.sanitizePath)(importConfig.modules.locales.dirName), (0, cli_utilities_1.sanitizePath)(importConfig.modules.locales.fileName));
|
|
34
|
+
// Initialize composable studio paths if config exists
|
|
35
|
+
if (this.importConfig.modules['composable-studio']) {
|
|
36
|
+
this.composableStudioSuccessPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.data), 'mapper', this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
|
|
37
|
+
this.composableStudioExportPath = path.join((0, cli_utilities_1.sanitizePath)(this.importConfig.data), this.importConfig.modules['composable-studio'].dirName, this.importConfig.modules['composable-studio'].fileName);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.composableStudioSuccessPath = '';
|
|
41
|
+
this.composableStudioExportPath = '';
|
|
42
|
+
}
|
|
34
43
|
this.importConcurrency = this.entriesConfig.importConcurrency || importConfig.importConcurrency;
|
|
35
44
|
this.entriesUidMapper = {};
|
|
36
45
|
this.modifiedCTs = [];
|
|
@@ -52,6 +61,28 @@ class EntriesImport extends base_class_1.default {
|
|
|
52
61
|
return;
|
|
53
62
|
}
|
|
54
63
|
cli_utilities_1.log.debug(`Found ${this.cTs.length} content types for entry import`, this.importConfig.context);
|
|
64
|
+
// If success file doesn't exist but export file does, skip the composition entries
|
|
65
|
+
// Only check if composable studio paths are configured
|
|
66
|
+
if (this.composableStudioSuccessPath &&
|
|
67
|
+
this.composableStudioExportPath &&
|
|
68
|
+
!utils_1.fileHelper.fileExistsSync(this.composableStudioSuccessPath) &&
|
|
69
|
+
utils_1.fileHelper.fileExistsSync(this.composableStudioExportPath)) {
|
|
70
|
+
const exportedProject = utils_1.fileHelper.readFileSync(this.composableStudioExportPath);
|
|
71
|
+
if (exportedProject === null || exportedProject === void 0 ? void 0 : exportedProject.contentTypeUid) {
|
|
72
|
+
const originalCount = this.cTs.length;
|
|
73
|
+
this.cTs = this.cTs.filter((ct) => {
|
|
74
|
+
const shouldSkip = ct.uid === exportedProject.contentTypeUid;
|
|
75
|
+
if (shouldSkip) {
|
|
76
|
+
cli_utilities_1.log.info(`Skipping entries for content type '${ct.uid}' as Composable Studio project was not created successfully`, this.importConfig.context);
|
|
77
|
+
}
|
|
78
|
+
return !shouldSkip;
|
|
79
|
+
});
|
|
80
|
+
const skippedCount = originalCount - this.cTs.length;
|
|
81
|
+
if (skippedCount > 0) {
|
|
82
|
+
cli_utilities_1.log.debug(`Filtered out ${skippedCount} composition content type(s) from entry import`, this.importConfig.context);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
55
86
|
this.installedExtensions = (utils_1.fsUtil.readFile(this.marketplaceAppMapperPath) || { extension_uid: {} }).extension_uid;
|
|
56
87
|
cli_utilities_1.log.debug('Loaded installed extensions for entry processing.', this.importConfig.context);
|
|
57
88
|
this.assetUidMapper = utils_1.fsUtil.readFile(this.assetUidMapperPath) || {};
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-import",
|
|
3
3
|
"description": "Contentstack CLI plugin to import content into stack",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.31.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-audit": "~1.
|
|
8
|
+
"@contentstack/cli-audit": "~1.17.0",
|
|
9
9
|
"@contentstack/cli-command": "~1.7.1",
|
|
10
10
|
"@contentstack/cli-utilities": "~1.16.0",
|
|
11
11
|
"@contentstack/management": "~1.22.0",
|