@contentstack/cli-cm-export 0.1.1-beta.9 → 1.1.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 +21 -0
- package/README.md +44 -29
- package/oclif.manifest.json +1 -1
- package/package.json +72 -68
- package/src/app.js +97 -104
- package/src/commands/cm/stacks/export.js +184 -0
- package/src/config/default.js +34 -59
- package/src/lib/export/assets.js +324 -223
- package/src/lib/export/content-types.js +72 -68
- package/src/lib/export/custom-roles.js +91 -0
- package/src/lib/export/entries.js +190 -135
- package/src/lib/export/environments.js +52 -47
- package/src/lib/export/extensions.js +50 -45
- package/src/lib/export/global-fields.js +17 -31
- package/src/lib/export/labels.js +52 -45
- package/src/lib/export/locales.js +74 -42
- package/src/lib/export/marketplace-apps.js +154 -0
- package/src/lib/export/stack.js +87 -47
- package/src/lib/export/webhooks.js +58 -50
- package/src/lib/export/workflows.js +85 -44
- package/src/lib/util/contentstack-management-sdk.js +26 -6
- package/src/lib/util/export-flags.js +140 -126
- package/src/lib/util/helper.js +20 -20
- package/src/lib/util/index.js +32 -19
- package/src/lib/util/log.js +109 -53
- package/src/lib/util/login.js +55 -40
- package/src/lib/util/marketplace-app-helper.js +42 -0
- package/src/lib/util/setup-branches.js +29 -38
- package/src/commands/cm/export.js +0 -142
- package/src/lib/util/request.js +0 -78
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Contentstack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -10,6 +10,26 @@ It is Contentstack’s CLI plugin to export content from the stack. To learn how
|
|
|
10
10
|
* [Commands](#commands)
|
|
11
11
|
<!-- tocstop -->
|
|
12
12
|
|
|
13
|
+
For switching to EU region update the hosts at config/default.js
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
{
|
|
17
|
+
host:'https://eu-api.contentstack.com/v3',
|
|
18
|
+
cdn: 'https://eu-cdn.contentstack.com/v3',
|
|
19
|
+
...
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
For switching to AZURE-NA region update the hosts at config/default.js
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
{
|
|
27
|
+
host:'https://azure-na-api.contentstack.com/v3',
|
|
28
|
+
cdn: 'https://azure-na-cdn.contentstack.com/v3',
|
|
29
|
+
...
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
13
33
|
# Usage
|
|
14
34
|
|
|
15
35
|
<!-- usage -->
|
|
@@ -18,7 +38,7 @@ $ npm install -g @contentstack/cli-cm-export
|
|
|
18
38
|
$ csdx COMMAND
|
|
19
39
|
running command...
|
|
20
40
|
$ csdx (-v|--version|version)
|
|
21
|
-
@contentstack/cli-cm-export/
|
|
41
|
+
@contentstack/cli-cm-export/1.1.0 darwin-arm64 node-v16.17.0
|
|
22
42
|
$ csdx --help [COMMAND]
|
|
23
43
|
USAGE
|
|
24
44
|
$ csdx COMMAND
|
|
@@ -29,44 +49,39 @@ USAGE
|
|
|
29
49
|
# Commands
|
|
30
50
|
|
|
31
51
|
<!-- commands -->
|
|
32
|
-
* [`csdx cm:export`](#csdx-
|
|
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)
|
|
33
53
|
|
|
34
|
-
## `csdx cm:export`
|
|
54
|
+
## `csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]`
|
|
35
55
|
|
|
36
56
|
Export content from a stack
|
|
37
57
|
|
|
38
58
|
```
|
|
39
59
|
USAGE
|
|
40
|
-
$ csdx cm:export
|
|
60
|
+
$ csdx cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types
|
|
61
|
+
<value>] [--branch <value>] [--secured-assets]
|
|
41
62
|
|
|
42
63
|
OPTIONS
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-m, --module=module
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
...
|
|
55
|
-
Export content from one stack to another
|
|
64
|
+
-B, --branch=branch [optional] branch name
|
|
65
|
+
-a, --alias=alias alias of the management token
|
|
66
|
+
-c, --config=config [optional] path of the config
|
|
67
|
+
-d, --data-dir=data-dir path or location to store the data
|
|
68
|
+
-k, --stack-api-key=stack-api-key API key of the source stack
|
|
69
|
+
-m, --module=module [optional] specific module name
|
|
70
|
+
-t, --content-types=content-types [optional] content type
|
|
71
|
+
--secured-assets [optional] use when assets are secured
|
|
72
|
+
|
|
73
|
+
ALIASES
|
|
74
|
+
$ csdx cm:export
|
|
56
75
|
|
|
57
76
|
EXAMPLES
|
|
58
|
-
csdx cm:export -
|
|
59
|
-
csdx cm:export
|
|
60
|
-
csdx cm:export
|
|
61
|
-
csdx cm:export
|
|
62
|
-
csdx cm:export
|
|
63
|
-
csdx cm:export
|
|
64
|
-
csdx cm:export
|
|
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
|
|
77
|
+
csdx cm:stacks:export --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>
|
|
78
|
+
csdx cm:stacks:export --config <path/to/config/dir>
|
|
79
|
+
csdx cm:stacks:export --alias <management_token_alias>
|
|
80
|
+
csdx cm:stacks:export --alias <management_token_alias> --data-dir <path/to/export/destination/dir>
|
|
81
|
+
csdx cm:stacks:export --alias <management_token_alias> --config <path/to/config/file>
|
|
82
|
+
csdx cm:stacks:export --module <single module name>
|
|
83
|
+
csdx cm:stacks:export --branch [optional] branch name
|
|
69
84
|
```
|
|
70
85
|
|
|
71
|
-
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/
|
|
86
|
+
_See code: [src/commands/cm/stacks/export.js](https://github.com/contentstack/cli/blob/v1.1.0/packages/contentstack-export/src/commands/cm/stacks/export.js)_
|
|
72
87
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
1
|
+
{"version":"1.1.0","commands":{"cm:stacks:export":{"id":"cm:stacks:export","description":"Export content from a stack","usage":"cm:stacks:export [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--content-types <value>] [--branch <value>] [--secured-assets]","pluginName":"@contentstack/cli-cm-export","pluginType":"core","aliases":["cm:export"],"examples":["csdx cm:stacks:export --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>","csdx cm:stacks:export --config <path/to/config/dir>","csdx cm:stacks:export --alias <management_token_alias>","csdx cm:stacks:export --alias <management_token_alias> --data-dir <path/to/export/destination/dir>","csdx cm:stacks:export --alias <management_token_alias> --config <path/to/config/file>","csdx cm:stacks:export --module <single module name>","csdx cm:stacks:export --branch [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","hidden":true},"stack-api-key":{"name":"stack-api-key","type":"option","char":"k","description":"API key of the source stack"},"data":{"name":"data","type":"option","description":"path or location to store the data","hidden":true},"data-dir":{"name":"data-dir","type":"option","char":"d","description":"path or location to store the data"},"alias":{"name":"alias","type":"option","char":"a","description":"alias of the management token"},"management-token-alias":{"name":"management-token-alias","type":"option","description":"alias of the management token","hidden":true},"auth-token":{"name":"auth-token","type":"boolean","char":"A","description":"to use auth token","hidden":true,"allowNo":false},"module":{"name":"module","type":"option","char":"m","description":"[optional] specific module name"},"content-types":{"name":"content-types","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,70 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
2
|
+
"name": "@contentstack/cli-cm-export",
|
|
3
|
+
"description": "Contentstack CLI plugin to export content from stack",
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"author": "Contentstack",
|
|
6
|
+
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@contentstack/cli-command": "^1.0.1",
|
|
9
|
+
"@contentstack/cli-utilities": "^1.0.2",
|
|
10
|
+
"@contentstack/management": "^1.3.0",
|
|
11
|
+
"@oclif/command": "^1.8.16",
|
|
12
|
+
"@oclif/config": "^1.18.3",
|
|
13
|
+
"async": "^3.2.4",
|
|
14
|
+
"bluebird": "^3.7.2",
|
|
15
|
+
"fs": "0.0.1-security",
|
|
16
|
+
"is-valid-path": "^0.1.1",
|
|
17
|
+
"lodash": "^4.17.20",
|
|
18
|
+
"mkdirp": "^1.0.4",
|
|
19
|
+
"path": "^0.12.7",
|
|
20
|
+
"progress-stream": "^2.0.0",
|
|
21
|
+
"proxyquire": "^2.1.3",
|
|
22
|
+
"winston": "^3.7.2"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@oclif/dev-cli": "^1.22.2",
|
|
26
|
+
"@oclif/plugin-help": "^5.1.12",
|
|
27
|
+
"@oclif/test": "^1.2.6",
|
|
28
|
+
"assert": "^2.0.0",
|
|
29
|
+
"chai": "^4.2.0",
|
|
30
|
+
"eslint": "^8.18.0",
|
|
31
|
+
"eslint-config-oclif": "^3.1.0",
|
|
32
|
+
"globby": "^10.0.2",
|
|
33
|
+
"mocha": "^10.0.0",
|
|
34
|
+
"nyc": "^14.1.1",
|
|
35
|
+
"sinon": "^9.0.2"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=8.0.0"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"/npm-shrinkwrap.json",
|
|
42
|
+
"/oclif.manifest.json",
|
|
43
|
+
"/src",
|
|
44
|
+
"/messages"
|
|
45
|
+
],
|
|
46
|
+
"homepage": "https://github.com/contentstack/cli",
|
|
47
|
+
"keywords": [
|
|
48
|
+
"contentstack",
|
|
49
|
+
"cli",
|
|
50
|
+
"plugin"
|
|
51
|
+
],
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"scripts": {
|
|
54
|
+
"postpack": "rm -f oclif.manifest.json",
|
|
55
|
+
"prepack": "oclif-dev manifest && oclif-dev readme",
|
|
56
|
+
"test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
|
|
57
|
+
"version": "oclif-dev readme && git add README.md"
|
|
58
|
+
},
|
|
59
|
+
"oclif": {
|
|
60
|
+
"commands": "./src/commands",
|
|
61
|
+
"bin": "csdx",
|
|
62
|
+
"devPlugins": [
|
|
63
|
+
"@oclif/plugin-help"
|
|
64
|
+
],
|
|
65
|
+
"repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/contentstack-export/<%- commandPath %>"
|
|
66
|
+
},
|
|
67
|
+
"csdxConfig": {
|
|
68
|
+
"expiredCommands": {
|
|
69
|
+
"cm:export": "csdx cm:stacks:export"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"main": "./src/commands/cm/stacks/export.js",
|
|
73
|
+
"repository": "https://github.com/contentstack/cli"
|
|
70
74
|
}
|
package/src/app.js
CHANGED
|
@@ -1,157 +1,150 @@
|
|
|
1
1
|
/* eslint-disable no-redeclare */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const cli = require("cli-ux");
|
|
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');
|
|
10
9
|
|
|
11
10
|
exports.initial = async function (config) {
|
|
12
|
-
return new Promise(function (resolve, reject) {
|
|
11
|
+
return new Promise(async function (resolve, reject) {
|
|
13
12
|
config = util.buildAppConfig(config);
|
|
14
13
|
util.validateConfig(config);
|
|
15
14
|
exports.getConfig = function () {
|
|
16
15
|
return config;
|
|
17
16
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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 {
|
|
17
|
+
|
|
18
|
+
const fetchBranchAndExport = async () => {
|
|
19
|
+
await setupBranches(config, config.branchName);
|
|
20
|
+
let types = config.modules.types;
|
|
21
|
+
|
|
22
|
+
if (Array.isArray(config.branches) && config.branches.length > 0) {
|
|
23
|
+
for (let branch of config.branches) {
|
|
24
|
+
config.branchName = branch.uid;
|
|
39
25
|
try {
|
|
40
26
|
if (config.moduleName) {
|
|
41
|
-
await singleExport(config.moduleName, types, config);
|
|
27
|
+
await singleExport(config.moduleName, types, config, branch.uid);
|
|
42
28
|
} else {
|
|
43
|
-
await allExport(config, types);
|
|
44
|
-
}
|
|
29
|
+
await allExport(config, types, branch.uid);
|
|
30
|
+
}
|
|
45
31
|
} catch (error) {
|
|
46
|
-
console.log('failed export
|
|
32
|
+
console.log('failed export branch', branch.uid, error);
|
|
47
33
|
}
|
|
48
34
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"Please enter valid Key",
|
|
59
|
-
"error"
|
|
60
|
-
)
|
|
61
|
-
);
|
|
62
|
-
addlogs(
|
|
63
|
-
config,
|
|
64
|
-
"The log for this is stored at " + config.data + "/export/logs",
|
|
65
|
-
"success"
|
|
66
|
-
);
|
|
67
|
-
} else {
|
|
68
|
-
console.log("Stack fail to export")
|
|
35
|
+
} else {
|
|
36
|
+
try {
|
|
37
|
+
if (config.moduleName) {
|
|
38
|
+
await singleExport(config.moduleName, types, config);
|
|
39
|
+
} else {
|
|
40
|
+
await allExport(config, types);
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.log('failed export contents', error && error.message);
|
|
69
44
|
}
|
|
70
|
-
|
|
71
|
-
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// try {
|
|
49
|
+
if (
|
|
50
|
+
(config.email && config.password) ||
|
|
51
|
+
(!config.email && !config.password && config.source_stack && config.access_token) ||
|
|
52
|
+
(config.auth_token && !config.management_token)
|
|
53
|
+
) {
|
|
54
|
+
login
|
|
55
|
+
.login(config)
|
|
56
|
+
.then(async function () {
|
|
57
|
+
// setup branches
|
|
58
|
+
await fetchBranchAndExport()
|
|
59
|
+
unlinkFileLogger();
|
|
60
|
+
resolve();
|
|
61
|
+
})
|
|
62
|
+
.catch((error) => {
|
|
63
|
+
console.log('error', error && error.message);
|
|
64
|
+
if (error && error.errors && error.errors.api_key) {
|
|
65
|
+
addlogs(config, chalk.red('Stack Api key ' + error.errors.api_key[0], 'Please enter valid Key', 'error'));
|
|
66
|
+
addlogs(config, 'The log for this is stored at ' + config.data + '/export/logs', 'success');
|
|
67
|
+
} else {
|
|
68
|
+
console.log('Stack fail to export');
|
|
69
|
+
}
|
|
70
|
+
reject(error);
|
|
71
|
+
});
|
|
72
|
+
} else if (config.management_token) {
|
|
73
|
+
await fetchBranchAndExport()
|
|
74
|
+
resolve();
|
|
75
|
+
}
|
|
72
76
|
});
|
|
73
77
|
};
|
|
74
78
|
|
|
75
|
-
|
|
79
|
+
const singleExport = async (moduleName, types, config, branchName) => {
|
|
76
80
|
try {
|
|
77
81
|
if (types.indexOf(moduleName) > -1) {
|
|
78
82
|
let iterateList;
|
|
79
83
|
if (config.modules.dependency && config.modules.dependency[moduleName]) {
|
|
80
84
|
iterateList = config.modules.dependency[moduleName];
|
|
81
85
|
} else {
|
|
82
|
-
iterateList = [
|
|
86
|
+
iterateList = ['stack'];
|
|
83
87
|
}
|
|
84
88
|
iterateList.push(moduleName);
|
|
85
89
|
|
|
86
|
-
for (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
for (const element of iterateList) {
|
|
91
|
+
let exportedModule = require('./lib/export/' + element);
|
|
92
|
+
const result = await exportedModule.start(config, branchName)
|
|
93
|
+
.catch((error) => {
|
|
94
|
+
console.log(error && error.message)
|
|
95
|
+
});
|
|
96
|
+
if (result && element === 'stack') {
|
|
91
97
|
let master_locale = {
|
|
92
|
-
master_locale: { code: result.
|
|
98
|
+
master_locale: { code: result.code },
|
|
93
99
|
};
|
|
94
100
|
config = _.merge(config, master_locale);
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
|
-
addlogs(config, moduleName +
|
|
98
|
-
addlogs(
|
|
99
|
-
config,
|
|
100
|
-
"The log for this is stored at " +
|
|
101
|
-
path.join(config.data, "logs", "export"),
|
|
102
|
-
"success"
|
|
103
|
-
);
|
|
103
|
+
addlogs(config, moduleName + ' was exported successfully!', 'success');
|
|
104
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success');
|
|
104
105
|
} else {
|
|
105
|
-
addlogs(config,
|
|
106
|
+
addlogs(config, 'Please provide valid module name.', 'error');
|
|
106
107
|
}
|
|
107
|
-
return true
|
|
108
|
+
return true;
|
|
108
109
|
} catch (error) {
|
|
109
|
-
addlogs(config,
|
|
110
|
-
addlogs(config, error,
|
|
111
|
-
addlogs(
|
|
112
|
-
|
|
113
|
-
"The log for this is stored at " +
|
|
114
|
-
path.join(config.data, "logs", "export"),
|
|
115
|
-
"error"
|
|
116
|
-
);
|
|
117
|
-
throw error
|
|
110
|
+
addlogs(config, 'Failed to migrate ' + moduleName, 'error');
|
|
111
|
+
addlogs(config, error, 'error');
|
|
112
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error');
|
|
113
|
+
throw error;
|
|
118
114
|
}
|
|
119
115
|
};
|
|
120
116
|
|
|
121
|
-
|
|
122
|
-
// eslint-disable-next-line no-async-promise-executor
|
|
117
|
+
const allExport = async (config, types, branchName) => {
|
|
123
118
|
return new Promise(async (resolve, reject) => {
|
|
124
119
|
try {
|
|
125
|
-
for (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
for (const type of types) {
|
|
121
|
+
const exportedModule = require('./lib/export/' + type);
|
|
122
|
+
const result = await exportedModule.start(config, branchName)
|
|
123
|
+
.catch((error) => {
|
|
124
|
+
console.log(error && error.message)
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
if (result && type === 'stack') {
|
|
130
128
|
let master_locale = { master_locale: { code: result.code } };
|
|
131
129
|
config = _.merge(config, master_locale);
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
132
|
addlogs(
|
|
135
133
|
config,
|
|
136
|
-
chalk.green(
|
|
137
|
-
|
|
138
|
-
config.source_stack +
|
|
139
|
-
" has been exported succesfully!"
|
|
140
|
-
),
|
|
141
|
-
"success"
|
|
134
|
+
chalk.green('The content of the ' + config.source_stack + ' has been exported successfully!'),
|
|
135
|
+
'success',
|
|
142
136
|
);
|
|
137
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success');
|
|
138
|
+
return resolve();
|
|
139
|
+
} catch (error) {
|
|
143
140
|
addlogs(
|
|
144
141
|
config,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"success"
|
|
142
|
+
chalk.red('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info'),
|
|
143
|
+
'error',
|
|
148
144
|
);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
addlogs(config, chalk.red(error.errorMessage), 'error')
|
|
153
|
-
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error')
|
|
154
|
-
return reject(error)
|
|
145
|
+
addlogs(config, chalk.red(error && error.errorMessage), 'error');
|
|
146
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error');
|
|
147
|
+
return reject(error);
|
|
155
148
|
}
|
|
156
149
|
});
|
|
157
150
|
};
|