Skip to content

Commit 9f6ca62

Browse files
authored
Merge pull request #1759 from contentstack/fix/dev-back-merge
Fix/dev back merge
2 parents 4202292 + 37411b7 commit 9f6ca62

File tree

6 files changed

+33
-14
lines changed

6 files changed

+33
-14
lines changed

packages/contentstack-import-setup/src/import/import-setup.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,34 @@ export default class ImportSetup {
2727
*/
2828
protected async generateDependencyTree() {
2929
type ModulesKey = keyof typeof this.config.modules;
30+
const visited: Set<string> = new Set();
31+
const assignedDependencies: Set<string> = new Set(); // Track assigned dependencies
3032

31-
const getAllDependencies = (module: ModulesKey, visited: Set<string> = new Set()): Modules[] => {
33+
const getAllDependencies = (module: ModulesKey): Modules[] => {
3234
if (visited.has(module)) return [];
3335

3436
visited.add(module);
35-
let dependencies: Modules[] = this.config.modules[module as ModulesKey]?.dependencies || [];
37+
const dependencies: Modules[] = this.config.modules[module]?.dependencies || [];
38+
39+
let allDeps: Modules[] = [...dependencies];
3640

3741
for (const dependency of dependencies) {
38-
dependencies = dependencies.concat(getAllDependencies(dependency as ModulesKey, visited));
42+
allDeps.push(...getAllDependencies(dependency as ModulesKey));
3943
}
4044

41-
return dependencies;
45+
return allDeps;
4246
};
4347

48+
this.dependencyTree = {}; // Reset before building
49+
4450
for (const module of this.config.selectedModules) {
45-
const allDependencies = getAllDependencies(module as ModulesKey);
46-
this.dependencyTree[module] = Array.from(new Set(allDependencies));
51+
let allDependencies = getAllDependencies(module as ModulesKey);
52+
allDependencies = allDependencies.filter((dep) => !assignedDependencies.has(dep)); // Remove assigned ones
53+
54+
this.dependencyTree[module] = allDependencies;
55+
56+
// Mark these dependencies as assigned so they won't be included in later modules
57+
allDependencies.forEach((dep) => assignedDependencies.add(dep));
4758
}
4859
}
4960

packages/contentstack-import-setup/src/import/modules/extensions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class ExtensionImportSetup {
5151

5252
log(this.config, `The required setup files for extensions have been generated successfully.`, 'success');
5353
} else {
54-
log(this.config, 'No extensions found in the content folder.', 'error');
54+
log(this.config, 'No extensions found in the content folder.', 'info');
5555
}
5656
} catch (error) {
5757
log(this.config, `Error occurred while generating the extension mapper: ${formatError(error)}.`, 'error');

packages/contentstack-import-setup/src/import/modules/marketplace-apps.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,14 @@ export default class marketplaceAppImportSetup {
8585
createMapper(sourceMarketplaceApps: any, targetMarketplaceApps: any) {
8686
sourceMarketplaceApps.forEach((sourceApp: any) => {
8787
// Find matching target item based on manifest.name
88-
const targetApp = targetMarketplaceApps.find(
89-
(targetApp: any) => get(targetApp, 'manifest.name') === get(sourceApp, 'manifest.name'),
90-
);
88+
// TBD: This logic is not foolproof, need to find a better way to match source and target apps
89+
// Reason: While importing apps, if an app exist in the target with the same name, it will be a conflict and will not be imported
90+
// So, import command gives an option to import the app with a different name by appending ◈ to the app name. Considering this we are matching the app name without the ◈ character
91+
const getAppName = (app: any) => get(app, 'manifest.name', '').split('◈')[0];
92+
93+
const sourceAppName = getAppName(sourceApp);
94+
95+
const targetApp = targetMarketplaceApps.find((app: any) => getAppName(app) === sourceAppName);
9196

9297
if (targetApp) {
9398
// Map app_uid from source and target
@@ -114,6 +119,8 @@ export default class marketplaceAppImportSetup {
114119
});
115120
}
116121
});
122+
} else {
123+
log(this.config, `No matching Marketplace app found in the target stack with name ${sourceAppName}`, 'info');
117124
}
118125
});
119126
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export default class ImportMarketplaceApps {
9494
return Promise.resolve();
9595
}
9696
await fsUtil.makeDirectory(this.mapperDirPath);
97-
this.developerHubBaseUrl = this.importConfig.developerHubBaseUrl || (await getDeveloperHubUrl(this.importConfig))
97+
this.developerHubBaseUrl = this.importConfig.developerHubBaseUrl || (await getDeveloperHubUrl(this.importConfig));
9898
this.importConfig.developerHubBaseUrl = this.developerHubBaseUrl;
9999

100100
// NOTE init marketplace app sdk
@@ -282,7 +282,8 @@ export default class ImportMarketplaceApps {
282282
.marketplace(this.importConfig.org_uid)
283283
.installation(app.uid)
284284
.fetch()
285-
.catch(() => {}); // NOTE Keeping this to avoid Unhandled exception
285+
.catch(() => {}); // NOTE Keeping this to avoid Unhandled exce
286+
// ption
286287

287288
return !isEmpty(installation);
288289
}

packages/contentstack-import/src/utils/entries-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export const lookupEntries = function (
214214
entry = entry.replace(uidRegex, escapedMappedUid);
215215
mapped.push(uid);
216216
} else {
217-
log(`Skipping the entry uid ${uid} since the regex is not valid`,'error');
217+
log(`Skipping the entry uid ${uid} since the regex is not valid`, 'warn');
218218
}
219219
} else {
220220
unmapped.push(uid);

packages/contentstack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli",
33
"description": "Command-line tool (CLI) to interact with Contentstack",
4-
"version": "1.35.0",
4+
"version": "1.35.1",
55
"author": "Contentstack",
66
"bin": {
77
"csdx": "./bin/run.js"

0 commit comments

Comments
 (0)