Skip to content

Commit

Permalink
Merge https://github.com/ngrx/platform into bug/strange-behavior-disp…
Browse files Browse the repository at this point in the history
…atch-action-and-effects-return-action
  • Loading branch information
SerkanSipahi committed Jun 7, 2019
2 parents 2b25c95 + 8b3fbfb commit c72dbde
Show file tree
Hide file tree
Showing 73 changed files with 622 additions and 504 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
<a name="8.0.0"></a>

# [8.0.0](https://github.com/ngrx/platform/compare/8.0.0-rc.1...8.0.0) (2019-06-06)

### Features

- **store:** add protection from type property use ([#1923](https://github.com/ngrx/platform/issues/1923)) ([bb9add7](https://github.com/ngrx/platform/commit/bb9add7)), closes [#1917](https://github.com/ngrx/platform/issues/1917)
- **store:** capture the type of a selector projector function ([#1920](https://github.com/ngrx/platform/issues/1920)) ([4e39cc1](https://github.com/ngrx/platform/commit/4e39cc1)), closes [#1908](https://github.com/ngrx/platform/issues/1908)

### Performance Improvements

- fine tune schematics to only commit changes ([#1925](https://github.com/ngrx/platform/issues/1925)) ([5fcdd3b](https://github.com/ngrx/platform/commit/5fcdd3b))

<a name="8.0.0-rc.1"></a>

# [8.0.0-rc.1](https://github.com/ngrx/platform/compare/8.0.0-rc.0...8.0.0-rc.1) (2019-06-04)

### Bug Fixes

- **router-store:** remove circular dependency in serializers ([#1904](https://github.com/ngrx/platform/issues/1904)) ([0407c5b](https://github.com/ngrx/platform/commit/0407c5b)), closes [#1902](https://github.com/ngrx/platform/issues/1902)

### Features

- **store:** add ngrx-store-freeze migration ([#1901](https://github.com/ngrx/platform/issues/1901)) ([4146650](https://github.com/ngrx/platform/commit/4146650)), closes [#1896](https://github.com/ngrx/platform/issues/1896)

<a name="8.0.0-rc.0"></a>

# [8.0.0-rc.0](https://github.com/ngrx/platform/compare/8.0.0-beta.2...8.0.0-rc.0) (2019-05-30)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

Reactive libraries for Angular

[![CircleCI](https://circleci.com/gh/ngrx/platform/tree/master.svg?style=shield)](https://circleci.com/gh/ngrx/workflows/platform/tree/master)
[![Join the chat at https://gitter.im/ngrx/platform](https://badges.gitter.im/ngrx/platform.svg)](https://gitter.im/ngrx/platform?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](https://commitizen.github.io/cz-cli/)
[![npm version](https://badge.fury.io/js/%40ngrx%2Fstore.svg)](https://www.npmjs.com/@ngrx/store)

## Documentation

Expand Down
1 change: 0 additions & 1 deletion build/publish-latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export async function publishToNpm(config: Config) {
'--',
'--access=public',
'--tag=latest',
'--dry-run',
];

shelljs.exec(cmd.join(' '));
Expand Down
1 change: 1 addition & 0 deletions modules/data/schematics-core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export {
ReplaceChange,
createReplaceChange,
createChangeRecorder,
commitChanges,
} from './utility/change';

export { AppConfig, getWorkspace, getWorkspacePath } from './utility/config';
Expand Down
2 changes: 1 addition & 1 deletion modules/data/schematics-core/utility/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ export function replaceImport(
})
.filter(({ hit }) => hit)
.map(({ specifier, text }) =>
createReplaceChange(sourceFile, path, specifier!, text!, importToBe)
createReplaceChange(sourceFile, specifier!, text!, importToBe)
);

return changes;
Expand Down
18 changes: 16 additions & 2 deletions modules/data/schematics-core/utility/change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,16 @@ export class ReplaceChange implements Change {

export function createReplaceChange(
sourceFile: ts.SourceFile,
path: Path,
node: ts.Node,
oldText: string,
newText: string
): ReplaceChange {
return new ReplaceChange(path, node.getStart(sourceFile), oldText, newText);
return new ReplaceChange(
sourceFile.fileName,
node.getStart(sourceFile),
oldText,
newText
);
}

export function createChangeRecorder(
Expand All @@ -162,3 +166,13 @@ export function createChangeRecorder(
}
return recorder;
}

export function commitChanges(tree: Tree, path: string, changes: Change[]) {
if (changes.length === 0) {
return false;
}

const recorder = createChangeRecorder(tree, path, changes);
tree.commitUpdate(recorder);
return true;
}
2 changes: 1 addition & 1 deletion modules/data/schematics-core/utility/libs-version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const platformVersion = '^8.0.0-beta.0';
export const platformVersion = '^8.0.0';
43 changes: 27 additions & 16 deletions modules/data/schematics-core/utility/visit-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import { Tree } from '@angular-devkit/schematics';
import { Tree, DirEntry } from '@angular-devkit/schematics';

export function visitTSSourceFiles<Result = void>(
tree: Tree,
Expand All @@ -10,24 +10,35 @@ export function visitTSSourceFiles<Result = void>(
) => Result | undefined
): Result | undefined {
let result: Result | undefined = undefined;
for (const sourceFile of visit(tree.root)) {
result = visitor(sourceFile, tree, result);
}

tree.visit(path => {
if (!path.endsWith('.ts')) {
return;
}

const sourceFile = ts.createSourceFile(
path,
tree.read(path)!.toString(),
ts.ScriptTarget.Latest
);
return result;
}

if (sourceFile.isDeclarationFile) {
return;
function* visit(directory: DirEntry): IterableIterator<ts.SourceFile> {
for (const path of directory.subfiles) {
if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
const entry = directory.file(path);
if (entry) {
const content = entry.content;
const source = ts.createSourceFile(
entry.path,
content.toString().replace(/^\uFEFF/, ''),
ts.ScriptTarget.Latest,
true
);
yield source;
}
}
}

result = visitor(sourceFile, tree, result);
});
for (const path of directory.subdirs) {
if (path === 'node_modules') {
continue;
}

return result;
yield* visit(directory.dir(path));
}
}
14 changes: 4 additions & 10 deletions modules/data/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
createChangeRecorder,
} from '@ngrx/data/schematics-core';
import { Schema as EntityDataOptions } from './schema';
import { Path } from '@angular-devkit/core';

function addNgRxDataToPackageJson() {
return (host: Tree, context: SchematicContext) => {
Expand Down Expand Up @@ -133,9 +132,9 @@ function renameNgrxDataModule(options: EntityDataOptions) {
}

const changes = [
...findNgrxDataImports(sourceFile, path, ngrxDataImports),
...findNgrxDataImportDeclarations(sourceFile, path, ngrxDataImports),
...findNgrxDataReplacements(sourceFile, path),
...findNgrxDataImports(sourceFile, ngrxDataImports),
...findNgrxDataImportDeclarations(sourceFile, ngrxDataImports),
...findNgrxDataReplacements(sourceFile),
];

if (changes.length === 0) {
Expand All @@ -150,13 +149,11 @@ function renameNgrxDataModule(options: EntityDataOptions) {

function findNgrxDataImports(
sourceFile: ts.SourceFile,
path: Path,
imports: ts.ImportDeclaration[]
) {
const changes = imports.map(specifier =>
createReplaceChange(
sourceFile,
path,
specifier.moduleSpecifier,
"'ngrx-data'",
"'@ngrx/data'"
Expand All @@ -168,7 +165,6 @@ function findNgrxDataImports(

function findNgrxDataImportDeclarations(
sourceFile: ts.SourceFile,
path: Path,
imports: ts.ImportDeclaration[]
) {
const changes = imports
Expand Down Expand Up @@ -198,7 +194,6 @@ function findNgrxDataImportDeclarations(
.map(({ specifier, text }) =>
createReplaceChange(
sourceFile,
path,
specifier!,
text!,
(renames as any)[text!]
Expand All @@ -208,7 +203,7 @@ function findNgrxDataImportDeclarations(
return changes;
}

function findNgrxDataReplacements(sourceFile: ts.SourceFile, path: Path) {
function findNgrxDataReplacements(sourceFile: ts.SourceFile) {
const renameKeys = Object.keys(renames);
let changes: ReplaceChange[] = [];
ts.forEachChild(sourceFile, node => find(node, changes));
Expand Down Expand Up @@ -252,7 +247,6 @@ function findNgrxDataReplacements(sourceFile: ts.SourceFile, path: Path) {
changes.push(
createReplaceChange(
sourceFile,
path,
change.node,
change.text,
(renames as any)[change.text]
Expand Down
1 change: 1 addition & 0 deletions modules/data/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"noEmitOnError": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"downlevelIteration": true,
"outDir": "../../dist/packages/data",
"paths": {
"@ngrx/store": ["../../dist/packages/store"],
Expand Down
1 change: 1 addition & 0 deletions modules/effects/schematics-core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export {
ReplaceChange,
createReplaceChange,
createChangeRecorder,
commitChanges,
} from './utility/change';

export { AppConfig, getWorkspace, getWorkspacePath } from './utility/config';
Expand Down
2 changes: 1 addition & 1 deletion modules/effects/schematics-core/utility/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ export function replaceImport(
})
.filter(({ hit }) => hit)
.map(({ specifier, text }) =>
createReplaceChange(sourceFile, path, specifier!, text!, importToBe)
createReplaceChange(sourceFile, specifier!, text!, importToBe)
);

return changes;
Expand Down
18 changes: 16 additions & 2 deletions modules/effects/schematics-core/utility/change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,16 @@ export class ReplaceChange implements Change {

export function createReplaceChange(
sourceFile: ts.SourceFile,
path: Path,
node: ts.Node,
oldText: string,
newText: string
): ReplaceChange {
return new ReplaceChange(path, node.getStart(sourceFile), oldText, newText);
return new ReplaceChange(
sourceFile.fileName,
node.getStart(sourceFile),
oldText,
newText
);
}

export function createChangeRecorder(
Expand All @@ -162,3 +166,13 @@ export function createChangeRecorder(
}
return recorder;
}

export function commitChanges(tree: Tree, path: string, changes: Change[]) {
if (changes.length === 0) {
return false;
}

const recorder = createChangeRecorder(tree, path, changes);
tree.commitUpdate(recorder);
return true;
}
2 changes: 1 addition & 1 deletion modules/effects/schematics-core/utility/libs-version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const platformVersion = '^8.0.0-beta.0';
export const platformVersion = '^8.0.0';
43 changes: 27 additions & 16 deletions modules/effects/schematics-core/utility/visit-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import { Tree } from '@angular-devkit/schematics';
import { Tree, DirEntry } from '@angular-devkit/schematics';

export function visitTSSourceFiles<Result = void>(
tree: Tree,
Expand All @@ -10,24 +10,35 @@ export function visitTSSourceFiles<Result = void>(
) => Result | undefined
): Result | undefined {
let result: Result | undefined = undefined;
for (const sourceFile of visit(tree.root)) {
result = visitor(sourceFile, tree, result);
}

tree.visit(path => {
if (!path.endsWith('.ts')) {
return;
}

const sourceFile = ts.createSourceFile(
path,
tree.read(path)!.toString(),
ts.ScriptTarget.Latest
);
return result;
}

if (sourceFile.isDeclarationFile) {
return;
function* visit(directory: DirEntry): IterableIterator<ts.SourceFile> {
for (const path of directory.subfiles) {
if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
const entry = directory.file(path);
if (entry) {
const content = entry.content;
const source = ts.createSourceFile(
entry.path,
content.toString().replace(/^\uFEFF/, ''),
ts.ScriptTarget.Latest,
true
);
yield source;
}
}
}

result = visitor(sourceFile, tree, result);
});
for (const path of directory.subdirs) {
if (path === 'node_modules') {
continue;
}

return result;
yield* visit(directory.dir(path));
}
}
Loading

0 comments on commit c72dbde

Please sign in to comment.