Skip to content

Commit 9de1b3e

Browse files
committed
build: update to rxjs 7
G3 is now using RXJS version 7 which makes it possible for the CLI to also be updated to RXJS 7. NB: this change does not remove all usages of the deprecated APIs. Closes #24371
1 parent cf2f30a commit 9de1b3e

File tree

96 files changed

+1502
-1087
lines changed

Some content is hidden

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

96 files changed

+1502
-1087
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;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import { ErrorObject } from 'ajv';
88
import { Format } from 'ajv';
99
import { Observable } from 'rxjs';
10+
import { ObservableInput } from 'rxjs';
1011
import { Operator } from 'rxjs';
1112
import { PartialObserver } from 'rxjs';
1213
import { Position } from 'source-map';
1314
import { Subject } from 'rxjs';
14-
import { SubscribableOrPromise } from 'rxjs';
1515
import { Subscription } from 'rxjs';
1616
import { ValidateFunction } from 'ajv';
1717

@@ -715,7 +715,7 @@ interface PromptDefinition {
715715
}
716716

717717
// @public (undocumented)
718-
type PromptProvider = (definitions: Array<PromptDefinition>) => SubscribableOrPromise<{
718+
type PromptProvider = (definitions: Array<PromptDefinition>) => ObservableInput<{
719719
[id: string]: JsonValue;
720720
}>;
721721

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/commands/update/schematic/index_spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { normalize, virtualFs } from '@angular-devkit/core';
1010
import { HostTree } from '@angular-devkit/schematics';
1111
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
12+
import { lastValueFrom } from 'rxjs';
1213
import { map } from 'rxjs/operators';
1314
import * as semver from 'semver';
1415
import { angularMajorCompatGuarantee } from './index';
@@ -94,15 +95,15 @@ describe('@schematics/update', () => {
9495
),
9596
);
9697

97-
const newTree = await schematicRunner
98-
.runSchematicAsync(
98+
const newTree = await lastValueFrom(
99+
schematicRunner.runSchematicAsync(
99100
'update',
100101
{
101102
packages: ['@angular-devkit-tests/update-base'],
102103
},
103104
tree,
104-
)
105-
.toPromise();
105+
),
106+
);
106107
const { dependencies } = JSON.parse(newTree.readContent('/package.json'));
107108
expect(dependencies['@angular-devkit-tests/update-base']).toBe('1.1.0');
108109
});

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
}

0 commit comments

Comments
 (0)