Skip to content

Commit

Permalink
added project flag
Browse files Browse the repository at this point in the history
  • Loading branch information
shafeeqd959 committed Jun 6, 2024
1 parent 7c3c499 commit b36ce33
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions packages/contentstack-import/src/commands/cm/stacks/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export default class ImportCommand extends Command {
default: false,
description: 'Skips the module exists warning messages.',
}),
'personalize-project-name': flags.string({
required: false,
description: 'Personalize project name.',
}),
'skip-audit': flags.boolean({
description: 'Skips the audit fix.',
}),
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-import/src/types/import-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig {
skipAudit?: boolean;
stackName?: string;
region: Region;
personalizeProjectName?: string;
}

type branch = {
Expand Down
11 changes: 5 additions & 6 deletions packages/contentstack-import/src/utils/import-config-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
config.contentDir = importCmdFlags['data'] || importCmdFlags['data-dir'] || config.data || (await askContentDir());
const pattern = /[*$%#<>{}!&?]/g;
if (pattern.test(config.contentDir)) {
cliux.print(
`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`,
{
color: 'yellow',
},
);
cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, {
color: 'yellow',
});
config.contentDir = await askContentDir();
}
config.contentDir = config.contentDir.replace(/['"]/g, '');
Expand Down Expand Up @@ -99,6 +96,8 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
config.replaceExisting = importCmdFlags['replace-existing'];
config.skipExisting = importCmdFlags['skip-existing'];

config.personalizeProjectName = importCmdFlags['personalize-project-name'];

return config;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-variants/src/import/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class Project extends PersonalizationAdapter<ImportConfig> {
});
};

await createProject();
await createProject(this.config.personalizeProjectName);

this.config.modules.personalization.project_id = projectRes.uid;
this.config.modules.personalization.importData = true;
Expand Down

0 comments on commit b36ce33

Please sign in to comment.