@angular-devkit/schematics 14.0.0-next.10 → 14.0.0-next.13
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/README.md +1 -1
- package/package.json +2 -2
- package/src/index.d.ts +2 -2
- package/src/index.js +3 -1
- package/src/tree/delegate.d.ts +3 -0
- package/src/tree/delegate.js +6 -0
- package/src/tree/host-tree.d.ts +3 -1
- package/src/tree/host-tree.js +30 -0
- package/src/tree/interface.d.ts +23 -1
- package/src/tree/null.d.ts +3 -1
- package/src/tree/null.js +6 -0
- package/src/tree/scoped.d.ts +3 -1
- package/src/tree/scoped.js +6 -0
- package/tasks/package-manager/executor.js +3 -0
- package/tasks/package-manager/install-task.d.ts +2 -0
- package/tasks/package-manager/install-task.js +5 -0
- package/tasks/package-manager/options.d.ts +1 -0
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ What distinguishes Schematics from other generators, such as Yeoman or Yarn Crea
|
|
|
23
23
|
|
|
24
24
|
# Tooling
|
|
25
25
|
|
|
26
|
-
Schematics is a library, and does not work by itself. A [reference CLI](https://github.com/angular/angular-cli/blob/
|
|
26
|
+
Schematics is a library, and does not work by itself. A [reference CLI](https://github.com/angular/angular-cli/blob/main/packages/angular_devkit/schematics_cli/bin/schematics.ts) is available on this repository, and is published on NPM at [@angular-devkit/schematics-cli](https://www.npmjs.com/package/@angular-devkit/schematics-cli). This document explains the library usage and the tooling API, but does not go into the tool implementation itself.
|
|
27
27
|
|
|
28
28
|
The tooling is responsible for the following tasks:
|
|
29
29
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/schematics",
|
|
3
|
-
"version": "14.0.0-next.
|
|
3
|
+
"version": "14.0.0-next.13",
|
|
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
|
"schematics"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@angular-devkit/core": "14.0.0-next.
|
|
21
|
+
"@angular-devkit/core": "14.0.0-next.13",
|
|
22
22
|
"jsonc-parser": "3.0.0",
|
|
23
23
|
"magic-string": "0.26.1",
|
|
24
24
|
"ora": "5.4.1",
|
package/src/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
+
import { strings } from '@angular-devkit/core';
|
|
8
9
|
import * as formats from './formats/index';
|
|
9
10
|
import { FilePredicate, MergeStrategy, Tree as TreeInterface } from './tree/interface';
|
|
10
11
|
import * as workflow from './workflow/index';
|
|
@@ -28,8 +29,7 @@ export * from './engine/schematic';
|
|
|
28
29
|
export * from './sink/dryrun';
|
|
29
30
|
export * from './sink/host';
|
|
30
31
|
export * from './sink/sink';
|
|
31
|
-
export { formats };
|
|
32
|
-
export { workflow };
|
|
32
|
+
export { formats, strings, workflow };
|
|
33
33
|
export interface TreeConstructor {
|
|
34
34
|
empty(): TreeInterface;
|
|
35
35
|
branch(tree: TreeInterface): TreeInterface;
|
package/src/index.js
CHANGED
|
@@ -33,7 +33,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
33
33
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Tree = exports.workflow = exports.formats = exports.SchematicsException = void 0;
|
|
36
|
+
exports.Tree = exports.workflow = exports.strings = exports.formats = exports.SchematicsException = void 0;
|
|
37
|
+
const core_1 = require("@angular-devkit/core");
|
|
38
|
+
Object.defineProperty(exports, "strings", { enumerable: true, get: function () { return core_1.strings; } });
|
|
37
39
|
const formats = __importStar(require("./formats/index"));
|
|
38
40
|
exports.formats = formats;
|
|
39
41
|
const interface_1 = require("./tree/interface");
|
package/src/tree/delegate.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="node" />
|
|
9
|
+
import { JsonValue } from '@angular-devkit/core';
|
|
9
10
|
import { Action } from './action';
|
|
10
11
|
import { DirEntry, FileEntry, FileVisitor, MergeStrategy, Tree, UpdateRecorder } from './interface';
|
|
11
12
|
export declare class DelegateTree implements Tree {
|
|
@@ -15,6 +16,8 @@ export declare class DelegateTree implements Tree {
|
|
|
15
16
|
merge(other: Tree, strategy?: MergeStrategy): void;
|
|
16
17
|
get root(): DirEntry;
|
|
17
18
|
read(path: string): Buffer | null;
|
|
19
|
+
readText(path: string): string;
|
|
20
|
+
readJson(path: string): JsonValue;
|
|
18
21
|
exists(path: string): boolean;
|
|
19
22
|
get(path: string): FileEntry | null;
|
|
20
23
|
getDir(path: string): DirEntry;
|
package/src/tree/delegate.js
CHANGED
|
@@ -26,6 +26,12 @@ class DelegateTree {
|
|
|
26
26
|
read(path) {
|
|
27
27
|
return this._other.read(path);
|
|
28
28
|
}
|
|
29
|
+
readText(path) {
|
|
30
|
+
return this._other.readText(path);
|
|
31
|
+
}
|
|
32
|
+
readJson(path) {
|
|
33
|
+
return this._other.readJson(path);
|
|
34
|
+
}
|
|
29
35
|
exists(path) {
|
|
30
36
|
return this._other.exists(path);
|
|
31
37
|
}
|
package/src/tree/host-tree.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="node" />
|
|
9
|
-
import { Path, PathFragment, virtualFs } from '@angular-devkit/core';
|
|
9
|
+
import { JsonValue, Path, PathFragment, virtualFs } from '@angular-devkit/core';
|
|
10
10
|
import { Action } from './action';
|
|
11
11
|
import { DirEntry, FileEntry, FilePredicate, FileVisitor, MergeStrategy, Tree, UpdateRecorder } from './interface';
|
|
12
12
|
export declare class HostDirEntry implements DirEntry {
|
|
@@ -41,6 +41,8 @@ export declare class HostTree implements Tree {
|
|
|
41
41
|
merge(other: Tree, strategy?: MergeStrategy): void;
|
|
42
42
|
get root(): DirEntry;
|
|
43
43
|
read(path: string): Buffer | null;
|
|
44
|
+
readText(path: string): string;
|
|
45
|
+
readJson(path: string): JsonValue;
|
|
44
46
|
exists(path: string): boolean;
|
|
45
47
|
get(path: string): FileEntry | null;
|
|
46
48
|
getDir(path: string): DirEntry;
|
package/src/tree/host-tree.js
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
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
|
+
const jsonc_parser_1 = require("jsonc-parser");
|
|
12
13
|
const rxjs_1 = require("rxjs");
|
|
13
14
|
const operators_1 = require("rxjs/operators");
|
|
15
|
+
const util_1 = require("util");
|
|
14
16
|
const exception_1 = require("../exception/exception");
|
|
15
17
|
const delegate_1 = require("./delegate");
|
|
16
18
|
const entry_1 = require("./entry");
|
|
@@ -208,6 +210,34 @@ class HostTree {
|
|
|
208
210
|
const entry = this.get(path);
|
|
209
211
|
return entry ? entry.content : null;
|
|
210
212
|
}
|
|
213
|
+
readText(path) {
|
|
214
|
+
const data = this.read(path);
|
|
215
|
+
if (data === null) {
|
|
216
|
+
throw new exception_1.FileDoesNotExistException(path);
|
|
217
|
+
}
|
|
218
|
+
const decoder = new util_1.TextDecoder('utf-8', { fatal: true });
|
|
219
|
+
try {
|
|
220
|
+
// With the `fatal` option enabled, invalid data will throw a TypeError
|
|
221
|
+
return decoder.decode(data);
|
|
222
|
+
}
|
|
223
|
+
catch (e) {
|
|
224
|
+
if (e instanceof TypeError) {
|
|
225
|
+
throw new Error(`Failed to decode "${path}" as UTF-8 text.`);
|
|
226
|
+
}
|
|
227
|
+
throw e;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
readJson(path) {
|
|
231
|
+
const content = this.readText(path);
|
|
232
|
+
const errors = [];
|
|
233
|
+
const result = (0, jsonc_parser_1.parse)(content, errors, { allowTrailingComma: true });
|
|
234
|
+
// If there is a parse error throw with the error information
|
|
235
|
+
if (errors[0]) {
|
|
236
|
+
const { error, offset } = errors[0];
|
|
237
|
+
throw new Error(`Failed to parse "${path}" as JSON. ${(0, jsonc_parser_1.printParseErrorCode)(error)} at offset: ${offset}.`);
|
|
238
|
+
}
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
211
241
|
exists(path) {
|
|
212
242
|
return this._recordSync.isFile(this._normalizePath(path));
|
|
213
243
|
}
|
package/src/tree/interface.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="node" />
|
|
9
|
-
import { Path, PathFragment } from '@angular-devkit/core';
|
|
9
|
+
import { JsonValue, Path, PathFragment } from '@angular-devkit/core';
|
|
10
10
|
import { Action } from './action';
|
|
11
11
|
export declare enum MergeStrategy {
|
|
12
12
|
AllowOverwriteConflict = 2,
|
|
@@ -41,6 +41,28 @@ export interface Tree {
|
|
|
41
41
|
merge(other: Tree, strategy?: MergeStrategy): void;
|
|
42
42
|
readonly root: DirEntry;
|
|
43
43
|
read(path: string): Buffer | null;
|
|
44
|
+
/**
|
|
45
|
+
* Reads a file from the Tree as a UTF-8 encoded text file.
|
|
46
|
+
*
|
|
47
|
+
* @param path The path of the file to read.
|
|
48
|
+
* @returns A string containing the contents of the file.
|
|
49
|
+
* @throws {@link FileDoesNotExistException} if the file is not found.
|
|
50
|
+
* @throws An error if the file contains invalid UTF-8 characters.
|
|
51
|
+
*/
|
|
52
|
+
readText(path: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Reads and parses a file from the Tree as a UTF-8 encoded JSON file.
|
|
55
|
+
* Supports parsing JSON (RFC 8259) with the following extensions:
|
|
56
|
+
* * Single-line and multi-line JavaScript comments
|
|
57
|
+
* * Trailing commas within objects and arrays
|
|
58
|
+
*
|
|
59
|
+
* @param path The path of the file to read.
|
|
60
|
+
* @returns A JsonValue containing the parsed contents of the file.
|
|
61
|
+
* @throws {@link FileDoesNotExistException} if the file is not found.
|
|
62
|
+
* @throws An error if the file contains invalid UTF-8 characters.
|
|
63
|
+
* @throws An error if the file contains malformed JSON.
|
|
64
|
+
*/
|
|
65
|
+
readJson(path: string): JsonValue;
|
|
44
66
|
exists(path: string): boolean;
|
|
45
67
|
get(path: string): FileEntry | null;
|
|
46
68
|
getDir(path: string): DirEntry;
|
package/src/tree/null.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="node" />
|
|
9
|
-
import { BaseException, Path, PathFragment } from '@angular-devkit/core';
|
|
9
|
+
import { BaseException, JsonValue, Path, PathFragment } from '@angular-devkit/core';
|
|
10
10
|
import { Action } from './action';
|
|
11
11
|
import { DirEntry, MergeStrategy, Tree, UpdateRecorder } from './interface';
|
|
12
12
|
export declare class CannotCreateFileException extends BaseException {
|
|
@@ -28,6 +28,8 @@ export declare class NullTree implements Tree {
|
|
|
28
28
|
readonly root: DirEntry;
|
|
29
29
|
exists(_path: string): boolean;
|
|
30
30
|
read(_path: string): null;
|
|
31
|
+
readText(path: string): string;
|
|
32
|
+
readJson(path: string): JsonValue;
|
|
31
33
|
get(_path: string): null;
|
|
32
34
|
getDir(path: string): NullTreeDirEntry;
|
|
33
35
|
visit(): void;
|
package/src/tree/null.js
CHANGED
|
@@ -54,6 +54,12 @@ class NullTree {
|
|
|
54
54
|
read(_path) {
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
|
+
readText(path) {
|
|
58
|
+
throw new exception_1.FileDoesNotExistException(path);
|
|
59
|
+
}
|
|
60
|
+
readJson(path) {
|
|
61
|
+
throw new exception_1.FileDoesNotExistException(path);
|
|
62
|
+
}
|
|
57
63
|
get(_path) {
|
|
58
64
|
return null;
|
|
59
65
|
}
|
package/src/tree/scoped.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="node" />
|
|
9
|
-
import { Path, PathFragment } from '@angular-devkit/core';
|
|
9
|
+
import { JsonValue, Path, PathFragment } from '@angular-devkit/core';
|
|
10
10
|
import { Action } from './action';
|
|
11
11
|
import { DirEntry, FileEntry, FileVisitor, MergeStrategy, Tree, UpdateRecorder } from './interface';
|
|
12
12
|
declare class ScopedDirEntry implements DirEntry {
|
|
@@ -29,6 +29,8 @@ export declare class ScopedTree implements Tree {
|
|
|
29
29
|
branch(): Tree;
|
|
30
30
|
merge(other: Tree, strategy?: MergeStrategy): void;
|
|
31
31
|
read(path: string): Buffer | null;
|
|
32
|
+
readText(path: string): string;
|
|
33
|
+
readJson(path: string): JsonValue;
|
|
32
34
|
exists(path: string): boolean;
|
|
33
35
|
get(path: string): FileEntry | null;
|
|
34
36
|
getDir(path: string): DirEntry;
|
package/src/tree/scoped.js
CHANGED
|
@@ -83,6 +83,12 @@ class ScopedTree {
|
|
|
83
83
|
read(path) {
|
|
84
84
|
return this._base.read(this._fullPath(path));
|
|
85
85
|
}
|
|
86
|
+
readText(path) {
|
|
87
|
+
return this._base.readText(this._fullPath(path));
|
|
88
|
+
}
|
|
89
|
+
readJson(path) {
|
|
90
|
+
return this._base.readJson(this._fullPath(path));
|
|
91
|
+
}
|
|
86
92
|
exists(path) {
|
|
87
93
|
return this._base.exists(this._fullPath(path));
|
|
88
94
|
}
|
|
@@ -110,6 +110,9 @@ function default_1(factoryOptions = {}) {
|
|
|
110
110
|
if (options.quiet && taskPackageManagerProfile.quietArgument) {
|
|
111
111
|
args.push(taskPackageManagerProfile.quietArgument);
|
|
112
112
|
}
|
|
113
|
+
if (!options.allowScripts) {
|
|
114
|
+
args.push('--ignore-scripts');
|
|
115
|
+
}
|
|
113
116
|
if (factoryOptions.registry) {
|
|
114
117
|
args.push(`--registry="${factoryOptions.registry}"`);
|
|
115
118
|
}
|
|
@@ -13,10 +13,12 @@ interface NodePackageInstallTaskOptions {
|
|
|
13
13
|
workingDirectory?: string;
|
|
14
14
|
quiet?: boolean;
|
|
15
15
|
hideOutput?: boolean;
|
|
16
|
+
allowScripts?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export declare class NodePackageInstallTask implements TaskConfigurationGenerator<NodePackageTaskOptions> {
|
|
18
19
|
quiet: boolean;
|
|
19
20
|
hideOutput: boolean;
|
|
21
|
+
allowScripts: boolean;
|
|
20
22
|
workingDirectory?: string;
|
|
21
23
|
packageManager?: string;
|
|
22
24
|
packageName?: string;
|
|
@@ -13,6 +13,7 @@ class NodePackageInstallTask {
|
|
|
13
13
|
constructor(options) {
|
|
14
14
|
this.quiet = true;
|
|
15
15
|
this.hideOutput = true;
|
|
16
|
+
this.allowScripts = false;
|
|
16
17
|
if (typeof options === 'string') {
|
|
17
18
|
this.workingDirectory = options;
|
|
18
19
|
}
|
|
@@ -32,6 +33,9 @@ class NodePackageInstallTask {
|
|
|
32
33
|
if (options.packageName != undefined) {
|
|
33
34
|
this.packageName = options.packageName;
|
|
34
35
|
}
|
|
36
|
+
if (options.allowScripts !== undefined) {
|
|
37
|
+
this.allowScripts = options.allowScripts;
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
toConfiguration() {
|
|
@@ -44,6 +48,7 @@ class NodePackageInstallTask {
|
|
|
44
48
|
workingDirectory: this.workingDirectory,
|
|
45
49
|
packageManager: this.packageManager,
|
|
46
50
|
packageName: this.packageName,
|
|
51
|
+
allowScripts: this.allowScripts,
|
|
47
52
|
},
|
|
48
53
|
};
|
|
49
54
|
}
|