@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 +2 -2
- package/src/rules/template.js +4 -1
- package/src/tree/host-tree.js +32 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/schematics",
|
|
3
|
-
"version": "18.0.0
|
|
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
|
|
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",
|
package/src/rules/template.js
CHANGED
|
@@ -42,7 +42,10 @@ function applyContentTemplate(options) {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
catch (e) {
|
|
45
|
-
|
|
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;
|
package/src/tree/host-tree.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
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;
|