@contentstack/cli-cm-import 1.16.1 → 1.16.3
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
CHANGED
|
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
|
|
|
47
47
|
$ csdx COMMAND
|
|
48
48
|
running command...
|
|
49
49
|
$ csdx (--version)
|
|
50
|
-
@contentstack/cli-cm-import/1.16.
|
|
50
|
+
@contentstack/cli-cm-import/1.16.3 linux-x64 node-v18.20.4
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -15,6 +15,7 @@ export default class ImportMarketplaceApps {
|
|
|
15
15
|
developerHubBaseUrl: string;
|
|
16
16
|
nodeCrypto: NodeCrypto;
|
|
17
17
|
appSdk: ContentstackMarketplaceClient;
|
|
18
|
+
existingNames: Set<string>;
|
|
18
19
|
constructor({ importConfig }: ModuleClassParams);
|
|
19
20
|
/**
|
|
20
21
|
* This function starts the process of importing marketplace apps.
|
|
@@ -28,6 +28,7 @@ class ImportMarketplaceApps {
|
|
|
28
28
|
this.appOriginalName = undefined;
|
|
29
29
|
this.installedApps = [];
|
|
30
30
|
this.installationUidMapping = {};
|
|
31
|
+
this.existingNames = new Set();
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* This function starts the process of importing marketplace apps.
|
|
@@ -269,14 +270,14 @@ class ImportMarketplaceApps {
|
|
|
269
270
|
if (location.meta) {
|
|
270
271
|
location.meta = (0, map_1.default)(location.meta, (meta) => {
|
|
271
272
|
if (meta.name && this.appOriginalName == meta.name) {
|
|
272
|
-
const name = (0, interactive_1.
|
|
273
|
+
const name = (0, interactive_1.getLocationName)((0, first_1.default)((0, split_1.default)(meta.name, '◈')), appSuffix, this.existingNames);
|
|
273
274
|
if (!this.appNameMapping[this.appOriginalName]) {
|
|
274
275
|
this.appNameMapping[this.appOriginalName] = name;
|
|
275
276
|
}
|
|
276
277
|
meta.name = name;
|
|
277
278
|
}
|
|
278
279
|
else if (meta.name) {
|
|
279
|
-
meta.name = (0, interactive_1.
|
|
280
|
+
meta.name = (0, interactive_1.getLocationName)((0, first_1.default)((0, split_1.default)(meta.name, '◈')), appSuffix + (+index + 1), this.existingNames);
|
|
280
281
|
}
|
|
281
282
|
return meta;
|
|
282
283
|
});
|
|
@@ -3,4 +3,5 @@ export declare const askAPIKey: () => Promise<string>;
|
|
|
3
3
|
export declare const askEncryptionKey: (defaultValue: unknown) => Promise<string>;
|
|
4
4
|
export declare const askAppName: (app: any, appSuffix: number) => Promise<string>;
|
|
5
5
|
export declare const getAppName: (name: string, appSuffix?: number) => string;
|
|
6
|
+
export declare const getLocationName: (name: string, appSuffix: number, existingNames: Set<string>) => string;
|
|
6
7
|
export declare const selectConfiguration: () => 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.selectConfiguration = exports.getAppName = exports.askAppName = exports.askEncryptionKey = exports.askAPIKey = exports.askContentDir = void 0;
|
|
3
|
+
exports.selectConfiguration = exports.getLocationName = exports.getAppName = exports.askAppName = exports.askEncryptionKey = exports.askAPIKey = exports.askContentDir = 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"));
|
|
@@ -56,6 +56,24 @@ const getAppName = (name, appSuffix = 1) => {
|
|
|
56
56
|
return name;
|
|
57
57
|
};
|
|
58
58
|
exports.getAppName = getAppName;
|
|
59
|
+
const getLocationName = (name, appSuffix = 1, existingNames) => {
|
|
60
|
+
const maxLength = 50;
|
|
61
|
+
const suffixLength = appSuffix.toString().length + 1; // +1 for the '◈' character
|
|
62
|
+
let truncatedName = name;
|
|
63
|
+
if (name.length + suffixLength > maxLength) {
|
|
64
|
+
truncatedName = name.slice(0, maxLength - suffixLength);
|
|
65
|
+
}
|
|
66
|
+
let newName = `${(0, first_1.default)((0, split_1.default)(truncatedName, '◈'))}◈${appSuffix}`;
|
|
67
|
+
// Ensure uniqueness
|
|
68
|
+
while (existingNames.has(newName)) {
|
|
69
|
+
appSuffix++;
|
|
70
|
+
newName = `${(0, first_1.default)((0, split_1.default)(truncatedName, '◈'))}◈${appSuffix}`;
|
|
71
|
+
}
|
|
72
|
+
// Add the new name to the set of existing names
|
|
73
|
+
existingNames.add(newName);
|
|
74
|
+
return newName;
|
|
75
|
+
};
|
|
76
|
+
exports.getLocationName = getLocationName;
|
|
59
77
|
const validateAppName = (name) => {
|
|
60
78
|
if (name.length < 3 || name.length > 20) {
|
|
61
79
|
return 'The app name should be within 3-20 characters long.';
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-import",
|
|
3
3
|
"description": "Contentstack CLI plugin to import content into stack",
|
|
4
|
-
"version": "1.16.
|
|
4
|
+
"version": "1.16.3",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@contentstack/cli-audit": "~1.6.3",
|
|
9
|
-
"@contentstack/cli-command": "~1.2.
|
|
10
|
-
"@contentstack/cli-utilities": "~1.
|
|
9
|
+
"@contentstack/cli-command": "~1.2.19",
|
|
10
|
+
"@contentstack/cli-utilities": "~1.7.0",
|
|
11
11
|
"@contentstack/management": "~1.15.3",
|
|
12
12
|
"@oclif/core": "^3.26.5",
|
|
13
13
|
"big-json": "^3.2.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"mkdirp": "^1.0.4",
|
|
22
22
|
"promise-limit": "^2.7.0",
|
|
23
23
|
"tslib": "^2.4.1",
|
|
24
|
-
"uuid": "^9.0.
|
|
24
|
+
"uuid": "^9.0.1",
|
|
25
25
|
"winston": "^3.7.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|