@contentstack/cli-cm-import-setup 1.0.0 → 1.1.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 CHANGED
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import-setup
47
47
  $ csdx COMMAND
48
48
  running command...
49
49
  $ csdx (--version)
50
- @contentstack/cli-cm-import-setup/1.0.0 linux-x64 node-v18.20.6
50
+ @contentstack/cli-cm-import-setup/1.1.0 linux-x64 node-v22.14.0
51
51
  $ csdx --help [COMMAND]
52
52
  USAGE
53
53
  $ csdx COMMAND
@@ -9,6 +9,8 @@ const config = {
9
9
  // host:'https://azure-eu-api.contentstack.com/v3',
10
10
  // use below hosts for gcp-na region
11
11
  // host:'https://gcp-na-api.contentstack.com',
12
+ // use below hosts for gcp-eu region
13
+ // host:'https://gcp-eu-api.contentstack.com',
12
14
  // pass locale, only to migrate entries from that locale
13
15
  // not passing `locale` will migrate all the locales present
14
16
  // locales: ['fr-fr'],
@@ -41,20 +41,27 @@ class ImportSetup {
41
41
  * @returns {Promise<Array<void | string>>}
42
42
  */
43
43
  async generateDependencyTree() {
44
- const getAllDependencies = (module, visited = new Set()) => {
44
+ const visited = new Set();
45
+ const assignedDependencies = new Set(); // Track assigned dependencies
46
+ const getAllDependencies = (module) => {
45
47
  var _a;
46
48
  if (visited.has(module))
47
49
  return [];
48
50
  visited.add(module);
49
- let dependencies = ((_a = this.config.modules[module]) === null || _a === void 0 ? void 0 : _a.dependencies) || [];
51
+ const dependencies = ((_a = this.config.modules[module]) === null || _a === void 0 ? void 0 : _a.dependencies) || [];
52
+ let allDeps = [...dependencies];
50
53
  for (const dependency of dependencies) {
51
- dependencies = dependencies.concat(getAllDependencies(dependency, visited));
54
+ allDeps.push(...getAllDependencies(dependency));
52
55
  }
53
- return dependencies;
56
+ return allDeps;
54
57
  };
58
+ this.dependencyTree = {}; // Reset before building
55
59
  for (const module of this.config.selectedModules) {
56
- const allDependencies = getAllDependencies(module);
57
- this.dependencyTree[module] = Array.from(new Set(allDependencies));
60
+ let allDependencies = getAllDependencies(module);
61
+ allDependencies = allDependencies.filter((dep) => !assignedDependencies.has(dep)); // Remove assigned ones
62
+ this.dependencyTree[module] = allDependencies;
63
+ // Mark these dependencies as assigned so they won't be included in later modules
64
+ allDependencies.forEach((dep) => assignedDependencies.add(dep));
58
65
  }
59
66
  }
60
67
  /**
@@ -37,7 +37,7 @@ class ExtensionImportSetup {
37
37
  (0, utils_1.log)(this.config, `The required setup files for extensions have been generated successfully.`, 'success');
38
38
  }
39
39
  else {
40
- (0, utils_1.log)(this.config, 'No extensions found in the content folder.', 'error');
40
+ (0, utils_1.log)(this.config, 'No extensions found in the content folder.', 'info');
41
41
  }
42
42
  }
43
43
  catch (error) {
@@ -56,7 +56,12 @@ class marketplaceAppImportSetup {
56
56
  createMapper(sourceMarketplaceApps, targetMarketplaceApps) {
57
57
  sourceMarketplaceApps.forEach((sourceApp) => {
58
58
  // Find matching target item based on manifest.name
59
- const targetApp = targetMarketplaceApps.find((targetApp) => (0, lodash_1.get)(targetApp, 'manifest.name') === (0, lodash_1.get)(sourceApp, 'manifest.name'));
59
+ // TBD: This logic is not foolproof, need to find a better way to match source and target apps
60
+ // 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
61
+ // 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
62
+ const getAppName = (app) => (0, lodash_1.get)(app, 'manifest.name', '').split('◈')[0];
63
+ const sourceAppName = getAppName(sourceApp);
64
+ const targetApp = targetMarketplaceApps.find((app) => getAppName(app) === sourceAppName);
60
65
  if (targetApp) {
61
66
  // Map app_uid from source and target
62
67
  this.marketplaceAppMapper.app_uid[sourceApp.manifest.uid] = targetApp.manifest.uid;
@@ -75,6 +80,9 @@ class marketplaceAppImportSetup {
75
80
  }
76
81
  });
77
82
  }
83
+ else {
84
+ (0, utils_1.log)(this.config, `No matching Marketplace app found in the target stack with name ${sourceAppName}`, 'info');
85
+ }
78
86
  });
79
87
  }
80
88
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0",
2
+ "version": "1.1.0",
3
3
  "commands": {
4
4
  "cm:stacks:import-setup": {
5
5
  "id": "cm:stacks:import-setup",
package/package.json CHANGED
@@ -1,29 +1,22 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import-setup",
3
3
  "description": "Contentstack CLI plugin to setup the mappers and configurations for the import command",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-command": "~1.3.2",
9
- "@contentstack/cli-utilities": "~1.8.0",
8
+ "@contentstack/cli-command": "~1.3.3",
9
+ "@contentstack/cli-utilities": "~1.8.4",
10
10
  "@oclif/core": "^3.27.0",
11
11
  "big-json": "^3.2.0",
12
- "bluebird": "^3.7.2",
13
12
  "chalk": "^4.1.2",
14
- "debug": "^4.4.0",
15
13
  "fs-extra": "^11.1.1",
16
14
  "lodash": "^4.17.21",
17
- "marked": "^4.3.0",
18
15
  "merge": "^2.1.1",
19
16
  "mkdirp": "^1.0.4",
20
- "promise-limit": "^2.7.0",
21
- "tslib": "^2.8.1",
22
- "uuid": "^9.0.1",
23
17
  "winston": "^3.17.0"
24
18
  },
25
19
  "devDependencies": {
26
- "@oclif/test": "^4.1.6",
27
20
  "@types/big-json": "^3.2.5",
28
21
  "@types/bluebird": "^3.5.42",
29
22
  "@types/chai": "^4.3.20",
@@ -31,20 +24,15 @@
31
24
  "@types/mkdirp": "^1.0.2",
32
25
  "@types/mocha": "^8.2.3",
33
26
  "@types/node": "^14.18.63",
34
- "@types/sinon": "^10.0.20",
35
27
  "@types/tar": "^6.1.13",
36
28
  "@types/uuid": "^9.0.8",
37
29
  "@typescript-eslint/eslint-plugin": "^5.62.0",
38
30
  "chai": "^4.5.0",
39
31
  "eslint": "^8.57.1",
40
32
  "eslint-config-oclif": "^4.0.0",
41
- "globby": "^10.0.2",
42
33
  "mocha": "^10.8.2",
43
34
  "nyc": "^15.1.0",
44
35
  "oclif": "^3.17.2",
45
- "rimraf": "^2.7.1",
46
- "sinon": "^11.1.2",
47
- "tmp": "^0.2.3",
48
36
  "ts-node": "^10.9.2",
49
37
  "typescript": "^4.9.5"
50
38
  },