@contentstack/cli-cm-export 1.6.1 → 1.8.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 +1 -1
- package/lib/config/index.js +16 -2
- package/lib/export/modules/base-class.d.ts +2 -1
- package/lib/export/modules/base-class.js +1 -0
- package/lib/export/modules/content-types.d.ts +15 -0
- package/lib/export/modules/content-types.js +72 -0
- package/lib/export/modules/custom-roles.d.ts +16 -0
- package/lib/export/modules/custom-roles.js +81 -0
- package/lib/export/modules/entries.d.ts +26 -0
- package/lib/export/modules/entries.js +167 -0
- package/lib/export/modules/environments.d.ts +12 -0
- package/lib/export/modules/environments.js +64 -0
- package/lib/export/modules/extensions.d.ts +12 -0
- package/lib/export/modules/extensions.js +64 -0
- package/lib/export/modules/global-fields.d.ts +14 -0
- package/lib/export/modules/global-fields.js +59 -0
- package/lib/export/modules/labels.d.ts +12 -0
- package/lib/export/modules/labels.js +64 -0
- package/lib/export/modules/locales.js +2 -1
- package/lib/export/modules/marketplace-apps.d.ts +18 -0
- package/lib/export/modules/marketplace-apps.js +119 -0
- package/lib/export/modules/stack.d.ts +12 -0
- package/lib/export/modules/stack.js +91 -0
- package/lib/export/modules/webhooks.d.ts +12 -0
- package/lib/export/modules/webhooks.js +63 -0
- package/lib/export/modules/workflows.d.ts +14 -0
- package/lib/export/modules/workflows.js +81 -0
- package/lib/export/modules-js/entries.js +2 -1
- package/lib/export/modules-js/index.d.ts +2 -1
- package/lib/export/modules-js/index.js +3 -5
- package/lib/export/modules-js/marketplace-apps.d.ts +0 -1
- package/lib/export/modules-js/marketplace-apps.js +3 -22
- package/lib/export/modules-js/stack.js +2 -2
- package/lib/types/default-config.d.ts +1 -0
- package/lib/types/export-config.d.ts +3 -0
- package/lib/types/index.d.ts +49 -0
- package/lib/utils/interactive.d.ts +1 -0
- package/lib/utils/interactive.js +15 -2
- package/lib/utils/marketplace-app-helper.d.ts +11 -1
- package/lib/utils/marketplace-app-helper.js +43 -11
- package/lib/utils/setup-branches.d.ts +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +9 -7
|
@@ -11,7 +11,7 @@ const eachOf = require('async/eachOf');
|
|
|
11
11
|
const { cliux, HttpClient, NodeCrypto, managementSDKClient, HttpClientDecorator, OauthDecorator, isAuthenticated, } = require('@contentstack/cli-utilities');
|
|
12
12
|
const { default: config } = require('../../config');
|
|
13
13
|
const { formatError, log, fileHelper } = require('../../utils');
|
|
14
|
-
const { getDeveloperHubUrl } = require('../../utils');
|
|
14
|
+
const { getDeveloperHubUrl, createNodeCryptoInstance } = require('../../utils');
|
|
15
15
|
module.exports = class ExportMarketplaceApps {
|
|
16
16
|
constructor(credentialConfig) {
|
|
17
17
|
this.marketplaceAppPath = null;
|
|
@@ -24,7 +24,7 @@ module.exports = class ExportMarketplaceApps {
|
|
|
24
24
|
cliux.print('WARNING!!! To export Marketplace apps, you must be logged in. Please check csdx auth:login --help to log in', { color: 'yellow' });
|
|
25
25
|
return Promise.resolve();
|
|
26
26
|
}
|
|
27
|
-
this.developerHubBaseUrl = this.config.developerHubBaseUrl || (await getDeveloperHubUrl());
|
|
27
|
+
this.developerHubBaseUrl = this.config.developerHubBaseUrl || (await getDeveloperHubUrl(this.config));
|
|
28
28
|
await this.getOrgUid();
|
|
29
29
|
const httpClient = new HttpClient();
|
|
30
30
|
if (!this.config.auth_token) {
|
|
@@ -39,6 +39,7 @@ module.exports = class ExportMarketplaceApps {
|
|
|
39
39
|
log(this.config, 'Starting marketplace app export', 'success');
|
|
40
40
|
this.marketplaceAppPath = path.resolve(this.config.data, this.config.branchName || '', this.marketplaceAppConfig.dirName);
|
|
41
41
|
mkdirp.sync(this.marketplaceAppPath);
|
|
42
|
+
this.nodeCrypto = await createNodeCryptoInstance(config);
|
|
42
43
|
return this.exportInstalledExtensions();
|
|
43
44
|
}
|
|
44
45
|
async getOrgUid() {
|
|
@@ -54,26 +55,6 @@ module.exports = class ExportMarketplaceApps {
|
|
|
54
55
|
this.config.org_uid = tempStackData.org_uid;
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
async createNodeCryptoInstance() {
|
|
58
|
-
const cryptoArgs = {};
|
|
59
|
-
if (this.config.forceStopMarketplaceAppsPrompt) {
|
|
60
|
-
cryptoArgs['encryptionKey'] = this.config.marketplaceAppEncryptionKey;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
cryptoArgs['encryptionKey'] = await cliux.inquire({
|
|
64
|
-
type: 'input',
|
|
65
|
-
name: 'name',
|
|
66
|
-
default: this.config.marketplaceAppEncryptionKey,
|
|
67
|
-
validate: (url) => {
|
|
68
|
-
if (!url)
|
|
69
|
-
return "Encryption key can't be empty.";
|
|
70
|
-
return true;
|
|
71
|
-
},
|
|
72
|
-
message: 'Enter marketplace app configurations encryption key',
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
this.nodeCrypto = new NodeCrypto(cryptoArgs);
|
|
76
|
-
}
|
|
77
58
|
async exportInstalledExtensions() {
|
|
78
59
|
const client = await managementSDKClient({ host: this.developerHubBaseUrl.split('://').pop() });
|
|
79
60
|
const installedApps = (await this.getAllStackSpecificApps()) || [];
|
|
@@ -44,8 +44,8 @@ class ExportStack {
|
|
|
44
44
|
}
|
|
45
45
|
else if (self.config.preserveStackVersion) {
|
|
46
46
|
log(self.config, 'Exporting stack details', 'success');
|
|
47
|
-
let stackFolderPath = path.resolve(self.config.data, stackConfig.dirName);
|
|
48
|
-
let stackContentsFile = path.resolve(stackFolderPath, stackConfig.fileName);
|
|
47
|
+
let stackFolderPath = path.resolve(self.config.data, this.stackConfig.dirName);
|
|
48
|
+
let stackContentsFile = path.resolve(stackFolderPath, this.stackConfig.fileName);
|
|
49
49
|
mkdirp.sync(stackFolderPath);
|
|
50
50
|
return new Promise((resolve, reject) => {
|
|
51
51
|
return self.stackAPIClient
|
package/lib/types/index.d.ts
CHANGED
|
@@ -41,5 +41,54 @@ export interface ExternalConfig extends ExportConfig {
|
|
|
41
41
|
email?: string;
|
|
42
42
|
password?: string;
|
|
43
43
|
}
|
|
44
|
+
export interface ExtensionsConfig {
|
|
45
|
+
dirName: string;
|
|
46
|
+
fileName: string;
|
|
47
|
+
dependencies?: Modules[];
|
|
48
|
+
limit?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface MarketplaceAppsConfig {
|
|
51
|
+
dirName: string;
|
|
52
|
+
fileName: string;
|
|
53
|
+
dependencies?: Modules[];
|
|
54
|
+
}
|
|
55
|
+
export interface EnvironmentConfig {
|
|
56
|
+
dirName: string;
|
|
57
|
+
fileName: string;
|
|
58
|
+
dependencies?: Modules[];
|
|
59
|
+
limit?: number;
|
|
60
|
+
}
|
|
61
|
+
export interface LabelConfig {
|
|
62
|
+
dirName: string;
|
|
63
|
+
fileName: string;
|
|
64
|
+
invalidKeys: string[];
|
|
65
|
+
dependencies?: Modules[];
|
|
66
|
+
limit?: number;
|
|
67
|
+
}
|
|
68
|
+
export interface WebhookConfig {
|
|
69
|
+
dirName: string;
|
|
70
|
+
fileName: string;
|
|
71
|
+
dependencies?: Modules[];
|
|
72
|
+
limit?: number;
|
|
73
|
+
}
|
|
74
|
+
export interface WorkflowConfig {
|
|
75
|
+
dirName: string;
|
|
76
|
+
fileName: string;
|
|
77
|
+
invalidKeys: string[];
|
|
78
|
+
dependencies?: Modules[];
|
|
79
|
+
limit?: number;
|
|
80
|
+
}
|
|
81
|
+
export interface CustomRoleConfig {
|
|
82
|
+
dirName: string;
|
|
83
|
+
fileName: string;
|
|
84
|
+
customRolesLocalesFileName: string;
|
|
85
|
+
dependencies?: Modules[];
|
|
86
|
+
}
|
|
87
|
+
export interface StackConfig {
|
|
88
|
+
dirName: string;
|
|
89
|
+
fileName: string;
|
|
90
|
+
dependencies?: Modules[];
|
|
91
|
+
limit?: number;
|
|
92
|
+
}
|
|
44
93
|
export { default as DefaultConfig } from './default-config';
|
|
45
94
|
export { default as ExportConfig } from './export-config';
|
|
@@ -4,3 +4,4 @@ export declare const askOTP: () => Promise<string>;
|
|
|
4
4
|
export declare const askUsername: () => Promise<string>;
|
|
5
5
|
export declare const askExportDir: () => Promise<string>;
|
|
6
6
|
export declare const askAPIKey: () => Promise<string>;
|
|
7
|
+
export declare const askDeveloperHub: (regionName: string) => Promise<string>;
|
package/lib/utils/interactive.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.askAPIKey = exports.askExportDir = exports.askUsername = exports.askOTP = exports.askOTPChannel = exports.askPassword = void 0;
|
|
3
|
+
exports.askDeveloperHub = exports.askAPIKey = exports.askExportDir = exports.askUsername = exports.askOTP = exports.askOTPChannel = exports.askPassword = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
@@ -62,10 +62,23 @@ const askExportDir = async () => {
|
|
|
62
62
|
};
|
|
63
63
|
exports.askExportDir = askExportDir;
|
|
64
64
|
const askAPIKey = async () => {
|
|
65
|
-
return cli_utilities_1.cliux.inquire({
|
|
65
|
+
return await cli_utilities_1.cliux.inquire({
|
|
66
66
|
type: 'input',
|
|
67
67
|
message: 'Enter the stack api key',
|
|
68
68
|
name: 'apiKey',
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
71
|
exports.askAPIKey = askAPIKey;
|
|
72
|
+
const askDeveloperHub = async (regionName) => {
|
|
73
|
+
return await cli_utilities_1.cliux.inquire({
|
|
74
|
+
type: 'input',
|
|
75
|
+
name: 'name',
|
|
76
|
+
validate: (url) => {
|
|
77
|
+
if (!url)
|
|
78
|
+
return "Developer-hub URL can't be empty.";
|
|
79
|
+
return true;
|
|
80
|
+
},
|
|
81
|
+
message: `Enter the developer-hub base URL for the ${regionName} region - `,
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
exports.askDeveloperHub = askDeveloperHub;
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { NodeCrypto, HttpClient } from '@contentstack/cli-utilities';
|
|
2
|
+
import { ExportConfig } from '../types';
|
|
3
|
+
export declare const getDeveloperHubUrl: (exportConfig: ExportConfig) => Promise<any>;
|
|
4
|
+
export declare function getOrgUid(config: ExportConfig): Promise<string>;
|
|
5
|
+
export declare function createNodeCryptoInstance(config: ExportConfig): Promise<NodeCrypto>;
|
|
6
|
+
export declare const getStackSpecificApps: (params: {
|
|
7
|
+
developerHubBaseUrl: string;
|
|
8
|
+
httpClient: HttpClient;
|
|
9
|
+
config: ExportConfig;
|
|
10
|
+
skip: number;
|
|
11
|
+
}) => Promise<any>;
|
|
@@ -1,23 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDeveloperHubUrl = void 0;
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
exports.getStackSpecificApps = exports.createNodeCryptoInstance = exports.getOrgUid = exports.getDeveloperHubUrl = void 0;
|
|
4
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const interactive_1 = require("./interactive");
|
|
7
|
+
const getDeveloperHubUrl = async (exportConfig) => {
|
|
8
|
+
const { cma, name } = cli_utilities_1.configHandler.get('region') || {};
|
|
9
|
+
let developerHubBaseUrl = exportConfig === null || exportConfig === void 0 ? void 0 : exportConfig.developerHubUrls[cma];
|
|
9
10
|
if (!developerHubBaseUrl) {
|
|
10
|
-
developerHubBaseUrl = await
|
|
11
|
+
developerHubBaseUrl = await (0, interactive_1.askDeveloperHub)(name);
|
|
12
|
+
}
|
|
13
|
+
return developerHubBaseUrl.startsWith('http') ? developerHubBaseUrl : `https://${developerHubBaseUrl}`;
|
|
14
|
+
};
|
|
15
|
+
exports.getDeveloperHubUrl = getDeveloperHubUrl;
|
|
16
|
+
async function getOrgUid(config) {
|
|
17
|
+
const tempAPIClient = await (0, cli_utilities_1.managementSDKClient)({ host: config.host });
|
|
18
|
+
const tempStackData = await tempAPIClient
|
|
19
|
+
.stack({ api_key: config.source_stack })
|
|
20
|
+
.fetch()
|
|
21
|
+
.catch((error) => {
|
|
22
|
+
(0, utils_1.log)(this.config, (0, utils_1.formatError)(error), 'error');
|
|
23
|
+
});
|
|
24
|
+
return tempStackData === null || tempStackData === void 0 ? void 0 : tempStackData.org_uid;
|
|
25
|
+
}
|
|
26
|
+
exports.getOrgUid = getOrgUid;
|
|
27
|
+
async function createNodeCryptoInstance(config) {
|
|
28
|
+
const cryptoArgs = { encryptionKey: '' };
|
|
29
|
+
if (config.forceStopMarketplaceAppsPrompt) {
|
|
30
|
+
cryptoArgs['encryptionKey'] = config.marketplaceAppEncryptionKey;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
cryptoArgs['encryptionKey'] = await cli_utilities_1.cliux.inquire({
|
|
11
34
|
type: 'input',
|
|
12
35
|
name: 'name',
|
|
36
|
+
default: config.marketplaceAppEncryptionKey,
|
|
13
37
|
validate: (url) => {
|
|
14
38
|
if (!url)
|
|
15
|
-
return "
|
|
39
|
+
return "Encryption key can't be empty.";
|
|
16
40
|
return true;
|
|
17
41
|
},
|
|
18
|
-
message:
|
|
42
|
+
message: 'Enter marketplace app configurations encryption key',
|
|
19
43
|
});
|
|
20
44
|
}
|
|
21
|
-
return
|
|
45
|
+
return new cli_utilities_1.NodeCrypto(cryptoArgs);
|
|
46
|
+
}
|
|
47
|
+
exports.createNodeCryptoInstance = createNodeCryptoInstance;
|
|
48
|
+
const getStackSpecificApps = async (params) => {
|
|
49
|
+
const { developerHubBaseUrl, httpClient, config, skip } = params;
|
|
50
|
+
return httpClient
|
|
51
|
+
.get(`${developerHubBaseUrl}/installations?target_uids=${config.source_stack}&skip=${skip}`)
|
|
52
|
+
.then((data) => data.data)
|
|
53
|
+
.catch((error) => (0, utils_1.log)(config, `Failed to export marketplace-apps ${(0, utils_1.formatError)(error)}`, 'error'));
|
|
22
54
|
};
|
|
23
|
-
exports.
|
|
55
|
+
exports.getStackSpecificApps = getStackSpecificApps;
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export",
|
|
3
3
|
"description": "Contentstack CLI plugin to export content from stack",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-command": "
|
|
9
|
-
"@contentstack/cli-utilities": "
|
|
8
|
+
"@contentstack/cli-command": "~1.2.11",
|
|
9
|
+
"@contentstack/cli-utilities": "~1.5.1",
|
|
10
10
|
"@oclif/command": "^1.8.16",
|
|
11
11
|
"@oclif/config": "^1.18.3",
|
|
12
|
-
"@oclif/core": "^2.3
|
|
12
|
+
"@oclif/core": "^2.9.3",
|
|
13
13
|
"async": "^3.2.4",
|
|
14
14
|
"big-json": "^3.2.0",
|
|
15
15
|
"bluebird": "^3.7.2",
|
|
@@ -26,13 +26,14 @@
|
|
|
26
26
|
"winston": "^3.7.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@contentstack/cli-auth": "
|
|
30
|
-
"@contentstack/cli-config": "
|
|
31
|
-
"@contentstack/cli-dev-dependencies": "
|
|
29
|
+
"@contentstack/cli-auth": "~1.3.11",
|
|
30
|
+
"@contentstack/cli-config": "~1.4.9",
|
|
31
|
+
"@contentstack/cli-dev-dependencies": "~1.2.3",
|
|
32
32
|
"@oclif/plugin-help": "^5.1.19",
|
|
33
33
|
"@oclif/test": "^1.2.6",
|
|
34
34
|
"@types/mkdirp": "^1.0.2",
|
|
35
35
|
"@types/progress-stream": "^2.0.2",
|
|
36
|
+
"@types/mkdirp": "^1.0.2",
|
|
36
37
|
"assert": "^2.0.0",
|
|
37
38
|
"chai": "^4.2.0",
|
|
38
39
|
"dotenv": "^16.0.1",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"lint": "eslint src/**/*.ts",
|
|
62
63
|
"format": "eslint src/**/*.ts --fix",
|
|
63
64
|
"test:integration": "INTEGRATION_TEST=true mocha --config ./test/.mocharc.js --forbid-only \"test/run.test.js\"",
|
|
65
|
+
"test:integration:report": "INTEGRATION_TEST=true nyc --extension .js mocha --forbid-only \"test/run.test.js\"",
|
|
64
66
|
"test:unit": "mocha --forbid-only \"test/unit/*.test.ts\""
|
|
65
67
|
},
|
|
66
68
|
"engines": {
|