Skip to content

Commit

Permalink
Merge pull request #1204 from contentstack/release/hotfix-CS-42696
Browse files Browse the repository at this point in the history
Release/hotfix cs 42696
  • Loading branch information
aman19K authored Dec 11, 2023
2 parents cf8c18d + b75de84 commit 7f5c722
Show file tree
Hide file tree
Showing 25 changed files with 1,450 additions and 1,476 deletions.
2,016 changes: 913 additions & 1,103 deletions package-lock.json

Large diffs are not rendered by default.

54 changes: 42 additions & 12 deletions packages/contentstack-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ USAGE
* [`csdx plugins:install PLUGIN...`](#csdx-pluginsinstall-plugin-1)
* [`csdx plugins:link PLUGIN`](#csdx-pluginslink-plugin)
* [`csdx plugins:uninstall PLUGIN...`](#csdx-pluginsuninstall-plugin)
* [`csdx plugins:reset`](#csdx-pluginsreset)
* [`csdx plugins:uninstall PLUGIN...`](#csdx-pluginsuninstall-plugin-1)
* [`csdx plugins:uninstall PLUGIN...`](#csdx-pluginsuninstall-plugin-2)
* [`csdx plugins:update`](#csdx-pluginsupdate)
Expand Down Expand Up @@ -284,7 +285,7 @@ EXAMPLES
$ csdx plugins
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.8.4/src/commands/plugins/index.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/index.ts)_

## `csdx plugins:install PLUGIN...`

Expand All @@ -300,7 +301,11 @@ ARGUMENTS
FLAGS
-f, --force Run yarn install with force flag.
-h, --help Show CLI help.
-v, --verbose
-s, --silent Silences yarn output.
-v, --verbose Show verbose yarn output.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Installs a plugin into the CLI.
Expand All @@ -317,11 +322,11 @@ ALIASES
$ csdx plugins:add
EXAMPLES
$ csdx plugins:install myplugin
$ csdx plugins:add myplugin
$ csdx plugins:install https://github.com/someuser/someplugin
$ csdx plugins:add https://github.com/someuser/someplugin
$ csdx plugins:install someuser/someplugin
$ csdx plugins:add someuser/someplugin
```

## `csdx plugins:inspect PLUGIN...`
Expand Down Expand Up @@ -349,7 +354,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.8.4/src/commands/plugins/inspect.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/inspect.ts)_

## `csdx plugins:install PLUGIN...`

Expand All @@ -365,7 +370,11 @@ ARGUMENTS
FLAGS
-f, --force Run yarn install with force flag.
-h, --help Show CLI help.
-v, --verbose
-s, --silent Silences yarn output.
-v, --verbose Show verbose yarn output.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Installs a plugin into the CLI.
Expand All @@ -389,7 +398,7 @@ EXAMPLES
$ csdx plugins:install someuser/someplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.8.4/src/commands/plugins/install.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/install.ts)_

## `csdx plugins:link PLUGIN`

Expand All @@ -403,8 +412,9 @@ ARGUMENTS
PATH [default: .] path to plugin
FLAGS
-h, --help Show CLI help.
-h, --help Show CLI help.
-v, --verbose
--[no-]install Install dependencies after linking the plugin.
DESCRIPTION
Links a plugin into the CLI for development.
Expand All @@ -418,7 +428,7 @@ EXAMPLES
$ csdx plugins:link myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.8.4/src/commands/plugins/link.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/link.ts)_

## `csdx plugins:uninstall PLUGIN...`

Expand All @@ -441,8 +451,22 @@ DESCRIPTION
ALIASES
$ csdx plugins:unlink
$ csdx plugins:remove
EXAMPLES
$ csdx plugins:remove myplugin
```

## `csdx plugins:reset`

Remove all user-installed and linked plugins.

```
USAGE
$ csdx plugins:reset
```

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

## `csdx plugins:uninstall PLUGIN...`

Removes a plugin from the CLI.
Expand All @@ -464,9 +488,12 @@ DESCRIPTION
ALIASES
$ csdx plugins:unlink
$ csdx plugins:remove
EXAMPLES
$ csdx plugins:uninstall myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.8.4/src/commands/plugins/uninstall.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/uninstall.ts)_

## `csdx plugins:uninstall PLUGIN...`

Expand All @@ -489,6 +516,9 @@ DESCRIPTION
ALIASES
$ csdx plugins:unlink
$ csdx plugins:remove
EXAMPLES
$ csdx plugins:unlink myplugin
```

## `csdx plugins:update`
Expand All @@ -507,5 +537,5 @@ DESCRIPTION
Update installed plugins.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.8.4/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/update.ts)_
<!-- commandsstop -->
4 changes: 2 additions & 2 deletions packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@contentstack/cli-command": "~1.2.16",
"@contentstack/cli-utilities": "~1.5.8",
"@oclif/plugin-help": "^5",
"@oclif/plugin-plugins": "^3.8.4",
"@oclif/plugin-plugins": "^4.1.9",
"chalk": "^4.1.2",
"fast-csv": "^4.3.6",
"fs-extra": "^11.1.1",
Expand Down Expand Up @@ -84,4 +84,4 @@
"keywords": [
"oclif"
]
}
}
2 changes: 1 addition & 1 deletion packages/contentstack-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-bootstrap/1.7.0 darwin-arm64 node-v20.8.0
@contentstack/cli-cm-bootstrap/1.7.1 darwin-arm64 node-v20.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-bootstrap",
"description": "Bootstrap contentstack apps",
"version": "1.7.0",
"version": "1.7.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions packages/contentstack-bootstrap/src/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ export default class Bootstrap {
} else {
throw new Error(messageHandler.parse('CLI_BOOTSTRAP_NO_API_KEY_FOUND'));
}

if (this.options.livePreviewEnabled) {
cliux.print(
'Important: set management token and app host in the environment file before running the application',
{
color: 'yellow',
},
);
}

cliux.print(messageHandler.parse('CLI_BOOTSTRAP_SUCCESS'));
} catch (error) {
cliux.error(messageHandler.parse('CLI_BOOTSTRAP_STACK_CREATION_FAILED', this.appConfig.stack));
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-bootstrap/src/bootstrap/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ const envFileHandler = async (
filePath = path.join(clonedDirectory, fileName);
content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${
environmentVariables.deliveryToken
}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${
customHost ? '\nCONTENTSTACK_API_HOST=' + customHost : ''
}\nCONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${
customHost ? customHost : managementAPIHost
}${
!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : ''
}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}`;
}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_MANAGEMENT_TOKEN=''\nCONTENTSTACK_APP_HOST=''\nCONTENTSTACK_LIVE_EDIT_TAGS=false`;
result = await writeEnvFile(content, filePath);
break;
case 'gatsby':
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-branches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-branches
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-branches/1.0.18 darwin-arm64 node-v20.8.0
@contentstack/cli-cm-branches/1.0.19 darwin-arm64 node-v20.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-branches",
"description": "Contentstack CLI plugin to do branches operations",
"version": "1.0.18",
"version": "1.0.19",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
18 changes: 10 additions & 8 deletions packages/contentstack-branches/src/utils/entry-create-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,17 @@ export function entryCreateScript(contentType) {
try {
compareFilteredProperties.length !== 0 &&
compareFilteredProperties.forEach(async (entryDetails) => {
entryDetails = updateAssetDetailsInEntries(entryDetails);
let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails }).catch(error => {
throw error;
});
if(createdEntry){
if (flag.references) {
await updateReferences(entryDetails, createdEntry, references);
if(entryDetails !== undefined){
entryDetails = updateAssetDetailsInEntries(entryDetails);
let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails }).catch(error => {
throw error;
});
if(createdEntry){
if (flag.references) {
await updateReferences(entryDetails, createdEntry, references);
}
await updateEntry(createdEntry, entryDetails);
}
await updateEntry(createdEntry, entryDetails);
}
});
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,56 +494,70 @@ export function entryCreateUpdateScript(contentType) {
}
try {
if (contentType.options.singleton) {
compareBranchEntries.items.map(async (el) => {
if (contentType?.options?.singleton) {
compareBranchEntries?.items?.map(async (el) => {
let entryDetails = deleteUnwantedKeysFromObject(el, keysToRemove);
entryDetails = updateAssetDetailsInEntries(entryDetails);
if (baseBranchEntries && baseBranchEntries.items.length) {
let baseEntryUid = baseBranchEntries.items[0].uid;
let entry = await stackSDKInstance.contentType('${contentType}').entry(baseEntryUid);
if(entryDetails !== undefined){
entryDetails = updateAssetDetailsInEntries(entryDetails);
if (baseBranchEntries && baseBranchEntries.items.length) {
let baseEntryUid = baseBranchEntries.items[0].uid;
let entry = await stackSDKInstance.contentType('${contentType}').entry(baseEntryUid);
if (flag.references) {
await updateReferences(entryDetails, baseBranchEntries.items[0], references);
}
await updateEntry(entry, entryDetails);
} else {
let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails });
if (flag.references) {
await updateReferences(entryDetails, baseBranchEntries.items[0], references);
}
await updateEntry(entry, entryDetails);
} else {
let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails });
if (flag.references) {
await updateReferences(entryDetails, createdEntry, references);
if (flag.references) {
await updateReferences(entryDetails, createdEntry, references);
}
await updateEntry(createdEntry, entryDetails);
}
await updateEntry(createdEntry, entryDetails);
}
});
} else {
let compareMap = new Map(converter(compareBranchEntries.items));
let baseMap = new Map(converter(baseBranchEntries.items));
//NOTE: Filter distinct entries from the base and compare branches according to their titles.
//TODO: Need to discuss this approach and replace it with uid condition
let arr = uniquelyConcatenateArrays(Array.from(compareMap.keys()), Array.from(baseMap.keys()));
arr.map(async (el) => {
let entryDetails = deleteUnwantedKeysFromObject(compareMap.get(el), keysToRemove);
entryDetails = updateAssetDetailsInEntries(entryDetails);
if (compareMap.get(el) && !baseMap.get(el)) {
let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails });
if (flag.references) {
await updateReferences(entryDetails, createdEntry, references);
}
//NOTE: In the compare branch, entry must exist. Condition of deleted entry not handled
if(entryDetails !== undefined){
entryDetails = updateAssetDetailsInEntries(entryDetails);
if (compareMap.get(el) && !baseMap.get(el)) {
let createdEntry = await stackSDKInstance
.contentType('${contentType}')
.entry()
.create({ entry: entryDetails })
.catch(err => {
(err?.errorMessage || err?.message) ? err?.errorMessage || err?.message : 'Something went wrong!'
})
if(createdEntry){
if (flag.references) {
await updateReferences(entryDetails, createdEntry, references);
}
await updateEntry(createdEntry, entryDetails);
}
} else if (compareMap.get(el) && baseMap.get(el)) {
let baseEntry = baseMap.get(el);
let entry = await stackSDKInstance.contentType('${contentType}').entry(baseEntry.uid);
if (flag.references) {
await updateReferences(entryDetails, baseEntry, references);
}
await updateEntry(createdEntry, entryDetails);
} else if (compareMap.get(el) && baseMap.get(el)) {
let baseEntry = baseMap.get(el);
let entry = await stackSDKInstance.contentType('${contentType}').entry(baseEntry.uid);
if (flag.references) {
await updateReferences(entryDetails, baseEntry, references);
await updateEntry(entry, entryDetails);
}
await updateEntry(entry, entryDetails);
}
});
}
Expand Down
Loading

0 comments on commit 7f5c722

Please sign in to comment.