Skip to content

Commit

Permalink
Merge pull request #1492 from contentstack/staging
Browse files Browse the repository at this point in the history
DX | 02-08-2024 | Hotfix
  • Loading branch information
cs-raj authored Aug 2, 2024
2 parents c7e2ed9 + e0402ff commit f68b973
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 25 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@colors/colors": "^1.5.0",
"@contentstack/cli-cm-export": "~1.11.6",
"@contentstack/cli-cm-import": "~1.16.2",
"@contentstack/cli-cm-import": "~1.16.3",
"@contentstack/cli-command": "~1.2.19",
"@contentstack/cli-utilities": "~1.7.0",
"async": "^3.2.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-import/1.16.2 darwin-arm64 node-v22.2.0
@contentstack/cli-cm-import/1.16.3 darwin-arm64 node-v22.2.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-import",
"description": "Contentstack CLI plugin to import content into stack",
"version": "1.16.2",
"version": "1.16.3",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '@contentstack/cli-utilities';

import { trace } from '../../utils/log';
import { askEncryptionKey, getAppName } from '../../utils/interactive';
import { askEncryptionKey, getLocationName } from '../../utils/interactive';
import { ModuleClassParams, MarketplaceAppsConfig, ImportConfig, Installation, Manifest } from '../../types';
import {
log,
Expand Down Expand Up @@ -51,6 +51,7 @@ export default class ImportMarketplaceApps {
public developerHubBaseUrl: string;
public nodeCrypto: NodeCrypto;
public appSdk: ContentstackMarketplaceClient;
public existingNames: Set<string>;

constructor({ importConfig }: ModuleClassParams) {
this.importConfig = importConfig;
Expand All @@ -63,6 +64,7 @@ export default class ImportMarketplaceApps {
this.appOriginalName = undefined;
this.installedApps = [];
this.installationUidMapping = {};
this.existingNames = new Set<string>();
}

/**
Expand Down Expand Up @@ -346,15 +348,15 @@ export default class ImportMarketplaceApps {
if (location.meta) {
location.meta = map(location.meta, (meta) => {
if (meta.name && this.appOriginalName == meta.name) {
const name = getAppName(first(split(meta.name, '◈')), appSuffix);
const name = getLocationName(first(split(meta.name, '◈')), appSuffix, this.existingNames);

if (!this.appNameMapping[this.appOriginalName]) {
this.appNameMapping[this.appOriginalName] = name;
}

meta.name = name;
} else if (meta.name) {
meta.name = getAppName(first(split(meta.name, '◈')), appSuffix + (+index + 1));
meta.name = getLocationName(first(split(meta.name, '◈')), appSuffix + (+index + 1), this.existingNames);
}

return meta;
Expand Down
23 changes: 23 additions & 0 deletions packages/contentstack-import/src/utils/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@ export const getAppName= (name: string, appSuffix = 1) => {
return name;
}

export const getLocationName= (name: string, appSuffix = 1, existingNames: Set<string>) => {
const maxLength = 50;
const suffixLength = appSuffix.toString().length + 1; // +1 for the '◈' character

let truncatedName = name;
if (name.length + suffixLength > maxLength) {
truncatedName = name.slice(0, maxLength - suffixLength);
}

let newName = `${first(split(truncatedName, '◈'))}${appSuffix}`;

// Ensure uniqueness
while (existingNames.has(newName)) {
appSuffix++;
newName = `${first(split(truncatedName, '◈'))}${appSuffix}`;
}

// Add the new name to the set of existing names
existingNames.add(newName);

return newName;
}

const validateAppName =(name: string ) =>{
if (name.length < 3 || name.length > 20) {
return 'The app name should be within 3-20 characters long.';
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-seed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-cm-import": "~1.16.2",
"@contentstack/cli-cm-import": "~1.16.3",
"@contentstack/cli-command": "~1.2.19",
"@contentstack/cli-utilities": "~1.7.0",
"inquirer": "8.2.4",
Expand Down
16 changes: 8 additions & 8 deletions packages/contentstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli/1.21.0 darwin-arm64 node-v22.2.0
@contentstack/cli/1.21.1 darwin-arm64 node-v22.2.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -3498,7 +3498,7 @@ EXAMPLES
$ csdx plugins
```

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

## `csdx plugins:add PLUGIN`

Expand Down Expand Up @@ -3572,7 +3572,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

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

## `csdx plugins:install PLUGIN`

Expand Down Expand Up @@ -3621,7 +3621,7 @@ EXAMPLES
$ csdx plugins:install someuser/someplugin
```

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

## `csdx plugins:link PATH`

Expand Down Expand Up @@ -3651,7 +3651,7 @@ EXAMPLES
$ csdx plugins:link myplugin
```

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

## `csdx plugins:remove [PLUGIN]`

Expand Down Expand Up @@ -3692,7 +3692,7 @@ FLAGS
--reinstall Reinstall all plugins after uninstalling.
```

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

## `csdx plugins:uninstall [PLUGIN]`

Expand Down Expand Up @@ -3720,7 +3720,7 @@ EXAMPLES
$ csdx plugins:uninstall myplugin
```

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

## `csdx plugins:unlink [PLUGIN]`

Expand Down Expand Up @@ -3764,7 +3764,7 @@ DESCRIPTION
Update installed plugins.
```

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

## `csdx tokens`

Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli",
"description": "Command-line tool (CLI) to interact with Contentstack",
"version": "1.21.0",
"version": "1.21.1",
"author": "Contentstack",
"bin": {
"csdx": "./bin/run.js"
Expand Down Expand Up @@ -30,7 +30,7 @@
"@contentstack/cli-cm-export": "~1.11.6",
"@contentstack/cli-cm-clone": "~1.10.7",
"@contentstack/cli-cm-export-to-csv": "~1.7.2",
"@contentstack/cli-cm-import": "~1.16.2",
"@contentstack/cli-cm-import": "~1.16.3",
"@contentstack/cli-cm-migrate-rte": "~1.4.18",
"@contentstack/cli-cm-seed": "~1.7.7",
"@contentstack/cli-command": "~1.2.19",
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f68b973

Please sign in to comment.