Skip to content

Commit beffa43

Browse files
committed
build: update to rxjs 7
1 parent cf2f30a commit beffa43

File tree

91 files changed

+1473
-1068
lines changed

Some content is hidden

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

91 files changed

+1473
-1068
lines changed

goldens/public-api/angular_devkit/architect/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { JsonObject } from '@angular-devkit/core';
1010
import { JsonValue } from '@angular-devkit/core';
1111
import { logging } from '@angular-devkit/core';
1212
import { Observable } from 'rxjs';
13+
import { ObservableInput } from 'rxjs';
1314
import { Observer } from 'rxjs';
1415
import { schema } from '@angular-devkit/core';
15-
import { SubscribableOrPromise } from 'rxjs';
1616

1717
// @public (undocumented)
1818
export class Architect {
@@ -67,7 +67,7 @@ export type BuilderInput = json.JsonObject & Schema;
6767
export type BuilderOutput = json.JsonObject & Schema_2;
6868

6969
// @public
70-
export type BuilderOutputLike = AsyncIterable<BuilderOutput> | SubscribableOrPromise<BuilderOutput> | BuilderOutput;
70+
export type BuilderOutputLike = ObservableInput<BuilderOutput> | BuilderOutput;
7171

7272
// @public (undocumented)
7373
export type BuilderProgress = json.JsonObject & Schema_3 & TypedBuilderProgress;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
"puppeteer": "18.2.1",
192192
"quicktype-core": "6.0.69",
193193
"resolve-url-loader": "5.0.0",
194-
"rxjs": "6.6.7",
194+
"rxjs": "7.6.0",
195195
"sass": "1.56.1",
196196
"sass-loader": "13.2.0",
197197
"sauce-connect-proxy": "https://saucelabs.com/downloads/sc-4.8.1-linux.tar.gz",

packages/angular/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"yargs": "17.6.2"
4343
},
4444
"devDependencies": {
45-
"rxjs": "6.6.7"
45+
"rxjs": "7.6.0"
4646
},
4747
"ng-update": {
4848
"migrations": "@schematics/angular/migrations/migration-collection.json",

packages/angular/cli/src/command-builder/architect-base-command-module.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { json } from '@angular-devkit/core';
1515
import { spawnSync } from 'child_process';
1616
import { existsSync } from 'fs';
17+
import assert from 'node:assert';
1718
import { resolve } from 'path';
1819
import { isPackageNameSafeForAnalytics } from '../analytics/analytics';
1920
import { EventCustomDimension, EventCustomMetric } from '../analytics/analytics-parameters';
@@ -85,7 +86,11 @@ export abstract class ArchitectBaseCommandModule<T extends object>
8586
}
8687

