Skip to content

Commit 1980210

Browse files
Merge pull request #278 from angular/master
Delete the redundant define test
2 parents 596c35b + 6ec0991 commit 1980210

File tree

77 files changed

+378
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+378
-222
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ http_archive(
1212
# We use protocol buffers for the Build Event Protocol
1313
git_repository(
1414
name = "com_google_protobuf",
15-
commit = "b6375e03aa80274dae89410efdf46346413b2247",
15+
commit = "beaeaeda34e97a6ff9735b33a66e011102ab506b",
1616
remote = "https://github.com/protocolbuffers/protobuf",
1717
)
1818

etc/api/angular_devkit/architect/src/index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export declare type BuilderInput = json.JsonObject & RealBuilderInput;
3838

3939
export declare type BuilderOutput = json.JsonObject & RealBuilderOutput;
4040

41-
export declare type BuilderOutputLike = Observable<BuilderOutput> | Promise<BuilderOutput> | BuilderOutput;
41+
export declare type BuilderOutputLike = SubscribableOrPromise<BuilderOutput> | BuilderOutput;
4242

4343
export declare type BuilderProgress = json.JsonObject & RealBuilderProgress & TypedBuilderProgress;
4444

@@ -60,6 +60,8 @@ export interface BuilderRun {
6060

6161
export declare function createBuilder<OptT extends json.JsonObject, OutT extends BuilderOutput = BuilderOutput>(fn: BuilderHandlerFn<OptT>): Builder<OptT>;
6262

63+
export declare function isBuilderOutput(obj: any): obj is BuilderOutput;
64+
6365
export interface ScheduleOptions {
6466
analytics?: analytics.Analytics;
6567
logger?: logging.Logger;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
"pidtree": "^0.3.0",
128128
"pidusage": "^2.0.17",
129129
"rxjs": "~6.4.0",
130-
"semver": "6.1.0",
130+
"semver": "6.1.1",
131131
"source-map": "^0.5.6",
132132
"source-map-support": "^0.5.0",
133133
"spdx-satisfies": "^4.0.0",

packages/angular/cli/commands/update-impl.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,19 @@ export class UpdateCommand extends SchematicCommand<UpdateCommandSchema> {
8383

8484
// If not asking for status then check for a clean git repository.
8585
// This allows the user to easily reset any changes from the update.
86-
if ((packages.length !== 0 || options.all) && !this.checkCleanGit()) {
87-
this.logger.error(
88-
'Repository is not clean. Please commit or stash any changes before updating.',
89-
);
86+
const statusCheck = packages.length === 0 && !options.all;
87+
if (!statusCheck && !this.checkCleanGit()) {
88+
if (options.allowDirty) {
89+
this.logger.warn(
90+
'Repository is not clean. Update changes will be mixed with pre-existing changes.',
91+
);
92+
} else {
93+
this.logger.error(
94+
'Repository is not clean. Please commit or stash any changes before updating.',
95+
);
9096

91-
return 2;
97+
return 2;
98+
}
9299
}
93100

94101
const packageManager = getPackageManager(this.workspace.root);

packages/angular/cli/commands/update.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
"to": {
5454
"description": "Version up to which to apply migrations. Only available with a single package being updated, and only on migrations only. Requires from to be specified. Default to the installed version detected.",
5555
"type": "string"
56+
},
57+
"allowDirty": {
58+
"description": "Whether to allow updating when the repository contains modified or untracked files.",
59+
"type": "boolean"
5660
}
5761
}
5862
}

packages/angular/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"open": "6.3.0",
3939
"pacote": "9.5.0",
4040
"read-package-tree": "5.2.2",
41-
"semver": "6.1.0",
41+
"semver": "6.1.1",
4242
"symbol-observable": "1.2.0",
4343
"universal-analytics": "^0.4.20",
4444
"uuid": "^3.3.2"

packages/angular/cli/utilities/tty.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export function isTTY(): boolean {
1111
return !(force === '0' || force.toUpperCase() === 'FALSE');
1212
}
1313

14-
return !!process.stdout.isTTY && !!process.stdin.isTTY;
14+
return !!process.stdout.isTTY && !!process.stdin.isTTY && !('CI' in process.env);
1515
}

packages/angular_devkit/architect/src/api.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { analytics, experimental, json, logging } from '@angular-devkit/core';
9-
import { Observable, from } from 'rxjs';
9+
import { Observable, SubscribableOrPromise, from } from 'rxjs';
1010
import { switchMap } from 'rxjs/operators';
1111
import { Schema as RealBuilderInput, Target as RealTarget } from './input-schema';
1212
import { Schema as RealBuilderOutput } from './output-schema';
@@ -250,8 +250,16 @@ export interface BuilderContext {
250250
/**
251251
* An accepted return value from a builder. Can be either an Observable, a Promise or a vector.
252252
*/
253-
export type BuilderOutputLike = Observable<BuilderOutput> | Promise<BuilderOutput> | BuilderOutput;
253+
export type BuilderOutputLike = SubscribableOrPromise<BuilderOutput> | BuilderOutput;
254254

255+
// tslint:disable-next-line:no-any
256+
export function isBuilderOutput(obj: any): obj is BuilderOutput {
257+
if (!obj || typeof obj.then === 'function' || typeof obj.subscribe === 'function') {
258+
return false;
259+
}
260+
261+
return typeof obj.success === 'boolean';
262+
}
255263

256264
/**
257265
* A builder handler function. The function signature passed to `createBuilder()`.

packages/angular_devkit/architect/src/create-builder.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
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 { analytics, experimental, isPromise, json, logging } from '@angular-devkit/core';
9-
import { Observable, Subscription, from, isObservable, of, throwError } from 'rxjs';
8+
import { analytics, experimental, json, logging } from '@angular-devkit/core';
9+
import { Observable, Subscription, from, of, throwError } from 'rxjs';
1010
import { tap } from 'rxjs/operators';
1111
import {
1212
BuilderContext,
1313
BuilderHandlerFn,
1414
BuilderInfo,
1515
BuilderInput,
1616
BuilderOutput,
17-
BuilderOutputLike,
1817
BuilderProgressState,
1918
ScheduleOptions,
2019
Target,
2120
TypedBuilderProgress,
21+
isBuilderOutput,
2222
targetStringFromTarget,
2323
} from './api';
2424
import { Builder, BuilderSymbol, BuilderVersionSymbol } from './internal';
@@ -189,19 +189,18 @@ export function createBuilder<
189189
};
190190

191191
context.reportRunning();
192-
let result: BuilderOutputLike;
192+
let result;
193193
try {
194194
result = fn(i.options as OptT, context);
195+
if (isBuilderOutput(result)) {
196+
result = of(result);
197+
} else {
198+
result = from(result);
199+
}
195200
} catch (e) {
196201
result = throwError(e);
197202
}
198203

199-
if (isPromise(result)) {
200-
result = from(result);
201-
} else if (!isObservable(result)) {
202-
result = of(result);
203-
}
204-
205204
// Manage some state automatically.
206205
progress({ state: BuilderProgressState.Running, current: 0, total: 1 }, context);
207206
subscriptions.push(result.pipe(

packages/angular_devkit/build_angular/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@ngtools/webpack": "0.0.0",
1515
"ajv": "6.10.0",
1616
"autoprefixer": "9.5.1",
17-
"browserslist": "4.6.0",
17+
"browserslist": "4.6.1",
1818
"caniuse-api": "3.0.0",
1919
"circular-dependency-plugin": "5.0.2",
2020
"clean-css": "4.2.1",
@@ -39,7 +39,7 @@
3939
"rxjs": "6.4.0",
4040
"sass": "1.20.1",
4141
"sass-loader": "7.1.0",
42-
"semver": "6.1.0",
42+
"semver": "6.1.1",
4343
"source-map-support": "0.5.12",
4444
"source-map-loader": "0.2.4",
4545
"speed-measure-webpack-plugin": "1.3.1",

packages/angular_devkit/build_angular/src/angular-cli-files/utilities/bundle-calculator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class BundleCalculator extends Calculator {
4848
const size: number = this.compilation.chunks
4949
.filter(chunk => chunk.name === this.budget.name)
5050
.reduce((files, chunk) => [...files, ...chunk.files], [])
51+
.filter((file: string) => !file.endsWith('.map'))
5152
.map((file: string) => this.compilation.assets[file].size())
5253
.reduce((total: number, size: number) => total + size, 0);
5354

packages/angular_devkit/build_angular/test/browser/bundle-budgets_spec_large.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ describe('Browser Builder bundle budgets', () => {
6565
});
6666

6767
describe(`should ignore '.map' files`, () => {
68+
it(`when 'bundle' budget`, async () => {
69+
const overrides = {
70+
optimization: true,
71+
budgets: [{ type: 'bundle', name: 'main', maximumError: '3Kb' }],
72+
};
73+
74+
const run = await architect.scheduleTarget(targetSpec, overrides);
75+
const output = await run.result;
76+
expect(output.success).toBe(true);
77+
await run.stop();
78+
});
79+
6880
it(`when 'intial' budget`, async () => {
6981
const overrides = {
7082
optimization: true,

packages/angular_devkit/schematics/tools/node-module-engine-host.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
7979
protected _resolveCollectionPath(name: string): string {
8080
let collectionPath: string | undefined = undefined;
8181

82-
if (name.replace(/\\/, '/').split('/').length > (name[0] == '@' ? 2 : 1)) {
82+
if (name.replace(/\\/g, '/').split('/').length > (name[0] == '@' ? 2 : 1)) {
8383
try {
8484
collectionPath = this._resolvePath(name, process.cwd());
8585
} catch {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
// tslint:disable:no-implicit-dependencies
10+
11+
import { SchematicEngine } from '@angular-devkit/schematics';
12+
import * as fs from 'fs';
13+
import * as os from 'os';
14+
import * as path from 'path';
15+
import { NodeModulesEngineHost } from './node-module-engine-host';
16+
17+
const TMP_DIR = process.env['$TEST_TMPDIR'] || os.tmpdir();
18+
19+
describe('NodeModulesEngineHost', () => {
20+
let tmpDir!: string;
21+
let previousDir!: string;
22+
23+
beforeEach(() => {
24+
tmpDir = fs.mkdtempSync(path.join(TMP_DIR,
25+
'angular-devkit-schematics-tools-node-module-engine-host'));
26+
previousDir = process.cwd();
27+
process.chdir(tmpDir);
28+
});
29+
30+
afterEach(() => process.chdir(previousDir));
31+
32+
/** Creates a fake NPM module that can be used to test the node module engine host. */
33+
function createFakeNpmModule() {
34+
fs.mkdirSync(path.join(tmpDir, 'node_modules'));
35+
fs.mkdirSync(path.join(tmpDir, 'node_modules/@angular/'));
36+
fs.mkdirSync(path.join(tmpDir, 'node_modules/@angular/core'));
37+
fs.mkdirSync(path.join(tmpDir, 'node_modules/@angular/core/schematics'));
38+
fs.writeFileSync(path.join(tmpDir, 'node_modules/@angular/core/package.json'),
39+
JSON.stringify({name: '@angular/core'}));
40+
fs.writeFileSync(path.join(tmpDir, 'node_modules/@angular/core/schematics/migrations.json'),
41+
JSON.stringify({schematics: {}}));
42+
}
43+
44+
it('should properly create collections with explicit collection path', () => {
45+
createFakeNpmModule();
46+
47+
const engineHost = new NodeModulesEngineHost();
48+
const engine = new SchematicEngine(engineHost);
49+
50+
expect(() => {
51+
engine.createCollection(path.join('@angular/core', './schematics/migrations.json'));
52+
}).not.toThrow();
53+
});
54+
});

packages/ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export class AngularCompilerPlugin {
152152
}
153153

154154
static isSupported() {
155-
return VERSION && parseInt(VERSION.major) >= 5;
155+
return VERSION && parseInt(VERSION.major) >= 8;
156156
}
157157

158158
private _setupOptions(options: AngularCompilerPluginOptions) {
@@ -660,24 +660,13 @@ export class AngularCompilerPlugin {
660660

661661
let ngccProcessor: NgccProcessor | undefined;
662662
if (this._compilerOptions.enableIvy) {
663-
let ngcc: typeof import('@angular/compiler-cli/ngcc') | undefined;
664-
try {
665-
// this is done for the sole reason that @ngtools/webpack
666-
// support versions of Angular that don't have NGCC API
667-
ngcc = require('@angular/compiler-cli/ngcc');
668-
} catch {
669-
}
670-
671-
if (ngcc) {
672-
ngccProcessor = new NgccProcessor(
673-
ngcc,
674-
this._mainFields,
675-
compilerWithFileSystems.inputFileSystem,
676-
this._warnings,
677-
this._errors,
678-
this._basePath,
679-
);
680-
}
663+
ngccProcessor = new NgccProcessor(
664+
this._mainFields,
665+
compilerWithFileSystems.inputFileSystem,
666+
this._warnings,
667+
this._errors,
668+
this._basePath,
669+
);
681670
}
682671

683672
// Create the webpack compiler host.

packages/ngtools/webpack/src/ngcc_processor.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { Logger } from '@angular/compiler-cli/ngcc';
9+
import { Logger, process as mainNgcc } from '@angular/compiler-cli/ngcc';
1010
import { existsSync } from 'fs';
1111
import * as path from 'path';
1212
import * as ts from 'typescript';
@@ -29,7 +29,6 @@ export class NgccProcessor {
2929
private _nodeModulesDirectory: string;
3030

3131
constructor(
32-
private readonly ngcc: typeof import('@angular/compiler-cli/ngcc'),
3332
private readonly propertiesToConsider: string[],
3433
private readonly inputFileSystem: InputFileSystem,
3534
private readonly compilationWarnings: (Error | string)[],
@@ -63,7 +62,7 @@ export class NgccProcessor {
6362

6463
const timeLabel = `NgccProcessor.processModule.ngcc.process+${moduleName}`;
6564
time(timeLabel);
66-
this.ngcc.process({
65+
mainNgcc({
6766
basePath: this._nodeModulesDirectory,
6867
targetEntryPointPath: path.dirname(packageJsonPath),
6968
propertiesToConsider: this.propertiesToConsider,

packages/schematics/angular/migrations/update-8/drop-es6-polyfills.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function dropES2015PolyfillsFromFile(polyfillPath: string): Rule {
106106
}
107107

108108
const sourceFile = ts.createSourceFile(polyfillPath,
109-
content,
109+
content.replace(/^\uFEFF/, ''),
110110
ts.ScriptTarget.Latest,
111111
true,
112112
);

packages/schematics/angular/migrations/update-8/update-lazy-module-paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function* visit(directory: DirEntry): IterableIterator<ts.SourceFile> {
1717
if (content.includes('loadChildren')) {
1818
const source = ts.createSourceFile(
1919
entry.path,
20-
content.toString(),
20+
content.toString().replace(/^\uFEFF/, ''),
2121
ts.ScriptTarget.Latest,
2222
true,
2323
);

packages/schematics/angular/migrations/update-8/update-lazy-module-paths_spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,19 @@ describe('Migration to version 8', () => {
7373
expect(routes).toContain(
7474
`loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule)`);
7575
});
76+
77+
it('should replace the module path string when file has BOM', async () => {
78+
tree.create(lazyRoutePath, '\uFEFF' + Buffer.from(lazyRoute).toString());
79+
80+
schematicRunner.runSchematic('migration-08', {}, tree);
81+
await schematicRunner.engine.executePostTasks().toPromise();
82+
83+
const routes = tree.readContent(lazyRoutePath);
84+
85+
expect(routes).not.toContain('./lazy/lazy.module#LazyModule');
86+
expect(routes).toContain(
87+
`loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule)`);
88+
});
89+
7690
});
7791
});

0 commit comments

Comments
 (0)