@contentstack/cli-cm-export 1.5.8 → 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 -161
  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 -451
  79. package/src/lib/export/content-types.js +0 -90
  80. package/src/lib/export/custom-roles.js +0 -93
  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 -69
  86. package/src/lib/export/locales.js +0 -72
  87. package/src/lib/export/marketplace-apps.js +0 -184
  88. package/src/lib/export/stack.js +0 -99
  89. package/src/lib/export/webhooks.js +0 -76
  90. package/src/lib/export/workflows.js +0 -110
  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 -158
  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
@@ -0,0 +1,49 @@
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 file_helper_1 = require("./file-helper");
6
+ const setupBranches = async (config, stackAPIClient) => {
7
+ if (typeof config !== 'object') {
8
+ throw new Error('Invalid config to setup the branch');
9
+ }
10
+ let branches = [];
11
+ if (config.branchName) {
12
+ // check branch exists
13
+ const result = await stackAPIClient
14
+ .branch(config.branchName)
15
+ .fetch()
16
+ .catch((_err) => { });
17
+ if (result && typeof result === 'object') {
18
+ branches.push(result);
19
+ }
20
+ else {
21
+ throw new Error('No branch found with the given name ' + config.branchName);
22
+ }
23
+ }
24
+ else {
25
+ try {
26
+ const result = await stackAPIClient
27
+ .branch()
28
+ .query()
29
+ .find()
30
+ .catch((_err) => { });
31
+ if (result && result.items && Array.isArray(result.items) && result.items.length > 0) {
32
+ branches = result.items;
33
+ }
34
+ else {
35
+ return;
36
+ }
37
+ }
38
+ catch (error) {
39
+ // Note skips the error
40
+ return;
41
+ }
42
+ }
43
+ (0, file_helper_1.makeDirectory)(config.exportDir);
44
+ // create branch info file
45
+ (0, file_helper_1.writeFileSync)(path.join(config.exportDir, 'branches.json'), branches);
46
+ // add branches list in the
47
+ config.branches = branches;
48
+ };
49
+ exports.default = setupBranches;
@@ -0,0 +1,2 @@
1
+ import { ExportConfig } from '../types';
2
+ export default function setupExportDir(exportConfig: ExportConfig): Promise<void[]>;
@@ -0,0 +1,12 @@
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 file_helper_1 = require("./file-helper");
6
+ async function setupExportDir(exportConfig) {
7
+ (0, file_helper_1.makeDirectory)(exportConfig.exportDir);
8
+ if (exportConfig.branches) {
9
+ return Promise.all(exportConfig.branches.map((branch) => (0, file_helper_1.makeDirectory)(path_1.default.join(exportConfig.exportDir, branch.uid))));
10
+ }
11
+ }
12
+ exports.default = setupExportDir;
@@ -1,7 +1 @@
1
- {
2
- "promptMessageList": {
3
- "promptMasterLocale": "Provide the master locale of the source stack",
4
- "promptSourceStack": "Provide the API Key of the source stack",
5
- "promptPathStoredData": "Provide the path to store the content"
6
- }
7
- }
1
+ {}
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.8",
2
+ "version": "1.6.1",
3
3
  "commands": {
4
4
  "cm:stacks:export": {
5
5
  "id": "cm:stacks:export",
package/package.json CHANGED
@@ -1,33 +1,38 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-export",
3
3
  "description": "Contentstack CLI plugin to export content from stack",
4
- "version": "1.5.8",
4
+ "version": "1.6.1",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-command": "^1.2.8",
9
- "@contentstack/cli-utilities": "^1.4.4",
8
+ "@contentstack/cli-command": "^1.2.0",
9
+ "@contentstack/cli-utilities": "^1.5.0",
10
10
  "@oclif/command": "^1.8.16",
11
11
  "@oclif/config": "^1.18.3",
12
+ "@oclif/core": "^2.3.0",
12
13
  "async": "^3.2.4",
13
14
  "big-json": "^3.2.0",
14
15
  "bluebird": "^3.7.2",
15
16
  "chalk": "^4.1.2",
16
17
  "is-valid-path": "^0.1.1",
17
18
  "lodash": "^4.17.20",
18
- "mkdirp": "^2.1.3",
19
+ "merge": "^2.1.1",
20
+ "mkdirp": "^1.0.4",
19
21
  "path": "^0.12.7",
20
22
  "progress-stream": "^2.0.0",
21
23
  "promise-limit": "^2.7.0",
22
24
  "proxyquire": "^2.1.3",
25
+ "tslib": "^2.4.1",
23
26
  "winston": "^3.7.2"
24
27
  },
25
28
  "devDependencies": {
26
- "@contentstack/cli-auth": "^1.3.8",
27
- "@contentstack/cli-config": "^1.4.6",
29
+ "@contentstack/cli-auth": "^1.3.11",
30
+ "@contentstack/cli-config": "^1.4.9",
28
31
  "@contentstack/cli-dev-dependencies": "^1.2.3",
29
32
  "@oclif/plugin-help": "^5.1.19",
30
33
  "@oclif/test": "^1.2.6",
34
+ "@types/mkdirp": "^1.0.2",
35
+ "@types/progress-stream": "^2.0.2",
31
36
  "assert": "^2.0.0",
32
37
  "chai": "^4.2.0",
33
38
  "dotenv": "^16.0.1",
@@ -37,17 +42,35 @@
37
42
  "globby": "^10.0.2",
38
43
  "mocha": "10.1.0",
39
44
  "nyc": "^15.1.0",
45
+ "oclif": "^3.8.1",
40
46
  "sinon": "^15.0.1",
41
- "oclif": "^3.8.1"
47
+ "ts-node": "^10.9.1",
48
+ "typescript": "^4.9.3"
49
+ },
50
+ "scripts": {
51
+ "build": "npm run clean && npm run compile",
52
+ "clean": "rm -rf ./lib ./node_modules tsconfig.build.tsbuildinfo",
53
+ "compile": "tsc -b tsconfig.json",
54
+ "postpack": "rm -f oclif.manifest.json",
55
+ "prepack": "pnpm compile && oclif manifest && oclif readme",
56
+ "version": "oclif readme && git add README.md",
57
+ "test:report": "tsc -p test && nyc --reporter=lcov --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
58
+ "pretest": "tsc -p test",
59
+ "test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
60
+ "posttest": "npm run lint",
61
+ "lint": "eslint src/**/*.ts",
62
+ "format": "eslint src/**/*.ts --fix",
63
+ "test:integration": "INTEGRATION_TEST=true mocha --config ./test/.mocharc.js --forbid-only \"test/run.test.js\"",
64
+ "test:unit": "mocha --forbid-only \"test/unit/*.test.ts\""
42
65
  },
43
66
  "engines": {
44
67
  "node": ">=14.0.0"
45
68
  },
46
69
  "files": [
70
+ "/lib",
71
+ "/messages",
47
72
  "/npm-shrinkwrap.json",
48
- "/oclif.manifest.json",
49
- "/src",
50
- "/messages"
73
+ "/oclif.manifest.json"
51
74
  ],
52
75
  "homepage": "https://github.com/contentstack/cli",
53
76
  "keywords": [
@@ -56,17 +79,9 @@
56
79
  "plugin"
57
80
  ],
58
81
  "license": "MIT",
59
- "scripts": {
60
- "postpack": "rm -f oclif.manifest.json",
61
- "prepack": "oclif manifest && oclif readme",
62
- "test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
63
- "version": "oclif readme && git add README.md",
64
- "clean": "rm -rf ./node_modules tsconfig.build.tsbuildinfo",
65
- "test:integration": "INTEGRATION_TEST=true mocha --config ./test/.mocharc.js --forbid-only \"test/run.test.js\"",
66
- "test:unit": "mocha --forbid-only \"test/unit/*.test.js\" --unit-test"
67
- },
82
+ "main": "./lib/commands/cm/stacks/export.js",
68
83
  "oclif": {
69
- "commands": "./src/commands",
84
+ "commands": "./lib/commands",
70
85
  "bin": "csdx",
71
86
  "devPlugins": [
72
87
  "@oclif/plugin-help"
@@ -79,9 +94,8 @@
79
94
  },
80
95
  "shortCommandName": {
81
96
  "cm:stacks:export": "EXPRT",
82
- "cm:export": "O-EXPRT"
97
+ "cm:export": "EXPRT"
83
98
  }
84
99
  },
85
- "main": "./src/commands/cm/stacks/export.js",
86
100
  "repository": "https://github.com/contentstack/cli"
87
- }
101
+ }
package/src/app.js DELETED
@@ -1,161 +0,0 @@
1
- /* eslint-disable no-redeclare */
2
- const _ = require('lodash');
3
- const path = require('path');
4
- const chalk = require('chalk');
5
- const util = require('./lib/util');
6
- const login = require('./lib/util/login');
7
- const setupBranches = require('./lib/util/setup-branches');
8
- const { addlogs, unlinkFileLogger } = require('./lib/util/log');
9
- const { managementSDKClient, isAuthenticated } = require('@contentstack/cli-utilities');
10
-
11
- exports.initial = async (config) => {
12
- return new Promise(async (resolve, reject) => {
13
- config = util.buildAppConfig(config);
14
- util.validateConfig(config);
15
- exports.getConfig = () => {
16
- return config;
17
- };
18
-
19
- const APIClient = await managementSDKClient(config);
20
- const stackAPIClient = APIClient.stack({
21
- api_key: config.source_stack,
22
- management_token: config.management_token,
23
- });
24
-
25
- const fetchBranchAndExport = async (APIClient, stackAPIClient) => {
26
- await setupBranches(config, config.branchName, stackAPIClient);
27
- let types = config.modules.types;
28
-
29
- if (Array.isArray(config.branches) && config.branches.length > 0) {
30
- for (let branch of config.branches) {
31
- config.branchName = branch.uid;
32
- try {
33
- if (config.moduleName) {
34
- await singleExport(APIClient, stackAPIClient, config.moduleName, types, config, branch.uid);
35
- } else {
36
- await allExport(APIClient, stackAPIClient, config, types, branch.uid);
37
- }
38
- } catch (error) {
39
- addlogs(config, `failed export contents ${branch.uid} ${util.formatError(error)}`, 'error');
40
- }
41
- }
42
- } else {
43
- try {
44
- if (config.moduleName) {
45
- await singleExport(APIClient, stackAPIClient, config.moduleName, types, config);
46
- } else {
47
- await allExport(APIClient, stackAPIClient, config, types);
48
- }
49
- } catch (error) {
50
- addlogs(config, `failed export contents ${util.formatError(error)}`, 'error');
51
- }
52
- }
53
- };
54
-
55
- if (config.management_token || config.isAuthenticated) {
56
- try {
57
- await fetchBranchAndExport(APIClient, stackAPIClient);
58
- } catch (error) {
59
- addlogs(config, `${util.formatError(error)}`, 'error');
60
- }
61
- resolve();
62
- } else if (
63
- (config.email && config.password) ||
64
- (!config.email && !config.password && config.source_stack && config.access_token) ||
65
- (isAuthenticated() && !config.management_token)
66
- ) {
67
- login
68
- .login(config, APIClient, stackAPIClient)
69
- .then(async function () {
70
- // setup branches
71
- try {
72
- await fetchBranchAndExport(APIClient, stackAPIClient);
73
- unlinkFileLogger();
74
- } catch (error) {
75
- addlogs(config, `${util.formatError(error)}`, 'error');
76
- }
77
- resolve();
78
- })
79
- .catch((error) => {
80
- console.log('error', error && error.message);
81
- if (error && error.errors && error.errors.api_key) {
82
- addlogs(config, chalk.red('Stack Api key ' + error.errors.api_key[0], 'Please enter valid Key', 'error'));
83
- addlogs(config, 'The log for this is stored at ' + config.data + '/export/logs', 'success');
84
- } else {
85
- addlogs(config, `${util.formatError(error)}`, 'error');
86
- }
87
- });
88
- } else {
89
- reject('Kindly login or provide management_token');
90
- }
91
- });
92
- };
93
-
94
- const singleExport = async (APIClient, stackAPIClient, moduleName, types, config, branchName) => {
95
- try {
96
- if (types.indexOf(moduleName) > -1) {
97
- let iterateList;
98
- if (config.modules.dependency && config.modules.dependency[moduleName]) {
99
- iterateList = config.modules.dependency[moduleName];
100
- } else {
101
- iterateList = ['stack'];
102
- }
103
- iterateList.push(moduleName);
104
-
105
- for (let element of iterateList) {
106
- const ExportModule = require('./lib/export/' + element);
107
- const result = await new ExportModule(config, stackAPIClient, APIClient).start(config, branchName);
108
- if (result && element === 'stack') {
109
- let master_locale = {
110
- master_locale: { code: result.code },
111
- };
112
- config = _.merge(config, master_locale);
113
- }
114
- }
115
- addlogs(config, moduleName + ' was exported successfully!', 'success');
116
- addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success');
117
- } else {
118
- addlogs(config, 'Please provide valid module name.', 'error');
119
- }
120
- return true;
121
- } catch (error) {
122
- addlogs(config, `${util.formatError(error)}`, 'error');
123
- addlogs(config, 'Failed to migrate ' + moduleName, 'error');
124
- addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error');
125
- }
126
- };
127
-
128
- const allExport = async (APIClient, stackAPIClient, config, types, branchName) => {
129
- try {
130
- for (let type of types) {
131
- const ExportModule = require('./lib/export/' + type);
132
- const result = await new ExportModule(config, stackAPIClient, APIClient).start(config, branchName);
133
-
134
- if (result && type === 'stack') {
135
- let master_locale = { master_locale: { code: result.code } };
136
- config = _.merge(config, master_locale);
137
- }
138
- }
139
- addlogs(
140
- config,
141
- chalk.green(
142
- 'The content of stack ' + (config.sourceStackName || config.source_stack) + ' has been exported successfully!',
143
- ),
144
- 'success',
145
- );
146
- addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success');
147
- return true;
148
- } catch (error) {
149
- addlogs(config, util.formatError(error), 'error');
150
- addlogs(
151
- config,
152
- chalk.red(
153
- 'Failed to migrate stack: ' +
154
- (config.sourceStackName || config.source_stack) +
155
- '. Please check error logs for more info',
156
- ),
157
- 'error',
158
- );
159
- addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error');
160
- }
161
- };
@@ -1,202 +0,0 @@
1
- /* eslint-disable complexity */
2
- const { Command } = require('@contentstack/cli-command');
3
- const { printFlagDeprecation, configHandler, flags, isAuthenticated } = require('@contentstack/cli-utilities');
4
- const {
5
- configWithMToken,
6
- parameterWithMToken,
7
- withoutParameterMToken,
8
- configWithAuthToken,
9
- parametersWithAuthToken,
10
- withoutParametersWithAuthToken,
11
- } = require('../../../lib/util/export-flags');
12
- const config = require('../../../config/default');
13
-
14
- class ExportCommand extends Command {
15
- async run() {
16
- const { flags: exportCommandFlags } = await this.parse(ExportCommand);
17
- const extConfig = exportCommandFlags.config;
18
- const sourceStack = exportCommandFlags['stack-uid'] || exportCommandFlags['stack-api-key'];
19
- const alias = exportCommandFlags['alias'] || exportCommandFlags['management-token-alias'];
20
- const securedAssets = exportCommandFlags['secured-assets'];
21
- const data = exportCommandFlags.data || exportCommandFlags['data-dir'];
22
- const moduleName = exportCommandFlags.module;
23
- const contentTypes = exportCommandFlags['content-types'];
24
- const branchName = exportCommandFlags.branch;
25
- let host = this.region;
26
- let cmaHost = host.cma.split('//');
27
- let cdaHost = host.cda.split('//');
28
- host.cma = cmaHost[1];
29
- host.cda = cdaHost[1];
30
- exportCommandFlags['isAuthenticated'] = isAuthenticated();
31
-
32
- config.forceStopMarketplaceAppsPrompt = exportCommandFlags.yes;
33
-
34
- if (alias) {
35
- const managementTokens = this.getToken(alias);
36
- const listOfTokens = configHandler.get('tokens');
37
- config.management_token_data = listOfTokens[alias];
38
-
39
- if (managementTokens) {
40
- if (extConfig) {
41
- await configWithMToken(
42
- extConfig,
43
- managementTokens,
44
- host,
45
- contentTypes,
46
- branchName,
47
- securedAssets,
48
- moduleName,
49
- data,
50
- exportCommandFlags,
51
- );
52
- } else if (data) {
53
- await parameterWithMToken(
54
- managementTokens,
55
- data,
56
- moduleName,
57
- host,
58
- contentTypes,
59
- branchName,
60
- securedAssets,
61
- exportCommandFlags,
62
- );
63
- } else if (data === undefined && sourceStack === undefined) {
64
- await withoutParameterMToken(
65
- managementTokens,
66
- moduleName,
67
- host,
68
- contentTypes,
69
- branchName,
70
- securedAssets,
71
- exportCommandFlags,
72
- );
73
- } else {
74
- this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage');
75
- }
76
- } else {
77
- this.log(alias + ' management token is not present, please add managment token first');
78
- }
79
- } else if (isAuthenticated()) {
80
- if (extConfig) {
81
- await configWithAuthToken(
82
- extConfig,
83
- moduleName,
84
- host,
85
- contentTypes,
86
- branchName,
87
- securedAssets,
88
- exportCommandFlags,
89
- );
90
- } else if (sourceStack && data) {
91
- return await parametersWithAuthToken(
92
- sourceStack,
93
- data,
94
- moduleName,
95
- host,
96
- contentTypes,
97
- branchName,
98
- securedAssets,
99
- exportCommandFlags,
100
- );
101
- } else if (data === undefined && sourceStack === undefined) {
102
- await withoutParametersWithAuthToken(
103
- moduleName,
104
- host,
105
- contentTypes,
106
- branchName,
107
- securedAssets,
108
- exportCommandFlags,
109
- );
110
- } else {
111
- this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage');
112
- }
113
- } else {
114
- this.log('Login or provide the alias for management token');
115
- }
116
- }
117
- }
118
-
119
- ExportCommand.description = `Export content from a stack`;
120
- ExportCommand.examples = [
121
- 'csdx cm:stacks:export --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>',
122
- 'csdx cm:stacks:export --config <path/to/config/dir>',
123
- 'csdx cm:stacks:export --alias <management_token_alias>',
124
- 'csdx cm:stacks:export --alias <management_token_alias> --data-dir <path/to/export/destination/dir>',
125
- 'csdx cm:stacks:export --alias <management_token_alias> --config <path/to/config/file>',
126
- 'csdx cm:stacks:export --module <single module name>',
127
- 'csdx cm:stacks:export --branch [optional] branch name',
128
- ];
129
- ExportCommand.usage =
130
- 'cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]';
131
-
132
- ExportCommand.flags = {
133
- config: flags.string({
134
- char: 'c',
135
- description: '[optional] path of the config',
136
- }),
137
- 'stack-uid': flags.string({
138
- char: 's',
139
- description: 'API key of the source stack',
140
- hidden: true,
141
- parse: printFlagDeprecation(['-s', '--stack-uid'], ['-k', '--stack-api-key']),
142
- }),
143
- 'stack-api-key': flags.string({
144
- char: 'k',
145
- description: 'API key of the source stack',
146
- }),
147
- data: flags.string({
148
- description: 'path or location to store the data',
149
- hidden: true,
150
- parse: printFlagDeprecation(['--data'], ['--data-dir']),
151
- }),
152
- 'data-dir': flags.string({
153
- char: 'd',
154
- description: 'path or location to store the data',
155
- }),
156
- alias: flags.string({
157
- char: 'a',
158
- description: 'alias of the management token',
159
- }),
160
- 'management-token-alias': flags.string({
161
- description: 'alias of the management token',
162
- hidden: true,
163
- parse: printFlagDeprecation(['--management-token-alias'], ['-a', '--alias']),
164
- }),
165
- 'auth-token': flags.boolean({
166
- char: 'A',
167
- description: 'to use auth token',
168
- hidden: true,
169
- parse: printFlagDeprecation(['-A', '--auth-token']),
170
- }),
171
- module: flags.string({
172
- char: 'm',
173
- description: '[optional] specific module name',
174
- exclusive: ['content-types'],
175
- parse: printFlagDeprecation(['-m'], ['--module']),
176
- }),
177
- 'content-types': flags.string({
178
- char: 't',
179
- description: '[optional] content type',
180
- multiple: true,
181
- exclusive: ['module'],
182
- parse: printFlagDeprecation(['-t'], ['--content-types']),
183
- }),
184
- branch: flags.string({
185
- char: 'B',
186
- // default: 'main',
187
- description: '[optional] branch name',
188
- parse: printFlagDeprecation(['-B'], ['--branch']),
189
- }),
190
- 'secured-assets': flags.boolean({
191
- description: '[optional] use when assets are secured',
192
- }),
193
- yes: flags.boolean({
194
- char: 'y',
195
- required: false,
196
- description: '[optional] Override marketplace apps related prompts',
197
- }),
198
- };
199
-
200
- ExportCommand.aliases = ['cm:export'];
201
-
202
- module.exports = ExportCommand;