Skip to content

Commit 4ebfe03

Browse files
committed
feat(@angular/cli): drop support for Node.js 12
Node.js v12 will become EOL on 2022-04-30. As a result, Angular CLI v14 will no longer support Node.js v12. BREAKING CHANGE: Support for Node.js v12 has been removed as it will become EOL on 2022-04-30. Please use Node.js v14.15 or later.
1 parent ef75362 commit 4ebfe03

File tree

17 files changed

+42
-253
lines changed

17 files changed

+42
-253
lines changed

‎constants.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Engine versions to stamp in a release package.json
2-
RELEASE_ENGINES_NODE = "^12.20.0 || ^14.15.0 || >=16.10.0"
2+
RELEASE_ENGINES_NODE = "^14.15.0 || >=16.10.0"
33
RELEASE_ENGINES_NPM = "^6.11.0 || ^7.5.6 || >=8.0.0"
44
RELEASE_ENGINES_YARN = ">= 1.13.0"
55

‎docs/DEVELOPER.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ To get started locally, follow these instructions:
66

77
1. If you haven't done it already, [make a fork of this repo](https://github.com/angular/angular-cli/fork).
88
1. Clone to your local computer using `git`.
9-
1. Make sure that you have Node `v12.20`, `v14.15`, or `v16.10` installed. See instructions [here](https://nodejs.org/en/download/).
9+
1. Make sure that you have Node `v14.15`, or `v16.10` installed. See instructions [here](https://nodejs.org/en/download/).
1010
1. Make sure that you have `yarn` installed; see instructions [here](https://yarnpkg.com/lang/en/docs/install/).
1111
1. Run `yarn` (no arguments) from the root of your clone of this project to install dependencies.
1212

‎lib/packages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function loadPackageJson(p: string) {
8585
// Overwrite engines to a common default.
8686
case 'engines':
8787
pkg['engines'] = {
88-
'node': '^12.20.0 || ^14.15.0 || >=16.10.0',
88+
'node': '^14.15.0 || >=16.10.0',
8989
'npm': '^6.11.0 || ^7.5.6 || >=8.0.0',
9090
'yarn': '>= 1.13.0',
9191
};

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"url": "https://github.com/angular/angular-cli.git"
4141
},
4242
"engines": {
43-
"node": "^12.20.0 || ^14.15.0 || ^16.10.0",
43+
"node": "^14.15.0 || ^16.10.0",
4444
"yarn": ">=1.21.1 <2",
4545
"npm": "Please use yarn instead of NPM to install dependencies"
4646
},
@@ -104,7 +104,7 @@
104104
"@types/karma": "^6.3.0",
105105
"@types/loader-utils": "^2.0.0",
106106
"@types/minimatch": "3.0.5",
107-
"@types/node": "~12.12.6",
107+
"@types/node": "^14.15.0",
108108
"@types/node-fetch": "^2.1.6",
109109
"@types/npm-package-arg": "^6.1.0",
110110
"@types/parse5-html-rewriting-stream": "^5.1.2",

‎packages/angular/cli/bin/ng.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,17 @@ if (version[0] % 2 === 1 && version[0] > 16) {
3636

3737
require('./bootstrap');
3838
} else if (
39-
version[0] < 12 ||
40-
version[0] === 13 ||
39+
version[0] < 14 ||
4140
version[0] === 15 ||
42-
(version[0] === 12 && version[1] < 20) ||
4341
(version[0] === 14 && version[1] < 15) ||
4442
(version[0] === 16 && version[1] < 10)
4543
) {
46-
// Error and exit if less than 12.20 or 13.x or less than 14.15 or 15.x or less than 16.10
44+
// Error and exit if less than 14.15 or 15.x or less than 16.10
4745
console.error(
4846
'Node.js version ' +
4947
process.version +
5048
' detected.\n' +
51-
'The Angular CLI requires a minimum Node.js version of either v12.20, v14.15, or v16.10.\n\n' +
49+
'The Angular CLI requires a minimum Node.js version of either v14.15, or v16.10.\n\n' +
5250
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
5351
);
5452

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

+5-26
Original file line numberDiff line numberDiff line change
@@ -635,32 +635,11 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
635635
try {
636636
// Remove existing node modules directory to provide a stronger guarantee that packages
637637
// will be hoisted into the correct locations.
638-
639-
// The below should be removed and replaced with just `rm` when support for Node.Js 12 is removed.
640-
const { rm, rmdir } = fs.promises as typeof fs.promises & {
641-
rm?: (
642-
path: fs.PathLike,
643-
options?: {
644-
force?: boolean;
645-
maxRetries?: number;
646-
recursive?: boolean;
647-
retryDelay?: number;
648-
},
649-
) => Promise<void>;
650-
};
651-
652-
if (rm) {
653-
await rm(path.join(this.context.root, 'node_modules'), {
654-
force: true,
655-
recursive: true,
656-
maxRetries: 3,
657-
});
658-
} else {
659-
await rmdir(path.join(this.context.root, 'node_modules'), {
660-
recursive: true,
661-
maxRetries: 3,
662-
});
663-
}
638+
await fs.promises.rm(path.join(this.context.root, 'node_modules'), {
639+
force: true,
640+
recursive: true,
641+
maxRetries: 3,
642+
});
664643
} catch {}
665644

666645
const result = await installAllPackages(

‎packages/angular/cli/lib/cli/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ const isDebug = debugEnv !== undefined && debugEnv !== '0' && debugEnv.toLowerCa
2222
/* eslint-disable no-console */
2323
export default async function (options: { testing?: boolean; cliArgs: string[] }) {
2424
// This node version check ensures that the requirements of the project instance of the CLI are met
25-
const version = process.versions.node.split('.').map((part) => Number(part));
26-
if (version[0] < 12 || (version[0] === 12 && version[1] < 20)) {
25+
const [major, minor] = process.versions.node.split('.').map((part) => Number(part));
26+
if (major < 14 || (major === 14 && minor < 15)) {
2727
process.stderr.write(
2828
`Node.js version ${process.version} detected.\n` +
29-
'The Angular CLI requires a minimum v12.20.\n\n' +
29+
'The Angular CLI requires a minimum v14.15.\n\n' +
3030
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
3131
);
3232

‎packages/angular_devkit/build_angular/src/utils/delete-output-dir.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,5 @@ export function deleteOutputDir(root: string, outputPath: string): void {
1818
throw new Error('Output path MUST not be project root directory!');
1919
}
2020

21-
// The below should be removed and replace with just `rmSync` when support for Node.Js 12 is removed.
22-
const { rmSync, rmdirSync } = fs as typeof fs & {
23-
rmSync?: (
24-
path: fs.PathLike,
25-
options?: {
26-
force?: boolean;
27-
maxRetries?: number;
28-
recursive?: boolean;
29-
retryDelay?: number;
30-
},
31-
) => void;
32-
};
33-
34-
if (rmSync) {
35-
rmSync(resolvedOutputPath, { force: true, recursive: true, maxRetries: 3 });
36-
} else {
37-
rmdirSync(resolvedOutputPath, { recursive: true, maxRetries: 3 });
38-
}
21+
fs.rmSync(resolvedOutputPath, { force: true, recursive: true, maxRetries: 3 });
3922
}

‎packages/angular_devkit/build_angular/src/utils/i18n-options.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -279,25 +279,8 @@ function findLocaleDataPath(locale: string, resolver: (locale: string) => string
279279

280280
/** Remove temporary directory used for i18n processing. */
281281
function deleteTempDirectory(tempPath: string): void {
282-
// The below should be removed and replaced with just `rmSync` when support for Node.Js 12 is removed.
283-
const { rmSync, rmdirSync } = fs as typeof fs & {
284-
rmSync?: (
285-
path: fs.PathLike,
286-
options?: {
287-
force?: boolean;
288-
maxRetries?: number;
289-
recursive?: boolean;
290-
retryDelay?: number;
291-
},
292-
) => void;
293-
};
294-
295282
try {
296-
if (rmSync) {
297-
rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
298-
} else {
299-
rmdirSync(tempPath, { recursive: true, maxRetries: 3 });
300-
}
283+
fs.rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
301284
} catch {}
302285
}
303286

‎packages/angular_devkit/build_angular/src/utils/purge-cache.ts

+1-16
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,12 @@ export async function purgeStaleBuildCache(context: BuilderContext): Promise<voi
2525
return;
2626
}
2727

28-
// The below should be removed and replaced with just `rm` when support for Node.Js 12 is removed.
29-
const { rm, rmdir } = fsPromises as typeof fsPromises & {
30-
rm?: (
31-
path: PathLike,
32-
options?: {
33-
force?: boolean;
34-
maxRetries?: number;
35-
recursive?: boolean;
36-
retryDelay?: number;
37-
},
38-
) => Promise<void>;
39-
};
40-
4128
const entriesToDelete = (await fsPromises.readdir(basePath, { withFileTypes: true }))
4229
.filter((d) => join(basePath, d.name) !== path && d.isDirectory())
4330
.map((d) => {
4431
const subPath = join(basePath, d.name);
4532
try {
46-
return rm
47-
? rm(subPath, { force: true, recursive: true, maxRetries: 3 })
48-
: rmdir(subPath, { recursive: true, maxRetries: 3 });
33+
return fsPromises.rm(subPath, { force: true, recursive: true, maxRetries: 3 });
4934
} catch {}
5035
});
5136

‎packages/angular_devkit/core/node/host.ts

+9-76
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,12 @@ import fs, {
1818
readdirSync,
1919
renameSync,
2020
statSync,
21-
unlinkSync,
2221
writeFileSync,
2322
} from 'fs';
2423
import { dirname as pathDirname } from 'path';
25-
import { Observable, concat, from as observableFrom, of, throwError } from 'rxjs';
26-
import { concatMap, map, mergeMap, publish, refCount } from 'rxjs/operators';
27-
import {
28-
Path,
29-
PathFragment,
30-
dirname,
31-
fragment,
32-
getSystemPath,
33-
join,
34-
normalize,
35-
virtualFs,
36-
} from '../src';
24+
import { Observable, from as observableFrom } from 'rxjs';
25+
import { map, mergeMap, publish, refCount } from 'rxjs/operators';
26+
import { Path, PathFragment, dirname, fragment, getSystemPath, normalize, virtualFs } from '../src';
3727

3828
async function exists(path: PathLike): Promise<boolean> {
3929
try {
@@ -88,31 +78,8 @@ export class NodeJsAsyncHost implements virtualFs.Host<Stats> {
8878
}
8979

9080
delete(path: Path): Observable<void> {
91-
return this.isDirectory(path).pipe(
92-
mergeMap(async (isDirectory) => {
93-
if (isDirectory) {
94-
// The below should be removed and replaced with just `rm` when support for Node.Js 12 is removed.
95-
const { rm, rmdir } = fsPromises as typeof fsPromises & {
96-
rm?: (
97-
path: fs.PathLike,
98-
options?: {
99-
force?: boolean;
100-
maxRetries?: number;
101-
recursive?: boolean;
102-
retryDelay?: number;
103-
},
104-
) => Promise<void>;
105-
};
106-
107-
if (rm) {
108-
await rm(getSystemPath(path), { force: true, recursive: true, maxRetries: 3 });
109-
} else {
110-
await rmdir(getSystemPath(path), { recursive: true, maxRetries: 3 });
111-
}
112-
} else {
113-
await fsPromises.unlink(getSystemPath(path));
114-
}
115-
}),
81+
return observableFrom(
82+
fsPromises.rm(getSystemPath(path), { force: true, recursive: true, maxRetries: 3 }),
11683
);
11784
}
11885

@@ -208,45 +175,11 @@ export class NodeJsSyncHost implements virtualFs.Host<Stats> {
208175
}
209176

210177
delete(path: Path): Observable<void> {
211-
return this.isDirectory(path).pipe(
212-
concatMap((isDir) => {
213-
if (isDir) {
214-
const dirPaths = readdirSync(getSystemPath(path));
215-
const rmDirComplete = new Observable<void>((obs) => {
216-
// The below should be removed and replaced with just `rmSync` when support for Node.Js 12 is removed.
217-
const { rmSync, rmdirSync } = fs as typeof fs & {
218-
rmSync?: (
219-
path: fs.PathLike,
220-
options?: {
221-
force?: boolean;
222-
maxRetries?: number;
223-
recursive?: boolean;
224-
retryDelay?: number;
225-
},
226-
) => void;
227-
};
228-
229-
if (rmSync) {
230-
rmSync(getSystemPath(path), { force: true, recursive: true, maxRetries: 3 });
231-
} else {
232-
rmdirSync(getSystemPath(path), { recursive: true, maxRetries: 3 });
233-
}
234-
235-
obs.complete();
236-
});
178+
return new Observable<void>((obs) => {
179+
fs.rmSync(getSystemPath(path), { force: true, recursive: true, maxRetries: 3 });
237180

238-
return concat(...dirPaths.map((name) => this.delete(join(path, name))), rmDirComplete);
239-
} else {
240-
try {
241-
unlinkSync(getSystemPath(path));
242-
} catch (err) {
243-
return throwError(err);
244-
}
245-
246-
return of(undefined);
247-
}
248-
}),
249-
);
181+
obs.complete();
182+
});
250183
}
251184

252185
rename(from: Path, to: Path): Observable<void> {

‎scripts/build-bazel.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,7 @@ function _recursiveCopy(from: string, to: string, logger: logging.Logger) {
5050
}
5151

5252
function rimraf(location: string) {
53-
// The below should be removed and replace with just `rmSync` when support for Node.Js 12 is removed.
54-
const { rmSync, rmdirSync } = fs as typeof fs & {
55-
rmSync?: (
56-
path: fs.PathLike,
57-
options?: {
58-
force?: boolean;
59-
maxRetries?: number;
60-
recursive?: boolean;
61-
retryDelay?: number;
62-
},
63-
) => void;
64-
};
65-
66-
if (rmSync) {
67-
rmSync(location, { force: true, recursive: true, maxRetries: 3 });
68-
} else {
69-
rmdirSync(location, { recursive: true, maxRetries: 3 });
70-
}
53+
fs.rmSync(location, { force: true, recursive: true, maxRetries: 3 });
7154
}
7255

7356
function _clean(logger: logging.Logger) {

‎scripts/build-schema.ts

+1-19
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,7 @@ export default async function (argv: {}, logger: logging.Logger) {
1919

2020
const quicktypeRunner = require('../tools/quicktype_runner');
2121
logger.info('Removing dist-schema/...');
22-
23-
// The below should be removed and replace with just `rmSync` when support for Node.Js 12 is removed.
24-
const { rmSync, rmdirSync } = fs as typeof fs & {
25-
rmSync?: (
26-
path: fs.PathLike,
27-
options?: {
28-
force?: boolean;
29-
maxRetries?: number;
30-
recursive?: boolean;
31-
retryDelay?: number;
32-
},
33-
) => void;
34-
};
35-
36-
if (rmSync) {
37-
rmSync(dist, { force: true, recursive: true, maxRetries: 3 });
38-
} else {
39-
rmdirSync(dist, { recursive: true, maxRetries: 3 });
40-
}
22+
fs.rmSync(dist, { force: true, recursive: true, maxRetries: 3 });
4123

4224
logger.info('Generating JSON Schema....');
4325

‎scripts/build.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,7 @@ function _rm(p: string) {
122122
}
123123

124124
function rimraf(location: string) {
125-
// The below should be removed and replace with just `rmSync` when support for Node.Js 12 is removed.
126-
const { rmSync, rmdirSync } = fs as typeof fs & {
127-
rmSync?: (
128-
path: fs.PathLike,
129-
options?: {
130-
force?: boolean;
131-
maxRetries?: number;
132-
recursive?: boolean;
133-
retryDelay?: number;
134-
},
135-
) => void;
136-
};
137-
138-
if (rmSync) {
139-
rmSync(location, { force: true, recursive: true, maxRetries: 3 });
140-
} else {
141-
rmdirSync(location, { recursive: true, maxRetries: 3 });
142-
}
125+
fs.rmSync(location, { force: true, recursive: true, maxRetries: 3 });
143126
}
144127

145128
function _clean(logger: logging.Logger) {

0 commit comments

Comments
 (0)