@contentstack/cli-cm-export 1.2.3 → 1.4.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.
- package/LICENSE +1 -1
- package/README.md +74 -22
- package/oclif.manifest.json +128 -1
- package/package.json +15 -14
- package/src/app.js +30 -32
- package/src/commands/cm/stacks/export.js +3 -5
- package/src/config/default.js +5 -0
- package/src/lib/export/assets.js +201 -194
- package/src/lib/export/custom-roles.js +7 -16
- package/src/lib/export/entries.js +6 -1
- package/src/lib/export/environments.js +6 -7
- package/src/lib/export/extensions.js +6 -7
- package/src/lib/export/global-fields.js +12 -12
- package/src/lib/export/labels.js +8 -11
- package/src/lib/export/locales.js +8 -6
- package/src/lib/export/marketplace-apps.js +102 -102
- package/src/lib/export/stack.js +78 -84
- package/src/lib/export/webhooks.js +4 -9
- package/src/lib/export/workflows.js +11 -11
- package/src/lib/util/helper.js +16 -25
- package/src/lib/util/login.js +59 -55
- package/src/lib/util/marketplace-app-helper.js +3 -40
- package/src/lib/util/setup-branches.js +14 -12
- package/src/lib/util/contentstack-management-sdk.js +0 -39
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -37,8 +37,8 @@ For switching to AZURE-NA region update the hosts at config/default.js
|
|
|
37
37
|
$ npm install -g @contentstack/cli-cm-export
|
|
38
38
|
$ csdx COMMAND
|
|
39
39
|
running command...
|
|
40
|
-
$ csdx (
|
|
41
|
-
@contentstack/cli-cm-export/1.
|
|
40
|
+
$ csdx (--version)
|
|
41
|
+
@contentstack/cli-cm-export/1.4.0 linux-x64 node-v16.19.1
|
|
42
42
|
$ csdx --help [COMMAND]
|
|
43
43
|
USAGE
|
|
44
44
|
$ csdx COMMAND
|
|
@@ -50,6 +50,7 @@ USAGE
|
|
|
50
50
|
|
|
51
51
|
<!-- commands -->
|
|
52
52
|
* [`csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]`](#csdx-cmstacksexport--c-value--k-value--d-value--a-value---module-value---content-types-value---branch-value---secured-assets)
|
|
53
|
+
* [`csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]`](#csdx-cmstacksexport--c-value--k-value--d-value--a-value---module-value---content-types-value---branch-value---secured-assets-1)
|
|
53
54
|
|
|
54
55
|
## `csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]`
|
|
55
56
|
|
|
@@ -57,31 +58,82 @@ Export content from a stack
|
|
|
57
58
|
|
|
58
59
|
```
|
|
59
60
|
USAGE
|
|
60
|
-
$ csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
-B, --branch
|
|
65
|
-
-a, --alias
|
|
66
|
-
-c, --config
|
|
67
|
-
-d, --data-dir
|
|
68
|
-
-k, --stack-api-key
|
|
69
|
-
-m, --module
|
|
70
|
-
-t, --content-types
|
|
71
|
-
-y, --yes
|
|
72
|
-
--secured-assets
|
|
61
|
+
$ csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types
|
|
62
|
+
<value>] [--branch <value>] [--secured-assets]
|
|
63
|
+
|
|
64
|
+
FLAGS
|
|
65
|
+
-B, --branch=<value> [optional] branch name
|
|
66
|
+
-a, --alias=<value> alias of the management token
|
|
67
|
+
-c, --config=<value> [optional] path of the config
|
|
68
|
+
-d, --data-dir=<value> path or location to store the data
|
|
69
|
+
-k, --stack-api-key=<value> API key of the source stack
|
|
70
|
+
-m, --module=<value> [optional] specific module name
|
|
71
|
+
-t, --content-types=<value>... [optional] content type
|
|
72
|
+
-y, --yes [optional] Override marketplace apps related prompts
|
|
73
|
+
--secured-assets [optional] use when assets are secured
|
|
74
|
+
|
|
75
|
+
DESCRIPTION
|
|
76
|
+
Export content from a stack
|
|
73
77
|
|
|
74
78
|
ALIASES
|
|
75
79
|
$ csdx cm:export
|
|
76
80
|
|
|
77
81
|
EXAMPLES
|
|
78
|
-
csdx cm:stacks:export --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>
|
|
79
|
-
|
|
80
|
-
csdx cm:stacks:export --
|
|
81
|
-
|
|
82
|
-
csdx cm:stacks:export --alias <management_token_alias>
|
|
83
|
-
|
|
84
|
-
csdx cm:stacks:export --
|
|
82
|
+
$ csdx cm:stacks:export --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>
|
|
83
|
+
|
|
84
|
+
$ csdx cm:stacks:export --config <path/to/config/dir>
|
|
85
|
+
|
|
86
|
+
$ csdx cm:stacks:export --alias <management_token_alias>
|
|
87
|
+
|
|
88
|
+
$ csdx cm:stacks:export --alias <management_token_alias> --data-dir <path/to/export/destination/dir>
|
|
89
|
+
|
|
90
|
+
$ csdx cm:stacks:export --alias <management_token_alias> --config <path/to/config/file>
|
|
91
|
+
|
|
92
|
+
$ csdx cm:stacks:export --module <single module name>
|
|
93
|
+
|
|
94
|
+
$ csdx cm:stacks:export --branch [optional] branch name
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## `csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]`
|
|
98
|
+
|
|
99
|
+
Export content from a stack
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
USAGE
|
|
103
|
+
$ csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types
|
|
104
|
+
<value>] [--branch <value>] [--secured-assets]
|
|
105
|
+
|
|
106
|
+
FLAGS
|
|
107
|
+
-B, --branch=<value> [optional] branch name
|
|
108
|
+
-a, --alias=<value> alias of the management token
|
|
109
|
+
-c, --config=<value> [optional] path of the config
|
|
110
|
+
-d, --data-dir=<value> path or location to store the data
|
|
111
|
+
-k, --stack-api-key=<value> API key of the source stack
|
|
112
|
+
-m, --module=<value> [optional] specific module name
|
|
113
|
+
-t, --content-types=<value>... [optional] content type
|
|
114
|
+
-y, --yes [optional] Override marketplace apps related prompts
|
|
115
|
+
--secured-assets [optional] use when assets are secured
|
|
116
|
+
|
|
117
|
+
DESCRIPTION
|
|
118
|
+
Export content from a stack
|
|
119
|
+
|
|
120
|
+
ALIASES
|
|
121
|
+
$ csdx cm:export
|
|
122
|
+
|
|
123
|
+
EXAMPLES
|
|
124
|
+
$ csdx cm:stacks:export --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>
|
|
125
|
+
|
|
126
|
+
$ csdx cm:stacks:export --config <path/to/config/dir>
|
|
127
|
+
|
|
128
|
+
$ csdx cm:stacks:export --alias <management_token_alias>
|
|
129
|
+
|
|
130
|
+
$ csdx cm:stacks:export --alias <management_token_alias> --data-dir <path/to/export/destination/dir>
|
|
131
|
+
|
|
132
|
+
$ csdx cm:stacks:export --alias <management_token_alias> --config <path/to/config/file>
|
|
133
|
+
|
|
134
|
+
$ csdx cm:stacks:export --module <single module name>
|
|
135
|
+
|
|
136
|
+
$ csdx cm:stacks:export --branch [optional] branch name
|
|
85
137
|
```
|
|
86
138
|
|
|
87
139
|
_See code: [src/commands/cm/stacks/export.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-export/src/commands/cm/stacks/export.js)_
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1,128 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": "1.4.0",
|
|
3
|
+
"commands": {
|
|
4
|
+
"cm:stacks:export": {
|
|
5
|
+
"id": "cm:stacks:export",
|
|
6
|
+
"description": "Export content from a stack",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"usage": "cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]",
|
|
9
|
+
"pluginName": "@contentstack/cli-cm-export",
|
|
10
|
+
"pluginAlias": "@contentstack/cli-cm-export",
|
|
11
|
+
"pluginType": "core",
|
|
12
|
+
"aliases": [
|
|
13
|
+
"cm:export"
|
|
14
|
+
],
|
|
15
|
+
"examples": [
|
|
16
|
+
"csdx cm:stacks:export --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>",
|
|
17
|
+
"csdx cm:stacks:export --config <path/to/config/dir>",
|
|
18
|
+
"csdx cm:stacks:export --alias <management_token_alias>",
|
|
19
|
+
"csdx cm:stacks:export --alias <management_token_alias> --data-dir <path/to/export/destination/dir>",
|
|
20
|
+
"csdx cm:stacks:export --alias <management_token_alias> --config <path/to/config/file>",
|
|
21
|
+
"csdx cm:stacks:export --module <single module name>",
|
|
22
|
+
"csdx cm:stacks:export --branch [optional] branch name"
|
|
23
|
+
],
|
|
24
|
+
"flags": {
|
|
25
|
+
"config": {
|
|
26
|
+
"name": "config",
|
|
27
|
+
"type": "option",
|
|
28
|
+
"char": "c",
|
|
29
|
+
"description": "[optional] path of the config",
|
|
30
|
+
"multiple": false
|
|
31
|
+
},
|
|
32
|
+
"stack-uid": {
|
|
33
|
+
"name": "stack-uid",
|
|
34
|
+
"type": "option",
|
|
35
|
+
"char": "s",
|
|
36
|
+
"description": "API key of the source stack",
|
|
37
|
+
"hidden": true,
|
|
38
|
+
"multiple": false
|
|
39
|
+
},
|
|
40
|
+
"stack-api-key": {
|
|
41
|
+
"name": "stack-api-key",
|
|
42
|
+
"type": "option",
|
|
43
|
+
"char": "k",
|
|
44
|
+
"description": "API key of the source stack",
|
|
45
|
+
"multiple": false
|
|
46
|
+
},
|
|
47
|
+
"data": {
|
|
48
|
+
"name": "data",
|
|
49
|
+
"type": "option",
|
|
50
|
+
"description": "path or location to store the data",
|
|
51
|
+
"hidden": true,
|
|
52
|
+
"multiple": false
|
|
53
|
+
},
|
|
54
|
+
"data-dir": {
|
|
55
|
+
"name": "data-dir",
|
|
56
|
+
"type": "option",
|
|
57
|
+
"char": "d",
|
|
58
|
+
"description": "path or location to store the data",
|
|
59
|
+
"multiple": false
|
|
60
|
+
},
|
|
61
|
+
"alias": {
|
|
62
|
+
"name": "alias",
|
|
63
|
+
"type": "option",
|
|
64
|
+
"char": "a",
|
|
65
|
+
"description": "alias of the management token",
|
|
66
|
+
"multiple": false
|
|
67
|
+
},
|
|
68
|
+
"management-token-alias": {
|
|
69
|
+
"name": "management-token-alias",
|
|
70
|
+
"type": "option",
|
|
71
|
+
"description": "alias of the management token",
|
|
72
|
+
"hidden": true,
|
|
73
|
+
"multiple": false
|
|
74
|
+
},
|
|
75
|
+
"auth-token": {
|
|
76
|
+
"name": "auth-token",
|
|
77
|
+
"type": "boolean",
|
|
78
|
+
"char": "A",
|
|
79
|
+
"description": "to use auth token",
|
|
80
|
+
"hidden": true,
|
|
81
|
+
"allowNo": false
|
|
82
|
+
},
|
|
83
|
+
"module": {
|
|
84
|
+
"name": "module",
|
|
85
|
+
"type": "option",
|
|
86
|
+
"char": "m",
|
|
87
|
+
"description": "[optional] specific module name",
|
|
88
|
+
"multiple": false,
|
|
89
|
+
"exclusive": [
|
|
90
|
+
"content-types"
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
"content-types": {
|
|
94
|
+
"name": "content-types",
|
|
95
|
+
"type": "option",
|
|
96
|
+
"char": "t",
|
|
97
|
+
"description": "[optional] content type",
|
|
98
|
+
"multiple": true,
|
|
99
|
+
"exclusive": [
|
|
100
|
+
"module"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"branch": {
|
|
104
|
+
"name": "branch",
|
|
105
|
+
"type": "option",
|
|
106
|
+
"char": "B",
|
|
107
|
+
"description": "[optional] branch name",
|
|
108
|
+
"multiple": false
|
|
109
|
+
},
|
|
110
|
+
"secured-assets": {
|
|
111
|
+
"name": "secured-assets",
|
|
112
|
+
"type": "boolean",
|
|
113
|
+
"description": "[optional] use when assets are secured",
|
|
114
|
+
"allowNo": false
|
|
115
|
+
},
|
|
116
|
+
"yes": {
|
|
117
|
+
"name": "yes",
|
|
118
|
+
"type": "boolean",
|
|
119
|
+
"char": "y",
|
|
120
|
+
"description": "[optional] Override marketplace apps related prompts",
|
|
121
|
+
"required": false,
|
|
122
|
+
"allowNo": false
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"args": {}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export",
|
|
3
3
|
"description": "Contentstack CLI plugin to export content from stack",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-command": "^1.0
|
|
9
|
-
"@contentstack/cli-utilities": "^1.0
|
|
10
|
-
"@contentstack/management": "^1.6.0",
|
|
8
|
+
"@contentstack/cli-command": "^1.2.0",
|
|
9
|
+
"@contentstack/cli-utilities": "^1.2.0",
|
|
11
10
|
"@oclif/command": "^1.8.16",
|
|
12
11
|
"@oclif/config": "^1.18.3",
|
|
13
12
|
"async": "^3.2.4",
|
|
14
13
|
"big-json": "^3.2.0",
|
|
15
14
|
"bluebird": "^3.7.2",
|
|
16
|
-
"
|
|
15
|
+
"chalk": "^4.1.2",
|
|
17
16
|
"is-valid-path": "^0.1.1",
|
|
18
17
|
"lodash": "^4.17.20",
|
|
19
18
|
"mkdirp": "^1.0.4",
|
|
@@ -24,24 +23,25 @@
|
|
|
24
23
|
"winston": "^3.7.2"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
|
-
"@contentstack/cli-auth": "^1.0
|
|
28
|
-
"@contentstack/cli-config": "^1.0
|
|
29
|
-
"@contentstack/cli-dev-dependencies": "^1.
|
|
30
|
-
"@oclif/
|
|
26
|
+
"@contentstack/cli-auth": "^1.2.0",
|
|
27
|
+
"@contentstack/cli-config": "^1.2.0",
|
|
28
|
+
"@contentstack/cli-dev-dependencies": "^1.2.0",
|
|
29
|
+
"@oclif/plugin-help": "^5.1.19",
|
|
31
30
|
"@oclif/test": "^1.2.6",
|
|
32
31
|
"assert": "^2.0.0",
|
|
33
32
|
"chai": "^4.2.0",
|
|
34
33
|
"dotenv": "^16.0.1",
|
|
35
34
|
"dotenv-expand": "^9.0.0",
|
|
36
35
|
"eslint": "^8.18.0",
|
|
37
|
-
"eslint-config-oclif": "^
|
|
36
|
+
"eslint-config-oclif": "^4.0.0",
|
|
38
37
|
"globby": "^10.0.2",
|
|
39
38
|
"mocha": "10.1.0",
|
|
40
39
|
"nyc": "^15.1.0",
|
|
41
|
-
"sinon": "^
|
|
40
|
+
"sinon": "^15.0.1",
|
|
41
|
+
"oclif": "^3.1.2"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
|
-
"node": ">=
|
|
44
|
+
"node": ">=14.0.0"
|
|
45
45
|
},
|
|
46
46
|
"files": [
|
|
47
47
|
"/npm-shrinkwrap.json",
|
|
@@ -58,9 +58,10 @@
|
|
|
58
58
|
"license": "MIT",
|
|
59
59
|
"scripts": {
|
|
60
60
|
"postpack": "rm -f oclif.manifest.json",
|
|
61
|
-
"prepack": "oclif
|
|
61
|
+
"prepack": "oclif manifest && oclif readme",
|
|
62
62
|
"test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
|
|
63
|
-
"version": "oclif
|
|
63
|
+
"version": "oclif readme && git add README.md",
|
|
64
|
+
"clean": "rm -rf ./node_modules tsconfig.build.tsbuildinfo",
|
|
64
65
|
"test:integration": "mocha --forbid-only \"test/run.test.js\" --integration-test",
|
|
65
66
|
"test:unit": "mocha --forbid-only \"test/unit/*.test.js\" --unit-test"
|
|
66
67
|
},
|
package/src/app.js
CHANGED
|
@@ -3,22 +3,27 @@ const _ = require('lodash');
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const util = require('./lib/util');
|
|
6
|
-
const { formatError } = require('./lib/util');
|
|
7
6
|
const login = require('./lib/util/login');
|
|
8
7
|
const setupBranches = require('./lib/util/setup-branches');
|
|
9
8
|
const { addlogs, unlinkFileLogger } = require('./lib/util/log');
|
|
10
|
-
const
|
|
9
|
+
const { managementSDKClient } = require('@contentstack/cli-utilities');
|
|
11
10
|
|
|
12
|
-
exports.initial = async
|
|
13
|
-
return new Promise(async
|
|
11
|
+
exports.initial = async (config) => {
|
|
12
|
+
return new Promise(async (resolve, reject) => {
|
|
14
13
|
config = util.buildAppConfig(config);
|
|
15
14
|
util.validateConfig(config);
|
|
16
|
-
exports.getConfig =
|
|
15
|
+
exports.getConfig = () => {
|
|
17
16
|
return config;
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
const
|
|
21
|
-
|
|
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);
|
|
22
27
|
let types = config.modules.types;
|
|
23
28
|
|
|
24
29
|
if (Array.isArray(config.branches) && config.branches.length > 0) {
|
|
@@ -26,23 +31,23 @@ exports.initial = async function (config) {
|
|
|
26
31
|
config.branchName = branch.uid;
|
|
27
32
|
try {
|
|
28
33
|
if (config.moduleName) {
|
|
29
|
-
await singleExport(config.moduleName, types, config, branch.uid);
|
|
34
|
+
await singleExport(APIClient, stackAPIClient, config.moduleName, types, config, branch.uid);
|
|
30
35
|
} else {
|
|
31
|
-
await allExport(config, types, branch.uid);
|
|
36
|
+
await allExport(APIClient, stackAPIClient, config, types, branch.uid);
|
|
32
37
|
}
|
|
33
38
|
} catch (error) {
|
|
34
|
-
addlogs(config, `failed export contents ${branch.uid} ${formatError(error)}`, 'error');
|
|
39
|
+
addlogs(config, `failed export contents ${branch.uid} ${util.formatError(error)}`, 'error');
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
} else {
|
|
38
43
|
try {
|
|
39
44
|
if (config.moduleName) {
|
|
40
|
-
await singleExport(config.moduleName, types, config);
|
|
45
|
+
await singleExport(APIClient, stackAPIClient, config.moduleName, types, config);
|
|
41
46
|
} else {
|
|
42
|
-
await allExport(config, types);
|
|
47
|
+
await allExport(APIClient, stackAPIClient, config, types);
|
|
43
48
|
}
|
|
44
49
|
} catch (error) {
|
|
45
|
-
addlogs(config, `failed export contents ${formatError(error)}`, 'error');
|
|
50
|
+
addlogs(config, `failed export contents ${util.formatError(error)}`, 'error');
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
};
|
|
@@ -55,13 +60,13 @@ exports.initial = async function (config) {
|
|
|
55
60
|
) {
|
|
56
61
|
login
|
|
57
62
|
.login(config)
|
|
58
|
-
.then(async
|
|
63
|
+
.then(async () => {
|
|
59
64
|
// setup branches
|
|
60
65
|
try {
|
|
61
|
-
await fetchBranchAndExport();
|
|
66
|
+
await fetchBranchAndExport(APIClient, stackAPIClient);
|
|
62
67
|
unlinkFileLogger();
|
|
63
68
|
} catch (error) {
|
|
64
|
-
addlogs(config, `${formatError(error)}`, 'error');
|
|
69
|
+
addlogs(config, `${util.formatError(error)}`, 'error');
|
|
65
70
|
}
|
|
66
71
|
resolve();
|
|
67
72
|
})
|
|
@@ -71,25 +76,22 @@ exports.initial = async function (config) {
|
|
|
71
76
|
addlogs(config, chalk.red('Stack Api key ' + error.errors.api_key[0], 'Please enter valid Key', 'error'));
|
|
72
77
|
addlogs(config, 'The log for this is stored at ' + config.data + '/export/logs', 'success');
|
|
73
78
|
} else {
|
|
74
|
-
addlogs(config, `${formatError(error)}`, 'error');
|
|
79
|
+
addlogs(config, `${util.formatError(error)}`, 'error');
|
|
75
80
|
}
|
|
76
81
|
});
|
|
77
82
|
} else if (config.management_token) {
|
|
78
83
|
try {
|
|
79
|
-
await fetchBranchAndExport();
|
|
84
|
+
await fetchBranchAndExport(APIClient, stackAPIClient);
|
|
80
85
|
} catch (error) {
|
|
81
|
-
addlogs(config, formatError(error), 'error');
|
|
86
|
+
addlogs(config, util.formatError(error), 'error');
|
|
82
87
|
}
|
|
83
88
|
resolve();
|
|
84
89
|
}
|
|
85
90
|
});
|
|
86
91
|
};
|
|
87
92
|
|
|
88
|
-
const singleExport = async (moduleName, types, config, branchName) => {
|
|
93
|
+
const singleExport = async (APIClient, stackAPIClient, moduleName, types, config, branchName) => {
|
|
89
94
|
try {
|
|
90
|
-
const stackClient = stack
|
|
91
|
-
.Client(config)
|
|
92
|
-
.stack({ api_key: config.source_stack, management_token: config.management_token });
|
|
93
95
|
if (types.indexOf(moduleName) > -1) {
|
|
94
96
|
let iterateList;
|
|
95
97
|
if (config.modules.dependency && config.modules.dependency[moduleName]) {
|
|
@@ -101,7 +103,7 @@ const singleExport = async (moduleName, types, config, branchName) => {
|
|
|
101
103
|
|
|
102
104
|
for (let element of iterateList) {
|
|
103
105
|
const ExportModule = require('./lib/export/' + element);
|
|
104
|
-
const result = await new ExportModule(config,
|
|
106
|
+
const result = await new ExportModule(config, stackAPIClient, APIClient).start(config, branchName);
|
|
105
107
|
if (result && element === 'stack') {
|
|
106
108
|
let master_locale = {
|
|
107
109
|
master_locale: { code: result.code },
|
|
@@ -116,21 +118,17 @@ const singleExport = async (moduleName, types, config, branchName) => {
|
|
|
116
118
|
}
|
|
117
119
|
return true;
|
|
118
120
|
} catch (error) {
|
|
119
|
-
addlogs(config, `${formatError(error)}`, 'error');
|
|
121
|
+
addlogs(config, `${util.formatError(error)}`, 'error');
|
|
120
122
|
addlogs(config, 'Failed to migrate ' + moduleName, 'error');
|
|
121
123
|
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error');
|
|
122
124
|
}
|
|
123
125
|
};
|
|
124
126
|
|
|
125
|
-
const allExport = async (config, types, branchName) => {
|
|
127
|
+
const allExport = async (APIClient, stackAPIClient, config, types, branchName) => {
|
|
126
128
|
try {
|
|
127
|
-
const stackClient = stack
|
|
128
|
-
.Client(config)
|
|
129
|
-
.stack({ api_key: config.source_stack, management_token: config.management_token });
|
|
130
|
-
|
|
131
129
|
for (let type of types) {
|
|
132
130
|
const ExportModule = require('./lib/export/' + type);
|
|
133
|
-
const result = await new ExportModule(config,
|
|
131
|
+
const result = await new ExportModule(config, stackAPIClient, APIClient).start(config, branchName);
|
|
134
132
|
|
|
135
133
|
if (result && type === 'stack') {
|
|
136
134
|
let master_locale = { master_locale: { code: result.code } };
|
|
@@ -147,7 +145,7 @@ const allExport = async (config, types, branchName) => {
|
|
|
147
145
|
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success');
|
|
148
146
|
return true;
|
|
149
147
|
} catch (error) {
|
|
150
|
-
addlogs(config, formatError(error), 'error');
|
|
148
|
+
addlogs(config, util.formatError(error), 'error');
|
|
151
149
|
addlogs(
|
|
152
150
|
config,
|
|
153
151
|
chalk.red('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info'),
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
|
-
const { Command
|
|
3
|
-
const { printFlagDeprecation } = require('@contentstack/cli-utilities');
|
|
4
|
-
|
|
2
|
+
const { Command } = require('@contentstack/cli-command');
|
|
5
3
|
const {
|
|
6
4
|
configWithMToken,
|
|
7
5
|
parameterWithMToken,
|
|
@@ -11,11 +9,11 @@ const {
|
|
|
11
9
|
withoutParametersWithAuthToken,
|
|
12
10
|
} = require('../../../lib/util/export-flags');
|
|
13
11
|
const config = require('../../../config/default');
|
|
14
|
-
const { configHandler } = require('@contentstack/cli-utilities');
|
|
12
|
+
const { configHandler, printFlagDeprecation, flags } = require('@contentstack/cli-utilities');
|
|
15
13
|
|
|
16
14
|
class ExportCommand extends Command {
|
|
17
15
|
async run() {
|
|
18
|
-
const exportCommandFlags = this.parse(ExportCommand)
|
|
16
|
+
const { flags: exportCommandFlags } = await this.parse(ExportCommand);
|
|
19
17
|
const extConfig = exportCommandFlags.config;
|
|
20
18
|
let sourceStack = exportCommandFlags['stack-uid'] || exportCommandFlags['stack-api-key'];
|
|
21
19
|
const alias = exportCommandFlags['alias'] || exportCommandFlags['management-token-alias'];
|
package/src/config/default.js
CHANGED
|
@@ -33,6 +33,11 @@ module.exports = {
|
|
|
33
33
|
fileName: 'locales.json',
|
|
34
34
|
requiredKeys: ['code', 'uid', 'name', 'fallback_locale'],
|
|
35
35
|
},
|
|
36
|
+
masterLocale: {
|
|
37
|
+
dirName: 'locales',
|
|
38
|
+
fileName: 'master-locale.json',
|
|
39
|
+
requiredKeys: ['code', 'uid', 'name'],
|
|
40
|
+
},
|
|
36
41
|
customRoles: {
|
|
37
42
|
dirName: 'custom-roles',
|
|
38
43
|
fileName: 'custom-roles.json',
|