@contentstack/cli-cm-import 2.0.0-beta.15 → 2.0.0-beta.16
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 +34 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +1 -0
- package/lib/import/modules/assets.d.ts +5 -0
- package/lib/import/modules/assets.js +54 -3
- package/lib/import/modules/base-class.js +1 -1
- package/lib/import/modules/stack.js +8 -0
- package/lib/types/default-config.d.ts +18 -0
- package/lib/types/import-config.d.ts +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/utils/build-import-spaces-options.d.ts +7 -0
- package/lib/utils/build-import-spaces-options.js +41 -0
- package/lib/utils/import-config-handler.js +29 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +3 -1
- package/oclif.manifest.json +1 -1
- package/package.json +6 -5
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/2.0.0-beta.
|
|
50
|
+
@contentstack/cli-cm-import/2.0.0-beta.16 linux-x64 node-v22.22.2
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
package/lib/config/index.js
CHANGED
|
@@ -101,6 +101,40 @@ const config = {
|
|
|
101
101
|
folderValidKeys: ['name', 'parent_uid'],
|
|
102
102
|
validKeys: ['title', 'parent_uid', 'description', 'tags'],
|
|
103
103
|
},
|
|
104
|
+
'asset-management': {
|
|
105
|
+
dirName: 'spaces',
|
|
106
|
+
fieldsDir: 'fields',
|
|
107
|
+
assetTypesDir: 'asset_types',
|
|
108
|
+
fieldsFileName: 'fields.json',
|
|
109
|
+
assetTypesFileName: 'asset-types.json',
|
|
110
|
+
foldersFileName: 'folders.json',
|
|
111
|
+
assetsFileName: 'assets.json',
|
|
112
|
+
fieldsImportInvalidKeys: [
|
|
113
|
+
'created_at',
|
|
114
|
+
'created_by',
|
|
115
|
+
'updated_at',
|
|
116
|
+
'updated_by',
|
|
117
|
+
'is_system',
|
|
118
|
+
'asset_types_count',
|
|
119
|
+
],
|
|
120
|
+
assetTypesImportInvalidKeys: [
|
|
121
|
+
'created_at',
|
|
122
|
+
'created_by',
|
|
123
|
+
'updated_at',
|
|
124
|
+
'updated_by',
|
|
125
|
+
'is_system',
|
|
126
|
+
'category',
|
|
127
|
+
'preview_image_url',
|
|
128
|
+
'category_detail',
|
|
129
|
+
],
|
|
130
|
+
mapperRootDir: 'mapper',
|
|
131
|
+
mapperAssetsModuleDir: 'assets',
|
|
132
|
+
mapperUidFileName: 'uid-mapping.json',
|
|
133
|
+
mapperUrlFileName: 'url-mapping.json',
|
|
134
|
+
mapperSpaceUidFileName: 'space-uid-mapping.json',
|
|
135
|
+
uploadAssetsConcurrency: 2,
|
|
136
|
+
importFoldersConcurrency: 1,
|
|
137
|
+
},
|
|
104
138
|
'assets-old': {
|
|
105
139
|
dirName: 'assets',
|
|
106
140
|
fileName: 'assets.json',
|
package/lib/constants/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare const PATH_CONSTANTS: {
|
|
|
19
19
|
readonly INDEX: "index.json";
|
|
20
20
|
readonly FOLDER_MAPPING: "folder-mapping.json";
|
|
21
21
|
readonly VERSIONED_ASSETS: "versioned-assets.json";
|
|
22
|
+
readonly SPACE_UID_MAPPING: "space-uid-mapping.json";
|
|
22
23
|
};
|
|
23
24
|
/** Module subdirectory names within mapper */
|
|
24
25
|
readonly MAPPER_MODULES: {
|
package/lib/constants/index.js
CHANGED
|
@@ -22,6 +22,7 @@ exports.PATH_CONSTANTS = {
|
|
|
22
22
|
INDEX: 'index.json',
|
|
23
23
|
FOLDER_MAPPING: 'folder-mapping.json',
|
|
24
24
|
VERSIONED_ASSETS: 'versioned-assets.json',
|
|
25
|
+
SPACE_UID_MAPPING: 'space-uid-mapping.json',
|
|
25
26
|
},
|
|
26
27
|
/** Module subdirectory names within mapper */
|
|
27
28
|
MAPPER_MODULES: {
|
|
@@ -32,6 +32,11 @@ export default class ImportAssets extends BaseClass {
|
|
|
32
32
|
* @returns {Promise<void>} Promise<any>
|
|
33
33
|
*/
|
|
34
34
|
start(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Merges imported AM spaces into the target stack branch's `am_v2.linked_workspaces`.
|
|
37
|
+
* Errors are logged and swallowed so a successful import still completes; import failures are handled separately.
|
|
38
|
+
*/
|
|
39
|
+
private linkImportedAmSpacesToBranch;
|
|
35
40
|
/**
|
|
36
41
|
* @method importFolders
|
|
37
42
|
* @returns {Promise<any>} Promise<any>
|
|
@@ -13,6 +13,7 @@ const includes_1 = tslib_1.__importDefault(require("lodash/includes"));
|
|
|
13
13
|
const uuid_1 = require("uuid");
|
|
14
14
|
const node_path_1 = require("node:path");
|
|
15
15
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
16
|
+
const cli_asset_management_1 = require("@contentstack/cli-asset-management");
|
|
16
17
|
const constants_1 = require("../../constants");
|
|
17
18
|
const config_1 = tslib_1.__importDefault(require("../../config"));
|
|
18
19
|
const utils_1 = require("../../utils");
|
|
@@ -41,8 +42,31 @@ class ImportAssets extends base_class_1.default {
|
|
|
41
42
|
* @returns {Promise<void>} Promise<any>
|
|
42
43
|
*/
|
|
43
44
|
async start() {
|
|
45
|
+
var _a;
|
|
44
46
|
try {
|
|
45
47
|
cli_utilities_1.log.debug('Starting assets import process...', this.importConfig.context);
|
|
48
|
+
// AM 2.0: assetManagementEnabled is set in the config handler when spaces/ + am_v2 are detected.
|
|
49
|
+
if (this.importConfig.assetManagementEnabled) {
|
|
50
|
+
if (!this.importConfig.assetManagementUrl) {
|
|
51
|
+
cli_utilities_1.log.info('AM 2.0 export detected but assetManagementUrl is not configured in the region settings. Skipping AM 2.0 asset import.', this.importConfig.context);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const progress = this.createNestedProgress(this.currentModuleName);
|
|
55
|
+
let spaceMappings = [];
|
|
56
|
+
try {
|
|
57
|
+
const importer = new cli_asset_management_1.ImportSpaces((0, utils_1.buildImportSpacesOptions)(this.importConfig, this.importConfig.assetManagementUrl));
|
|
58
|
+
importer.setParentProgressManager(progress);
|
|
59
|
+
({ spaceMappings } = await importer.start());
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
this.completeProgress(false, (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : 'AM 2.0 asset import failed');
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
await this.linkImportedAmSpacesToBranch(spaceMappings);
|
|
66
|
+
this.completeProgressWithMessage();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// Legacy flow continues below
|
|
46
70
|
// Step 1: Analyze import data
|
|
47
71
|
const [foldersCount, assetsCount, versionedAssetsCount, publishableAssetsCount] = await this.withLoadingSpinner('ASSETS: Analyzing import data...', () => this.analyzeImportData());
|
|
48
72
|
// Step 2: Initialize progress tracking
|
|
@@ -74,6 +98,35 @@ class ImportAssets extends base_class_1.default {
|
|
|
74
98
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.importConfig.context));
|
|
75
99
|
}
|
|
76
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Merges imported AM spaces into the target stack branch's `am_v2.linked_workspaces`.
|
|
103
|
+
* Errors are logged and swallowed so a successful import still completes; import failures are handled separately.
|
|
104
|
+
*/
|
|
105
|
+
async linkImportedAmSpacesToBranch(spaceMappings) {
|
|
106
|
+
var _a, _b, _c, _d;
|
|
107
|
+
if (spaceMappings.length === 0) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const branchUid = (_a = this.importConfig.branchName) !== null && _a !== void 0 ? _a : 'main';
|
|
112
|
+
const branchData = (await this.stack.branch(branchUid).fetch({ include_settings: true }));
|
|
113
|
+
const currentLinked = ((_d = (_c = (_b = branchData === null || branchData === void 0 ? void 0 : branchData.settings) === null || _b === void 0 ? void 0 : _b.am_v2) === null || _c === void 0 ? void 0 : _c.linked_workspaces) !== null && _d !== void 0 ? _d : []);
|
|
114
|
+
const newWorkspaces = spaceMappings.map(({ newSpaceUid, workspaceUid }) => ({
|
|
115
|
+
uid: workspaceUid,
|
|
116
|
+
space_uid: newSpaceUid,
|
|
117
|
+
is_default: false,
|
|
118
|
+
operation: 'LINK',
|
|
119
|
+
}));
|
|
120
|
+
const combinedWorkspaces = [...currentLinked, ...newWorkspaces];
|
|
121
|
+
await this.stack.branch(branchUid).updateSettings({
|
|
122
|
+
branch: { settings: { am_v2: { linked_workspaces: combinedWorkspaces } } },
|
|
123
|
+
});
|
|
124
|
+
cli_utilities_1.log.success(`Linked ${newWorkspaces.length} space(s) to branch "${branchUid}"`, this.importConfig.context);
|
|
125
|
+
}
|
|
126
|
+
catch (linkErr) {
|
|
127
|
+
(0, cli_utilities_1.handleAndLogError)(linkErr, Object.assign(Object.assign({}, this.importConfig.context), { phase: 'AM 2.0 branch linking (linked_workspaces)' }));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
77
130
|
/**
|
|
78
131
|
* @method importFolders
|
|
79
132
|
* @returns {Promise<any>} Promise<any>
|
|
@@ -142,9 +195,7 @@ class ImportAssets extends base_class_1.default {
|
|
|
142
195
|
*/
|
|
143
196
|
async importAssets(isVersion = false) {
|
|
144
197
|
const processName = isVersion ? 'import versioned assets' : 'import assets';
|
|
145
|
-
const indexFileName = isVersion
|
|
146
|
-
? constants_1.PATH_CONSTANTS.FILES.VERSIONED_ASSETS
|
|
147
|
-
: this.assetConfig.fileName;
|
|
198
|
+
const indexFileName = isVersion ? constants_1.PATH_CONSTANTS.FILES.VERSIONED_ASSETS : this.assetConfig.fileName;
|
|
148
199
|
const basePath = isVersion ? (0, node_path_1.join)(this.assetsPath, 'versions') : this.assetsPath;
|
|
149
200
|
const progressProcessName = isVersion ? utils_1.PROCESS_NAMES.ASSET_VERSIONS : utils_1.PROCESS_NAMES.ASSET_UPLOAD;
|
|
150
201
|
cli_utilities_1.log.debug(`Importing ${processName} from ${basePath}`, this.importConfig.context);
|
|
@@ -109,7 +109,7 @@ class BaseClass {
|
|
|
109
109
|
* @returns {Promise} Promise<void>
|
|
110
110
|
*/
|
|
111
111
|
makeConcurrentCall(env, promisifyHandler, logBatchCompletionMsg = true) {
|
|
112
|
-
const { apiParams, apiContent, processName, indexerCount, currentIndexer, concurrencyLimit = this.importConfig.
|
|
112
|
+
const { apiParams, apiContent, processName, indexerCount, currentIndexer, concurrencyLimit = this.importConfig.fetchConcurrency, } = env;
|
|
113
113
|
/* eslint-disable no-async-promise-executor */
|
|
114
114
|
return new Promise(async (resolve) => {
|
|
115
115
|
let batchNo = 0;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
5
6
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
7
|
const constants_1 = require("../../constants");
|
|
7
8
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
@@ -46,6 +47,13 @@ class ImportStack extends base_class_1.default {
|
|
|
46
47
|
async importStackSettings() {
|
|
47
48
|
var _a, _b, _c;
|
|
48
49
|
cli_utilities_1.log.debug('Processing stack settings for import', this.importConfig.context);
|
|
50
|
+
// Old source-org space UIDs must not be written to the target stack —
|
|
51
|
+
// the asset-management module will apply the correct am_v2.linked_workspaces.
|
|
52
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(this.importConfig.contentDir, 'spaces'))) {
|
|
53
|
+
const _d = this.stackSettings, { am_v2 } = _d, settingsWithoutAm = tslib_1.__rest(_d, ["am_v2"]);
|
|
54
|
+
this.stackSettings = settingsWithoutAm;
|
|
55
|
+
cli_utilities_1.log.debug('Stripped am_v2 from stack settings; asset-management module will apply it after space creation', this.importConfig.context);
|
|
56
|
+
}
|
|
49
57
|
// Update environment UID mapping if live preview is configured
|
|
50
58
|
if (((_a = this.stackSettings) === null || _a === void 0 ? void 0 : _a.live_preview) && ((_b = this.stackSettings) === null || _b === void 0 ? void 0 : _b.live_preview['default-env']) !== undefined) {
|
|
51
59
|
const oldEnvUid = this.stackSettings.live_preview['default-env'];
|
|
@@ -70,6 +70,24 @@ export default interface DefaultConfig {
|
|
|
70
70
|
uploadAssetsConcurrency: number;
|
|
71
71
|
importFoldersConcurrency: number;
|
|
72
72
|
};
|
|
73
|
+
'asset-management': {
|
|
74
|
+
dirName: string;
|
|
75
|
+
fieldsDir: string;
|
|
76
|
+
assetTypesDir: string;
|
|
77
|
+
fieldsFileName: string;
|
|
78
|
+
assetTypesFileName: string;
|
|
79
|
+
foldersFileName: string;
|
|
80
|
+
assetsFileName: string;
|
|
81
|
+
fieldsImportInvalidKeys: string[];
|
|
82
|
+
assetTypesImportInvalidKeys: string[];
|
|
83
|
+
mapperRootDir: string;
|
|
84
|
+
mapperAssetsModuleDir: string;
|
|
85
|
+
mapperUidFileName: string;
|
|
86
|
+
mapperUrlFileName: string;
|
|
87
|
+
mapperSpaceUidFileName: string;
|
|
88
|
+
uploadAssetsConcurrency: number;
|
|
89
|
+
importFoldersConcurrency: number;
|
|
90
|
+
};
|
|
73
91
|
content_types: {
|
|
74
92
|
dirName: string;
|
|
75
93
|
fileName: string;
|
|
@@ -55,6 +55,8 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig {
|
|
|
55
55
|
personalizeProjectName?: string;
|
|
56
56
|
'exclude-global-modules': false;
|
|
57
57
|
context: Context;
|
|
58
|
+
assetManagementUrl?: string;
|
|
59
|
+
assetManagementEnabled?: boolean;
|
|
58
60
|
}
|
|
59
61
|
type branch = {
|
|
60
62
|
uid: string;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ImportSpacesOptions } from '@contentstack/cli-asset-management';
|
|
2
|
+
import type ImportConfig from '../types/import-config';
|
|
3
|
+
/**
|
|
4
|
+
* Maps stack `ImportConfig` and AM base URL into a single `ImportSpacesOptions` for the AM package
|
|
5
|
+
* (variants-style: one flat object; `ImportSpaces` splits API vs context internally).
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildImportSpacesOptions(importConfig: ImportConfig, assetManagementUrl: string): ImportSpacesOptions;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildImportSpacesOptions = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
/**
|
|
6
|
+
* Maps stack `ImportConfig` and AM base URL into a single `ImportSpacesOptions` for the AM package
|
|
7
|
+
* (variants-style: one flat object; `ImportSpaces` splits API vs context internally).
|
|
8
|
+
*/
|
|
9
|
+
function buildImportSpacesOptions(importConfig, assetManagementUrl) {
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
11
|
+
const am = importConfig.modules['asset-management'];
|
|
12
|
+
const org_uid = (_a = importConfig.org_uid) !== null && _a !== void 0 ? _a : '';
|
|
13
|
+
return {
|
|
14
|
+
contentDir: importConfig.contentDir,
|
|
15
|
+
assetManagementUrl,
|
|
16
|
+
org_uid,
|
|
17
|
+
apiKey: importConfig.apiKey,
|
|
18
|
+
host: (_d = (_c = (_b = importConfig.region) === null || _b === void 0 ? void 0 : _b.cma) !== null && _c !== void 0 ? _c : importConfig.host) !== null && _d !== void 0 ? _d : '',
|
|
19
|
+
sourceApiKey: importConfig.source_stack,
|
|
20
|
+
context: importConfig.context,
|
|
21
|
+
backupDir: importConfig.backupDir,
|
|
22
|
+
apiConcurrency: importConfig.fetchConcurrency,
|
|
23
|
+
uploadAssetsConcurrency: am === null || am === void 0 ? void 0 : am.uploadAssetsConcurrency,
|
|
24
|
+
importFoldersConcurrency: am === null || am === void 0 ? void 0 : am.importFoldersConcurrency,
|
|
25
|
+
spacesDirName: am === null || am === void 0 ? void 0 : am.dirName,
|
|
26
|
+
fieldsDir: am === null || am === void 0 ? void 0 : am.fieldsDir,
|
|
27
|
+
assetTypesDir: am === null || am === void 0 ? void 0 : am.assetTypesDir,
|
|
28
|
+
fieldsFileName: am === null || am === void 0 ? void 0 : am.fieldsFileName,
|
|
29
|
+
assetTypesFileName: am === null || am === void 0 ? void 0 : am.assetTypesFileName,
|
|
30
|
+
foldersFileName: am === null || am === void 0 ? void 0 : am.foldersFileName,
|
|
31
|
+
assetsFileName: am === null || am === void 0 ? void 0 : am.assetsFileName,
|
|
32
|
+
fieldsImportInvalidKeys: am === null || am === void 0 ? void 0 : am.fieldsImportInvalidKeys,
|
|
33
|
+
assetTypesImportInvalidKeys: am === null || am === void 0 ? void 0 : am.assetTypesImportInvalidKeys,
|
|
34
|
+
mapperRootDir: (_e = am === null || am === void 0 ? void 0 : am.mapperRootDir) !== null && _e !== void 0 ? _e : constants_1.PATH_CONSTANTS.MAPPER,
|
|
35
|
+
mapperAssetsModuleDir: (_f = am === null || am === void 0 ? void 0 : am.mapperAssetsModuleDir) !== null && _f !== void 0 ? _f : constants_1.PATH_CONSTANTS.MAPPER_MODULES.ASSETS,
|
|
36
|
+
mapperUidFileName: (_g = am === null || am === void 0 ? void 0 : am.mapperUidFileName) !== null && _g !== void 0 ? _g : constants_1.PATH_CONSTANTS.FILES.UID_MAPPING,
|
|
37
|
+
mapperUrlFileName: (_h = am === null || am === void 0 ? void 0 : am.mapperUrlFileName) !== null && _h !== void 0 ? _h : constants_1.PATH_CONSTANTS.FILES.URL_MAPPING,
|
|
38
|
+
mapperSpaceUidFileName: (_j = am === null || am === void 0 ? void 0 : am.mapperSpaceUidFileName) !== null && _j !== void 0 ? _j : constants_1.PATH_CONSTANTS.FILES.SPACE_UID_MAPPING,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.buildImportSpacesOptions = buildImportSpacesOptions;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const merge_1 = tslib_1.__importDefault(require("merge"));
|
|
5
5
|
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
6
7
|
const lodash_1 = require("lodash");
|
|
7
8
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
8
9
|
const config_1 = tslib_1.__importDefault(require("../config"));
|
|
@@ -10,7 +11,7 @@ const file_helper_1 = require("./file-helper");
|
|
|
10
11
|
const interactive_1 = require("./interactive");
|
|
11
12
|
const login_handler_1 = tslib_1.__importDefault(require("./login-handler"));
|
|
12
13
|
const setupConfig = async (importCmdFlags) => {
|
|
13
|
-
var _a;
|
|
14
|
+
var _a, _b, _c;
|
|
14
15
|
// Set progress supported module FIRST, before any log calls
|
|
15
16
|
// This ensures the logger respects the showConsoleLogs setting correctly
|
|
16
17
|
cli_utilities_1.configHandler.set('log.progressSupportedModule', 'import');
|
|
@@ -108,6 +109,33 @@ const setupConfig = async (importCmdFlags) => {
|
|
|
108
109
|
if (importCmdFlags['exclude-global-modules']) {
|
|
109
110
|
config['exclude-global-modules'] = importCmdFlags['exclude-global-modules'];
|
|
110
111
|
}
|
|
112
|
+
const spacesDir = path.join(config.contentDir, 'spaces');
|
|
113
|
+
const stackSettingsPath = path.join(config.contentDir, 'stack', 'settings.json');
|
|
114
|
+
const stackJsonPath = path.join(config.contentDir, 'stack', 'stack.json');
|
|
115
|
+
if ((0, node_fs_1.existsSync)(spacesDir) && (0, node_fs_1.existsSync)(stackSettingsPath)) {
|
|
116
|
+
try {
|
|
117
|
+
const stackSettings = JSON.parse((0, node_fs_1.readFileSync)(stackSettingsPath, 'utf8'));
|
|
118
|
+
if (stackSettings === null || stackSettings === void 0 ? void 0 : stackSettings.am_v2) {
|
|
119
|
+
config.assetManagementEnabled = true;
|
|
120
|
+
config.assetManagementUrl = (_b = cli_utilities_1.configHandler.get('region')) === null || _b === void 0 ? void 0 : _b.assetManagementUrl;
|
|
121
|
+
if ((0, node_fs_1.existsSync)(stackJsonPath)) {
|
|
122
|
+
try {
|
|
123
|
+
const stackData = JSON.parse((0, node_fs_1.readFileSync)(stackJsonPath, 'utf8'));
|
|
124
|
+
const apiKey = (stackData === null || stackData === void 0 ? void 0 : stackData.api_key) || ((_c = stackData === null || stackData === void 0 ? void 0 : stackData.stackHeaders) === null || _c === void 0 ? void 0 : _c.api_key);
|
|
125
|
+
if (apiKey) {
|
|
126
|
+
config.source_stack = apiKey;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (_d) {
|
|
130
|
+
// stack.json unreadable — source stack API key will not be set
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (_e) {
|
|
136
|
+
// stack settings unreadable — not an AM 2.0 export we can process
|
|
137
|
+
}
|
|
138
|
+
}
|
|
111
139
|
// Add authentication details to config for context tracking
|
|
112
140
|
config.authenticationMethod = authenticationMethod;
|
|
113
141
|
cli_utilities_1.log.debug('Import configuration setup completed.', Object.assign({}, config));
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export { lookupEntries, removeUidsFromJsonRteFields, removeEntryRefsFromJSONRTE,
|
|
|
14
14
|
export * from './common-helper';
|
|
15
15
|
export { lookUpTaxonomy, lookUpTerms } from './taxonomies-helper';
|
|
16
16
|
export { MODULE_CONTEXTS, MODULE_NAMES, PROCESS_NAMES, PROCESS_STATUS } from './constants';
|
|
17
|
+
export { buildImportSpacesOptions } from './build-import-spaces-options';
|
package/lib/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROCESS_STATUS = exports.PROCESS_NAMES = exports.MODULE_NAMES = exports.MODULE_CONTEXTS = exports.lookUpTerms = exports.lookUpTaxonomy = exports.restoreJsonRteEntryRefs = exports.removeEntryRefsFromJSONRTE = exports.removeUidsFromJsonRteFields = exports.lookupEntries = exports.lookupExtension = exports.removeReferenceFields = exports.suppressSchemaReference = exports.schemaTemplate = exports.ifAppAlreadyExist = exports.getAllStackSpecificApps = exports.confirmToCloseProcess = exports.makeRedirectUrlCall = exports.handleNameConflict = exports.getConfirmationToCreateApps = exports.getOrgUid = exports.getDeveloperHubUrl = exports.lookupAssets = exports.uploadAssetHelper = exports.unlinkFileLogger = exports.log = exports.backupHandler = exports.fsUtil = exports.fileHelper = exports.setupImportConfig = exports.interactive = exports.executeImportPathLogic = exports.updateImportConfigWithResolvedPath = exports.resolveImportPath = exports.setupBranchConfig = void 0;
|
|
3
|
+
exports.buildImportSpacesOptions = exports.PROCESS_STATUS = exports.PROCESS_NAMES = exports.MODULE_NAMES = exports.MODULE_CONTEXTS = exports.lookUpTerms = exports.lookUpTaxonomy = exports.restoreJsonRteEntryRefs = exports.removeEntryRefsFromJSONRTE = exports.removeUidsFromJsonRteFields = exports.lookupEntries = exports.lookupExtension = exports.removeReferenceFields = exports.suppressSchemaReference = exports.schemaTemplate = exports.ifAppAlreadyExist = exports.getAllStackSpecificApps = exports.confirmToCloseProcess = exports.makeRedirectUrlCall = exports.handleNameConflict = exports.getConfirmationToCreateApps = exports.getOrgUid = exports.getDeveloperHubUrl = exports.lookupAssets = exports.uploadAssetHelper = exports.unlinkFileLogger = exports.log = exports.backupHandler = exports.fsUtil = exports.fileHelper = exports.setupImportConfig = exports.interactive = exports.executeImportPathLogic = exports.updateImportConfigWithResolvedPath = exports.resolveImportPath = exports.setupBranchConfig = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var setup_branch_1 = require("./setup-branch");
|
|
6
6
|
Object.defineProperty(exports, "setupBranchConfig", { enumerable: true, get: function () { return setup_branch_1.setupBranchConfig; } });
|
|
@@ -51,3 +51,5 @@ Object.defineProperty(exports, "MODULE_CONTEXTS", { enumerable: true, get: funct
|
|
|
51
51
|
Object.defineProperty(exports, "MODULE_NAMES", { enumerable: true, get: function () { return constants_1.MODULE_NAMES; } });
|
|
52
52
|
Object.defineProperty(exports, "PROCESS_NAMES", { enumerable: true, get: function () { return constants_1.PROCESS_NAMES; } });
|
|
53
53
|
Object.defineProperty(exports, "PROCESS_STATUS", { enumerable: true, get: function () { return constants_1.PROCESS_STATUS; } });
|
|
54
|
+
var build_import_spaces_options_1 = require("./build-import-spaces-options");
|
|
55
|
+
Object.defineProperty(exports, "buildImportSpacesOptions", { enumerable: true, get: function () { return build_import_spaces_options_1.buildImportSpacesOptions; } });
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +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.16",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-audit": "~2.0.0-beta.
|
|
8
|
+
"@contentstack/cli-audit": "~2.0.0-beta.11",
|
|
9
9
|
"@contentstack/cli-command": "~2.0.0-beta.6",
|
|
10
10
|
"@contentstack/cli-utilities": "~2.0.0-beta.7",
|
|
11
11
|
"@contentstack/cli-variants": "~2.0.0-beta.12",
|
|
12
|
+
"@contentstack/cli-asset-management": "~1.0.0-beta.0",
|
|
12
13
|
"@oclif/core": "^4.3.0",
|
|
13
14
|
"big-json": "^3.2.0",
|
|
14
15
|
"bluebird": "^3.7.2",
|
|
@@ -21,10 +22,10 @@
|
|
|
21
22
|
"mkdirp": "^1.0.4",
|
|
22
23
|
"promise-limit": "^2.7.0",
|
|
23
24
|
"uuid": "^9.0.1",
|
|
24
|
-
"winston": "^3.
|
|
25
|
+
"winston": "^3.19.0"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@oclif/test": "^4.1.
|
|
28
|
+
"@oclif/test": "^4.1.18",
|
|
28
29
|
"@types/big-json": "^3.2.5",
|
|
29
30
|
"@types/bluebird": "^3.5.42",
|
|
30
31
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -90,4 +91,4 @@
|
|
|
90
91
|
}
|
|
91
92
|
},
|
|
92
93
|
"repository": "https://github.com/contentstack/cli"
|
|
93
|
-
}
|
|
94
|
+
}
|