@contentstack/cli-cm-export 1.5.9 → 1.6.1

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 (97) hide show
  1. package/README.md +2 -2
  2. package/lib/commands/cm/stacks/export.d.ts +10 -0
  3. package/lib/commands/cm/stacks/export.js +108 -0
  4. package/lib/config/index.d.ts +3 -0
  5. package/lib/config/index.js +393 -0
  6. package/lib/export/index.d.ts +1 -0
  7. package/lib/export/index.js +8 -0
  8. package/lib/export/module-exporter.d.ts +15 -0
  9. package/lib/export/module-exporter.js +93 -0
  10. package/lib/export/modules/assets.d.ts +54 -0
  11. package/lib/export/modules/assets.js +303 -0
  12. package/lib/export/modules/base-class.d.ts +48 -0
  13. package/lib/export/modules/base-class.js +117 -0
  14. package/lib/export/modules/index.d.ts +3 -0
  15. package/lib/export/modules/index.js +38 -0
  16. package/lib/export/modules/locales.d.ts +16 -0
  17. package/lib/export/modules/locales.js +68 -0
  18. package/lib/export/modules-js/assets.d.ts +43 -0
  19. package/lib/export/modules-js/assets.js +391 -0
  20. package/lib/export/modules-js/content-types.d.ts +21 -0
  21. package/lib/export/modules-js/content-types.js +75 -0
  22. package/lib/export/modules-js/custom-roles.d.ts +21 -0
  23. package/lib/export/modules-js/custom-roles.js +76 -0
  24. package/lib/export/modules-js/entries.d.ts +18 -0
  25. package/lib/export/modules-js/entries.js +141 -0
  26. package/lib/export/modules-js/environments.d.ts +16 -0
  27. package/lib/export/modules-js/environments.js +62 -0
  28. package/lib/export/modules-js/extensions.d.ts +18 -0
  29. package/lib/export/modules-js/extensions.js +57 -0
  30. package/lib/export/modules-js/global-fields.d.ts +22 -0
  31. package/lib/export/modules-js/global-fields.js +107 -0
  32. package/lib/export/modules-js/index.d.ts +1 -0
  33. package/lib/export/modules-js/index.js +33 -0
  34. package/lib/export/modules-js/labels.d.ts +14 -0
  35. package/lib/export/modules-js/labels.js +56 -0
  36. package/lib/export/modules-js/locales.d.ts +23 -0
  37. package/lib/export/modules-js/locales.js +67 -0
  38. package/lib/export/modules-js/marketplace-apps.d.ts +21 -0
  39. package/lib/export/modules-js/marketplace-apps.js +144 -0
  40. package/lib/export/modules-js/stack.d.ts +18 -0
  41. package/lib/export/modules-js/stack.js +91 -0
  42. package/lib/export/modules-js/webhooks.d.ts +18 -0
  43. package/lib/export/modules-js/webhooks.js +60 -0
  44. package/lib/export/modules-js/workflows.d.ts +16 -0
  45. package/lib/export/modules-js/workflows.js +89 -0
  46. package/lib/types/default-config.d.ts +158 -0
  47. package/lib/types/default-config.js +2 -0
  48. package/lib/types/export-config.d.ts +34 -0
  49. package/lib/types/export-config.js +2 -0
  50. package/lib/types/index.d.ts +45 -0
  51. package/lib/types/index.js +2 -0
  52. package/lib/utils/basic-login.d.ts +8 -0
  53. package/lib/utils/basic-login.js +45 -0
  54. package/lib/utils/common-helper.d.ts +11 -0
  55. package/lib/utils/common-helper.js +78 -0
  56. package/lib/utils/export-config-handler.d.ts +3 -0
  57. package/lib/utils/export-config-handler.js +72 -0
  58. package/lib/utils/file-helper.d.ts +14 -0
  59. package/lib/utils/file-helper.js +120 -0
  60. package/lib/utils/index.d.ts +10 -0
  61. package/lib/utils/index.js +21 -0
  62. package/lib/utils/interactive.d.ts +6 -0
  63. package/lib/utils/interactive.js +71 -0
  64. package/lib/utils/logger.d.ts +8 -0
  65. package/lib/utils/logger.js +154 -0
  66. package/lib/utils/marketplace-app-helper.d.ts +1 -0
  67. package/lib/utils/marketplace-app-helper.js +23 -0
  68. package/lib/utils/setup-branches.d.ts +3 -0
  69. package/lib/utils/setup-branches.js +49 -0
  70. package/lib/utils/setup-export-dir.d.ts +2 -0
  71. package/lib/utils/setup-export-dir.js +12 -0
  72. package/messages/index.json +1 -7
  73. package/oclif.manifest.json +1 -1
  74. package/package.json +37 -23
  75. package/src/app.js +0 -156
  76. package/src/commands/cm/stacks/export.js +0 -202
  77. package/src/config/default.js +0 -360
  78. package/src/lib/export/assets.js +0 -454
  79. package/src/lib/export/content-types.js +0 -90
  80. package/src/lib/export/custom-roles.js +0 -92
  81. package/src/lib/export/entries.js +0 -200
  82. package/src/lib/export/environments.js +0 -74
  83. package/src/lib/export/extensions.js +0 -69
  84. package/src/lib/export/global-fields.js +0 -122
  85. package/src/lib/export/labels.js +0 -67
  86. package/src/lib/export/locales.js +0 -72
  87. package/src/lib/export/marketplace-apps.js +0 -187
  88. package/src/lib/export/stack.js +0 -98
  89. package/src/lib/export/webhooks.js +0 -76
  90. package/src/lib/export/workflows.js +0 -106
  91. package/src/lib/util/export-flags.js +0 -193
  92. package/src/lib/util/helper.js +0 -113
  93. package/src/lib/util/index.js +0 -80
  94. package/src/lib/util/log.js +0 -161
  95. package/src/lib/util/login.js +0 -79
  96. package/src/lib/util/marketplace-app-helper.js +0 -24
  97. package/src/lib/util/setup-branches.js +0 -56
