Skip to content

Commit a5c0bb3

Browse files
Merge pull request #183 from angular/master
Update upstream
2 parents 45569af + ad84bb1 commit a5c0bb3

File tree

19 files changed

+145
-618
lines changed

19 files changed

+145
-618
lines changed

.appveyor.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@ matrix:
99
install:
1010
- ps: Install-Product node $env:nodejs_version
1111
- yarn install --frozen-lockfile
12-
# Appveyor (via chocolatey) cannot use older versions of Chrome:
13-
# https://github.com/chocolatey/chocolatey-coreteampackages/tree/master/automatic/googlechrome
1412
- npm run webdriver-update-appveyor
1513

1614
test_script:
1715
- node --version
18-
- npm --version
19-
- npm test
20-
- npm run test-large
16+
- yarn --version
17+
- yarn test
18+
- node tests\legacy-cli\run_e2e.js --appveyor "--glob=tests/{basic,commands,generate,build/styles}/**"
2119

2220
build: off
2321
deploy: off
2422

2523
cache:
2624
- node_modules -> yarn.lock
25+
- "%LOCALAPPDATA%\\Yarn"

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"name": "@angular/devkit-repo",
3+
"version": "0.0.0",
24
"private": true,
35
"description": "Software Development Kit for Angular",
46
"bin": {

packages/angular/cli/bin/ng

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33

44
// Provide a title to the process in `ps`.
55
// Due to an obscure Mac bug, do not start this title with any symbol.
6-
process.title = 'ng';
6+
try {
7+
process.title = 'ng ' + Array.from(process.argv).slice(2).join(' ');
8+
} catch(_) {
9+
// If an error happened above, use the most basic title.
10+
process.title = 'ng';
11+
}
712

13+
// Some older versions of Node do not support let or const.
814
var version = process.version.substr(1).split('.');
915
if (Number(version[0]) < 8 || (Number(version[0]) === 8 && Number(version[1]) < 9)) {
1016
process.stderr.write(

packages/angular/cli/models/command-runner.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@
99
// tslint:disable:no-global-tslint-disable no-any
1010
import {
1111
JsonObject,
12-
Path,
1312
deepCopy,
14-
dirname,
15-
join,
1613
logging,
17-
normalize,
1814
parseJson,
1915
schema,
2016
strings as coreStrings,
2117
tags,
2218
} from '@angular-devkit/core';
2319
import { ExportStringRef } from '@angular-devkit/schematics/tools';
2420
import { readFileSync } from 'fs';
21+
import { dirname, join } from 'path';
2522
import { of, throwError } from 'rxjs';
2623
import { concatMap } from 'rxjs/operators';
2724
import * as yargsParser from 'yargs-parser';
@@ -37,8 +34,8 @@ import { insideProject } from '../utilities/project';
3734
import { convertSchemaToOptions, parseSchema } from './json-schema';
3835

3936

40-
export interface CommandMap {
41-
[key: string]: Path;
37+
interface CommandMap {
38+
[key: string]: string;
4239
}
4340

4441
interface CommandMetadata {
@@ -111,7 +108,7 @@ export async function runCommand(
111108

112109
return 1;
113110
}
114-
const cliDir = dirname(normalize(commandMapPath));
111+
const cliDir = dirname(commandMapPath);
115112
const commandsText = readFileSync(commandMapPath).toString('utf-8');
116113
const commandJson = JSON.parse(commandsText) as { [name: string]: string };
117114

@@ -410,7 +407,7 @@ async function createCommand(metadata: CommandLocation,
410407
throw new Error('Implementation path is incorrect');
411408
}
412409

413-
const implRef = new ExportStringRef(implPath, dirname(normalize(metadata.path)));
410+
const implRef = new ExportStringRef(implPath, dirname(metadata.path));
414411

415412
const ctor = implRef.ref as CommandConstructor;
416413

packages/angular/cli/models/json-schema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { JsonObject, JsonValue, parseJson } from '@angular-devkit/core';
8+
import { JsonObject, isJsonObject, parseJson } from '@angular-devkit/core';
99
import * as jsonSchemaTraverse from 'json-schema-traverse';
1010
import { Option, OptionSmartDefault } from './command';
1111

@@ -42,7 +42,7 @@ function getOptions(schemaText: string, onlyRootProperties = true): Promise<Opti
4242
}
4343
}
4444
let $default: OptionSmartDefault | undefined = undefined;
45-
if (schema.$default !== null && JsonValue.isJsonObject(schema.$default)) {
45+
if (schema.$default !== null && isJsonObject(schema.$default)) {
4646
$default = <OptionSmartDefault> schema.$default;
4747
}
4848
let required = false;
@@ -98,7 +98,7 @@ function isPropertyNested(jsonPath: string): boolean {
9898

9999
export function parseSchema(schema: string): JsonObject | null {
100100
const parsedSchema = parseJson(schema);
101-
if (parsedSchema === null || !JsonValue.isJsonObject(parsedSchema)) {
101+
if (parsedSchema === null || !isJsonObject(parsedSchema)) {
102102
return null;
103103
}
104104

packages/angular/pwa/pwa/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function updateIndexFile(options: PwaOptions): Rule {
9393
...itemsToAddToHead.map(line => headIndent + line),
9494
...lines.slice(closingHeadTagLineIndex, closingBodyTagLineIndex),
9595
...itemsToAddToBody.map(line => bodyIndent + line),
96-
...lines.slice(closingHeadTagLineIndex),
96+
...lines.slice(closingBodyTagLineIndex),
9797
].join('\n');
9898

9999
host.overwrite(path, updatedIndex);

packages/angular_devkit/build_angular/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@
7979
"jquery": "^3.3.1",
8080
"jasmine-core": "~2.8.0",
8181
"jasmine-spec-reporter": "~4.2.1",
82-
"karma": "~2.0.0",
82+
"karma": "~3.0.0",
8383
"karma-chrome-launcher": "~2.2.0",
84-
"karma-cli": "~1.0.1",
8584
"karma-coverage-istanbul-reporter": "~2.0.0",
8685
"karma-jasmine": "~1.1.0",
8786
"karma-jasmine-html-reporter": "^0.2.2",

packages/angular_devkit/core/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import * as experimental from './experimental';
9+
import * as json from './json';
910
import * as logging from './logger';
1011
import * as terminal from './terminal';
1112

@@ -16,6 +17,7 @@ export * from './virtual-fs';
1617

1718
export {
1819
experimental,
20+
json,
1921
logging,
2022
terminal,
2123
};

packages/angular_devkit/core/src/json/interface.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ export interface JsonAstComment extends JsonAstNodeBase {
110110

111111
export type JsonValue = JsonAstNode['value'];
112112

113-
export const JsonValue = {
114-
isJsonObject(value: JsonValue): value is JsonObject {
115-
return value != null && typeof value === 'object' && !Array.isArray(value);
116-
},
117-
};
113+
export function isJsonObject(value: JsonValue): value is JsonObject {
114+
return value != null && typeof value === 'object' && !Array.isArray(value);
115+
}
116+
117+
export function isJsonArray(value: JsonValue): value is JsonArray {
118+
return Array.isArray(value);
119+
}

packages/angular_devkit/core/src/json/schema/transforms.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { JsonObject, JsonValue } from '../interface';
8+
import { JsonObject, JsonValue, isJsonObject } from '../interface';
99
import { JsonPointer } from './interface';
1010

1111
const allTypes = ['string', 'integer', 'number', 'object', 'array', 'boolean', 'null'];
@@ -24,7 +24,7 @@ function findTypes(schema: JsonObject): Set<string> {
2424
potentials = new Set(allTypes);
2525
}
2626

27-
if (JsonValue.isJsonObject(schema.not)) {
27+
if (isJsonObject(schema.not)) {
2828
const notTypes = findTypes(schema.not);
2929
potentials = new Set([...potentials].filter(p => !notTypes.has(p)));
3030
}
@@ -97,13 +97,13 @@ export function addUndefinedDefaults(
9797
let newValue;
9898
if (value == undefined) {
9999
newValue = {} as JsonObject;
100-
} else if (JsonValue.isJsonObject(value)) {
100+
} else if (isJsonObject(value)) {
101101
newValue = value;
102102
} else {
103103
return value;
104104
}
105105

106-
if (!JsonValue.isJsonObject(schema.properties)) {
106+
if (!isJsonObject(schema.properties)) {
107107
return newValue;
108108
}
109109

packages/angular_devkit/schematics/src/rules/base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ export function noop(): Rule {
9696
export function filter(predicate: FilePredicate<boolean>): Rule {
9797
return ((tree: Tree) => {
9898
// TODO: Remove VirtualTree usage in 7.0
99-
if (tree instanceof VirtualTree) {
99+
if (VirtualTree.isVirtualTree(tree)) {
100100
return new FilteredTree(tree, predicate);
101-
} else if (tree instanceof HostTree) {
101+
} else if (HostTree.isHostTree(tree)) {
102102
return new FilterHostTree(tree, predicate);
103103
} else {
104104
throw new SchematicsException('Tree type is not supported.');

packages/angular_devkit/schematics/src/tree/host-tree.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ export class HostTree implements Tree {
109109
return this;
110110
}
111111

112+
static isHostTree(tree: Tree): tree is HostTree {
113+
if (tree instanceof HostTree) {
114+
return true;
115+
}
116+
117+
if (typeof tree === 'object' && typeof (tree as HostTree)._ancestry === 'object') {
118+
return true;
119+
}
120+
121+
return false;
122+
}
123+
112124
constructor(protected _backend: virtualFs.ReadonlyHost<{}> = new virtualFs.Empty()) {
113125
this._record = new virtualFs.CordHost(new virtualFs.SafeReadonlyHost(_backend));
114126
this._recordSync = new virtualFs.SyncDelegateHost(this._record);

packages/angular_devkit/schematics/src/tree/virtual.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ export class VirtualDirEntry implements DirEntry {
104104
}
105105
}
106106

107-
108107
/**
109108
* The root class of most trees.
110109
*/
@@ -114,6 +113,18 @@ export class VirtualTree implements Tree {
114113
protected _root = new VirtualDirEntry(this);
115114
protected _tree = new Map<Path, FileEntry>();
116115

116+
static isVirtualTree(tree: Tree): tree is VirtualTree {
117+
if (tree instanceof VirtualTree) {
118+
return true;
119+
}
120+
121+
if (typeof tree === 'object' && typeof (tree as VirtualTree)._copyTo === 'function') {
122+
return true;
123+
}
124+
125+
return false;
126+
}
127+
117128
/**
118129
* Normalize the path. Made available to subclasses to overload.
119130
* @param path The path to normalize.

packages/schematics/angular/workspace/files/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"codelyzer": "~4.3.0",
3535
"jasmine-core": "~2.99.1",
3636
"jasmine-spec-reporter": "~4.2.1",
37-
"karma": "~1.7.1",
37+
"karma": "~3.0.0",
3838
"karma-chrome-launcher": "~2.2.0",
3939
"karma-coverage-istanbul-reporter": "~2.0.1",
4040
"karma-jasmine": "~1.1.2",

scripts/validate-licenses.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ const licenseReplacements: { [key: string]: string } = {
6161

6262
// Specific packages to ignore, add a reason in a comment. Format: package-name@version.
6363
const ignoredPackages = [
64+
// Us.
65+
'@angular/[email protected]', // Hey, that's us!
6466
// * Development only
6567
'[email protected]', // CC0 but it's content only (index.json, no code) and not distributed.
6668
'[email protected]', // LGPL-3.0 but only used as a tool, not linked in the build.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { execAndWaitForOutputToMatch, execWithEnv, killAllProcesses } from '../../utils/process';
2+
3+
4+
export default async function() {
5+
try {
6+
await execAndWaitForOutputToMatch('ng', ['build', '--watch'], /./);
7+
8+
const output = await execWithEnv('ps', ['x'], { COLUMNS: '200' });
9+
10+
if (!output.stdout.match(/ng build --watch/)) {
11+
throw new Error('Title of the process was not properly set.');
12+
}
13+
} finally {
14+
await killAllProcesses();
15+
}
16+
}

tests/legacy-cli/e2e/utils/process.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { SpawnOptions } from "child_process";
12
import * as child_process from 'child_process';
23
import { terminal } from '@angular-devkit/core';
34
import { Observable, concat, defer, EMPTY, from} from 'rxjs';
@@ -11,6 +12,7 @@ const treeKill = require('tree-kill');
1112
interface ExecOptions {
1213
silent?: boolean;
1314
waitForMatch?: RegExp;
15+
env?: { [varname: string]: string };
1416
}
1517

1618

@@ -26,6 +28,7 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proc
2628
let stdout = '';
2729
let stderr = '';
2830
const cwd = process.cwd();
31+
const env = options.env;
2932
console.log(
3033
`==========================================================================================`
3134
);
@@ -41,7 +44,7 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proc
4144

4245
console.log(terminal.blue(`Running \`${cmd} ${args.map(x => `"${x}"`).join(' ')}\`${flags}...`));
4346
console.log(terminal.blue(`CWD: ${cwd}`));
44-
const spawnOptions: any = {cwd};
47+
const spawnOptions: SpawnOptions = {cwd, env};
4548

4649
if (process.platform.startsWith('win')) {
4750
args.unshift('/c', cmd);
@@ -146,6 +149,10 @@ export function silentExec(cmd: string, ...args: string[]) {
146149
return _exec({ silent: true }, cmd, args);
147150
}
148151

152+
export function execWithEnv(cmd: string, args: string[], env: { [varname: string]: string }) {
153+
return _exec({ env }, cmd, args);
154+
}
155+
149156
export function execAndWaitForOutputToMatch(cmd: string, args: string[], match: RegExp) {
150157
if (cmd === 'ng' && args[0] === 'serve') {
151158
// Accept matches up to 20 times after the initial match.

0 commit comments

Comments
 (0)