Skip to content

Commit

Permalink
feat(nx): update to Angular 8.2, Devkit 8.3, and NgRx 8.3
Browse files Browse the repository at this point in the history
Incorporates fix from angular/angular-cli#15041
which changed the behavior of registering schematic defaults
  • Loading branch information
brandonroberts committed Sep 3, 2019
1 parent 70d71b3 commit 7f149d2
Show file tree
Hide file tree
Showing 21 changed files with 772 additions and 566 deletions.
46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
"documentation": "./scripts/documentation/documentation.sh && yarn format && ./scripts/documentation/check-documentation.sh"
},
"devDependencies": {
"@angular-devkit/architect": "0.801.1",
"@angular-devkit/build-angular": "0.801.1",
"@angular-devkit/build-ng-packagr": "0.801.1",
"@angular-devkit/build-webpack": "0.801.1",
"@angular-devkit/core": "8.1.1",
"@angular-devkit/schematics": "8.1.1",
"@angular-eslint/builder": "0.0.1-alpha.16",
"@angular/cli": "8.1.1",
"@angular/common": "^8.0.0",
"@angular/compiler": "^8.0.0",
"@angular/compiler-cli": "^8.0.0",
"@angular/core": "^8.0.0",
"@angular/platform-browser": "^8.0.0",
"@angular/platform-browser-dynamic": "^8.0.0",
"@angular/router": "^8.0.0",
"@angular/upgrade": "^8.0.0",
"@angular-devkit/architect": "0.803.2",
"@angular-devkit/build-angular": "0.803.2",
"@angular-devkit/build-ng-packagr": "0.803.2",
"@angular-devkit/build-webpack": "0.803.2",
"@angular-devkit/core": "8.3.2",
"@angular-devkit/schematics": "8.3.2",
"@angular-eslint/builder": "0.0.1-alpha.17",
"@angular/cli": "8.3.2",
"@angular/common": "^8.2.0",
"@angular/compiler": "^8.2.0",
"@angular/compiler-cli": "^8.2.0",
"@angular/core": "^8.2.0",
"@angular/platform-browser": "^8.2.0",
"@angular/platform-browser-dynamic": "^8.2.0",
"@angular/router": "^8.2.0",
"@angular/upgrade": "^8.2.0",
"@babel/core": "7.5.5",
"@babel/plugin-proposal-decorators": "7.4.4",
"@babel/preset-env": "7.5.5",
Expand All @@ -49,13 +49,13 @@
"@nestjs/platform-express": "^6.2.4",
"@nestjs/schematics": "^6.3.0",
"@nestjs/testing": "^6.2.4",
"@ngrx/effects": "8.1.0",
"@ngrx/entity": "8.1.0",
"@ngrx/router-store": "8.1.0",
"@ngrx/schematics": "8.1.0",
"@ngrx/store": "8.1.0",
"@ngrx/store-devtools": "8.1.0",
"@schematics/angular": "8.1.1",
"@ngrx/effects": "8.3.0",
"@ngrx/entity": "8.3.0",
"@ngrx/router-store": "8.3.0",
"@ngrx/schematics": "8.3.0",
"@ngrx/store": "8.3.0",
"@ngrx/store-devtools": "8.3.0",
"@schematics/angular": "8.3.2",
"@testing-library/react": "8.0.5",
"@types/express": "4.17.0",
"@types/jasmine": "~2.8.6",
Expand Down
5 changes: 5 additions & 0 deletions packages/angular/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"version": "8.3.0-beta.1",
"description": "Upgrades NgRx dependencies to version 8, and runs migrations for breaking changes",
"factory": "./src/migrations/update-8-3-0/upgrade-ngrx-8-0"
},
"upgrade-cli-8-3": {
"version": "8.5.0-beta.1",
"description": "Upgrades Angular CLI to 8.3.0 and NgRx dependencies to version 8.2",
"factory": "./src/migrations/update-8-5-0/upgrade-cli-8-3"
}
}
}
4 changes: 2 additions & 2 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"dependencies": {
"@nrwl/cypress": "*",
"@nrwl/jest": "*",
"@angular-devkit/schematics": "8.1.1",
"@schematics/angular": "8.1.1",
"@angular-devkit/schematics": "8.3.2",
"@schematics/angular": "8.3.2",
"jasmine-marbles": "~0.6.0"
}
}
20 changes: 20 additions & 0 deletions packages/angular/src/migrations/update-8-5-0/upgrade-cli-8-3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { chain, Tree, noop, TaskId } from '@angular-devkit/schematics';
import { addUpdateTask, readJsonInTree, formatFiles } from '@nrwl/workspace';

