@contentstack/cli-cm-import 1.5.10 → 1.6.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 (110) hide show
  1. package/README.md +6 -14
  2. package/bin/dev +17 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/run +6 -0
  5. package/bin/run.cmd +3 -0
  6. package/lib/commands/cm/stacks/import.d.ts +10 -0
  7. package/lib/commands/cm/stacks/import.js +111 -0
  8. package/lib/config/index.d.ts +3 -0
  9. package/lib/config/index.js +372 -0
  10. package/lib/import/index.d.ts +1 -0
  11. package/lib/import/index.js +8 -0
  12. package/lib/import/module-importer.d.ts +13 -0
  13. package/lib/import/module-importer.js +70 -0
  14. package/lib/import/modules/assets.d.ts +63 -0
  15. package/lib/import/modules/assets.js +265 -0
  16. package/lib/import/modules/base-class.d.ts +69 -0
  17. package/lib/import/modules/base-class.js +165 -0
  18. package/lib/import/modules/index.d.ts +2 -0
  19. package/lib/import/modules/index.js +19 -0
  20. package/lib/import/modules/locales.d.ts +31 -0
  21. package/lib/import/modules/locales.js +152 -0
  22. package/lib/import/modules-js/assets.d.ts +33 -0
  23. package/lib/import/modules-js/assets.js +415 -0
  24. package/lib/import/modules-js/content-types.d.ts +33 -0
  25. package/lib/import/modules-js/content-types.js +176 -0
  26. package/lib/import/modules-js/custom-roles.d.ts +15 -0
  27. package/lib/import/modules-js/custom-roles.js +141 -0
  28. package/lib/import/modules-js/entries.d.ts +54 -0
  29. package/lib/import/modules-js/entries.js +1260 -0
  30. package/lib/import/modules-js/environments.d.ts +13 -0
  31. package/lib/import/modules-js/environments.js +85 -0
  32. package/lib/import/modules-js/extensions.d.ts +17 -0
  33. package/lib/import/modules-js/extensions.js +86 -0
  34. package/lib/import/modules-js/global-fields.d.ts +13 -0
  35. package/lib/import/modules-js/global-fields.js +109 -0
  36. package/lib/import/modules-js/index.d.ts +1 -0
  37. package/lib/import/modules-js/index.js +33 -0
  38. package/lib/import/modules-js/labels.d.ts +20 -0
  39. package/lib/import/modules-js/labels.js +148 -0
  40. package/lib/import/modules-js/locales.d.ts +24 -0
  41. package/lib/import/modules-js/locales.js +196 -0
  42. package/lib/import/modules-js/marketplace-apps.d.ts +60 -0
  43. package/lib/import/modules-js/marketplace-apps.js +409 -0
  44. package/lib/import/modules-js/webhooks.d.ts +17 -0
  45. package/lib/import/modules-js/webhooks.js +85 -0
  46. package/lib/import/modules-js/workflows.d.ts +18 -0
  47. package/lib/import/modules-js/workflows.js +132 -0
  48. package/lib/types/default-config.d.ts +130 -0
  49. package/lib/types/default-config.js +2 -0
  50. package/lib/types/import-config.d.ts +51 -0
  51. package/lib/types/import-config.js +2 -0
  52. package/lib/types/index.d.ts +30 -0
  53. package/lib/types/index.js +2 -0
  54. package/lib/utils/asset-helper.d.ts +4 -0
  55. package/lib/utils/asset-helper.js +387 -0
  56. package/lib/utils/backup-handler.d.ts +2 -0
  57. package/lib/utils/backup-handler.js +31 -0
  58. package/lib/utils/common-helper.d.ts +20 -0
  59. package/lib/utils/common-helper.js +244 -0
  60. package/lib/utils/content-type-helper.d.ts +49 -0
  61. package/lib/utils/content-type-helper.js +143 -0
  62. package/lib/utils/entries-helper.d.ts +4 -0
  63. package/lib/utils/entries-helper.js +252 -0
  64. package/lib/utils/extension-helper.d.ts +10 -0
  65. package/lib/utils/extension-helper.js +72 -0
  66. package/lib/utils/file-helper.d.ts +14 -0
  67. package/lib/utils/file-helper.js +140 -0
  68. package/lib/utils/import-config-handler.d.ts +3 -0
  69. package/lib/utils/import-config-handler.js +73 -0
  70. package/lib/utils/index.d.ts +12 -0
  71. package/lib/utils/index.js +29 -0
  72. package/lib/utils/interactive.d.ts +2 -0
  73. package/lib/utils/interactive.js +23 -0
  74. package/lib/utils/logger.d.ts +8 -0
  75. package/lib/utils/logger.js +154 -0
  76. package/lib/utils/login-handler.d.ts +8 -0
  77. package/lib/utils/login-handler.js +53 -0
  78. package/lib/utils/marketplace-app-helper.d.ts +4 -0
  79. package/lib/utils/marketplace-app-helper.js +31 -0
  80. package/messages/index.json +1 -7
  81. package/oclif.manifest.json +2 -2
  82. package/package.json +47 -21
  83. package/src/app.js +0 -217
  84. package/src/commands/cm/stacks/import.js +0 -161
  85. package/src/config/default.js +0 -352
  86. package/src/lib/import/assets.js +0 -495
  87. package/src/lib/import/content-types.js +0 -201
  88. package/src/lib/import/custom-roles.js +0 -169
  89. package/src/lib/import/entries.js +0 -1480
  90. package/src/lib/import/environments.js +0 -106
  91. package/src/lib/import/extensions.js +0 -108
  92. package/src/lib/import/global-fields.js +0 -135
  93. package/src/lib/import/labels.js +0 -175
  94. package/src/lib/import/locales.js +0 -216
  95. package/src/lib/import/marketplace-apps.js +0 -542
  96. package/src/lib/import/webhooks.js +0 -113
  97. package/src/lib/import/workflows.js +0 -166
  98. package/src/lib/util/extensionsUidReplace.js +0 -67
  99. package/src/lib/util/fs.js +0 -124
  100. package/src/lib/util/import-flags.js +0 -187
  101. package/src/lib/util/index.js +0 -222
  102. package/src/lib/util/log.js +0 -144
  103. package/src/lib/util/login.js +0 -58
  104. package/src/lib/util/lookupReplaceAssets.js +0 -366
  105. package/src/lib/util/lookupReplaceEntries.js +0 -250
  106. package/src/lib/util/marketplace-app-helper.js +0 -31
  107. package/src/lib/util/removeReferenceFields.js +0 -59
  108. package/src/lib/util/schemaTemplate.js +0 -38
  109. package/src/lib/util/supress-mandatory-fields.js +0 -34
  110. package/src/lib/util/upload.js +0 -56
