@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
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
content_type: {
|
|
3
|
-
title: 'Seed',
|
|
4
|
-
uid: '',
|
|
5
|
-
schema: [
|
|
6
|
-
{
|
|
7
|
-
display_name: 'Title',
|
|
8
|
-
uid: 'title',
|
|
9
|
-
data_type: 'text',
|
|
10
|
-
field_metadata: {
|
|
11
|
-
_default: true,
|
|
12
|
-
},
|
|
13
|
-
unique: false,
|
|
14
|
-
mandatory: true,
|
|
15
|
-
multiple: false,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
display_name: 'URL',
|
|
19
|
-
uid: 'url',
|
|
20
|
-
data_type: 'text',
|
|
21
|
-
field_metadata: {
|
|
22
|
-
_default: true,
|
|
23
|
-
},
|
|
24
|
-
unique: false,
|
|
25
|
-
multiple: false,
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
options: {
|
|
29
|
-
title: 'title',
|
|
30
|
-
publishable: true,
|
|
31
|
-
is_page: true,
|
|
32
|
-
singleton: false,
|
|
33
|
-
sub_title: ['url'],
|
|
34
|
-
url_pattern: '/:title',
|
|
35
|
-
url_prefix: '/',
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Contentstack Import
|
|
3
|
-
* Copyright (c) 2019 Contentstack LLC
|
|
4
|
-
* MIT Licensed
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
var supress = (module.exports = function (schema, flag) {
|
|
8
|
-
for (var i in schema) {
|
|
9
|
-
if (schema[i].data_type === 'group' || schema[i].data_type === 'global_field') {
|
|
10
|
-
supress(schema[i].schema, flag);
|
|
11
|
-
} else if (schema[i].data_type === 'blocks') {
|
|
12
|
-
for (var block in schema[i].blocks) {
|
|
13
|
-
supress(schema[i].blocks[block].schema, flag);
|
|
14
|
-
}
|
|
15
|
-
} else if (schema[i].data_type === 'reference') {
|
|
16
|
-
flag.references = true;
|
|
17
|
-
} else if (schema[i].data_type === 'json' && schema[i].field_metadata.rich_text_type) {
|
|
18
|
-
flag.jsonRte = true
|
|
19
|
-
if (schema[i].field_metadata.embed_entry === true)
|
|
20
|
-
flag.jsonRteEmbeddedEntries = true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
(schema[i].hasOwnProperty('mandatory') && schema[i].mandatory) ||
|
|
25
|
-
(schema[i].hasOwnProperty('unique') && schema[i].unique)
|
|
26
|
-
) {
|
|
27
|
-
if (schema[i].uid !== 'title') {
|
|
28
|
-
schema[i].unique = false;
|
|
29
|
-
schema[i].mandatory = false;
|
|
30
|
-
flag.suppressed = true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
package/src/lib/util/upload.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Contentstack Import
|
|
3
|
-
* Copyright (c) 2019 Contentstack LLC
|
|
4
|
-
* MIT Licensed
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
const debug = require('debug')('util:requests');
|
|
10
|
-
const MAX_RETRY_LIMIT = 5;
|
|
11
|
-
const Bluebird = require('bluebird');
|
|
12
|
-
|
|
13
|
-
const util = require('./index');
|
|
14
|
-
const config = util.getConfig();
|
|
15
|
-
const { managementSDKClient } = require('@contentstack/cli-utilities');
|
|
16
|
-
|
|
17
|
-
function validate(req) {
|
|
18
|
-
if (typeof req !== 'object') {
|
|
19
|
-
throw new Error(`Invalid params passed for request\n${JSON.stringify(arguments)}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const upload = (module.exports = function (req, fsPath, RETRY) {
|
|
24
|
-
return new Bluebird(function (resolve, reject) {
|
|
25
|
-
try {
|
|
26
|
-
managementSDKClient(config)
|
|
27
|
-
.then((APIClient) => {
|
|
28
|
-
validate(req);
|
|
29
|
-
if (typeof RETRY !== 'number') {
|
|
30
|
-
RETRY = 1;
|
|
31
|
-
} else if (RETRY > MAX_RETRY_LIMIT) {
|
|
32
|
-
return reject(new Error('Max retry limit exceeded!'));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
req.upload = fsPath;
|
|
36
|
-
const stackAPIClient = APIClient.stack({
|
|
37
|
-
api_key: config.target_stack,
|
|
38
|
-
management_token: config.management_token,
|
|
39
|
-
});
|
|
40
|
-
stackAPIClient
|
|
41
|
-
.asset()
|
|
42
|
-
.create(req)
|
|
43
|
-
.then((response) => {
|
|
44
|
-
return resolve(response);
|
|
45
|
-
})
|
|
46
|
-
.catch((error) => {
|
|
47
|
-
return reject(error);
|
|
48
|
-
});
|
|
49
|
-
})
|
|
50
|
-
.catch(reject);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
debug(error);
|
|
53
|
-
return reject(error);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|