Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge staging to main (Hotfix release) #1257

Merged
merged 15 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 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-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "1.3.2",
"version": "1.3.3",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class Audit extends AuditBaseCommand {
try {
await this.start('cm:stacks:audit');
} catch (error) {
console.trace(error);
this.log(error instanceof Error ? error.message : error, 'error');
ux.action.stop('Process failed.!');
this.exit(1);
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-audit/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const config = {
showTerminalOutput: true,
skipRefs: ['sys_assets'],
skipFieldTypes: ['taxonomy'],
modules: ['content-types', 'global-fields', 'entries'],
'fix-fields': ['reference', 'global_field', 'json:rte', 'json:custom-field', 'blocks', 'group'],
moduleConfig: {
Expand Down
5 changes: 3 additions & 2 deletions packages/contentstack-audit/src/modules/content-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,9 @@ export default class ContentType {
}
})
.filter((val: any) => {
if (val?.schema && isEmpty(val.schema)) return false;
if (val?.reference_to && isEmpty(val.reference_to)) return false;
if (this.config.skipFieldTypes.includes(val?.data_type)) return true;
if (val?.schema && isEmpty(val?.schema)) return false;
if (val?.reference_to && isEmpty(val?.reference_to)) return false;

return !!val;
}) as ContentTypeSchemaType[];
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.20 darwin-arm64 node-v20.8.0
@contentstack/cli-cm-branches/1.0.21 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.20",
"version": "1.0.21",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
48 changes: 20 additions & 28 deletions packages/contentstack-branches/src/branch/merge-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ export default class MergeHandler {
async executeEntryExpFlow(mergeJobUID: string, mergePayload) {
const { mergeContent } = this.mergeSettings;
let mergePreference = await selectContentMergePreference();
let selectedMergePreference;

const updateEntryMergeStrategy = (items, mergeStrategy) => {
items &&
Expand All @@ -250,25 +249,16 @@ export default class MergeHandler {
});
};

switch (mergePreference) {
case 'existing_new':
selectedMergePreference = 'merge_existing_new';
updateEntryMergeStrategy(mergeContent.content_types.added, selectedMergePreference);
updateEntryMergeStrategy(mergeContent.content_types.modified, selectedMergePreference);
break;

case 'new':
selectedMergePreference = 'merge_new';
updateEntryMergeStrategy(mergeContent.content_types.added, selectedMergePreference);
break;

case 'existing':
selectedMergePreference = 'merge_existing';
updateEntryMergeStrategy(mergeContent.content_types.modified, selectedMergePreference);
break;
const mergePreferencesMap = {
'existing_new': 'merge_existing_new',
'new': 'merge_new',
'existing': 'merge_existing',
'ask_preference': 'custom',
};
const selectedMergePreference = mergePreferencesMap[mergePreference];

case 'ask_preference':
selectedMergePreference = 'custom';
if (selectedMergePreference) {
if (selectedMergePreference === 'custom') {
const selectedMergeItems = await selectContentMergeCustomPreferences(mergeContent.content_types);
mergeContent.content_types = {
added: [],
Expand All @@ -279,23 +269,25 @@ export default class MergeHandler {
selectedMergeItems?.forEach((item) => {
mergeContent.content_types[item.status].push(item.value);
});
break;

default:
cliux.error(`error: Invalid preference ${mergePreference}`);
process.exit(1);
} else {
updateEntryMergeStrategy(mergeContent.content_types.added, selectedMergePreference);
updateEntryMergeStrategy(mergeContent.content_types.modified, selectedMergePreference);
}
} else {
cliux.error(`error: Invalid preference ${mergePreference}`);
process.exit(1);
}

let scriptFolderPath = generateMergeScripts(mergeContent.content_types, mergeJobUID);

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'});
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' });

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{
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}`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,20 @@ export function generateMergeScripts(mergeSummary, mergeJobUID) {

const processContentTypes = (contentTypes, messageType) => {
if (contentTypes && contentTypes.length > 0) {
processContentType(
{ type: 'assets', uid: '', entry_merge_strategy: '' },
mergeStrategies['asset_create_folder'],
);
contentTypes.forEach((contentType) => {
const mergeStrategy = contentType.entry_merge_strategy;
if (mergeStrategies.hasOwnProperty(mergeStrategy)) {
processContentType(contentType, mergeStrategies[mergeStrategy]);
}
});
} else {
cliux.print(`No ${messageType} entries selected for merge`, { color: 'yellow' });
cliux.print(`Info: Entries of ${messageType} content types selected for the migration`, { color: 'blue' });
}
};


processContentType(
{ type: 'assets', uid: '', entry_merge_strategy: '' },
mergeStrategies['asset_create_folder'],
);
processContentTypes(mergeSummary.modified, 'Modified');
processContentTypes(mergeSummary.added, 'New');

Expand Down Expand Up @@ -93,10 +92,11 @@ export function createMergeScripts(contentType: CreateMergeScriptsProps, mergeJo
fs.mkdirSync(fullPath);
}
let filePath: string;
let milliSeconds = date.getMilliseconds().toString().padStart(3, '0')
if (contentType.type === 'assets') {
filePath = `${fullPath}/${fileCreatedAt}_create_assets_folder.js`;
filePath = `${fullPath}/${fileCreatedAt}${milliSeconds}_create_assets_folder.js`;
} else {
filePath = `${fullPath}/${fileCreatedAt}_${getContentTypeMergeStatus(contentType.entry_merge_strategy)}_${
filePath = `${fullPath}/${fileCreatedAt}${milliSeconds}_${getContentTypeMergeStatus(contentType.entry_merge_strategy)}_${
contentType.uid
}.js`;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bulk-publish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-cm-bulk-publish
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-bulk-publish/1.4.0 darwin-arm64 node-v20.8.0
@contentstack/cli-cm-bulk-publish/1.4.0 darwin-arm64 node-v20.10.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
"dependencies": {
"@contentstack/cli-cm-export": "~1.10.2",
"@contentstack/cli-cm-import": "~1.13.0",
"@contentstack/cli-cm-import": "~1.13.1",
"@contentstack/cli-command": "~1.2.16",
"@contentstack/cli-utilities": "~1.5.10",
"@colors/colors": "^1.5.0",
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.13.0",
"version": "1.13.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ class ModuleImporter {

if (this.importConfig.moduleName) {
args.push('--modules', this.importConfig.moduleName);
} else if (this.importConfig.modules.types.length) {
this.importConfig.modules.types
.filter((val) => ['content-types', 'global-fields', 'entries'].includes(val))
.forEach((val) => {
args.push('--modules', val);
});
}

log(this.importConfig, 'Starting audit process', 'info');
Expand Down Expand Up @@ -159,7 +165,6 @@ class ModuleImporter {

return true;
} catch (error) {
trace(error);
log(this.importConfig, `Audit failed with following error. ${error}`, 'error');
}
}
Expand Down
10 changes: 10 additions & 0 deletions packages/contentstack-import/src/utils/content-type-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ export const removeReferenceFields = async function (
flag.supressed = true;
schema[i].reference_to = ['sys_assets'];
}
else if (
// handling entry references in rte
schema[i].data_type === 'text' &&
schema[i].field_metadata.rich_text_type &&
schema[i].field_metadata.embed_entry &&
schema[i].reference_to.length >= 1
) {
flag.supressed = true;
schema[i].reference_to = ['sys_assets'];
}
}
};

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.13.0",
"@contentstack/cli-cm-import": "~1.13.1",
"@contentstack/cli-command": "~1.2.16",
"@contentstack/cli-utilities": "~1.5.10",
"inquirer": "8.2.4",
Expand Down
4 changes: 2 additions & 2 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.12.1 darwin-arm64 node-v20.8.0
@contentstack/cli/1.12.2 darwin-arm64 node-v20.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -3217,7 +3217,7 @@ DESCRIPTION
Display help for csdx.
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.14/src/commands/help.ts)_
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.20/src/commands/help.ts)_

## `csdx launch`

Expand Down
8 changes: 4 additions & 4 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.12.1",
"version": "1.12.2",
"author": "Contentstack",
"bin": {
"csdx": "./bin/run"
Expand All @@ -22,15 +22,15 @@
"prepack": "pnpm compile && oclif manifest && oclif readme"
},
"dependencies": {
"@contentstack/cli-audit": "~1.3.2",
"@contentstack/cli-audit": "~1.3.3",
"@contentstack/cli-auth": "~1.3.17",
"@contentstack/cli-cm-bootstrap": "~1.7.1",
"@contentstack/cli-cm-branches": "~1.0.20",
"@contentstack/cli-cm-branches": "~1.0.21",
"@contentstack/cli-cm-bulk-publish": "~1.4.0",
"@contentstack/cli-cm-clone": "~1.9.0",
"@contentstack/cli-cm-export": "~1.10.2",
"@contentstack/cli-cm-export-to-csv": "~1.6.2",
"@contentstack/cli-cm-import": "~1.13.0",
"@contentstack/cli-cm-import": "~1.13.1",
"@contentstack/cli-cm-migrate-rte": "~1.4.15",
"@contentstack/cli-cm-seed": "~1.7.1",
"@contentstack/cli-command": "~1.2.17",
Expand Down
Loading
Loading