@contentstack/cli-cm-import 1.12.1 → 1.13.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/LICENSE +1 -1
- package/README.md +7 -3
- package/lib/commands/cm/stacks/import.js +11 -3
- package/lib/import/module-importer.d.ts +8 -1
- package/lib/import/module-importer.js +69 -8
- package/lib/import/modules/index.js +24 -11
- package/lib/import/modules/marketplace-apps.d.ts +93 -21
- package/lib/import/modules/marketplace-apps.js +204 -120
- package/lib/import/modules/workflows.js +1 -0
- package/lib/import/modules-js/marketplace-apps.js +3 -2
- package/lib/import/modules-js/workflows.js +1 -0
- package/lib/types/import-config.d.ts +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/marketplace-app.d.ts +54 -0
- package/lib/types/marketplace-app.js +2 -0
- package/lib/utils/asset-helper.js +4 -2
- package/lib/utils/entries-helper.js +2 -4
- package/lib/utils/import-config-handler.js +3 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -4
- package/lib/utils/log.d.ts +2 -0
- package/lib/utils/log.js +4 -3
- package/lib/utils/marketplace-app-helper.d.ts +2 -9
- package/lib/utils/marketplace-app-helper.js +25 -48
- package/oclif.manifest.json +14 -2
- package/package.json +5 -5
package/lib/utils/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { fsUtil } from './file-helper';
|
|
|
5
5
|
export { default as backupHandler } from './backup-handler';
|
|
6
6
|
export { log, unlinkFileLogger } from './logger';
|
|
7
7
|
export { uploadAssetHelper, lookupAssets } from './asset-helper';
|
|
8
|
-
export { getDeveloperHubUrl, getOrgUid, getConfirmationToCreateApps,
|
|
8
|
+
export { getDeveloperHubUrl, getOrgUid, getConfirmationToCreateApps, handleNameConflict, makeRedirectUrlCall, confirmToCloseProcess, getAllStackSpecificApps, ifAppAlreadyExist, } from './marketplace-app-helper';
|
|
9
9
|
export { schemaTemplate, suppressSchemaReference, removeReferenceFields } from './content-type-helper';
|
|
10
10
|
export { lookupExtension } from './extension-helper';
|
|
11
11
|
export { lookupEntries, removeUidsFromJsonRteFields, removeEntryRefsFromJSONRTE, restoreJsonRteEntryRefs, } from './entries-helper';
|
package/lib/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lookUpTerms = exports.lookUpTaxonomy = exports.restoreJsonRteEntryRefs = exports.removeEntryRefsFromJSONRTE = exports.removeUidsFromJsonRteFields = exports.lookupEntries = exports.lookupExtension = exports.removeReferenceFields = exports.suppressSchemaReference = exports.schemaTemplate = exports.
|
|
3
|
+
exports.lookUpTerms = exports.lookUpTaxonomy = exports.restoreJsonRteEntryRefs = exports.removeEntryRefsFromJSONRTE = exports.removeUidsFromJsonRteFields = exports.lookupEntries = exports.lookupExtension = exports.removeReferenceFields = exports.suppressSchemaReference = exports.schemaTemplate = exports.ifAppAlreadyExist = exports.getAllStackSpecificApps = exports.confirmToCloseProcess = exports.makeRedirectUrlCall = exports.handleNameConflict = exports.getConfirmationToCreateApps = exports.getOrgUid = exports.getDeveloperHubUrl = exports.lookupAssets = exports.uploadAssetHelper = exports.unlinkFileLogger = exports.log = exports.backupHandler = exports.fsUtil = exports.fileHelper = exports.setupImportConfig = exports.interactive = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
exports.interactive = tslib_1.__importStar(require("./interactive"));
|
|
6
6
|
var import_config_handler_1 = require("./import-config-handler");
|
|
@@ -20,14 +20,11 @@ var marketplace_app_helper_1 = require("./marketplace-app-helper");
|
|
|
20
20
|
Object.defineProperty(exports, "getDeveloperHubUrl", { enumerable: true, get: function () { return marketplace_app_helper_1.getDeveloperHubUrl; } });
|
|
21
21
|
Object.defineProperty(exports, "getOrgUid", { enumerable: true, get: function () { return marketplace_app_helper_1.getOrgUid; } });
|
|
22
22
|
Object.defineProperty(exports, "getConfirmationToCreateApps", { enumerable: true, get: function () { return marketplace_app_helper_1.getConfirmationToCreateApps; } });
|
|
23
|
-
Object.defineProperty(exports, "createPrivateApp", { enumerable: true, get: function () { return marketplace_app_helper_1.createPrivateApp; } });
|
|
24
23
|
Object.defineProperty(exports, "handleNameConflict", { enumerable: true, get: function () { return marketplace_app_helper_1.handleNameConflict; } });
|
|
25
|
-
Object.defineProperty(exports, "installApp", { enumerable: true, get: function () { return marketplace_app_helper_1.installApp; } });
|
|
26
24
|
Object.defineProperty(exports, "makeRedirectUrlCall", { enumerable: true, get: function () { return marketplace_app_helper_1.makeRedirectUrlCall; } });
|
|
27
25
|
Object.defineProperty(exports, "confirmToCloseProcess", { enumerable: true, get: function () { return marketplace_app_helper_1.confirmToCloseProcess; } });
|
|
28
26
|
Object.defineProperty(exports, "getAllStackSpecificApps", { enumerable: true, get: function () { return marketplace_app_helper_1.getAllStackSpecificApps; } });
|
|
29
27
|
Object.defineProperty(exports, "ifAppAlreadyExist", { enumerable: true, get: function () { return marketplace_app_helper_1.ifAppAlreadyExist; } });
|
|
30
|
-
Object.defineProperty(exports, "updateAppConfig", { enumerable: true, get: function () { return marketplace_app_helper_1.updateAppConfig; } });
|
|
31
28
|
var content_type_helper_1 = require("./content-type-helper");
|
|
32
29
|
Object.defineProperty(exports, "schemaTemplate", { enumerable: true, get: function () { return content_type_helper_1.schemaTemplate; } });
|
|
33
30
|
Object.defineProperty(exports, "suppressSchemaReference", { enumerable: true, get: function () { return content_type_helper_1.suppressSchemaReference; } });
|
package/lib/utils/log.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ import { LogEntry } from 'winston/index';
|
|
|
2
2
|
import { Logger } from '@contentstack/cli-utilities';
|
|
3
3
|
import { LogsType, MessageType } from '@contentstack/cli-utilities/lib/logger';
|
|
4
4
|
import { ImportConfig } from '../types';
|
|
5
|
+
declare let logger: Logger;
|
|
5
6
|
export declare function isImportConfig(config: ImportConfig | MessageType): config is ImportConfig;
|
|
6
7
|
export declare function log(entry: LogEntry): void;
|
|
7
8
|
export declare function log(error: MessageType, logType: LogsType): void;
|
|
8
9
|
export declare function log(error: MessageType, logType: 'error', hidden: boolean): void;
|
|
9
10
|
export declare function initLogger(config?: ImportConfig | undefined): Logger;
|
|
11
|
+
export { logger };
|
|
10
12
|
export declare const trace: typeof log;
|
package/lib/utils/log.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.trace = exports.initLogger = exports.log = exports.isImportConfig = void 0;
|
|
3
|
+
exports.trace = exports.logger = exports.initLogger = exports.log = exports.isImportConfig = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
6
|
let logger;
|
|
7
|
+
exports.logger = logger;
|
|
7
8
|
function isImportConfig(config) {
|
|
8
9
|
return config.data !== undefined && (config === null || config === void 0 ? void 0 : config.contentVersion) !== undefined;
|
|
9
10
|
}
|
|
10
11
|
exports.isImportConfig = isImportConfig;
|
|
11
12
|
function log(entryOrMessage, logType, hidden) {
|
|
12
|
-
logger = initLogger();
|
|
13
|
+
exports.logger = logger = initLogger();
|
|
13
14
|
if (logType === 'error') {
|
|
14
15
|
logger.log(entryOrMessage, logType, hidden);
|
|
15
16
|
}
|
|
@@ -22,7 +23,7 @@ function initLogger(config) {
|
|
|
22
23
|
var _a;
|
|
23
24
|
if (!logger) {
|
|
24
25
|
const basePath = (0, path_1.join)((_a = config === null || config === void 0 ? void 0 : config.data) !== null && _a !== void 0 ? _a : process.cwd(), 'logs', 'import');
|
|
25
|
-
logger = new cli_utilities_1.Logger(Object.assign(config !== null && config !== void 0 ? config : {}, { basePath }));
|
|
26
|
+
exports.logger = logger = new cli_utilities_1.Logger(Object.assign(config !== null && config !== void 0 ? config : {}, { basePath }));
|
|
26
27
|
}
|
|
27
28
|
return logger;
|
|
28
29
|
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const getAllStackSpecificApps: (developerHubBaseUrl: string, httpClient: HttpClient, config: ImportConfig) => Promise<any>;
|
|
1
|
+
import { ImportConfig, Installation } from '../types';
|
|
2
|
+
export declare const getAllStackSpecificApps: (config: ImportConfig, skip?: number, listOfApps?: Installation[]) => Promise<Installation[]>;
|
|
4
3
|
export declare const getDeveloperHubUrl: (config: ImportConfig) => Promise<string>;
|
|
5
4
|
export declare const getOrgUid: (config: ImportConfig) => Promise<string>;
|
|
6
5
|
export declare const getConfirmationToCreateApps: (privateApps: any, config: ImportConfig) => Promise<boolean>;
|
|
7
|
-
export declare const createPrivateApp: (client: ContentstackClient, config: ImportConfig, app: any) => Promise<any>;
|
|
8
|
-
export declare const installApp: (client: ContentstackClient, config: ImportConfig, appManifestUid?: string, mappedUid?: string) => Promise<any>;
|
|
9
6
|
export declare const handleNameConflict: (app: any, appSuffix: number, config: ImportConfig) => Promise<any>;
|
|
10
7
|
export declare const makeRedirectUrlCall: (response: any, appName: string, config: ImportConfig) => Promise<void>;
|
|
11
8
|
export declare const confirmToCloseProcess: (installation: any, config: ImportConfig) => Promise<void>;
|
|
12
9
|
export declare const ifAppAlreadyExist: (app: any, currentStackApp: any, config: ImportConfig) => Promise<{}>;
|
|
13
|
-
export declare const updateAppConfig: (client: ContentstackClient, config: ImportConfig, app: any, payload: {
|
|
14
|
-
configuration: Record<string, unknown>;
|
|
15
|
-
server_configuration: Record<string, unknown>;
|
|
16
|
-
}) => Promise<any>;
|
|
@@ -1,33 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ifAppAlreadyExist = exports.confirmToCloseProcess = exports.makeRedirectUrlCall = exports.handleNameConflict = exports.getConfirmationToCreateApps = exports.getOrgUid = exports.getDeveloperHubUrl = exports.getAllStackSpecificApps = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
6
|
const map_1 = tslib_1.__importDefault(require("lodash/map"));
|
|
7
|
-
const
|
|
7
|
+
const omitBy_1 = tslib_1.__importDefault(require("lodash/omitBy"));
|
|
8
|
+
const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
8
9
|
const includes_1 = tslib_1.__importDefault(require("lodash/includes"));
|
|
9
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
10
10
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
11
11
|
const logger_1 = require("./logger");
|
|
12
12
|
const log_1 = require("../utils/log");
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
14
|
const interactive_1 = require("./interactive");
|
|
15
15
|
const interactive_2 = require("../utils/interactive");
|
|
16
|
-
const getAllStackSpecificApps = async (
|
|
17
|
-
const
|
|
18
|
-
host: developerHubBaseUrl.split('://').pop(),
|
|
16
|
+
const getAllStackSpecificApps = async (config, skip = 0, listOfApps = []) => {
|
|
17
|
+
const appSdk = await (0, cli_utilities_1.marketplaceSDKClient)({
|
|
18
|
+
host: config.developerHubBaseUrl.split('://').pop(),
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
})
|
|
26
|
-
.then(({ data }) => data.data)
|
|
20
|
+
const collection = await appSdk
|
|
21
|
+
.marketplace(config.org_uid)
|
|
22
|
+
.installation()
|
|
23
|
+
.fetchAll({ target_uids: config.target_stack, skip })
|
|
27
24
|
.catch((error) => {
|
|
28
25
|
(0, log_1.trace)(error, 'error', true);
|
|
29
26
|
(0, logger_1.log)(config, `Failed to export marketplace-apps ${(0, utils_1.formatError)(error)}`, 'error');
|
|
30
27
|
});
|
|
28
|
+
if (collection) {
|
|
29
|
+
const { items: apps, count } = collection;
|
|
30
|
+
// NOTE Remove all the chain functions
|
|
31
|
+
const installation = (0, map_1.default)(apps, (app) => (0, omitBy_1.default)(app, (val, _key) => {
|
|
32
|
+
if (val instanceof Function)
|
|
33
|
+
return true;
|
|
34
|
+
return false;
|
|
35
|
+
}));
|
|
36
|
+
listOfApps = listOfApps.concat(installation);
|
|
37
|
+
if (count - (skip + 50) > 0) {
|
|
38
|
+
return await (0, exports.getAllStackSpecificApps)(config, skip + 50, listOfApps);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return listOfApps;
|
|
31
42
|
};
|
|
32
43
|
exports.getAllStackSpecificApps = getAllStackSpecificApps;
|
|
33
44
|
const getDeveloperHubUrl = async (config) => {
|
|
@@ -64,24 +75,6 @@ const getConfirmationToCreateApps = async (privateApps, config) => {
|
|
|
64
75
|
}
|
|
65
76
|
};
|
|
66
77
|
exports.getConfirmationToCreateApps = getConfirmationToCreateApps;
|
|
67
|
-
const createPrivateApp = async (client, config, app) => {
|
|
68
|
-
const privateApp = (0, omit_1.default)(app, ['uid']);
|
|
69
|
-
return await client
|
|
70
|
-
.organization(config.org_uid)
|
|
71
|
-
.app()
|
|
72
|
-
.create(privateApp)
|
|
73
|
-
.catch((error) => error);
|
|
74
|
-
};
|
|
75
|
-
exports.createPrivateApp = createPrivateApp;
|
|
76
|
-
const installApp = async (client, config, appManifestUid, mappedUid) => {
|
|
77
|
-
const appUid = mappedUid || appManifestUid;
|
|
78
|
-
return await client
|
|
79
|
-
.organization(config.org_uid)
|
|
80
|
-
.app(appUid)
|
|
81
|
-
.install({ targetUid: config.target_stack, targetType: 'stack' })
|
|
82
|
-
.catch((error) => error);
|
|
83
|
-
};
|
|
84
|
-
exports.installApp = installApp;
|
|
85
78
|
const handleNameConflict = async (app, appSuffix, config) => {
|
|
86
79
|
const appName = config.forceStopMarketplaceAppsPrompt
|
|
87
80
|
? (0, interactive_2.getAppName)(app.name, appSuffix)
|
|
@@ -142,19 +135,3 @@ const ifAppAlreadyExist = async (app, currentStackApp, config) => {
|
|
|
142
135
|
return updateParam;
|
|
143
136
|
};
|
|
144
137
|
exports.ifAppAlreadyExist = ifAppAlreadyExist;
|
|
145
|
-
const updateAppConfig = async (client, config, app, payload) => {
|
|
146
|
-
var _a;
|
|
147
|
-
let installation = client.organization(config.org_uid).app((_a = app === null || app === void 0 ? void 0 : app.manifest) === null || _a === void 0 ? void 0 : _a.uid).installation(app === null || app === void 0 ? void 0 : app.uid);
|
|
148
|
-
installation = Object.assign(installation, payload);
|
|
149
|
-
return await installation
|
|
150
|
-
.update()
|
|
151
|
-
.then((data) => {
|
|
152
|
-
var _a;
|
|
153
|
-
(0, logger_1.log)(config, `${(_a = app === null || app === void 0 ? void 0 : app.manifest) === null || _a === void 0 ? void 0 : _a.name} app config updated successfully.!`, 'success');
|
|
154
|
-
})
|
|
155
|
-
.catch((error) => {
|
|
156
|
-
(0, log_1.trace)(error, 'error', true);
|
|
157
|
-
(0, logger_1.log)(config, `Failed to update app config.${(0, utils_1.formatError)(error)}`, 'error');
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
exports.updateAppConfig = updateAppConfig;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.13.0",
|
|
3
3
|
"commands": {
|
|
4
4
|
"cm:stacks:import": {
|
|
5
5
|
"id": "cm:stacks:import",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"csdx cm:stacks:import --alias <management_token_alias>",
|
|
21
21
|
"csdx cm:stacks:import --alias <management_token_alias> --data-dir <path/of/export/destination/dir>",
|
|
22
22
|
"csdx cm:stacks:import --alias <management_token_alias> --config <path/of/config/file>",
|
|
23
|
-
"csdx cm:stacks:import --branch <branch name> --yes"
|
|
23
|
+
"csdx cm:stacks:import --branch <branch name> --yes --skip-audit"
|
|
24
24
|
],
|
|
25
25
|
"flags": {
|
|
26
26
|
"config": {
|
|
@@ -123,6 +123,12 @@
|
|
|
123
123
|
"required": false,
|
|
124
124
|
"allowNo": false
|
|
125
125
|
},
|
|
126
|
+
"skip-app-recreation": {
|
|
127
|
+
"name": "skip-app-recreation",
|
|
128
|
+
"type": "boolean",
|
|
129
|
+
"description": "[optional] Skip private apps recreation if already exist",
|
|
130
|
+
"allowNo": false
|
|
131
|
+
},
|
|
126
132
|
"replace-existing": {
|
|
127
133
|
"name": "replace-existing",
|
|
128
134
|
"type": "boolean",
|
|
@@ -136,6 +142,12 @@
|
|
|
136
142
|
"description": "Skips the module exists warning messages.",
|
|
137
143
|
"required": false,
|
|
138
144
|
"allowNo": false
|
|
145
|
+
},
|
|
146
|
+
"skip-audit": {
|
|
147
|
+
"name": "skip-audit",
|
|
148
|
+
"type": "boolean",
|
|
149
|
+
"description": "Skips the audit fix.",
|
|
150
|
+
"allowNo": false
|
|
139
151
|
}
|
|
140
152
|
},
|
|
141
153
|
"args": {}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-import",
|
|
3
3
|
"description": "Contentstack CLI plugin to import content into stack",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.13.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"@contentstack/cli-audit": "^1.3.2",
|
|
8
9
|
"@contentstack/cli-command": "~1.2.16",
|
|
9
|
-
"@contentstack/cli-utilities": "~1.5.
|
|
10
|
-
"@contentstack/management": "~1.
|
|
10
|
+
"@contentstack/cli-utilities": "~1.5.10",
|
|
11
|
+
"@contentstack/management": "~1.13.0",
|
|
11
12
|
"@oclif/core": "^2.9.3",
|
|
12
|
-
"axios": "^1.6.0",
|
|
13
13
|
"big-json": "^3.2.0",
|
|
14
14
|
"bluebird": "^3.7.2",
|
|
15
15
|
"chalk": "^4.1.2",
|
|
@@ -99,4 +99,4 @@
|
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
"repository": "https://github.com/contentstack/cli"
|
|
102
|
-
}
|
|
102
|
+
}
|