@contentstack/cli-cm-export 1.0.0 → 1.2.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/README.md +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +14 -5
- package/src/app.js +64 -51
- package/src/commands/cm/stacks/export.js +10 -3
- package/src/config/default.js +21 -1
- package/src/lib/export/assets.js +254 -228
- package/src/lib/export/content-types.js +72 -101
- package/src/lib/export/custom-roles.js +106 -0
- package/src/lib/export/entries.js +168 -225
- package/src/lib/export/environments.js +57 -52
- package/src/lib/export/extensions.js +50 -46
- package/src/lib/export/global-fields.js +64 -61
- package/src/lib/export/labels.js +57 -57
- package/src/lib/export/locales.js +57 -91
- package/src/lib/export/marketplace-apps.js +153 -0
- package/src/lib/export/stack.js +35 -22
- package/src/lib/export/webhooks.js +59 -54
- package/src/lib/export/workflows.js +94 -55
- package/src/lib/util/export-flags.js +7 -8
- package/src/lib/util/helper.js +83 -2
- package/src/lib/util/index.js +36 -1
- package/src/lib/util/log.js +6 -3
- package/src/lib/util/marketplace-app-helper.js +61 -0
- package/src/lib/util/setup-branches.js +5 -7
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
let config = require('../../config/default');
|
|
2
|
+
const sdk = require('./contentstack-management-sdk');
|
|
3
|
+
const { cliux, HttpClient, configHandler } = require('@contentstack/cli-utilities');
|
|
4
|
+
|
|
5
|
+
const getInstalledExtensions = (config) => {
|
|
6
|
+
const client = sdk.Client(config)
|
|
7
|
+
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const queryRequestOptions = {
|
|
10
|
+
include_marketplace_extensions: true
|
|
11
|
+
}
|
|
12
|
+
const {
|
|
13
|
+
management_token_data: { apiKey: api_key, token: management_token } = { apiKey: config.source_stack },
|
|
14
|
+
auth_token
|
|
15
|
+
} = config || { management_token_data: {} }
|
|
16
|
+
|
|
17
|
+
if (api_key && management_token) {
|
|
18
|
+
client
|
|
19
|
+
.stack({ api_key, management_token })
|
|
20
|
+
.extension()
|
|
21
|
+
.query(queryRequestOptions)
|
|
22
|
+
.find()
|
|
23
|
+
.then(({ items }) => resolve(items))
|
|
24
|
+
.catch(reject)
|
|
25
|
+
} else if (api_key && auth_token) {
|
|
26
|
+
const { cma } = configHandler.get('region') || {};
|
|
27
|
+
const headers = {
|
|
28
|
+
api_key,
|
|
29
|
+
authtoken: auth_token
|
|
30
|
+
}
|
|
31
|
+
const httpClient = new HttpClient().headers(headers);
|
|
32
|
+
httpClient.get(`${cma}/v3/extensions/?include_marketplace_extensions=true`)
|
|
33
|
+
.then(({ data: { extensions } }) => resolve(extensions))
|
|
34
|
+
.catch(reject)
|
|
35
|
+
} else {
|
|
36
|
+
resolve([])
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const getDeveloperHubUrl = async () => {
|
|
42
|
+
const { cma, name } = configHandler.get('region') || {};
|
|
43
|
+
let developerHubBaseUrl = config.developerHubUrls[cma];
|
|
44
|
+
|
|
45
|
+
if (!developerHubBaseUrl) {
|
|
46
|
+
developerHubBaseUrl = await cliux.inquire({
|
|
47
|
+
type: 'input',
|
|
48
|
+
name: 'name',
|
|
49
|
+
validate: (url) => {
|
|
50
|
+
if (!url) return "Developer-hub URL can't be empty.";
|
|
51
|
+
|
|
52
|
+
return true;
|
|
53
|
+
},
|
|
54
|
+
message: `Enter the developer-hub base URL for the ${name} region - `,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return developerHubBaseUrl.startsWith('http') ? developerHubBaseUrl : `https://${developerHubBaseUrl}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = { getInstalledExtensions, getDeveloperHubUrl }
|
|
@@ -8,12 +8,12 @@ const setupBranches = async (config, branch) => {
|
|
|
8
8
|
throw new Error('Invalid config to setup the branch');
|
|
9
9
|
}
|
|
10
10
|
let branches = [];
|
|
11
|
-
const headers = { api_key: config.source_stack }
|
|
11
|
+
const headers = { api_key: config.source_stack };
|
|
12
12
|
|
|
13
13
|
if (config.auth_token) {
|
|
14
|
-
headers['authtoken'] = config.auth_token
|
|
14
|
+
headers['authtoken'] = config.auth_token;
|
|
15
15
|
} else if (config.management_token) {
|
|
16
|
-
headers['authorization'] = config.management_token
|
|
16
|
+
headers['authorization'] = config.management_token;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
if (typeof branch === 'string') {
|
|
@@ -29,14 +29,12 @@ const setupBranches = async (config, branch) => {
|
|
|
29
29
|
}
|
|
30
30
|
} else {
|
|
31
31
|
try {
|
|
32
|
-
const result = await HttpClient.create()
|
|
33
|
-
.headers(headers)
|
|
34
|
-
.get(`https://${config.host}/v3/stacks/branches`);
|
|
32
|
+
const result = await HttpClient.create().headers(headers).get(`https://${config.host}/v3/stacks/branches`);
|
|
35
33
|
|
|
36
34
|
if (result && result.data && Array.isArray(result.data.branches) && result.data.branches.length > 0) {
|
|
37
35
|
branches = result.data.branches;
|
|
38
36
|
} else {
|
|
39
|
-
|
|
37
|
+
return;
|
|
40
38
|
}
|
|
41
39
|
} catch (error) {
|
|
42
40
|
return;
|