Skip to content

Commit 25f0dd7

Browse files
authored
Merge pull request #1492 from contentstack/staging
DX | 02-08-2024 | Hotfix
2 parents e4d1ac3 + cbbf71e commit 25f0dd7

10 files changed

Lines changed: 50 additions & 25 deletions

File tree

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-clone/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"@colors/colors": "^1.5.0",
99
"@contentstack/cli-cm-export": "~1.11.6",
10-
"@contentstack/cli-cm-import": "~1.16.2",
10+
"@contentstack/cli-cm-import": "~1.16.3",
1111
"@contentstack/cli-command": "~1.2.19",
1212
"@contentstack/cli-utilities": "~1.7.0",
1313
"async": "^3.2.4",

packages/contentstack-import/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
4747
$ csdx COMMAND
4848
running command...
4949
$ csdx (--version)
50-
@contentstack/cli-cm-import/1.16.2 darwin-arm64 node-v22.2.0
50+
@contentstack/cli-cm-import/1.16.3 darwin-arm64 node-v22.2.0
5151
$ csdx --help [COMMAND]
5252
USAGE
5353
$ csdx COMMAND

packages/contentstack-import/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-import",
33
"description": "Contentstack CLI plugin to import content into stack",
4-
"version": "1.16.2",
4+
"version": "1.16.3",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {

packages/contentstack-import/src/import/modules/marketplace-apps.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from '@contentstack/cli-utilities';
2020

2121
import { trace } from '../../utils/log';
22-
import { askEncryptionKey, getAppName } from '../../utils/interactive';
22+
import { askEncryptionKey, getLocationName } from '../../utils/interactive';
2323
import { ModuleClassParams, MarketplaceAppsConfig, ImportConfig, Installation, Manifest } from '../../types';
2424
import {
2525
log,
@@ -51,6 +51,7 @@ export default class ImportMarketplaceApps {
5151
public developerHubBaseUrl: string;
5252
public nodeCrypto: NodeCrypto;
5353
public appSdk: ContentstackMarketplaceClient;
54+
public existingNames: Set<string>;
5455

5556
constructor({ importConfig }: ModuleClassParams) {
5657
this.importConfig = importConfig;
@@ -63,6 +64,7 @@ export default class ImportMarketplaceApps {
6364
this.appOriginalName = undefined;
6465
this.installedApps = [];
6566
this.installationUidMapping = {};
67+
this.existingNames = new Set<string>();
6668
}
6769

6870
/**
@@ -346,15 +348,15 @@ export default class ImportMarketplaceApps {
346348
if (location.meta) {
347349
location.meta = map(location.meta, (meta) => {
348350
if (meta.name && this.appOriginalName == meta.name) {
349-
const name = getAppName(first(split(meta.name, '◈')), appSuffix);
351+
const name = getLocationName(first(split(meta.name, '◈')), appSuffix, this.existingNames);
350352

351353
if (!this.appNameMapping[this.appOriginalName]) {
352354
this.appNameMapping[this.appOriginalName] = name;
353355
}
354356

355357
meta.name = name;
356358
} else if (meta.name) {
357-
meta.name = getAppName(first(split(meta.name, '◈')), appSuffix + (+index + 1));
359+
meta.name = getLocationName(first(split(meta.name, '◈')), appSuffix + (+index + 1), this.existingNames);
358360
}
359361

360362
return meta;

packages/contentstack-import/src/utils/interactive.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ export const getAppName= (name: string, appSuffix = 1) => {
5353
return name;
5454
}
5555

56+
export const getLocationName= (name: string, appSuffix = 1, existingNames: Set<string>) => {
57+
const maxLength = 50;
58+
const suffixLength = appSuffix.toString().length + 1; // +1 for the '◈' character
59+
60+
let truncatedName = name;
61+
if (name.length + suffixLength > maxLength) {
62+
truncatedName = name.slice(0, maxLength - suffixLength);
63+
}
64+
65+
let newName = `${first(split(truncatedName, '◈'))}${appSuffix}`;
66+
67+
// Ensure uniqueness
68+
while (existingNames.has(newName)) {
69+
appSuffix++;
70+
newName = `${first(split(truncatedName, '◈'))}${appSuffix}`;
71+
}
72+
73+
// Add the new name to the set of existing names
74+
existingNames.add(newName);
75+
76+
return newName;
77+
}
78+
5679
const validateAppName =(name: string ) =>{
5780
if (name.length < 3 || name.length > 20) {
5881
return 'The app name should be within 3-20 characters long.';

packages/contentstack-seed/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {
8-
"@contentstack/cli-cm-import": "~1.16.2",
8+
"@contentstack/cli-cm-import": "~1.16.3",
99
"@contentstack/cli-command": "~1.2.19",
1010
"@contentstack/cli-utilities": "~1.7.0",
1111
"inquirer": "8.2.4",

packages/contentstack/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli
1818
$ csdx COMMAND
1919
running command...
2020
$ csdx (--version|-v)
21-
@contentstack/cli/1.21.0 darwin-arm64 node-v22.2.0
21+
@contentstack/cli/1.21.1 darwin-arm64 node-v22.2.0
2222
$ csdx --help [COMMAND]
2323
USAGE
2424
$ csdx COMMAND
@@ -3498,7 +3498,7 @@ EXAMPLES
34983498
$ csdx plugins
34993499
```
35003500

3501-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/index.ts)_
3501+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.9/src/commands/plugins/index.ts)_
35023502

35033503
## `csdx plugins:add PLUGIN`
35043504

@@ -3572,7 +3572,7 @@ EXAMPLES
35723572
$ csdx plugins:inspect myplugin
35733573
```
35743574

3575-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/inspect.ts)_
3575+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.9/src/commands/plugins/inspect.ts)_
35763576

35773577
## `csdx plugins:install PLUGIN`
35783578

@@ -3621,7 +3621,7 @@ EXAMPLES
36213621
$ csdx plugins:install someuser/someplugin
36223622
```
36233623

3624-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/install.ts)_
3624+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.9/src/commands/plugins/install.ts)_
36253625

36263626
## `csdx plugins:link PATH`
36273627

@@ -3651,7 +3651,7 @@ EXAMPLES
36513651
$ csdx plugins:link myplugin
36523652
```
36533653

3654-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/link.ts)_
3654+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.9/src/commands/plugins/link.ts)_
36553655

36563656
## `csdx plugins:remove [PLUGIN]`
36573657

@@ -3692,7 +3692,7 @@ FLAGS
36923692
--reinstall Reinstall all plugins after uninstalling.
36933693
```
36943694

3695-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/reset.ts)_
3695+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.9/src/commands/plugins/reset.ts)_
36963696

36973697
## `csdx plugins:uninstall [PLUGIN]`
36983698

@@ -3720,7 +3720,7 @@ EXAMPLES
37203720
$ csdx plugins:uninstall myplugin
37213721
```
37223722

3723-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/uninstall.ts)_
3723+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.9/src/commands/plugins/uninstall.ts)_
37243724

37253725
## `csdx plugins:unlink [PLUGIN]`
37263726

@@ -3764,7 +3764,7 @@ DESCRIPTION
37643764
Update installed plugins.
37653765
```
37663766

3767-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/update.ts)_
3767+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.9/src/commands/plugins/update.ts)_
37683768

37693769
## `csdx tokens`
37703770

packages/contentstack/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli",
33
"description": "Command-line tool (CLI) to interact with Contentstack",
4-
"version": "1.21.0",
4+
"version": "1.21.1",
55
"author": "Contentstack",
66
"bin": {
77
"csdx": "./bin/run.js"
@@ -30,7 +30,7 @@
3030
"@contentstack/cli-cm-export": "~1.11.6",
3131
"@contentstack/cli-cm-clone": "~1.10.7",
3232
"@contentstack/cli-cm-export-to-csv": "~1.7.2",
33-
"@contentstack/cli-cm-import": "~1.16.2",
33+
"@contentstack/cli-cm-import": "~1.16.3",
3434
"@contentstack/cli-cm-migrate-rte": "~1.4.18",
3535
"@contentstack/cli-cm-seed": "~1.7.7",
3636
"@contentstack/cli-command": "~1.2.19",

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)