Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8eb2965
change master locale fix, change master locale script support for loc…
Jun 11, 2026
3bf2ce8
Merge branch 'development' of github.com:contentstack/cli-plugins int…
Jun 11, 2026
c3953ef
fixes three related pagination bugs in the command's org user fetch …
cs-raj Jun 19, 2026
4bcaea7
issues-jira.yml
Aravind-Kumar-cstk Jun 19, 2026
6439829
version bump
cs-raj Jun 19, 2026
27d8b97
Merge pull request #234 from contentstack/fix/DX-9107-dev
cs-raj Jun 19, 2026
3b0458a
Merge branch 'main' into fix/back-merge
harshitha-cstk Jun 19, 2026
d38e617
Merge pull request #238 from contentstack/fix/back-merge
harshitha-cstk Jun 19, 2026
e81a662
Merge pull request #236 from contentstack/development
harshitha-cstk Jun 22, 2026
64817f3
Merge pull request #239 from contentstack/main
harshitha-cstk Jun 23, 2026
df4fe43
Upgraded Node version to 22 for plugins and Readme Update
cs-raj Jun 25, 2026
752f05d
Dependency Update
cs-raj Jun 25, 2026
da5c9ea
Merge pull request #245 from contentstack/fix/DX-9334
harshitha-cstk Jun 26, 2026
e86d7a7
feat: migrate cli-plugins ESLint configs to flat config format
harshitha-cstk Jun 26, 2026
7a56bec
Merge branch 'development' into enh/dx-9335-eslint-upgrade
harshitha-cstk Jun 26, 2026
078fbe0
Merge pull request #246 from contentstack/enh/dx-9335-eslint-upgrade
harshitha-cstk Jun 26, 2026
0ff8360
Merge branch 'development' of github.com:contentstack/cli-plugins int…
Jun 29, 2026
6d8b11c
Merge pull request #231 from contentstack/fix/DX-8939
shafeeqd959 Jun 29, 2026
e8f151e
version bump
harshitha-cstk Jun 29, 2026
f087a7e
version bump
harshitha-cstk Jun 29, 2026
8f301ef
upgrade eslint-config-oclif-typescript
harshitha-cstk Jun 29, 2026
c0d0aba
Merge pull request #250 from contentstack/fix/version-bumps
harshitha-cstk Jun 29, 2026
1293503
Merge pull request #247 from contentstack/development
harshitha-cstk Jun 29, 2026
a144f07
Merge branch 'main' into fix/back-merge-development-v2
harshitha-cstk Jun 30, 2026
c03512c
update pnpm lock file
harshitha-cstk Jun 30, 2026
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
6 changes: 3 additions & 3 deletions packages/contentstack-cli-cm-regex-validate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"jest": "^30.4.2",
"mocha": "^10.8.2",
"nyc": "^15.1.0",
"oclif": "^4.23.8",
"ts-jest": "^29.4.9",
"oclif": "^4.23.21",
"ts-jest": "^29.4.11",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
},
Expand Down Expand Up @@ -84,4 +84,4 @@
"cm:stacks:validate-regex": "RGXVLD"
}
}
}
}
2 changes: 1 addition & 1 deletion packages/contentstack-external-migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@contentstack/cli-command": "~2.0.0-beta.9",
"@contentstack/cli-utilities": "~2.0.0-beta.10",
"@contentstack/json-rte-serializer": "~2.1.0",
"@contentstack/marketplace-sdk": "~1.5.2",
"@contentstack/marketplace-sdk": "~1.5.3",
"@oclif/core": "^4.8.0",
"axios": "^1.18.1",
"chalk": "^4.1.2",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ module.exports = async ({ migration, config }) => {
}

