Skip to content
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
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fileignoreconfig:
- filename: pnpm-lock.yaml
checksum: d39a5776abcde242965c5f7d86e4b885a16a0feeb8230e9bc1c89aa78b047ecf
checksum: 91b899dce1aff75164a1bd2a8b7dbb3d6d6babf4c3114a933b758131449d57e6
version: '1.0'
4 changes: 2 additions & 2 deletions packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@types/node": "^20.17.50",
"@types/uuid": "^9.0.8",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"eslint": "^9.26.0",
"eslint-config-oclif": "^6.0.62",
"eslint-config-oclif-typescript": "^3.1.14",
"mocha": "^10.8.2",
Expand Down Expand Up @@ -83,4 +83,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.19.0 darwin-arm64 node-v24.14.0
@contentstack/cli-cm-bootstrap/1.19.1 darwin-arm64 node-v24.14.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
8 changes: 4 additions & 4 deletions 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.19.2",
"version": "1.19.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand All @@ -16,7 +16,7 @@
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
},
"dependencies": {
"@contentstack/cli-cm-seed": "~1.15.2",
"@contentstack/cli-cm-seed": "~1.15.1",
"@contentstack/cli-command": "~1.8.1",
"@contentstack/cli-config": "~1.20.2",
"@contentstack/cli-utilities": "~1.18.2",
Expand All @@ -33,7 +33,7 @@
"@types/node": "^14.18.63",
"@types/tar": "^6.1.13",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"eslint": "^9.26.0",
"eslint-config-oclif": "^6.0.62",
"eslint-config-oclif-typescript": "^3.1.14",
"mocha": "10.8.2",
Expand Down Expand Up @@ -73,4 +73,4 @@
}
},
"repository": "contentstack/cli"
}
}
4 changes: 2 additions & 2 deletions packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"chai": "^4.5.0",
"dotenv": "^16.5.0",
"dotenv-expand": "^9.0.0",
"eslint": "^8.57.1",
"eslint": "^9.26.0",
"eslint-config-oclif": "^6.0.62",
"mocha": "10.8.2",
"nyc": "^15.1.0",
Expand Down Expand Up @@ -80,4 +80,4 @@
}
},
"repository": "https://github.com/contentstack/cli"
}
}
4 changes: 2 additions & 2 deletions packages/contentstack-bulk-publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"devDependencies": {
"@oclif/test": "^4.1.18",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"eslint": "^9.26.0",
"eslint-config-oclif": "^6.0.62",
"mocha": "^10.8.2",
"nyc": "^15.1.0",
Expand Down Expand Up @@ -98,4 +98,4 @@
"version": "oclif readme && git add README.md",
"clean": "rm -rf ./node_modules tsconfig.build.tsbuildinfo"
}
}
}
10 changes: 5 additions & 5 deletions packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@contentstack/cli-cm-clone",
"description": "Contentstack stack clone plugin",
"version": "1.21.3",
"version": "1.21.2",
"author": "Contentstack",
"bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
"dependencies": {
"@colors/colors": "^1.6.0",
"@contentstack/cli-cm-export": "~1.25.0",
"@contentstack/cli-cm-import": "~1.33.0",
"@contentstack/cli-cm-export": "~1.24.2",
"@contentstack/cli-cm-import": "~1.32.2",
"@contentstack/cli-command": "~1.8.1",
"@contentstack/cli-utilities": "~1.18.2",
"@oclif/core": "^4.10.5",
Expand All @@ -28,7 +28,7 @@
"@types/sinon": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"eslint": "^9.26.0",
"eslint-config-oclif": "^6.0.62",
"mocha": "^10.8.2",
"nyc": "^15.1.0",
Expand Down Expand Up @@ -82,4 +82,4 @@
"cm:stack-clone": "O-CLN"
}
}
}
}
4 changes: 2 additions & 2 deletions packages/contentstack-export-to-csv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@types/mkdirp": "^1.0.2",
"@types/node": "^20.17.50",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"eslint": "^9.26.0",
"eslint-config-oclif": "^6.0.62",
"eslint-config-oclif-typescript": "^3.1.14",
"mocha": "^10.8.2",
Expand Down Expand Up @@ -77,4 +77,4 @@
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\"",
"version": "oclif readme && git add README.md"
}
}
}
6 changes: 3 additions & 3 deletions packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-export",
"description": "Contentstack CLI plugin to export content from stack",
"version": "1.25.0",
"version": "1.24.2",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down Expand Up @@ -35,7 +35,7 @@
"chai": "^4.4.1",
"dotenv": "^16.5.0",
"dotenv-expand": "^9.0.0",
"eslint": "^8.57.1",
"eslint": "^9.26.0",
"eslint-config-oclif": "^6.0.68",
"mocha": "10.8.2",
"nyc": "^15.1.0",
Expand Down Expand Up @@ -98,4 +98,4 @@
}
},
"repository": "https://github.com/contentstack/cli"
}
}
11 changes: 7 additions & 4 deletions packages/contentstack-export/src/commands/cm/stacks/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ export default class ExportCommand extends Command {
try {
const { flags } = await this.parse(ExportCommand);
const exportConfig = await setupExportConfig(flags);

// Store apiKey in configHandler for session.json (return value not needed)
createLogContext(
this.context?.info?.command || 'cm:stacks:export',
exportConfig.apiKey,
exportConfig.authenticationMethod,
exportConfig.authenticationMethod
);

// For log entries, only pass module (other fields are in session.json)
exportConfig.context = { module: '' };
//log.info(`Using Cli Version: ${this.context?.cliVersion}`, exportConfig.context);
Expand All @@ -143,7 +143,9 @@ export default class ExportCommand extends Command {
if (!exportConfig.branches?.length) {
writeExportMetaFile(exportConfig);
}
log.success(`The content of the stack ${exportConfig.apiKey} has been exported successfully!`);
log.success(
`The content of the stack ${exportConfig.apiKey} has been exported successfully!`,
);
log.info(`The exported content has been stored at '${exportDir}'.`, exportConfig.context);
log.success(`The log has been stored at '${getLogPath()}'.`, exportConfig.context);
} catch (error) {
Expand All @@ -152,6 +154,7 @@ export default class ExportCommand extends Command {
}
}


// Assign values to exportConfig
private assignExportConfig(exportConfig: ExportConfig): void {
// Note setting host to create cma client
Expand Down
6 changes: 0 additions & 6 deletions packages/contentstack-export/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const config: DefaultConfig = {
'content-types',
'custom-roles',
'workflows',
'publishing-rules',
'personalize',
'entries',
'labels',
Expand Down Expand Up @@ -87,11 +86,6 @@ const config: DefaultConfig = {
fileName: 'workflows.json',
invalidKeys: ['stackHeaders', 'urlPath', 'created_at', 'updated_at', 'created_by', 'updated_by'],
},
'publishing-rules': {
dirName: 'workflows',
fileName: 'publishing-rules.json',
invalidKeys: ['stackHeaders', 'urlPath', 'created_at', 'updated_at', 'created_by', 'updated_by'],
},
globalfields: {
dirName: 'global_fields',
fileName: 'globalfields.json',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import * as path from 'path';
import { ContentstackClient, handleAndLogError, messageHandler, log, sanitizePath } from '@contentstack/cli-utilities';
import {
ContentstackClient,
handleAndLogError,
messageHandler,
log,
sanitizePath,
} from '@contentstack/cli-utilities';

import BaseClass from './base-class';
import { fsUtil, executeTask } from '../../utils';
Expand Down Expand Up @@ -80,9 +86,7 @@ export default class ContentTypesExport extends BaseClass {
const contentTypeSearchResponse = await this.stackAPIClient.contentType().query(this.qs).find();

log.debug(
`Fetched ${contentTypeSearchResponse.items?.length || 0} content types out of total ${
contentTypeSearchResponse.count
}`,
`Fetched ${contentTypeSearchResponse.items?.length || 0} content types out of total ${contentTypeSearchResponse.count}`,
this.exportConfig.context,
);

Expand Down
43 changes: 17 additions & 26 deletions packages/contentstack-export/src/export/modules/custom-roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,23 @@ export default class ExportCustomRoles extends BaseClass {
this.customRolesConfig.dirName,
);
log.debug(`Custom roles folder path is: ${this.rolesFolderPath}`, this.exportConfig.context);

await fsUtil.makeDirectory(this.rolesFolderPath);
log.debug('Custom roles directory created.', this.exportConfig.context);

this.customRolesLocalesFilepath = pResolve(this.rolesFolderPath, this.customRolesConfig.customRolesLocalesFileName);
log.debug(`Custom roles locales file path is: ${this.customRolesLocalesFilepath}`, this.exportConfig.context);

await this.getCustomRoles();
await this.getLocales();
await this.getCustomRolesLocales();

log.debug(
`Custom roles export completed. Total custom roles: ${Object.keys(this.customRoles).length}`,
this.exportConfig.context,
);

log.debug(`Custom roles export completed. Total custom roles: ${Object.keys(this.customRoles).length}`, this.exportConfig.context);
}

async getCustomRoles(): Promise<void> {
log.debug('Fetching all roles from the stack...', this.exportConfig.context);

const roles = await this.stack
.role()
.fetchAll({ include_rules: true, include_permissions: true })
Expand All @@ -68,12 +65,9 @@ export default class ExportCustomRoles extends BaseClass {
log.debug('An error occurred while fetching roles.', this.exportConfig.context);
return handleAndLogError(err, { ...this.exportConfig.context });
});

const customRoles = roles.items.filter((role: any) => !this.existingRoles[role.name]);
log.debug(
`Found ${customRoles.length} custom roles from ${roles.items?.length || 0} total roles.`,
this.exportConfig.context,
);
log.debug(`Found ${customRoles.length} custom roles from ${roles.items?.length || 0} total roles.`, this.exportConfig.context);

if (!customRoles.length) {
log.info(messageHandler.parse('ROLES_NO_CUSTOM_ROLES'), this.exportConfig.context);
Expand All @@ -85,15 +79,15 @@ export default class ExportCustomRoles extends BaseClass {
log.info(messageHandler.parse('ROLES_EXPORTING_ROLE', role?.name), this.exportConfig.context);
this.customRoles[role.uid] = role;
});

const customRolesFilePath = pResolve(this.rolesFolderPath, this.customRolesConfig.fileName);
log.debug(`Writing custom roles to: ${customRolesFilePath}.`, this.exportConfig.context);
fsUtil.writeFile(customRolesFilePath, this.customRoles);
}

async getLocales() {
log.debug('Fetching locales for custom roles mapping...', this.exportConfig.context);

const locales = await this.stack
.locale()
.query({})
Expand All @@ -106,28 +100,25 @@ export default class ExportCustomRoles extends BaseClass {
log.debug('An error occurred while fetching locales.', this.exportConfig.context);
return handleAndLogError(err, { ...this.exportConfig.context });
});

for (const locale of locales.items) {
log.debug(`Mapping locale: ${locale?.name} (${locale?.uid})`, this.exportConfig.context);
this.sourceLocalesMap[locale.uid] = locale;
}

log.debug(`Mapped ${Object.keys(this.sourceLocalesMap).length} source locales.`, this.exportConfig.context);
}

async getCustomRolesLocales() {
log.debug('Processing custom roles locales mapping...', this.exportConfig.context);

for (const role of values(this.customRoles)) {
const customRole = role as Record<string, any>;
log.debug(`Processing locales for custom role: ${customRole?.name}`, this.exportConfig.context);

const rulesLocales = find(customRole.rules, (rule: any) => rule.module === 'locale');
if (rulesLocales?.locales?.length) {
log.debug(
`Found ${rulesLocales.locales.length} locales for the role: ${customRole?.name}.`,
this.exportConfig.context,
);
log.debug(`Found ${rulesLocales.locales.length} locales for the role: ${customRole?.name}.`, this.exportConfig.context);
forEach(rulesLocales.locales, (locale: any) => {
log.debug(`Adding locale ${locale} to the custom roles mapping.`, this.exportConfig.context);
this.localesMap[locale] = 1;
Expand All @@ -137,7 +128,7 @@ export default class ExportCustomRoles extends BaseClass {

if (keys(this.localesMap)?.length) {
log.debug(`Processing ${Object.keys(this.localesMap).length} mapped locales.`, this.exportConfig.context);

for (const locale in this.localesMap) {
if (this.sourceLocalesMap[locale] !== undefined) {
const sourceLocale = this.sourceLocalesMap[locale] as Record<string, any>;
Expand All @@ -146,7 +137,7 @@ export default class ExportCustomRoles extends BaseClass {
}
this.localesMap[locale] = this.sourceLocalesMap[locale];
}

log.debug(`Writing custom roles locales to: ${this.customRolesLocalesFilepath}.`, this.exportConfig.context);
fsUtil.writeFile(this.customRolesLocalesFilepath, this.localesMap);
} else {
Expand Down
Loading
Loading