@contentstack/cli-cm-export 1.5.8 → 1.5.9
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 +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +3 -3
- package/src/app.js +8 -13
- package/src/commands/cm/stacks/export.js +5 -5
- package/src/lib/export/assets.js +14 -11
- package/src/lib/export/content-types.js +2 -2
- package/src/lib/export/custom-roles.js +3 -4
- package/src/lib/export/entries.js +5 -5
- 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 +4 -6
- package/src/lib/export/locales.js +1 -1
- package/src/lib/export/marketplace-apps.js +29 -26
- package/src/lib/export/stack.js +0 -1
- package/src/lib/export/webhooks.js +3 -3
- package/src/lib/export/workflows.js +4 -8
- package/src/lib/util/log.js +4 -1
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export
|
|
|
48
48
|
$ csdx COMMAND
|
|
49
49
|
running command...
|
|
50
50
|
$ csdx (--version)
|
|
51
|
-
@contentstack/cli-cm-export/1.5.
|
|
51
|
+
@contentstack/cli-cm-export/1.5.9 linux-x64 node-v16.20.0
|
|
52
52
|
$ csdx --help [COMMAND]
|
|
53
53
|
USAGE
|
|
54
54
|
$ csdx COMMAND
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export",
|
|
3
3
|
"description": "Contentstack CLI plugin to export content from stack",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.9",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-command": "^1.2.
|
|
9
|
-
"@contentstack/cli-utilities": "^1.4.
|
|
8
|
+
"@contentstack/cli-command": "^1.2.9",
|
|
9
|
+
"@contentstack/cli-utilities": "^1.4.5",
|
|
10
10
|
"@oclif/command": "^1.8.16",
|
|
11
11
|
"@oclif/config": "^1.18.3",
|
|
12
12
|
"async": "^3.2.4",
|
package/src/app.js
CHANGED
|
@@ -36,7 +36,7 @@ exports.initial = async (config) => {
|
|
|
36
36
|
await allExport(APIClient, stackAPIClient, config, types, branch.uid);
|
|
37
37
|
}
|
|
38
38
|
} catch (error) {
|
|
39
|
-
addlogs(config, `failed export contents ${branch.uid} ${util.formatError(error)}`, 'error');
|
|
39
|
+
addlogs(config, `failed export contents '${branch.uid}' ${util.formatError(error)}`, 'error');
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
} else {
|
|
@@ -47,7 +47,7 @@ exports.initial = async (config) => {
|
|
|
47
47
|
await allExport(APIClient, stackAPIClient, config, types);
|
|
48
48
|
}
|
|
49
49
|
} catch (error) {
|
|
50
|
-
addlogs(config, `failed export contents ${util.formatError(error)}`, 'error');
|
|
50
|
+
addlogs(config, `failed export contents. ${util.formatError(error)}`, 'error');
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
};
|
|
@@ -77,9 +77,8 @@ exports.initial = async (config) => {
|
|
|
77
77
|
resolve();
|
|
78
78
|
})
|
|
79
79
|
.catch((error) => {
|
|
80
|
-
console.log('error', error && error.message);
|
|
81
80
|
if (error && error.errors && error.errors.api_key) {
|
|
82
|
-
addlogs(config,
|
|
81
|
+
addlogs(config, `Stack Api key '${error.errors.api_key[0]}', Please enter valid Key`, 'error');
|
|
83
82
|
addlogs(config, 'The log for this is stored at ' + config.data + '/export/logs', 'success');
|
|
84
83
|
} else {
|
|
85
84
|
addlogs(config, `${util.formatError(error)}`, 'error');
|
|
@@ -112,7 +111,7 @@ const singleExport = async (APIClient, stackAPIClient, moduleName, types, config
|
|
|
112
111
|
config = _.merge(config, master_locale);
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
|
-
addlogs(config,
|
|
114
|
+
addlogs(config, `Module '${moduleName}' was exported successfully!`, 'success');
|
|
116
115
|
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success');
|
|
117
116
|
} else {
|
|
118
117
|
addlogs(config, 'Please provide valid module name.', 'error');
|
|
@@ -120,8 +119,8 @@ const singleExport = async (APIClient, stackAPIClient, moduleName, types, config
|
|
|
120
119
|
return true;
|
|
121
120
|
} catch (error) {
|
|
122
121
|
addlogs(config, `${util.formatError(error)}`, 'error');
|
|
123
|
-
addlogs(config,
|
|
124
|
-
addlogs(config,
|
|
122
|
+
addlogs(config, `Failed to migrate module '${moduleName}'`, 'error');
|
|
123
|
+
addlogs(config, `The log for this is stored at '${path.join(config.data, 'logs', 'export')}'`, 'error');
|
|
125
124
|
}
|
|
126
125
|
};
|
|
127
126
|
|
|
@@ -149,13 +148,9 @@ const allExport = async (APIClient, stackAPIClient, config, types, branchName) =
|
|
|
149
148
|
addlogs(config, util.formatError(error), 'error');
|
|
150
149
|
addlogs(
|
|
151
150
|
config,
|
|
152
|
-
|
|
153
|
-
'Failed to migrate stack: ' +
|
|
154
|
-
(config.sourceStackName || config.source_stack) +
|
|
155
|
-
'. Please check error logs for more info',
|
|
156
|
-
),
|
|
151
|
+
`Failed to migrate stack '${config.sourceStackName || config.source_stack}'. Please check error logs for more info.`,
|
|
157
152
|
'error',
|
|
158
153
|
);
|
|
159
|
-
addlogs(config,
|
|
154
|
+
addlogs(config, `The log for this is stored at '${path.join(config.data, 'logs', 'export')}'`, 'error');
|
|
160
155
|
}
|
|
161
156
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
2
|
const { Command } = require('@contentstack/cli-command');
|
|
3
|
-
const { printFlagDeprecation, configHandler, flags, isAuthenticated } = require('@contentstack/cli-utilities');
|
|
3
|
+
const { printFlagDeprecation, configHandler, flags, isAuthenticated, cliux } = require('@contentstack/cli-utilities');
|
|
4
4
|
const {
|
|
5
5
|
configWithMToken,
|
|
6
6
|
parameterWithMToken,
|
|
@@ -71,10 +71,10 @@ class ExportCommand extends Command {
|
|
|
71
71
|
exportCommandFlags,
|
|
72
72
|
);
|
|
73
73
|
} else {
|
|
74
|
-
|
|
74
|
+
cliux.print(`error: Please provide a valid command. Run "csdx cm:export --help" command to view the command usage`, {color: 'red'});
|
|
75
75
|
}
|
|
76
76
|
} else {
|
|
77
|
-
|
|
77
|
+
cliux.print(`error: ${alias} management token is not present, please add managment token first`, {color: 'red'});
|
|
78
78
|
}
|
|
79
79
|
} else if (isAuthenticated()) {
|
|
80
80
|
if (extConfig) {
|
|
@@ -108,10 +108,10 @@ class ExportCommand extends Command {
|
|
|
108
108
|
exportCommandFlags,
|
|
109
109
|
);
|
|
110
110
|
} else {
|
|
111
|
-
|
|
111
|
+
cliux.print(`error: Please provide a valid command. Run "csdx cm:export --help" command to view the command usage`, {color: 'red'});
|
|
112
112
|
}
|
|
113
113
|
} else {
|
|
114
|
-
|
|
114
|
+
cliux.print(`error: Login or provide the alias for management token`, {color: 'red'});
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
}
|
package/src/lib/export/assets.js
CHANGED
|
@@ -17,6 +17,7 @@ const helper = require('../util/helper');
|
|
|
17
17
|
const { addlogs } = require('../util/log');
|
|
18
18
|
|
|
19
19
|
let config = require('../../config/default');
|
|
20
|
+
const { formatError } = require('../util');
|
|
20
21
|
|
|
21
22
|
module.exports = class ExportAssets {
|
|
22
23
|
config;
|
|
@@ -86,7 +87,8 @@ module.exports = class ExportAssets {
|
|
|
86
87
|
.catch((error) => {
|
|
87
88
|
addlogs(
|
|
88
89
|
self.config,
|
|
89
|
-
|
|
90
|
+
`Asset '${assetJSON.uid}' failed to download.\n ${formatError(error)}`,
|
|
91
|
+
'error'
|
|
90
92
|
);
|
|
91
93
|
addlogs(self.config, error, 'error');
|
|
92
94
|
});
|
|
@@ -98,8 +100,8 @@ module.exports = class ExportAssets {
|
|
|
98
100
|
})
|
|
99
101
|
.catch((err) => {
|
|
100
102
|
addlogs(
|
|
101
|
-
|
|
102
|
-
`Asset download failed
|
|
103
|
+
self.config,
|
|
104
|
+
`Asset '${assetJSON.uid}' download failed. ${formatError(err)}`,
|
|
103
105
|
'error',
|
|
104
106
|
);
|
|
105
107
|
return err;
|
|
@@ -113,8 +115,8 @@ module.exports = class ExportAssets {
|
|
|
113
115
|
// helper.writeFileSync(this.assetContentsFile, self.assetContents)
|
|
114
116
|
})
|
|
115
117
|
.catch((error) => {
|
|
116
|
-
|
|
117
|
-
addlogs(self.config,
|
|
118
|
+
addlogs(self.config, `Asset batch ${batch + 1} failed to download`, 'error');
|
|
119
|
+
addlogs(self.config, formatError(error), 'error');
|
|
118
120
|
addlogs(self.config, error, 'error');
|
|
119
121
|
});
|
|
120
122
|
})
|
|
@@ -135,7 +137,7 @@ module.exports = class ExportAssets {
|
|
|
135
137
|
return resolve();
|
|
136
138
|
})
|
|
137
139
|
.catch((error) => {
|
|
138
|
-
addlogs(self.config, error, '
|
|
140
|
+
addlogs(self.config, error, 'error');
|
|
139
141
|
reject(error);
|
|
140
142
|
});
|
|
141
143
|
})
|
|
@@ -143,14 +145,15 @@ module.exports = class ExportAssets {
|
|
|
143
145
|
helper.writeFileSync(self.assetContentsFile, self.assetContents);
|
|
144
146
|
addlogs(
|
|
145
147
|
self.config,
|
|
146
|
-
|
|
148
|
+
`Asset export failed. ${formatError(error)}`,
|
|
149
|
+
'error'
|
|
147
150
|
);
|
|
148
|
-
addlogs(self.config, error, '
|
|
151
|
+
addlogs(self.config, error, 'error');
|
|
149
152
|
reject(error);
|
|
150
153
|
});
|
|
151
154
|
})
|
|
152
155
|
.catch((error) => {
|
|
153
|
-
addlogs(self.config, error, '
|
|
156
|
+
addlogs(self.config, error, 'error');
|
|
154
157
|
reject(error);
|
|
155
158
|
});
|
|
156
159
|
});
|
|
@@ -175,7 +178,7 @@ module.exports = class ExportAssets {
|
|
|
175
178
|
return resolve();
|
|
176
179
|
})
|
|
177
180
|
.catch((error) => {
|
|
178
|
-
addlogs(self.config,
|
|
181
|
+
addlogs(self.config, `Error while exporting asset-folders!\n ${formatError(error)}`, 'error');
|
|
179
182
|
return reject(error);
|
|
180
183
|
});
|
|
181
184
|
})
|
|
@@ -319,7 +322,6 @@ module.exports = class ExportAssets {
|
|
|
319
322
|
})
|
|
320
323
|
.catch((error) => {
|
|
321
324
|
addlogs(self.config, error, 'error');
|
|
322
|
-
console.log('Error on fetch', error && error.message);
|
|
323
325
|
|
|
324
326
|
if (error.status === 408) {
|
|
325
327
|
console.log('retrying', uid);
|
|
@@ -383,6 +385,7 @@ module.exports = class ExportAssets {
|
|
|
383
385
|
return resolve();
|
|
384
386
|
})
|
|
385
387
|
.on('error', (error) => {
|
|
388
|
+
addlogs(self.config, `Download ${asset.filename}: ${asset.uid} failed!`, 'error');
|
|
386
389
|
addlogs(self.config, error, 'error');
|
|
387
390
|
reject(error);
|
|
388
391
|
});
|
|
@@ -37,7 +37,7 @@ class ContentTypesExport {
|
|
|
37
37
|
await this.writeContentTypes(this.contentTypes);
|
|
38
38
|
addlogs(this.exportConfig, chalk.green('Content type(s) exported successfully'), 'success');
|
|
39
39
|
} catch (error) {
|
|
40
|
-
addlogs(this.exportConfig,
|
|
40
|
+
addlogs(this.exportConfig, `Failed to export content types ${formatError(error)}`, 'error');
|
|
41
41
|
throw new Error('Failed to export content types');
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -58,7 +58,7 @@ class ContentTypesExport {
|
|
|
58
58
|
}
|
|
59
59
|
return await this.getContentTypes(skip);
|
|
60
60
|
} else {
|
|
61
|
-
|
|
61
|
+
addlogs(this.exportConfig, 'No content types returned for the given query', 'info');
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -45,7 +45,7 @@ module.exports = class ExportCustomRoles {
|
|
|
45
45
|
);
|
|
46
46
|
self.customRoles = {};
|
|
47
47
|
customRoles.forEach((role) => {
|
|
48
|
-
addlogs(self.config, role.name
|
|
48
|
+
addlogs(self.config, `'${role.name}' role was exported successfully`, 'success');
|
|
49
49
|
self.customRoles[role.uid] = role;
|
|
50
50
|
});
|
|
51
51
|
helper.writeFileSync(path.join(rolesFolderPath, self.rolesConfig.fileName), self.customRoles);
|
|
@@ -54,13 +54,12 @@ module.exports = class ExportCustomRoles {
|
|
|
54
54
|
if (error.statusCode === 401) {
|
|
55
55
|
addlogs(
|
|
56
56
|
self.config,
|
|
57
|
-
|
|
57
|
+
'You are not allowed to export roles, Unless you provide email and password in config',
|
|
58
58
|
'error',
|
|
59
59
|
);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
addlogs(self.config,
|
|
63
|
-
addlogs(self.config, formatError(error), 'error');
|
|
62
|
+
addlogs(self.config, `Error occurred in exporting roles. ${formatError(error)}`, 'error');
|
|
64
63
|
throw error;
|
|
65
64
|
}
|
|
66
65
|
}
|
|
@@ -32,7 +32,7 @@ class EntriesExport {
|
|
|
32
32
|
const locales = await fileHelper.readFile(this.localesFilePath);
|
|
33
33
|
const contentTypes = await fileHelper.readFile(this.schemaFilePath);
|
|
34
34
|
if (contentTypes.length === 0) {
|
|
35
|
-
addlogs(this.exportConfig, 'No content types found to export entries');
|
|
35
|
+
addlogs(this.exportConfig, 'No content types found to export entries', 'info');
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
const entryRequestOptions = this.createRequestObjects(locales, contentTypes);
|
|
@@ -52,13 +52,13 @@ class EntriesExport {
|
|
|
52
52
|
await fileHelper.writeLargeFile(entriesFilePath, entries);
|
|
53
53
|
addlogs(
|
|
54
54
|
this.exportConfig,
|
|
55
|
-
`Exported entries of type ${requestOption.content_type} locale ${requestOption.locale}`,
|
|
55
|
+
`Exported entries of type '${requestOption.content_type}' locale '${requestOption.locale}'`,
|
|
56
56
|
'success',
|
|
57
57
|
);
|
|
58
58
|
if (this.exportConfig.versioning) {
|
|
59
59
|
addlogs(
|
|
60
60
|
this.exportConfig,
|
|
61
|
-
`Started export versioned entries of type ${requestOption.content_type} locale ${requestOption.locale}`,
|
|
61
|
+
`Started export versioned entries of type '${requestOption.content_type}' locale '${requestOption.locale}'`,
|
|
62
62
|
'info',
|
|
63
63
|
);
|
|
64
64
|
for (let entry of entries) {
|
|
@@ -85,7 +85,7 @@ class EntriesExport {
|
|
|
85
85
|
await executeTask(versionedEntries, write.bind(this), { concurrency: this.writeConcurrency });
|
|
86
86
|
addlogs(
|
|
87
87
|
this.exportConfig,
|
|
88
|
-
`Exported versioned entries of type ${requestOption.content_type} locale ${requestOption.locale}`,
|
|
88
|
+
`Exported versioned entries of type '${requestOption.content_type}' locale '${requestOption.locale}'`,
|
|
89
89
|
'success',
|
|
90
90
|
);
|
|
91
91
|
}
|
|
@@ -94,7 +94,7 @@ class EntriesExport {
|
|
|
94
94
|
}
|
|
95
95
|
addlogs(this.exportConfig, chalk.green('Entries exported successfully'), 'success');
|
|
96
96
|
} catch (error) {
|
|
97
|
-
addlogs(this.exportConfig,
|
|
97
|
+
addlogs(this.exportConfig, `Failed to export entries ${formatError(error)}`, 'error');
|
|
98
98
|
throw new Error('Failed to export entries');
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -66,7 +66,7 @@ module.exports = class ExportEnvironments {
|
|
|
66
66
|
}
|
|
67
67
|
})
|
|
68
68
|
.catch((error) => {
|
|
69
|
-
addlogs(self.config, `Environments export failed ${formatError(error)}`, 'error');
|
|
69
|
+
addlogs(self.config, `Environments export failed. ${formatError(error)}`, 'error');
|
|
70
70
|
reject(error);
|
|
71
71
|
});
|
|
72
72
|
});
|
|
@@ -61,7 +61,7 @@ module.exports = class ExportExtensions {
|
|
|
61
61
|
resolve();
|
|
62
62
|
})
|
|
63
63
|
.catch((error) => {
|
|
64
|
-
addlogs(self.config, `Failed to export extensions ${formatError(error)}`, 'error');
|
|
64
|
+
addlogs(self.config, `Failed to export extensions. ${formatError(error)}`, 'error');
|
|
65
65
|
reject();
|
|
66
66
|
});
|
|
67
67
|
});
|
|
@@ -95,7 +95,7 @@ module.exports = class ExportGlobalFields {
|
|
|
95
95
|
}
|
|
96
96
|
return self.getGlobalFields(skip, globalFieldConfig).then(resolve).catch(reject);
|
|
97
97
|
} catch (error) {
|
|
98
|
-
addlogs(globalFieldConfig,
|
|
98
|
+
addlogs(globalFieldConfig, `Failed to export global-fields. ${formatError(error)}`, 'error');
|
|
99
99
|
reject(error);
|
|
100
100
|
}
|
|
101
101
|
})
|
package/src/lib/export/labels.js
CHANGED
|
@@ -37,7 +37,7 @@ module.exports = class ExportLabels {
|
|
|
37
37
|
.then((response) => {
|
|
38
38
|
if (response.items.length !== 0) {
|
|
39
39
|
response.items.forEach(function (label) {
|
|
40
|
-
addlogs(self.config, label.name
|
|
40
|
+
addlogs(self.config, `'${label.name}' label was exported successfully`, 'success');
|
|
41
41
|
self.labels[label.uid] = label;
|
|
42
42
|
const deleteItems = self.config.modules.labels.invalidKeys;
|
|
43
43
|
deleteItems.forEach((e) => delete label[e]);
|
|
@@ -53,15 +53,13 @@ module.exports = class ExportLabels {
|
|
|
53
53
|
if (error.statusCode === 401) {
|
|
54
54
|
addlogs(
|
|
55
55
|
self.config,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
'error',
|
|
59
|
-
),
|
|
56
|
+
'You are not allowed to export label, Unless you provide email and password in config',
|
|
57
|
+
'error'
|
|
60
58
|
);
|
|
61
59
|
return resolve();
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
addlogs(self.config, formatError(error)
|
|
62
|
+
addlogs(self.config, `Failed to export labels. ${formatError(error)}`, 'error');
|
|
65
63
|
reject();
|
|
66
64
|
});
|
|
67
65
|
});
|
|
@@ -33,7 +33,7 @@ class LocaleExport {
|
|
|
33
33
|
await fileHelper.writeFile(path.join(this.localesPath, this.masterLocaleConfig.fileName), this.masterLocale);
|
|
34
34
|
addlogs(this.exportConfig, 'Completed locale export', 'success');
|
|
35
35
|
} catch (error) {
|
|
36
|
-
addlogs(this.exportConfig,
|
|
36
|
+
addlogs(this.exportConfig, `Failed to export locales. ${formatError(error)}`, 'error');
|
|
37
37
|
throw new Error('Failed to export locales');
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -107,11 +107,12 @@ module.exports = class ExportMarketplaceApps {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
async exportInstalledExtensions() {
|
|
110
|
+
const client = await managementSDKClient({ host: this.developerHubBaseUrl.split("://").pop() })
|
|
110
111
|
const installedApps = (await this.getAllStackSpecificApps()) || [];
|
|
111
112
|
|
|
112
113
|
if (!_.isEmpty(installedApps)) {
|
|
113
114
|
for (const [index, app] of _.entries(installedApps)) {
|
|
114
|
-
await this.getAppConfigurations(installedApps, [+index, app]);
|
|
115
|
+
await this.getAppConfigurations(client, installedApps, [+index, app]);
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
await writeFileSync(path.join(this.marketplaceAppPath, this.marketplaceAppConfig.fileName), installedApps);
|
|
@@ -149,36 +150,38 @@ module.exports = class ExportMarketplaceApps {
|
|
|
149
150
|
return listOfApps;
|
|
150
151
|
})
|
|
151
152
|
.catch((error) => {
|
|
152
|
-
log(this.config, `Failed to export marketplace-apps ${formatError(error)}`, 'error');
|
|
153
|
+
log(this.config, `Failed to export marketplace-apps. ${formatError(error)}`, 'error');
|
|
153
154
|
});
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
getAppConfigurations(installedApps, [index,
|
|
157
|
-
const appName =
|
|
157
|
+
async getAppConfigurations(sdkClient, installedApps, [index, appInstallation]) {
|
|
158
|
+
const appName = appInstallation.manifest.name;
|
|
158
159
|
log(this.config, `Exporting ${appName} app and it's config.`, 'success');
|
|
159
160
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (!_.isEmpty(data.server_configuration)) {
|
|
171
|
-
installedApps[index]['server_configuration'] = this.nodeCrypto.encrypt(data.server_configuration);
|
|
172
|
-
log(this.config, `Exported ${appName} app and it's config.`, 'success');
|
|
173
|
-
} else {
|
|
174
|
-
log(this.config, `Exported ${appName} app`, 'success');
|
|
175
|
-
}
|
|
176
|
-
} else if (error) {
|
|
177
|
-
log(this.config, `Error on exporting ${appName} app and it's config.`, 'error');
|
|
161
|
+
await sdkClient
|
|
162
|
+
.organization(this.config.org_uid)
|
|
163
|
+
.app(appInstallation.manifest.uid)
|
|
164
|
+
.installation(appInstallation.uid)
|
|
165
|
+
.installationData()
|
|
166
|
+
.then(async result => {
|
|
167
|
+
const {data, error} = result;
|
|
168
|
+
if (_.has(data, 'server_configuration')) {
|
|
169
|
+
if (!this.nodeCrypto && _.has(data, 'server_configuration')) {
|
|
170
|
+
await this.createNodeCryptoInstance();
|
|
178
171
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
172
|
+
|
|
173
|
+
if (!_.isEmpty(data.server_configuration)) {
|
|
174
|
+
installedApps[index]['server_configuration'] = this.nodeCrypto.encrypt(data.server_configuration);
|
|
175
|
+
log(this.config, `Exported ${appName} app and it's config.`, 'success');
|
|
176
|
+
} else {
|
|
177
|
+
log(this.config, `Exported ${appName} app`, 'success');
|
|
178
|
+
}
|
|
179
|
+
} else if (error) {
|
|
180
|
+
log(this.config, `Error on exporting ${appName} app and it's config.`, 'error');
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
.catch(err => {
|
|
184
|
+
log(this.config, `Failed to export ${appName} app config ${formatError(err)}`, 'error');
|
|
185
|
+
})
|
|
183
186
|
}
|
|
184
187
|
};
|
package/src/lib/export/stack.js
CHANGED
|
@@ -63,13 +63,13 @@ module.exports = class ExportWebhooks {
|
|
|
63
63
|
if (error.statusCode === 401) {
|
|
64
64
|
addlogs(
|
|
65
65
|
self.config,
|
|
66
|
-
|
|
66
|
+
'You are not allowed to export webhooks, Unless you provide email and password in config',
|
|
67
67
|
'error',
|
|
68
68
|
);
|
|
69
69
|
return resolve();
|
|
70
70
|
}
|
|
71
|
-
addlogs(self.config, formatError(error)
|
|
72
|
-
reject('Failed export webhooks');
|
|
71
|
+
addlogs(self.config, `Failed to export webhooks. ${formatError(error)}`, 'error');
|
|
72
|
+
reject('Failed to export webhooks');
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
}
|
|
@@ -59,10 +59,8 @@ module.exports = class ExportWorkFlows {
|
|
|
59
59
|
if (error.statusCode === 401) {
|
|
60
60
|
addlogs(
|
|
61
61
|
self.config,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
'error',
|
|
65
|
-
),
|
|
62
|
+
'You are not allowed to export workflow, Unless you provide email and password in config',
|
|
63
|
+
'error',
|
|
66
64
|
);
|
|
67
65
|
return resolve();
|
|
68
66
|
}
|
|
@@ -86,8 +84,7 @@ module.exports = class ExportWorkFlows {
|
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
} catch (error) {
|
|
89
|
-
|
|
90
|
-
addlogs(self.config, 'Error fetching roles in export workflows task.', 'error');
|
|
87
|
+
addlogs(self.config, `Error fetching roles in export workflows task. ${formatError(error)}`, 'error');
|
|
91
88
|
throw new Error({ message: 'Error fetching roles in export workflows task.' });
|
|
92
89
|
}
|
|
93
90
|
}
|
|
@@ -102,8 +99,7 @@ module.exports = class ExportWorkFlows {
|
|
|
102
99
|
deleteItems.forEach((e) => delete workflow[e]);
|
|
103
100
|
}
|
|
104
101
|
} catch (error) {
|
|
105
|
-
|
|
106
|
-
addlogs(self.config, 'Error fetching workflow data in export workflows task.', 'error');
|
|
102
|
+
addlogs(self.config, `Error fetching workflow data in export workflows task. ${formatError(error)}`, 'error');
|
|
107
103
|
throw error;
|
|
108
104
|
}
|
|
109
105
|
}
|
package/src/lib/util/log.js
CHANGED
|
@@ -89,7 +89,10 @@ function init(_logPath) {
|
|
|
89
89
|
errorLogger = winston.createLogger({
|
|
90
90
|
transports: [
|
|
91
91
|
new winston.transports.File(errorTransport),
|
|
92
|
-
new winston.transports.Console({
|
|
92
|
+
new winston.transports.Console({
|
|
93
|
+
level: 'error',
|
|
94
|
+
format: winston.format.combine(winston.format.colorize({ all: true,colors:{ error: 'red'} }), winston.format.simple()),
|
|
95
|
+
}),
|
|
93
96
|
],
|
|
94
97
|
levels: { error: 0 },
|
|
95
98
|
});
|