@angular-devkit/schematics 18.0.0-rc.2 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-devkit/schematics",
3
- "version": "18.0.0-rc.2",
3
+ "version": "18.0.0",
4
4
  "description": "Angular Schematics - Library",
5
5
  "main": "src/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "tooling"
19
19
  ],
20
20
  "dependencies": {
21
- "@angular-devkit/core": "18.0.0-rc.2",
21
+ "@angular-devkit/core": "18.0.0",
22
22
  "jsonc-parser": "3.2.1",
23
23
  "magic-string": "0.30.10",
24
24
  "ora": "5.4.1",
@@ -42,7 +42,10 @@ function applyContentTemplate(options) {
42
42
  };
43
43
  }
44
44
  catch (e) {
45
- if (e instanceof TypeError) {
45
+ // The second part should not be needed. But Jest does not support instanceof correctly.
46
+ // See: https://github.com/jestjs/jest/issues/2549
47
+ if (e instanceof TypeError ||
48
+ e.code === 'ERR_ENCODING_INVALID_ENCODED_DATA') {
46
49
  return entry;
47
50
  }
48
51
  throw e;
@@ -10,8 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.FilterHostTree = exports.HostCreateTree = exports.HostTree = exports.HostDirEntry = void 0;
11
11
  const core_1 = require("@angular-devkit/core");
12
12
  const jsonc_parser_1 = require("jsonc-parser");
13
- const rxjs_1 = require("rxjs");
14
- const util_1 = require("util");
15
13
  const exception_1 = require("../exception/exception");
16
14
  const delegate_1 = require("./delegate");
17
15
  const entry_1 = require("./entry");
@@ -221,13 +219,16 @@ class HostTree {
221
219
  if (data === null) {
222
220
  throw new exception_1.FileDoesNotExistException(path);
223
221
  }
224
- const decoder = new util_1.TextDecoder('utf-8', { fatal: true });
222
+ const decoder = new TextDecoder('utf-8', { fatal: true });
225
223
  try {
226
224
  // With the `fatal` option enabled, invalid data will throw a TypeError
227
225
  return decoder.decode(data);
228
226
  }
229
227
  catch (e) {
230
- if (e instanceof TypeError) {
228
+ // The second part should not be needed. But Jest does not support instanceof correctly.
229
+ // See: https://github.com/jestjs/jest/issues/2549
230
+ if (e instanceof TypeError ||
231
+ e.code === 'ERR_ENCODING_INVALID_ENCODED_DATA') {
231
232
  throw new Error(`Failed to decode "${path}" as UTF-8 text.`);
232
233
  }
233
234
  throw e;
@@ -396,28 +397,34 @@ class FilterHostTree extends HostTree {
396
397
  const newBackend = new core_1.virtualFs.SimpleMemoryHost();
397
398
  // cast to allow access
398
399
  const originalBackend = tree._backend;
399
- const recurse = (base) => {
400
- return originalBackend.list(base).pipe((0, rxjs_1.mergeMap)((x) => x), (0, rxjs_1.map)((path) => (0, core_1.join)(base, path)), (0, rxjs_1.concatMap)((path) => {
401
- let isDirectory = false;
402
- originalBackend.isDirectory(path).subscribe((val) => (isDirectory = val));
403
- if (isDirectory) {
404
- return recurse(path);
405
- }
406
- let isFile = false;
407
- originalBackend.isFile(path).subscribe((val) => (isFile = val));
408
- if (!isFile || !filter(path)) {
409
- return rxjs_1.EMPTY;
410
- }
411
- let content = null;
412
- originalBackend.read(path).subscribe((val) => (content = val));
413
- if (!content) {
414
- return rxjs_1.EMPTY;
415
- }
416
- return newBackend.write(path, content);
417
- }));
418
- };
419
- recurse((0, core_1.normalize)('/')).subscribe();
400
+ // Walk the original backend and add files that match the filter to the new backend
401
+ const pendingPaths = ['/'];
402
+ while (pendingPaths.length > 0) {
403
+ const currentPath = pendingPaths.pop();
404
+ if (currentPath === undefined) {
405
+ break;
406
+ }
407
+ let isDirectory = false;
408
+ originalBackend.isDirectory(currentPath).subscribe((val) => (isDirectory = val));
409
+ if (isDirectory) {
410
+ originalBackend
411
+ .list(currentPath)
412
+ .subscribe((val) => pendingPaths.push(...val.map((p) => (0, core_1.join)(currentPath, p))));
413
+ continue;
414
+ }
415
+ let isFile = false;
416
+ originalBackend.isFile(currentPath).subscribe((val) => (isFile = val));
417
+ if (!isFile || !filter(currentPath)) {
418
+ continue;
419
+ }
420
+ let content = null;
421
+ originalBackend.read(currentPath).subscribe((val) => (content = val));
422
+ if (content !== null) {
423
+ newBackend.write(currentPath, content).subscribe();
424
+ }
425
+ }
420
426
  super(newBackend);
427
+ // Add actions that match the filter to new tree
421
428
  for (const action of tree.actions) {
422
429
  if (!filter(action.path)) {
423
430
  continue;