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

Fix/dx 1781 #1699

Merged
merged 16 commits into from
Dec 9, 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
8 changes: 4 additions & 4 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-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.3.2",
"@contentstack/cli-variants": "~1.1.3",
"@contentstack/cli-variants": "~1.1.4",
"@contentstack/cli-utilities": "~1.8.0",
"@oclif/core": "^3.27.0",
"async": "^3.2.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@contentstack/cli-command": "~1.3.2",
"@contentstack/cli-utilities": "~1.8.0",
"@contentstack/management": "~1.18.4",
"@contentstack/cli-variants": "~1.1.3",
"@contentstack/cli-variants": "~1.1.4",
"@oclif/core": "^3.27.0",
"big-json": "^3.2.0",
"bluebird": "^3.7.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-variants/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-variants",
"version": "1.1.3",
"version": "1.1.4",
"description": "Variants plugin",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
15 changes: 11 additions & 4 deletions packages/contentstack-variants/src/import/experiences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
const conf: APIConfig = {
config,
baseURL: config.modules.personalize.baseURL[config.region.name],
headers: { 'X-Project-Uid': config.modules.personalize.project_id},
headers: { 'X-Project-Uid': config.modules.personalize.project_id },
cmaConfig: {
baseURL: config.region.cma + `/v3`,
headers: { api_key: config.apiKey },
Expand Down Expand Up @@ -141,8 +141,11 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
const jobRes = await this.validateVariantGroupAndVariantsCreated();
fsUtil.writeFile(this.cmsVariantPath, this.cmsVariants);
fsUtil.writeFile(this.cmsVariantGroupPath, this.cmsVariantGroups);
if (jobRes)
if (jobRes) {
this.log(this.config, this.$t(this.messages.CREATE_SUCCESS, { module: 'Variant & Variant groups' }), 'info');
} else {
this.personalizeConfig.importData = false;
}

if (this.personalizeConfig.importData) {
this.log(this.config, this.messages.UPDATING_CT_IN_EXP, 'info');
Expand All @@ -162,7 +165,11 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
* function import experience versions from a JSON file and creates them in the project.
*/
async importExperienceVersions(experience: ExperienceStruct, oldExperienceUid: string) {
const versionsPath = resolve(sanitizePath(this.experiencesDirPath), 'versions', `${sanitizePath(oldExperienceUid)}.json`);
const versionsPath = resolve(
sanitizePath(this.experiencesDirPath),
'versions',
`${sanitizePath(oldExperienceUid)}.json`,
);

if (!existsSync(versionsPath)) {
return;
Expand Down Expand Up @@ -231,7 +238,7 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
try {
const promises = this.pendingVariantAndVariantGrpForExperience.map(async (expUid) => {
const expRes = await this.getExperience(expUid);
if (expRes?._cms) {
if (expRes?._cms && expRes?._cms?.variantGroup && Object.keys(expRes._cms.variants).length > 0) {
this.cmsVariants[expUid] = expRes._cms?.variants ?? {};
this.cmsVariantGroups[expUid] = expRes._cms?.variantGroup ?? {};
return expUid; // Return the expUid for filtering later
Expand Down
14 changes: 11 additions & 3 deletions packages/contentstack-variants/src/import/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ export default class Project extends PersonalizationAdapter<ImportConfig> {
async import() {
const personalize = this.config.modules.personalize;
const { dirName, fileName } = personalize.projects;
const projectPath = join(sanitizePath(this.config.data), sanitizePath(personalize.dirName), sanitizePath(dirName), sanitizePath(fileName));

const projectPath = join(
sanitizePath(this.config.data),
sanitizePath(personalize.dirName),
sanitizePath(dirName),
sanitizePath(fileName),
);

if (existsSync(projectPath)) {
const projects = JSON.parse(readFileSync(projectPath, 'utf8')) as CreateProjectInput[];

Expand All @@ -46,7 +51,10 @@ export default class Project extends PersonalizationAdapter<ImportConfig> {
description: project.description,
connectedStackApiKey: this.config.apiKey,
}).catch(async (error) => {
if (error.includes('personalization.PROJECTS.DUPLICATE_NAME') || error.includes('personalize.PROJECTS.DUPLICATE_NAME')) {
if (
error.includes('personalization.PROJECTS.DUPLICATE_NAME') ||
error.includes('personalize.PROJECTS.DUPLICATE_NAME')
) {
const projectName = await askProjectName('Copy Of ' + (newName || project.name));
return await createProject(projectName);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@contentstack/cli-migration": "~1.6.4",
"@contentstack/cli-utilities": "~1.8.0",
"@contentstack/management": "~1.18.4",
"@contentstack/cli-variants": "~1.1.3",
"@contentstack/cli-variants": "~1.1.4",
"@contentstack/cli-cm-import-setup": "1.0.0-beta.1",
"@oclif/core": "^3.27.0",
"@oclif/plugin-help": "^5",
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

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

Loading