Skip to content

Commit

Permalink
- adding single-spa-serve to schematics
Browse files Browse the repository at this point in the history
- added serve:single-spa to package.json modifications
  • Loading branch information
[email protected] committed Mar 25, 2019
1 parent f04b5c9 commit 6a3a1d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,18 @@ describe('ng-add', () => {
const angularJSON = JSON.parse(getFileContent(tree, '/angular.json'));
const ssApp = angularJSON.projects['ss-angular-cli-app'];
expect(ssApp.architect['single-spa']).toBeDefined();
expect(ssApp.architect['single-spa'].builder).toBe('single-spa-angular:build');
expect(ssApp.architect['single-spa'].builder).toBe('single-spa-angular:build');
expect(ssApp.architect['single-spa'].options.main).toBe('src/main.single-spa.ts');
expect(ssApp.architect['single-spa-serve']).toBeDefined();
expect(ssApp.architect['single-spa-serve'].builder).toBe('single-spa-angular:dev-server');
expect(ssApp.architect['single-spa-serve'].options.browserTarget).toBe('ss-angular-cli-app:single-spa');

});

test('should add build:single-spa npm script', () => {
const tree = testRunner.runSchematic<NgAddOptions>('ng-add', { routing: true }, defaultAppTree);
const packageJSON = JSON.parse(getFileContent(tree, '/package.json'));
expect(packageJSON.scripts['build:single-spa']).toBeDefined();
expect(packageJSON.scripts['serve:single-spa']).toBeDefined();
});
});
6 changes: 6 additions & 0 deletions src/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export function updateConfiguration(options: NgAddOptions) {
clientProject.architect['single-spa'].builder = 'single-spa-angular:build';
clientProject.architect['single-spa'].options.main = 'src/main.single-spa.ts';

// Copy configuration from the serve architect
clientProject.architect['single-spa-serve'] = clientProject.architect.serve;
clientProject.architect['single-spa-serve'].builder = 'single-spa-angular:dev-server';
clientProject.architect['single-spa-serve'].options.browserTarget = `${project.name}:single-spa`;

host.overwrite(workspacePath, JSON.stringify(workspace, null, 2));

Expand All @@ -93,6 +97,8 @@ export function addNPMScripts(options: NgAddOptions) {

pkg.scripts['build:single-spa'] = `ng run ${options.project}:single-spa`;

pkg.scripts['serve:single-spa'] = `ng run ${options.project}:single-spa-serve`

host.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
};
}
Expand Down

0 comments on commit 6a3a1d0

Please sign in to comment.