Skip to content

Commit

Permalink
Merge branch 'development' into feat/CS-42473-live-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-raj committed Jan 11, 2024
2 parents f44b4d5 + f29b61f commit 9895351
Show file tree
Hide file tree
Showing 29 changed files with 667 additions and 289 deletions.
40 changes: 20 additions & 20 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion packages/contentstack-audit/src/audit-base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
* @param {string} command - The `command` parameter is a string that represents the current command
* being executed.
*/
async start(command: CommandNames): Promise<void> {
async start(command: CommandNames): Promise<boolean> {
this.currentCommand = command;
await this.promptQueue();
await this.createBackUp();
Expand Down Expand Up @@ -69,6 +69,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
rmSync(this.sharedConfig.basePath, { recursive: true });
}
}

return !isEmpty(missingCtRefs) || !isEmpty(missingGfRefs) || !isEmpty(missingEntryRefs);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/contentstack-audit/src/base-command.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import merge from 'lodash/merge';
import isEmpty from 'lodash/isEmpty';
import { existsSync, readFileSync } from 'fs';
import { Command } from '@contentstack/cli-command';
import { Flags, FlagInput, Interfaces, cliux, ux, PrintOptions } from '@contentstack/cli-utilities';
Expand Down Expand Up @@ -57,7 +58,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {

this.sharedConfig = Object.assign(this.sharedConfig, { flags: this.flags });

if (this.flags['external-config']?.config) {
if (!isEmpty(this.flags['external-config']?.config)) {
this.sharedConfig = Object.assign(this.sharedConfig, this.flags['external-config']?.config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export default class AuditFix extends AuditBaseCommand {
* The `run` function is an asynchronous function that performs an audit on different modules
* (content-types, global-fields, entries) and generates a report.
*/
async run(): Promise<void | ConfigType> {
async run(): Promise<void | { config: ConfigType; hasFix: boolean }> {
try {
await this.start('cm:stacks:audit:fix');
const hasFix = await this.start('cm:stacks:audit:fix');

if (this.flags['external-config']?.returnConfig) {
return this.sharedConfig;
if (this.flags['external-config']?.returnResponse) {
return { config: this.sharedConfig, hasFix };
}
} catch (error) {
this.log(error instanceof Error ? error.message : error, 'error');
Expand Down
5 changes: 4 additions & 1 deletion packages/contentstack-audit/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export default {};
import Audit from "./commands/cm/stacks/audit";
import AuditFix from "./commands/cm/stacks/audit/fix";

export { Audit, AuditFix };
2 changes: 1 addition & 1 deletion packages/contentstack-audit/src/modules/content-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default class ContentType {
let canWrite = true;

if (!this.inMemoryFix && this.fix) {
if (!this.config.flags['copy-dir']) {
if (!this.config.flags['copy-dir'] && !this.config.flags['external-config']?.skipConfirm) {
canWrite = this.config.flags.yes ?? (await ux.confirm(commonMsg.FIX_CONFIRMATION));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-audit/src/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default class Entries {
let canWrite = true;

if (this.fix) {
if (!this.config.flags['copy-dir']) {
if (!this.config.flags['copy-dir'] && !this.config.flags['external-config']?.skipConfirm) {
canWrite = this.config.flags.yes || (await ux.confirm(commonMsg.FIX_CONFIRMATION));
}

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.19 darwin-arm64 node-v20.8.0
@contentstack/cli-cm-branches/1.0.20 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.19",
"version": "1.0.20",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
15 changes: 11 additions & 4 deletions packages/contentstack-branches/src/branch/merge-handler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os from 'os';
import path from 'path';
import forEach from 'lodash/forEach';
import { cliux } from '@contentstack/cli-utilities';
Expand Down Expand Up @@ -275,7 +276,7 @@ export default class MergeHandler {
deleted: [],
};

selectedMergeItems.forEach((item) => {
selectedMergeItems?.forEach((item) => {
mergeContent.content_types[item.status].push(item.value);
});
break;
Expand All @@ -290,10 +291,16 @@ export default class MergeHandler {
if (scriptFolderPath !== undefined) {
cliux.success(`\nSuccess! We have generated entry migration files in the folder ${scriptFolderPath}`);
cliux.print('\nWARNING!!! Migration is not intended to be run more than once. Migrated(entries/assets) will be duplicated if run more than once', {color: 'yellow'});

const migrationCommand = `csdx cm:stacks:migration --multiple --file-path ./${scriptFolderPath} --config {compare-branch:${mergePayload.compare_branch},file-path:./${scriptFolderPath}} --branch ${mergePayload.base_branch} --stack-api-key ${this.stackAPIKey}`;

let migrationCommand: string;
if(os.platform() === 'win32'){
migrationCommand = `csdx cm:stacks:migration --multiple --file-path ./${scriptFolderPath} --config compare-branch:${mergePayload.compare_branch},file-path:./${scriptFolderPath} --branch ${mergePayload.base_branch} --stack-api-key ${this.stackAPIKey}`;
}else{
migrationCommand = `csdx cm:stacks:migration --multiple --file-path ./${scriptFolderPath} --config {compare-branch:${mergePayload.compare_branch},file-path:./${scriptFolderPath}} --branch ${mergePayload.base_branch} --stack-api-key ${this.stackAPIKey}`;
}

cliux.print(
`\nKindly follow the steps in the guide "https://www.contentstack.com/docs/developers/cli/migrate-branch-entries" to update the migration scripts, and then run the command:\n\n${migrationCommand}`,
`\nKindly follow the steps in the guide "https://www.contentstack.com/docs/developers/cli/entry-migration" to update the migration scripts, and then run the command:\n\n${migrationCommand}`,
{ color: 'blue' },
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function generateMergeScripts(mergeSummary, mergeJobUID) {
merge_existing_new: entryCreateUpdateScript,
merge_existing: entryUpdateScript,
merge_new: entryCreateScript,
ignore: entryCreateUpdateScript,
};

const processContentTypes = (contentTypes, messageType) => {
Expand Down Expand Up @@ -66,6 +65,8 @@ export function getContentTypeMergeStatus(status) {
return 'created';
} else if (status === 'merge_existing_new') {
return 'created_updated';
} else if (status === 'ignore') {
return;
} else {
return '';
}
Expand Down
Loading

0 comments on commit 9895351

Please sign in to comment.