package/README.md CHANGED
@@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export
48
48
  $ csdx COMMAND
49
49
  running command...
50
50
  $ csdx (--version)
51
- @contentstack/cli-cm-export/1.5.9 linux-x64 node-v16.20.0
51
+ @contentstack/cli-cm-export/1.6.1 linux-x64 node-v18.16.1
52
52
  $ csdx --help [COMMAND]
53
53
  USAGE
54
54
  $ csdx COMMAND
@@ -146,5 +146,5 @@ EXAMPLES
146
146
  $ csdx cm:stacks:export --branch [optional] branch name
147
147
  ```
148
148
 
149
- _See code: [src/commands/cm/stacks/export.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-export/src/commands/cm/stacks/export.js)_
149
+ _See code: [src/commands/cm/stacks/export.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-export/src/commands/cm/stacks/export.ts)_
150
150
  <!-- commandsstop -->
@@ -0,0 +1,10 @@
1
+ import { Command } from '@contentstack/cli-command';
2
+ import { FlagInput } from '@contentstack/cli-utilities';
3
+ export default class ExportCommand extends Command {
4
+ static description: string;
5
+ static examples: string[];
6
+ static usage: string;
7
+ static flags: FlagInput;
8
+ static aliases: string[];
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const path_1 = tslib_1.__importDefault(require("path"));
5
+ const cli_command_1 = require("@contentstack/cli-command");
6
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
7
+ const export_1 = require("../../../export");
8
+ const utils_1 = require("../../../utils");
9
+ class ExportCommand extends cli_command_1.Command {
10
+ async run() {
11
+ let exportDir;
12
+ try {
13
+ const { flags } = await this.parse(ExportCommand);
14
+ let exportConfig = await (0, utils_1.setupExportConfig)(flags);
15
+ // Note setting host to create cma client
16
+ exportConfig.host = this.cmaHost;
17
+ exportDir = exportConfig.data || exportConfig.exportDir;
18
+ const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)(exportConfig);
19
+ const moduleExporter = new export_1.ModuleExporter(managementAPIClient, exportConfig);
20
+ await moduleExporter.start();
21
+ (0, utils_1.log)(exportConfig, `The content of the stack ${exportConfig.apiKey} has been exported successfully!`, 'success');
22
+ }
23
+ catch (error) {
24
+ (0, utils_1.log)({ data: exportDir }, `Failed to export stack content - ${(0, utils_1.formatError)(error)}`, 'error');
25
+ (0, utils_1.log)({ data: exportDir }, `The log has been stored at ${exportDir ? path_1.default.join(exportDir, 'logs', 'export') : path_1.default.join(__dirname, 'logs')}`, 'info');
26
+ }
27
+ }
28
+ }
29
+ exports.default = ExportCommand;
30
+ ExportCommand.description = cli_utilities_1.messageHandler.parse('Export content from a stack');
31
+ ExportCommand.examples = [
32
+ 'csdx cm:stacks:export --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>',
33
+ 'csdx cm:stacks:export --config <path/to/config/dir>',
34
+ 'csdx cm:stacks:export --alias <management_token_alias>',
35
+ 'csdx cm:stacks:export --alias <management_token_alias> --data-dir <path/to/export/destination/dir>',
36
+ 'csdx cm:stacks:export --alias <management_token_alias> --config <path/to/config/file>',
37
+ 'csdx cm:stacks:export --module <single module name>',
38
+ 'csdx cm:stacks:export --branch [optional] branch name',
39
+ ];
40
+ ExportCommand.usage = 'cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]';
41
+ ExportCommand.flags = {
42
+ config: cli_utilities_1.flags.string({
43
+ char: 'c',
44
+ description: '[optional] path of the config',
45
+ }),
46
+ 'stack-uid': cli_utilities_1.flags.string({
47
+ char: 's',
48
+ description: 'API key of the source stack',
49
+ hidden: true,
50
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['-s', '--stack-uid'], ['-k', '--stack-api-key']),
51
+ }),
52
+ 'stack-api-key': cli_utilities_1.flags.string({
53
+ char: 'k',
54
+ description: 'API key of the source stack',
55
+ }),
56
+ data: cli_utilities_1.flags.string({
57
+ description: 'path or location to store the data',
58
+ hidden: true,
59
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['--data'], ['--data-dir']),
60
+ }),
61
+ 'data-dir': cli_utilities_1.flags.string({
62
+ char: 'd',
63
+ description: 'path or location to store the data',
64
+ }),
65
+ alias: cli_utilities_1.flags.string({
66
+ char: 'a',
67
+ description: 'alias of the management token',
68
+ }),
69
+ 'management-token-alias': cli_utilities_1.flags.string({
70
+ description: 'alias of the management token',
71
+ hidden: true,
72
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['--management-token-alias'], ['-a', '--alias']),
73
+ }),
74
+ 'auth-token': cli_utilities_1.flags.boolean({
75
+ char: 'A',
76
+ description: 'to use auth token',
77
+ hidden: true,
78
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['-A', '--auth-token']),
79
+ }),
80
+ module: cli_utilities_1.flags.string({
81
+ char: 'm',
82
+ description: '[optional] specific module name',
83
+ exclusive: ['content-types'],
84
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['-m'], ['--module']),
85
+ }),
86
+ 'content-types': cli_utilities_1.flags.string({
87
+ char: 't',
88
+ description: '[optional] content type',
89
+ multiple: true,
90
+ exclusive: ['module'],
91
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['-t'], ['--content-types']),
92
+ }),
93
+ branch: cli_utilities_1.flags.string({
94
+ char: 'B',
95
+ // default: 'main',
96
+ description: '[optional] branch name',
97
+ parse: (0, cli_utilities_1.printFlagDeprecation)(['-B'], ['--branch']),
98
+ }),
99
+ 'secured-assets': cli_utilities_1.flags.boolean({
100
+ description: '[optional] use when assets are secured',
101
+ }),
102
+ yes: cli_utilities_1.flags.boolean({
103
+ char: 'y',
104
+ required: false,
105
+ description: '[optional] Override marketplace apps related prompts',
106
+ }),
107
+ };
108
+ ExportCommand.aliases = ['cm:export'];
@@ -0,0 +1,3 @@
1
+ import { DefaultConfig } from '../types';
2
+ declare const config: DefaultConfig;
3
+ export default config;
@@ -0,0 +1,393 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config = {
4
+ versioning: false,
5
+ host: 'https://api.contentstack.io/v3',
6
+ developerHubUrls: {
7
+ // NOTE CDA url used as developer-hub url mapper to avoid conflict if user used any custom name
8
+ 'https://api.contentstack.io': 'https://developerhub-api.contentstack.com',
9
+ 'https://eu-api.contentstack.com': 'https://eu-developerhub-api.contentstack.com',
10
+ 'https://azure-na-api.contentstack.com': 'https://azure-na-developerhub-api.contentstack.com',
11
+ 'https://azure-eu-api.contentstack.com': 'https://azure-eu-developerhub-api.contentstack.com',
12
+ 'https://stag-api.csnonprod.com': 'https://stag-developerhub-api.csnonprod.com',
13
+ },
14
+ // use below hosts for eu region
15
+ // host:'https://eu-api.contentstack.com/v3',
16
+ // use below hosts for azure-na region
17
+ // host:'https://azure-na-api.contentstack.com/v3',
18
+ // use below hosts for azure-eu region
19
+ // host:'https://azure-eu-api.contentstack.com/v3',
20
+ modules: {
21
+ types: [
22
+ 'stack',
23
+ 'assets',
24
+ 'locales',
25
+ 'environments',
26
+ 'extensions',
27
+ 'webhooks',
28
+ 'global-fields',
29
+ 'content-types',
30
+ 'custom-roles',
31
+ 'workflows',
32
+ 'entries',
33
+ 'labels',
34
+ 'marketplace-apps',
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
+ 'custom-roles': {
52
+ dirName: 'custom-roles',
53
+ fileName: 'custom-roles.json',
54
+ customRolesLocalesFileName: 'custom-roles-locales.json',
55
+ },
56
+ environments: {
57
+ dirName: 'environments',
58
+ fileName: 'environments.json',
59
+ },
60
+ labels: {
61
+ dirName: 'labels',
62
+ fileName: 'labels.json',
63
+ invalidKeys: ['stackHeaders', 'uid', 'urlPath', 'created_at', 'updated_at', 'created_by', 'updated_by'],
64
+ },
65
+ webhooks: {
66
+ dirName: 'webhooks',
67
+ fileName: 'webhooks.json',
68
+ },
69
+ releases: {
70
+ dirName: 'releases',
71
+ fileName: 'releases.json',
72
+ releasesList: 'releasesList.json',
73
+ invalidKeys: ['stackHeaders', 'urlPath', 'created_at', 'updated_at', 'created_by', 'updated_by'],
74
+ },
75
+ workflows: {
76
+ dirName: 'workflows',
77
+ fileName: 'workflows.json',
78
+ invalidKeys: ['stackHeaders', 'urlPath', 'created_at', 'updated_at', 'created_by', 'updated_by'],
79
+ },
80
+ globalfields: {
81
+ dirName: 'global_fields',
82
+ fileName: 'globalfields.json',
83
+ validKeys: ['title', 'uid', 'schema', 'options', 'singleton', 'description'],
84
+ },
85
+ 'global-fields': {
86
+ dirName: 'global_fields',
87
+ fileName: 'globalfields.json',
88
+ validKeys: ['title', 'uid', 'schema', 'options', 'singleton', 'description'],
89
+ },
90
+ assets: {
91
+ dirName: 'assets',
92
+ fileName: 'assets.json',
93
+ // This is the total no. of asset objects fetched in each 'get assets' call
94
+ batchLimit: 20,
95
+ host: 'https://images.contentstack.io',
96
+ invalidKeys: ['created_at', 'updated_at', 'created_by', 'updated_by', '_metadata', 'published'],
97
+ // no of asset version files (of a single asset) that'll be downloaded parallel
98
+ chunkFileSize: 1,
99
+ downloadLimit: 10,
100
+ fetchConcurrency: 10,
101
+ assetsMetaKeys: [],
102
+ securedAssets: false,
103
+ displayExecutionTime: false,
104
+ enableDownloadStatus: false,
105
+ includeVersionedAssets: false,
106
+ },
107
+ content_types: {
108
+ dirName: 'content_types',
109
+ fileName: 'content_types.json',
110
+ validKeys: ['title', 'uid', 'field_rules', 'schema', 'options', 'singleton', 'description'],
111
+ // total no of content types fetched in each 'get content types' call
112
+ limit: 100,
113
+ },
114
+ 'content-types': {
115
+ dirName: 'content_types',
116
+ fileName: 'content_types.json',
117
+ validKeys: ['title', 'uid', 'field_rules', 'schema', 'options', 'singleton', 'description'],
118
+ // total no of content types fetched in each 'get content types' call
119
+ limit: 100,
120
+ },
121
+ entries: {
122
+ dirName: 'entries',
123
+ fileName: 'entries.json',
124
+ invalidKeys: [
125
+ 'stackHeaders',
126
+ 'content_type_uid',
127
+ 'urlPath',
128
+ 'created_at',
129
+ 'updated_at',
130
+ 'created_by',
131
+ 'updated_by',
132
+ '_metadata',
133
+ 'published',
134
+ ],
135
+ batchLimit: 20,
136
+ downloadLimit: 5,
137
+ // total no of entries fetched in each content type in a single call
138
+ limit: 100,
139
+ dependencies: ['locales', 'content-types'],
140
+ },
141
+ extensions: {
142
+ dirName: 'extensions',
143
+ fileName: 'extensions.json',
144
+ },
145
+ stack: {
146
+ dirName: 'stack',
147
+ fileName: 'stack.json',
148
+ },
149
+ dependency: {
150
+ entries: ['stack', 'locales', 'content-types'],
151
+ },
152
+ marketplace_apps: {
153
+ dirName: 'marketplace_apps',
154
+ fileName: 'marketplace_apps.json',
155
+ },
156
+ 'marketplace-apps': {
157
+ dirName: 'marketplace_apps',
158
+ fileName: 'marketplace_apps.json',
159
+ },
160
+ },
161
+ languagesCode: [
162
+ 'af-za',
163
+ 'sq-al',
164
+ 'ar',
165
+ 'ar-dz',
166
+ 'ar-bh',
167
+ 'ar-eg',
168
+ 'ar-iq',
169
+ 'ar-jo',
170
+ 'ar-kw',
171
+ 'ar-lb',
172
+ 'ar-ly',
173
+ 'ar-ma',
174
+ 'ar-om',
175
+ 'ar-qa',
176
+ 'ar-sa',
177
+ 'ar-sy',
178
+ 'ar-tn',
179
+ 'ar-ae',
180
+ 'ar-ye',
181
+ 'hy-am',
182
+ 'az',
183
+ 'cy-az-az',
184
+ 'lt-az-az',
185
+ 'eu-es',
186
+ 'be-by',
187
+ 'bs',
188
+ 'bg-bg',
189
+ 'ca-es',
190
+ 'zh',
191
+ 'zh-au',
192
+ 'zh-cn',
193
+ 'zh-hk',
194
+ 'zh-mo',
195
+ 'zh-my',
196
+ 'zh-sg',
197
+ 'zh-tw',
198
+ 'zh-chs',
199
+ 'zh-cht',
200
+ 'hr-hr',
201
+ 'cs',
202
+ 'cs-cz',
203
+ 'da-dk',
204
+ 'div-mv',
205
+ 'nl',
206
+ 'nl-be',
207
+ 'nl-nl',
208
+ 'en',
209
+ 'en-au',
210
+ 'en-at',
211
+ 'en-be',
212
+ 'en-bz',
213
+ 'en-ca',
214
+ 'en-cb',
215
+ 'en-cn',
216
+ 'en-cz',
217
+ 'en-dk',
218
+ 'en-do',
219
+ 'en-ee',
220
+ 'en-fi',
221
+ 'en-fr',
222
+ 'en-de',
223
+ 'en-gr',
224
+ 'en-hk',
225
+ 'en-hu',
226
+ 'en-in',
227
+ 'en-id',
228
+ 'en-ie',
229
+ 'en-it',
230
+ 'en-jm',
231
+ 'en-jp',
232
+ 'en-kr',
233
+ 'en-lv',
234
+ 'en-lt',
235
+ 'en-lu',
236
+ 'en-my',
237
+ 'en-mx',
238
+ 'en-nz',
239
+ 'en-no',
240
+ 'en-ph',
241
+ 'en-pl',
242
+ 'en-pt',
243
+ 'en-pr',
244
+ 'en-ru',
245
+ 'en-sg',
246
+ 'en-sk',
247
+ 'en-si',
248
+ 'en-za',
249
+ 'en-es',
250
+ 'en-se',
251
+ 'en-ch',
252
+ 'en-th',
253
+ 'en-nl',
254
+ 'en-tt',
255
+ 'en-gb',
256
+ 'en-us',
257
+ 'en-zw',
258
+ 'et-ee',
259
+ 'fo-fo',
260
+ 'fa-ir',
261
+ 'fi',
262
+ 'fi-fi',
263
+ 'fr',
264
+ 'fr-be',
265
+ 'fr-ca',
266
+ 'fr-fr',
267
+ 'fr-lu',
268
+ 'fr-mc',
269
+ 'fr-ch',
270
+ 'fr-us',
271
+ 'gd',
272
+ 'gl-es',
273
+ 'ka-ge',
274
+ 'de',
275
+ 'de-at',
276
+ 'de-de',
277
+ 'de-li',
278
+ 'de-lu',
279
+ 'de-ch',
280
+ 'el-gr',
281
+ 'gu-in',
282
+ 'he-il',
283
+ 'hi-in',
284
+ 'hu-hu',
285
+ 'is-is',
286
+ 'id-id',
287
+ 'it',
288
+ 'it-it',
289
+ 'it-ch',
290
+ 'ja',
291
+ 'ja-jp',
292
+ 'kn-in',
293
+ 'kk-kz',
294
+ 'km-kh',
295
+ 'kok-in',
296
+ 'ko',
297
+ 'ko-kr',
298
+ 'ky-kz',
299
+ 'lv-lv',
300
+ 'lt-lt',
301
+ 'mk-mk',
302
+ 'ms',
303
+ 'ms-bn',
304
+ 'ms-my',
305
+ 'ms-sg',
306
+ 'mt',
307
+ 'mr-in',
308
+ 'mn-mn',
309
+ 'no',
310
+ 'no-no',
311
+ 'nb-no',
312
+ 'nn-no',
313
+ 'pl-pl',
314
+ 'pt',
315
+ 'pt-br',
316
+ 'pt-pt',
317
+ 'pa-in',
318
+ 'ro-ro',
319
+ 'ru',
320
+ 'ru-kz',
321
+ 'ru-ru',
322
+ 'ru-ua',
323
+ 'sa-in',
324
+ 'cy-sr-sp',
325
+ 'lt-sr-sp',
326
+ 'sr-me',
327
+ 'sk-sk',
328
+ 'sl-si',
329
+ 'es',
330
+ 'es-ar',
331
+ 'es-bo',
332
+ 'es-cl',
333
+ 'es-co',
334
+ 'es-cr',
335
+ 'es-do',
336
+ 'es-ec',
337
+ 'es-sv',
338
+ 'es-gt',
339
+ 'es-hn',
340
+ 'es-419',
341
+ 'es-mx',
342
+ 'es-ni',
343
+ 'es-pa',
344
+ 'es-py',
345
+ 'es-pe',
346
+ 'es-pr',
347
+ 'es-es',
348
+ 'es-us',
349
+ 'es-uy',
350
+ 'es-ve',
351
+ 'sw-ke',
352
+ 'sv',
353
+ 'sv-fi',
354
+ 'sv-se',
355
+ 'syr-sy',
356
+ 'tl',
357
+ 'ta-in',
358
+ 'tt-ru',
359
+ 'te-in',
360
+ 'th-th',
361
+ 'tr-tr',
362
+ 'uk-ua',
363
+ 'ur-pk',
364
+ 'uz',
365
+ 'cy-uz-uz',
366
+ 'lt-uz-uz',
367
+ 'vi-vn',
368
+ 'xh',
369
+ 'zu',
370
+ ],
371
+ updatedModules: ['assets', 'locales'],
372
+ apis: {
373
+ userSession: '/user-session/',
374
+ globalfields: '/global_fields/',
375
+ locales: '/locales/',
376
+ labels: '/labels/',
377
+ environments: '/environments/',
378
+ assets: '/assets/',
379
+ content_types: '/content_types/',
380
+ entries: '/entries/',
381
+ users: '/stacks',
382
+ extension: '/extensions',
383
+ webhooks: '/webhooks/',
384
+ stacks: '/stacks/',
385
+ },
386
+ preserveStackVersion: false,
387
+ fetchConcurrency: 5,
388
+ writeConcurrency: 5,
389
+ developerHubBaseUrl: '',
390
+ marketplaceAppEncryptionKey: 'nF2ejRQcTv',
391
+ useNewModuleStructure: false,
392
+ };
393
+ exports.default = config;
@@ -0,0 +1 @@
1
+ export { default as ModuleExporter } from './module-exporter';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ModuleExporter = void 0;
7
+ var module_exporter_1 = require("./module-exporter");
8
+ Object.defineProperty(exports, "ModuleExporter", { enumerable: true, get: function () { return __importDefault(module_exporter_1).default; } });
@@ -0,0 +1,15 @@
1
+ import { ContentstackClient } from '@contentstack/cli-utilities';
2
+ import { ExportConfig, Modules } from '../types';
3
+ declare class ModuleExporter {
4
+ private managementAPIClient;
5
+ private exportConfig;
6
+ private stackAPIClient;
7
+ constructor(managementAPIClient: ContentstackClient, exportConfig: ExportConfig);
8
+ start(): Promise<any>;
9
+ exportByBranches(): Promise<void>;
10
+ export(): Promise<any>;
11
+ exportByModuleByName(moduleName: Modules): Promise<void>;
12
+ exportSingleModule(moduleName: Modules): Promise<void>;
13
+ exportAllModules(): Promise<any>;
14
+ }
15
+ export default ModuleExporter;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const path = tslib_1.__importStar(require("path"));
5
+ const utils_1 = require("../utils");
6
+ const modules_1 = tslib_1.__importDefault(require("./modules"));
7
+ const modules_js_1 = tslib_1.__importDefault(require("./modules-js"));
8
+ class ModuleExporter {
9
+ constructor(managementAPIClient, exportConfig) {
10
+ this.managementAPIClient = managementAPIClient;
11
+ this.stackAPIClient = this.managementAPIClient.stack({
12
+ api_key: exportConfig.apiKey,
13
+ management_token: exportConfig.management_token,
14
+ });
15
+ this.exportConfig = exportConfig;
16
+ }
17
+ async start() {
18
+ // setup the branches
19
+ await (0, utils_1.setupBranches)(this.exportConfig, this.stackAPIClient);
20
+ await (0, utils_1.setupExportDir)(this.exportConfig);
21
+ // if branches available run it export by branches
22
+ if (this.exportConfig.branches) {
23
+ this.exportConfig.branchEnabled = true;
24
+ return this.exportByBranches();
25
+ }
26
+ return this.export();
27
+ }
28
+ async exportByBranches() {
29
+ // loop through the branches and export it parallel
30
+ for (const branch of this.exportConfig.branches) {
31
+ try {
32
+ this.exportConfig.branchName = branch.uid;
33
+ this.exportConfig.branchDir = path.join(this.exportConfig.exportDir, branch.uid);
34
+ await this.export();
35
+ (0, utils_1.log)(this.exportConfig, `The content of branch ${branch.uid} has been exported successfully!`, 'success');
36
+ }
37
+ catch (error) {
38
+ (0, utils_1.log)(this.exportConfig, (0, utils_1.formatError)(error), 'error');
39
+ throw new Error(`Failed to export contents from branch ${branch.uid}`);
40
+ }
41
+ }
42
+ }
43
+ async export() {
44
+ // checks for single module or all modules
45
+ if (this.exportConfig.singleModuleExport) {
46
+ return this.exportSingleModule(this.exportConfig.moduleName);
47
+ }
48
+ return this.exportAllModules();
49
+ }
50
+ async exportByModuleByName(moduleName) {
51
+ (0, utils_1.log)(this.exportConfig, `Starting export of ${moduleName} module`, 'info');
52
+ // export the modules by name
53
+ // calls the module runner which inturn calls the module itself
54
+ let exportedModuleResponse;
55
+ if (this.exportConfig.useNewModuleStructure && this.exportConfig.updatedModules.indexOf(moduleName) !== -1) {
56
+ exportedModuleResponse = await (0, modules_1.default)({
57
+ stackAPIClient: this.stackAPIClient,
58
+ exportConfig: this.exportConfig,
59
+ moduleName,
60
+ });
61
+ }
62
+ else {
63
+ exportedModuleResponse = await (0, modules_js_1.default)({
64
+ stackAPIClient: this.stackAPIClient,
65
+ exportConfig: this.exportConfig,
66
+ moduleName,
67
+ });
68
+ }
69
+ // set master locale to config
70
+ if (moduleName === 'stack' && (exportedModuleResponse === null || exportedModuleResponse === void 0 ? void 0 : exportedModuleResponse.code)) {
71
+ this.exportConfig.master_locale = { code: exportedModuleResponse.code };
72
+ }
73
+ }
74
+ async exportSingleModule(moduleName) {
75
+ // Note stack is always exported
76
+ let exportModules = ['stack'];
77
+ const { modules: { [moduleName]: { dependencies = [] } = {} }, } = this.exportConfig;
78
+ if (dependencies.length > 0) {
79
+ exportModules = exportModules.concat(dependencies);
80
+ }
81
+ exportModules.push(moduleName);
82
+ for (const moduleName of exportModules) {
83
+ await this.exportByModuleByName(moduleName);
84
+ }
85
+ }
86
+ async exportAllModules() {
87
+ // use the algorithm to determine the parallel and sequential execution of modules
88
+ for (const moduleName of this.exportConfig.modules.types) {
89
+ await this.exportByModuleByName(moduleName);
90
+ }
91
+ }
92
+ }
93
+ exports.default = ModuleExporter;