@contentstack/cli-cm-import 2.0.0-beta.2 → 2.0.0-beta.4
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/LICENSE +1 -1
- package/README.md +50 -96
- package/lib/commands/cm/stacks/import.d.ts +0 -1
- package/lib/commands/cm/stacks/import.js +9 -42
- package/lib/config/index.js +7 -0
- package/lib/import/module-importer.js +0 -4
- package/lib/import/modules/composable-studio.d.ts +44 -0
- package/lib/import/modules/composable-studio.js +234 -0
- package/lib/import/modules/content-types.d.ts +2 -0
- package/lib/import/modules/content-types.js +48 -9
- package/lib/import/modules/entries.d.ts +2 -0
- package/lib/import/modules/entries.js +19 -10
- package/lib/import/modules/global-fields.d.ts +1 -1
- package/lib/import/modules/global-fields.js +8 -8
- package/lib/import/modules/locales.d.ts +1 -1
- package/lib/import/modules/locales.js +6 -6
- package/lib/import/modules/marketplace-apps.js +2 -2
- package/lib/import/modules/personalize.js +1 -1
- package/lib/import/modules/stack.js +1 -1
- package/lib/import/modules/variant-entries.js +2 -2
- package/lib/import/modules/workflows.js +1 -1
- package/lib/types/default-config.d.ts +6 -0
- package/lib/types/import-config.d.ts +0 -1
- package/lib/types/index.d.ts +37 -11
- package/lib/utils/asset-helper.js +1 -1
- package/lib/utils/common-helper.d.ts +1 -1
- package/lib/utils/common-helper.js +6 -6
- package/lib/utils/content-type-helper.d.ts +1 -1
- package/lib/utils/content-type-helper.js +3 -3
- package/lib/utils/extension-helper.js +1 -1
- package/lib/utils/file-helper.js +1 -1
- package/lib/utils/import-config-handler.js +7 -11
- package/lib/utils/import-path-resolver.js +2 -8
- package/lib/utils/logger.d.ts +1 -1
- package/lib/utils/logger.js +2 -2
- package/lib/utils/login-handler.d.ts +1 -1
- package/lib/utils/login-handler.js +4 -4
- package/lib/utils/marketplace-app-helper.js +9 -6
- package/lib/utils/taxonomies-helper.js +1 -1
- package/messages/index.json +10 -1
- package/oclif.manifest.json +4 -48
- package/package.json +9 -13
|
@@ -63,7 +63,7 @@ exports.selectBranchFromDirectory = selectBranchFromDirectory;
|
|
|
63
63
|
*/
|
|
64
64
|
const resolveImportPath = async (importConfig, stackAPIClient) => {
|
|
65
65
|
cli_utilities_1.log.debug('Resolving import path based on directory structure');
|
|
66
|
-
const contentDir = importConfig.contentDir
|
|
66
|
+
const contentDir = importConfig.contentDir;
|
|
67
67
|
cli_utilities_1.log.debug(`Content directory: ${contentDir}`);
|
|
68
68
|
if (!(0, file_helper_1.fileExistsSync)(contentDir)) {
|
|
69
69
|
throw new Error(`Content directory does not exist: ${contentDir}`);
|
|
@@ -83,11 +83,6 @@ const resolveImportPath = async (importConfig, stackAPIClient) => {
|
|
|
83
83
|
cli_utilities_1.log.debug(`Branch directory not found: ${branchPath}, using contentDir as-is`);
|
|
84
84
|
return contentDir;
|
|
85
85
|
}
|
|
86
|
-
const exportInfoPath = path.join(contentDir, 'export-info.json');
|
|
87
|
-
if ((0, file_helper_1.fileExistsSync)(exportInfoPath)) {
|
|
88
|
-
cli_utilities_1.log.debug('Found export-info.json - using contentDir as-is (v2 export)');
|
|
89
|
-
return contentDir;
|
|
90
|
-
}
|
|
91
86
|
const moduleTypes = config_1.default.modules.types;
|
|
92
87
|
const hasModuleFolders = moduleTypes.some((moduleType) => (0, file_helper_1.fileExistsSync)(path.join(contentDir, moduleType)));
|
|
93
88
|
if (hasModuleFolders) {
|
|
@@ -115,8 +110,7 @@ const updateImportConfigWithResolvedPath = async (importConfig, resolvedPath) =>
|
|
|
115
110
|
}
|
|
116
111
|
importConfig.branchDir = resolvedPath;
|
|
117
112
|
importConfig.contentDir = resolvedPath;
|
|
118
|
-
importConfig.
|
|
119
|
-
cli_utilities_1.log.debug(`Import config updated - contentDir: ${importConfig.contentDir}, branchDir: ${importConfig.branchDir}, data: ${importConfig.data},`);
|
|
113
|
+
cli_utilities_1.log.debug(`Import config updated - contentDir: ${importConfig.contentDir}, branchDir: ${importConfig.branchDir}`);
|
|
120
114
|
};
|
|
121
115
|
exports.updateImportConfigWithResolvedPath = updateImportConfigWithResolvedPath;
|
|
122
116
|
/**
|
package/lib/utils/logger.d.ts
CHANGED
package/lib/utils/logger.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*!
|
|
3
3
|
* Contentstack Export
|
|
4
|
-
* Copyright (c)
|
|
4
|
+
* Copyright (c) 2026 Contentstack LLC
|
|
5
5
|
* MIT Licensed
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -125,7 +125,7 @@ function init(_logPath) {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
const log = async (config, message, type) => {
|
|
128
|
-
config.cliLogsPath = (0, cli_utilities_1.sanitizePath)(config.cliLogsPath || config.
|
|
128
|
+
config.cliLogsPath = (0, cli_utilities_1.sanitizePath)(config.cliLogsPath || config.contentDir || path.join(__dirname, 'logs'));
|
|
129
129
|
// ignoring the type argument, as we are not using it to create a logfile anymore
|
|
130
130
|
if (type !== 'error') {
|
|
131
131
|
// removed type argument from init method
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/* eslint-disable no-empty */
|
|
5
5
|
/*!
|
|
6
6
|
* Contentstack Import
|
|
7
|
-
* Copyright (c)
|
|
7
|
+
* Copyright (c) 2026 Contentstack LLC
|
|
8
8
|
* MIT Licensed
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -18,7 +18,7 @@ const login = async (config) => {
|
|
|
18
18
|
if (authtoken) {
|
|
19
19
|
cli_utilities_1.log.debug('Login successful, setting up headers');
|
|
20
20
|
config.headers = {
|
|
21
|
-
api_key: config.
|
|
21
|
+
api_key: config.apiKey,
|
|
22
22
|
access_token: config.access_token,
|
|
23
23
|
authtoken: config.authtoken,
|
|
24
24
|
'X-User-Agent': 'contentstack-export/v',
|
|
@@ -36,7 +36,7 @@ const login = async (config) => {
|
|
|
36
36
|
else if ((0, cli_utilities_1.isAuthenticated)()) {
|
|
37
37
|
cli_utilities_1.log.debug('Using existing authentication, validating stack access');
|
|
38
38
|
const stackAPIClient = client.stack({
|
|
39
|
-
api_key: config.
|
|
39
|
+
api_key: config.apiKey,
|
|
40
40
|
management_token: config.management_token,
|
|
41
41
|
});
|
|
42
42
|
const stack = await stackAPIClient.fetch().catch((error) => {
|
|
@@ -44,7 +44,7 @@ const login = async (config) => {
|
|
|
44
44
|
let errorstack_key = (_a = error === null || error === void 0 ? void 0 : error.errors) === null || _a === void 0 ? void 0 : _a.api_key;
|
|
45
45
|
if (errorstack_key) {
|
|
46
46
|
const keyError = errorstack_key[0];
|
|
47
|
-
cli_utilities_1.log.error(`Invalid stack API token: ${keyError} Please enter valid stack API token.`);
|
|
47
|
+
cli_utilities_1.log.error(`Invalid stack API token: ${keyError}. Please enter a valid stack API token.`);
|
|
48
48
|
throw error;
|
|
49
49
|
}
|
|
50
50
|
cli_utilities_1.log.error(`Stack fetch error: ${error === null || error === void 0 ? void 0 : error.errorMessage}`);
|
|
@@ -18,9 +18,10 @@ const getAllStackSpecificApps = async (config, skip = 0, listOfApps = []) => {
|
|
|
18
18
|
const collection = await appSdk
|
|
19
19
|
.marketplace(config.org_uid)
|
|
20
20
|
.installation()
|
|
21
|
-
.fetchAll({ target_uids: config.
|
|
21
|
+
.fetchAll({ target_uids: config.apiKey, skip })
|
|
22
22
|
.catch((error) => {
|
|
23
23
|
(0, cli_utilities_1.handleAndLogError)(error);
|
|
24
|
+
cli_utilities_1.log.error(error, config === null || config === void 0 ? void 0 : config.context);
|
|
24
25
|
});
|
|
25
26
|
if (collection) {
|
|
26
27
|
const { items: apps, count } = collection;
|
|
@@ -53,10 +54,11 @@ const getOrgUid = async (config) => {
|
|
|
53
54
|
cli_utilities_1.log.debug('Fetching organization UID');
|
|
54
55
|
const tempAPIClient = await (0, cli_utilities_1.managementSDKClient)({ host: config.host });
|
|
55
56
|
const tempStackData = await tempAPIClient
|
|
56
|
-
.stack({ api_key: config.
|
|
57
|
+
.stack({ api_key: config.apiKey })
|
|
57
58
|
.fetch()
|
|
58
59
|
.catch((error) => {
|
|
59
|
-
|
|
60
|
+
(0, cli_utilities_1.handleAndLogError)(error);
|
|
61
|
+
cli_utilities_1.log.error(error, config === null || config === void 0 ? void 0 : config.context);
|
|
60
62
|
});
|
|
61
63
|
const orgUid = (tempStackData === null || tempStackData === void 0 ? void 0 : tempStackData.org_uid) || '';
|
|
62
64
|
cli_utilities_1.log.debug(`Organization UID: ${orgUid}`);
|
|
@@ -78,7 +80,7 @@ const getConfirmationToCreateApps = async (privateApps, config) => {
|
|
|
78
80
|
return Promise.resolve(true);
|
|
79
81
|
}
|
|
80
82
|
else {
|
|
81
|
-
cli_utilities_1.log.
|
|
83
|
+
cli_utilities_1.log.debug('User declined to create private apps (second prompt).');
|
|
82
84
|
return Promise.resolve(false);
|
|
83
85
|
}
|
|
84
86
|
}
|
|
@@ -89,7 +91,7 @@ const getConfirmationToCreateApps = async (privateApps, config) => {
|
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
else {
|
|
92
|
-
cli_utilities_1.log.
|
|
94
|
+
cli_utilities_1.log.debug('Force prompt disabled, automatically creating private apps');
|
|
93
95
|
return Promise.resolve(true);
|
|
94
96
|
}
|
|
95
97
|
};
|
|
@@ -111,7 +113,7 @@ const makeRedirectUrlCall = async (response, appName, config) => {
|
|
|
111
113
|
.get(response.redirect_url)
|
|
112
114
|
.then(async ({ response }) => {
|
|
113
115
|
if ((0, includes_1.default)([501, 403], response.status)) {
|
|
114
|
-
cli_utilities_1.log.error(`OAuth API call failed for ${appName}: ${response.statusText}
|
|
116
|
+
cli_utilities_1.log.error(`OAuth API call failed for ${appName}: ${response.statusText}`, config === null || config === void 0 ? void 0 : config.context);
|
|
115
117
|
await (0, exports.confirmToCloseProcess)(response.data, config);
|
|
116
118
|
}
|
|
117
119
|
else {
|
|
@@ -119,6 +121,7 @@ const makeRedirectUrlCall = async (response, appName, config) => {
|
|
|
119
121
|
}
|
|
120
122
|
})
|
|
121
123
|
.catch((error) => {
|
|
124
|
+
cli_utilities_1.log.error(error, config === null || config === void 0 ? void 0 : config.context);
|
|
122
125
|
if ((0, includes_1.default)([501, 403], error.status)) {
|
|
123
126
|
(0, cli_utilities_1.handleAndLogError)(error);
|
|
124
127
|
}
|
|
@@ -14,7 +14,7 @@ const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
|
14
14
|
* @param {ImportConfig} importConfig
|
|
15
15
|
*/
|
|
16
16
|
const lookUpTaxonomy = function (importConfig, schema, taxonomies) {
|
|
17
|
-
cli_utilities_1.log.debug(`Starting taxonomy lookup for schema with ${Object.keys(schema).length} fields
|
|
17
|
+
cli_utilities_1.log.debug(`Starting taxonomy lookup for schema with ${Object.keys(schema).length} fields.`);
|
|
18
18
|
for (let i in schema) {
|
|
19
19
|
if (schema[i].data_type === 'taxonomy') {
|
|
20
20
|
cli_utilities_1.log.debug(`Processing taxonomy field: ${schema[i].uid}`);
|
package/messages/index.json
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"COMPOSABLE_STUDIO_IMPORT_START": "Starting Studio project import...",
|
|
3
|
+
"COMPOSABLE_STUDIO_NOT_FOUND": "No Studio project found in exported data",
|
|
4
|
+
"COMPOSABLE_STUDIO_SKIP_EXISTING": "Skipping Studio import - target stack already has a connected project",
|
|
5
|
+
"COMPOSABLE_STUDIO_IMPORT_COMPLETE": "Successfully imported Studio project '%s'",
|
|
6
|
+
"COMPOSABLE_STUDIO_IMPORT_FAILED": "Failed to import Studio project: %s",
|
|
7
|
+
"COMPOSABLE_STUDIO_NAME_CONFLICT": "Project name '%s' already exists. Please provide a new name:",
|
|
8
|
+
"COMPOSABLE_STUDIO_SUGGEST_NAME": "Suggested name: %s",
|
|
9
|
+
"COMPOSABLE_STUDIO_ENV_MAPPING_FAILED": "Warning: Could not map environment '%s', using empty environment"
|
|
10
|
+
}
|
package/oclif.manifest.json
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
3
|
"cm:stacks:import": {
|
|
4
|
-
"aliases": [
|
|
5
|
-
"cm:import"
|
|
6
|
-
],
|
|
4
|
+
"aliases": [],
|
|
7
5
|
"args": {},
|
|
8
6
|
"description": "Import content from a stack",
|
|
9
7
|
"examples": [
|
|
@@ -25,15 +23,6 @@
|
|
|
25
23
|
"multiple": false,
|
|
26
24
|
"type": "option"
|
|
27
25
|
},
|
|
28
|
-
"stack-uid": {
|
|
29
|
-
"char": "s",
|
|
30
|
-
"description": "API key of the target stack.",
|
|
31
|
-
"hidden": true,
|
|
32
|
-
"name": "stack-uid",
|
|
33
|
-
"hasDynamicHelp": false,
|
|
34
|
-
"multiple": false,
|
|
35
|
-
"type": "option"
|
|
36
|
-
},
|
|
37
26
|
"stack-api-key": {
|
|
38
27
|
"char": "k",
|
|
39
28
|
"description": "API Key of the target stack",
|
|
@@ -42,14 +31,6 @@
|
|
|
42
31
|
"multiple": false,
|
|
43
32
|
"type": "option"
|
|
44
33
|
},
|
|
45
|
-
"data": {
|
|
46
|
-
"description": "path and location where data is stored",
|
|
47
|
-
"hidden": true,
|
|
48
|
-
"name": "data",
|
|
49
|
-
"hasDynamicHelp": false,
|
|
50
|
-
"multiple": false,
|
|
51
|
-
"type": "option"
|
|
52
|
-
},
|
|
53
34
|
"data-dir": {
|
|
54
35
|
"char": "d",
|
|
55
36
|
"description": "The path or the location in your file system where the content, you intend to import, is stored. For example, -d \"C:\\Users\\Name\\Desktop\\cli\\content\". If the export folder has branches involved, then the path should point till the particular branch. For example, “-d \"C:\\Users\\Name\\Desktop\\cli\\content\\branch_name\"",
|
|
@@ -66,25 +47,8 @@
|
|
|
66
47
|
"multiple": false,
|
|
67
48
|
"type": "option"
|
|
68
49
|
},
|
|
69
|
-
"management-token-alias": {
|
|
70
|
-
"description": "alias of the management token",
|
|
71
|
-
"hidden": true,
|
|
72
|
-
"name": "management-token-alias",
|
|
73
|
-
"hasDynamicHelp": false,
|
|
74
|
-
"multiple": false,
|
|
75
|
-
"type": "option"
|
|
76
|
-
},
|
|
77
|
-
"auth-token": {
|
|
78
|
-
"char": "A",
|
|
79
|
-
"description": "to use auth token",
|
|
80
|
-
"hidden": true,
|
|
81
|
-
"name": "auth-token",
|
|
82
|
-
"allowNo": false,
|
|
83
|
-
"type": "boolean"
|
|
84
|
-
},
|
|
85
50
|
"module": {
|
|
86
|
-
"
|
|
87
|
-
"description": "[optional] Specify the module to import into the target stack. If not specified, the import command will import all the modules into the stack. The available modules are assets, content-types, entries, environments, extensions, marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, personalize projects, and taxonomies.",
|
|
51
|
+
"description": "[optional] Specify the module to import into the target stack. If not specified, the import command will import all the modules into the stack. The available modules are assets, content-types, entries, environments, extensions, marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, personalize projects, taxonomies, and composable-studio.",
|
|
88
52
|
"name": "module",
|
|
89
53
|
"required": false,
|
|
90
54
|
"hasDynamicHelp": false,
|
|
@@ -92,7 +56,6 @@
|
|
|
92
56
|
"type": "option"
|
|
93
57
|
},
|
|
94
58
|
"backup-dir": {
|
|
95
|
-
"char": "b",
|
|
96
59
|
"description": "[optional] Backup directory name when using specific module.",
|
|
97
60
|
"name": "backup-dir",
|
|
98
61
|
"hasDynamicHelp": false,
|
|
@@ -100,7 +63,6 @@
|
|
|
100
63
|
"type": "option"
|
|
101
64
|
},
|
|
102
65
|
"branch": {
|
|
103
|
-
"char": "B",
|
|
104
66
|
"description": "The name of the branch where you want to import your content. If you don't mention the branch name, then by default the content will be imported to the main branch.",
|
|
105
67
|
"exclusive": [
|
|
106
68
|
"branch-alias"
|
|
@@ -141,12 +103,6 @@
|
|
|
141
103
|
"allowNo": false,
|
|
142
104
|
"type": "boolean"
|
|
143
105
|
},
|
|
144
|
-
"skip-app-recreation": {
|
|
145
|
-
"description": "(optional) Skips the recreation of private apps if they already exist.",
|
|
146
|
-
"name": "skip-app-recreation",
|
|
147
|
-
"allowNo": false,
|
|
148
|
-
"type": "boolean"
|
|
149
|
-
},
|
|
150
106
|
"replace-existing": {
|
|
151
107
|
"description": "Replaces the existing module in the target stack.",
|
|
152
108
|
"name": "replace-existing",
|
|
@@ -201,7 +157,7 @@
|
|
|
201
157
|
"pluginName": "@contentstack/cli-cm-import",
|
|
202
158
|
"pluginType": "core",
|
|
203
159
|
"strict": true,
|
|
204
|
-
"usage": "cm:stacks:import [
|
|
160
|
+
"usage": "cm:stacks:import [--config <value>] [--stack-api-key <value>] [--data-dir <value>] [--alias <value>] [--module <value>] [--backup-dir <value>] [--branch <value>] [--import-webhook-status disable|current]",
|
|
205
161
|
"isESM": false,
|
|
206
162
|
"relativePath": [
|
|
207
163
|
"lib",
|
|
@@ -212,5 +168,5 @@
|
|
|
212
168
|
]
|
|
213
169
|
}
|
|
214
170
|
},
|
|
215
|
-
"version": "2.0.0-beta.
|
|
171
|
+
"version": "2.0.0-beta.4"
|
|
216
172
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-import",
|
|
3
3
|
"description": "Contentstack CLI plugin to import content into stack",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.4",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-audit": "~
|
|
9
|
-
"@contentstack/cli-command": "~1.
|
|
10
|
-
"@contentstack/cli-utilities": "~1.
|
|
11
|
-
"@contentstack/management": "~1.
|
|
12
|
-
"@contentstack/cli-variants": "~2.0.0-beta.
|
|
8
|
+
"@contentstack/cli-audit": "~2.0.0-beta.1",
|
|
9
|
+
"@contentstack/cli-command": "~1.7.0",
|
|
10
|
+
"@contentstack/cli-utilities": "~1.17.0",
|
|
11
|
+
"@contentstack/management": "~1.27.3",
|
|
12
|
+
"@contentstack/cli-variants": "~2.0.0-beta.4",
|
|
13
13
|
"@oclif/core": "^4.3.0",
|
|
14
14
|
"big-json": "^3.2.0",
|
|
15
15
|
"bluebird": "^3.7.2",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"format": "eslint src/**/*.ts --fix",
|
|
61
61
|
"test:integration": "mocha --forbid-only \"test/run.test.js\" --integration-test --timeout 60000",
|
|
62
62
|
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\"",
|
|
63
|
-
"test:unit": "mocha --forbid-only \"test/**/*.test.ts\""
|
|
63
|
+
"test:unit": "mocha --forbid-only \"test/**/*.test.ts\" --exit"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": ">=14.0.0"
|
|
@@ -86,13 +86,9 @@
|
|
|
86
86
|
"repositoryPrefix": "<%- repo %>/blob/main/packages/contentstack-import/<%- commandPath %>"
|
|
87
87
|
},
|
|
88
88
|
"csdxConfig": {
|
|
89
|
-
"expiredCommands": {
|
|
90
|
-
"cm:import": "csdx cm:stacks:import"
|
|
91
|
-
},
|
|
92
89
|
"shortCommandName": {
|
|
93
|
-
"cm:stacks:import": "IMPRT"
|
|
94
|
-
"cm:import": "O-IMPRT"
|
|
90
|
+
"cm:stacks:import": "IMPRT"
|
|
95
91
|
}
|
|
96
92
|
},
|
|
97
93
|
"repository": "https://github.com/contentstack/cli"
|
|
98
|
-
}
|
|
94
|
+
}
|