@contentstack/cli-cm-export 0.1.1-beta.2 → 0.1.1-beta.6
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 +14 -9
- package/oclif.manifest.json +1 -1
- package/package.json +14 -11
- package/src/app.js +70 -54
- package/src/commands/cm/export.js +32 -27
- package/src/config/default.js +28 -2
- package/src/lib/export/assets.js +5 -3
- package/src/lib/export/content-types.js +1 -1
- package/src/lib/export/entries.js +2 -2
- package/src/lib/export/environments.js +1 -1
- package/src/lib/export/extensions.js +1 -1
- package/src/lib/export/global-fields.js +1 -1
- package/src/lib/export/labels.js +1 -1
- package/src/lib/export/locales.js +6 -5
- package/src/lib/export/stack.js +34 -16
- package/src/lib/export/webhooks.js +1 -1
- package/src/lib/export/workflows.js +59 -0
- package/src/lib/util/contentstack-management-sdk.js +1 -0
- package/src/lib/util/export-flags.js +34 -27
- package/src/lib/util/index.js +1 -5
- package/src/lib/util/log.js +0 -1
- package/src/lib/util/login.js +3 -4
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
|
[](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.
|
|
21
|
+
@contentstack/cli-cm-export/0.1.1-beta.6 darwin-x64 node-v14.16.0
|
|
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
|
|
|
@@ -40,9 +44,9 @@ OPTIONS
|
|
|
40
44
|
-a, --management-token-alias=management-token-alias alias of the management token
|
|
41
45
|
-c, --config=config [optional] path of the config
|
|
42
46
|
-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
47
|
-m, --module=module [optional] specific module name
|
|
45
48
|
-s, --stack-uid=stack-uid API key of the source stack
|
|
49
|
+
--secured-assets [optional] use when assets are secured
|
|
46
50
|
|
|
47
51
|
DESCRIPTION
|
|
48
52
|
...
|
|
@@ -50,13 +54,14 @@ DESCRIPTION
|
|
|
50
54
|
|
|
51
55
|
EXAMPLES
|
|
52
56
|
csdx cm:export -A
|
|
53
|
-
csdx cm:export -A -
|
|
57
|
+
csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>
|
|
54
58
|
csdx cm:export -A -c <path/to/config/dir>
|
|
59
|
+
csdx cm:export -A -m <single module name>
|
|
60
|
+
csdx cm:export -A --secured-assets
|
|
55
61
|
csdx cm:export -a <management_token_alias>
|
|
56
|
-
csdx cm:export -a <management_token_alias> -
|
|
62
|
+
csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>
|
|
57
63
|
csdx cm:export -a <management_token_alias> -c <path/to/config/file>
|
|
58
|
-
csdx cm:export -A -m <single module name>
|
|
59
64
|
```
|
|
60
65
|
|
|
61
|
-
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.
|
|
66
|
+
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.6/packages/contentstack-export/src/commands/cm/export.js)_
|
|
62
67
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.1.1-beta.
|
|
1
|
+
{"version":"0.1.1-beta.6","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>"],"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"},"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.
|
|
4
|
+
"version": "0.1.1-beta.6",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/
|
|
8
|
+
"@contentstack/cli-command": "0.1.0-beta",
|
|
9
|
+
"@contentstack/management": "^1.2.1",
|
|
9
10
|
"@oclif/command": "^1.6.1",
|
|
10
11
|
"@oclif/config": "^1.15.1",
|
|
11
|
-
"
|
|
12
|
-
"axios": "^0.
|
|
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.
|
|
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": "^
|
|
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",
|
|
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,90 @@
|
|
|
1
1
|
/* eslint-disable no-redeclare */
|
|
2
|
-
var Bluebird = require('bluebird')
|
|
3
2
|
var util = require('./lib/util')
|
|
4
3
|
var login = require('./lib/util/login')
|
|
5
4
|
var {addlogs} = require('./lib/util/log')
|
|
6
5
|
const chalk = require('chalk')
|
|
7
6
|
let path = require('path')
|
|
7
|
+
let _ = require('lodash')
|
|
8
8
|
|
|
9
|
-
exports.initial = function (config) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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')
|
|
27
|
-
} else {
|
|
28
|
-
let objKey = Object.keys(error.errors)
|
|
29
|
-
addlogs(config, chalk.red('Stack fail to export, ' + objKey + "" + error.errors[objKey][0]), 'error')
|
|
9
|
+
exports.initial = async function (config) {
|
|
10
|
+
return new Promise(function (resolve, reject) {
|
|
11
|
+
config = util.buildAppConfig(config)
|
|
12
|
+
util.validateConfig(config)
|
|
13
|
+
exports.getConfig = function () {
|
|
14
|
+
return config
|
|
30
15
|
}
|
|
16
|
+
// try {
|
|
17
|
+
login.login(config).then(async function () {
|
|
18
|
+
var types = config.modules.types
|
|
19
|
+
if (config.moduleName && config.moduleName !== undefined) {
|
|
20
|
+
singleExport(config.moduleName, types, config)
|
|
21
|
+
return resolve()
|
|
22
|
+
} else {
|
|
23
|
+
allExport(config, types).then(() => {
|
|
24
|
+
return resolve()
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}).catch(error => {
|
|
28
|
+
if (error.errors.api_key) {
|
|
29
|
+
addlogs(config, chalk.red('Stack Api key ' + error.errors.api_key[0], 'Please enter valid Key', 'error'))
|
|
30
|
+
addlogs(config, 'The log for this is stored at ' + config.data + '/export/logs', 'success')
|
|
31
|
+
} else {
|
|
32
|
+
let objKey = Object.keys(error.errors)
|
|
33
|
+
addlogs(config, chalk.red('Stack fail to export, ' + objKey + '' + error.errors[objKey][0]), 'error')
|
|
34
|
+
}
|
|
35
|
+
})
|
|
31
36
|
})
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
var singleExport = (moduleName, types, config) => {
|
|
39
|
+
var singleExport = async (moduleName, types, config) => {
|
|
35
40
|
var types = config.modules.types
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
try {
|
|
42
|
+
if (types.indexOf(moduleName) > -1) {
|
|
43
|
+
let iterateList = ['stack', moduleName]
|
|
44
|
+
for (let i = 0; i < iterateList.length; i++) {
|
|
45
|
+
var exportedModule = require('./lib/export/' + iterateList[i])
|
|
46
|
+
await exportedModule.start(config).then(function (result) {
|
|
47
|
+
if (iterateList[i] === 'stack') {
|
|
48
|
+
let master_locale = { master_locale: { code: result.master_locale } }
|
|
49
|
+
config = _.merge(config, master_locale)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
}
|
|
39
53
|
addlogs(config, moduleName + ' was exported successfully!', 'success')
|
|
40
|
-
addlogs(config, 'The log for this is stored at ' + path.join(config.data
|
|
41
|
-
}
|
|
42
|
-
addlogs(config, '
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
addlogs(config, '
|
|
54
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success')
|
|
55
|
+
} else {
|
|
56
|
+
addlogs(config, 'Please provide valid module name.', 'error')
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
addlogs(config, 'Failed to migrate ' + moduleName, 'error')
|
|
60
|
+
addlogs(config, error, 'error')
|
|
61
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error')
|
|
48
62
|
}
|
|
49
63
|
}
|
|
50
64
|
|
|
51
65
|
var allExport = async (config, types) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
67
|
+
return new Promise(async (resolve, reject) => {
|
|
68
|
+
try {
|
|
69
|
+
for (let i = 0; i < types.length; i++) {
|
|
70
|
+
let type = types[i]
|
|
71
|
+
var exportedModule = require('./lib/export/' + type)
|
|
72
|
+
await exportedModule.start(config).then(result => {
|
|
73
|
+
if (type === 'stack') {
|
|
74
|
+
let master_locale = { master_locale: { code: result.code } }
|
|
75
|
+
config = _.merge(config, master_locale)
|
|
76
|
+
}
|
|
77
|
+
return
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
addlogs(config, chalk.green('The content of the ' + config.source_stack + ' has been exported succesfully!'), 'success')
|
|
81
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success')
|
|
82
|
+
return resolve()
|
|
83
|
+
} catch (error) {
|
|
84
|
+
addlogs(config, chalk.red('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info'), 'error')
|
|
85
|
+
addlogs(config, chalk.red(error.errorMessage), 'error')
|
|
86
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error')
|
|
87
|
+
return reject()
|
|
64
88
|
}
|
|
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
89
|
})
|
|
74
90
|
}
|
|
@@ -14,44 +14,45 @@ class ExportCommand extends Command {
|
|
|
14
14
|
async run() {
|
|
15
15
|
const {flags} = this.parse(ExportCommand)
|
|
16
16
|
const extConfig = flags.config
|
|
17
|
-
const masterLang = flags['master-lang']
|
|
18
17
|
let sourceStack = flags['stack-uid']
|
|
19
18
|
const alias = flags['management-token-alias']
|
|
20
19
|
const authToken = flags['auth-token']
|
|
20
|
+
const securedAssets = flags['secured-assets']
|
|
21
21
|
const data = flags.data
|
|
22
22
|
const moduleName = flags.module
|
|
23
23
|
let _authToken = credStore.get('authtoken')
|
|
24
|
-
let host = this.
|
|
25
|
-
let
|
|
26
|
-
let
|
|
27
|
-
host.cma =
|
|
28
|
-
host.cda =
|
|
24
|
+
let host = this.region
|
|
25
|
+
let cmaHost = host.cma.split('//')
|
|
26
|
+
let cdaHost = host.cda.split('//')
|
|
27
|
+
host.cma = cmaHost[1]
|
|
28
|
+
host.cda = cdaHost[1]
|
|
29
29
|
|
|
30
30
|
if (alias && alias !== undefined) {
|
|
31
|
-
// await this.config.runHook('validateManagementTokenAlias', {alias: alias})
|
|
32
31
|
let managementTokens = this.getToken(alias)
|
|
33
32
|
if (managementTokens && managementTokens !== undefined) {
|
|
34
33
|
if (extConfig && extConfig !== undefined) {
|
|
35
34
|
configWithMToken(
|
|
36
35
|
extConfig,
|
|
37
36
|
managementTokens,
|
|
38
|
-
host
|
|
37
|
+
host,
|
|
38
|
+
securedAssets
|
|
39
39
|
)
|
|
40
|
-
} else if (
|
|
41
|
-
sourceStack = managementTokens.apiKey
|
|
40
|
+
} else if (data) {
|
|
42
41
|
parameterWithMToken(
|
|
43
|
-
masterLang,
|
|
44
42
|
managementTokens,
|
|
45
|
-
sourceStack,
|
|
46
43
|
data,
|
|
47
44
|
moduleName,
|
|
48
|
-
host
|
|
45
|
+
host,
|
|
46
|
+
_authToken,
|
|
47
|
+
securedAssets
|
|
49
48
|
)
|
|
50
|
-
} else if (
|
|
49
|
+
} else if (data === undefined && sourceStack === undefined) {
|
|
51
50
|
withoutParameterMToken(
|
|
52
51
|
managementTokens,
|
|
53
52
|
moduleName,
|
|
54
|
-
host
|
|
53
|
+
host,
|
|
54
|
+
_authToken,
|
|
55
|
+
securedAssets
|
|
55
56
|
)
|
|
56
57
|
} else {
|
|
57
58
|
this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage')
|
|
@@ -65,22 +66,24 @@ class ExportCommand extends Command {
|
|
|
65
66
|
extConfig,
|
|
66
67
|
_authToken,
|
|
67
68
|
moduleName,
|
|
68
|
-
host
|
|
69
|
+
host,
|
|
70
|
+
securedAssets
|
|
69
71
|
)
|
|
70
|
-
} else if (
|
|
71
|
-
parametersWithAuthToken(
|
|
72
|
-
masterLang,
|
|
72
|
+
} else if (sourceStack && data) {
|
|
73
|
+
return parametersWithAuthToken(
|
|
73
74
|
_authToken,
|
|
74
75
|
sourceStack,
|
|
75
76
|
data,
|
|
76
77
|
moduleName,
|
|
77
|
-
host
|
|
78
|
+
host,
|
|
79
|
+
securedAssets
|
|
78
80
|
)
|
|
79
|
-
} else if (
|
|
81
|
+
} else if (data === undefined && sourceStack === undefined) {
|
|
80
82
|
withoutParametersWithAuthToken(
|
|
81
83
|
_authToken,
|
|
82
84
|
moduleName,
|
|
83
|
-
host
|
|
85
|
+
host,
|
|
86
|
+
securedAssets
|
|
84
87
|
)
|
|
85
88
|
} else {
|
|
86
89
|
this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage')
|
|
@@ -88,6 +91,7 @@ class ExportCommand extends Command {
|
|
|
88
91
|
} else {
|
|
89
92
|
this.log('Provide the alias for management token or auth token')
|
|
90
93
|
}
|
|
94
|
+
// return
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
|
|
@@ -97,22 +101,23 @@ Export content from one stack to another
|
|
|
97
101
|
`
|
|
98
102
|
ExportCommand.examples = [
|
|
99
103
|
'csdx cm:export -A',
|
|
100
|
-
'csdx cm:export -A -
|
|
104
|
+
'csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>',
|
|
101
105
|
'csdx cm:export -A -c <path/to/config/dir>',
|
|
102
|
-
'csdx cm:export -a <management_token_alias>',
|
|
103
|
-
'csdx cm:export -a <management_token_alias> -l <master_language> -d <path/to/export/destination/dir>',
|
|
104
|
-
'csdx cm:export -a <management_token_alias> -c <path/to/config/file>',
|
|
105
106
|
'csdx cm:export -A -m <single module name>',
|
|
107
|
+
'csdx cm:export -A --secured-assets',
|
|
108
|
+
'csdx cm:export -a <management_token_alias>',
|
|
109
|
+
'csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>',
|
|
110
|
+
'csdx cm:export -a <management_token_alias> -c <path/to/config/file>'
|
|
106
111
|
]
|
|
107
112
|
|
|
108
113
|
ExportCommand.flags = {
|
|
109
114
|
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
115
|
'stack-uid': flags.string({char: 's', description: 'API key of the source stack'}),
|
|
112
116
|
data: flags.string({char: 'd', description: 'path or location to store the data'}),
|
|
113
117
|
'management-token-alias': flags.string({char: 'a', description: 'alias of the management token'}),
|
|
114
118
|
'auth-token': flags.boolean({char: 'A', description: 'to use auth token'}),
|
|
115
119
|
module: flags.string({char: 'm', description: '[optional] specific module name'}),
|
|
120
|
+
'secured-assets': flags.boolean({description: '[optional] use when assets are secured'}),
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
module.exports = ExportCommand
|
package/src/config/default.js
CHANGED
|
@@ -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
|
],
|
|
@@ -37,13 +38,38 @@ module.exports = {
|
|
|
37
38
|
'created_at',
|
|
38
39
|
'updated_at',
|
|
39
40
|
'created_by',
|
|
40
|
-
'updated_by'
|
|
41
|
-
]
|
|
41
|
+
'updated_by',
|
|
42
|
+
],
|
|
42
43
|
},
|
|
43
44
|
webhooks: {
|
|
44
45
|
dirName: 'webhooks',
|
|
45
46
|
fileName: 'webhooks.json',
|
|
46
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
|
+
},
|
|
47
73
|
globalfields: {
|
|
48
74
|
dirName: 'global_fields',
|
|
49
75
|
fileName: 'globalfields.json',
|
package/src/lib/export/assets.js
CHANGED
|
@@ -50,7 +50,7 @@ ExportAssets.prototype = {
|
|
|
50
50
|
return new Promise(function (resolve, reject) {
|
|
51
51
|
return self.getAssetCount().then(function (count) {
|
|
52
52
|
if (typeof count !== 'number' || count === 0) {
|
|
53
|
-
addlogs(config, '
|
|
53
|
+
addlogs(config, 'No assets found', 'success')
|
|
54
54
|
return resolve()
|
|
55
55
|
}
|
|
56
56
|
const assetBatches = []
|
|
@@ -246,8 +246,10 @@ ExportAssets.prototype = {
|
|
|
246
246
|
return resolve()
|
|
247
247
|
}
|
|
248
248
|
self.assetStream = {
|
|
249
|
-
url:
|
|
250
|
-
|
|
249
|
+
url: config.securedAssets
|
|
250
|
+
? `${asset.url}?authtoken=${config.authtoken || config.auth_token}`
|
|
251
|
+
: asset.url,
|
|
252
|
+
};
|
|
251
253
|
|
|
252
254
|
const assetStreamRequest = nativeRequest(self.assetStream)
|
|
253
255
|
assetStreamRequest.on('response', function () {
|
|
@@ -97,7 +97,7 @@ ExportContentTypes.prototype = {
|
|
|
97
97
|
helper.writeFile(path.join(contentTypesFolderPath, content_type.uid + '.json'),
|
|
98
98
|
content_type)
|
|
99
99
|
})
|
|
100
|
-
addlogs(config, chalk.green('Content type
|
|
100
|
+
addlogs(config, chalk.green('Content type(s) exported successfully'), 'success')
|
|
101
101
|
return resolve()
|
|
102
102
|
})
|
|
103
103
|
},
|
|
@@ -180,8 +180,8 @@ exportEntries.prototype.getEntries = function (apiDetails) {
|
|
|
180
180
|
})
|
|
181
181
|
}
|
|
182
182
|
if (apiDetails.skip > entriesList.items.length) {
|
|
183
|
-
addlogs(config, '
|
|
184
|
-
'
|
|
183
|
+
addlogs(config, 'Exported entries of ' + apiDetails.content_type +
|
|
184
|
+
' to the ' + apiDetails.locale + ' language successfully', 'success')
|
|
185
185
|
return resolve()
|
|
186
186
|
}
|
|
187
187
|
apiDetails.skip += limit
|
|
@@ -50,7 +50,7 @@ ExportEnvironments.prototype.start = function (mergConfig) {
|
|
|
50
50
|
return resolve()
|
|
51
51
|
}
|
|
52
52
|
if (environmentResponse.items.length === 0) {
|
|
53
|
-
addlogs(config, 'No environments
|
|
53
|
+
addlogs(config, 'No environments found', 'success')
|
|
54
54
|
return resolve()
|
|
55
55
|
}
|
|
56
56
|
}).catch(error => {
|
|
@@ -47,7 +47,7 @@ ExportExtensions.prototype.start = function (mergeConfig) {
|
|
|
47
47
|
addlogs(config, chalk.green('All the extensions have been exported successfully'), 'success')
|
|
48
48
|
return resolve()
|
|
49
49
|
}
|
|
50
|
-
addlogs(config, 'No extensions
|
|
50
|
+
addlogs(config, 'No extensions found', 'success')
|
|
51
51
|
return resolve()
|
|
52
52
|
}).catch(error => {
|
|
53
53
|
addlogs(config, error, 'error')
|
|
@@ -73,7 +73,7 @@ ExportGlobalFields.prototype = {
|
|
|
73
73
|
.then(globalFieldResponse => {
|
|
74
74
|
try {
|
|
75
75
|
if (globalFieldResponse.items.length === 0) {
|
|
76
|
-
addlogs(config, 'No
|
|
76
|
+
addlogs(config, 'No global fields found', 'success')
|
|
77
77
|
return resolve('No Global Fields')
|
|
78
78
|
}
|
|
79
79
|
globalFieldResponse.items.forEach(function (globalField) {
|
package/src/lib/export/labels.js
CHANGED
|
@@ -46,7 +46,7 @@ ExportLabels.prototype.start = function (credentialConfig) {
|
|
|
46
46
|
})
|
|
47
47
|
addlogs(config, chalk.green('All the labels have been exported successfully'), 'success')
|
|
48
48
|
} else {
|
|
49
|
-
addlogs(config, 'No labels
|
|
49
|
+
addlogs(config, 'No labels found', 'success')
|
|
50
50
|
}
|
|
51
51
|
helper.writeFile(path.join(labelsFolderPath, labelConfig.fileName), self.labels)
|
|
52
52
|
return resolve()
|
|
@@ -16,6 +16,7 @@ const masterLocale = config.master_locale
|
|
|
16
16
|
let requiredKeys = localeConfig.requiredKeys
|
|
17
17
|
let stack = require('../util/contentstack-management-sdk')
|
|
18
18
|
|
|
19
|
+
|
|
19
20
|
function ExportLocales() {
|
|
20
21
|
this.qs = {
|
|
21
22
|
include_count: true,
|
|
@@ -45,23 +46,23 @@ ExportLocales.prototype.start = function (credentialConfig) {
|
|
|
45
46
|
.then(localeResponse => {
|
|
46
47
|
if (localeResponse.items.length !== 0) {
|
|
47
48
|
localeResponse.items.forEach(function (locale) {
|
|
48
|
-
addlogs(credentialConfig, 'locale was exported successfully', 'success')
|
|
49
|
+
addlogs(credentialConfig, locale.name + ' locale was exported successfully', 'success')
|
|
49
50
|
for (const key in locale) {
|
|
50
51
|
if (requiredKeys.indexOf(key) === -1) {
|
|
51
|
-
delete locale
|
|
52
|
+
delete locale[key]
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
self.locales[locale.uid] = locale
|
|
55
56
|
})
|
|
56
57
|
addlogs(credentialConfig, chalk.green('All the locales have been exported successfully'), 'success')
|
|
57
58
|
} else if (localeResponse.items.length === 0) {
|
|
58
|
-
addlogs(credentialConfig, 'No
|
|
59
|
+
addlogs(credentialConfig, 'No languages found except the master language', 'success')
|
|
59
60
|
}
|
|
60
61
|
helper.writeFile(path.join(localesFolderPath, localeConfig.fileName), self.locales)
|
|
61
|
-
resolve()
|
|
62
|
+
return resolve()
|
|
62
63
|
}).catch(error => {
|
|
63
64
|
addlogs(credentialConfig, error, 'error')
|
|
64
|
-
reject()
|
|
65
|
+
return reject()
|
|
65
66
|
})
|
|
66
67
|
})
|
|
67
68
|
}
|
package/src/lib/export/stack.js
CHANGED
|
@@ -8,10 +8,11 @@ var chalk = require('chalk')
|
|
|
8
8
|
var mkdirp = require('mkdirp')
|
|
9
9
|
var path = require('path')
|
|
10
10
|
|
|
11
|
-
var request = require('../util/request')
|
|
12
11
|
var app = require('../../app')
|
|
13
12
|
var helper = require('../util/helper')
|
|
14
13
|
var {addlogs} = require('../util/log')
|
|
14
|
+
const stack = require('../util/contentstack-management-sdk')
|
|
15
|
+
|
|
15
16
|
|
|
16
17
|
let config = require('../../config/default')
|
|
17
18
|
|
|
@@ -28,22 +29,39 @@ function ExportStack () {
|
|
|
28
29
|
|
|
29
30
|
ExportStack.prototype.start = function (credentialConfig) {
|
|
30
31
|
config = credentialConfig
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
client = stack.Client(config)
|
|
33
|
+
if (!config.preserveStackVersion && !config.hasOwnProperty("master_locale")) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
var result = client.stack({ api_key: credentialConfig.source_stack, management_token: credentialConfig.management_token }).locale().query()
|
|
36
|
+
result.find()
|
|
37
|
+
.then(response => {
|
|
38
|
+
var masterLocalObj = response.items.filter(obj => {
|
|
39
|
+
if (obj.fallback_locale === null) {
|
|
40
|
+
return obj
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return resolve(masterLocalObj[0])
|
|
44
|
+
}).catch(error => {
|
|
45
|
+
return reject(error)
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
} else if(config.preserveStackVersion) {
|
|
49
|
+
addlogs(config, 'Exporting stack details', 'success')
|
|
50
|
+
let stackFolderPath = path.resolve(config.data, stackConfig.dirName)
|
|
51
|
+
let stackContentsFile = path.resolve(stackFolderPath, stackConfig.fileName)
|
|
52
|
+
|
|
53
|
+
mkdirp.sync(stackFolderPath)
|
|
54
|
+
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
return client.stack({api_key: config.source_stack}).fetch()
|
|
57
|
+
.then(response => {
|
|
58
|
+
helper.writeFile(stackContentsFile, response)
|
|
59
|
+
addlogs(config, 'Exported stack details successfully!', 'success')
|
|
60
|
+
return resolve(response)
|
|
61
|
+
})
|
|
62
|
+
.catch(reject)
|
|
44
63
|
})
|
|
45
|
-
|
|
46
|
-
})
|
|
64
|
+
}
|
|
47
65
|
}
|
|
48
66
|
|
|
49
67
|
module.exports = new ExportStack()
|
|
@@ -49,7 +49,7 @@ ExportWebhooks.prototype.start = function (credentialConfig) {
|
|
|
49
49
|
addlogs(config, chalk.green('All the webhooks have been exported successfully'), 'success')
|
|
50
50
|
return resolve()
|
|
51
51
|
}
|
|
52
|
-
addlogs(config, 'No webhooks
|
|
52
|
+
addlogs(config, 'No webhooks found', 'success')
|
|
53
53
|
return resolve()
|
|
54
54
|
}).catch(function (error) {
|
|
55
55
|
if (error.statusCode === 401) {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Contentstack Export
|
|
3
|
+
* Copyright (c) 2019 Contentstack LLC
|
|
4
|
+
* MIT Licensed
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const mkdirp = require('mkdirp')
|
|
8
|
+
const path = require('path')
|
|
9
|
+
const chalk = require('chalk')
|
|
10
|
+
|
|
11
|
+
let helper = require('../util/helper')
|
|
12
|
+
let {addlogs} = require('../util/log')
|
|
13
|
+
|
|
14
|
+
const stack = require('../util/contentstack-management-sdk')
|
|
15
|
+
let config = require('../../config/default')
|
|
16
|
+
let workFlowConfig = config.modules.workflows
|
|
17
|
+
let client
|
|
18
|
+
|
|
19
|
+
function ExportWorkFlows() {
|
|
20
|
+
this.workflows = {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
ExportWorkFlows.prototype.start = function (credentialConfig) {
|
|
24
|
+
addlogs(config, 'Starting workflow export', 'success')
|
|
25
|
+
let self = this
|
|
26
|
+
config = credentialConfig
|
|
27
|
+
client = stack.Client(config)
|
|
28
|
+
|
|
29
|
+
let workflowsFolderPath = path.resolve(config.data, workFlowConfig.dirName)
|
|
30
|
+
mkdirp.sync(workflowsFolderPath)
|
|
31
|
+
return new Promise(function (resolve, reject) {
|
|
32
|
+
return client.stack({api_key: config.source_stack, management_token: config.management_token}).workflow().fetchAll()
|
|
33
|
+
.then(response => {
|
|
34
|
+
if (response.items.length !== 0) {
|
|
35
|
+
response.items.forEach(function (workflow) {
|
|
36
|
+
addlogs(config, workflow.name + ' workflow was exported successfully', 'success')
|
|
37
|
+
self.workflows[workflow.uid] = workflow
|
|
38
|
+
let deleteItems = config.modules.workflows.invalidKeys
|
|
39
|
+
deleteItems.forEach(e => delete workflow[e])
|
|
40
|
+
})
|
|
41
|
+
addlogs(config, chalk.green('All the workflow have been exported successfully'), 'success')
|
|
42
|
+
}
|
|
43
|
+
if (response.items.length === 0) {
|
|
44
|
+
addlogs(config, 'No workflow were found in the Stack', 'success')
|
|
45
|
+
}
|
|
46
|
+
helper.writeFile(path.join(workflowsFolderPath, workFlowConfig.fileName), self.workflows)
|
|
47
|
+
return resolve()
|
|
48
|
+
}).catch(function (error) {
|
|
49
|
+
if (error.statusCode === 401) {
|
|
50
|
+
addlogs(config, chalk.red('You are not allowed to export workflow, Unless you provide email and password in config', 'error'))
|
|
51
|
+
return resolve()
|
|
52
|
+
}
|
|
53
|
+
addlogs(config, error, 'error')
|
|
54
|
+
return reject()
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = new ExportWorkFlows()
|
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
let defaultConfig = require('../../config/default')
|
|
7
7
|
let message = require('../../../messages/index.json')
|
|
8
8
|
let {initial} = require('../../app')
|
|
9
|
+
let path = require('path')
|
|
10
|
+
const helper = require('../util/helper');
|
|
9
11
|
let _ = require('lodash')
|
|
10
12
|
const {cli} = require('cli-ux')
|
|
11
13
|
|
|
12
|
-
exports.configWithMToken = function (config, managementTokens, host) {
|
|
14
|
+
exports.configWithMToken = function (config, managementTokens, host, securedAssets) {
|
|
13
15
|
let externalConfig = require(config)
|
|
16
|
+
defaultConfig.securedAssets = securedAssets
|
|
14
17
|
defaultConfig.management_token = managementTokens.token
|
|
15
18
|
defaultConfig.host = host.cma
|
|
16
19
|
defaultConfig.cdn = host.cda
|
|
@@ -18,43 +21,43 @@ exports.configWithMToken = function (config, managementTokens, host) {
|
|
|
18
21
|
initial(defaultConfig)
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
exports.parameterWithMToken = function (
|
|
22
|
-
let masterloc = {master_locale: {code: masterLang}}
|
|
24
|
+
exports.parameterWithMToken = function (managementTokens, data, moduleName, host, _authToken, securedAssets) {
|
|
23
25
|
defaultConfig.management_token = managementTokens.token
|
|
26
|
+
defaultConfig.auth_token = _authToken
|
|
24
27
|
defaultConfig.host = host.cma
|
|
25
28
|
defaultConfig.cdn = host.cda
|
|
29
|
+
defaultConfig.securedAssets = securedAssets
|
|
26
30
|
if (moduleName && moduleName !== undefined) {
|
|
27
31
|
defaultConfig.moduleName = moduleName
|
|
28
32
|
}
|
|
29
|
-
defaultConfig.source_stack =
|
|
33
|
+
defaultConfig.source_stack = managementTokens.apiKey
|
|
30
34
|
defaultConfig.data = data
|
|
31
|
-
defaultConfig = _.merge(defaultConfig, masterloc)
|
|
32
35
|
initial(defaultConfig)
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
// using ManagementToken
|
|
36
|
-
exports.withoutParameterMToken = async (managementTokens, moduleName, host) => {
|
|
37
|
-
const masterLocale = await cli.prompt(message.promptMessageList.promptMasterLocale)
|
|
39
|
+
exports.withoutParameterMToken = async (managementTokens, moduleName, host, _authToken, securedAssets) => {
|
|
38
40
|
const stackUid = managementTokens.apiKey
|
|
39
41
|
const pathOfExport = await cli.prompt(message.promptMessageList.promptPathStoredData)
|
|
40
|
-
let masterloc = {master_locale: {code: masterLocale}}
|
|
41
42
|
defaultConfig.management_token = managementTokens.token
|
|
42
43
|
defaultConfig.host = host.cma
|
|
43
44
|
defaultConfig.cdn = host.cda
|
|
45
|
+
defaultConfig.auth_token = _authToken
|
|
46
|
+
defaultConfig.securedAssets = securedAssets
|
|
44
47
|
if (moduleName && moduleName !== undefined) {
|
|
45
48
|
defaultConfig.moduleName = moduleName
|
|
46
49
|
}
|
|
47
50
|
defaultConfig.source_stack = stackUid
|
|
48
51
|
defaultConfig.data = pathOfExport
|
|
49
|
-
defaultConfig = _.merge(defaultConfig, masterloc)
|
|
50
52
|
initial(defaultConfig)
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
exports.configWithAuthToken = function (config, _authToken, moduleName, host) {
|
|
54
|
-
let externalConfig =
|
|
55
|
+
exports.configWithAuthToken = function (config, _authToken, moduleName, host, securedAssets) {
|
|
56
|
+
let externalConfig = helper.readFile(path.resolve(config))
|
|
55
57
|
defaultConfig.auth_token = _authToken
|
|
56
58
|
defaultConfig.host = host.cma
|
|
57
59
|
defaultConfig.cdn = host.cda
|
|
60
|
+
defaultConfig.securedAssets = securedAssets
|
|
58
61
|
if (moduleName && moduleName !== undefined) {
|
|
59
62
|
defaultConfig.moduleName = moduleName
|
|
60
63
|
}
|
|
@@ -62,33 +65,37 @@ exports.configWithAuthToken = function (config, _authToken, moduleName, host) {
|
|
|
62
65
|
initial(defaultConfig)
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
exports.parametersWithAuthToken = function (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
exports.parametersWithAuthToken = function (_authToken, sourceStack, data, moduleName, host, securedAssets) {
|
|
69
|
+
return new Promise(async(resolve, reject) => {
|
|
70
|
+
defaultConfig.auth_token = _authToken
|
|
71
|
+
defaultConfig.source_stack = sourceStack
|
|
72
|
+
if (moduleName && moduleName !== undefined) {
|
|
73
|
+
defaultConfig.moduleName = moduleName
|
|
74
|
+
}
|
|
75
|
+
defaultConfig.host = host.cma
|
|
76
|
+
defaultConfig.cdn = host.cda
|
|
77
|
+
defaultConfig.data = data
|
|
78
|
+
defaultConfig.securedAssets = securedAssets
|
|
79
|
+
var exportStart = initial(defaultConfig)
|
|
80
|
+
exportStart.then(() => {
|
|
81
|
+
return resolve()
|
|
82
|
+
}).catch((error) => {
|
|
83
|
+
return reject(error)
|
|
84
|
+
})
|
|
85
|
+
})
|
|
77
86
|
}
|
|
78
87
|
|
|
79
|
-
exports.withoutParametersWithAuthToken = async (_authToken, moduleName, host) => {
|
|
80
|
-
const masterLocale = await cli.prompt(message.promptMessageList.promptMasterLocale)
|
|
88
|
+
exports.withoutParametersWithAuthToken = async (_authToken, moduleName, host, securedAssets) => {
|
|
81
89
|
const stackUid = await cli.prompt(message.promptMessageList.promptSourceStack)
|
|
82
90
|
const pathOfExport = await cli.prompt(message.promptMessageList.promptPathStoredData)
|
|
83
|
-
let masterloc = {master_locale: {code: masterLocale}}
|
|
84
91
|
defaultConfig.auth_token = _authToken
|
|
85
92
|
defaultConfig.source_stack = stackUid
|
|
93
|
+
defaultConfig.securedAssets = securedAssets
|
|
86
94
|
if (moduleName && moduleName !== undefined) {
|
|
87
95
|
defaultConfig.moduleName = moduleName
|
|
88
96
|
}
|
|
89
97
|
defaultConfig.data = pathOfExport
|
|
90
98
|
defaultConfig.host = host.cma
|
|
91
99
|
defaultConfig.cdn = host.cda
|
|
92
|
-
defaultConfig = _.merge(defaultConfig, masterloc)
|
|
93
100
|
initial(defaultConfig)
|
|
94
101
|
}
|
package/src/lib/util/index.js
CHANGED
|
@@ -23,14 +23,10 @@ exports.validateConfig = function (config) {
|
|
|
23
23
|
} else if (!config.email && !config.password && config.preserveStackVersion) {
|
|
24
24
|
throw new Error('Kindly provide Email and password for stack details')
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
if(!config.languagesCode.includes(config.master_locale.code)) {
|
|
28
|
-
addlogs(config, chalk.red('Kindly provide valid master_locale code'), 'error')
|
|
29
|
-
process.exit()
|
|
30
|
-
}
|
|
31
26
|
}
|
|
32
27
|
|
|
33
28
|
exports.buildAppConfig = function (config) {
|
|
34
29
|
config = _.merge(defaultConfig, config)
|
|
35
30
|
return config
|
|
36
31
|
}
|
|
32
|
+
|
package/src/lib/util/log.js
CHANGED
package/src/lib/util/login.js
CHANGED
|
@@ -43,17 +43,16 @@ module.exports.login = config => {
|
|
|
43
43
|
}
|
|
44
44
|
return resolve(config)
|
|
45
45
|
// eslint-disable-next-line no-else-return
|
|
46
|
-
} else if (config.auth_token) {
|
|
46
|
+
} else if (config.auth_token && !config.management_token) {
|
|
47
47
|
client.stack({api_key: config.source_stack, management_token: config.management_token}).users()
|
|
48
48
|
.then(function () {
|
|
49
49
|
return resolve()
|
|
50
|
-
})
|
|
51
|
-
.catch(error => {
|
|
50
|
+
}).catch(error => {
|
|
52
51
|
if (error.errors.api_key) {
|
|
53
52
|
return reject(error)
|
|
54
53
|
}
|
|
55
54
|
addlogs(config, error.errorMessage, 'error')
|
|
56
|
-
return reject()
|
|
55
|
+
return reject(error)
|
|
57
56
|
})
|
|
58
57
|
} else if (config.management_token) {
|
|
59
58
|
return resolve()
|