Skip to content

Commit d835006

Browse files
authored
Merge pull request #2077 from contentstack/feat/DX-3380
feat: Integrated CLIProgressManager and SummaryManager across CT, custom-roles, entries, labels, etc. Added Strategy pattern implementation in utilities plugin
2 parents 3cd2bbb + 4b0671c commit d835006

46 files changed

Lines changed: 2696 additions & 1133 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.talismanrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,14 @@ fileignoreconfig:
3737
checksum: 449a5e3383631a6f78d1291aa3c28c91681879289398f0a933158fba5c5d5acf
3838
- filename: packages/contentstack-import/src/commands/cm/stacks/import.ts
3939
checksum: 0dbf0a6bc447206260b8acd41b85781d60ca50c948bb3ca62f444f97d64d1fb2
40+
- filename: packages/contentstack-utilities/src/interfaces/index.ts
41+
checksum: d0b0042e643ce0c0489b86f15f3b64f60a837c2ae928b6275028e5e0184b0a7a
42+
- filename: packages/contentstack-variants/src/import/attribute.ts
43+
checksum: 03e764ee2032c44d9493f2be194f91a2337026b7fd8037df90240327e6bcaabb
44+
- filename: packages/contentstack-variants/src/import/audiences.ts
45+
checksum: f24697ef86e928bb4d16f93c021b647639cc344a7f02463d79d69f9434ebed56
46+
- filename: packages/contentstack-variants/src/import/events.ts
47+
checksum: 6cb014b5518ffe204a9f894ad801c05e2ef91a1692049168f74dd12a224363c4
48+
- filename: packages/contentstack-import/src/import/modules/personalize.ts
49+
checksum: 1311a613177160637e21b3983b281b384c2cb15837d001a398b67afef30a393a
4050
version: "1.0"

