@contentstack/cli-cm-import 1.8.3 → 1.9.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.
Files changed (37) hide show
  1. package/README.md +1 -1
  2. package/bin/dev +4 -15
  3. package/lib/commands/cm/stacks/import.js +5 -2
  4. package/lib/config/index.js +2 -16
  5. package/lib/import/module-importer.js +2 -5
  6. package/lib/import/modules/assets.js +5 -2
  7. package/lib/import/modules/base-class.js +29 -14
  8. package/lib/import/modules/custom-roles.d.ts +1 -1
  9. package/lib/import/modules/custom-roles.js +12 -7
  10. package/lib/import/modules/entries.js +119 -68
  11. package/lib/import/modules/environments.d.ts +1 -1
  12. package/lib/import/modules/environments.js +3 -4
  13. package/lib/import/modules/extensions.js +3 -4
  14. package/lib/import/modules/global-fields.js +3 -2
  15. package/lib/import/modules/labels.d.ts +2 -2
  16. package/lib/import/modules/labels.js +6 -7
  17. package/lib/import/modules/marketplace-apps.d.ts +1 -0
  18. package/lib/import/modules/marketplace-apps.js +11 -5
  19. package/lib/import/modules/webhooks.d.ts +1 -1
  20. package/lib/import/modules/webhooks.js +3 -4
  21. package/lib/import/modules/workflows.js +11 -7
  22. package/lib/import/modules-js/entries.js +3 -3
  23. package/lib/import/modules-js/marketplace-apps.d.ts +1 -0
  24. package/lib/import/modules-js/marketplace-apps.js +9 -2
  25. package/lib/import/modules-js/workflows.js +5 -1
  26. package/lib/types/default-config.d.ts +0 -2
  27. package/lib/types/import-config.d.ts +1 -0
  28. package/lib/utils/asset-helper.d.ts +1 -1
  29. package/lib/utils/asset-helper.js +1 -2
  30. package/lib/utils/backup-handler.js +37 -17
  31. package/lib/utils/entries-helper.d.ts +6 -3
  32. package/lib/utils/entries-helper.js +14 -14
  33. package/lib/utils/import-config-handler.js +7 -0
  34. package/lib/utils/logger.js +1 -1
  35. package/lib/utils/marketplace-app-helper.js +9 -2
  36. package/oclif.manifest.json +1 -1
  37. package/package.json +6 -6
@@ -24,6 +24,13 @@ const setupConfig = async (importCmdFlags) => {
24
24
  config.contentDir = path.resolve(config.contentDir);
25
25
  //Note to support the old key
26
26
  config.data = config.contentDir;
27
+ if ((0, file_helper_1.fileExistsSync)(path.join(config.contentDir, 'export-info.json'))) {
28
+ config.contentVersion =
29
+ ((await (0, file_helper_1.readFile)(path.join(config.contentDir, 'export-info.json'))) || {}).contentVersion || 2;
30
+ }
31
+ else {
32
+ config.contentVersion = 1;
33
+ }
27
34
  const managementTokenAlias = importCmdFlags['management-token-alias'] || importCmdFlags['alias'];
28
35
  if (managementTokenAlias) {
29
36
  const { token, apiKey } = cli_utilities_1.configHandler.get(`tokens.${managementTokenAlias}`);
@@ -55,7 +55,7 @@ let successTransport;
55
55
  let errorTransport;
56
56
  function init(_logPath) {
57
57
  if (!logger || !errorLogger) {
58
- var logsDir = path.resolve(_logPath, 'logs', 'export');
58
+ var logsDir = path.resolve(_logPath, 'logs', 'import');
59
59
  // Create dir if doesn't already exist
60
60
  mkdirp_1.default.sync(logsDir);
61
61
  successTransport = {
@@ -13,8 +13,15 @@ const interactive_1 = require("./interactive");
13
13
  const utils_1 = require("../utils");
14
14
  const interactive_2 = require("../utils/interactive");
15
15
  const getAllStackSpecificApps = async (developerHubBaseUrl, httpClient, config) => {
16
- return await httpClient
17
- .get(`${developerHubBaseUrl}/installations?target_uids=${config.target_stack}`)
16
+ const appSdkAxiosInstance = await (0, cli_utilities_1.managementSDKClient)({
17
+ host: developerHubBaseUrl.split('://').pop()
18
+ });
19
+ return await appSdkAxiosInstance.axiosInstance
20
+ .get(`${developerHubBaseUrl}/installations?target_uids=${config.target_stack}`, {
21
+ headers: {
22
+ organization_uid: config.org_uid,
23
+ },
24
+ })
18
25
  .then(({ data }) => data.data)
19
26
  .catch((error) => (0, logger_1.log)(config, `Failed to export marketplace-apps ${(0, utils_1.formatError)(error)}`, 'error'));
20
27
  };
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.3",
2
+ "version": "1.9.0",
3
3
  "commands": {
4
4
  "cm:stacks:import": {
5
5
  "id": "cm:stacks:import",
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "1.8.3",
4
+ "version": "1.9.0",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
+ "@contentstack/management": "~1.10.2",
8
9
  "@contentstack/cli-command": "~1.2.12",
9
10
  "@contentstack/cli-utilities": "~1.5.2",
10
- "@contentstack/management": "~1.10.0",
11
- "@oclif/config": "^1.18.3",
12
11
  "@oclif/core": "^2.9.3",
13
12
  "big-json": "^3.2.0",
14
13
  "bluebird": "^3.7.2",
15
14
  "chalk": "^4.1.2",
16
15
  "debug": "^4.1.0",
16
+ "fs-extra": "^11.1.1",
17
17
  "lodash": "^4.17.20",
18
18
  "marked": "^4.0.17",
19
19
  "merge": "^2.1.1",
20
20
  "mkdirp": "^1.0.4",
21
- "ncp": "^2.0.0",
22
21
  "promise-limit": "^2.7.0",
23
22
  "tslib": "^2.4.1",
24
23
  "winston": "^3.7.2"
25
24
  },
26
25
  "devDependencies": {
27
26
  "@oclif/test": "^1.2.6",
27
+ "@types/big-json": "^3.2.0",
28
28
  "@types/bluebird": "^3.5.38",
29
29
  "@types/chai": "^4.2.18",
30
+ "@types/fs-extra": "^11.0.1",
30
31
  "@types/mkdirp": "^1.0.2",
31
32
  "@types/mocha": "^8.2.2",
32
- "@types/ncp": "^2.0.5",
33
33
  "@types/node": "^14.14.32",
34
34
  "@types/sinon": "^10.0.2",
35
35
  "@types/tar": "^4.0.3",
@@ -96,4 +96,4 @@
96
96
  }
97
97
  },
98
98
  "repository": "https://github.com/contentstack/cli"
99
- }
99
+ }