Skip to content

Commit

Permalink
fix(frontend): fix default collection
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored and vsavkin committed May 23, 2019
1 parent 4d000d9 commit 2f9116f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
8 changes: 4 additions & 4 deletions packages/angular/src/schematics/ng-add/ng-add.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('ng-add', () => {
it('should be set if none was set before', async () => {
const result = await runSchematic('ng-add', {}, appTree);
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 () => {
Expand All @@ -214,14 +214,14 @@ describe('ng-add', () => {
);
const result = await runSchematic('ng-add', {}, appTree);
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 () => {
appTree = await callRule(
updateJsonInTree('angular.json', json => {
json.cli = {
defaultCollection: '@nrwl/angular'
defaultCollection: '@nrwl/react'
};

return json;
Expand All @@ -230,7 +230,7 @@ describe('ng-add', () => {
);
const result = await runSchematic('ng-add', {}, appTree);
const angularJson = readJsonInTree(result, 'angular.json');
expect(angularJson.cli.defaultCollection).toEqual('@nrwl/angular');
expect(angularJson.cli.defaultCollection).toEqual('@nrwl/react');
});
});
});
24 changes: 14 additions & 10 deletions packages/angular/src/schematics/ng-add/ng-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,23 @@ export function addE2eTestRunner(options: Pick<Schema, 'e2eTestRunner'>): Rule {
export function setDefaults(options: Schema): Rule {
return updateWorkspace(workspace => {
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'],
unitTestRunner: options.unitTestRunner,
e2eTestRunner: options.e2eTestRunner
};
workspace.extensions.schematics[
'@nrwl/angular:application'
].unitTestRunner =
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'],
unitTestRunner: options.unitTestRunner
};
workspace.extensions.schematics['@nrwl/angular:library'].unitTestRunner =
workspace.extensions.schematics['@nrwl/angular:library'].unitTestRunner ||
options.unitTestRunner;

workspace.extensions.cli = workspace.extensions.cli || {};
const defaultCollection: string =
Expand All @@ -143,7 +147,7 @@ export function setDefaults(options: Schema): Rule {

if (!defaultCollection || defaultCollection === '@nrwl/workspace') {
(workspace.extensions.cli as JsonObject).defaultCollection =
'@nrwl/react';
'@nrwl/angular';
}
});
}
Expand Down

0 comments on commit 2f9116f

Please sign in to comment.