@contentstack/cli-cm-export 1.5.0 → 1.5.2
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 +11 -8
- package/src/app.js +17 -12
- package/src/commands/cm/stacks/export.js +28 -11
- package/src/lib/export/assets.js +37 -37
- package/src/lib/export/content-types.js +4 -1
- package/src/lib/export/custom-roles.js +4 -10
- package/src/lib/export/environments.js +2 -2
- package/src/lib/export/extensions.js +1 -1
- package/src/lib/export/global-fields.js +3 -9
- package/src/lib/export/labels.js +1 -1
- package/src/lib/export/locales.js +1 -0
- package/src/lib/export/marketplace-apps.js +28 -24
- package/src/lib/export/webhooks.js +2 -1
- package/src/lib/export/workflows.js +3 -2
- package/src/lib/util/export-flags.js +59 -28
- package/src/lib/util/index.js +4 -5
- package/src/lib/util/setup-branches.js +2 -0
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ $ npm install -g @contentstack/cli-cm-export
|
|
|
38
38
|
$ csdx COMMAND
|
|
39
39
|
running command...
|
|
40
40
|
$ csdx (--version)
|
|
41
|
-
@contentstack/cli-cm-export/1.5.
|
|
41
|
+
@contentstack/cli-cm-export/1.5.2 linux-x64 node-v16.20.0
|
|
42
42
|
$ csdx --help [COMMAND]
|
|
43
43
|
USAGE
|
|
44
44
|
$ 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.2",
|
|
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.
|
|
8
|
+
"@contentstack/cli-command": "^1.2.3",
|
|
9
|
+
"@contentstack/cli-utilities": "^1.4.0",
|
|
10
10
|
"@oclif/command": "^1.8.16",
|
|
11
11
|
"@oclif/config": "^1.18.3",
|
|
12
12
|
"async": "^3.2.4",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"winston": "^3.7.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@contentstack/cli-auth": "^1.
|
|
27
|
-
"@contentstack/cli-config": "^1.
|
|
26
|
+
"@contentstack/cli-auth": "^1.3.1",
|
|
27
|
+
"@contentstack/cli-config": "^1.3.1",
|
|
28
28
|
"@contentstack/cli-dev-dependencies": "^1.2.0",
|
|
29
29
|
"@oclif/plugin-help": "^5.1.19",
|
|
30
30
|
"@oclif/test": "^1.2.6",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"mocha": "10.1.0",
|
|
39
39
|
"nyc": "^15.1.0",
|
|
40
40
|
"sinon": "^15.0.1",
|
|
41
|
-
"oclif": "^3.1
|
|
41
|
+
"oclif": "^3.8.1"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=14.0.0"
|
|
@@ -62,12 +62,15 @@
|
|
|
62
62
|
"test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
|
|
63
63
|
"version": "oclif readme && git add README.md",
|
|
64
64
|
"clean": "rm -rf ./node_modules tsconfig.build.tsbuildinfo",
|
|
65
|
-
"test:integration": "mocha --forbid-only \"test/run.test.js\"
|
|
65
|
+
"test:integration": "INTEGRATION_TEST=true mocha --config ./test/.mocharc.js --forbid-only \"test/run.test.js\"",
|
|
66
66
|
"test:unit": "mocha --forbid-only \"test/unit/*.test.js\" --unit-test"
|
|
67
67
|
},
|
|
68
68
|
"oclif": {
|
|
69
69
|
"commands": "./src/commands",
|
|
70
70
|
"bin": "csdx",
|
|
71
|
+
"devPlugins": [
|
|
72
|
+
"@oclif/plugin-help"
|
|
73
|
+
],
|
|
71
74
|
"repositoryPrefix": "<%- repo %>/blob/main/packages/contentstack-export/<%- commandPath %>"
|
|
72
75
|
},
|
|
73
76
|
"csdxConfig": {
|
|
@@ -81,4 +84,4 @@
|
|
|
81
84
|
},
|
|
82
85
|
"main": "./src/commands/cm/stacks/export.js",
|
|
83
86
|
"repository": "https://github.com/contentstack/cli"
|
|
84
|
-
}
|
|
87
|
+
}
|
package/src/app.js
CHANGED
|
@@ -52,15 +52,21 @@ exports.initial = async (config) => {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
if (config.management_token || config.isAuthenticated) {
|
|
56
|
+
try {
|
|
57
|
+
await fetchBranchAndExport(APIClient, stackAPIClient);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
addlogs(config, `${util.formatError(error)}`, 'error');
|
|
60
|
+
}
|
|
61
|
+
resolve();
|
|
62
|
+
} else if (
|
|
57
63
|
(config.email && config.password) ||
|
|
58
64
|
(!config.email && !config.password && config.source_stack && config.access_token) ||
|
|
59
65
|
(isAuthenticated() && !config.management_token)
|
|
60
66
|
) {
|
|
61
67
|
login
|
|
62
|
-
.login(config)
|
|
63
|
-
.then(async ()
|
|
68
|
+
.login(config, APIClient, stackAPIClient)
|
|
69
|
+
.then(async function () {
|
|
64
70
|
// setup branches
|
|
65
71
|
try {
|
|
66
72
|
await fetchBranchAndExport(APIClient, stackAPIClient);
|
|
@@ -79,13 +85,8 @@ exports.initial = async (config) => {
|
|
|
79
85
|
addlogs(config, `${util.formatError(error)}`, 'error');
|
|
80
86
|
}
|
|
81
87
|
});
|
|
82
|
-
} else
|
|
83
|
-
|
|
84
|
-
await fetchBranchAndExport(APIClient, stackAPIClient);
|
|
85
|
-
} catch (error) {
|
|
86
|
-
addlogs(config, util.formatError(error), 'error');
|
|
87
|
-
}
|
|
88
|
-
resolve();
|
|
88
|
+
} else {
|
|
89
|
+
reject('Kindly login or provide management_token');
|
|
89
90
|
}
|
|
90
91
|
});
|
|
91
92
|
};
|
|
@@ -148,7 +149,11 @@ const allExport = async (APIClient, stackAPIClient, config, types, branchName) =
|
|
|
148
149
|
addlogs(config, util.formatError(error), 'error');
|
|
149
150
|
addlogs(
|
|
150
151
|
config,
|
|
151
|
-
chalk.red(
|
|
152
|
+
chalk.red(
|
|
153
|
+
'Failed to migrate stack: ' +
|
|
154
|
+
(config.sourceStackName || config.source_stack) +
|
|
155
|
+
'. Please check error logs for more info',
|
|
156
|
+
),
|
|
152
157
|
'error',
|
|
153
158
|
);
|
|
154
159
|
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'error');
|
|
@@ -1,5 +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
4
|
const {
|
|
4
5
|
configWithMToken,
|
|
5
6
|
parameterWithMToken,
|
|
@@ -9,13 +10,12 @@ const {
|
|
|
9
10
|
withoutParametersWithAuthToken,
|
|
10
11
|
} = require('../../../lib/util/export-flags');
|
|
11
12
|
const config = require('../../../config/default');
|
|
12
|
-
const { configHandler, printFlagDeprecation, flags, isAuthenticated } = require('@contentstack/cli-utilities');
|
|
13
13
|
|
|
14
14
|
class ExportCommand extends Command {
|
|
15
15
|
async run() {
|
|
16
16
|
const { flags: exportCommandFlags } = await this.parse(ExportCommand);
|
|
17
17
|
const extConfig = exportCommandFlags.config;
|
|
18
|
-
|
|
18
|
+
const sourceStack = exportCommandFlags['stack-uid'] || exportCommandFlags['stack-api-key'];
|
|
19
19
|
const alias = exportCommandFlags['alias'] || exportCommandFlags['management-token-alias'];
|
|
20
20
|
const securedAssets = exportCommandFlags['secured-assets'];
|
|
21
21
|
const data = exportCommandFlags.data || exportCommandFlags['data-dir'];
|
|
@@ -27,16 +27,14 @@ class ExportCommand extends Command {
|
|
|
27
27
|
let cdaHost = host.cda.split('//');
|
|
28
28
|
host.cma = cmaHost[1];
|
|
29
29
|
host.cda = cdaHost[1];
|
|
30
|
+
exportCommandFlags['isAuthenticated'] = isAuthenticated();
|
|
30
31
|
|
|
31
32
|
config.forceStopMarketplaceAppsPrompt = exportCommandFlags.yes;
|
|
32
33
|
|
|
33
34
|
if (alias) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const listOfTokens = configHandler.get('tokens');
|
|
38
|
-
config.management_token_data = listOfTokens[alias];
|
|
39
|
-
}
|
|
35
|
+
const managementTokens = this.getToken(alias);
|
|
36
|
+
const listOfTokens = configHandler.get('tokens');
|
|
37
|
+
config.management_token_data = listOfTokens[alias];
|
|
40
38
|
|
|
41
39
|
if (managementTokens) {
|
|
42
40
|
if (extConfig) {
|
|
@@ -48,6 +46,8 @@ class ExportCommand extends Command {
|
|
|
48
46
|
branchName,
|
|
49
47
|
securedAssets,
|
|
50
48
|
moduleName,
|
|
49
|
+
data,
|
|
50
|
+
exportCommandFlags,
|
|
51
51
|
);
|
|
52
52
|
} else if (data) {
|
|
53
53
|
await parameterWithMToken(
|
|
@@ -58,6 +58,7 @@ class ExportCommand extends Command {
|
|
|
58
58
|
contentTypes,
|
|
59
59
|
branchName,
|
|
60
60
|
securedAssets,
|
|
61
|
+
exportCommandFlags,
|
|
61
62
|
);
|
|
62
63
|
} else if (data === undefined && sourceStack === undefined) {
|
|
63
64
|
await withoutParameterMToken(
|
|
@@ -67,6 +68,7 @@ class ExportCommand extends Command {
|
|
|
67
68
|
contentTypes,
|
|
68
69
|
branchName,
|
|
69
70
|
securedAssets,
|
|
71
|
+
exportCommandFlags,
|
|
70
72
|
);
|
|
71
73
|
} else {
|
|
72
74
|
this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage');
|
|
@@ -76,7 +78,15 @@ class ExportCommand extends Command {
|
|
|
76
78
|
}
|
|
77
79
|
} else if (isAuthenticated()) {
|
|
78
80
|
if (extConfig) {
|
|
79
|
-
await configWithAuthToken(
|
|
81
|
+
await configWithAuthToken(
|
|
82
|
+
extConfig,
|
|
83
|
+
moduleName,
|
|
84
|
+
host,
|
|
85
|
+
contentTypes,
|
|
86
|
+
branchName,
|
|
87
|
+
securedAssets,
|
|
88
|
+
exportCommandFlags,
|
|
89
|
+
);
|
|
80
90
|
} else if (sourceStack && data) {
|
|
81
91
|
return await parametersWithAuthToken(
|
|
82
92
|
sourceStack,
|
|
@@ -86,16 +96,23 @@ class ExportCommand extends Command {
|
|
|
86
96
|
contentTypes,
|
|
87
97
|
branchName,
|
|
88
98
|
securedAssets,
|
|
99
|
+
exportCommandFlags,
|
|
89
100
|
);
|
|
90
101
|
} else if (data === undefined && sourceStack === undefined) {
|
|
91
|
-
await withoutParametersWithAuthToken(
|
|
102
|
+
await withoutParametersWithAuthToken(
|
|
103
|
+
moduleName,
|
|
104
|
+
host,
|
|
105
|
+
contentTypes,
|
|
106
|
+
branchName,
|
|
107
|
+
securedAssets,
|
|
108
|
+
exportCommandFlags,
|
|
109
|
+
);
|
|
92
110
|
} else {
|
|
93
111
|
this.log('Please provide a valid command. Run "csdx cm:export --help" command to view the command usage');
|
|
94
112
|
}
|
|
95
113
|
} else {
|
|
96
114
|
this.log('Login or provide the alias for management token');
|
|
97
115
|
}
|
|
98
|
-
// return
|
|
99
116
|
}
|
|
100
117
|
}
|
|
101
118
|
|
package/src/lib/export/assets.js
CHANGED
|
@@ -53,11 +53,11 @@ module.exports = class ExportAssets {
|
|
|
53
53
|
// Create asset folder
|
|
54
54
|
mkdirp.sync(this.assetsFolderPath);
|
|
55
55
|
|
|
56
|
-
return new Promise(
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
57
|
// TBD: getting all the assets should have optimized
|
|
58
58
|
return self
|
|
59
59
|
.getAssetCount()
|
|
60
|
-
.then(
|
|
60
|
+
.then((count) => {
|
|
61
61
|
const assetBatches = [];
|
|
62
62
|
|
|
63
63
|
if (typeof count !== 'number' || count === 0) {
|
|
@@ -70,20 +70,20 @@ module.exports = class ExportAssets {
|
|
|
70
70
|
|
|
71
71
|
return Promise.map(
|
|
72
72
|
assetBatches,
|
|
73
|
-
|
|
73
|
+
(batch) => {
|
|
74
74
|
return self
|
|
75
75
|
.getAssetJSON(batch)
|
|
76
|
-
.then(
|
|
76
|
+
.then((assetsJSON) => {
|
|
77
77
|
return Promise.map(
|
|
78
78
|
assetsJSON,
|
|
79
|
-
|
|
79
|
+
(assetJSON) => {
|
|
80
80
|
if (self.assetConfig.downloadVersionAssets) {
|
|
81
81
|
return self
|
|
82
82
|
.getVersionedAssetJSON(assetJSON.uid, assetJSON._version)
|
|
83
|
-
.then(
|
|
83
|
+
.then(() => {
|
|
84
84
|
self.assetContents[assetJSON.uid] = assetJSON;
|
|
85
85
|
})
|
|
86
|
-
.catch(
|
|
86
|
+
.catch((error) => {
|
|
87
87
|
addlogs(
|
|
88
88
|
self.config,
|
|
89
89
|
chalk.red('The following asset failed to download\n' + JSON.stringify(assetJSON)),
|
|
@@ -93,7 +93,7 @@ module.exports = class ExportAssets {
|
|
|
93
93
|
} else {
|
|
94
94
|
return self
|
|
95
95
|
.downloadAsset(assetJSON)
|
|
96
|
-
.then(
|
|
96
|
+
.then(() => {
|
|
97
97
|
self.assetContents[assetJSON.uid] = assetJSON;
|
|
98
98
|
})
|
|
99
99
|
.catch((err) => {
|
|
@@ -108,38 +108,38 @@ module.exports = class ExportAssets {
|
|
|
108
108
|
},
|
|
109
109
|
{ concurrency: self.vLimit },
|
|
110
110
|
)
|
|
111
|
-
.then(
|
|
111
|
+
.then(() => {
|
|
112
112
|
addlogs(self.config, 'Batch no ' + (batch + 1) + ' of assets is complete', 'success');
|
|
113
113
|
// helper.writeFileSync(this.assetContentsFile, self.assetContents)
|
|
114
114
|
})
|
|
115
|
-
.catch(
|
|
115
|
+
.catch((error) => {
|
|
116
116
|
console.log('Error fetch/download the asset', error && error.message);
|
|
117
117
|
addlogs(self.config, 'Asset batch ' + (batch + 1) + ' failed to download', 'error');
|
|
118
118
|
addlogs(self.config, error, 'error');
|
|
119
119
|
});
|
|
120
120
|
})
|
|
121
|
-
.catch(
|
|
121
|
+
.catch((error) => {
|
|
122
122
|
addlogs(self.config, error, 'error');
|
|
123
123
|
reject(error);
|
|
124
124
|
});
|
|
125
125
|
},
|
|
126
126
|
{ concurrency: self.assetConfig.concurrencyLimit || 1 },
|
|
127
127
|
)
|
|
128
|
-
.then(
|
|
128
|
+
.then(() => {
|
|
129
129
|
helper.writeFileSync(self.assetContentsFile, self.assetContents);
|
|
130
130
|
|
|
131
131
|
return self
|
|
132
132
|
.exportFolders()
|
|
133
|
-
.then(
|
|
133
|
+
.then(() => {
|
|
134
134
|
addlogs(self.config, chalk.green('Asset export completed successfully'), 'success');
|
|
135
135
|
return resolve();
|
|
136
136
|
})
|
|
137
|
-
.catch(
|
|
137
|
+
.catch((error) => {
|
|
138
138
|
addlogs(self.config, error, 'success');
|
|
139
139
|
reject(error);
|
|
140
140
|
});
|
|
141
141
|
})
|
|
142
|
-
.catch(
|
|
142
|
+
.catch((error) => {
|
|
143
143
|
helper.writeFileSync(self.assetContentsFile, self.assetContents);
|
|
144
144
|
addlogs(
|
|
145
145
|
self.config,
|
|
@@ -149,7 +149,7 @@ module.exports = class ExportAssets {
|
|
|
149
149
|
reject(error);
|
|
150
150
|
});
|
|
151
151
|
})
|
|
152
|
-
.catch(
|
|
152
|
+
.catch((error) => {
|
|
153
153
|
addlogs(self.config, error, 'success');
|
|
154
154
|
reject(error);
|
|
155
155
|
});
|
|
@@ -158,10 +158,10 @@ module.exports = class ExportAssets {
|
|
|
158
158
|
|
|
159
159
|
exportFolders() {
|
|
160
160
|
const self = this;
|
|
161
|
-
return new Promise(
|
|
161
|
+
return new Promise((resolve, reject) => {
|
|
162
162
|
return self
|
|
163
163
|
.getAssetCount(true)
|
|
164
|
-
.then(
|
|
164
|
+
.then((fCount) => {
|
|
165
165
|
if (fCount === 0) {
|
|
166
166
|
addlogs(self.config, 'No folders were found in the stack!', 'success');
|
|
167
167
|
return resolve();
|
|
@@ -169,17 +169,17 @@ module.exports = class ExportAssets {
|
|
|
169
169
|
|
|
170
170
|
return self
|
|
171
171
|
.getFolderJSON(0, fCount)
|
|
172
|
-
.then(
|
|
172
|
+
.then(() => {
|
|
173
173
|
// asset folders have been successfully exported
|
|
174
174
|
addlogs(self.config, 'Asset-folders have been successfully exported!', 'success');
|
|
175
175
|
return resolve();
|
|
176
176
|
})
|
|
177
|
-
.catch(
|
|
177
|
+
.catch((error) => {
|
|
178
178
|
addlogs(self.config, chalk.red('Error while exporting asset-folders!'), 'error');
|
|
179
179
|
return reject(error);
|
|
180
180
|
});
|
|
181
181
|
})
|
|
182
|
-
.catch(
|
|
182
|
+
.catch((error) => {
|
|
183
183
|
addlogs(self.config, error, 'error');
|
|
184
184
|
// error while fetching asset folder count
|
|
185
185
|
return reject(error);
|
|
@@ -189,7 +189,7 @@ module.exports = class ExportAssets {
|
|
|
189
189
|
|
|
190
190
|
getFolderJSON(skip, fCount) {
|
|
191
191
|
const self = this;
|
|
192
|
-
return new Promise(
|
|
192
|
+
return new Promise((resolve, reject) => {
|
|
193
193
|
if (typeof skip !== 'number') {
|
|
194
194
|
skip = 0;
|
|
195
195
|
}
|
|
@@ -213,13 +213,14 @@ module.exports = class ExportAssets {
|
|
|
213
213
|
skip += 100;
|
|
214
214
|
self.folderData.push(...response.items);
|
|
215
215
|
return self.getFolderJSON(skip, fCount).then(resolve).catch(reject);
|
|
216
|
-
})
|
|
216
|
+
})
|
|
217
|
+
.catch((error) => reject(error));
|
|
217
218
|
});
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
getAssetCount(folder) {
|
|
221
222
|
const self = this;
|
|
222
|
-
return new Promise(
|
|
223
|
+
return new Promise((resolve, reject) => {
|
|
223
224
|
if (folder && typeof folder === 'boolean') {
|
|
224
225
|
const queryOptions = {
|
|
225
226
|
skip: 99999990,
|
|
@@ -254,7 +255,7 @@ module.exports = class ExportAssets {
|
|
|
254
255
|
|
|
255
256
|
getAssetJSON(skip) {
|
|
256
257
|
const self = this;
|
|
257
|
-
return new Promise(
|
|
258
|
+
return new Promise((resolve, reject) => {
|
|
258
259
|
if (typeof skip !== 'number') {
|
|
259
260
|
skip = 0;
|
|
260
261
|
}
|
|
@@ -283,7 +284,7 @@ module.exports = class ExportAssets {
|
|
|
283
284
|
const self = this;
|
|
284
285
|
const assetVersionInfo = bucket || [];
|
|
285
286
|
|
|
286
|
-
return new Promise(
|
|
287
|
+
return new Promise((resolve, reject) => {
|
|
287
288
|
if (self.assetDownloadRetry[uid + version] > self.assetDownloadRetryLimit) {
|
|
288
289
|
console.log('Reached max', self.assetDownloadRetry[uid + version]);
|
|
289
290
|
return reject(new Error('Asset Max download retry limit exceeded! ' + uid));
|
|
@@ -308,7 +309,7 @@ module.exports = class ExportAssets {
|
|
|
308
309
|
.then((versionedAssetJSONResponse) => {
|
|
309
310
|
self
|
|
310
311
|
.downloadAsset(versionedAssetJSONResponse)
|
|
311
|
-
.then(
|
|
312
|
+
.then(() => {
|
|
312
313
|
assetVersionInfo.splice(0, 0, versionedAssetJSONResponse);
|
|
313
314
|
// Remove duplicates
|
|
314
315
|
assetVersionInfo = _.uniqWith(assetVersionInfo, _.isEqual);
|
|
@@ -328,7 +329,6 @@ module.exports = class ExportAssets {
|
|
|
328
329
|
: (self.assetDownloadRetry[uid + version] = 1);
|
|
329
330
|
return self.getVersionedAssetJSON(uid, version, assetVersionInfo).then(resolve).catch(reject);
|
|
330
331
|
}
|
|
331
|
-
|
|
332
332
|
reject(error);
|
|
333
333
|
});
|
|
334
334
|
});
|
|
@@ -336,7 +336,7 @@ module.exports = class ExportAssets {
|
|
|
336
336
|
|
|
337
337
|
downloadAsset(asset) {
|
|
338
338
|
const self = this;
|
|
339
|
-
return new Promise(async
|
|
339
|
+
return new Promise(async (resolve, reject) => {
|
|
340
340
|
const assetFolderPath = path.resolve(self.assetsFolderPath, asset.uid);
|
|
341
341
|
const assetFilePath = path.resolve(assetFolderPath, asset.filename);
|
|
342
342
|
|
|
@@ -366,7 +366,7 @@ module.exports = class ExportAssets {
|
|
|
366
366
|
time: 5000,
|
|
367
367
|
length: assetStreamRequest.headers['content-length'],
|
|
368
368
|
});
|
|
369
|
-
str.on('progress',
|
|
369
|
+
str.on('progress', (progressData) => {
|
|
370
370
|
console.log(`${asset.filename}: ${Math.round(progressData.percentage)}%`);
|
|
371
371
|
});
|
|
372
372
|
assetStreamRequest.pipe(str).pipe(assetFileStream);
|
|
@@ -378,7 +378,7 @@ module.exports = class ExportAssets {
|
|
|
378
378
|
reject(error);
|
|
379
379
|
});
|
|
380
380
|
assetFileStream
|
|
381
|
-
.on('close',
|
|
381
|
+
.on('close', () => {
|
|
382
382
|
addlogs(self.config, 'Downloaded ' + asset.filename + ': ' + asset.uid + ' successfully!', 'success');
|
|
383
383
|
return resolve();
|
|
384
384
|
})
|
|
@@ -391,26 +391,26 @@ module.exports = class ExportAssets {
|
|
|
391
391
|
|
|
392
392
|
getFolders() {
|
|
393
393
|
const self = this;
|
|
394
|
-
return new Promise(
|
|
394
|
+
return new Promise((resolve, reject) => {
|
|
395
395
|
return self
|
|
396
396
|
.getAssetCount(true)
|
|
397
|
-
.then(
|
|
397
|
+
.then((count) => {
|
|
398
398
|
if (count === 0) {
|
|
399
399
|
addlogs(self.config, 'No folders were found in the stack', 'success');
|
|
400
400
|
return resolve();
|
|
401
401
|
}
|
|
402
402
|
return self
|
|
403
403
|
.getFolderDetails(0, count)
|
|
404
|
-
.then(
|
|
404
|
+
.then(() => {
|
|
405
405
|
addlogs(self.config, chalk.green('Exported asset-folders successfully!'), 'success');
|
|
406
406
|
return resolve();
|
|
407
407
|
})
|
|
408
|
-
.catch(
|
|
408
|
+
.catch((error) => {
|
|
409
409
|
addlogs(self.config, error, 'error');
|
|
410
410
|
reject(error);
|
|
411
411
|
});
|
|
412
412
|
})
|
|
413
|
-
.catch(
|
|
413
|
+
.catch((error) => {
|
|
414
414
|
addlogs(self.config, error, 'error');
|
|
415
415
|
reject(error);
|
|
416
416
|
});
|
|
@@ -419,7 +419,7 @@ module.exports = class ExportAssets {
|
|
|
419
419
|
|
|
420
420
|
getFolderDetails(skip, tCount) {
|
|
421
421
|
const self = this;
|
|
422
|
-
return new Promise(
|
|
422
|
+
return new Promise((resolve, reject) => {
|
|
423
423
|
if (typeof skip !== 'number') {
|
|
424
424
|
skip = 0;
|
|
425
425
|
}
|
|
@@ -77,7 +77,10 @@ class ContentTypesExport {
|
|
|
77
77
|
|
|
78
78
|
async writeContentTypes(contentTypes) {
|
|
79
79
|
function write(contentType) {
|
|
80
|
-
return fileHelper.writeFile(
|
|
80
|
+
return fileHelper.writeFile(
|
|
81
|
+
path.join(this.contentTypesPath,
|
|
82
|
+
`${contentType.uid === 'schema' ? 'schema|1' : contentType.uid}.json`),
|
|
83
|
+
contentType);
|
|
81
84
|
}
|
|
82
85
|
await executeTask(contentTypes, write.bind(this), { concurrency: this.writeConcurrency });
|
|
83
86
|
return fileHelper.writeFile(path.join(this.contentTypesPath, 'schema.json'), contentTypes);
|
|
@@ -4,7 +4,6 @@ const path = require('path');
|
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const mkdirp = require('mkdirp');
|
|
6
6
|
const { merge } = require('lodash');
|
|
7
|
-
|
|
8
7
|
const helper = require('../util/helper');
|
|
9
8
|
const { addlogs } = require('../util/log');
|
|
10
9
|
const { formatError } = require('../util');
|
|
@@ -21,31 +20,27 @@ module.exports = class ExportCustomRoles {
|
|
|
21
20
|
rolesConfig = config.modules.customRoles;
|
|
22
21
|
|
|
23
22
|
constructor(exportConfig, stackAPIClient) {
|
|
24
|
-
this.stackAPIClient = stackAPIClient;
|
|
25
23
|
this.config = merge(config, exportConfig);
|
|
24
|
+
this.stackAPIClient = stackAPIClient;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
async start() {
|
|
29
28
|
const self = this;
|
|
29
|
+
|
|
30
30
|
try {
|
|
31
31
|
addlogs(this.config, 'Starting roles export', 'success');
|
|
32
|
-
|
|
33
32
|
const rolesFolderPath = path.resolve(this.config.data, this.config.branchName || '', this.rolesConfig.dirName);
|
|
34
33
|
mkdirp.sync(rolesFolderPath);
|
|
35
|
-
|
|
36
|
-
const roles = await this.stackAPIClient.role().fetchAll({ include_rules: true, include_permissions: true });
|
|
37
|
-
|
|
34
|
+
const roles = await self.stackAPIClient.role().fetchAll({ include_rules: true, include_permissions: true });
|
|
38
35
|
const customRoles = roles.items.filter((role) => !self.EXISTING_ROLES[role.name]);
|
|
39
|
-
|
|
40
36
|
if (!customRoles.length) {
|
|
41
37
|
addlogs(self.config, 'No custom roles were found in the Stack', 'success');
|
|
42
38
|
return;
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
await self.getCustomRolesLocales(
|
|
46
41
|
customRoles,
|
|
47
42
|
path.join(rolesFolderPath, self.rolesConfig.customRolesLocalesFileName),
|
|
48
|
-
|
|
43
|
+
self.stackAPIClient,
|
|
49
44
|
self.config,
|
|
50
45
|
);
|
|
51
46
|
self.customRoles = {};
|
|
@@ -80,7 +75,6 @@ module.exports = class ExportCustomRoles {
|
|
|
80
75
|
});
|
|
81
76
|
}
|
|
82
77
|
}
|
|
83
|
-
|
|
84
78
|
if (Object.keys(localesMap).length) {
|
|
85
79
|
const locales = await stackAPIClient.locale().query({}).find();
|
|
86
80
|
const sourceLocalesMap = {};
|
|
@@ -25,8 +25,8 @@ module.exports = class ExportEnvironments {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
constructor(exportConfig, stackAPIClient) {
|
|
28
|
-
this.stackAPIClient = stackAPIClient;
|
|
29
28
|
this.config = merge(this.config, exportConfig);
|
|
29
|
+
this.stackAPIClient = stackAPIClient;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
start() {
|
|
@@ -42,7 +42,7 @@ module.exports = class ExportEnvironments {
|
|
|
42
42
|
mkdirp.sync(environmentsFolderPath);
|
|
43
43
|
addlogs(self.config, 'Starting environment export', 'success');
|
|
44
44
|
|
|
45
|
-
return new Promise(
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
46
|
self.stackAPIClient
|
|
47
47
|
.environment()
|
|
48
48
|
.query(self.requestOptions.qs)
|
|
@@ -34,8 +34,8 @@ module.exports = class ExportGlobalFields {
|
|
|
34
34
|
include_count: true,
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
|
-
this.stackAPIClient = stackAPIClient;
|
|
38
37
|
this.config = merge(config, exportConfig);
|
|
38
|
+
this.stackAPIClient = stackAPIClient;
|
|
39
39
|
this.globalfieldsFolderPath = path.resolve(
|
|
40
40
|
this.config.data,
|
|
41
41
|
this.config.branchName || '',
|
|
@@ -89,22 +89,17 @@ module.exports = class ExportGlobalFields {
|
|
|
89
89
|
}
|
|
90
90
|
self.global_fields.push(globalField);
|
|
91
91
|
});
|
|
92
|
-
|
|
93
92
|
skip += self.limit;
|
|
94
|
-
|
|
95
|
-
if (skip > globalFieldResponse.count) {
|
|
93
|
+
if (skip >= globalFieldResponse.count) {
|
|
96
94
|
return resolve();
|
|
97
95
|
}
|
|
98
|
-
|
|
99
96
|
return self.getGlobalFields(skip, globalFieldConfig).then(resolve).catch(reject);
|
|
100
97
|
} catch (error) {
|
|
101
98
|
addlogs(globalFieldConfig, chalk.red(`Failed to export global-fields ${formatError(error)}`), 'error');
|
|
102
99
|
reject(error);
|
|
103
100
|
}
|
|
104
101
|
})
|
|
105
|
-
.catch(
|
|
106
|
-
reject(error);
|
|
107
|
-
});
|
|
102
|
+
.catch(reject);
|
|
108
103
|
});
|
|
109
104
|
}
|
|
110
105
|
|
|
@@ -117,7 +112,6 @@ module.exports = class ExportGlobalFields {
|
|
|
117
112
|
self.global_fields,
|
|
118
113
|
);
|
|
119
114
|
addlogs(self.config, chalk.green('Global Fields export completed successfully'), 'success');
|
|
120
|
-
|
|
121
115
|
resolve();
|
|
122
116
|
} catch (error) {
|
|
123
117
|
addlogs(self.config, error, 'error');
|
package/src/lib/export/labels.js
CHANGED
|
@@ -19,8 +19,8 @@ module.exports = class ExportLabels {
|
|
|
19
19
|
labelConfig = config.modules.labels;
|
|
20
20
|
|
|
21
21
|
constructor(exportConfig, stackAPIClient) {
|
|
22
|
-
this.stackAPIClient = stackAPIClient;
|
|
23
22
|
this.config = merge(config, exportConfig);
|
|
23
|
+
this.stackAPIClient = stackAPIClient;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
start() {
|
|
@@ -2,6 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const chalk = require('chalk');
|
|
3
3
|
const fileHelper = require('../util/helper');
|
|
4
4
|
const { addlogs } = require('../util/log');
|
|
5
|
+
const { formatError } = require('../util');
|
|
5
6
|
class LocaleExport {
|
|
6
7
|
constructor(exportConfig, stackAPIClient) {
|
|
7
8
|
this.stackAPIClient = stackAPIClient;
|
|
@@ -7,13 +7,14 @@ const _ = require('lodash');
|
|
|
7
7
|
const path = require('path');
|
|
8
8
|
const chalk = require('chalk');
|
|
9
9
|
const mkdirp = require('mkdirp');
|
|
10
|
-
const {
|
|
11
|
-
cliux,
|
|
12
|
-
HttpClient,
|
|
13
|
-
NodeCrypto,
|
|
14
|
-
managementSDKClient,
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const {
|
|
11
|
+
cliux,
|
|
12
|
+
HttpClient,
|
|
13
|
+
NodeCrypto,
|
|
14
|
+
managementSDKClient,
|
|
15
|
+
HttpClientDecorator,
|
|
16
|
+
OauthDecorator,
|
|
17
|
+
isAuthenticated,
|
|
17
18
|
} = require('@contentstack/cli-utilities');
|
|
18
19
|
|
|
19
20
|
const { formatError } = require('../util');
|
|
@@ -48,10 +49,15 @@ module.exports = class ExportMarketplaceApps {
|
|
|
48
49
|
|
|
49
50
|
await this.getOrgUid();
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const httpClient = new HttpClient();
|
|
53
|
+
if (!this.config.auth_token) {
|
|
54
|
+
this.httpClient = new OauthDecorator(httpClient);
|
|
55
|
+
const headers = await this.httpClient.preHeadersCheck(this.config);
|
|
56
|
+
this.httpClient = this.httpClient.headers(headers);
|
|
57
|
+
} else {
|
|
58
|
+
this.httpClient = new HttpClientDecorator(httpClient);
|
|
59
|
+
this.httpClient.headers(this.config);
|
|
60
|
+
}
|
|
55
61
|
|
|
56
62
|
log(this.config, 'Starting marketplace app export', 'success');
|
|
57
63
|
this.marketplaceAppPath = path.resolve(
|
|
@@ -65,18 +71,16 @@ module.exports = class ExportMarketplaceApps {
|
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
async getOrgUid() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.config.org_uid = tempStackData.org_uid;
|
|
79
|
-
}
|
|
74
|
+
const tempAPIClient = await managementSDKClient({ host: this.config.host });
|
|
75
|
+
const tempStackData = await tempAPIClient
|
|
76
|
+
.stack({ api_key: this.config.source_stack })
|
|
77
|
+
.fetch()
|
|
78
|
+
.catch((error) => {
|
|
79
|
+
console.log(error);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
if (tempStackData && tempStackData.org_uid) {
|
|
83
|
+
this.config.org_uid = tempStackData.org_uid;
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
|
|
@@ -145,7 +149,7 @@ module.exports = class ExportMarketplaceApps {
|
|
|
145
149
|
return listOfApps;
|
|
146
150
|
})
|
|
147
151
|
.catch((error) => {
|
|
148
|
-
log(
|
|
152
|
+
log(this.config, `Failed to export marketplace-apps ${formatError(error)}`, 'error');
|
|
149
153
|
});
|
|
150
154
|
}
|
|
151
155
|
|
|
@@ -14,6 +14,7 @@ const { formatError } = require('../util');
|
|
|
14
14
|
const { addlogs } = require('../util/log');
|
|
15
15
|
const config = require('../../config/default');
|
|
16
16
|
|
|
17
|
+
// Create folder for environments
|
|
17
18
|
module.exports = class ExportWebhooks {
|
|
18
19
|
config;
|
|
19
20
|
master = {};
|
|
@@ -25,8 +26,8 @@ module.exports = class ExportWebhooks {
|
|
|
25
26
|
webhooksConfig = config.modules.webhooks;
|
|
26
27
|
|
|
27
28
|
constructor(exportConfig, stackAPIClient) {
|
|
28
|
-
this.stackAPIClient = stackAPIClient;
|
|
29
29
|
this.config = merge(config, exportConfig);
|
|
30
|
+
this.stackAPIClient = stackAPIClient;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
start() {
|
|
@@ -20,8 +20,8 @@ module.exports = class ExportWorkFlows {
|
|
|
20
20
|
workFlowConfig = config.modules.workflows;
|
|
21
21
|
|
|
22
22
|
constructor(exportConfig, stackAPIClient) {
|
|
23
|
-
this.stackAPIClient = stackAPIClient;
|
|
24
23
|
this.config = merge(config, exportConfig);
|
|
24
|
+
this.stackAPIClient = stackAPIClient;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
start() {
|
|
@@ -33,7 +33,6 @@ module.exports = class ExportWorkFlows {
|
|
|
33
33
|
this.config.branchName || '',
|
|
34
34
|
this.workFlowConfig.dirName,
|
|
35
35
|
);
|
|
36
|
-
|
|
37
36
|
mkdirp.sync(workflowsFolderPath);
|
|
38
37
|
|
|
39
38
|
return new Promise(function (resolve, reject) {
|
|
@@ -103,6 +102,8 @@ module.exports = class ExportWorkFlows {
|
|
|
103
102
|
deleteItems.forEach((e) => delete workflow[e]);
|
|
104
103
|
}
|
|
105
104
|
} catch (error) {
|
|
105
|
+
console.log('Error getting workflow data', error && error.message);
|
|
106
|
+
addlogs(self.config, 'Error fetching workflow data in export workflows task.', 'error');
|
|
106
107
|
throw error;
|
|
107
108
|
}
|
|
108
109
|
}
|
|
@@ -11,14 +11,27 @@ const helper = require('../util/helper');
|
|
|
11
11
|
let _ = require('lodash');
|
|
12
12
|
const { cliux } = require('@contentstack/cli-utilities');
|
|
13
13
|
|
|
14
|
-
exports.configWithMToken = async
|
|
14
|
+
exports.configWithMToken = async (
|
|
15
|
+
config,
|
|
16
|
+
managementTokens,
|
|
17
|
+
host,
|
|
18
|
+
contentTypes,
|
|
19
|
+
branchName,
|
|
20
|
+
securedAssets,
|
|
21
|
+
moduleName,
|
|
22
|
+
data,
|
|
23
|
+
exportCommandFlags,
|
|
24
|
+
) => {
|
|
15
25
|
let externalConfig = require(config);
|
|
26
|
+
const modules = externalConfig.filteredModules;
|
|
27
|
+
|
|
16
28
|
defaultConfig.securedAssets = securedAssets;
|
|
17
29
|
defaultConfig.management_token = managementTokens.token;
|
|
18
30
|
defaultConfig.host = host.cma;
|
|
19
31
|
defaultConfig.cdn = host.cda;
|
|
20
32
|
defaultConfig.branchName = branchName;
|
|
21
33
|
defaultConfig.source_stack = managementTokens.apiKey;
|
|
34
|
+
defaultConfig.isAuthenticated = exportCommandFlags.isAuthenticated;
|
|
22
35
|
if (moduleName) {
|
|
23
36
|
defaultConfig.moduleName = moduleName;
|
|
24
37
|
// Specfic content type setting is only for entries module
|
|
@@ -27,10 +40,19 @@ exports.configWithMToken = async function (config, managementTokens, host, conte
|
|
|
27
40
|
}
|
|
28
41
|
}
|
|
29
42
|
defaultConfig = _.merge(defaultConfig, externalConfig);
|
|
43
|
+
|
|
44
|
+
if(!defaultConfig.data) {
|
|
45
|
+
defaultConfig.data = data
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (_.isArray(modules)) {
|
|
49
|
+
defaultConfig.modules.types = _.filter(defaultConfig.modules.types, (module) => _.includes(modules, module));
|
|
50
|
+
}
|
|
51
|
+
|
|
30
52
|
await initial(defaultConfig);
|
|
31
53
|
};
|
|
32
54
|
|
|
33
|
-
exports.parameterWithMToken = async
|
|
55
|
+
exports.parameterWithMToken = async (
|
|
34
56
|
managementTokens,
|
|
35
57
|
data,
|
|
36
58
|
moduleName,
|
|
@@ -38,12 +60,14 @@ exports.parameterWithMToken = async function (
|
|
|
38
60
|
contentTypes,
|
|
39
61
|
branchName,
|
|
40
62
|
securedAssets,
|
|
41
|
-
|
|
63
|
+
exportCommandFlags,
|
|
64
|
+
) => {
|
|
42
65
|
defaultConfig.management_token = managementTokens.token;
|
|
43
66
|
defaultConfig.host = host.cma;
|
|
44
67
|
defaultConfig.cdn = host.cda;
|
|
45
68
|
defaultConfig.branchName = branchName;
|
|
46
69
|
defaultConfig.securedAssets = securedAssets;
|
|
70
|
+
defaultConfig.isAuthenticated = exportCommandFlags.isAuthenticated;
|
|
47
71
|
if (!moduleName) {
|
|
48
72
|
defaultConfig.contentTypes = contentTypes;
|
|
49
73
|
} else {
|
|
@@ -66,6 +90,7 @@ exports.withoutParameterMToken = async (
|
|
|
66
90
|
contentTypes,
|
|
67
91
|
branchName,
|
|
68
92
|
securedAssets,
|
|
93
|
+
exportCommandFlags,
|
|
69
94
|
) => {
|
|
70
95
|
const stackUid = managementTokens.apiKey;
|
|
71
96
|
const pathOfExport = await cliux.prompt(message.promptMessageList.promptPathStoredData);
|
|
@@ -74,6 +99,7 @@ exports.withoutParameterMToken = async (
|
|
|
74
99
|
defaultConfig.cdn = host.cda;
|
|
75
100
|
defaultConfig.branchName = branchName;
|
|
76
101
|
defaultConfig.securedAssets = securedAssets;
|
|
102
|
+
defaultConfig.isAuthenticated = exportCommandFlags.isAuthenticated;
|
|
77
103
|
if (moduleName) {
|
|
78
104
|
defaultConfig.moduleName = moduleName;
|
|
79
105
|
// Specfic content type setting is only for entries module
|
|
@@ -86,12 +112,21 @@ exports.withoutParameterMToken = async (
|
|
|
86
112
|
await initial(defaultConfig);
|
|
87
113
|
};
|
|
88
114
|
|
|
89
|
-
exports.configWithAuthToken = async function (
|
|
90
|
-
|
|
115
|
+
exports.configWithAuthToken = async function (
|
|
116
|
+
config,
|
|
117
|
+
moduleName,
|
|
118
|
+
host,
|
|
119
|
+
contentTypes,
|
|
120
|
+
branchName,
|
|
121
|
+
securedAssets,
|
|
122
|
+
exportCommandFlags,
|
|
123
|
+
) {
|
|
124
|
+
let externalConfig = helper.readFileSync(path.resolve(config));
|
|
91
125
|
defaultConfig.host = host.cma;
|
|
92
126
|
defaultConfig.cdn = host.cda;
|
|
93
127
|
defaultConfig.branchName = branchName;
|
|
94
128
|
defaultConfig.securedAssets = securedAssets;
|
|
129
|
+
defaultConfig.isAuthenticated = exportCommandFlags.isAuthenticated;
|
|
95
130
|
if (moduleName) {
|
|
96
131
|
defaultConfig.moduleName = moduleName;
|
|
97
132
|
// Specfic content type setting is only for entries module
|
|
@@ -103,7 +138,7 @@ exports.configWithAuthToken = async function (config, moduleName, host, contentT
|
|
|
103
138
|
await initial(defaultConfig);
|
|
104
139
|
};
|
|
105
140
|
|
|
106
|
-
exports.parametersWithAuthToken =
|
|
141
|
+
exports.parametersWithAuthToken = async (
|
|
107
142
|
sourceStack,
|
|
108
143
|
data,
|
|
109
144
|
moduleName,
|
|
@@ -111,29 +146,23 @@ exports.parametersWithAuthToken = function (
|
|
|
111
146
|
contentTypes,
|
|
112
147
|
branchName,
|
|
113
148
|
securedAssets,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
149
|
+
exportCommandFlags,
|
|
150
|
+
) => {
|
|
151
|
+
defaultConfig.source_stack = sourceStack;
|
|
152
|
+
defaultConfig.isAuthenticated = exportCommandFlags.isAuthenticated;
|
|
153
|
+
if (moduleName) {
|
|
154
|
+
defaultConfig.moduleName = moduleName;
|
|
155
|
+
// Specfic content type setting is only for entries module
|
|
156
|
+
if (moduleName === 'entries' && Array.isArray(contentTypes) && contentTypes.length > 0) {
|
|
157
|
+
defaultConfig.contentTypes = contentTypes;
|
|
123
158
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return resolve();
|
|
132
|
-
})
|
|
133
|
-
.catch((error) => {
|
|
134
|
-
return reject(error);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
159
|
+
}
|
|
160
|
+
defaultConfig.branchName = branchName;
|
|
161
|
+
defaultConfig.host = host.cma;
|
|
162
|
+
defaultConfig.cdn = host.cda;
|
|
163
|
+
defaultConfig.data = data;
|
|
164
|
+
defaultConfig.securedAssets = securedAssets;
|
|
165
|
+
await initial(defaultConfig);
|
|
137
166
|
};
|
|
138
167
|
|
|
139
168
|
exports.withoutParametersWithAuthToken = async (
|
|
@@ -142,11 +171,13 @@ exports.withoutParametersWithAuthToken = async (
|
|
|
142
171
|
contentTypes,
|
|
143
172
|
branchName,
|
|
144
173
|
securedAssets,
|
|
174
|
+
exportCommandFlags,
|
|
145
175
|
) => {
|
|
146
176
|
const stackUid = await cliux.prompt(message.promptMessageList.promptSourceStack);
|
|
147
177
|
const pathOfExport = await cliux.prompt(message.promptMessageList.promptPathStoredData);
|
|
148
178
|
defaultConfig.source_stack = stackUid;
|
|
149
179
|
defaultConfig.securedAssets = securedAssets;
|
|
180
|
+
defaultConfig.isAuthenticated = exportCommandFlags.isAuthenticated;
|
|
150
181
|
if (moduleName) {
|
|
151
182
|
defaultConfig.moduleName = moduleName;
|
|
152
183
|
// Specfic content type setting is only for entries module
|
package/src/lib/util/index.js
CHANGED
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const chalk = require('chalk');
|
|
7
|
+
const _ = require('lodash');
|
|
8
|
+
const defaultConfig = require('../../config/default');
|
|
10
9
|
const promiseLimit = require('promise-limit');
|
|
11
|
-
const { isAuthenticated } = require('@contentstack/cli-utilities')
|
|
10
|
+
const { isAuthenticated } = require('@contentstack/cli-utilities');
|
|
12
11
|
|
|
13
|
-
exports.validateConfig =
|
|
12
|
+
exports.validateConfig = (config) => {
|
|
14
13
|
if (!config.host || !config.cdn) {
|
|
15
14
|
throw new Error('Host/CDN end point is missing from config');
|
|
16
15
|
}
|
|
@@ -7,7 +7,9 @@ const setupBranches = async (config, branch, stackAPIClient) => {
|
|
|
7
7
|
if (typeof config !== 'object') {
|
|
8
8
|
throw new Error('Invalid config to setup the branch');
|
|
9
9
|
}
|
|
10
|
+
|
|
10
11
|
let branches = [];
|
|
12
|
+
|
|
11
13
|
const headers = { api_key: config.source_stack };
|
|
12
14
|
|
|
13
15
|
if (isAuthenticated()) {
|