@@ -1,166 +0,0 @@
1
- /*!
2
- * Contentstack Import
3
- * Copyright (c) 2019 Contentstack LLC
4
- * MIT Licensed
5
- */
6
-
7
- const mkdirp = require('mkdirp');
8
- const fs = require('fs');
9
- const path = require('path');
10
- const Promise = require('bluebird');
11
- const chalk = require('chalk');
12
- const { isEmpty, merge } = require('lodash');
13
-
14
- const helper = require('../util/fs');
15
- const { formatError } = require('../util');
16
- const { addlogs } = require('../util/log');
17
- let config = require('../../config/default');
18
-
19
- module.exports = class importWorkflows {
20
- fails = [];
21
- success = [];
22
- workflowUidMapper = {};
23
- workflowConfig = config.modules.workflows;
24
- reqConcurrency = config.concurrency || config.fetchConcurrency || 1;
25
-
26
- constructor(importConfig, stackAPIClient) {
27
- this.config = merge(config, importConfig);
28
- this.stackAPIClient = stackAPIClient;
29
- }
30
-
31
- start() {
32
- addlogs(this.config, chalk.white('Migrating workflows'), 'success');
33
-
34
- let self = this;
35
- let workflowMapperPath = path.resolve(this.config.data, 'mapper', 'workflows');
36
- let workflowFailsPath = path.resolve(this.config.data, 'workflows', 'fails.json');
37
- let workflowSuccessPath = path.resolve(this.config.data, 'workflows', 'success.json');
38
- let workflowUidMapperPath = path.resolve(this.config.data, 'mapper', 'workflows', 'uid-mapping.json');
39
- let workflowFolderPath = path.resolve(this.config.data, this.workflowConfig.dirName);
40
-
41
- self.workflows = helper.readFileSync(path.resolve(workflowFolderPath, this.workflowConfig.fileName));
42
-
43
- if (fs.existsSync(workflowUidMapperPath)) {
44
- this.workflowUidMapper = helper.readFileSync(workflowUidMapperPath);
45
- this.workflowUidMapper = this.workflowUidMapper || {};
46
- }
47
-
48
- mkdirp.sync(workflowMapperPath);
49
-
50
- return new Promise(function (resolve, reject) {
51
- if (self.workflows == undefined || isEmpty(self.workflows)) {
52
- addlogs(self.config, chalk.white('No workflow Found'), 'success');
53
- return resolve({ empty: true });
54
- }
55
- self.workflowsUids = Object.keys(self.workflows);
56
- return Promise.map(
57
- self.workflowsUids,
58
- async function (workflowUid) {
59
- let workflow = self.workflows[workflowUid];
60
-
61
- if (!self.workflowUidMapper.hasOwnProperty(workflowUid)) {
62
- const roleNameMap = {};
63
- const workflowStages = workflow.workflow_stages;
64
- const roles = await self.stackAPIClient.role().fetchAll();
65
-
66
- for (const role of roles.items) {
67
- roleNameMap[role.name] = role.uid;
68
- }
69
-
70
- for (const stage of workflowStages) {
71
- if (stage.SYS_ACL.users.uids.length && stage.SYS_ACL.users.uids[0] !== '$all') {
72
- stage.SYS_ACL.users.uids = ['$all'];
73
- }
74
-
75
- if (stage.SYS_ACL.roles.uids.length) {
76
- try {
77
- for (let i = 0; i < stage.SYS_ACL.roles.uids.length; i++) {
78
- const roleData = stage.SYS_ACL.roles.uids[i];
79
- if (!roleNameMap[roleData.name]) {
80
- // rules.branch is required to create custom roles.
81
- const branchRuleExists = roleData.rules.find((rule) => rule.module === 'branch');
82
- if (!branchRuleExists) {
83
- roleData.rules.push({
84
- module: 'branch',
85
- branches: ['main'],
86
- acl: { read: true },
87
- });
88
- }
89
-
90
- const role = await self.stackAPIClient.role().create({ role: roleData });
91
- stage.SYS_ACL.roles.uids[i] = role.uid;
92
- roleNameMap[roleData.name] = role.uid;
93
- } else {
94
- stage.SYS_ACL.roles.uids[i] = roleNameMap[roleData.name];
95
- }
96
- }
97
- } catch (error) {
98
- addlogs(
99
- self.config,
100
- `Error while importing workflows roles. ${formatError(error)}`,
101
- 'error',
102
- );
103
- reject({ message: 'Error while importing workflows roles' });
104
- }
105
- }
106
- }
107
-
108
- if (workflow.admin_users !== undefined) {
109
- addlogs(
110
- self.config,
111
- chalk.yellow('We are skipping import of `Workflow superuser(s)` from workflow'),
112
- 'info',
113
- );
114
- delete workflow.admin_users;
115
- }
116
- // One branch is required to create workflow.
117
- if (!workflow.branches) {
118
- workflow.branches = ['main'];
119
- }
120
-
121
- return self.stackAPIClient
122
- .workflow()
123
- .create({ workflow })
124
- .then(function (response) {
125
- self.workflowUidMapper[workflowUid] = response;
126
- helper.writeFileSync(workflowUidMapperPath, self.workflowUidMapper);
127
- })
128
- .catch(function (error) {
129
- self.fails.push(workflow);
130
- if (error.errors.name) {
131
- addlogs(self.config, `workflow ${workflow.name} already exist`, 'error');
132
- } else if (error.errors['workflow_stages.0.users']) {
133
- addlogs(
134
- self.config,
135
- "Failed to import Workflows as you've specified certain roles in the Stage transition and access rules section. We currently don't import roles to the stack.",
136
- 'error',
137
- );
138
- } else {
139
- addlogs(self.config, `workflow ${workflow.name} failed.`, 'error');
140
- }
141
- });
142
- } else {
143
- // the workflow has already been created
144
- addlogs(
145
- self.config,
146
- chalk.white( `The Workflows ${workflow.name} already exists. Skipping it to avoid duplicates!`),
147
- 'success',
148
- );
149
- }
150
- // import 1 workflows at a time
151
- },
152
- { concurrency: self.reqConcurrency },
153
- )
154
- .then(function () {
155
- helper.writeFileSync(workflowSuccessPath, self.success);
156
- addlogs(self.config, chalk.green('Workflows have been imported successfully!'), 'success');
157
- resolve();
158
- })
159
- .catch(function (error) {
160
- helper.writeFileSync(workflowFailsPath, self.fails);
161
- addlogs(self.config, `Workflows import failed. ${formatError(error)}`, 'error');
162
- return reject(error);
163
- });
164
- });
165
- }
166
- };
@@ -1,67 +0,0 @@
1
- /*!
2
- * Contentstack Import
3
- * Copyright (c) 2019 Contentstack LLC
4
- * MIT Licensed
5
- */
6
-
7
- // eslint-disable-next-line unicorn/filename-case
8
- let path = require('path');
9
- const _ = require('lodash');
10
- let helper = require('./fs');
11
- let util = require('../util');
12
- let config = util.getConfig();
13
- let extensionPath = path.resolve(config.data, 'mapper/extensions', 'uid-mapping.json');
14
- let globalfieldsPath = path.resolve(config.data, 'mapper/globalfields', 'uid-mapping.json');
15
-
16
- // eslint-disable-next-line camelcase
17
- let extension_uid_Replace = (module.exports = function (schema, preserveStackVersion, installedExtensions) {
18
- for (let i in schema) {
19
- if (schema[i].data_type === 'group') {
20
- extension_uid_Replace(schema[i].schema, preserveStackVersion, installedExtensions);
21
- } else if (schema[i].data_type === 'blocks') {
22
- for (let block in schema[i].blocks) {
23
- if (schema[i].blocks[block].hasOwnProperty('reference_to')) {
24
- delete schema[i].blocks[block].schema;
25
- } else {
26
- extension_uid_Replace(schema[i].blocks[block].schema, preserveStackVersion, installedExtensions);
27
- }
28
- }
29
- } else if (
30
- schema[i].data_type === 'reference' &&
31
- !schema[i].field_metadata.hasOwnProperty('ref_multiple_content_types')
32
- ) {
33
- if (preserveStackVersion) {
34
- // do nothing
35
- } else {
36
- schema[i].reference_to = [schema[i].reference_to];
37
- schema[i].field_metadata.ref_multiple_content_types = true;
38
- }
39
- } else if (schema[i].data_type === 'global_field') {
40
- let global_fields_key_value = schema[i].reference_to;
41
- let global_fields_data = helper.readFileSync(path.join(globalfieldsPath));
42
- if (global_fields_data && global_fields_data.hasOwnProperty(global_fields_key_value)) {
43
- schema[i].reference_to = global_fields_data[global_fields_key_value];
44
- }
45
- } else if (schema[i].hasOwnProperty('extension_uid')) {
46
- const extension_key_value = schema[i].extension_uid;
47
- const data = helper.readFileSync(path.join(extensionPath));
48
- if (data && data.hasOwnProperty(extension_key_value)) {
49
- // eslint-disable-next-line camelcase
50
- schema[i].extension_uid = data[extension_key_value];
51
- } else if (schema[i].field_metadata && schema[i].field_metadata.extension) {
52
- if (installedExtensions && installedExtensions[schema[i].extension_uid]) {
53
- schema[i].extension_uid = installedExtensions[schema[i].extension_uid];
54
- }
55
- }
56
- } else if (schema[i].data_type === 'json' && schema[i].hasOwnProperty('plugins') && schema[i].plugins.length > 0) {
57
- const newPluginUidsArray = [];
58
- const data = helper.readFileSync(path.join(extensionPath));
59
- schema[i].plugins.forEach((extension_key_value) => {
60
- if (data && data.hasOwnProperty(extension_key_value)) {
61
- newPluginUidsArray.push(data[extension_key_value]);
62
- }
63
- });
64
- schema[i].plugins = newPluginUidsArray;
65
- }
66
- }
67
- });
@@ -1,124 +0,0 @@
1
- /*!
2
- * Contentstack Import
3
- * Copyright (c) 2019 Contentstack LLC
4
- * MIT Licensed
5
- */
6
-
7
- var fs = require('fs');
8
- var path = require('path');
9
- var mkdirp = require('mkdirp');
10
- const bigJSON = require('big-json');
11
-
12
- exports.readFileSync = function (filePath, parse) {
13
- let data;
14
- parse = typeof parse === 'undefined' ? true : parse;
15
- filePath = path.resolve(filePath);
16
- if (fs.existsSync(filePath)) {
17
- try {
18
- data = parse ? JSON.parse(fs.readFileSync(filePath, 'utf-8')) : data;
19
- } catch (error) {
20
- return data;
21
- }
22
- }
23
- return data;
24
- };
25
-
26
- // by default file type is json
27
- exports.readFile = async (filePath, options = { type: 'json' }) => {
28
- return new Promise((resolve, reject) => {
29
- filePath = path.resolve(filePath);
30
- fs.readFile(filePath, 'utf-8', (error, data) => {
31
- if (error) {
32
- if (error.code === 'ENOENT') {
33
- return resolve();
34
- }
35
- reject(error);
36
- } else {
37
- if (options.type !== 'json') {
38
- return resolve(data);
39
- }
40
- resolve(JSON.parse(data));
41
- }
42
- });
43
- });
44
- };
45
-
46
- exports.writeFileSync = function (filePath, data) {
47
- data = typeof data === 'object' ? JSON.stringify(data) : data || '{}';
48
- fs.writeFileSync(filePath, data);
49
- };
50
-
51
- exports.writeFile = function (filePath, data) {
52
- return new Promise((resolve, reject) => {
53
- data = typeof data === 'object' ? JSON.stringify(data) : data || '{}';
54
- fs.writeFile(filePath, data, (error) => {
55
- if (error) {
56
- return reject(error);
57
- }
58
- resolve('done');
59
- });
60
- });
61
- };
62
-
63
- exports.makeDirectory = async function (path) {
64
- if (!path) {
65
- throw new Error('Invalid path to create directory');
66
- }
67
- return mkdirp(path);
68
- };
69
-
70
- exports.readLargeFile = function (filePath, opts = {}) {
71
- if (typeof filePath !== 'string') {
72
- return;
73
- }
74
- filePath = path.resolve(filePath);
75
- if (fs.existsSync(filePath)) {
76
- return new Promise((resolve, reject) => {
77
- const readStream = fs.createReadStream(filePath, { encoding: 'utf-8' });
78
- const parseStream = bigJSON.createParseStream();
79
- parseStream.on('data', function (data) {
80
- if (opts.type === 'array') {
81
- return resolve(Object.values(data));
82
- }
83
- resolve(data);
84
- });
85
- parseStream.on('error', function (error) {
86
- console.log('error', error);
87
- reject(error);
88
- });
89
- readStream.pipe(parseStream);
90
- });
91
- }
92
- };
93
-
94
- exports.writeLargeFile = function (filePath, data) {
95
- if (typeof filePath !== 'string' || typeof data !== 'object') {
96
- return;
97
- }
98
- filePath = path.resolve(filePath);
99
- return new Promise((resolve, reject) => {
100
- const stringifyStream = bigJSON.createStringifyStream({
101
- body: data,
102
- });
103
- var writeStream = fs.createWriteStream(filePath, 'utf-8');
104
- stringifyStream.pipe(writeStream);
105
- writeStream.on('finish', () => {
106
- resolve();
107
- });
108
- writeStream.on('error', (error) => {
109
- reject(error);
110
- });
111
- });
112
- };
113
-
114
- exports.readdirSync = function (dirPath) {
115
- if (fs.existsSync(dirPath)) {
116
- return fs.readdirSync(dirPath);
117
- } else {
118
- return [];
119
- }
120
- };
121
-
122
- exports.fileExistsSync = function (path) {
123
- return fs.existsSync(path);
124
- };
@@ -1,187 +0,0 @@
1
- /*!
2
- * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
4
- * MIT Licensed
5
- */
6
- let defaultConfig = require('../../config/default');
7
- let { initial } = require('../../app');
8
- let _ = require('lodash');
9
- const { cliux } = require('@contentstack/cli-utilities');
10
- let message = require('../../../messages/index.json');
11
-
12
- exports.configWithMToken = function (
13
- config,
14
- managementTokens,
15
- moduleName,
16
- host,
17
- backupdir,
18
- importCommandFlags,
19
- ) {
20
- return new Promise(async function (resolve, reject) {
21
- let externalConfig = config ? require(config) : {};
22
- const modules = externalConfig.modules;
23
-
24
- if (_.isArray(externalConfig['modules'])) {
25
- externalConfig = _.omit(externalConfig, ['modules']);
26
- }
27
-
28
- defaultConfig.host = host;
29
- defaultConfig.branchName = importCommandFlags.branchName;
30
- defaultConfig.target_stack = managementTokens.apiKey;
31
- defaultConfig.management_token = managementTokens.token;
32
- defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
33
- defaultConfig.isAuthenticated = importCommandFlags.isAuthenticated;
34
-
35
- if (moduleName && moduleName !== undefined) {
36
- defaultConfig.moduleName = moduleName;
37
- }
38
-
39
- if (backupdir) {
40
- defaultConfig.useBackedupDir = backupdir;
41
- }
42
-
43
- defaultConfig = _.merge(defaultConfig, externalConfig);
44
-
45
- if (!defaultConfig.data) {
46
- const exporteddata = await cliux.prompt(message.promptMessageList.promptPathStoredData);
47
- defaultConfig.data = exporteddata;
48
- }
49
-
50
- if (_.isArray(modules)) {
51
- defaultConfig.modules.types = _.filter(defaultConfig.modules.types, (module) => _.includes(modules, module));
52
- }
53
-
54
- initial(defaultConfig).then(resolve).catch(reject);
55
- });
56
- };
57
-
58
- exports.parameterWithMToken = function (
59
- managementTokens,
60
- data,
61
- moduleName,
62
- host,
63
- backupdir,
64
- importCommandFlags,
65
- ) {
66
- return new Promise(async function (resolve, reject) {
67
- defaultConfig.management_token = managementTokens.token;
68
- defaultConfig.target_stack = managementTokens.apiKey;
69
- defaultConfig.branchName = importCommandFlags.branchName;
70
- defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
71
- defaultConfig.isAuthenticated = importCommandFlags.isAuthenticated;
72
- if (moduleName && moduleName !== undefined) {
73
- defaultConfig.moduleName = moduleName;
74
- }
75
- defaultConfig.data = data;
76
- defaultConfig.host = host;
77
- if (backupdir) {
78
- defaultConfig.useBackedupDir = backupdir;
79
- }
80
- initial(defaultConfig).then(resolve).catch(reject);
81
- });
82
- };
83
-
84
- // using ManagemetToken
85
- exports.withoutParameterMToken = async (
86
- managementTokens,
87
- moduleName,
88
- host,
89
- backupdir,
90
- importCommandFlags,
91
- ) => {
92
- return new Promise(async function (resolve, reject) {
93
- const exporteddata = await cliux.prompt(message.promptMessageList.promptPathStoredData);
94
- defaultConfig.management_token = managementTokens.token;
95
- defaultConfig.target_stack = managementTokens.apiKey;
96
- defaultConfig.branchName = importCommandFlags.branchName;
97
- defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
98
- defaultConfig.isAuthenticated = importCommandFlags.isAuthenticated;
99
- if (moduleName && moduleName !== undefined) {
100
- defaultConfig.moduleName = moduleName;
101
- }
102
- defaultConfig.data = exporteddata;
103
- defaultConfig.host = host;
104
- if (backupdir) {
105
- defaultConfig.useBackedupDir = backupdir;
106
- }
107
- initial(defaultConfig).then(resolve).catch(reject);
108
- });
109
- };
110
-
111
- exports.configWithAuthToken = function (config, moduleName, host, backupdir, importCommandFlags) {
112
- return new Promise(async function (resolve, reject) {
113
- let externalConfig = require(config);
114
- defaultConfig.branchName = importCommandFlags.branchName;
115
- defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
116
- defaultConfig.isAuthenticated = importCommandFlags.isAuthenticated;
117
- if (moduleName && moduleName !== undefined) {
118
- defaultConfig.moduleName = moduleName;
119
- }
120
- defaultConfig.host = host;
121
-
122
- if (externalConfig.modules) {
123
- defaultConfig.modules.types = externalConfig.modules;
124
- delete externalConfig.modules;
125
- }
126
-
127
- if (backupdir) {
128
- defaultConfig.useBackedupDir = backupdir;
129
- }
130
- defaultConfig = _.merge(defaultConfig, externalConfig);
131
- if (!defaultConfig.data) {
132
- const exporteddata = await cliux.prompt(message.promptMessageList.promptPathStoredData);
133
- defaultConfig.data = exporteddata;
134
- }
135
- initial(defaultConfig).then(resolve).catch(reject);
136
- });
137
- };
138
-
139
- exports.parametersWithAuthToken = function (
140
- targetStack,
141
- data,
142
- moduleName,
143
- host,
144
- backupdir,
145
- importCommandFlags,
146
- ) {
147
- return new Promise(async function (resolve, reject) {
148
- defaultConfig.target_stack = targetStack;
149
- defaultConfig.branchName = importCommandFlags.branchName;
150
- defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
151
- defaultConfig.isAuthenticated = importCommandFlags.isAuthenticated;
152
- if (moduleName && moduleName !== undefined && backupdir === undefined) {
153
- defaultConfig.moduleName = moduleName;
154
- } else if (moduleName && moduleName !== undefined && backupdir !== undefined) {
155
- defaultConfig.moduleName = moduleName;
156
- defaultConfig.useBackedupDir = backupdir;
157
- } else if (backupdir) {
158
- defaultConfig.useBackedupDir = backupdir;
159
- }
160
- defaultConfig.data = data;
161
- defaultConfig.host = host;
162
-
163
- initial(defaultConfig).then(resolve).catch(reject);
164
- });
165
- };
166
-
167
- exports.withoutParametersWithAuthToken = async (moduleName, host, backupdir, importCommandFlags) => {
168
- return new Promise(async function (resolve, reject) {
169
- const stackUid = await cliux.prompt(message.promptMessageList.promptTargetStack);
170
- const exporteddata = await cliux.prompt(message.promptMessageList.promptPathStoredData);
171
- defaultConfig.target_stack = stackUid;
172
- defaultConfig.data = exporteddata;
173
- defaultConfig.branchName = importCommandFlags.branchName;
174
- defaultConfig.importWebhookStatus = importCommandFlags.importWebhookStatus;
175
- defaultConfig.isAuthenticated = importCommandFlags.isAuthenticated;
176
- if (moduleName && moduleName !== undefined && backupdir === undefined) {
177
- defaultConfig.moduleName = moduleName;
178
- } else if (moduleName && moduleName !== undefined && backupdir !== undefined) {
179
- defaultConfig.moduleName = moduleName;
180
- defaultConfig.useBackedupDir = backupdir;
181
- }
182
-
183
- defaultConfig.host = host;
184
-
185
- initial(defaultConfig).then(resolve).catch(reject);
186
- });
187
- };