async function tailorData() {
let locales = await fs.readFile(pathValidator(path.resolve(sanitizePath(config.data_dir), 'locales/locales.json')), 'utf-8');
let locales = await fs.readFile(
pathValidator(path.resolve(sanitizePath(config.data_dir), 'locales/locales.json')),
'utf-8',
);
let masterLocale = await fs.readFile(
pathValidator(path.resolve(sanitizePath(config.data_dir), 'locales/master-locale.json')),
'utf-8',
Expand All @@ -34,12 +37,14 @@ module.exports = async ({ migration, config }) => {
if (masterLocale) {
masterLocale = JSON.parse(masterLocale);
masterLocale = Object.values(masterLocale);
masterLocale = masterLocale[0]
masterLocale = masterLocale[0];

// Validate that we have a valid master locale code
if (!masterLocale) {
if (!masterLocale || !masterLocale.code) {
throw new Error('Unable to determine master locale code from master-locale.json');
}

masterLocale = masterLocale.code;
}
locales = JSON.parse(locales);
let id = crypto.randomBytes(8).toString('hex');
Expand All @@ -60,6 +65,7 @@ module.exports = async ({ migration, config }) => {
locales[id].fallback_locale = config.target_locale;

await handleEntries(masterLocale);
await handleTaxonomies(masterLocale);
await fs.writeFile(
pathValidator(path.resolve(sanitizePath(config.data_dir), 'locales/locales.json')),
JSON.stringify(locales),
Expand All @@ -84,21 +90,23 @@ module.exports = async ({ migration, config }) => {
let sourceMasterLocaleEntries, targetMasterLocaleEntries;

// Check if index.json exists (if no entries, index.json won't be created)
const indexFilePath = pathValidator(path.resolve(sanitizePath(config.data_dir), sanitizePath(`entries/${contentType}/${masterLocale}/index.json`)));
const indexFilePath = pathValidator(
path.resolve(
sanitizePath(config.data_dir),
sanitizePath(`entries/${contentType}/${masterLocale}/index.json`),
),
);
if (!existsSync(indexFilePath)) {
console.log(`Skipping ${contentType} - no index.json found (likely no entries)`);
continue;
}

sourceMasterLocaleEntries = await fs.readFile(
indexFilePath,
{ encoding: 'utf8' },
);
sourceMasterLocaleEntries = await fs.readFile(indexFilePath, { encoding: 'utf8' });

// Parse the index.json to get the entries file name
const indexData = JSON.parse(sourceMasterLocaleEntries);
const entriesFileName = Object.values(indexData)[0];

// Check if we have a valid entries file name
if (!entriesFileName) {
console.log(`Skipping ${contentType} - no entries file found in index.json`);
Expand All @@ -112,10 +120,7 @@ module.exports = async ({ migration, config }) => {
),
);

sourceMasterLocaleEntries = await fs.readFile(
entriesFilePath,
{ encoding: 'utf8' },
);
sourceMasterLocaleEntries = await fs.readFile(entriesFilePath, { encoding: 'utf8' });
sourceMasterLocaleEntries = JSON.parse(sourceMasterLocaleEntries);
if (
existsSync(pathValidator(path.resolve(config.data_dir, `entries/${contentType}/${config.target_locale}`)))
Expand All @@ -127,7 +132,7 @@ module.exports = async ({ migration, config }) => {
if (targetMasterLocaleEntries) {
const targetIndexData = JSON.parse(targetMasterLocaleEntries);
const targetEntriesFileName = Object.values(targetIndexData)[0];

if (targetEntriesFileName) {
targetMasterLocaleEntries = await fs.readFile(
pathValidator(
Expand All @@ -152,7 +157,7 @@ module.exports = async ({ migration, config }) => {
Object.keys(sourceMasterLocaleEntries).forEach((uid) => {
if (!targetMasterLocaleEntries[uid]) {
targetMasterLocaleEntries[uid] = JSON.parse(JSON.stringify(sourceMasterLocaleEntries[uid]));
delete targetMasterLocaleEntries[uid]['publish_details'];
targetMasterLocaleEntries[uid]['publish_details'] = [];
targetMasterLocaleEntries[uid].locale = config.target_locale;
}
});
Expand All @@ -164,10 +169,10 @@ module.exports = async ({ migration, config }) => {
pathValidator(path.resolve(config.data_dir, `entries/${contentType}/${config.target_locale}/index.json`)),
{ encoding: 'utf8', flag: 'a+' },
);

const existingIndexData = JSON.parse(exsitingTargetMasterLocalEntries);
const existingEntriesFileName = Object.values(existingIndexData)[0];

if (existingEntriesFileName) {
await fs.writeFile(
pathValidator(
Expand All @@ -194,6 +199,88 @@ module.exports = async ({ migration, config }) => {
}
}

async function handleTaxonomies(masterLocale) {
const taxonomiesDirPath = pathValidator(path.resolve(sanitizePath(config.data_dir), 'taxonomies'));
const taxonomiesIndexPath = pathValidator(path.resolve(taxonomiesDirPath, 'taxonomies.json'));

if (!existsSync(taxonomiesIndexPath)) {
console.log('Skipping taxonomies - no taxonomies.json found');
return;
}

let taxonomiesIndex = await fs.readFile(taxonomiesIndexPath, { encoding: 'utf8' });
taxonomiesIndex = JSON.parse(taxonomiesIndex);

const targetLocaleDirPath = pathValidator(path.resolve(taxonomiesDirPath, sanitizePath(config.target_locale)));

for (const taxonomyUid of Object.keys(taxonomiesIndex)) {
const fileName = `${sanitizePath(taxonomyUid)}.json`;
const targetFilePath = pathValidator(path.resolve(targetLocaleDirPath, fileName));

// Prefer the old master locale's taxonomy data, then the locale recorded at export time,
// then fall back to any other locale that has it
const exportedLocale = taxonomiesIndex[taxonomyUid]?.locale;
let sourceFilePath;
for (const localeCode of [masterLocale, exportedLocale]) {
if (!localeCode) {
continue;
}
const candidatePath = pathValidator(path.resolve(taxonomiesDirPath, sanitizePath(localeCode), fileName));
if (existsSync(candidatePath)) {
sourceFilePath = candidatePath;
break;
}
}

if (!sourceFilePath) {
const localeEntries = await fs.readdir(taxonomiesDirPath, { withFileTypes: true });
for (const localeEntry of localeEntries) {
if (!localeEntry.isDirectory() || localeEntry.name === config.target_locale) {
continue;
}
const candidatePath = pathValidator(
path.resolve(taxonomiesDirPath, sanitizePath(localeEntry.name), fileName),
);
if (existsSync(candidatePath)) {
sourceFilePath = candidatePath;
break;
}
}
}

if (!sourceFilePath) {
console.log(`Skipping taxonomy '${taxonomyUid}' - no source locale data found`);
continue;
}

let sourceTaxonomy = await fs.readFile(sourceFilePath, { encoding: 'utf8' });
sourceTaxonomy = JSON.parse(sourceTaxonomy);

if (existsSync(targetFilePath)) {
let targetTaxonomy = await fs.readFile(targetFilePath, { encoding: 'utf8' });
targetTaxonomy = JSON.parse(targetTaxonomy);
targetTaxonomy.terms = targetTaxonomy.terms || [];

const existingTermUids = new Set(targetTaxonomy.terms.map((term) => term.uid));
for (const term of sourceTaxonomy.terms || []) {
if (!existingTermUids.has(term.uid)) {
targetTaxonomy.terms.push(JSON.parse(JSON.stringify(term)));
}
}

await fs.writeFile(targetFilePath, JSON.stringify(targetTaxonomy));
} else {
await fs.mkdir(targetLocaleDirPath, { recursive: true });

const targetTaxonomy = JSON.parse(JSON.stringify(sourceTaxonomy));
targetTaxonomy.taxonomy = targetTaxonomy.taxonomy || {};
targetTaxonomy.taxonomy.locale = config.target_locale;

await fs.writeFile(targetFilePath, JSON.stringify(targetTaxonomy));
}
}
}

await tailorData();
},
};
Expand Down
Loading
Loading