Skip to content

Commit 87b0065

Browse files
authored
Merge branch 'master' into master
2 parents bb18940 + c889dd8 commit 87b0065

34 files changed

+51
-141
lines changed

packages/@angular-cli/ast-tools/package.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

packages/@angular-cli/ast-tools/tsconfig.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/@angular-cli/base-href-webpack/package.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

packages/@angular-cli/base-href-webpack/tsconfig.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/@angular/cli/blueprints/component/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {NodeHost} from '../../lib/ast-tools';
2+
13
const path = require('path');
24
const fs = require('fs');
35
const chalk = require('chalk');
@@ -7,7 +9,6 @@ const findParentModule = require('../../utilities/find-parent-module').default;
79
const getFiles = Blueprint.prototype.files;
810
const stringUtils = require('ember-cli-string-utils');
911
const astUtils = require('../../utilities/ast-utils');
10-
const NodeHost = require('@angular-cli/ast-tools').NodeHost;
1112

1213
export default Blueprint.extend({
1314
description: '',

packages/@angular/cli/blueprints/directive/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import {NodeHost} from '../../lib/ast-tools';
2+
13
const path = require('path');
24
const fs = require('fs');
35
const chalk = require('chalk');
46
const dynamicPathParser = require('../../utilities/dynamic-path-parser');
57
const stringUtils = require('ember-cli-string-utils');
68
const astUtils = require('../../utilities/ast-utils');
79
const findParentModule = require('../../utilities/find-parent-module').default;
8-
const NodeHost = require('@angular-cli/ast-tools').NodeHost;
910
const Blueprint = require('../../ember-cli/lib/models/blueprint');
1011
const getFiles = Blueprint.prototype.files;
1112

packages/@angular/cli/blueprints/pipe/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import {NodeHost} from '../../lib/ast-tools';
2+
13
const path = require('path');
24
const fs = require('fs');
35
const chalk = require('chalk');
46
const dynamicPathParser = require('../../utilities/dynamic-path-parser');
57
const stringUtils = require('ember-cli-string-utils');
68
const astUtils = require('../../utilities/ast-utils');
79
const findParentModule = require('../../utilities/find-parent-module').default;
8-
const NodeHost = require('@angular-cli/ast-tools').NodeHost;
910
const Blueprint = require('../../ember-cli/lib/models/blueprint');
1011
const getFiles = Blueprint.prototype.files;
1112

packages/@angular/cli/blueprints/service/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import {NodeHost} from '../../lib/ast-tools';
12
import { oneLine } from 'common-tags';
23

34
const path = require('path');
45
const fs = require('fs');
56
const chalk = require('chalk');
67
const dynamicPathParser = require('../../utilities/dynamic-path-parser');
78
const Blueprint = require('../../ember-cli/lib/models/blueprint');
8-
const NodeHost = require('@angular-cli/ast-tools').NodeHost;
99
const stringUtils = require('ember-cli-string-utils');
1010
const astUtils = require('../../utilities/ast-utils');
1111
const getFiles = Blueprint.prototype.files;

packages/@angular/cli/models/webpack-configs/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as webpack from 'webpack';
22
import * as path from 'path';
33
import { GlobCopyWebpackPlugin } from '../../plugins/glob-copy-webpack-plugin';
44
import { packageChunkSort } from '../../utilities/package-chunk-sort';
5-
import { BaseHrefWebpackPlugin } from '@angular-cli/base-href-webpack';
5+
import { BaseHrefWebpackPlugin } from '../../lib/base-href-webpack';
66
import { extraEntryParser, lazyChunksFilter, getOutputHashFormat } from './utils';
77
import { WebpackConfigOptions } from '../webpack-config';
88

packages/@angular/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
},
2727
"homepage": "https://github.com/angular/angular-cli",
2828
"dependencies": {
29-
"@angular-cli/ast-tools": "^1.0.14",
30-
"@angular-cli/base-href-webpack": "^1.0.14",
3129
"@angular/compiler": "^2.3.1",
3230
"@angular/compiler-cli": "^2.3.1",
3331
"@angular/core": "^2.3.1",
32+
"@angular/tsc-wrapped": "^0.5.0",
3433
"@ngtools/json-schema": "^1.0.0",
3534
"@ngtools/webpack": "^1.2.3",
3635
"async": "^2.1.4",
@@ -74,6 +73,7 @@
7473
"resolve": "^1.1.7",
7574
"rimraf": "^2.5.3",
7675
"rsvp": "^3.0.17",
76+
"rxjs": "^5.0.1",
7777
"sass-loader": "^4.1.1",
7878
"script-loader": "^0.7.0",
7979
"semver": "^5.1.0",

packages/@angular/cli/tsconfig.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
],
2121
"baseUrl": "",
2222
"paths": {
23-
"@angular-cli/ast-tools": [ "../../../dist/@angular-cli/ast-tools/src" ],
24-
"@angular-cli/base-href-webpack": [ "../../../dist/@angular-cli/base-href-webpack/src" ],
25-
"@angular-cli/version": [ "../../../dist/@angular-cli/version/src" ],
2623
"@ngtools/json-schema": [ "../../../dist/@ngtools/json-schema/src" ],
2724
"@ngtools/webpack": [ "../../../dist/@ngtools/webpack/src" ]
2825
}

packages/@angular/cli/utilities/INITIAL_COMMIT_MESSAGE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
chore: initial commit from @angular/cli
2+
23
_ _ _
34
__ _ _ __ __ _ _ _| | __ _ _ __ ___| (_)
45
/ _ | _ \ / _ | | | | |/ _ | __|____ / __| | |

packages/@angular/cli/utilities/ast-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ export {
1010
addDeclarationToModule,
1111
addProviderToModule,
1212
addExportToModule
13-
} from '@angular-cli/ast-tools';
13+
} from '../lib/ast-tools';

