@contentstack/cli-cm-import 1.28.0 → 1.28.2
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 +5 -7
- package/lib/commands/cm/stacks/import.js +1 -1
- package/lib/import/module-importer.d.ts +2 -2
- package/lib/import/module-importer.js +3 -5
- package/lib/utils/backup-handler.js +1 -1
- package/lib/utils/import-config-handler.js +0 -7
- package/lib/utils/import-path-resolver.d.ts +1 -1
- package/lib/utils/import-path-resolver.js +13 -3
- package/lib/utils/setup-branch.js +1 -1
- package/oclif.manifest.json +2 -2
- package/package.json +4 -3
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.28.
|
|
50
|
+
@contentstack/cli-cm-import/1.28.2 linux-x64 node-v22.20.0
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -91,9 +91,8 @@ FLAGS
|
|
|
91
91
|
extensions, marketplace-apps, global-fields, labels, locales, webhooks,
|
|
92
92
|
workflows, custom-roles, personalize projects, and taxonomies.
|
|
93
93
|
-y, --yes [optional] Force override all Marketplace prompts.
|
|
94
|
-
--branch-alias=<value>
|
|
95
|
-
|
|
96
|
-
main branch.
|
|
94
|
+
--branch-alias=<value> Specify the branch alias where you want to import your content. If not
|
|
95
|
+
specified, the content is imported into the main branch by default.
|
|
97
96
|
--exclude-global-modules Excludes the branch-independent module from the import operation.
|
|
98
97
|
--import-webhook-status=<option> [default: disable] [default: disable] (optional) This webhook state keeps the
|
|
99
98
|
same state of webhooks as the source stack. <options: disable|current>
|
|
@@ -160,9 +159,8 @@ FLAGS
|
|
|
160
159
|
extensions, marketplace-apps, global-fields, labels, locales, webhooks,
|
|
161
160
|
workflows, custom-roles, personalize projects, and taxonomies.
|
|
162
161
|
-y, --yes [optional] Force override all Marketplace prompts.
|
|
163
|
-
--branch-alias=<value>
|
|
164
|
-
|
|
165
|
-
main branch.
|
|
162
|
+
--branch-alias=<value> Specify the branch alias where you want to import your content. If not
|
|
163
|
+
specified, the content is imported into the main branch by default.
|
|
166
164
|
--exclude-global-modules Excludes the branch-independent module from the import operation.
|
|
167
165
|
--import-webhook-status=<option> [default: disable] [default: disable] (optional) This webhook state keeps the
|
|
168
166
|
same state of webhooks as the source stack. <options: disable|current>
|
|
@@ -133,7 +133,7 @@ ImportCommand.flags = {
|
|
|
133
133
|
exclusive: ['branch-alias'],
|
|
134
134
|
}),
|
|
135
135
|
'branch-alias': cli_utilities_1.flags.string({
|
|
136
|
-
description: "
|
|
136
|
+
description: "Specify the branch alias where you want to import your content. If not specified, the content is imported into the main branch by default.",
|
|
137
137
|
exclusive: ['branch'],
|
|
138
138
|
}),
|
|
139
139
|
'import-webhook-status': cli_utilities_1.flags.string({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContentstackClient
|
|
1
|
+
import { ContentstackClient } from '@contentstack/cli-utilities';
|
|
2
2
|
import { ImportConfig, Modules } from '../types';
|
|
3
3
|
declare class ModuleImporter {
|
|
4
4
|
private managementAPIClient;
|
|
@@ -20,6 +20,6 @@ declare class ModuleImporter {
|
|
|
20
20
|
* @returns The function `auditImportData()` returns a boolean value. It returns `true` if there is a
|
|
21
21
|
* fix available and the user confirms to proceed with the fix, otherwise it returns `false`.
|
|
22
22
|
*/
|
|
23
|
-
auditImportData(
|
|
23
|
+
auditImportData(): Promise<boolean>;
|
|
24
24
|
}
|
|
25
25
|
export default ModuleImporter;
|
|
@@ -41,13 +41,11 @@ class ModuleImporter {
|
|
|
41
41
|
// To support the old config
|
|
42
42
|
this.importConfig.data = backupDir;
|
|
43
43
|
}
|
|
44
|
-
// NOTE init log
|
|
45
|
-
const logger = (0, utils_1.initLogger)(this.importConfig);
|
|
46
44
|
// NOTE audit and fix the import content.
|
|
47
45
|
if (!this.importConfig.skipAudit &&
|
|
48
46
|
(!this.importConfig.moduleName ||
|
|
49
47
|
['content-types', 'global-fields', 'entries', 'extensions', 'workflows', 'custom-roles', 'assets'].includes(this.importConfig.moduleName))) {
|
|
50
|
-
if (!(await this.auditImportData(
|
|
48
|
+
if (!(await this.auditImportData())) {
|
|
51
49
|
return { noSuccessMsg: true };
|
|
52
50
|
}
|
|
53
51
|
}
|
|
@@ -120,7 +118,7 @@ class ModuleImporter {
|
|
|
120
118
|
* @returns The function `auditImportData()` returns a boolean value. It returns `true` if there is a
|
|
121
119
|
* fix available and the user confirms to proceed with the fix, otherwise it returns `false`.
|
|
122
120
|
*/
|
|
123
|
-
async auditImportData(
|
|
121
|
+
async auditImportData() {
|
|
124
122
|
const basePath = (0, path_1.resolve)(this.importConfig.cliLogsPath || this.importConfig.backupDir, 'logs', 'audit');
|
|
125
123
|
const auditConfig = this.importConfig.auditConfig;
|
|
126
124
|
auditConfig.config.basePath = basePath;
|
|
@@ -151,7 +149,7 @@ class ModuleImporter {
|
|
|
151
149
|
if (result) {
|
|
152
150
|
const { hasFix, config } = result;
|
|
153
151
|
if (hasFix) {
|
|
154
|
-
|
|
152
|
+
cli_utilities_1.log.warn((0, messages_1.$t)(messages_1.default.FINAL_REPORT_PATH, { path: config.reportPath }), this.importConfig.context);
|
|
155
153
|
if (this.importConfig.forceStopMarketplaceAppsPrompt ||
|
|
156
154
|
(await cli_utilities_1.cliux.inquire({
|
|
157
155
|
type: 'confirm',
|
|
@@ -41,7 +41,7 @@ async function backupHandler(importConfig) {
|
|
|
41
41
|
}
|
|
42
42
|
if (backupDirPath) {
|
|
43
43
|
cli_utilities_1.log.debug(`Starting content copy to backup directory: ${backupDirPath}`);
|
|
44
|
-
cli_utilities_1.
|
|
44
|
+
cli_utilities_1.log.info('Copying content to the backup directory...', importConfig.context);
|
|
45
45
|
return new Promise((resolve, reject) => {
|
|
46
46
|
return (0, fs_extra_1.copy)(sourceDir, backupDirPath, (error) => {
|
|
47
47
|
if (error) {
|
|
@@ -35,13 +35,6 @@ const setupConfig = async (importCmdFlags) => {
|
|
|
35
35
|
config.contentDir = path.resolve(config.contentDir);
|
|
36
36
|
//Note to support the old key
|
|
37
37
|
config.data = config.contentDir;
|
|
38
|
-
if ((0, file_helper_1.fileExistsSync)(path.join(config.contentDir, 'export-info.json'))) {
|
|
39
|
-
config.contentVersion =
|
|
40
|
-
((await (0, file_helper_1.readFile)(path.join(config.contentDir, 'export-info.json'))) || {}).contentVersion || 2;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
config.contentVersion = 1;
|
|
44
|
-
}
|
|
45
38
|
const managementTokenAlias = importCmdFlags['management-token-alias'] || importCmdFlags['alias'];
|
|
46
39
|
if (managementTokenAlias) {
|
|
47
40
|
const { token, apiKey } = (_a = cli_utilities_1.configHandler.get(`tokens.${managementTokenAlias}`)) !== null && _a !== void 0 ? _a : {};
|
|
@@ -19,7 +19,7 @@ export declare const resolveImportPath: (importConfig: ImportConfig, stackAPICli
|
|
|
19
19
|
* @param importConfig - The import configuration object
|
|
20
20
|
* @param resolvedPath - The resolved path
|
|
21
21
|
*/
|
|
22
|
-
export declare const updateImportConfigWithResolvedPath: (importConfig: ImportConfig, resolvedPath: string) => void
|
|
22
|
+
export declare const updateImportConfigWithResolvedPath: (importConfig: ImportConfig, resolvedPath: string) => Promise<void>;
|
|
23
23
|
/**
|
|
24
24
|
* Executes the complete import path resolution logic
|
|
25
25
|
* @param importConfig - The import configuration object
|
|
@@ -107,7 +107,7 @@ exports.resolveImportPath = resolveImportPath;
|
|
|
107
107
|
* @param importConfig - The import configuration object
|
|
108
108
|
* @param resolvedPath - The resolved path
|
|
109
109
|
*/
|
|
110
|
-
const updateImportConfigWithResolvedPath = (importConfig, resolvedPath) => {
|
|
110
|
+
const updateImportConfigWithResolvedPath = async (importConfig, resolvedPath) => {
|
|
111
111
|
cli_utilities_1.log.debug(`Updating import config with resolved path: ${resolvedPath}`);
|
|
112
112
|
if (!(0, file_helper_1.fileExistsSync)(resolvedPath)) {
|
|
113
113
|
cli_utilities_1.log.warn(`Resolved path does not exist: ${resolvedPath}, skipping config update`);
|
|
@@ -116,7 +116,17 @@ const updateImportConfigWithResolvedPath = (importConfig, resolvedPath) => {
|
|
|
116
116
|
importConfig.branchDir = resolvedPath;
|
|
117
117
|
importConfig.contentDir = resolvedPath;
|
|
118
118
|
importConfig.data = resolvedPath;
|
|
119
|
-
|
|
119
|
+
const exportInfoPath = path.join(resolvedPath, 'export-info.json');
|
|
120
|
+
if ((0, file_helper_1.fileExistsSync)(exportInfoPath)) {
|
|
121
|
+
const exportInfo = await (0, file_helper_1.readFile)(exportInfoPath);
|
|
122
|
+
importConfig.contentVersion = (exportInfo === null || exportInfo === void 0 ? void 0 : exportInfo.contentVersion) || 2;
|
|
123
|
+
cli_utilities_1.log.debug(`Content version set to ${importConfig.contentVersion} from ${exportInfoPath}`);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
importConfig.contentVersion = 1;
|
|
127
|
+
cli_utilities_1.log.debug(`No export-info.json found at ${exportInfoPath}, setting content version to 1`);
|
|
128
|
+
}
|
|
129
|
+
cli_utilities_1.log.debug(`Import config updated - contentDir: ${importConfig.contentDir}, branchDir: ${importConfig.branchDir}, data: ${importConfig.data}, contentVersion: ${importConfig.contentVersion}`);
|
|
120
130
|
};
|
|
121
131
|
exports.updateImportConfigWithResolvedPath = updateImportConfigWithResolvedPath;
|
|
122
132
|
/**
|
|
@@ -128,7 +138,7 @@ exports.updateImportConfigWithResolvedPath = updateImportConfigWithResolvedPath;
|
|
|
128
138
|
const executeImportPathLogic = async (importConfig, stackAPIClient) => {
|
|
129
139
|
cli_utilities_1.log.debug('Executing import path resolution logic');
|
|
130
140
|
const resolvedPath = await (0, exports.resolveImportPath)(importConfig, stackAPIClient);
|
|
131
|
-
(0, exports.updateImportConfigWithResolvedPath)(importConfig, resolvedPath);
|
|
141
|
+
await (0, exports.updateImportConfigWithResolvedPath)(importConfig, resolvedPath);
|
|
132
142
|
return resolvedPath;
|
|
133
143
|
};
|
|
134
144
|
exports.executeImportPathLogic = executeImportPathLogic;
|
|
@@ -19,7 +19,7 @@ const setupBranchConfig = async (config, stackAPIClient) => {
|
|
|
19
19
|
.find()
|
|
20
20
|
.then(({ items }) => items);
|
|
21
21
|
if (branches.length) {
|
|
22
|
-
cli_utilities_1.log.info(`
|
|
22
|
+
cli_utilities_1.log.info(`The stack is branch-enabled, and branches exist. By default, content will be imported into the main branch.`);
|
|
23
23
|
config.branchName = 'main';
|
|
24
24
|
cli_utilities_1.log.debug(`Setting default target branch to 'main'`);
|
|
25
25
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"type": "option"
|
|
112
112
|
},
|
|
113
113
|
"branch-alias": {
|
|
114
|
-
"description": "
|
|
114
|
+
"description": "Specify the branch alias where you want to import your content. If not specified, the content is imported into the main branch by default.",
|
|
115
115
|
"exclusive": [
|
|
116
116
|
"branch"
|
|
117
117
|
],
|
|
@@ -212,5 +212,5 @@
|
|
|
212
212
|
]
|
|
213
213
|
}
|
|
214
214
|
},
|
|
215
|
-
"version": "1.28.
|
|
215
|
+
"version": "1.28.2"
|
|
216
216
|
}
|
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.28.
|
|
4
|
+
"version": "1.28.2",
|
|
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.15.0",
|
|
9
9
|
"@contentstack/cli-command": "~1.6.1",
|
|
10
10
|
"@contentstack/cli-utilities": "~1.14.1",
|
|
11
11
|
"@contentstack/management": "~1.22.0",
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"lint": "eslint src/**/*.ts",
|
|
58
58
|
"format": "eslint src/**/*.ts --fix",
|
|
59
59
|
"test:integration": "mocha --forbid-only \"test/run.test.js\" --integration-test --timeout 60000",
|
|
60
|
-
"test:unit": "mocha --forbid-only \"test/unit
|
|
60
|
+
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\"",
|
|
61
|
+
"test:unit": "mocha --forbid-only \"test/**/*.test.ts\""
|
|
61
62
|
},
|
|
62
63
|
"engines": {
|
|
63
64
|
"node": ">=14.0.0"
|