@contentstack/cli-cm-export 0.1.1-beta.1 → 0.1.1-beta.12

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.
package/README.md CHANGED
@@ -1,29 +1,33 @@
1
- @contentstack/cli-cm-export
2
- ===================
1
+ # @contentstack/cli-cm-export
3
2
 
4
- It is Contentstack’s CLI plugin to export content from the stack. To learn how to export and import content in Contentstack, refer to the [Migration guide](https://www.contentstack.com/docs/developers/cli/migration/).
3
+ It is Contentstack’s CLI plugin to export content from the stack. To learn how to export and import content in Contentstack, refer to the [Migration guide](https://www.contentstack.com/docs/developers/cli/migration/).
5
4
 
6
5
  [![License](https://img.shields.io/npm/l/@contentstack/cli)](https://github.com/contentstack/cli/blob/main/LICENSE)
7
6
 
8
7
  <!-- toc -->
8
+ * [@contentstack/cli-cm-export](#contentstackcli-cm-export)
9
9
  * [Usage](#usage)
10
10
  * [Commands](#commands)
11
11
  <!-- tocstop -->
12
+
12
13
  # Usage
14
+
13
15
  <!-- usage -->
14
16
  ```sh-session
15
17
  $ npm install -g @contentstack/cli-cm-export
16
18
  $ csdx COMMAND
17
19
  running command...
18
20
  $ csdx (-v|--version|version)
19
- @contentstack/cli-cm-export/0.1.1-beta.1 darwin-x64 node-v10.19.0
21
+ @contentstack/cli-cm-export/0.1.1-beta.12 linux-x64 node-v16.14.2
20
22
  $ csdx --help [COMMAND]
21
23
  USAGE
22
24
  $ csdx COMMAND
23
25
  ...
24
26
  ```
25
27
  <!-- usagestop -->
28
+
26
29
  # Commands
30
+
27
31
  <!-- commands -->
28
32
  * [`csdx cm:export`](#csdx-cmexport)
29
33
 
@@ -37,12 +41,14 @@ USAGE
37
41
 
38
42
  OPTIONS
39
43
  -A, --auth-token to use auth token
44
+ -B, --branch=branch [optional] branch name
40
45
  -a, --management-token-alias=management-token-alias alias of the management token
41
46
  -c, --config=config [optional] path of the config
42
47
  -d, --data=data path or location to store the data
43
- -l, --master-lang=master-lang code of the source stack's master Language
44
48
  -m, --module=module [optional] specific module name
45
49
  -s, --stack-uid=stack-uid API key of the source stack
50
+ -t, --content-type=content-type [optional] content type
51
+ --secured-assets [optional] use when assets are secured
46
52
 
47
53
  DESCRIPTION
48
54
  ...
@@ -50,13 +56,17 @@ DESCRIPTION
50
56
 
51
57
  EXAMPLES
52
58
  csdx cm:export -A
53
- csdx cm:export -A -l 'master-language' -s 'stack_ApiKey' -d 'path/of/export/destination/dir'
54
- csdx cm:export -A -c 'path/of/config/dir'
55
- csdx cm:export -a 'management_token_alias'
56
- csdx cm:export -a "management_token_alias" -l "master-language" -d "path/of/export/destination/dir"
57
- csdx cm:export -a "management_token_alias" -c "path/of/config/file"
58
- csdx cm:export -A -m "single module name"
59
+ csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>
60
+ csdx cm:export -A -c <path/to/config/dir>
61
+ csdx cm:export -A -m <single module name>
62
+ csdx cm:export -A --secured-assets
63
+ csdx cm:export -a <management_token_alias>
64
+ csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>
65
+ csdx cm:export -a <management_token_alias> -c <path/to/config/file>
66
+ csdx cm:export -A -m <single module name>
67
+ csdx cm:export -A -m <single module name> -t <content type>
68
+ csdx cm:export -A -B [optional] branch name
59
69
  ```
60
70
 
61
- _See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.1/packages/contentstack-export/src/commands/cm/export.js)_
71
+ _See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.12/packages/contentstack-export/src/commands/cm/export.js)_
62
72
  <!-- commandsstop -->
@@ -1 +1 @@
1
- {"version":"0.1.1-beta.1","commands":{"cm:export":{"id":"cm:export","description":"Export content from a stack\n...\nExport content from one stack to another\n","pluginName":"@contentstack/cli-cm-export","pluginType":"core","aliases":[],"examples":["csdx cm:export -A","csdx cm:export -A -l 'master-language' -s 'stack_ApiKey' -d 'path/of/export/destination/dir'","csdx cm:export -A -c 'path/of/config/dir'","csdx cm:export -a 'management_token_alias'","csdx cm:export -a \"management_token_alias\" -l \"master-language\" -d \"path/of/export/destination/dir\"","csdx cm:export -a \"management_token_alias\" -c \"path/of/config/file\"","csdx cm:export -A -m \"single module name\""],"flags":{"config":{"name":"config","type":"option","char":"c","description":"[optional] path of the config"},"master-lang":{"name":"master-lang","type":"option","char":"l","description":"code of the source stack's master Language"},"stack-uid":{"name":"stack-uid","type":"option","char":"s","description":"API key of the source stack"},"data":{"name":"data","type":"option","char":"d","description":"path or location to store the data"},"management-token-alias":{"name":"management-token-alias","type":"option","char":"a","description":"alias of the management token"},"auth-token":{"name":"auth-token","type":"boolean","char":"A","description":"to use auth token","allowNo":false},"module":{"name":"module","type":"option","char":"m","description":"[optional] specific module name"}},"args":[]}}}
1
+ {"version":"0.1.1-beta.12","commands":{"cm:export":{"id":"cm:export","description":"Export content from a stack\n...\nExport content from one stack to another\n","pluginName":"@contentstack/cli-cm-export","pluginType":"core","aliases":[],"examples":["csdx cm:export -A","csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>","csdx cm:export -A -c <path/to/config/dir>","csdx cm:export -A -m <single module name>","csdx cm:export -A --secured-assets","csdx cm:export -a <management_token_alias>","csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>","csdx cm:export -a <management_token_alias> -c <path/to/config/file>","csdx cm:export -A -m <single module name>","csdx cm:export -A -m <single module name> -t <content type>","csdx cm:export -A -B [optional] branch name"],"flags":{"config":{"name":"config","type":"option","char":"c","description":"[optional] path of the config"},"stack-uid":{"name":"stack-uid","type":"option","char":"s","description":"API key of the source stack"},"data":{"name":"data","type":"option","char":"d","description":"path or location to store the data"},"management-token-alias":{"name":"management-token-alias","type":"option","char":"a","description":"alias of the management token"},"auth-token":{"name":"auth-token","type":"boolean","char":"A","description":"to use auth token","allowNo":false},"module":{"name":"module","type":"option","char":"m","description":"[optional] specific module name"},"content-type":{"name":"content-type","type":"option","char":"t","description":"[optional] content type"},"branch":{"name":"branch","type":"option","char":"B","description":"[optional] branch name"},"secured-assets":{"name":"secured-assets","type":"boolean","description":"[optional] use when assets are secured","allowNo":false}},"args":[]}}}
package/package.json CHANGED
@@ -1,38 +1,39 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-export",
3
3
  "description": "Contentstack CLI plugin to export content from stack",
4
- "version": "0.1.1-beta.1",
4
+ "version": "0.1.1-beta.12",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/management": "1.0.0",
8
+ "@contentstack/cli-command": "0.1.1-beta.6",
9
+ "@contentstack/management": "^1.3.0",
9
10
  "@oclif/command": "^1.6.1",
10
11
  "@oclif/config": "^1.15.1",
11
- "@contentstack/cli-command": "0.1.1-beta.1",
12
- "axios": "^0.19.2",
12
+ "async": "^3.2.0",
13
+ "axios": "^0.21.1",
13
14
  "bluebird": "^3.7.2",
14
15
  "cli-ux": "^5.4.6",
15
16
  "configstore": "^5.0.1",
16
17
  "fs": "0.0.1-security",
17
18
  "is-valid-path": "^0.1.1",
18
- "lodash": "^4.17.15",
19
+ "lodash": "^4.17.20",
19
20
  "path": "^0.12.7",
20
21
  "proxyquire": "^2.1.3",
21
22
  "request": "^2.88.2",
22
23
  "winston": "^2.2.0"
23
24
  },
24
25
  "devDependencies": {
25
- "assert": "^2.0.0",
26
- "sinon": "^9.0.2",
27
26
  "@oclif/dev-cli": "^1.22.2",
28
27
  "@oclif/plugin-help": "^3.0.1",
29
28
  "@oclif/test": "^1.2.6",
29
+ "assert": "^2.0.0",
30
30
  "chai": "^4.2.0",
31
31
  "eslint": "^5.16.0",
32
32
  "eslint-config-oclif": "^3.1.0",
33
33
  "globby": "^10.0.2",
34
- "mocha": "^5.2.0",
35
- "nyc": "^14.1.1"
34
+ "mocha": "^8.2.1",
35
+ "nyc": "^14.1.1",
36
+ "sinon": "^9.0.2"
36
37
  },
37
38
  "engines": {
38
39
  "node": ">=8.0.0"
@@ -45,11 +46,12 @@
45
46
  ],
46
47
  "homepage": "https://github.com/contentstack/cli",
47
48
  "keywords": [
48
- "contentstack","cli","plugin"
49
+ "contentstack",
50
+ "cli",
51
+ "plugin"
49
52
  ],
50
53
  "license": "MIT",
51
54
  "scripts": {
52
- "pack": "npm pack && mv *.tgz ../../build",
53
55
  "postpack": "rm -f oclif.manifest.json",
54
56
  "prepack": "oclif-dev manifest && oclif-dev readme",
55
57
  "test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
@@ -63,5 +65,6 @@
63
65
  ],
64
66
  "repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/contentstack-export/<%- commandPath %>"
65
67
  },
68
+ "main": "./src/commands/cm/export.js",
66
69
  "repository": "https://github.com/contentstack/cli"
67
70
  }
package/src/app.js CHANGED
@@ -1,74 +1,158 @@
1
1
  /* eslint-disable no-redeclare */
2
- var Bluebird = require('bluebird')
3
- var util = require('./lib/util')
4
- var login = require('./lib/util/login')
5
- var {addlogs} = require('./lib/util/log')
6
- const chalk = require('chalk')
7
- let path = require('path')
2
+ var util = require("./lib/util");
3
+ var login = require("./lib/util/login");
4
+ var { addlogs, unlinkFileLogger } = require("./lib/util/log");
5
+ const setupBranches = require("./lib/util/setup-branches");
6
+ const chalk = require("chalk");
7
+ let path = require("path");
8
+ let _ = require("lodash");
9
+ const cli = require("cli-ux");
8
10
 
9
- exports.initial = function (config) {
10
- config = util.buildAppConfig(config)
11
- util.validateConfig(config)
12
- exports.getConfig = function () {
13
- return config
14
- }
11
+ exports.initial = async function (config) {
12
+ return new Promise(function (resolve, reject) {
13
+ config = util.buildAppConfig(config);
14
+ util.validateConfig(config);
15
+ exports.getConfig = function () {
16
+ return config;
17
+ };
18
+ // try {
19
+ login
20
+ .login(config)
21
+ .then(async function () {
22
+ //setup branches
23
+ await setupBranches(config, config.branchName);
24
+ var types = config.modules.types;
25
+ if (Array.isArray(config.branches) && config.branches.length > 0) {
26
+ for (let branch of config.branches) {
27
+ config.branchName = branch.uid;
28
+ try {
29
+ if (config.moduleName) {
30
+ await singleExport(config.moduleName, types, config, branch.uid);
31
+ } else {
32
+ await allExport(config, types, branch.uid);
33
+ }
34
+ } catch (error) {
35
+ console.log('failed export branch', branch.uid, error)
36
+ }
37
+ }
38
+ } else {
39
+ try {
40
+ if (config.moduleName) {
41
+ await singleExport(config.moduleName, types, config);
42
+ } else {
43
+ await allExport(config, types);
44
+ }
45
+ } catch (error) {
46
+ console.log('failed export contents', error)
47
+ }
48
+ }
49
+ unlinkFileLogger()
50
+ resolve()
51
+ })
52
+ .catch((error) => {
53
+ console.log("error", error);
54
+ if (error && error.errors && error.errors.api_key) {
55
+ addlogs(
56
+ config,
57
+ chalk.red(
58
+ "Stack Api key " + error.errors.api_key[0],
59
+ "Please enter valid Key",
60
+ "error"
61
+ )
62
+ );
63
+ addlogs(
64
+ config,
65
+ "The log for this is stored at " + config.data + "/export/logs",
66
+ "success"
67
+ );
68
+ } else {
69
+ console.log("Stack fail to export")
70
+ }
71
+ reject(error)
72
+ });
73
+ });
74
+ };
15
75
 
16
- login.login(config).then(function () {
17
- var types = config.modules.types
18
- if (config.moduleName && config.moduleName !== undefined) {
19
- singleExport(config.moduleName, types, config)
20
- } else {
21
- allExport(config, types)
22
- }
23
- }).catch(error => {
24
- if (error.errors.api_key) {
25
- addlogs(config, chalk.red('Stack Api key ' + error.errors.api_key[0], 'Please enter valid Key', 'error'))
26
- addlogs(config, 'The log for this is stored at ' + config.data + '/export/logs', 'success')
76
+ var singleExport = async (moduleName, types, config, branchName) => {
77
+ try {
78
+ if (types.indexOf(moduleName) > -1) {
79
+ let iterateList;
80
+ if (config.modules.dependency && config.modules.dependency[moduleName]) {
81
+ iterateList = config.modules.dependency[moduleName];
82
+ } else {
83
+ iterateList = ["stack"];
84
+ }
85
+ iterateList.push(moduleName);
86
+
87
+ for (let i = 0; i < iterateList.length; i++) {
88
+
89
+ var exportedModule = require("./lib/export/" + iterateList[i]);
90
+ const result = await exportedModule.start(config, branchName);
91
+ if (result && iterateList[i] === "stack") {
92
+ let master_locale = {
93
+ master_locale: { code: result.master_locale },
94
+ };
95
+ config = _.merge(config, master_locale);
96
+ }
97
+ }
98
+ addlogs(config, moduleName + " was exported successfully!", "success");
99
+ addlogs(
100
+ config,
101
+ "The log for this is stored at " +
102
+ path.join(config.data, "logs", "export"),
103
+ "success"
104
+ );
27
105
  } else {
28
- let objKey = Object.keys(error.errors)
29
- addlogs(config, chalk.red('Stack fail to export, ' + objKey + "" + error.errors[objKey][0]), 'error')
106
+ addlogs(config, "Please provide valid module name.", "error");
30
107
  }
31
- })
32
- }
33
-
34
- var singleExport = (moduleName, types, config) => {
35
- var types = config.modules.types
36
- if (types.indexOf(moduleName) > -1) {
37
- var exportedModule = require('./lib/export/' + moduleName)
38
- exportedModule.start(config).then(function () {
39
- addlogs(config, moduleName + ' was exported successfully!', 'success')
40
- addlogs(config, 'The log for this is stored at ' + path.join(config.data , 'logs', 'export'), 'success')
41
- }).catch(function (error) {
42
- addlogs(config, 'Failed to migrate ' + moduleName, 'error')
43
- addlogs(config, error, 'error')
44
- addlogs(config, 'The log for this is stored at ' + path.join(config.data , 'logs', 'export'), 'error')
45
- })
46
- } else {
47
- addlogs(config, 'Please provide valid module name.', 'error')
108
+ return true
109
+ } catch (error) {
110
+ addlogs(config, "Failed to migrate " + moduleName, "error");
111
+ addlogs(config, error, "error");
112
+ addlogs(
113
+ config,
114
+ "The log for this is stored at " +
115
+ path.join(config.data, "logs", "export"),
116
+ "error"
117
+ );
118
+ throw error
48
119
  }
49
- }
120
+ };
50
121
 
51
- var allExport = async (config, types) => {
52
- var counter = 0
53
- Bluebird.map(types, function (type) {
54
- if (config.preserveStackVersion) {
55
- var exportedModule = require('./lib/export/' + types[counter])
56
- counter++
57
- return exportedModule.start(config)
58
- } else if(!config.preserveStackVersion && type !== 'stack') {
59
- var exportedModule = require('./lib/export/' + types[counter])
60
- counter++
61
- return exportedModule.start(config)
62
- } else {
63
- counter++
122
+ var allExport = async (config, types, branchName) => {
123
+ // eslint-disable-next-line no-async-promise-executor
124
+ return new Promise(async (resolve, reject) => {
125
+ try {
126
+ for (let i = 0; i < types.length; i++) {
127
+ let type = types[i];
128
+ var exportedModule = require("./lib/export/" + type);
129
+ const result = await exportedModule.start(config, branchName);
130
+ if (result && type === "stack") {
131
+ let master_locale = { master_locale: { code: result.code } };
132
+ config = _.merge(config, master_locale);
133
+ }
134
+ }
135
+ addlogs(
136
+ config,
137
+ chalk.green(
138
+ "The content of the " +
139
+ config.source_stack +
140
+ " has been exported succesfully!"
141
+ ),
142
+ "success"
143
+ );
144
+ addlogs(
145
+ config,
146
+ "The log for this is stored at " +
147
+ path.join(config.data, "logs", "export"),
148
+ "success"
149
+ );
150
+ return resolve();
151
+ } catch (error) {
152
+ addlogs(config, chalk.red('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info'), 'error')
153
+ addlogs(config, chalk.red(error.errorMessage), 'error')
154
+ addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error')
155
+ return reject(error)
64
156
  }
65
- }, {
66
- concurrency: 1,
67
- }).then(function () {
68
- addlogs(config, chalk.green('Stack: ' + config.source_stack + ' has been exported succesfully!'), 'success')
69
- addlogs(config, 'The log for this is stored at ' + path.join(config.data , 'logs', 'export'), 'success')
70
- }).catch(function () {
71
- addlogs(config, chalk.red('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info'), 'error')
72
- addlogs(config, 'The log for this is stored at ' + path.join(config.data , 'logs', 'export'), 'error')
73
- })
74
- }
157
+ });
158
+ };
@@ -1,57 +1,66 @@
1
1
  /* eslint-disable complexity */
2
- const {Command, flags} = require('@contentstack/cli-command')
3
- const {configWithMToken,
2
+ const { Command, flags } = require('@contentstack/cli-command')
3
+ const { configWithMToken,
4
4
  parameterWithMToken,
5
5
  withoutParameterMToken,
6
6
  configWithAuthToken,
7
7
  parametersWithAuthToken,
8
8
  withoutParametersWithAuthToken,
9
9
  } = require('../../lib/util/export-flags')
10
- const Configstore = require('configstore')
10
+ const Configstore = require('configstore')
11
11
  const credStore = new Configstore('contentstack_cli')
12
12
 
13
13
  class ExportCommand extends Command {
14
14
  async run() {
15
- const {flags} = this.parse(ExportCommand)
16
- const extConfig = flags.config
17
- const masterLang = flags['master-lang']
18
- let sourceStack = flags['stack-uid']
19
- const alias = flags['management-token-alias']
20
- const authToken = flags['auth-token']
21
- const data = flags.data
22
- const moduleName = flags.module
15
+ const exportCommandFlags = this.parse(ExportCommand).flags
16
+ const extConfig = exportCommandFlags.config
17
+ let sourceStack = exportCommandFlags['stack-uid']
18
+ const alias = exportCommandFlags['management-token-alias']
19
+ const authToken = exportCommandFlags['auth-token']
20
+ const securedAssets = exportCommandFlags['secured-assets']
21
+ const data = exportCommandFlags.data
22
+ const moduleName = exportCommandFlags.module
23
+ const contentTypes = exportCommandFlags['content-type']
24
+ const branchName = exportCommandFlags.branch;
23
25
  let _authToken = credStore.get('authtoken')
24
- let host = this.config.userConfig.getRegion()
25
- let cmaMaiURL = host.cma.split('//')
26
- let cdaMaiURL = host.cda.split('//')
27
- host.cma = cmaMaiURL[1]
28
- host.cda = cdaMaiURL[1]
26
+ let host = this.region
27
+ let cmaHost = host.cma.split('//')
28
+ let cdaHost = host.cda.split('//')
29
+ host.cma = cmaHost[1]
30
+ host.cda = cdaHost[1]
29
31
 
30
- if (alias && alias !== undefined) {
31
- // await this.config.runHook('validateManagementTokenAlias', {alias: alias})
32
+ if (alias) {
32
33
  let managementTokens = this.getToken(alias)
33
- if (managementTokens && managementTokens !== undefined) {
34
- if (extConfig && extConfig !== undefined) {
34
+ if (managementTokens) {
35
+ if (extConfig) {
35
36
  configWithMToken(
36
37
  extConfig,
37
38
  managementTokens,
38
- host
39
+ host,
40
+ contentTypes,
41
+ branchName,
42
+ securedAssets
39
43
  )
40
- } else if (masterLang && data) {
41
- sourceStack = managementTokens.apiKey
44
+ } else if (data) {
42
45
  parameterWithMToken(
43
- masterLang,
44
46
  managementTokens,
45
- sourceStack,
46
47
  data,
47
48
  moduleName,
48
- host
49
+ host,
50
+ _authToken,
51
+ contentTypes,
52
+ branchName,
53
+ securedAssets
49
54
  )
50
- } else if (masterLang === undefined && data === undefined && sourceStack === undefined) {
55
+ } else if (data === undefined && sourceStack === undefined) {
51
56
  withoutParameterMToken(
52
57
  managementTokens,
53
58
  moduleName,
54
- host
59
+ host,
60
+ _authToken,
61
+ contentTypes,
62
+ branchName,
63
+ securedAssets
55
64
  )
56
65
  } else {
57
66
  this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage')
@@ -59,28 +68,36 @@ class ExportCommand extends Command {
59
68
  } else {
60
69
  this.log(alias + ' management token is not present, please add managment token first')
61
70
  }
62
- } else if (authToken && authToken !== undefined && _authToken && _authToken !== undefined) {
63
- if (extConfig && extConfig !== undefined) {
71
+ } else if (authToken && _authToken) {
72
+ if (extConfig) {
64
73
  configWithAuthToken(
65
74
  extConfig,
66
75
  _authToken,
67
76
  moduleName,
68
- host
77
+ host,
78
+ contentTypes,
79
+ branchName,
80
+ securedAssets
69
81
  )
70
- } else if (masterLang && sourceStack && data) {
71
- parametersWithAuthToken(
72
- masterLang,
82
+ } else if (sourceStack && data) {
83
+ return parametersWithAuthToken(
73
84
  _authToken,
74
85
  sourceStack,
75
86
  data,
76
87
  moduleName,
77
- host
88
+ host,
89
+ contentTypes,
90
+ branchName,
91
+ securedAssets
78
92
  )
79
- } else if (masterLang === undefined && data === undefined && sourceStack === undefined) {
93
+ } else if (data === undefined && sourceStack === undefined) {
80
94
  withoutParametersWithAuthToken(
81
95
  _authToken,
82
96
  moduleName,
83
- host
97
+ host,
98
+ contentTypes,
99
+ branchName,
100
+ securedAssets
84
101
  )
85
102
  } else {
86
103
  this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage')
@@ -88,6 +105,7 @@ class ExportCommand extends Command {
88
105
  } else {
89
106
  this.log('Provide the alias for management token or auth token')
90
107
  }
108
+ // return
91
109
  }
92
110
  }
93
111
 
@@ -97,22 +115,28 @@ Export content from one stack to another
97
115
  `
98
116
  ExportCommand.examples = [
99
117
  'csdx cm:export -A',
100
- 'csdx cm:export -A -l \'master-language\' -s \'stack_ApiKey\' -d \'path/of/export/destination/dir\'',
101
- 'csdx cm:export -A -c \'path/of/config/dir\'',
102
- 'csdx cm:export -a \'management_token_alias\'',
103
- 'csdx cm:export -a "management_token_alias" -l "master-language" -d "path/of/export/destination/dir"',
104
- 'csdx cm:export -a "management_token_alias" -c "path/of/config/file"',
105
- 'csdx cm:export -A -m "single module name"',
118
+ 'csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>',
119
+ 'csdx cm:export -A -c <path/to/config/dir>',
120
+ 'csdx cm:export -A -m <single module name>',
121
+ 'csdx cm:export -A --secured-assets',
122
+ 'csdx cm:export -a <management_token_alias>',
123
+ 'csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>',
124
+ 'csdx cm:export -a <management_token_alias> -c <path/to/config/file>',
125
+ 'csdx cm:export -A -m <single module name>',
126
+ 'csdx cm:export -A -m <single module name> -t <content type>',
127
+ 'csdx cm:export -A -B [optional] branch name',
106
128
  ]
107
129
 
108
130
  ExportCommand.flags = {
109
- config: flags.string({char: 'c', description: '[optional] path of the config'}),
110
- 'master-lang': flags.string({char: 'l', description: "code of the source stack's master Language"}),
111
- 'stack-uid': flags.string({char: 's', description: 'API key of the source stack'}),
112
- data: flags.string({char: 'd', description: 'path or location to store the data'}),
113
- 'management-token-alias': flags.string({char: 'a', description: 'alias of the management token'}),
114
- 'auth-token': flags.boolean({char: 'A', description: 'to use auth token'}),
115
- module: flags.string({char: 'm', description: '[optional] specific module name'}),
131
+ config: flags.string({ char: 'c', description: '[optional] path of the config' }),
132
+ 'stack-uid': flags.string({ char: 's', description: 'API key of the source stack' }),
133
+ data: flags.string({ char: 'd', description: 'path or location to store the data' }),
134
+ 'management-token-alias': flags.string({ char: 'a', description: 'alias of the management token' }),
135
+ 'auth-token': flags.boolean({ char: 'A', description: 'to use auth token' }),
136
+ module: flags.string({ char: 'm', description: '[optional] specific module name' }),
137
+ 'content-type': flags.string({ char: 't', description: '[optional] content type', multiple: true }),
138
+ branch: flags.string({ char: 'B', description: '[optional] branch name' }),
139
+ 'secured-assets': flags.boolean({ description: '[optional] use when assets are secured' }),
116
140
  }
117
141
 
118
142
  module.exports = ExportCommand
@@ -10,6 +10,7 @@ module.exports = {
10
10
  'webhooks',
11
11
  'global-fields',
12
12
  'content-types',
13
+ 'workflows',
13
14
  'entries',
14
15
  'labels',
15
16
  ],
@@ -20,7 +21,7 @@ module.exports = {
20
21
  'code',
21
22
  'uid',
22
23
  'name',
23
- 'fallback_locale',
24
+ 'fallback_locale'
24
25
  ],
25
26
  },
26
27
  environments: {
@@ -30,11 +31,45 @@ module.exports = {
30
31
  labels: {
31
32
  dirName: 'labels',
32
33
  fileName: 'labels.json',
34
+ invalidKeys: [
35
+ 'stackHeaders',
36
+ 'uid',
37
+ 'urlPath',
38
+ 'created_at',
39
+ 'updated_at',
40
+ 'created_by',
41
+ 'updated_by',
42
+ ],
33
43
  },
34
44
  webhooks: {
35
45
  dirName: 'webhooks',
36
46
  fileName: 'webhooks.json',
37
47
  },
48
+ releases: {
49
+ dirName: 'releases',
50
+ fileName: 'releases.json',
51
+ releasesList: 'releasesList.json',
52
+ invalidKeys: [
53
+ 'stackHeaders',
54
+ 'urlPath',
55
+ 'created_at',
56
+ 'updated_at',
57
+ 'created_by',
58
+ 'updated_by',
59
+ ],
60
+ },
61
+ workflows: {
62
+ dirName: 'workflows',
63
+ fileName: 'workflows.json',
64
+ invalidKeys: [
65
+ 'stackHeaders',
66
+ 'urlPath',
67
+ 'created_at',
68
+ 'updated_at',
69
+ 'created_by',
70
+ 'updated_by',
71
+ ],
72
+ },
38
73
  globalfields: {
39
74
  dirName: 'global_fields',
40
75
  fileName: 'globalfields.json',
@@ -106,6 +141,9 @@ module.exports = {
106
141
  dirName: 'stack',
107
142
  fileName: 'stack.json',
108
143
  },
144
+ dependency: {
145
+ entries: ['stack', 'locales', 'content-types'],
146
+ },
109
147
  },
110
148
  languagesCode: [
111
149
  'af-za',