packages/@angular/cli/utilities/change.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export {
55
InsertChange,
66
RemoveChange,
77
ReplaceChange
8-
} from '@angular-cli/ast-tools';
8+
} from '../lib/ast-tools';

packages/@angular/cli/utilities/module-resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as dependentFilesUtils from './get-dependent-files';
66

77

88
import {Change, ReplaceChange} from './change';
9-
import {NodeHost, Host} from '@angular-cli/ast-tools';
9+
import {NodeHost, Host} from '../lib/ast-tools';
1010

1111
/**
1212
* Rewrites import module of dependent files when the file is moved.

packages/@angular/cli/utilities/route-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export {
88
confirmComponentExport,
99
resolveComponentPath,
1010
applyChanges
11-
} from '@angular-cli/ast-tools';
11+
} from '../lib/ast-tools';

packages/@ngtools/json-schema/src/schema-tree.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ describe('@ngtools/json-schema', () => {
6060
proto.a[1] = 'INVALID';
6161
expect(proto.a).toEqual(['v2', null, null, 'v3']);
6262
});
63+
64+
it('supports default values', () => {
65+
const proto: any = Object.create(null);
66+
const schema = new RootSchemaTreeNode(proto, {
67+
value: valueJson,
68+
schema: schemaJson
69+
});
70+
71+
expect(schema.children['b'].get()).toEqual('default');
72+
});
6373
});
6474

6575
});

packages/@ngtools/json-schema/src/schema-tree.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export abstract class SchemaTreeNode<T> implements SchemaNode {
9797
get itemPrototype(): SchemaTreeNode<any> | null { return null; }
9898

9999
abstract get(): T;
100-
set(v: T, force = false) {
100+
set(v: T, init = false, force = false) {
101101
if (!this.readOnly) {
102102
throw new MissingImplementationError();
103103
}
@@ -220,10 +220,10 @@ export class OneOfSchemaTreeNode extends NonLeafSchemaTreeNode<any> {
220220
}
221221

222222
this._currentTypeHolder = proto;
223-
this._currentTypeHolder.set(v, true);
223+
this._currentTypeHolder.set(v, false, true);
224224
}
225225

226-
set(v: any, force = false) {
226+
set(v: any, init = false, force = false) {
227227
return this._set(v, false, force);
228228
}
229229

@@ -338,7 +338,6 @@ export class ArraySchemaTreeNode extends NonLeafSchemaTreeNode<Array<any>> {
338338
const schema = this._schema;
339339
const forward = this._forward;
340340

341-
this._defined = !!value;
342341
this._value = Object.create(null);
343342
this._dirty = this._dirty || !init;
344343

@@ -361,8 +360,8 @@ export class ArraySchemaTreeNode extends NonLeafSchemaTreeNode<Array<any>> {
361360
}
362361
}
363362

364-
set(v: any, force = false) {
365-
return this._set(v, false, force);
363+
set(v: any, init = false, force = false) {
364+
return this._set(v, init, force);
366365
}
367366

368367
isCompatible(v: any) { return Array.isArray(v); }
@@ -395,7 +394,7 @@ export class RootSchemaTreeNode extends ObjectSchemaTreeNode {
395394

396395
/** A leaf in the schema tree. Must contain a single primitive value. */
397396
export abstract class LeafSchemaTreeNode<T> extends SchemaTreeNode<T> {
398-
private _default: T;
397+
protected _default: T;
399398

400399
constructor(metaData: TreeNodeConstructorArgument<T>) {
401400
super(metaData);
@@ -410,13 +409,13 @@ export abstract class LeafSchemaTreeNode<T> extends SchemaTreeNode<T> {
410409
return this._forward.get();
411410
}
412411
if (!this.defined) {
413-
return this._default !== undefined ? this._default : undefined;
412+
return 'default' in this._schema ? this._default : undefined;
414413
}
415414
return this._value === undefined
416415
? undefined
417416
: (this._value === null ? null : this.convert(this._value));
418417
}
419-
set(v: T, force = false) {
418+
set(v: T, init = false, force = false) {
420419
if (this.readOnly && !force) {
421420
throw new SettingReadOnlyPropertyError();
422421
}
@@ -428,7 +427,7 @@ export abstract class LeafSchemaTreeNode<T> extends SchemaTreeNode<T> {
428427
}
429428
}
430429

431-
this.dirty = true;
430+
this.dirty = !init;
432431
this._value = convertedValue;
433432
}
434433

@@ -438,7 +437,10 @@ export abstract class LeafSchemaTreeNode<T> extends SchemaTreeNode<T> {
438437
}
439438

440439
get defaultValue(): T {
441-
return 'default' in this._schema ? this._default : null;
440+
return this.hasDefault ? this._default : null;
441+
}
442+
get hasDefault() {
443+
return 'default' in this._schema;
442444
}
443445

444446
abstract convert(v: any): T;
@@ -462,20 +464,20 @@ class StringSchemaTreeNode extends LeafSchemaTreeNode<string> {
462464

463465

464466
class EnumSchemaTreeNode extends StringSchemaTreeNode {
465-
private _enumValues: string[];
466-
467467
constructor(metaData: TreeNodeConstructorArgument<string>) {
468468
super(metaData);
469469

470470
if (!Array.isArray(metaData.schema['enum'])) {
471471
throw new InvalidSchema();
472472
}
473-
this._enumValues = [].concat(metaData.schema['enum']);
474-
this.set(metaData.value, true);
473+
if (this.hasDefault && !this._isInEnum(this._default)) {
474+
throw new InvalidSchema();
475+
}
476+
this.set(metaData.value, true, true);
475477
}
476478

477479
protected _isInEnum(value: string) {
478-
return this._enumValues.some(v => v === value);
480+
return this._schema['enum'].some((v: string) => v === value);
479481
}
480482

481483
isCompatible(v: any) {

packages/@ngtools/json-schema/tests/schema2.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
"items": {
99
"enum": [ "v1", "v2", "v3" ]
1010
}
11+
},
12+
"b": {
13+
"enum": [ "default", "v1", "v2" ],
14+
"default": "default"
1115
}
1216
}
1317
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"a": [
3-
null,
3+
"v2",
44
"v1",
5-
null,
5+
"v2",
66
"v3"
77
]
88
}

packages/@ngtools/webpack/src/compiler_host.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ export class WebpackCompilerHost implements ts.CompilerHost {
192192
}
193193

194194
invalidate(fileName: string): void {
195+
fileName = this._resolve(fileName);
195196
if (fileName in this._files) {
196197
this._files[fileName] = null;
197198
this._changedFiles[fileName] = true;

0 commit comments

Comments
 (0)