@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 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/0.1.1-beta.9 linux-x64 node-v12.18.4
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-cmexport)
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
- -A, --auth-token to use auth token
44
- -B, --branch=branch [optional] branch name
45
- -a, --management-token-alias=management-token-alias alias of the management token
46
- -c, --config=config [optional] path of the config
47
- -d, --data=data path or location to store the data
48
- -m, --module=module [optional] specific module name
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
52
-
53
- DESCRIPTION
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 -A
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
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/v0.1.1-beta.9/packages/contentstack-export/src/commands/cm/export.js)_
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 -->
@@ -1 +1 @@
1
- {"version":"0.1.1-beta.9","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":[]}}}
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
- "name": "@contentstack/cli-cm-export",
3
- "description": "Contentstack CLI plugin to export content from stack",
4
- "version": "0.1.1-beta.9",
5
- "author": "Contentstack",
6
- "bugs": "https://github.com/contentstack/cli/issues",
7
- "dependencies": {
8
- "@contentstack/cli-command": "0.1.0-beta",
9
- "@contentstack/management": "github:contentstack/contentstack-management-javascript#65e8588",
10
- "@oclif/command": "^1.6.1",
11
- "@oclif/config": "^1.15.1",
12
- "async": "^3.2.0",
13
- "axios": "^0.21.1",
14
- "bluebird": "^3.7.2",
15
- "cli-ux": "^5.4.6",
16
- "configstore": "^5.0.1",
17
- "fs": "0.0.1-security",
18
- "is-valid-path": "^0.1.1",
19
- "lodash": "^4.17.20",
20
- "path": "^0.12.7",
21
- "proxyquire": "^2.1.3",
22
- "request": "^2.88.2",
23
- "winston": "^2.2.0"
24
- },
25
- "devDependencies": {
26
- "@oclif/dev-cli": "^1.22.2",
27
- "@oclif/plugin-help": "^3.0.1",
28
- "@oclif/test": "^1.2.6",
29
- "assert": "^2.0.0",
30
- "chai": "^4.2.0",
31
- "eslint": "^5.16.0",
32
- "eslint-config-oclif": "^3.1.0",
33
- "globby": "^10.0.2",
34
- "mocha": "^8.2.1",
35
- "nyc": "^14.1.1",
36
- "sinon": "^9.0.2"
37
- },
38
- "engines": {
39
- "node": ">=8.0.0"
40
- },
41
- "files": [
42
- "/npm-shrinkwrap.json",
43
- "/oclif.manifest.json",
44
- "/src",
45
- "/messages"
46
- ],
47
- "homepage": "https://github.com/contentstack/cli",
48
- "keywords": [
49
- "contentstack",
50
- "cli",
51
- "plugin"
52
- ],
53
- "license": "MIT",
54
- "scripts": {
55
- "postpack": "rm -f oclif.manifest.json",
56
- "prepack": "oclif-dev manifest && oclif-dev readme",
57
- "test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
58
- "version": "oclif-dev readme && git add README.md"
59
- },
60
- "oclif": {
61
- "commands": "./src/commands",
62
- "bin": "csdx",
63
- "devPlugins": [
64
- "@oclif/plugin-help"
65
- ],
66
- "repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/contentstack-export/<%- commandPath %>"
67
- },
68
- "main": "./src/commands/cm/export.js",
69
- "repository": "https://github.com/contentstack/cli"
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
- var util = require("./lib/util");
3
- var login = require("./lib/util/login");
4
- var { addlogs } = 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");
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
- // 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 {
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 contents', error)
32
+ console.log('failed export branch', branch.uid, error);
47
33
  }
48
34
  }
49
- resolve()
50
- })
51
- .catch((error) => {
52
- console.log("error", error);
53
- if (error && error.errors && error.errors.api_key) {
54
- addlogs(
55
- config,
56
- chalk.red(
57
- "Stack Api key " + error.errors.api_key[0],
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
- reject(error)
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
- var singleExport = async (moduleName, types, config, branchName) => {
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 = ["stack"];
86
+ iterateList = ['stack'];
83
87
  }
84
88
  iterateList.push(moduleName);
85
89
 
86
- for (let i = 0; i < iterateList.length; i++) {
87
-
88
- var exportedModule = require("./lib/export/" + iterateList[i]);
89
- const result = await exportedModule.start(config, branchName);
90
- if (result && iterateList[i] === "stack") {
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.master_locale },
98
+ master_locale: { code: result.code },
93
99
  };
94
100
  config = _.merge(config, master_locale);
95
101
  }
96
102
  }
97
- addlogs(config, moduleName + " was exported successfully!", "success");
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, "Please provide valid module name.", "error");
106
+ addlogs(config, 'Please provide valid module name.', 'error');
106
107
  }
107
- return true
108
+ return true;
108
109
  } catch (error) {
109
- addlogs(config, "Failed to migrate " + moduleName, "error");
110
- addlogs(config, error, "error");
111
- addlogs(
112
- config,
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
- var allExport = async (config, types, branchName) => {
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 (let i = 0; i < types.length; i++) {
126
- let type = types[i];
127
- var exportedModule = require("./lib/export/" + type);
128
- const result = await exportedModule.start(config, branchName);
129
- if (result && type === "stack") {
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
- "The content of the " +
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
- "The log for this is stored at " +
146
- path.join(config.data, "logs", "export"),
147
- "success"
142
+ chalk.red('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info'),
143
+ 'error',
148
144
  );
149
- return resolve();
150
- } catch (error) {
151
- addlogs(config, chalk.red('Failed to migrate stack: ' + config.source_stack + '. Please check error logs for more info'), 'error')
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
  };