const updateCLI = addUpdateTask('@angular/cli', '8.3.2');

function updateNgrx() {
return (host: Tree) => {
const { dependencies } = readJsonInTree(host, 'package.json');

if (dependencies && dependencies['@ngrx/store']) {
return chain([addUpdateTask('@ngrx/store', '8.3.0'), formatFiles()]);
}

return noop();
};
}

export default function() {
return chain([updateCLI, updateNgrx()]);
}
19 changes: 17 additions & 2 deletions packages/angular/src/schematics/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('app', () => {
let myAppPrefix = workspaceJson.projects['my-app'].prefix;

expect(myAppPrefix).toEqual('proj');
expect(appE2eSpec).toContain('Welcome to my-app!');
expect(appE2eSpec).toContain('my-app app is running!');

// Testing WITH prefix

Expand All @@ -124,7 +124,7 @@ describe('app', () => {
myAppPrefix = workspaceJson.projects['my-app'].prefix;

expect(myAppPrefix).toEqual('custom');
expect(appE2eSpec).toContain('Welcome to my-app!');
expect(appE2eSpec).toContain('my-app app is running!');
});

xit('should work if the new project root is changed', async () => {
Expand Down Expand Up @@ -297,6 +297,21 @@ describe('app', () => {
getFileContent(tree, 'apps/my-dir/my-app/src/app/app.component.ts')
).toContain('Thank you for using and showing some ♥ for Nx.');
});

it('should update the AppComponent spec to target Nx content', async () => {
const tree = await runSchematic(
'app',
{ name: 'myApp', directory: 'myDir', inlineTemplate: true },
appTree
);
const testFileContent = getFileContent(
tree,
'apps/my-dir/my-app/src/app/app.component.spec.ts'
);

expect(testFileContent).toContain(`querySelector('h1')`);
expect(testFileContent).toContain('Welcome to my-dir-my-app!');
});
});

describe('--style scss', () => {
Expand Down
102 changes: 74 additions & 28 deletions packages/angular/src/schematics/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,34 +286,6 @@ function addRouterRootConfiguration(options: NormalizedSchema): Rule {
)
]);

if (options.skipTests !== true) {
const componentSpecPath = `${
options.appProjectRoot
}/src/app/app.component.spec.ts`;
const componentSpecSource = host
.read(componentSpecPath)!
.toString('utf-8');
const componentSpecSourceFile = ts.createSourceFile(
componentSpecPath,
componentSpecSource,
ts.ScriptTarget.Latest,
true
);
insert(host, componentSpecPath, [
insertImport(
componentSpecSourceFile,
componentSpecPath,
'RouterTestingModule',
'@angular/router/testing'
),
...addImportToTestBed(
componentSpecSourceFile,
componentSpecPath,
`RouterTestingModule`
)
]);
}

return host;
};
}
Expand Down Expand Up @@ -385,6 +357,79 @@ function updateComponentTemplate(options: NormalizedSchema): Rule {
};
}

function updateComponentSpec(options: NormalizedSchema) {
return (host: Tree) => {
if (options.skipTests !== true) {
const componentSpecPath = `${
options.appProjectRoot
}/src/app/app.component.spec.ts`;
const componentSpecSource = host
.read(componentSpecPath)!
.toString('utf-8');
const componentSpecSourceFile = ts.createSourceFile(
componentSpecPath,
componentSpecSource,
ts.ScriptTarget.Latest,
true
);
insert(host, componentSpecPath, [
insertImport(
componentSpecSourceFile,
componentSpecPath,
'RouterTestingModule',
'@angular/router/testing'
),
...addImportToTestBed(
componentSpecSourceFile,
componentSpecPath,
`RouterTestingModule`
)
]);

host.overwrite(
componentSpecPath,
`import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { RouterTestingModule } from '@angular/router/testing';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule],
declarations: [AppComponent]
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it('should have as title \'${options.name}\'', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('${options.name}');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain(
'Welcome to ${options.name}!'
);
});
});
`
);
}

return host;
};
}

