Skip to content

Commit 0200b21

Browse files
authored
Merge pull request #1744 from contentstack/fix/DX-2147
Fix/dx 2147
2 parents fe9fbf8 + 988f750 commit 0200b21

File tree

12 files changed

+55
-33
lines changed

12 files changed

+55
-33
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-audit/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ EXAMPLES
269269
$ csdx plugins
270270
```
271271

272-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.26/src/commands/plugins/index.ts)_
272+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/index.ts)_
273273

274274
## `csdx plugins:add PLUGIN`
275275

@@ -343,7 +343,7 @@ EXAMPLES
343343
$ csdx plugins:inspect myplugin
344344
```
345345

346-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.26/src/commands/plugins/inspect.ts)_
346+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/inspect.ts)_
347347

348348
## `csdx plugins:install PLUGIN`
349349

@@ -392,7 +392,7 @@ EXAMPLES
392392
$ csdx plugins:install someuser/someplugin
393393
```
394394

395-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.26/src/commands/plugins/install.ts)_
395+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/install.ts)_
396396

397397
## `csdx plugins:link PATH`
398398

@@ -423,7 +423,7 @@ EXAMPLES
423423
$ csdx plugins:link myplugin
424424
```
425425

426-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.26/src/commands/plugins/link.ts)_
426+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/link.ts)_
427427

428428
## `csdx plugins:remove [PLUGIN]`
429429

@@ -464,7 +464,7 @@ FLAGS
464464
--reinstall Reinstall all plugins after uninstalling.
465465
```
466466

467-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.26/src/commands/plugins/reset.ts)_
467+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/reset.ts)_
468468

469469
## `csdx plugins:uninstall [PLUGIN]`
470470

@@ -492,7 +492,7 @@ EXAMPLES
492492
$ csdx plugins:uninstall myplugin
493493
```
494494

495-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.26/src/commands/plugins/uninstall.ts)_
495+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/uninstall.ts)_
496496

497497
## `csdx plugins:unlink [PLUGIN]`
498498

@@ -536,5 +536,5 @@ DESCRIPTION
536536
Update installed plugins.
537537
```
538538

539-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.26/src/commands/plugins/update.ts)_
539+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/update.ts)_
540540
<!-- commandsstop -->

packages/contentstack-import-setup/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import-setup
4747
$ csdx COMMAND
4848
running command...
4949
$ csdx (--version)
50-
@contentstack/cli-cm-import-setup/1.0.0 darwin-arm64 node-v22.2.0
50+
@contentstack/cli-cm-import-setup/1.0.1 darwin-arm64 node-v22.2.0
5151
$ csdx --help [COMMAND]
5252
USAGE
5353
$ csdx COMMAND

packages/contentstack-import-setup/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-cm-import-setup",
33
"description": "Contentstack CLI plugin to setup the mappers and configurations for the import command",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as fileHelper from './file-helper';
1010
import { escapeRegExp, validateRegex } from '@contentstack/cli-utilities';
1111

1212
import { EntryJsonRTEFieldDataType } from '../types/entries';
13+
import { log } from './log';
1314

1415
// update references in entry object
1516
export const lookupEntries = function (
@@ -212,6 +213,8 @@ export const lookupEntries = function (
212213
if (status === 'safe') {
213214
entry = entry.replace(uidRegex, escapedMappedUid);
214215
mapped.push(uid);
216+
} else {
217+
log(`Skipping the entry uid ${uid} since the regex is not valid`, 'warn');
215218
}
216219
} else {
217220
unmapped.push(uid);

packages/contentstack/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,7 +3887,7 @@ EXAMPLES
38873887
$ csdx plugins
38883888
```
38893889

3890-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.24/src/commands/plugins/index.ts)_
3890+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/index.ts)_
38913891

38923892
## `csdx plugins:add PLUGIN`
38933893

@@ -3961,7 +3961,7 @@ EXAMPLES
39613961
$ csdx plugins:inspect myplugin
39623962
```
39633963

3964-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.24/src/commands/plugins/inspect.ts)_
3964+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/inspect.ts)_
39653965

39663966
## `csdx plugins:install PLUGIN`
39673967

@@ -4010,7 +4010,7 @@ EXAMPLES
40104010
$ csdx plugins:install someuser/someplugin
40114011
```
40124012

4013-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.24/src/commands/plugins/install.ts)_
4013+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/install.ts)_
40144014

40154015
## `csdx plugins:link PATH`
40164016

@@ -4041,7 +4041,7 @@ EXAMPLES
40414041
$ csdx plugins:link myplugin
40424042
```
40434043

4044-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.24/src/commands/plugins/link.ts)_
4044+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/link.ts)_
40454045

40464046
## `csdx plugins:remove [PLUGIN]`
40474047

@@ -4082,7 +4082,7 @@ FLAGS
40824082
--reinstall Reinstall all plugins after uninstalling.
40834083
```
40844084

4085-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.24/src/commands/plugins/reset.ts)_
4085+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/reset.ts)_
40864086

40874087
## `csdx plugins:uninstall [PLUGIN]`
40884088

@@ -4110,7 +4110,7 @@ EXAMPLES
41104110
$ csdx plugins:uninstall myplugin
41114111
```
41124112

4113-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.24/src/commands/plugins/uninstall.ts)_
4113+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/uninstall.ts)_
41144114

41154115
## `csdx plugins:unlink [PLUGIN]`
41164116

@@ -4154,7 +4154,7 @@ DESCRIPTION
41544154
Update installed plugins.
41554155
```
41564156

4157-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.24/src/commands/plugins/update.ts)_
4157+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.30/src/commands/plugins/update.ts)_
41584158

41594159
## `csdx tokens`
41604160

0 commit comments

Comments
 (0)