Skip to content

Commit

Permalink
sxp/xmc journey prep
Browse files Browse the repository at this point in the history
  • Loading branch information
art-alexeyenko committed Jul 18, 2024
1 parent bb66d6b commit 6a9058d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
15 changes: 15 additions & 0 deletions packages/create-sitecore-jss/src/initializers/angular/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,25 @@ export default class AngularInitializer implements Initializer {
};
const templatePath = path.resolve(__dirname, '../../templates/angular');
await transform(templatePath, mergedArgs);
const addInitializers: string[] = [];

if (answers.xmcloud) {
if (!args.templates.includes('angular-xmcloud')) {
addInitializers.push('angular-xmcloud');
}
if (!args.templates.includes('node-xmcloud-proxy')) {
addInitializers.push('angular-xmcloud');
}
} else {
if (!args.templates.includes('angular-sxp')) {
addInitializers.push('angular-sxp');
}
}

const response = {
nextSteps: [`* Connect to Sitecore with ${chalk.green('jss setup')} (optional)`],
appName: answers.appName,
initializers: addInitializers,
};

return response;
Expand Down
21 changes: 19 additions & 2 deletions packages/create-sitecore-jss/src/initializers/angular/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ import {
styleguidePrompts,
} from '../../common';

export type AngularAnswer = ClientAppAnswer & StyleguideAnswer;
export type AngularAnswer = ClientAppAnswer & StyleguideAnswer & {
xmcloud: boolean
};

export const prompts = [...clientAppPrompts, ...styleguidePrompts];
export const prompts = [...clientAppPrompts, {
type: 'confirm',
name: 'xmcloud',
message: 'Are you building for Sitecore XM Cloud?',
default: false,
when: (answers: AngularAnswer): boolean => {
// don't prompt if --yes or nextjs-xmcloud template was specified
if (answers.yes) {
return false;
} else if (answers.templates.includes('angular-xmcloud') && !answers.templates.includes('angular-sxp')) {
answers.xmcloud = true;
return false;
}
return true;
},
}, ...styleguidePrompts];

0 comments on commit 6a9058d

Please sign in to comment.