function updateLinting(options: NormalizedSchema): Rule {
return chain([
updateJsonInTree('tslint.json', json => {
Expand Down Expand Up @@ -677,6 +722,7 @@ export default function(schema: Schema): Rule {
updateProject(options),
updateComponentTemplate(options),
updateComponentStyles(options),
updateComponentSpec(options),
options.routing ? addRouterRootConfiguration(options) : noop(),
updateLinting(options),
options.unitTestRunner === 'jest'
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/src/utils/versions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const nxVersion = '*';
export const angularVersion = '^8.0.0';
export const angularDevkitVersion = '^0.800.1';
export const angularVersion = '^8.2.0';
export const angularDevkitVersion = '^0.803.0';
export const angularJsVersion = '1.6.6';
export const ngrxVersion = '8.1.0';
export const ngrxVersion = '8.3.0';
export const rxjsVersion = '~6.4.0';
export const jestPresetAngularVersion = '7.0.0';
4 changes: 2 additions & 2 deletions packages/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"@nrwl/workspace": "*"
},
"dependencies": {
"@angular-devkit/architect": "0.801.1",
"@angular-devkit/core": "8.1.1",
"@angular-devkit/architect": "0.803.2",
"@angular-devkit/core": "8.3.0",
"@cypress/webpack-preprocessor": "~4.1.0",
"tree-kill": "1.2.1",
"ts-loader": "5.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"dependencies": {
"@nrwl/node": "*",
"@nrwl/jest": "*",
"@angular-devkit/schematics": "8.1.1"
"@angular-devkit/schematics": "8.3.2"
}
}
6 changes: 3 additions & 3 deletions packages/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"@nrwl/workspace": "*"
},
"dependencies": {
"@angular-devkit/architect": "0.801.1",
"@angular-devkit/core": "8.1.1",
"@angular-devkit/schematics": "8.1.1"
"@angular-devkit/architect": "0.803.2",
"@angular-devkit/core": "8.3.2",
"@angular-devkit/schematics": "8.3.2"
}
}
10 changes: 5 additions & 5 deletions packages/linter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"@nrwl/workspace": "*"
},
"dependencies": {
"@angular/compiler": "8.1.2",
"@angular/compiler-cli": "8.1.2",
"@angular-devkit/build-angular": "0.801.1",
"@angular-devkit/architect": "0.801.1",
"@angular-eslint/builder": "0.0.1-alpha.16"
"@angular/compiler": "8.2.0",
"@angular/compiler-cli": "8.2.0",
"@angular-devkit/build-angular": "0.803.0",
"@angular-devkit/architect": "0.803.0",
"@angular-eslint/builder": "0.0.1-alpha.17"
}
}
2 changes: 1 addition & 1 deletion packages/nest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"dependencies": {
"@nrwl/node": "*",
"@nrwl/jest": "*",
"@angular-devkit/schematics": "8.1.1"
"@angular-devkit/schematics": "8.3.2"
}
}
8 changes: 4 additions & 4 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"dependencies": {
"@nrwl/jest": "*",
"@nrwl/linter": "*",
"@angular-devkit/architect": "0.801.1",
"@angular-devkit/core": "8.1.1",
"@angular-devkit/schematics": "8.1.1",
"@angular-devkit/build-webpack": "0.801.1",
"@angular-devkit/architect": "0.803.2",
"@angular-devkit/core": "8.3.2",
"@angular-devkit/schematics": "8.3.2",
"@angular-devkit/build-webpack": "0.803.2",
"circular-dependency-plugin": "^5.0.2",
"copy-webpack-plugin": "4.6.0",
"fork-ts-checker-webpack-plugin": "0.4.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@nrwl/cypress": "*",
"@nrwl/jest": "*",
"@nrwl/web": "*",
"@angular-devkit/schematics": "8.1.1",
"@angular-devkit/schematics": "8.3.2",
"confusing-browser-globals": "^1.0.8",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
Expand Down
6 changes: 3 additions & 3 deletions packages/tao/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
},
"homepage": "https://nx.dev",
"dependencies": {
"@angular-devkit/schematics": "8.1.1",
"@angular-devkit/core": "8.1.1",
"@angular-devkit/architect": "0.801.1",
"@angular-devkit/schematics": "8.3.2",
"@angular-devkit/core": "8.3.2",
"@angular-devkit/architect": "0.803.2",
"inquirer": "^6.3.1",
"minimist": "^1.2.0",
"strip-json-comments": "2.0.1"
Expand Down
Loading

0 comments on commit 7f149d2

Please sign in to comment.