@contentstack/cli-cm-import 1.29.0 → 1.30.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 +125 -67
- package/lib/commands/cm/stacks/import.js +8 -6
- package/lib/config/index.js +7 -0
- package/lib/import/modules/assets.js +18 -18
- package/lib/import/modules/composable-studio.d.ts +43 -0
- package/lib/import/modules/composable-studio.js +231 -0
- package/lib/import/modules/content-types.js +9 -9
- package/lib/import/modules/custom-roles.js +24 -24
- package/lib/import/modules/entries.js +35 -18
- package/lib/import/modules/environments.js +10 -10
- package/lib/import/modules/extensions.js +16 -16
- package/lib/import/modules/global-fields.js +13 -13
- package/lib/import/modules/labels.js +12 -12
- package/lib/import/modules/locales.js +21 -21
- package/lib/import/modules/marketplace-apps.js +53 -53
- package/lib/import/modules/personalize.js +11 -11
- package/lib/import/modules/taxonomies.js +10 -10
- package/lib/import/modules-js/entries.js +1 -1
- package/lib/import/modules-js/marketplace-apps.js +2 -2
- package/lib/types/default-config.d.ts +6 -0
- package/lib/types/index.d.ts +27 -1
- package/lib/utils/content-type-helper.js +2 -2
- package/lib/utils/file-helper.js +1 -1
- package/lib/utils/import-config-handler.js +2 -2
- package/lib/utils/login-handler.js +1 -1
- package/lib/utils/marketplace-app-helper.js +1 -1
- package/lib/utils/taxonomies-helper.js +1 -1
- package/messages/index.json +10 -1
- package/oclif.manifest.json +2 -2
- package/package.json +5 -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/1.
|
|
50
|
+
@contentstack/cli-cm-import/1.30.0 linux-x64 node-v22.21.1
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -71,39 +71,68 @@ USAGE
|
|
|
71
71
|
[--backup-dir <value>] [--branch <value>] [--import-webhook-status disable|current]
|
|
72
72
|
|
|
73
73
|
FLAGS
|
|
74
|
-
-B, --branch=<value>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
74
|
+
-B, --branch=<value>
|
|
75
|
+
The name of the branch where you want to import your content. If you don't mention the branch name, then by default
|
|
76
|
+
the content will be imported to the main branch.
|
|
77
|
+
|
|
78
|
+
-a, --alias=<value>
|
|
79
|
+
The management token of the destination stack where you will import the content.
|
|
80
|
+
|
|
81
|
+
-b, --backup-dir=<value>
|
|
82
|
+
[optional] Backup directory name when using specific module.
|
|
83
|
+
|
|
84
|
+
-c, --config=<value>
|
|
85
|
+
[optional] The path of the configuration JSON file containing all the options for a single run.
|
|
86
|
+
|
|
87
|
+
-d, --data-dir=<value>
|
|
88
|
+
The path or the location in your file system where the content, you intend to import, is stored. For example, -d
|
|
89
|
+
"C:\Users\Name\Desktop\cli\content". If the export folder has branches involved, then the path should point till the
|
|
90
|
+
particular branch. For example, “-d "C:\Users\Name\Desktop\cli\content\branch_name"
|
|
91
|
+
|
|
92
|
+
-k, --stack-api-key=<value>
|
|
93
|
+
API Key of the target stack
|
|
94
|
+
|
|
95
|
+
-m, --module=<value>
|
|
96
|
+
[optional] Specify the module to import into the target stack. If not specified, the import command will import all
|
|
97
|
+
the modules into the stack. The available modules are assets, content-types, entries, environments, extensions,
|
|
98
|
+
marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, personalize projects,
|
|
99
|
+
taxonomies, and composable-studio.
|
|
100
|
+
|
|
101
|
+
-y, --yes
|
|
102
|
+
[optional] Force override all Marketplace prompts.
|
|
103
|
+
|
|
104
|
+
--branch-alias=<value>
|
|
105
|
+
Specify the branch alias where you want to import your content. If not specified, the content is imported into the
|
|
106
|
+
main branch by default.
|
|
107
|
+
|
|
108
|
+
--exclude-global-modules
|
|
109
|
+
Excludes the branch-independent module from the import operation.
|
|
110
|
+
|
|
111
|
+
--import-webhook-status=<option>
|
|
112
|
+
[default: disable] [default: disable] (optional) This webhook state keeps the same state of webhooks as the source
|
|
113
|
+
stack. <options: disable|current>
|
|
114
|
+
<options: disable|current>
|
|
115
|
+
|
|
116
|
+
--personalize-project-name=<value>
|
|
117
|
+
(optional) Provide a unique name for the Personalize project.
|
|
118
|
+
|
|
119
|
+
--replace-existing
|
|
120
|
+
Replaces the existing module in the target stack.
|
|
121
|
+
|
|
122
|
+
--skip-app-recreation
|
|
123
|
+
(optional) Skips the recreation of private apps if they already exist.
|
|
124
|
+
|
|
125
|
+
--skip-assets-publish
|
|
126
|
+
Skips asset publishing during the import process.
|
|
127
|
+
|
|
128
|
+
--skip-audit
|
|
129
|
+
Skips the audit fix that occurs during an import operation.
|
|
130
|
+
|
|
131
|
+
--skip-entries-publish
|
|
132
|
+
Skips entry publishing during the import process
|
|
133
|
+
|
|
134
|
+
--skip-existing
|
|
135
|
+
Skips the module exists warning messages.
|
|
107
136
|
|
|
108
137
|
DESCRIPTION
|
|
109
138
|
Import content from a stack
|
|
@@ -139,39 +168,68 @@ USAGE
|
|
|
139
168
|
<value>] [--branch <value>] [--import-webhook-status disable|current]
|
|
140
169
|
|
|
141
170
|
FLAGS
|
|
142
|
-
-B, --branch=<value>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
-B, --branch=<value>
|
|
172
|
+
The name of the branch where you want to import your content. If you don't mention the branch name, then by default
|
|
173
|
+
the content will be imported to the main branch.
|
|
174
|
+
|
|
175
|
+
-a, --alias=<value>
|
|
176
|
+
The management token of the destination stack where you will import the content.
|
|
177
|
+
|
|
178
|
+
-b, --backup-dir=<value>
|
|
179
|
+
[optional] Backup directory name when using specific module.
|
|
180
|
+
|
|
181
|
+
-c, --config=<value>
|
|
182
|
+
[optional] The path of the configuration JSON file containing all the options for a single run.
|
|
183
|
+
|
|
184
|
+
-d, --data-dir=<value>
|
|
185
|
+
The path or the location in your file system where the content, you intend to import, is stored. For example, -d
|
|
186
|
+
"C:\Users\Name\Desktop\cli\content". If the export folder has branches involved, then the path should point till the
|
|
187
|
+
particular branch. For example, “-d "C:\Users\Name\Desktop\cli\content\branch_name"
|
|
188
|
+
|
|
189
|
+
-k, --stack-api-key=<value>
|
|
190
|
+
API Key of the target stack
|
|
191
|
+
|
|
192
|
+
-m, --module=<value>
|
|
193
|
+
[optional] Specify the module to import into the target stack. If not specified, the import command will import all
|
|
194
|
+
the modules into the stack. The available modules are assets, content-types, entries, environments, extensions,
|
|
195
|
+
marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, personalize projects,
|
|
196
|
+
taxonomies, and composable-studio.
|
|
197
|
+
|
|
198
|
+
-y, --yes
|
|
199
|
+
[optional] Force override all Marketplace prompts.
|
|
200
|
+
|
|
201
|
+
--branch-alias=<value>
|
|
202
|
+
Specify the branch alias where you want to import your content. If not specified, the content is imported into the
|
|
203
|
+
main branch by default.
|
|
204
|
+
|
|
205
|
+
--exclude-global-modules
|
|
206
|
+
Excludes the branch-independent module from the import operation.
|
|
207
|
+
|
|
208
|
+
--import-webhook-status=<option>
|
|
209
|
+
[default: disable] [default: disable] (optional) This webhook state keeps the same state of webhooks as the source
|
|
210
|
+
stack. <options: disable|current>
|
|
211
|
+
<options: disable|current>
|
|
212
|
+
|
|
213
|
+
--personalize-project-name=<value>
|
|
214
|
+
(optional) Provide a unique name for the Personalize project.
|
|
215
|
+
|
|
216
|
+
--replace-existing
|
|
217
|
+
Replaces the existing module in the target stack.
|
|
218
|
+
|
|
219
|
+
--skip-app-recreation
|
|
220
|
+
(optional) Skips the recreation of private apps if they already exist.
|
|
221
|
+
|
|
222
|
+
--skip-assets-publish
|
|
223
|
+
Skips asset publishing during the import process.
|
|
224
|
+
|
|
225
|
+
--skip-audit
|
|
226
|
+
Skips the audit fix that occurs during an import operation.
|
|
227
|
+
|
|
228
|
+
--skip-entries-publish
|
|
229
|
+
Skips entry publishing during the import process
|
|
230
|
+
|
|
231
|
+
--skip-existing
|
|
232
|
+
Skips the module exists warning messages.
|
|
175
233
|
|
|
176
234
|
DESCRIPTION
|
|
177
235
|
Import content from a stack
|
|
@@ -17,7 +17,7 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
17
17
|
// Prepare the context object
|
|
18
18
|
const context = this.createImportContext(importConfig.apiKey, importConfig.authenticationMethod);
|
|
19
19
|
importConfig.context = Object.assign({}, context);
|
|
20
|
-
//log.info(`Using
|
|
20
|
+
// log.info(`Using CLI version: ${this.context?.cliVersion}`, importConfig.context);
|
|
21
21
|
// Note setting host to create cma client
|
|
22
22
|
importConfig.host = this.cmaHost;
|
|
23
23
|
importConfig.region = this.region;
|
|
@@ -25,6 +25,8 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
25
25
|
importConfig.developerHubBaseUrl = this.developerHubUrl;
|
|
26
26
|
if (this.personalizeUrl)
|
|
27
27
|
importConfig.modules.personalize.baseURL[importConfig.region.name] = this.personalizeUrl;
|
|
28
|
+
if (this.composableStudioUrl)
|
|
29
|
+
importConfig.modules['composable-studio'].apiBaseUrl = this.composableStudioUrl;
|
|
28
30
|
const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)(importConfig);
|
|
29
31
|
const moduleImporter = new import_1.ModuleImporter(managementAPIClient, importConfig);
|
|
30
32
|
const result = await moduleImporter.start();
|
|
@@ -35,14 +37,14 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
35
37
|
: `The content has been imported to the stack ${importConfig.apiKey} successfully!`;
|
|
36
38
|
cli_utilities_1.log.success(successMessage, importConfig.context);
|
|
37
39
|
}
|
|
38
|
-
cli_utilities_1.log.success(`The log has been stored at
|
|
39
|
-
cli_utilities_1.log.info(`The backup content has been stored at
|
|
40
|
+
cli_utilities_1.log.success(`The log has been stored at: ${(0, cli_utilities_1.getLogPath)()}`, importConfig.context);
|
|
41
|
+
cli_utilities_1.log.info(`The backup content has been stored at: ${backupDir}`, importConfig.context);
|
|
40
42
|
}
|
|
41
43
|
catch (error) {
|
|
42
44
|
(0, cli_utilities_1.handleAndLogError)(error);
|
|
43
45
|
cli_utilities_1.log.info(`The log has been stored at '${(0, cli_utilities_1.getLogPath)()}'`);
|
|
44
46
|
if (importConfig === null || importConfig === void 0 ? void 0 : importConfig.backupDir) {
|
|
45
|
-
cli_utilities_1.log.info(`The backup content has been stored at
|
|
47
|
+
cli_utilities_1.log.info(`The backup content has been stored at: ${importConfig === null || importConfig === void 0 ? void 0 : importConfig.backupDir}`);
|
|
46
48
|
}
|
|
47
49
|
else {
|
|
48
50
|
cli_utilities_1.log.info('No backup directory was created due to early termination');
|
|
@@ -118,7 +120,7 @@ ImportCommand.flags = {
|
|
|
118
120
|
module: cli_utilities_1.flags.string({
|
|
119
121
|
required: false,
|
|
120
122
|
char: 'm',
|
|
121
|
-
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
|
|
123
|
+
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.',
|
|
122
124
|
parse: (0, cli_utilities_1.printFlagDeprecation)(['-m'], ['--module']),
|
|
123
125
|
}),
|
|
124
126
|
'backup-dir': cli_utilities_1.flags.string({
|
|
@@ -133,7 +135,7 @@ ImportCommand.flags = {
|
|
|
133
135
|
exclusive: ['branch-alias'],
|
|
134
136
|
}),
|
|
135
137
|
'branch-alias': cli_utilities_1.flags.string({
|
|
136
|
-
description:
|
|
138
|
+
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
139
|
exclusive: ['branch'],
|
|
138
140
|
}),
|
|
139
141
|
'import-webhook-status': cli_utilities_1.flags.string({
|
package/lib/config/index.js
CHANGED
|
@@ -44,6 +44,7 @@ const config = {
|
|
|
44
44
|
'variant-entries',
|
|
45
45
|
'labels',
|
|
46
46
|
'webhooks',
|
|
47
|
+
'composable-studio',
|
|
47
48
|
],
|
|
48
49
|
locales: {
|
|
49
50
|
dirName: 'locales',
|
|
@@ -199,6 +200,12 @@ const config = {
|
|
|
199
200
|
locale: 'en-us',
|
|
200
201
|
},
|
|
201
202
|
},
|
|
203
|
+
'composable-studio': {
|
|
204
|
+
dirName: 'composable_studio',
|
|
205
|
+
fileName: 'composable_studio.json',
|
|
206
|
+
apiBaseUrl: 'https://composable-studio-api.contentstack.com',
|
|
207
|
+
apiVersion: 'v1',
|
|
208
|
+
},
|
|
202
209
|
},
|
|
203
210
|
languagesCode: [
|
|
204
211
|
'af-za',
|
|
@@ -41,25 +41,25 @@ class ImportAssets extends base_class_1.default {
|
|
|
41
41
|
async start() {
|
|
42
42
|
try {
|
|
43
43
|
// NOTE Step 1: Import folders and create uid mapping file
|
|
44
|
-
cli_utilities_1.log.debug('Starting folder import process', this.importConfig.context);
|
|
44
|
+
cli_utilities_1.log.debug('Starting folder import process...', this.importConfig.context);
|
|
45
45
|
await this.importFolders();
|
|
46
46
|
// NOTE Step 2: Import versioned assets and create it mapping files (uid, url)
|
|
47
47
|
if (this.assetConfig.includeVersionedAssets) {
|
|
48
48
|
const versionsPath = `${this.assetsPath}/versions`;
|
|
49
49
|
if ((0, node_fs_1.existsSync)(versionsPath)) {
|
|
50
|
-
cli_utilities_1.log.debug('Starting versioned assets import', this.importConfig.context);
|
|
50
|
+
cli_utilities_1.log.debug('Starting versioned assets import...', this.importConfig.context);
|
|
51
51
|
await this.importAssets(true);
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
cli_utilities_1.log.info('No
|
|
54
|
+
cli_utilities_1.log.info('No versioned assets found to import.', this.importConfig.context);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
// NOTE Step 3: Import Assets and create it mapping files (uid, url)
|
|
58
|
-
cli_utilities_1.log.debug('Starting assets import', this.importConfig.context);
|
|
58
|
+
cli_utilities_1.log.debug('Starting assets import...', this.importConfig.context);
|
|
59
59
|
await this.importAssets();
|
|
60
60
|
// NOTE Step 4: Publish assets
|
|
61
61
|
if (!this.importConfig.skipAssetsPublish) {
|
|
62
|
-
cli_utilities_1.log.debug('Starting assets publishing', this.importConfig.context);
|
|
62
|
+
cli_utilities_1.log.debug('Starting assets publishing...', this.importConfig.context);
|
|
63
63
|
await this.publish();
|
|
64
64
|
}
|
|
65
65
|
cli_utilities_1.log.success('Assets imported successfully!', this.importConfig.context);
|
|
@@ -77,19 +77,19 @@ class ImportAssets extends base_class_1.default {
|
|
|
77
77
|
cli_utilities_1.log.debug(`Reading folders from: ${foldersPath}`, this.importConfig.context);
|
|
78
78
|
const folders = this.fs.readFile(foldersPath);
|
|
79
79
|
if ((0, isEmpty_1.default)(folders)) {
|
|
80
|
-
cli_utilities_1.log.info('No folders found to import', this.importConfig.context);
|
|
80
|
+
cli_utilities_1.log.info('No folders found to import.', this.importConfig.context);
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
cli_utilities_1.log.debug(`Found ${folders.length} folders to import
|
|
83
|
+
cli_utilities_1.log.debug(`Found ${folders.length} folders to import.`, this.importConfig.context);
|
|
84
84
|
const batches = this.constructFolderImportOrder(folders);
|
|
85
|
-
cli_utilities_1.log.debug(`Organized folders into ${batches.length} batches for import
|
|
85
|
+
cli_utilities_1.log.debug(`Organized folders into ${batches.length} batches for import.`, this.importConfig.context);
|
|
86
86
|
const onSuccess = ({ response, apiData: { uid, name } = { uid: null, name: '' } }) => {
|
|
87
87
|
this.assetsFolderMap[uid] = response.uid;
|
|
88
|
-
cli_utilities_1.log.debug(`Created folder: ${name} (Mapped ${uid} → ${response.uid})
|
|
88
|
+
cli_utilities_1.log.debug(`Created folder: ${name} (Mapped ${uid} → ${response.uid}).`, this.importConfig.context);
|
|
89
89
|
cli_utilities_1.log.success(`Created folder: '${name}'`, this.importConfig.context);
|
|
90
90
|
};
|
|
91
91
|
const onReject = ({ error, apiData: { name } = { name: '' } }) => {
|
|
92
|
-
cli_utilities_1.log.error(`${name} folder creation failed
|
|
92
|
+
cli_utilities_1.log.error(`${name} folder creation failed.`, this.importConfig.context);
|
|
93
93
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { name }));
|
|
94
94
|
};
|
|
95
95
|
const serializeData = (apiOptions) => {
|
|
@@ -101,7 +101,7 @@ class ImportAssets extends base_class_1.default {
|
|
|
101
101
|
return apiOptions;
|
|
102
102
|
};
|
|
103
103
|
const batch = (0, map_1.default)((0, unionBy_1.default)(batches, 'parent_uid'), 'parent_uid');
|
|
104
|
-
cli_utilities_1.log.debug(`Processing ${batch.length} folder batches
|
|
104
|
+
cli_utilities_1.log.debug(`Processing ${batch.length} folder batches.`, this.importConfig.context);
|
|
105
105
|
for (const parent_uid of batch) {
|
|
106
106
|
const currentBatch = (0, filter_1.default)(batches, { parent_uid });
|
|
107
107
|
cli_utilities_1.log.debug(`Processing batch with parent_uid: ${parent_uid} (${currentBatch.length} folders)`, this.importConfig.context);
|
|
@@ -146,7 +146,7 @@ class ImportAssets extends base_class_1.default {
|
|
|
146
146
|
cli_utilities_1.log.success(`Created asset: '${title}'`, this.importConfig.context);
|
|
147
147
|
};
|
|
148
148
|
const onReject = ({ error, apiData: { title } = undefined }) => {
|
|
149
|
-
cli_utilities_1.log.error(`${title} asset upload failed
|
|
149
|
+
cli_utilities_1.log.error(`${title} asset upload failed.`, this.importConfig.context);
|
|
150
150
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.importConfig.context), { title }));
|
|
151
151
|
};
|
|
152
152
|
/* eslint-disable @typescript-eslint/no-unused-vars, guard-for-in */
|
|
@@ -159,7 +159,7 @@ class ImportAssets extends base_class_1.default {
|
|
|
159
159
|
let apiContent = (0, orderBy_1.default)((0, values_1.default)(chunk), '_version');
|
|
160
160
|
cli_utilities_1.log.debug(`Processing ${apiContent.length} assets in chunk`, this.importConfig.context);
|
|
161
161
|
if (isVersion && this.assetConfig.importSameStructure) {
|
|
162
|
-
cli_utilities_1.log.debug('Processing version 1 assets first', this.importConfig.context);
|
|
162
|
+
cli_utilities_1.log.debug('Processing version 1 assets first...', this.importConfig.context);
|
|
163
163
|
const versionOneAssets = (0, filter_1.default)(apiContent, ({ _version }) => _version === 1);
|
|
164
164
|
await this.makeConcurrentCall({
|
|
165
165
|
processName,
|
|
@@ -247,7 +247,7 @@ class ImportAssets extends base_class_1.default {
|
|
|
247
247
|
async publish() {
|
|
248
248
|
const fs = new cli_utilities_1.FsUtility({ basePath: this.assetsPath, indexFileName: 'assets.json' });
|
|
249
249
|
if ((0, isEmpty_1.default)(this.assetsUidMap)) {
|
|
250
|
-
cli_utilities_1.log.debug('Loading asset UID mappings from file', this.importConfig.context);
|
|
250
|
+
cli_utilities_1.log.debug('Loading asset UID mappings from file...', this.importConfig.context);
|
|
251
251
|
this.assetsUidMap = fs.readFile(this.assetUidMapperPath, true);
|
|
252
252
|
}
|
|
253
253
|
const indexer = fs.indexFileContent;
|
|
@@ -270,7 +270,7 @@ class ImportAssets extends base_class_1.default {
|
|
|
270
270
|
const environments = (0, uniq_1.default)((0, map_1.default)(publishDetails, ({ environment }) => this.environments[environment].name));
|
|
271
271
|
const locales = (0, uniq_1.default)((0, map_1.default)(publishDetails, 'locale'));
|
|
272
272
|
if (environments.length === 0 || locales.length === 0) {
|
|
273
|
-
cli_utilities_1.log.debug(`Skipping publish for asset ${asset.uid}
|
|
273
|
+
cli_utilities_1.log.debug(`Skipping publish for asset ${asset.uid}: no valid environments/locales`, this.importConfig.context);
|
|
274
274
|
apiOptions.entity = undefined;
|
|
275
275
|
return apiOptions;
|
|
276
276
|
}
|
|
@@ -281,7 +281,7 @@ class ImportAssets extends base_class_1.default {
|
|
|
281
281
|
}
|
|
282
282
|
apiOptions.uid = this.assetsUidMap[asset.uid];
|
|
283
283
|
if (!apiOptions.uid) {
|
|
284
|
-
cli_utilities_1.log.debug(`Skipping publish for asset ${asset.uid}
|
|
284
|
+
cli_utilities_1.log.debug(`Skipping publish for asset ${asset.uid}: no UID mapping found.`, this.importConfig.context);
|
|
285
285
|
apiOptions.entity = undefined;
|
|
286
286
|
}
|
|
287
287
|
return apiOptions;
|
|
@@ -328,7 +328,7 @@ class ImportAssets extends base_class_1.default {
|
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
330
|
if (this.importConfig.replaceExisting) {
|
|
331
|
-
cli_utilities_1.log.debug('Setting up root folder for import', this.importConfig.context);
|
|
331
|
+
cli_utilities_1.log.debug('Setting up root folder for import...', this.importConfig.context);
|
|
332
332
|
// Note: adds a root folder to distinguish latest asset uploads
|
|
333
333
|
// Todo: This temporary approach should be updated with asset and folder overwrite strategy, which follows
|
|
334
334
|
// folder overwrite
|
|
@@ -350,7 +350,7 @@ class ImportAssets extends base_class_1.default {
|
|
|
350
350
|
}
|
|
351
351
|
});
|
|
352
352
|
importOrder.unshift(this.rootFolder);
|
|
353
|
-
cli_utilities_1.log.debug('Added root folder to import order', this.importConfig.context);
|
|
353
|
+
cli_utilities_1.log.debug('Added root folder to import order.', this.importConfig.context);
|
|
354
354
|
}
|
|
355
355
|
return importOrder;
|
|
356
356
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ModuleClassParams, ComposableStudioProject } from '../../types';
|
|
2
|
+
export default class ImportComposableStudio {
|
|
3
|
+
private importConfig;
|
|
4
|
+
private composableStudioConfig;
|
|
5
|
+
private composableStudioPath;
|
|
6
|
+
private composableStudioFilePath;
|
|
7
|
+
private apiClient;
|
|
8
|
+
private envUidMapperPath;
|
|
9
|
+
private envUidMapper;
|
|
10
|
+
constructor({ importConfig }: ModuleClassParams);
|
|
11
|
+
/**
|
|
12
|
+
* Entry point for Composable Studio import
|
|
13
|
+
*/
|
|
14
|
+
start(): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Initialize authentication headers for API calls
|
|
17
|
+
*/
|
|
18
|
+
addAuthHeaders(): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Load environment UID mapper from backup directory
|
|
21
|
+
*/
|
|
22
|
+
loadEnvironmentMapper(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Read exported project from file system
|
|
25
|
+
*/
|
|
26
|
+
readExportedProject(): Promise<ComposableStudioProject | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Check if target stack already has a connected project
|
|
29
|
+
*/
|
|
30
|
+
getExistingProject(): Promise<ComposableStudioProject | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Import project with name conflict handling
|
|
33
|
+
*/
|
|
34
|
+
importProject(exportedProject: ComposableStudioProject): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Map environment UID from source to target
|
|
37
|
+
*/
|
|
38
|
+
mapEnvironmentUid(sourceEnvUid: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Prompt user for a new project name when conflict occurs
|
|
41
|
+
*/
|
|
42
|
+
promptForNewProjectName(currentName: string): Promise<string>;
|
|
43
|
+
}
|