@contentstack/cli-cm-import 1.5.10 → 1.6.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 +6 -14
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +6 -0
- package/bin/run.cmd +3 -0
- package/lib/commands/cm/stacks/import.d.ts +10 -0
- package/lib/commands/cm/stacks/import.js +111 -0
- package/lib/config/index.d.ts +3 -0
- package/lib/config/index.js +372 -0
- package/lib/import/index.d.ts +1 -0
- package/lib/import/index.js +8 -0
- package/lib/import/module-importer.d.ts +13 -0
- package/lib/import/module-importer.js +70 -0
- package/lib/import/modules/assets.d.ts +63 -0
- package/lib/import/modules/assets.js +265 -0
- package/lib/import/modules/base-class.d.ts +69 -0
- package/lib/import/modules/base-class.js +165 -0
- package/lib/import/modules/index.d.ts +2 -0
- package/lib/import/modules/index.js +19 -0
- package/lib/import/modules/locales.d.ts +31 -0
- package/lib/import/modules/locales.js +152 -0
- package/lib/import/modules-js/assets.d.ts +33 -0
- package/lib/import/modules-js/assets.js +415 -0
- package/lib/import/modules-js/content-types.d.ts +33 -0
- package/lib/import/modules-js/content-types.js +176 -0
- package/lib/import/modules-js/custom-roles.d.ts +15 -0
- package/lib/import/modules-js/custom-roles.js +141 -0
- package/lib/import/modules-js/entries.d.ts +54 -0
- package/lib/import/modules-js/entries.js +1260 -0
- package/lib/import/modules-js/environments.d.ts +13 -0
- package/lib/import/modules-js/environments.js +85 -0
- package/lib/import/modules-js/extensions.d.ts +17 -0
- package/lib/import/modules-js/extensions.js +86 -0
- package/lib/import/modules-js/global-fields.d.ts +13 -0
- package/lib/import/modules-js/global-fields.js +109 -0
- package/lib/import/modules-js/index.d.ts +1 -0
- package/lib/import/modules-js/index.js +33 -0
- package/lib/import/modules-js/labels.d.ts +20 -0
- package/lib/import/modules-js/labels.js +148 -0
- package/lib/import/modules-js/locales.d.ts +24 -0
- package/lib/import/modules-js/locales.js +196 -0
- package/lib/import/modules-js/marketplace-apps.d.ts +60 -0
- package/lib/import/modules-js/marketplace-apps.js +409 -0
- package/lib/import/modules-js/webhooks.d.ts +17 -0
- package/lib/import/modules-js/webhooks.js +85 -0
- package/lib/import/modules-js/workflows.d.ts +18 -0
- package/lib/import/modules-js/workflows.js +132 -0
- package/lib/types/default-config.d.ts +130 -0
- package/lib/types/default-config.js +2 -0
- package/lib/types/import-config.d.ts +51 -0
- package/lib/types/import-config.js +2 -0
- package/lib/types/index.d.ts +30 -0
- package/lib/types/index.js +2 -0
- package/lib/utils/asset-helper.d.ts +4 -0
- package/lib/utils/asset-helper.js +387 -0
- package/lib/utils/backup-handler.d.ts +2 -0
- package/lib/utils/backup-handler.js +31 -0
- package/lib/utils/common-helper.d.ts +20 -0
- package/lib/utils/common-helper.js +244 -0
- package/lib/utils/content-type-helper.d.ts +49 -0
- package/lib/utils/content-type-helper.js +143 -0
- package/lib/utils/entries-helper.d.ts +4 -0
- package/lib/utils/entries-helper.js +252 -0
- package/lib/utils/extension-helper.d.ts +10 -0
- package/lib/utils/extension-helper.js +72 -0
- package/lib/utils/file-helper.d.ts +14 -0
- package/lib/utils/file-helper.js +140 -0
- package/lib/utils/import-config-handler.d.ts +3 -0
- package/lib/utils/import-config-handler.js +73 -0
- package/lib/utils/index.d.ts +12 -0
- package/lib/utils/index.js +29 -0
- package/lib/utils/interactive.d.ts +2 -0
- package/lib/utils/interactive.js +23 -0
- package/lib/utils/logger.d.ts +8 -0
- package/lib/utils/logger.js +154 -0
- package/lib/utils/login-handler.d.ts +8 -0
- package/lib/utils/login-handler.js +53 -0
- package/lib/utils/marketplace-app-helper.d.ts +4 -0
- package/lib/utils/marketplace-app-helper.js +31 -0
- package/messages/index.json +1 -7
- package/oclif.manifest.json +2 -2
- package/package.json +47 -21
- package/src/app.js +0 -217
- package/src/commands/cm/stacks/import.js +0 -161
- package/src/config/default.js +0 -352
- package/src/lib/import/assets.js +0 -495
- package/src/lib/import/content-types.js +0 -201
- package/src/lib/import/custom-roles.js +0 -169
- package/src/lib/import/entries.js +0 -1480
- package/src/lib/import/environments.js +0 -106
- package/src/lib/import/extensions.js +0 -108
- package/src/lib/import/global-fields.js +0 -135
- package/src/lib/import/labels.js +0 -175
- package/src/lib/import/locales.js +0 -216
- package/src/lib/import/marketplace-apps.js +0 -542
- package/src/lib/import/webhooks.js +0 -113
- package/src/lib/import/workflows.js +0 -166
- package/src/lib/util/extensionsUidReplace.js +0 -67
- package/src/lib/util/fs.js +0 -124
- package/src/lib/util/import-flags.js +0 -187
- package/src/lib/util/index.js +0 -222
- package/src/lib/util/log.js +0 -144
- package/src/lib/util/login.js +0 -58
- package/src/lib/util/lookupReplaceAssets.js +0 -366
- package/src/lib/util/lookupReplaceEntries.js +0 -250
- package/src/lib/util/marketplace-app-helper.js +0 -31
- package/src/lib/util/removeReferenceFields.js +0 -59
- package/src/lib/util/schemaTemplate.js +0 -38
- package/src/lib/util/supress-mandatory-fields.js +0 -34
- package/src/lib/util/upload.js +0 -56
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Contentstack Import
|
|
3
|
+
* Copyright (c) 2019 Contentstack LLC
|
|
4
|
+
* MIT Licensed
|
|
5
|
+
*/
|
|
6
|
+
const mkdirp = require('mkdirp');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const Promise = require('bluebird');
|
|
10
|
+
const chalk = require('chalk');
|
|
11
|
+
const { isEmpty, merge } = require('lodash');
|
|
12
|
+
let { default: config } = require('../../config');
|
|
13
|
+
const { fileHelper, log, formatError } = require('../../utils');
|
|
14
|
+
module.exports = class ImportWebhooks {
|
|
15
|
+
constructor(importConfig, stackAPIClient) {
|
|
16
|
+
this.fails = [];
|
|
17
|
+
this.success = [];
|
|
18
|
+
this.webUidMapper = {};
|
|
19
|
+
this.webhooksConfig = config.modules.webhooks;
|
|
20
|
+
this.reqConcurrency = config.concurrency || config.fetchConcurrency;
|
|
21
|
+
this.config = merge(config, importConfig);
|
|
22
|
+
this.stackAPIClient = stackAPIClient;
|
|
23
|
+
}
|
|
24
|
+
start() {
|
|
25
|
+
log(this.config, chalk.white('Migrating webhooks'), 'success');
|
|
26
|
+
const self = this;
|
|
27
|
+
let webMapperPath = path.resolve(this.config.data, 'mapper', 'webhooks');
|
|
28
|
+
let webFailsPath = path.resolve(this.config.data, 'mapper', 'webhooks', 'fails.json');
|
|
29
|
+
let webSuccessPath = path.resolve(this.config.data, 'mapper', 'webhooks', 'success.json');
|
|
30
|
+
let webUidMapperPath = path.resolve(this.config.data, 'mapper', 'webhooks', 'uid-mapping.json');
|
|
31
|
+
let webhooksFolderPath = path.resolve(this.config.data, this.webhooksConfig.dirName);
|
|
32
|
+
this.webhooks = fileHelper.readFileSync(path.resolve(webhooksFolderPath, this.webhooksConfig.fileName));
|
|
33
|
+
if (fs.existsSync(webUidMapperPath)) {
|
|
34
|
+
self.webUidMapper = fileHelper.readFileSync(webUidMapperPath);
|
|
35
|
+
self.webUidMapper = self.webUidMapper || {};
|
|
36
|
+
}
|
|
37
|
+
mkdirp.sync(webMapperPath);
|
|
38
|
+
return new Promise(function (resolve, reject) {
|
|
39
|
+
if (self.webhooks == undefined || isEmpty(self.webhooks)) {
|
|
40
|
+
log(self.config, chalk.white('No Webhooks Found'), 'success');
|
|
41
|
+
return resolve({ empty: true });
|
|
42
|
+
}
|
|
43
|
+
let webUids = Object.keys(self.webhooks);
|
|
44
|
+
return Promise.map(webUids, function (webUid) {
|
|
45
|
+
let web = self.webhooks[webUid];
|
|
46
|
+
if (self.config.importWebhookStatus !== 'current' || self.config.importWebhookStatus === 'disable') {
|
|
47
|
+
web.disabled = true;
|
|
48
|
+
}
|
|
49
|
+
if (!self.webUidMapper.hasOwnProperty(webUid)) {
|
|
50
|
+
let requestOption = { json: { webhook: web } };
|
|
51
|
+
return self.stackAPIClient
|
|
52
|
+
.webhook()
|
|
53
|
+
.create(requestOption.json)
|
|
54
|
+
.then(function (response) {
|
|
55
|
+
self.success.push(response);
|
|
56
|
+
self.webUidMapper[webUid] = response.uid;
|
|
57
|
+
fileHelper.writeFileSync(webUidMapperPath, self.webUidMapper);
|
|
58
|
+
})
|
|
59
|
+
.catch(function (err) {
|
|
60
|
+
let error = JSON.parse(err.message);
|
|
61
|
+
self.fails.push(web);
|
|
62
|
+
log(self.config, `Webhooks '${web.name}' failed to be import.\n ${formatError(error)}`, 'error');
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// the webhooks has already been created
|
|
67
|
+
log(self.config, chalk.white("The Webhooks: '" + web.name + "' already exists. Skipping it to avoid duplicates!"), 'success');
|
|
68
|
+
}
|
|
69
|
+
// import 2 webhooks at a time
|
|
70
|
+
}, { concurrency: self.reqConcurrency })
|
|
71
|
+
.then(function () {
|
|
72
|
+
// webhooks have imported successfully
|
|
73
|
+
fileHelper.writeFileSync(webSuccessPath, self.success);
|
|
74
|
+
log(self.config, chalk.green('Webhooks have been imported successfully!'), 'success');
|
|
75
|
+
return resolve();
|
|
76
|
+
})
|
|
77
|
+
.catch(function (error) {
|
|
78
|
+
// error while importing environments
|
|
79
|
+
fileHelper.writeFileSync(webFailsPath, self.fails);
|
|
80
|
+
log(self.config, `Webhooks import failed. ${formatError(error)}`, 'error');
|
|
81
|
+
return reject(error);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export = importWorkflows;
|
|
2
|
+
declare class importWorkflows {
|
|
3
|
+
constructor(importConfig: any, stackAPIClient: any);
|
|
4
|
+
fails: any[];
|
|
5
|
+
success: any[];
|
|
6
|
+
workflowUidMapper: {};
|
|
7
|
+
workflowConfig: {
|
|
8
|
+
dirName: string;
|
|
9
|
+
fileName: string;
|
|
10
|
+
invalidKeys: string[];
|
|
11
|
+
};
|
|
12
|
+
reqConcurrency: number;
|
|
13
|
+
config: any;
|
|
14
|
+
stackAPIClient: any;
|
|
15
|
+
start(): Promise<any>;
|
|
16
|
+
workflows: any;
|
|
17
|
+
}
|
|
18
|
+
import Promise = require("bluebird");
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Contentstack Import
|
|
3
|
+
* Copyright (c) 2019 Contentstack LLC
|
|
4
|
+
* MIT Licensed
|
|
5
|
+
*/
|
|
6
|
+
const mkdirp = require('mkdirp');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const Promise = require('bluebird');
|
|
10
|
+
const chalk = require('chalk');
|
|
11
|
+
const { isEmpty, merge } = require('lodash');
|
|
12
|
+
let { default: config } = require('../../config');
|
|
13
|
+
const { fileHelper, log, formatError } = require('../../utils');
|
|
14
|
+
module.exports = class importWorkflows {
|
|
15
|
+
constructor(importConfig, stackAPIClient) {
|
|
16
|
+
this.fails = [];
|
|
17
|
+
this.success = [];
|
|
18
|
+
this.workflowUidMapper = {};
|
|
19
|
+
this.workflowConfig = config.modules.workflows;
|
|
20
|
+
this.reqConcurrency = config.concurrency || config.fetchConcurrency || 1;
|
|
21
|
+
this.config = merge(config, importConfig);
|
|
22
|
+
this.stackAPIClient = stackAPIClient;
|
|
23
|
+
}
|
|
24
|
+
start() {
|
|
25
|
+
log(this.config, chalk.white('Migrating workflows'), 'success');
|
|
26
|
+
let self = this;
|
|
27
|
+
let workflowMapperPath = path.resolve(this.config.data, 'mapper', 'workflows');
|
|
28
|
+
let workflowFailsPath = path.resolve(this.config.data, 'workflows', 'fails.json');
|
|
29
|
+
let workflowSuccessPath = path.resolve(this.config.data, 'workflows', 'success.json');
|
|
30
|
+
let workflowUidMapperPath = path.resolve(this.config.data, 'mapper', 'workflows', 'uid-mapping.json');
|
|
31
|
+
let workflowFolderPath = path.resolve(this.config.data, this.workflowConfig.dirName);
|
|
32
|
+
self.workflows = fileHelper.readFileSync(path.resolve(workflowFolderPath, this.workflowConfig.fileName));
|
|
33
|
+
if (fs.existsSync(workflowUidMapperPath)) {
|
|
34
|
+
this.workflowUidMapper = fileHelper.readFileSync(workflowUidMapperPath);
|
|
35
|
+
this.workflowUidMapper = this.workflowUidMapper || {};
|
|
36
|
+
}
|
|
37
|
+
mkdirp.sync(workflowMapperPath);
|
|
38
|
+
return new Promise(function (resolve, reject) {
|
|
39
|
+
if (self.workflows == undefined || isEmpty(self.workflows)) {
|
|
40
|
+
log(self.config, chalk.white('No workflow Found'), 'success');
|
|
41
|
+
return resolve({ empty: true });
|
|
42
|
+
}
|
|
43
|
+
self.workflowsUids = Object.keys(self.workflows);
|
|
44
|
+
return Promise.map(self.workflowsUids, async function (workflowUid) {
|
|
45
|
+
let workflow = self.workflows[workflowUid];
|
|
46
|
+
if (!self.workflowUidMapper.hasOwnProperty(workflowUid)) {
|
|
47
|
+
const roleNameMap = {};
|
|
48
|
+
const workflowStages = workflow.workflow_stages;
|
|
49
|
+
const roles = await self.stackAPIClient.role().fetchAll();
|
|
50
|
+
for (const role of roles.items) {
|
|
51
|
+
roleNameMap[role.name] = role.uid;
|
|
52
|
+
}
|
|
53
|
+
for (const stage of workflowStages) {
|
|
54
|
+
if (stage.SYS_ACL.users.uids.length && stage.SYS_ACL.users.uids[0] !== '$all') {
|
|
55
|
+
stage.SYS_ACL.users.uids = ['$all'];
|
|
56
|
+
}
|
|
57
|
+
if (stage.SYS_ACL.roles.uids.length) {
|
|
58
|
+
try {
|
|
59
|
+
for (let i = 0; i < stage.SYS_ACL.roles.uids.length; i++) {
|
|
60
|
+
const roleData = stage.SYS_ACL.roles.uids[i];
|
|
61
|
+
if (!roleNameMap[roleData.name]) {
|
|
62
|
+
// rules.branch is required to create custom roles.
|
|
63
|
+
const branchRuleExists = roleData.rules.find((rule) => rule.module === 'branch');
|
|
64
|
+
if (!branchRuleExists) {
|
|
65
|
+
roleData.rules.push({
|
|
66
|
+
module: 'branch',
|
|
67
|
+
branches: ['main'],
|
|
68
|
+
acl: { read: true },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const role = await self.stackAPIClient.role().create({ role: roleData });
|
|
72
|
+
stage.SYS_ACL.roles.uids[i] = role.uid;
|
|
73
|
+
roleNameMap[roleData.name] = role.uid;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
stage.SYS_ACL.roles.uids[i] = roleNameMap[roleData.name];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
log(self.config, `Error while importing workflows roles. ${formatError(error)}`, 'error');
|
|
82
|
+
reject({ message: 'Error while importing workflows roles' });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (workflow.admin_users !== undefined) {
|
|
87
|
+
log(self.config, chalk.yellow('We are skipping import of `Workflow superuser(s)` from workflow'), 'info');
|
|
88
|
+
delete workflow.admin_users;
|
|
89
|
+
}
|
|
90
|
+
// One branch is required to create workflow.
|
|
91
|
+
if (!workflow.branches) {
|
|
92
|
+
workflow.branches = ['main'];
|
|
93
|
+
}
|
|
94
|
+
return self.stackAPIClient
|
|
95
|
+
.workflow()
|
|
96
|
+
.create({ workflow })
|
|
97
|
+
.then(function (response) {
|
|
98
|
+
self.workflowUidMapper[workflowUid] = response;
|
|
99
|
+
fileHelper.writeFileSync(workflowUidMapperPath, self.workflowUidMapper);
|
|
100
|
+
})
|
|
101
|
+
.catch(function (error) {
|
|
102
|
+
self.fails.push(workflow);
|
|
103
|
+
if (error.errors.name) {
|
|
104
|
+
log(self.config, `workflow ${workflow.name} already exist`, 'error');
|
|
105
|
+
}
|
|
106
|
+
else if (error.errors['workflow_stages.0.users']) {
|
|
107
|
+
log(self.config, "Failed to import Workflows as you've specified certain roles in the Stage transition and access rules section. We currently don't import roles to the stack.", 'error');
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
log(self.config, `workflow ${workflow.name} failed.`, 'error');
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// the workflow has already been created
|
|
116
|
+
log(self.config, chalk.white(`The Workflows ${workflow.name} already exists. Skipping it to avoid duplicates!`), 'success');
|
|
117
|
+
}
|
|
118
|
+
// import 1 workflows at a time
|
|
119
|
+
}, { concurrency: self.reqConcurrency })
|
|
120
|
+
.then(function () {
|
|
121
|
+
fileHelper.writeFileSync(workflowSuccessPath, self.success);
|
|
122
|
+
log(self.config, chalk.green('Workflows have been imported successfully!'), 'success');
|
|
123
|
+
resolve();
|
|
124
|
+
})
|
|
125
|
+
.catch(function (error) {
|
|
126
|
+
fileHelper.writeFileSync(workflowFailsPath, self.fails);
|
|
127
|
+
log(self.config, `Workflows import failed. ${formatError(error)}`, 'error');
|
|
128
|
+
return reject(error);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Modules } from '.';
|
|
2
|
+
export default interface DefaultConfig {
|
|
3
|
+
versioning: boolean;
|
|
4
|
+
host: string;
|
|
5
|
+
extensionHost: string;
|
|
6
|
+
developerHubUrls: Record<string, string>;
|
|
7
|
+
modules: {
|
|
8
|
+
apiConcurrency: number;
|
|
9
|
+
types: Modules[];
|
|
10
|
+
locales: {
|
|
11
|
+
dirName: string;
|
|
12
|
+
fileName: string;
|
|
13
|
+
requiredKeys: string[];
|
|
14
|
+
};
|
|
15
|
+
customRoles: {
|
|
16
|
+
dirName: string;
|
|
17
|
+
fileName: string;
|
|
18
|
+
customRolesLocalesFileName: string;
|
|
19
|
+
};
|
|
20
|
+
environments: {
|
|
21
|
+
dirName: string;
|
|
22
|
+
fileName: string;
|
|
23
|
+
};
|
|
24
|
+
labels: {
|
|
25
|
+
dirName: string;
|
|
26
|
+
fileName: string;
|
|
27
|
+
};
|
|
28
|
+
extensions: {
|
|
29
|
+
dirName: string;
|
|
30
|
+
fileName: string;
|
|
31
|
+
};
|
|
32
|
+
webhooks: {
|
|
33
|
+
dirName: string;
|
|
34
|
+
fileName: string;
|
|
35
|
+
};
|
|
36
|
+
releases: {
|
|
37
|
+
dirName: string;
|
|
38
|
+
fileName: string;
|
|
39
|
+
invalidKeys: string[];
|
|
40
|
+
};
|
|
41
|
+
workflows: {
|
|
42
|
+
dirName: string;
|
|
43
|
+
fileName: string;
|
|
44
|
+
invalidKeys: string[];
|
|
45
|
+
};
|
|
46
|
+
assets: {
|
|
47
|
+
dirName: string;
|
|
48
|
+
assetBatchLimit: number;
|
|
49
|
+
publishAssets: boolean;
|
|
50
|
+
fileName: string;
|
|
51
|
+
importSameStructure: boolean;
|
|
52
|
+
uploadAssetsConcurrency: number;
|
|
53
|
+
displayExecutionTime: boolean;
|
|
54
|
+
importFoldersConcurrency: number;
|
|
55
|
+
includeVersionedAssets: boolean;
|
|
56
|
+
host: string;
|
|
57
|
+
folderValidKeys: string[];
|
|
58
|
+
validKeys: string[];
|
|
59
|
+
};
|
|
60
|
+
'assets-old': {
|
|
61
|
+
dirName: string;
|
|
62
|
+
fileName: string;
|
|
63
|
+
limit: number;
|
|
64
|
+
host: string;
|
|
65
|
+
validKeys: string[];
|
|
66
|
+
assetBatchLimit: number;
|
|
67
|
+
uploadAssetsConcurrency: number;
|
|
68
|
+
importFoldersConcurrency: number;
|
|
69
|
+
};
|
|
70
|
+
content_types: {
|
|
71
|
+
dirName: string;
|
|
72
|
+
fileName: string;
|
|
73
|
+
validKeys: string[];
|
|
74
|
+
limit: number;
|
|
75
|
+
};
|
|
76
|
+
entries: {
|
|
77
|
+
dirName: string;
|
|
78
|
+
fileName: string;
|
|
79
|
+
invalidKeys: string[];
|
|
80
|
+
limit: number;
|
|
81
|
+
assetBatchLimit: number;
|
|
82
|
+
};
|
|
83
|
+
globalfields: {
|
|
84
|
+
dirName: string;
|
|
85
|
+
fileName: string;
|
|
86
|
+
validKeys: string[];
|
|
87
|
+
limit: number;
|
|
88
|
+
};
|
|
89
|
+
stack: {
|
|
90
|
+
dirName: string;
|
|
91
|
+
fileName: string;
|
|
92
|
+
};
|
|
93
|
+
marketplace_apps: {
|
|
94
|
+
dirName: string;
|
|
95
|
+
fileName: string;
|
|
96
|
+
};
|
|
97
|
+
masterLocale: {
|
|
98
|
+
dirName: string;
|
|
99
|
+
fileName: string;
|
|
100
|
+
requiredKeys: string[];
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
languagesCode: string[];
|
|
104
|
+
apis: {
|
|
105
|
+
userSession: string;
|
|
106
|
+
locales: string;
|
|
107
|
+
environments: string;
|
|
108
|
+
assets: string;
|
|
109
|
+
content_types: string;
|
|
110
|
+
entries: string;
|
|
111
|
+
extensions: string;
|
|
112
|
+
webhooks: string;
|
|
113
|
+
globalfields: string;
|
|
114
|
+
folders: string;
|
|
115
|
+
stacks: string;
|
|
116
|
+
labels: string;
|
|
117
|
+
};
|
|
118
|
+
updatedModules: string[];
|
|
119
|
+
rateLimit: number;
|
|
120
|
+
preserveStackVersion: boolean;
|
|
121
|
+
entriesPublish: boolean;
|
|
122
|
+
concurrency: number;
|
|
123
|
+
importConcurrency: number;
|
|
124
|
+
fetchConcurrency: number;
|
|
125
|
+
writeConcurrency: number;
|
|
126
|
+
developerHubBaseUrl: string;
|
|
127
|
+
marketplaceAppEncryptionKey: string;
|
|
128
|
+
getEncryptionKeyMaxRetry: number;
|
|
129
|
+
useNewModuleStructure: boolean;
|
|
130
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Modules } from '.';
|
|
2
|
+
import DefaultConfig from './default-config';
|
|
3
|
+
export interface ExternalConfig {
|
|
4
|
+
source_stack?: string;
|
|
5
|
+
data: string;
|
|
6
|
+
fetchConcurrency: number;
|
|
7
|
+
writeConcurrency: number;
|
|
8
|
+
email?: string;
|
|
9
|
+
password?: string;
|
|
10
|
+
}
|
|
11
|
+
export default interface ImportConfig extends DefaultConfig, ExternalConfig {
|
|
12
|
+
contentDir: string;
|
|
13
|
+
data: string;
|
|
14
|
+
management_token?: string;
|
|
15
|
+
apiKey: string;
|
|
16
|
+
forceStopMarketplaceAppsPrompt: boolean;
|
|
17
|
+
auth_token?: string;
|
|
18
|
+
branchName?: string;
|
|
19
|
+
securedAssets?: boolean;
|
|
20
|
+
contentTypes?: string[];
|
|
21
|
+
branches?: branch[];
|
|
22
|
+
branchEnabled?: boolean;
|
|
23
|
+
branchDir?: string;
|
|
24
|
+
moduleName?: Modules;
|
|
25
|
+
master_locale: masterLocale;
|
|
26
|
+
headers?: {
|
|
27
|
+
api_key: string;
|
|
28
|
+
access_token?: string;
|
|
29
|
+
authtoken?: string;
|
|
30
|
+
'X-User-Agent': string;
|
|
31
|
+
};
|
|
32
|
+
access_token?: string;
|
|
33
|
+
isAuthenticated?: boolean;
|
|
34
|
+
importWebhookStatus?: string;
|
|
35
|
+
target_stack?: string;
|
|
36
|
+
singleModuleImport?: boolean;
|
|
37
|
+
useBackedupDir?: string;
|
|
38
|
+
masterLocale: masterLocale;
|
|
39
|
+
backupDir: string;
|
|
40
|
+
backupConcurrency?: number;
|
|
41
|
+
authtoken?: string;
|
|
42
|
+
destinationStackName?: string;
|
|
43
|
+
}
|
|
44
|
+
type branch = {
|
|
45
|
+
uid: string;
|
|
46
|
+
source: string;
|
|
47
|
+
};
|
|
48
|
+
type masterLocale = {
|
|
49
|
+
code: string;
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ContentstackClient } from '@contentstack/cli-utilities';
|
|
2
|
+
import ImportConfig from './import-config';
|
|
3
|
+
export interface AuthOptions {
|
|
4
|
+
contentstackClient: ContentstackClient;
|
|
5
|
+
}
|
|
6
|
+
export interface ContentStackManagementClient {
|
|
7
|
+
contentstackClient: object;
|
|
8
|
+
}
|
|
9
|
+
export interface PrintOptions {
|
|
10
|
+
color?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface InquirePayload {
|
|
13
|
+
type: string;
|
|
14
|
+
name: string;
|
|
15
|
+
message: string;
|
|
16
|
+
choices?: Array<any>;
|
|
17
|
+
transformer?: Function;
|
|
18
|
+
}
|
|
19
|
+
export interface User {
|
|
20
|
+
email: string;
|
|
21
|
+
authtoken: string;
|
|
22
|
+
}
|
|
23
|
+
export type Modules = 'stack' | 'assets' | 'locales' | 'environments' | 'extensions' | 'webhooks' | 'global-fields' | 'entries' | 'content-types' | 'custom-roles' | 'workflows' | 'labels' | 'marketplace-apps';
|
|
24
|
+
export type ModuleClassParams = {
|
|
25
|
+
stackAPIClient: ReturnType<ContentstackClient['stack']>;
|
|
26
|
+
importConfig: ImportConfig;
|
|
27
|
+
moduleName: Modules;
|
|
28
|
+
};
|
|
29
|
+
export { default as DefaultConfig } from './default-config';
|
|
30
|
+
export { default as ImportConfig } from './import-config';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import Bluebird from 'bluebird';
|
|
2
|
+
import { ImportConfig } from 'src/types';
|
|
3
|
+
export declare const uploadAssetHelper: (config: ImportConfig, req: any, fsPath: string, RETRY?: number) => Bluebird<unknown>;
|
|
4
|
+
export declare const lookupAssets: (data: any, mappedAssetUids: string[], mappedAssetUrls: string[], assetUidMapperPath: string[], installedExtensions: string[]) => any;
|