build(aio): example-boilerplate is no longer responsible for yarn install (#19511)
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 #19511
This commit is contained in:

committed by
Tobias Bosch

parent
ca7f2f8c8f
commit
03227e65cf
@ -18,27 +18,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();
|
||||
@ -53,6 +38,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 for systemjs', () => {
|
||||
const boilerplateDir = path.resolve(sharedDir, 'boilerplate');
|
||||
exampleBoilerPlate.loadJsonFile.and.callFake(filePath => filePath.indexOf('a/b') !== -1 ? { projectType: 'systemjs' } : {})
|
||||
@ -95,28 +88,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']);
|
||||
|
Reference in New Issue
Block a user