@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,161 +0,0 @@
1
- const _ = require('lodash');
2
- const defaultConfig = require('../../../config/default');
3
- const { Command } = require('@contentstack/cli-command');
4
- const { flags, printFlagDeprecation, isAuthenticated, cliux } = require('@contentstack/cli-utilities');
5
- const {
6
- configWithMToken,
7
- parameterWithMToken,
8
- withoutParameterMToken,
9
- configWithAuthToken,
10
- parametersWithAuthToken,
11
- withoutParametersWithAuthToken,
12
- } = require('../../../lib/util/import-flags');
13
-
14
- class ImportCommand extends Command {
15
- async run() {
16
- let self = this;
17
- const { flags: importCommandFlags } = await self.parse(ImportCommand);
18
- const extConfig = importCommandFlags.config;
19
- let targetStack = importCommandFlags['stack-uid'] || importCommandFlags['stack-api-key'];
20
- const data = importCommandFlags.data || importCommandFlags['data-dir'];
21
- const moduleName = importCommandFlags.module;
22
- const backupdir = importCommandFlags['backup-dir'];
23
- const alias = importCommandFlags['alias'] || importCommandFlags['management-token-alias'];
24
- importCommandFlags.branchName = importCommandFlags.branch;
25
- importCommandFlags.importWebhookStatus = importCommandFlags['import-webhook-status'];
26
- delete importCommandFlags.branch;
27
- delete importCommandFlags['import-webhook-status'];
28
- let host = self.cmaHost;
29
- importCommandFlags['isAuthenticated'] = isAuthenticated();
30
-
31
- return new Promise((resolve, reject) => {
32
- if (data) {
33
- defaultConfig.data = data;
34
- }
35
-
36
- defaultConfig.forceStopMarketplaceAppsPrompt = importCommandFlags.yes;
37
-
38
- if (alias) {
39
- let managementTokens = self.getToken(alias);
40
-
41
- if (managementTokens) {
42
- let result;
43
-
44
- if ((extConfig && isAuthenticated()) || alias) {
45
- result = configWithMToken(extConfig, managementTokens, moduleName, host, backupdir, importCommandFlags);
46
- } else if (data) {
47
- result = parameterWithMToken(managementTokens, data, moduleName, host, backupdir, importCommandFlags);
48
- } else {
49
- result = withoutParameterMToken(managementTokens, moduleName, host, backupdir, importCommandFlags);
50
- }
51
-
52
- result.then(resolve).catch(reject);
53
- } else {
54
- cliux.print(`error: management Token is not present please add managment token first`, {color: 'red'});
55
- }
56
- } else if (isAuthenticated()) {
57
- let result;
58
-
59
- if (extConfig) {
60
- result = configWithAuthToken(extConfig, moduleName, host, backupdir, importCommandFlags);
61
- } else if (targetStack && data) {
62
- result = parametersWithAuthToken(targetStack, data, moduleName, host, backupdir, importCommandFlags);
63
- } else {
64
- result = withoutParametersWithAuthToken(moduleName, host, backupdir, importCommandFlags);
65
- }
66
-
67
- result.then(resolve).catch(reject);
68
- } else {
69
- cliux.print(`error: Login or provide the alias for management token`, {color: 'red'});
70
- }
71
- });
72
- }
73
- }
74
-
75
- ImportCommand.description = `Import script for importing the content into the new stack
76
- ...
77
- Once you export content from the source stack, import it to your destination stack by using the cm:stacks:import command.
78
- `;
79
- ImportCommand.examples = [
80
- `csdx cm:stacks:import --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>`,
81
- `csdx cm:stacks:import --config <path/of/config/dir>`,
82
- `csdx cm:stacks:import --module <single module name>`,
83
- `csdx cm:stacks:import --module <single module name> --backup-dir <backup dir>`,
84
- `csdx cm:stacks:import --alias <management_token_alias>`,
85
- `csdx cm:stacks:import --alias <management_token_alias> --data-dir <path/of/export/destination/dir>`,
86
- `csdx cm:stacks:import --alias <management_token_alias> --config <path/of/config/file>`,
87
- `csdx cm:stacks:import --branch <branch name> --yes`,
88
- ];
89
- ImportCommand.flags = {
90
- config: flags.string({
91
- char: 'c',
92
- description: '[optional] path of config file',
93
- }),
94
- 'stack-uid': flags.string({
95
- char: 's',
96
- description: 'API key of the target stack',
97
- hidden: true,
98
- parse: printFlagDeprecation(['-s', '--stack-uid'], ['-k', '--stack-api-key']),
99
- }),
100
- 'stack-api-key': flags.string({
101
- char: 'k',
102
- description: 'API key of the target stack',
103
- }),
104
- data: flags.string({
105
- description: 'path and location where data is stored',
106
- hidden: true,
107
- parse: printFlagDeprecation(['--data'], ['--data-dir']),
108
- }),
109
- 'data-dir': flags.string({
110
- char: 'd',
111
- description: 'path and location where data is stored',
112
- }),
113
- alias: flags.string({
114
- char: 'a',
115
- description: 'alias of the management token',
116
- }),
117
- 'management-token-alias': flags.string({
118
- description: 'alias of the management token',
119
- hidden: true,
120
- parse: printFlagDeprecation(['--management-token-alias'], ['-a', '--alias']),
121
- }),
122
- 'auth-token': flags.boolean({
123
- char: 'A',
124
- description: 'to use auth token',
125
- hidden: true,
126
- parse: printFlagDeprecation(['-A', '--auth-token']),
127
- }),
128
- module: flags.string({
129
- char: 'm',
130
- description: '[optional] specific module name',
131
- parse: printFlagDeprecation(['-m'], ['--module']),
132
- }),
133
- 'backup-dir': flags.string({
134
- char: 'b',
135
- description: '[optional] backup directory name when using specific module',
136
- parse: printFlagDeprecation(['-b'], ['--backup-dir']),
137
- }),
138
- branch: flags.string({
139
- char: 'B',
140
- description: '[optional] branch name',
141
- parse: printFlagDeprecation(['-B'], ['--branch']),
142
- }),
143
- 'import-webhook-status': flags.string({
144
- description: '[optional] Webhook state',
145
- options: ['disable', 'current'],
146
- required: false,
147
- default: 'disable',
148
- }),
149
- yes: flags.boolean({
150
- char: 'y',
151
- required: false,
152
- description: '[optional] Override marketplace prompts',
153
- }),
154
- };
155
-
156
- ImportCommand.aliases = ['cm:import'];
157
-
158
- ImportCommand.usage =
159
- 'cm:stacks:import [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--backup-dir <value>] [--branch <value>] [--import-webhook-status disable|current]';
160
-
161
- module.exports = ImportCommand;
@@ -1,352 +0,0 @@
1
- module.exports = {
2
- versioning: false,
3
- // use below hosts for eu region
4
- // host:'https://eu-api.contentstack.com/v3',
5
- // use below hosts for azure-na region
6
- // host:'https://azure-na-api.contentstack.com/v3',
7
- // use below hosts for azure-eu region
8
- // host:'https://azure-eu-api.contentstack.com/v3',
9
- // pass locale, only to migrate entries from that locale
10
- // not passing `locale` will migrate all the locales present
11
- // locales: ['fr-fr'],
12
- host: 'https://api.contentstack.io/v3',
13
- extensionHost: 'https://app.contentstack.com',
14
- developerHubUrls: {
15
- 'https://api.contentstack.io': 'https://developerhub-api.contentstack.com',
16
- 'https://eu-api.contentstack.com': 'https://eu-developerhub-api.contentstack.com',
17
- 'https://azure-na-api.contentstack.com': 'https://azure-na-developerhub-api.contentstack.com',
18
- 'https://azure-eu-api.contentstack.com': 'https://azure-eu-developerhub-api.contentstack.com',
19
- 'https://stag-api.csnonprod.com': 'https://stag-developerhub-api.csnonprod.com',
20
- },
21
- modules: {
22
- types: [
23
- 'locales',
24
- 'environments',
25
- 'assets',
26
- 'extensions',
27
- 'marketplace-apps',
28
- 'global-fields',
29
- 'content-types',
30
- 'custom-roles',
31
- 'workflows',
32
- 'entries',
33
- 'labels',
34
- 'webhooks',
35
- ],
36
- locales: {
37
- dirName: 'locales',
38
- fileName: 'locales.json',
39
- requiredKeys: ['code', 'uid', 'name', 'fallback_locale'],
40
- },
41
- masterLocale: {
42
- dirName: 'locales',
43
- fileName: 'master-locale.json',
44
- requiredKeys: ['code', 'uid', 'name'],
45
- },
46
- customRoles: {
47
- dirName: 'custom-roles',
48
- fileName: 'custom-roles.json',
49
- customRolesLocalesFileName: 'custom-roles-locales.json',
50
- },
51
- environments: {
52
- dirName: 'environments',
53
- fileName: 'environments.json',
54
- },
55
- labels: {
56
- dirName: 'labels',
57
- fileName: 'labels.json',
58
- },
59
- extensions: {
60
- dirName: 'extensions',
61
- fileName: 'extensions.json',
62
- },
63
- webhooks: {
64
- dirName: 'webhooks',
65
- fileName: 'webhooks.json',
66
- },
67
- releases: {
68
- dirName: 'releases',
69
- fileName: 'releases.json',
70
- invalidKeys: ['stackHeaders', 'urlPath', 'created_at', 'updated_at', 'created_by', 'updated_by'],
71
- },
72
- workflows: {
73
- dirName: 'workflows',
74
- fileName: 'workflows.json',
75
- invalidKeys: ['stackHeaders', 'urlPath', 'created_at', 'updated_at', 'created_by', 'updated_by'],
76
- },
77
- assets: {
78
- dirName: 'assets',
79
- fileName: 'assets.json',
80
- // This is the total no. of asset objects fetched in each 'get assets' call
81
- limit: 100,
82
- host: 'https://api.contentstack.io',
83
- validKeys: ['uid', 'filename', 'url', 'status'],
84
- assetBatchLimit: 1,
85
- uploadAssetsConcurrency: 1,
86
- importFoldersConcurrency: 1,
87
- },
88
- content_types: {
89
- dirName: 'content_types',
90
- fileName: 'content_types.json',
91
- validKeys: ['title', 'uid', 'schema', 'options', 'singleton', 'description'],
92
- limit: 100,
93
- },
94
- entries: {
95
- dirName: 'entries',
96
- fileName: 'entries.json',
97
- invalidKeys: ['created_at', 'updated_at', 'created_by', 'updated_by', '_metadata', 'published'],
98
- limit: 50,
99
- assetBatchLimit: 5,
100
- },
101
- globalfields: {
102
- dirName: 'global_fields',
103
- fileName: 'globalfields.json',
104
- validKeys: ['title', 'uid', 'schema', 'options', 'singleton', 'description'],
105
- limit: 100,
106
- },
107
- stack: {
108
- dirName: 'stack',
109
- fileName: 'stack.json',
110
- },
111
- marketplace_apps: {
112
- dirName: 'marketplace_apps',
113
- fileName: 'marketplace_apps.json',
114
- },
115
- },
116
- languagesCode: [
117
- 'af-za',
118
- 'sq-al',
119
- 'ar',
120
- 'ar-dz',
121
- 'ar-bh',
122
- 'ar-eg',
123
- 'ar-iq',
124
- 'ar-jo',
125
- 'ar-kw',
126
- 'ar-lb',
127
- 'ar-ly',
128
- 'ar-ma',
129
- 'ar-om',
130
- 'ar-qa',
131
- 'ar-sa',
132
- 'ar-sy',
133
- 'ar-tn',
134
- 'ar-ae',
135
- 'ar-ye',
136
- 'hy-am',
137
- 'az',
138
- 'cy-az-az',
139
- 'lt-az-az',
140
- 'eu-es',
141
- 'be-by',
142
- 'bs',
143
- 'bg-bg',
144
- 'ca-es',
145
- 'zh',
146
- 'zh-au',
147
- 'zh-cn',
148
- 'zh-hk',
149
- 'zh-mo',
150
- 'zh-my',
151
- 'zh-sg',
152
- 'zh-tw',
153
- 'zh-chs',
154
- 'zh-cht',
155
- 'hr-hr',
156
- 'cs',
157
- 'cs-cz',
158
- 'da-dk',
159
- 'div-mv',
160
- 'nl',
161
- 'nl-be',
162
- 'nl-nl',
163
- 'en',
164
- 'en-au',
165
- 'en-at',
166
- 'en-be',
167
- 'en-bz',
168
- 'en-ca',
169
- 'en-cb',
170
- 'en-cn',
171
- 'en-cz',
172
- 'en-dk',
173
- 'en-do',
174
- 'en-ee',
175
- 'en-fi',
176
- 'en-fr',
177
- 'en-de',
178
- 'en-gr',
179
- 'en-hk',
180
- 'en-hu',
181
- 'en-in',
182
- 'en-id',
183
- 'en-ie',
184
- 'en-it',
185
- 'en-jm',
186
- 'en-jp',
187
- 'en-kr',
188
- 'en-lv',
189
- 'en-lt',
190
- 'en-lu',
191
- 'en-my',
192
- 'en-mx',
193
- 'en-nz',
194
- 'en-no',
195
- 'en-ph',
196
- 'en-pl',
197
- 'en-pt',
198
- 'en-pr',
199
- 'en-ru',
200
- 'en-sg',
201
- 'en-sk',
202
- 'en-si',
203
- 'en-za',
204
- 'en-es',
205
- 'en-se',
206
- 'en-ch',
207
- 'en-th',
208
- 'en-nl',
209
- 'en-tt',
210
- 'en-gb',
211
- 'en-us',
212
- 'en-zw',
213
- 'et-ee',
214
- 'fo-fo',
215
- 'fa-ir',
216
- 'fi',
217
- 'fi-fi',
218
- 'fr',
219
- 'fr-be',
220
- 'fr-ca',
221
- 'fr-fr',
222
- 'fr-lu',
223
- 'fr-mc',
224
- 'fr-ch',
225
- 'fr-us',
226
- 'gd',
227
- 'gl-es',
228
- 'ka-ge',
229
- 'de',
230
- 'de-at',
231
- 'de-de',
232
- 'de-li',
233
- 'de-lu',
234
- 'de-ch',
235
- 'el-gr',
236
- 'gu-in',
237
- 'he-il',
238
- 'hi-in',
239
- 'hu-hu',
240
- 'is-is',
241
- 'id-id',
242
- 'it',
243
- 'it-it',
244
- 'it-ch',
245
- 'ja',
246
- 'ja-jp',
247
- 'kn-in',
248
- 'kk-kz',
249
- 'km-kh',
250
- 'kok-in',
251
- 'ko',
252
- 'ko-kr',
253
- 'ky-kz',
254
- 'lv-lv',
255
- 'lt-lt',
256
- 'mk-mk',
257
- 'ms',
258
- 'ms-bn',
259
- 'ms-my',
260
- 'ms-sg',
261
- 'mt',
262
- 'mr-in',
263
- 'mn-mn',
264
- 'no',
265
- 'no-no',
266
- 'nb-no',
267
- 'nn-no',
268
- 'pl-pl',
269
- 'pt',
270
- 'pt-br',
271
- 'pt-pt',
272
- 'pa-in',
273
- 'ro-ro',
274
- 'ru',
275
- 'ru-kz',
276
- 'ru-ru',
277
- 'ru-ua',
278
- 'sa-in',
279
- 'cy-sr-sp',
280
- 'lt-sr-sp',
281
- 'sr-me',
282
- 'sk-sk',
283
- 'sl-si',
284
- 'es',
285
- 'es-ar',
286
- 'es-bo',
287
- 'es-cl',
288
- 'es-co',
289
- 'es-cr',
290
- 'es-do',
291
- 'es-ec',
292
- 'es-sv',
293
- 'es-gt',
294
- 'es-hn',
295
- 'es-419',
296
- 'es-mx',
297
- 'es-ni',
298
- 'es-pa',
299
- 'es-py',
300
- 'es-pe',
301
- 'es-pr',
302
- 'es-es',
303
- 'es-us',
304
- 'es-uy',
305
- 'es-ve',
306
- 'sw-ke',
307
- 'sv',
308
- 'sv-fi',
309
- 'sv-se',
310
- 'syr-sy',
311
- 'tl',
312
- 'ta-in',
313
- 'tt-ru',
314
- 'te-in',
315
- 'th-th',
316
- 'tr-tr',
317
- 'uk-ua',
318
- 'ur-pk',
319
- 'uz',
320
- 'cy-uz-uz',
321
- 'lt-uz-uz',
322
- 'vi-vn',
323
- 'xh',
324
- 'zu',
325
- ],
326
- apis: {
327
- userSession: '/user-session/',
328
- locales: '/locales/',
329
- environments: '/environments/',
330
- assets: '/assets/',
331
- content_types: '/content_types/',
332
- entries: '/entries/',
333
- extensions: '/extensions/',
334
- webhooks: '/webhooks/',
335
- globalfields: '/global_fields/',
336
- folders: '/folders/',
337
- stacks: '/stacks/',
338
- labels: '/labels/',
339
- },
340
- rateLimit: 5,
341
- preserveStackVersion: false,
342
- entriesPublish: true,
343
- concurrency: 1,
344
- importConcurrency: 5,
345
- fetchConcurrency: 5,
346
- writeConcurrency: 5,
347
- developerHubBaseUrl: '',
348
- marketplaceAppEncryptionKey: 'nF2ejRQcTv',
349
- getEncryptionKeyMaxRetry: 3,
350
- // useBackedupDir: '',
351
- // backupConcurrency: 10,
352
- };