packages/contentstack-export/src/export/module-exporter.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ class ModuleExporter {
5050
// Reset progress manager for each branch (except the first one which was initialized in export command)
5151
if (index >= 0) {
5252
CLIProgressManager.clearGlobalSummary();
53-
CLIProgressManager.initializeGlobalSummary(`EXPORT-${branch.uid}`, branch.uid, `EXPORTING "${branch.uid}" BRANCH CONTENT`,);
54-
53+
CLIProgressManager.initializeGlobalSummary(
54+
`EXPORT-${branch.uid}`,
55+
branch.uid,
56+
`EXPORTING "${branch.uid}" BRANCH CONTENT`,
57+
);
5558
}
5659

5760
log.info(`Exporting content from branch ${branch.uid}`, this.exportConfig.context);
@@ -97,7 +100,7 @@ class ModuleExporter {
97100
} else {
98101
//NOTE - new modules support only ts
99102
if (this.exportConfig.onlyTSModules.indexOf(moduleName) === -1) {
100-
await startJSModuleExport({
103+
await startJSModuleExport({
101104
stackAPIClient: this.stackAPIClient,
102105
exportConfig: this.exportConfig,
103106
moduleName,

packages/contentstack-export/src/export/modules/assets.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,41 +64,41 @@ export default class ExportAssets extends BaseClass {
6464

6565
// Add sub-processes
6666
if (typeof assetsFolderCount === 'number' && assetsFolderCount > 0) {
67-
progress.addProcess('Asset Folders', assetsFolderCount);
67+
progress.addProcess('Folders', assetsFolderCount);
6868
}
6969
if (typeof assetsCount === 'number' && assetsCount > 0) {
70-
progress.addProcess('Asset Metadata', assetsCount);
71-
progress.addProcess('Asset Downloads', assetsCount);
70+
progress.addProcess('Metadata', assetsCount);
71+
progress.addProcess('Downloads', assetsCount);
7272
}
7373

7474
try {
7575
// Process asset folders
7676
if (typeof assetsFolderCount === 'number' && assetsFolderCount > 0) {
77-
progress.startProcess('Asset Folders').updateStatus('Fetching folder structure...', 'Asset Folders');
77+
progress.startProcess('Folders').updateStatus('Fetching folder structure...', 'Folders');
7878
await this.getAssetsFolders(assetsFolderCount);
79-
progress.completeProcess('Asset Folders', true);
79+
progress.completeProcess('Folders', true);
8080
}
8181

8282
// Process asset metadata
8383
if (typeof assetsCount === 'number' && assetsCount > 0) {
84-
progress.startProcess('Asset Metadata').updateStatus('Fetching asset information...', 'Asset Metadata');
84+
progress.startProcess('Metadata').updateStatus('Fetching asset information...', 'Metadata');
8585
await this.getAssets(assetsCount);
86-
progress.completeProcess('Asset Metadata', true);
86+
progress.completeProcess('Metadata', true);
8787
}
8888

8989
// Get versioned assets
9090
if (!isEmpty(this.versionedAssets) && this.assetConfig.includeVersionedAssets) {
9191
log.debug('Fetching versioned assets metadata...', this.exportConfig.context);
92-
progress.updateStatus('Processing versioned assets...', 'Asset Metadata');
92+
progress.updateStatus('Processing versioned assets...', 'Metadata');
9393
await this.getVersionedAssets();
9494
}
9595

9696
// Download all assets
9797
if (typeof assetsCount === 'number' && assetsCount > 0) {
98-
progress.startProcess('Asset Downloads').updateStatus('Downloading asset files...', 'Asset Downloads');
98+
progress.startProcess('Downloads').updateStatus('Downloading asset files...', 'Downloads');
9999
log.debug('Starting download of all assets...', this.exportConfig.context);
100100
await this.downloadAssets();
101-
progress.completeProcess('Asset Downloads', true);
101+
progress.completeProcess('Downloads', true);
102102
}
103103

104104
this.completeProgress(true);
@@ -128,13 +128,13 @@ export default class ExportAssets extends BaseClass {
128128
if (!isEmpty(items)) {
129129
this.assetsFolder.push(...items);
130130
items.forEach((folder: any) => {
131-
this.progressManager?.tick(true, `folder: ${folder.name || folder.uid}`, null, 'Asset Folders');
131+
this.progressManager?.tick(true, `folder: ${folder.name || folder.uid}`, null, 'Folders');
132132
});
133133
}
134134
};
135135

136136
const onReject = ({ error }: any) => {
137-
this.progressManager?.tick(false, 'asset folder', error?.message || 'Failed to fetch folder', 'Asset Folders');
137+
this.progressManager?.tick(false, 'asset folder', error?.message || 'Failed to fetch folder', 'Folders');
138138
handleAndLogError(error, { ...this.exportConfig.context });
139139
};
140140

@@ -197,7 +197,7 @@ export default class ExportAssets extends BaseClass {
197197
}
198198

199199
const onReject = ({ error }: any) => {
200-
this.progressManager?.tick(false, 'asset', error?.message || 'Failed to fetch asset', 'Asset Metadata');
200+
this.progressManager?.tick(false, 'asset', error?.message || 'Failed to fetch asset', 'Metadata');
201201
handleAndLogError(error, { ...this.exportConfig.context }, messageHandler.parse('ASSET_QUERY_FAILED'));
202202
};
203203

@@ -219,7 +219,7 @@ export default class ExportAssets extends BaseClass {
219219
fs?.writeIntoFile(items, { mapKeyVal: true });
220220
// Track progress for each asset with process name
221221
items.forEach((asset: any) => {
222-
this.progressManager?.tick(true, `asset: ${asset.filename || asset.uid}`, null, 'Asset Metadata');
222+
this.progressManager?.tick(true, `asset: ${asset.filename || asset.uid}`, null, 'Metadata');
223223
});
224224
}
225225
};
@@ -418,7 +418,7 @@ export default class ExportAssets extends BaseClass {
418418
} else {
419419
data.pipe(assetWriterStream);
420420
}
421-
this.progressManager?.tick(true, `Downloaded asset: ${asset.filename || asset.uid}`, null, 'Asset Downloads');
421+
this.progressManager?.tick(true, `Downloaded asset: ${asset.filename || asset.uid}`, null, 'Downloads');
422422
log.success(messageHandler.parse('ASSET_DOWNLOAD_SUCCESS', asset.filename, asset.uid), this.exportConfig.context);
423423
};
424424

@@ -428,7 +428,7 @@ export default class ExportAssets extends BaseClass {
428428
false,
429429
`Failed to download asset: ${asset.filename || asset.uid}`,
430430
null,
431-
'Asset Downloads',
431+
'Downloads',
432432
);
433433
handleAndLogError(
434434
error,

packages/contentstack-export/src/export/modules/entries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default class EntriesExport extends BaseClass {
109109
}
110110

111111
if (this.exportVariantEntry) {
112-
progress.addProcess('Variant Entries', totalEntriesCount);
112+
progress.addProcess('Variant Entries', 0);
113113
}
114114
}
115115

packages/contentstack-export/src/export/modules/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { handleAndLogError } from '@contentstack/cli-utilities';
22
import { ModuleClassParams } from '../../types';
3+
import '../../utils/strategy-registrations';
34

45
export default async function startModuleExport(modulePayload: ModuleClassParams) {
56
try {

packages/contentstack-export/src/export/modules/marketplace-apps.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ export default class ExportMarketplaceApps extends BaseClass {
7171
const progress = this.createNestedProgress(this.currentModuleName);
7272

7373
// Add processes based on what we found
74-
progress.addProcess('Apps Fetch', appsCount);
75-
progress.addProcess('App Processing', appsCount); // Manifests and configurations
74+
progress.addProcess('Fetch', appsCount);
75+
progress.addProcess('Fetch config & manifest', appsCount); // Manifests and configurations
7676

7777
// Fetch stack specific apps
78-
progress.startProcess('Apps Fetch').updateStatus('Fetching marketplace apps...', 'Apps Fetch');
78+
progress.startProcess('Fetch').updateStatus('Fetching marketplace apps...', 'Fetch');
7979
await this.exportApps();
80-
progress.completeProcess('Apps Fetch', true);
80+
progress.completeProcess('Fetch', true);
8181

8282
// Process apps (manifests and configurations)
8383
if (this.installedApps.length > 0) {
84-
progress.startProcess('App Processing').updateStatus('Processing app manifests and configurations...', 'App Processing');
84+
progress.startProcess('Fetch config & manifest').updateStatus('Processing app manifests and configurations...', 'Fetch config & manifest');
8585
await this.getAppManifestAndAppConfig();
86-
progress.completeProcess('App Processing', true);
86+
progress.completeProcess('Fetch config & manifest', true);
8787
}
8888

8989
this.completeProgress(true);
@@ -196,7 +196,7 @@ export default class ExportMarketplaceApps extends BaseClass {
196196
await this.getAppConfigurations(+index, app);
197197

198198
// Track progress for each app processed
199-
this.progressManager?.tick(true, `app: ${app.manifest?.name || app.uid}`, null, 'App Processing');
199+
this.progressManager?.tick(true, `app: ${app.manifest?.name || app.uid}`, null, 'Fetch config & manifest');
200200
}
201201

202202
const marketplaceAppsFilePath = pResolve(this.marketplaceAppPath, this.marketplaceAppConfig.fileName);
@@ -346,7 +346,7 @@ export default class ExportMarketplaceApps extends BaseClass {
346346

347347
// Track progress for each app fetched
348348
installation.forEach((app) => {
349-
this.progressManager?.tick(true, `app: ${app.manifest?.name || app.uid}`, null, 'Apps Fetch');
349+
this.progressManager?.tick(true, `app: ${app.manifest?.name || app.uid}`, null, 'Fetch');
350350
});
351351

352352
this.installedApps = this.installedApps.concat(installation);

packages/contentstack-export/src/export/modules/stack.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default class ExportStack extends BaseClass {
5858
}
5959

6060
if (!this.exportConfig.management_token) {
61-
progress.addProcess('Stack Settings', 1);
61+
progress.addProcess('Settings', 1);
6262
processCount++;
6363
}
6464

@@ -67,18 +67,18 @@ export default class ExportStack extends BaseClass {
6767
!this.exportConfig.hasOwnProperty('master_locale') &&
6868
localesCount > 0
6969
) {
70-
progress.addProcess('Locales', localesCount);
70+
progress.addProcess('Locale', localesCount);
7171
processCount++;
7272
} else if (this.exportConfig.preserveStackVersion) {
73-
progress.addProcess('Stack Export', 1);
73+
progress.addProcess('Details', 1);
7474
processCount++;
7575
}
7676

7777
// Execute processes
7878
if (!this.exportConfig.management_token) {
79-
progress.startProcess('Stack Settings').updateStatus('Exporting stack settings...', 'Stack Settings');
79+
progress.startProcess('Settings').updateStatus('Exporting stack settings...', 'Settings');
8080
await this.exportStackSettings();
81-
progress.completeProcess('Stack Settings', true);
81+
progress.completeProcess('Settings', true);
8282
} else {
8383
log.info(
8484
'Skipping stack settings export: Operation is not supported when using a management token.',
@@ -91,9 +91,9 @@ export default class ExportStack extends BaseClass {
9191
!this.exportConfig.hasOwnProperty('master_locale') &&
9292
localesCount > 0
9393
) {
94-
progress.startProcess('Locales').updateStatus('Fetching master locale...', 'Locales');
94+
progress.startProcess('Locale').updateStatus('Fetching master locale...', 'Locale');
9595
const masterLocale = await this.getLocales();
96-
progress.completeProcess('Locales', true);
96+
progress.completeProcess('Locale', true);
9797

9898
if (masterLocale?.code) {
9999
this.exportConfig.master_locale = { code: masterLocale.code };
@@ -103,14 +103,14 @@ export default class ExportStack extends BaseClass {
103103
this.completeProgress(true);
104104
return masterLocale;
105105
} else if (this.exportConfig.preserveStackVersion) {
106-
progress.startProcess('Stack Export').updateStatus('Exporting stack data...', 'Stack Export');
106+
progress.startProcess('Details').updateStatus('Exporting stack data...', 'Details');
107107
const stackResult = await this.exportStack();
108-
progress.completeProcess('Stack Export', true);
108+
progress.completeProcess('Details', true);
109109

110110
this.completeProgress(true);
111111
return stackResult;
112112
} else {
113-
log.debug('Master locale already set, skipping locale fetch', this.exportConfig.context);
113+
log.debug('Locale locale already set, skipping locale fetch', this.exportConfig.context);
114114
}
115115

116116
this.completeProgress(true);
@@ -185,7 +185,7 @@ export default class ExportStack extends BaseClass {
185185

186186
// Track progress for each locale processed
187187
items.forEach((locale: any) => {
188-
this.progressManager?.tick(true, `locale: ${locale.name || locale.code}`, null, 'Locales');
188+
this.progressManager?.tick(true, `locale: ${locale.name || locale.code}`, null, 'Locale');
189189
});
190190

191191
skip += this.stackConfig.limit || 100;
@@ -200,14 +200,14 @@ export default class ExportStack extends BaseClass {
200200
return masterLocalObj;
201201
} else if (skip >= count) {
202202
log.error(
203-
`Master locale not found in the stack ${this.exportConfig.source_stack}. Please ensure that the stack has a master locale.`,
203+
`Locale locale not found in the stack ${this.exportConfig.source_stack}. Please ensure that the stack has a master locale.`,
204204
this.exportConfig.context,
205205
);
206206
log.debug('Completed searching all locales without finding master locale', this.exportConfig.context);
207207
return;
208208
} else {
209209
log.debug(
210-
`Master locale not found in current batch, continuing with skip: ${skip}`,
210+
`Locale locale not found in current batch, continuing with skip: ${skip}`,
211211
this.exportConfig.context,
212212
);
213213
return await this.getLocales(skip);
@@ -221,7 +221,7 @@ export default class ExportStack extends BaseClass {
221221
`Error occurred while fetching locales for stack: ${this.exportConfig.source_stack}`,
222222
this.exportConfig.context,
223223
);
224-
this.progressManager?.tick(false, 'locale fetch', error?.message || 'Failed to fetch locales', 'Locales');
224+
this.progressManager?.tick(false, 'locale fetch', error?.message || 'Failed to fetch locales', 'Locale');
225225
handleAndLogError(
226226
error,
227227
{ ...this.exportConfig.context },
@@ -245,7 +245,7 @@ export default class ExportStack extends BaseClass {
245245
fsUtil.writeFile(stackFilePath, resp);
246246

247247
// Track progress for stack export completion
248-
this.progressManager?.tick(true, `stack: ${this.exportConfig.source_stack}`, null, 'Stack Export');
248+
this.progressManager?.tick(true, `stack: ${this.exportConfig.source_stack}`, null, 'Details');
249249

250250
log.success(
251251
`Stack details exported successfully for stack ${this.exportConfig.source_stack}`,
@@ -256,7 +256,7 @@ export default class ExportStack extends BaseClass {
256256
})
257257
.catch((error: any) => {
258258
log.debug(`Error occurred while exporting stack: ${this.exportConfig.source_stack}`, this.exportConfig.context);
259-
this.progressManager?.tick(false, 'stack export', error?.message || 'Failed to export stack', 'Stack Export');
259+
this.progressManager?.tick(false, 'stack export', error?.message || 'Failed to export stack', 'Details');
260260
handleAndLogError(error, { ...this.exportConfig.context });
261261
});
262262
}
@@ -270,7 +270,7 @@ export default class ExportStack extends BaseClass {
270270
fsUtil.writeFile(pResolve(this.stackFolderPath, 'settings.json'), resp);
271271

272272
// Track progress for stack settings completion
273-
this.progressManager?.tick(true, 'stack settings', null, 'Stack Settings');
273+
this.progressManager?.tick(true, 'stack settings', null, 'Settings');
274274

275275
log.success('Exported stack settings successfully!', this.exportConfig.context);
276276
return resp;
@@ -280,7 +280,7 @@ export default class ExportStack extends BaseClass {
280280
false,
281281
'stack settings',
282282
error?.message || 'Failed to export stack settings',
283-
'Stack Settings',
283+
'Settings',
284284
);
285285
handleAndLogError(error, { ...this.exportConfig.context });
286286
});

0 commit comments

Comments
 (0)