build(aio): example-boilerplate is no longer responsible for yarn install (#19600)

The tooling for boilerplate was also running `yarn install` on the examples'
shared folder. But since this is handled by `ng-packages-installer` this
commit refactors the tools so that the boilerplate no longer does this
anymore.

PR Close #19600
This commit is contained in:
Peter Bacon Darwin
2017-10-06 14:48:37 +01:00
committed by Chuck Jazdzewski
parent e4dac421db
commit 1d5c3c1c9b
4 changed files with 29 additions and 66 deletions

View File

@ -15,27 +15,12 @@ describe('example-boilerplate tool', () => {
beforeEach(() => {
spyOn(fs, 'ensureSymlinkSync');
spyOn(fs, 'existsSync').and.returnValue(true);
spyOn(exampleBoilerPlate, 'copyFile');
spyOn(exampleBoilerPlate, 'getFoldersContaining').and.returnValue(exampleFolders);
spyOn(exampleBoilerPlate, 'installNodeModules');
spyOn(exampleBoilerPlate, 'loadJsonFile').and.returnValue({});
});
it('should install the npm dependencies into `sharedDir` (and pass the `useLocal` argument through)', () => {
exampleBoilerPlate.add();
expect(exampleBoilerPlate.installNodeModules).toHaveBeenCalledWith(sharedDir, undefined);
exampleBoilerPlate.installNodeModules.calls.reset();
exampleBoilerPlate.add(true);
expect(exampleBoilerPlate.installNodeModules).toHaveBeenCalledWith(sharedDir, true);
exampleBoilerPlate.installNodeModules.calls.reset();
exampleBoilerPlate.add(false);
expect(exampleBoilerPlate.installNodeModules).toHaveBeenCalledWith(sharedDir, false);
});
it('should process all the example folders', () => {
const examplesDir = path.resolve(__dirname, '../../content/examples');
exampleBoilerPlate.add();
@ -50,6 +35,14 @@ describe('example-boilerplate tool', () => {
expect(fs.ensureSymlinkSync).toHaveBeenCalledWith(sharedNodeModulesDir, path.resolve('c/d/node_modules'));
});
it('should error if the node_modules folder is missing', () => {
fs.existsSync.and.returnValue(false);
expect(() => exampleBoilerPlate.add()).toThrowError(
`The shared node_modules folder for the examples (${sharedNodeModulesDir}) is missing.\n` +
`Perhaps you need to run "yarn example-use-npm" or "yarn example-use-local" to install the dependencies?`);
expect(fs.ensureSymlinkSync).not.toHaveBeenCalled();
});
it('should copy all the source boilerplate files', () => {
exampleBoilerPlate.add();
expect(exampleBoilerPlate.copyFile).toHaveBeenCalledTimes(numberOfBoilerPlateFiles * exampleFolders.length);
@ -83,28 +76,6 @@ describe('example-boilerplate tool', () => {
});
});
describe('installNodeModules', () => {
beforeEach(() => {
spyOn(shelljs, 'exec');
});
it('should overwrite the Angular packages if `useLocal` is true', () => {
exampleBoilerPlate.installNodeModules('some/base/path', true);
expect(shelljs.exec).toHaveBeenCalledWith('node tools/ng-packages-installer overwrite some/base/path --debug');
expect(shelljs.exec.calls.count()).toEqual(1);
});
it('should restore the Angular packages if `useLocal` is not true', () => {
exampleBoilerPlate.installNodeModules('some/base/path1');
expect(shelljs.exec).toHaveBeenCalledWith('node tools/ng-packages-installer restore some/base/path1 --debug');
exampleBoilerPlate.installNodeModules('some/base/path2', false);
expect(shelljs.exec).toHaveBeenCalledWith('node tools/ng-packages-installer restore some/base/path2 --debug');
expect(shelljs.exec.calls.count()).toEqual(2);
});
});
describe('getFoldersContaining', () => {
it('should use glob.sync', () => {
spyOn(glob, 'sync').and.returnValue(['a/b/config.json', 'c/d/config.json']);