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 authored and vsavkin committed Sep 7, 2019
1 parent 241d9dd commit 0491ccc
Show file tree
Hide file tree
Showing 25 changed files with 753 additions and 552 deletions.
5 changes: 5 additions & 0 deletions e2e/ng-add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ forEachCli('angular', () => {
maximumError: '5mb',
maximumWarning: '2mb',
type: 'initial'
},
{
maximumError: '10kb',
maximumWarning: '6kb',
type: 'anyComponentStyle'
}
],
optimization: true,
Expand Down
8 changes: 6 additions & 2 deletions e2e/ngrx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ forEachCli(() => {
expect(runCLI(`build ${myapp}`)).toContain(
'chunk {main} main-es2015.js,'
);
expect(runCLI(`build ${myapp}`)).toContain('chunk {main} main-es5.js,');
expect(runCLI(`build ${myapp}`)).toContain(
'ES5 bundle generation complete'
);
expectTestsPass(await runCLIAsync(`test ${myapp} --no-watch`));
expectTestsPass(await runCLIAsync(`test ${mylib} --no-watch`));
}, 1000000);
Expand Down Expand Up @@ -69,7 +71,9 @@ forEachCli(() => {
expect(runCLI(`build ${myapp}`)).toContain(
'chunk {main} main-es2015.js,'
);
expect(runCLI(`build ${myapp}`)).toContain('chunk {main} main-es5.js,');
expect(runCLI(`build ${myapp}`)).toContain(
'ES5 bundle generation complete'
);
expectTestsPass(await runCLIAsync(`test ${myapp} --no-watch`));
expectTestsPass(await runCLIAsync(`test ${mylib} --no-watch`));
}, 1000000);
Expand Down
48 changes: 24 additions & 24 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-class-properties": "7.5.5",
"@babel/plugin-proposal-decorators": "7.4.4",
Expand All @@ -50,13 +50,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 Expand Up @@ -142,7 +142,7 @@
"tslint": "5.11.0",
"typescript": "~3.4.5",
"viz.js": "^1.8.1",
"webpack": "4.39.3",
"webpack": "4.39.2",
"webpack-dev-server": "3.1.14",
"webpack-node-externals": "^1.7.2",
"yargs": "^11.0.0",
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()]);
}
15 changes: 15 additions & 0 deletions packages/angular/src/schematics/application/application.spec.ts
Original file line number Diff line number Diff line change
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
78 changes: 49 additions & 29 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,53 @@ 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
);

host.overwrite(
componentSpecPath,
componentSpecSource
.replace('.content span', 'h1')
.replace(
`${options.name} app is running!`,
`Welcome to ${options.name}!`
)
);

if (options.routing) {
insert(host, componentSpecPath, [
insertImport(
componentSpecSourceFile,
componentSpecPath,
'RouterTestingModule',
'@angular/router/testing'
),
...addImportToTestBed(
componentSpecSourceFile,
componentSpecPath,
`RouterTestingModule`
)
]);
}
}

return host;
};
}

function updateLinting(options: NormalizedSchema): Rule {
return chain([
updateJsonInTree('tslint.json', json => {
Expand Down Expand Up @@ -552,7 +571,7 @@ function updateE2eProject(options: NormalizedSchema): Rule {
const content = host.read(spec).toString();
host.overwrite(
spec,
content.replace('Welcome to app!', `Welcome to ${options.prefix}!`)
content.replace('my-app app is running!', `Welcome to ${options.name}!`)
);

return chain([
Expand Down Expand Up @@ -677,6 +696,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.2';
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.2",
"@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.2",
"@angular-devkit/architect": "0.803.2",
"@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"
}
}
10 changes: 5 additions & 5 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": "5.0.3",
"fork-ts-checker-webpack-plugin": "0.4.15",
Expand All @@ -46,7 +46,7 @@
"tree-kill": "1.2.1",
"ts-loader": "5.4.5",
"tsconfig-paths-webpack-plugin": "3.2.0",
"webpack": "4.39.3",
"webpack": "4.39.2",
"webpack-dev-server": "3.1.14",
"webpack-node-externals": "1.7.2"
}
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 0491ccc

Please sign in to comment.