8788
try {
88-
const { error, success } = await run.output.toPromise();
89+
const output = await run.output.toPromise();
90+
// TODO(RXJS): temporary assert to avoid adding rxjs dependency.
91+
assert(output);
92+
93+
const { error, success } = output;
8994

9095
if (error) {
9196
logger.error(error);

packages/angular/cli/src/command-builder/utilities/json-schema.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import { json } from '@angular-devkit/core';
10+
import assert from 'node:assert';
1011
import yargs from 'yargs';
1112

1213
/**
@@ -198,6 +199,8 @@ export async function parseJsonSchemaToOptions(
198199
}
199200

200201
const flattenedSchema = await registry.flatten(schema).toPromise();
202+
// TODO(RXJS): temporary assert to avoid adding rxjs dependency.
203+
assert(flattenedSchema);
201204
json.schema.visitJsonSchema(flattenedSchema, visitor);
202205

203206
// Sort by positional and name.

packages/angular/cli/src/utilities/config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { json, workspaces } from '@angular-devkit/core';
1010
import { existsSync, promises as fs } from 'fs';
11+
import assert from 'node:assert';
1112
import * as os from 'os';
1213
import * as path from 'path';
1314
import { PackageManager } from '../../lib/config/workspace-schema';
@@ -254,8 +255,12 @@ export async function validateWorkspace(data: json.JsonObject, isGlobal: boolean
254255
const { formats } = await import('@angular-devkit/schematics');
255256
const registry = new json.schema.CoreSchemaRegistry(formats.standardFormats);
256257
const validator = await registry.compile(schemaToValidate).toPromise();
257-
258-
const { success, errors } = await validator(data).toPromise();
258+
// TODO(RXJS): temporary assert to avoid adding rxjs dependency.
259+
assert(validator);
260+
const result = await validator(data).toPromise();
261+
// TODO(RXJS): temporary assert to avoid adding rxjs dependency.
262+
assert(result);
263+
const { success, errors } = result;
259264
if (!success) {
260265
throw new json.schema.SchemaValidationException(errors);
261266
}

packages/angular/pwa/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ ts_library(
5959
":pwa",
6060
"//packages/angular_devkit/schematics/testing",
6161
"@npm//parse5-html-rewriting-stream",
62+
"@npm//rxjs",
6263
],
6364
)
6465

packages/angular/pwa/pwa/index_spec.ts

Lines changed: 61 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
1010
import * as path from 'path';
11+
// eslint-disable-next-line import/no-extraneous-dependencies
12+
import { lastValueFrom } from 'rxjs';
1113
import { Schema as PwaOptions } from './schema';
1214

1315
describe('PWA Schematic', () => {
@@ -39,86 +41,92 @@ describe('PWA Schematic', () => {
3941
};
4042

4143
beforeEach(async () => {
42-
appTree = await schematicRunner
43-
.runExternalSchematicAsync('@schematics/angular', 'workspace', workspaceOptions)
44-
.toPromise();
45-
appTree = await schematicRunner
46-
.runExternalSchematicAsync('@schematics/angular', 'application', appOptions, appTree)
47-
.toPromise();
44+
appTree = await lastValueFrom(
45+
schematicRunner.runExternalSchematicAsync(
46+
'@schematics/angular',
47+
'workspace',
48+
workspaceOptions,
49+
),
50+
);
51+
52+
appTree = await lastValueFrom(
53+
schematicRunner.runExternalSchematicAsync(
54+
'@schematics/angular',
55+
'application',
56+
appOptions,
57+
appTree,
58+
),
59+
);
4860
});
4961

5062
it('should run the service worker schematic', (done) => {
51-
schematicRunner
52-
.runSchematicAsync('ng-add', defaultOptions, appTree)
53-
.toPromise()
54-
.then((tree) => {
63+
lastValueFrom(schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree)).then(
64+
(tree) => {
5565
const configText = tree.readContent('/angular.json');
5666
const config = JSON.parse(configText);
5767
const swFlag = config.projects.bar.architect.build.options.serviceWorker;
5868
expect(swFlag).toEqual(true);
5969
done();
60-
}, done.fail);
70+
},
71+
done.fail,
72+
);
6173
});
6274

6375
it('should create icon files', (done) => {
6476
const dimensions = [72, 96, 128, 144, 152, 192, 384, 512];
6577
const iconPath = '/projects/bar/src/assets/icons/icon-';
66-
schematicRunner
67-
.runSchematicAsync('ng-add', defaultOptions, appTree)
68-
.toPromise()
69-
.then((tree) => {
78+
lastValueFrom(schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree)).then(
79+
(tree) => {
7080
dimensions.forEach((d) => {
7181
const path = `${iconPath}${d}x${d}.png`;
7282
expect(tree.exists(path)).toEqual(true);
7383
});
7484
done();
75-
}, done.fail);
85+
},
86+
done.fail,
87+
);
7688
});
7789

7890
it('should create a manifest file', (done) => {
79-
schematicRunner
80-
.runSchematicAsync('ng-add', defaultOptions, appTree)
81-
.toPromise()
82-
.then((tree) => {
91+
lastValueFrom(schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree)).then(
92+
(tree) => {
8393
expect(tree.exists('/projects/bar/src/manifest.webmanifest')).toEqual(true);
8494
done();
85-
}, done.fail);
95+
},
96+
done.fail,
97+
);
8698
});
8799

88100
it('should set the name & short_name in the manifest file', (done) => {
89-
schematicRunner
90-
.runSchematicAsync('ng-add', defaultOptions, appTree)
91-
.toPromise()
92-
.then((tree) => {
101+
lastValueFrom(schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree)).then(
102+
(tree) => {
93103
const manifestText = tree.readContent('/projects/bar/src/manifest.webmanifest');
94104
const manifest = JSON.parse(manifestText);
95105

96106
expect(manifest.name).toEqual(defaultOptions.title);
97107
expect(manifest.short_name).toEqual(defaultOptions.title);
98108
done();
99-
}, done.fail);
109+
},
110+
done.fail,
111+
);
100112
});
101113

102114
it('should set the name & short_name in the manifest file when no title provided', (done) => {
103115
const options = { ...defaultOptions, title: undefined };
104-
schematicRunner
105-
.runSchematicAsync('ng-add', options, appTree)
106-
.toPromise()
107-
.then((tree) => {
108-
const manifestText = tree.readContent('/projects/bar/src/manifest.webmanifest');
109-
const manifest = JSON.parse(manifestText);
110116

111-
expect(manifest.name).toEqual(defaultOptions.project);
112-
expect(manifest.short_name).toEqual(defaultOptions.project);
113-
done();
114-
}, done.fail);
117+
lastValueFrom(schematicRunner.runSchematicAsync('ng-add', options, appTree)).then((tree) => {
118+
const manifestText = tree.readContent('/projects/bar/src/manifest.webmanifest');
119+
const manifest = JSON.parse(manifestText);
120+
121+
expect(manifest.name).toEqual(defaultOptions.project);
122+
expect(manifest.short_name).toEqual(defaultOptions.project);
123+
done();
124+
}, done.fail);
115125
});
116126

117127
it('should update the index file', (done) => {
118-
schematicRunner
119-
.runSchematicAsync('ng-add', defaultOptions, appTree)
120-
.toPromise()
121-
.then((tree) => {
128+
lastValueFrom(schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree)).then(
129+
(tree) => {
122130
const content = tree.readContent('projects/bar/src/index.html');
123131

124132
expect(content).toMatch(/<link rel="manifest" href="manifest.webmanifest">/);
@@ -127,17 +135,17 @@ describe('PWA Schematic', () => {
127135
/<noscript>Please enable JavaScript to continue using this application.<\/noscript>/,
128136
);
129137
done();
130-
}, done.fail);
138+
},
139+
done.fail,
140+
);
131141
});
132142

133143
it('should not add noscript element to the index file if already present', (done) => {
134144
let index = appTree.readContent('projects/bar/src/index.html');
135145
index = index.replace('</body>', '<noscript>NO JAVASCRIPT</noscript></body>');
136146
appTree.overwrite('projects/bar/src/index.html', index);
137-
schematicRunner
138-
.runSchematicAsync('ng-add', defaultOptions, appTree)
139-
.toPromise()
140-
.then((tree) => {
147+
lastValueFrom(schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree)).then(
148+
(tree) => {
141149
const content = tree.readContent('projects/bar/src/index.html');
142150

143151
expect(content).toMatch(/<link rel="manifest" href="manifest.webmanifest">/);
@@ -147,14 +155,14 @@ describe('PWA Schematic', () => {
147155
);
148156
expect(content).toMatch(/<noscript>NO JAVASCRIPT<\/noscript>/);
149157
done();
150-
}, done.fail);
158+
},
159+
done.fail,
160+
);
151161
});
152162

153163
it('should update the build and test assets configuration', (done) => {
154-
schematicRunner
155-
.runSchematicAsync('ng-add', defaultOptions, appTree)
156-
.toPromise()
157-
.then((tree) => {
164+
lastValueFrom(schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree)).then(
165+
(tree) => {
158166
const configText = tree.readContent('/angular.json');
159167
const config = JSON.parse(configText);
160168
const targets = config.projects.bar.architect;
@@ -163,6 +171,8 @@ describe('PWA Schematic', () => {
163171
expect(targets[target].options.assets).toContain('projects/bar/src/manifest.webmanifest');
164172
});
165173
done();
166-
}, done.fail);
174+
},
175+
done.fail,
176+
);
167177
});
168178
});

packages/angular_devkit/architect/node/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ ts_library(
4040
deps = [
4141
":node",
4242
"//packages/angular_devkit/architect",
43+
"@npm//rxjs",
4344
],
4445
)
4546

packages/angular_devkit/architect/node/jobs/job-registry_spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { jobs } from '@angular-devkit/architect';
1010
import * as path from 'path';
11+
import { lastValueFrom } from 'rxjs';
1112
import { NodeModuleJobRegistry } from './job-registry';
1213

1314
const root = path.join(__dirname, '../../../../../tests/angular_devkit/architect/node/jobs');
@@ -18,6 +19,6 @@ describe('NodeModuleJobScheduler', () => {
1819
const scheduler = new jobs.SimpleScheduler(registry);
1920

2021
const job = scheduler.schedule(path.join(root, 'add'), [1, 2, 3]);
21-
expect(await job.output.toPromise()).toBe(6);
22+
expect(await lastValueFrom(job.output)).toBe(6);
2223
});
2324
});

packages/angular_devkit/architect/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"typings": "src/index.d.ts",
88
"dependencies": {
99
"@angular-devkit/core": "0.0.0-PLACEHOLDER",
10-
"rxjs": "6.6.7"
10+
"rxjs": "7.6.0"
1111
},
1212
"builders": "./builders/builders.json"
1313
}

packages/angular_devkit/architect/src/api.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import { json, logging } from '@angular-devkit/core';
10-
import { Observable, SubscribableOrPromise, Subscriber, from } from 'rxjs';
10+
import { Observable, ObservableInput, Subscriber, from } from 'rxjs';
1111
import { switchMap } from 'rxjs/operators';
1212
import { Schema as RealBuilderInput, Target as RealTarget } from './input-schema';
1313
import { Registry } from './jobs';
@@ -248,10 +248,7 @@ export interface BuilderContext {
248248
/**
249249
* An accepted return value from a builder. Can be either an Observable, a Promise or a vector.
250250
*/
251-
export type BuilderOutputLike =
252-
| AsyncIterable<BuilderOutput>
253-
| SubscribableOrPromise<BuilderOutput>
254-
| BuilderOutput;
251+
export type BuilderOutputLike = ObservableInput<BuilderOutput> | BuilderOutput;
255252

256253
// eslint-disable-next-line @typescript-eslint/no-explicit-any
257254
export function isBuilderOutput(obj: any): obj is BuilderOutput {

packages/angular_devkit/architect/src/architect.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
*/
88

99
import { json, logging } from '@angular-devkit/core';
10-
import { Observable, from, merge, of, onErrorResumeNext } from 'rxjs';
10+
import {
11+
Observable,
12+
firstValueFrom,
13+
from,
14+
lastValueFrom,
15+
merge,
16+
of,
17+
onErrorResumeNext,
18+
} from 'rxjs';
1119
import {
1220
concatMap,
1321
first,
@@ -335,9 +343,8 @@ function _validateOptionsFactory(host: ArchitectHost, registry: json.schema.Sche
335343
throw new Error(`No builder info were found for builder ${JSON.stringify(builderName)}.`);
336344
}
337345

338-
return registry
339-
.compile(builderInfo.optionSchema)
340-
.pipe(
346+
return firstValueFrom(
347+
registry.compile(builderInfo.optionSchema).pipe(
341348
concatMap((validation) => validation(options)),
342349
switchMap(({ data, success, errors }) => {
343350
if (success) {
@@ -346,8 +353,8 @@ function _validateOptionsFactory(host: ArchitectHost, registry: json.schema.Sche
346353

347354
throw new json.schema.SchemaValidationException(errors);
348355
}),
349-
)
350-
.toPromise();
356+
),
357+
);
351358
},
352359
{
353360
name: '..validateOptions',

0 commit comments

Comments
 (0)