Skip to content

Commit

Permalink
remove requirment for base initializer when adding appName to array; …
Browse files Browse the repository at this point in the history
…fixes development test 'Should create nextjs app with Styleguide using post-initializer template only'
  • Loading branch information
yavorsk committed Sep 16, 2024
1 parent cc443e1 commit a2b1c7d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
27 changes: 27 additions & 0 deletions packages/create-sitecore-jss/src/init-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,33 @@ describe('initRunner', () => {
);
});

it('should aggregate nextSteps when using non base, post-initializer template', async () => {
const templates = ['bar'];
const appName = 'test-app-bar';
const args = {
silent: false,
destination: 'samples/next',
templates,
};

const mockBar = mockInitializer(false, {
appName,
nextSteps: ['bar step 1', 'bar step 2'],
initializers: ['baz'],
});
const mockBaz = mockInitializer(false, { appName, nextSteps: ['baz step 1'] });
createStub = sinon.stub(InitializerFactory.prototype, 'create');
createStub.withArgs('bar').returns(mockBar);
createStub.withArgs('baz').returns(mockBaz);

await initRunner(templates, args);

expect(nextStepsStub).to.be.calledOnceWith(
[appName],
['bar step 1', 'bar step 2', 'baz step 1']
);
});

it('should pass two appNames when two main apps initialized', async () => {
const templates = ['foo', 'bar'];
const args = {
Expand Down
4 changes: 1 addition & 3 deletions packages/create-sitecore-jss/src/init-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ export const initRunner = async (initializers: string[], args: BaseArgs) => {
const response = await initializer.init(args);

// We can have multiple appNames if base template requires to setup an additional standalone app (e.g. XM Cloud proxy)
if (initializer.isBase) {
appNames.add(response.appName);
}
appNames.add(response.appName);
nextStepsArr = [...nextStepsArr, ...(response.nextSteps ?? [])];
// process any returned initializers
if (response.initializers && response.initializers.length > 0) {
Expand Down

0 comments on commit a2b1c7d

Please sign in to comment.