Skip to content

Commit

Permalink
build: update Angular dependencies to RC, TypeScript to 3.4.x, and Rx…
Browse files Browse the repository at this point in the history
…JS to 6.5.x (#1795)

Closes #1788
  • Loading branch information
santoshyadavdev authored and brandonroberts committed May 6, 2019
1 parent 6bb3f39 commit b49638a
Show file tree
Hide file tree
Showing 28 changed files with 869 additions and 629 deletions.
9 changes: 5 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "213dcf7e72f3acd4d1e369b7a356f3e5d9560f380bd655b13b7c0ea425d7c419",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.27.9/rules_nodejs-0.27.9.tar.gz"],
sha256 = "3a3efbf223f6de733475602844ad3a8faa02abda25ab8cfe1d1ed0db134887cf",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.27.12/rules_nodejs-0.27.12.tar.gz"],
)

http_archive(
Expand All @@ -38,7 +38,8 @@ check_bazel_version(minimum_bazel_version = "0.24.0")

node_repositories(
node_version = "10.9.0",
yarn_version = "1.9.2",
package_json = ["//:package.json"],
yarn_version = "1.12.1",
)

yarn_install(
Expand All @@ -61,7 +62,7 @@ browser_repositories(
firefox = True,
)

load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace")
load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")

ts_setup_workspace()

Expand Down
8 changes: 4 additions & 4 deletions modules/data/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ describe('Data ng-add Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it('should update package.json', () => {
Expand Down Expand Up @@ -260,7 +260,7 @@ describe('Data ng-add Schematic', () => {
NgrxDataModuleConfig,
Pluralizer
} from 'ngrx-data';
const customConfig: NgrxDataModuleConfig = {
root: 'api', // default root path to the server's web api
timeout: 3000, // request timeout
Expand Down Expand Up @@ -291,7 +291,7 @@ describe('Data ng-add Schematic', () => {
EntityDataModuleConfig,
Pluralizer
} from '@ngrx/data';
const customConfig: EntityDataModuleConfig = {
root: 'api', // default root path to the server's web api
timeout: 3000, // request timeout
Expand Down
16 changes: 9 additions & 7 deletions modules/data/spec/utils/default-pluralizer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { TestBed } from '@angular/core/testing';
import { DefaultPluralizer, Pluralizer, PLURAL_NAMES_TOKEN } from '../../';

describe('DefaultPluralizer', () => {
let pluralizer: Pluralizer;
describe('without plural names', () => {
let pluralizer: Pluralizer;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [{ provide: Pluralizer, useClass: DefaultPluralizer }],
});

beforeEach(() => {
TestBed.configureTestingModule({
providers: [{ provide: Pluralizer, useClass: DefaultPluralizer }],
pluralizer = TestBed.get(Pluralizer);
});
});
describe('without plural names', () => {
it('should turn "Hero" to "Heros" because no plural names map', () => {
pluralizer = TestBed.get(Pluralizer);
// No map so 'Hero' gets default pluralization
expect(pluralizer.pluralize('Hero')).toBe('Heros');
});
Expand Down Expand Up @@ -42,6 +42,8 @@ describe('DefaultPluralizer', () => {
});

describe('with injected plural names', () => {
let pluralizer: Pluralizer;

beforeEach(() => {
TestBed.configureTestingModule({
providers: [
Expand Down
4 changes: 2 additions & 2 deletions modules/effects/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('Effect ng-add Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it('should update package.json', () => {
Expand Down
4 changes: 2 additions & 2 deletions modules/entity/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe('Entity ng-add Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it('should update package.json', () => {
Expand Down
4 changes: 2 additions & 2 deletions modules/router-store/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe('Router Store ng-add Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it('should update package.json', () => {
Expand Down
1 change: 1 addition & 0 deletions modules/schematics-core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ts_library(
deps = [
"@npm//@angular-devkit/core",
"@npm//@angular-devkit/schematics",
"@npm//rxjs",
"@npm//typescript",
],
)
46 changes: 27 additions & 19 deletions modules/schematics-core/testing/create-workspace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
UnitTestTree,
SchematicTestRunner,
UnitTestTree,
} from '@angular-devkit/schematics/testing';

export const defaultWorkspaceOptions = {
Expand Down Expand Up @@ -38,30 +38,38 @@ export function getTestProjectPath(
return `/${workspaceOptions.newProjectRoot}/${appOptions.name}`;
}

export function createWorkspace(
export async function createWorkspace(
schematicRunner: SchematicTestRunner,
appTree: UnitTestTree,
workspaceOptions = defaultWorkspaceOptions,
appOptions = defaultAppOptions,
libOptions = defaultLibOptions
) {
appTree = schematicRunner.runExternalSchematic(
'@schematics/angular',
'workspace',
workspaceOptions
);
appTree = schematicRunner.runExternalSchematic(
'@schematics/angular',
'application',
appOptions,
appTree
);
appTree = schematicRunner.runExternalSchematic(
'@schematics/angular',
'library',
libOptions,
appTree
);
appTree = await schematicRunner
.runExternalSchematicAsync(
'@schematics/angular',
'workspace',
workspaceOptions
)
.toPromise();

appTree = await schematicRunner
.runExternalSchematicAsync(
'@schematics/angular',
'application',
appOptions,
appTree
)
.toPromise();

appTree = await schematicRunner
.runExternalSchematicAsync(
'@schematics/angular',
'library',
libOptions,
appTree
)
.toPromise();

return appTree;
}
4 changes: 2 additions & 2 deletions modules/schematics/src/action/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('Action Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it('should create an action to specified project if provided', () => {
Expand Down
10 changes: 6 additions & 4 deletions modules/schematics/src/cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ describe('CLI Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it('should create a class by the angular/cli', () => {
it('should create a class by the angular/cli', async () => {
const options = { ...defaultOptions };
const tree = schematicRunner.runSchematic('class', options, appTree);
const tree = await schematicRunner
.runSchematicAsync('class', options, appTree)
.toPromise();
const content = tree.readContent(`${projectPath}/src/app/foo.ts`);

expect(content).toMatch(/export class Foo/);
Expand Down
46 changes: 30 additions & 16 deletions modules/schematics/src/container/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,63 +32,75 @@ describe('Container Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it('should respect the state option if not provided', () => {
it('should respect the state option if not provided', async () => {
const options = { ...defaultOptions, state: undefined };
const tree = schematicRunner.runSchematic('container', options, appTree);
const tree = await schematicRunner
.runSchematicAsync('container', options, appTree)
.toPromise();
const content = tree.readContent(
`${projectPath}/src/app/foo/foo.component.ts`
);
expect(content).not.toMatch(/import \* as fromStore/);
});

it('should import the state path if provided', () => {
it('should import the state path if provided', async () => {
const options = { ...defaultOptions, state: 'reducers' };
appTree.create(`${projectPath}/src/app/reducers`, '');
const tree = schematicRunner.runSchematic('container', options, appTree);
const tree = await schematicRunner
.runSchematicAsync('container', options, appTree)
.toPromise();
const content = tree.readContent(
`${projectPath}/src/app/foo/foo.component.ts`
);
expect(content).toMatch(/import \* as fromStore from '..\/reducers';/);
});

it('should remove .ts from the state path if provided', () => {
it('should remove .ts from the state path if provided', async () => {
const options = { ...defaultOptions, state: 'reducers/foo.ts' };
appTree.create(`${projectPath}/src/app/reducers/foo.ts`, '');
const tree = schematicRunner.runSchematic('container', options, appTree);
const tree = await schematicRunner
.runSchematicAsync('container', options, appTree)
.toPromise();
const content = tree.readContent(
`${projectPath}/src/app/foo/foo.component.ts`
);
expect(content).toMatch(/import \* as fromStore from '..\/reducers\/foo';/);
});

it('should remove index.ts from the state path if provided', () => {
it('should remove index.ts from the state path if provided', async () => {
const options = { ...defaultOptions, state: 'reducers/index.ts' };
appTree.create(`${projectPath}/src/app/reducers/index.ts`, '');
const tree = schematicRunner.runSchematic('container', options, appTree);
const tree = await schematicRunner
.runSchematicAsync('container', options, appTree)
.toPromise();
const content = tree.readContent(
`${projectPath}/src/app/foo/foo.component.ts`
);
expect(content).toMatch(/import \* as fromStore from '..\/reducers';/);
});

it('should import Store into the component', () => {
it('should import Store into the component', async () => {
const options = { ...defaultOptions, state: 'reducers' };
appTree.create(`${projectPath}/src/app/reducers`, '');
const tree = schematicRunner.runSchematic('container', options, appTree);
const tree = await schematicRunner
.runSchematicAsync('container', options, appTree)
.toPromise();
const content = tree.readContent(
`${projectPath}/src/app/foo/foo.component.ts`
);
expect(content).toMatch(/import\ {\ Store\ }\ from\ '@ngrx\/store';/);
});

it('should update the component constructor if the state path if provided', () => {
it('should update the component constructor if the state path if provided', async () => {
const options = { ...defaultOptions, state: 'reducers' };
appTree.create(`${projectPath}/src/app/reducers`, '');
const tree = schematicRunner.runSchematic('container', options, appTree);
const tree = await schematicRunner
.runSchematicAsync('container', options, appTree)
.toPromise();
const content = tree.readContent(
`${projectPath}/src/app/foo/foo.component.ts`
);
Expand All @@ -97,9 +109,11 @@ describe('Container Schematic', () => {
);
});

it('should update the component spec', () => {
it('should update the component spec', async () => {
const options = { ...defaultOptions, spec: true };
const tree = schematicRunner.runSchematic('container', options, appTree);
const tree = await schematicRunner
.runSchematicAsync('container', options, appTree)
.toPromise();
const content = tree.readContent(
`${projectPath}/src/app/foo/foo.component.spec.ts`
);
Expand Down
4 changes: 2 additions & 2 deletions modules/schematics/src/effect/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ describe('Effect Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it('should create an effect to specified project if provided', () => {
Expand Down
4 changes: 2 additions & 2 deletions modules/schematics/src/entity/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ describe('Entity Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it('should create 3 files', () => {
Expand Down
4 changes: 2 additions & 2 deletions modules/schematics/src/feature/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('Feature Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it('should create all files of a feature', () => {
Expand Down
4 changes: 2 additions & 2 deletions modules/schematics/src/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe('ng-add Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it(`should leave the workspace's cli as default`, () => {
Expand Down
4 changes: 2 additions & 2 deletions modules/schematics/src/reducer/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe('Reducer Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createReducers(createWorkspace(schematicRunner, appTree));
beforeEach(async () => {
appTree = createReducers(await createWorkspace(schematicRunner, appTree));
});

it('should create one file', () => {
Expand Down
4 changes: 2 additions & 2 deletions modules/schematics/src/store/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('Store Schematic', () => {

let appTree: UnitTestTree;

beforeEach(() => {
appTree = createWorkspace(schematicRunner, appTree);
beforeEach(async () => {
appTree = await createWorkspace(schematicRunner, appTree);
});

it('should create the initial store setup', () => {
Expand Down
Loading

0 comments on commit b49638a

Please sign in to comment.