fix(frontend): fix default collection

This commit is contained in:
Jason Jean 2019-05-21 22:56:02 -04:00 committed by Victor Savkin
parent 4d000d93d1
commit 2f9116ff39
2 changed files with 18 additions and 14 deletions

View File

@ -198,7 +198,7 @@ describe('ng-add', () => {
it('should be set if none was set before', async () => { it('should be set if none was set before', async () => {
const result = await runSchematic('ng-add', {}, appTree); const result = await runSchematic('ng-add', {}, appTree);
const angularJson = readJsonInTree(result, 'angular.json'); const angularJson = readJsonInTree(result, 'angular.json');
expect(angularJson.cli.defaultCollection).toEqual('@nrwl/react'); expect(angularJson.cli.defaultCollection).toEqual('@nrwl/angular');
}); });
it('should be set if @nrwl/workspace was set before', async () => { it('should be set if @nrwl/workspace was set before', async () => {
@ -214,14 +214,14 @@ describe('ng-add', () => {
); );
const result = await runSchematic('ng-add', {}, appTree); const result = await runSchematic('ng-add', {}, appTree);
const angularJson = readJsonInTree(result, 'angular.json'); const angularJson = readJsonInTree(result, 'angular.json');
expect(angularJson.cli.defaultCollection).toEqual('@nrwl/react'); expect(angularJson.cli.defaultCollection).toEqual('@nrwl/angular');
}); });
it('should not be set if something else was set before', async () => { it('should not be set if something else was set before', async () => {
appTree = await callRule( appTree = await callRule(
updateJsonInTree('angular.json', json => { updateJsonInTree('angular.json', json => {
json.cli = { json.cli = {
defaultCollection: '@nrwl/angular' defaultCollection: '@nrwl/react'
}; };
return json; return json;
@ -230,7 +230,7 @@ describe('ng-add', () => {
); );
const result = await runSchematic('ng-add', {}, appTree); const result = await runSchematic('ng-add', {}, appTree);
const angularJson = readJsonInTree(result, 'angular.json'); const angularJson = readJsonInTree(result, 'angular.json');
expect(angularJson.cli.defaultCollection).toEqual('@nrwl/angular'); expect(angularJson.cli.defaultCollection).toEqual('@nrwl/react');
}); });
}); });
}); });

View File

@ -122,19 +122,23 @@ export function addE2eTestRunner(options: Pick<Schema, 'e2eTestRunner'>): Rule {
export function setDefaults(options: Schema): Rule { export function setDefaults(options: Schema): Rule {
return updateWorkspace(workspace => { return updateWorkspace(workspace => {
workspace.extensions.schematics = workspace.extensions.schematics || {}; workspace.extensions.schematics = workspace.extensions.schematics || {};
workspace.extensions.schematics['@nrwl/angular:application'] = workspace.extensions.schematics['@nrwl/angular:application'] =
workspace.extensions.schematics['@nrwl/angular:application'] || {}; workspace.extensions.schematics['@nrwl/angular:application'] || {};
workspace.extensions.schematics['@nrwl/angular:application'] = { workspace.extensions.schematics[
...workspace.extensions.schematics['@nrwl/angular:application'], '@nrwl/angular:application'
unitTestRunner: options.unitTestRunner, ].unitTestRunner =
e2eTestRunner: options.e2eTestRunner workspace.extensions.schematics['@nrwl/angular:application']
}; .unitTestRunner || options.unitTestRunner;
workspace.extensions.schematics['@nrwl/angular:application'].e2eTestRunner =
workspace.extensions.schematics['@nrwl/angular:application']
.e2eTestRunner || options.e2eTestRunner;
workspace.extensions.schematics['@nrwl/angular:library'] = workspace.extensions.schematics['@nrwl/angular:library'] =
workspace.extensions.schematics['@nrwl/angular:library'] || {}; workspace.extensions.schematics['@nrwl/angular:library'] || {};
workspace.extensions.schematics['@nrwl/angular:library'] = { workspace.extensions.schematics['@nrwl/angular:library'].unitTestRunner =
...workspace.extensions.schematics['@nrwl/angular:library'], workspace.extensions.schematics['@nrwl/angular:library'].unitTestRunner ||
unitTestRunner: options.unitTestRunner options.unitTestRunner;
};
workspace.extensions.cli = workspace.extensions.cli || {}; workspace.extensions.cli = workspace.extensions.cli || {};
const defaultCollection: string = const defaultCollection: string =
@ -143,7 +147,7 @@ export function setDefaults(options: Schema): Rule {
if (!defaultCollection || defaultCollection === '@nrwl/workspace') { if (!defaultCollection || defaultCollection === '@nrwl/workspace') {
(workspace.extensions.cli as JsonObject).defaultCollection = (workspace.extensions.cli as JsonObject).defaultCollection =
'@nrwl/react'; '@nrwl/angular';
} }
}); });
} }