@yuuvis/client-cli 19.2.0 → 19.3.1
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 +3 -1
- package/package.json +1 -1
- package/schematics/commands/angular-json.d.ts +122 -0
- package/schematics/commands/angular-json.js +228 -0
- package/schematics/commands/angular-json.js.map +1 -0
- package/schematics/commands/app-config-ts.d.ts +11 -0
- package/schematics/commands/app-config-ts.js +44 -0
- package/schematics/commands/app-config-ts.js.map +1 -0
- package/schematics/commands/app-routes-ts.d.ts +12 -0
- package/schematics/commands/app-routes-ts.js +72 -0
- package/schematics/commands/app-routes-ts.js.map +1 -0
- package/schematics/commands/library-component.d.ts +25 -0
- package/schematics/commands/library-component.js +71 -0
- package/schematics/commands/library-component.js.map +1 -0
- package/schematics/commands/ng-package-json.d.ts +67 -0
- package/schematics/commands/ng-package-json.js +102 -0
- package/schematics/commands/ng-package-json.js.map +1 -0
- package/schematics/commands/package-json.d.ts +102 -0
- package/schematics/commands/package-json.js +158 -0
- package/schematics/commands/package-json.js.map +1 -0
- package/schematics/commands/public-api-ts.d.ts +68 -0
- package/schematics/commands/public-api-ts.js +102 -0
- package/schematics/commands/public-api-ts.js.map +1 -0
- package/schematics/commands/tsconfig-json.d.ts +71 -0
- package/schematics/commands/tsconfig-json.js +118 -0
- package/schematics/commands/tsconfig-json.js.map +1 -0
- package/schematics/commands/typescript-file.d.ts +64 -0
- package/schematics/commands/typescript-file.js +127 -0
- package/schematics/commands/typescript-file.js.map +1 -0
- package/schematics/factories/add-app/index.js +6 -5
- package/schematics/factories/add-app/index.js.map +1 -1
- package/schematics/factories/generate-app/index.js +107 -63
- package/schematics/factories/generate-app/index.js.map +1 -1
- package/schematics/factories/new/index.js +66 -27
- package/schematics/factories/new/index.js.map +1 -1
- package/schematics/files/_root/README.md +8 -0
- package/schematics/files/_scripts/i18n-collect.js +72 -48
- package/schematics/files/_scripts/i18n-extract.js +24 -17
- package/schematics/files/_scripts/update-shell.js +18 -0
- package/schematics/files/_src/styles.scss +4 -3
- package/schematics/files/_src_app/app.routes.ts.template +1 -1
- package/schematics/patches/impl/0001.patch.js +4 -15
- package/schematics/patches/impl/0001.patch.js.map +1 -1
- package/schematics/project-util.d.ts +1 -1
- package/schematics/project-util.js +1 -0
- package/schematics/project-util.js.map +1 -1
- package/schematics/rules/app-config.d.ts +2 -0
- package/schematics/{tasks/copy-ui-files.js → rules/app-config.js} +13 -14
- package/schematics/rules/app-config.js.map +1 -0
- package/schematics/{tasks/update-app-routes.d.ts → rules/app-routes.d.ts} +1 -1
- package/schematics/{tasks/copy-extensions-files.js → rules/app-routes.js} +13 -14
- package/schematics/rules/app-routes.js.map +1 -0
- package/schematics/{tasks → rules}/clean-up-ng-app.js.map +1 -1
- package/schematics/{tasks/copy-extensions-files.d.ts → rules/copy-resources.d.ts} +2 -0
- package/schematics/{tasks/copy-files.js → rules/copy-resources.js} +31 -3
- package/schematics/rules/copy-resources.js.map +1 -0
- package/schematics/rules/create-update-manifest.d.ts +3 -0
- package/schematics/{tasks → rules}/create-update-manifest.js +2 -2
- package/schematics/rules/create-update-manifest.js.map +1 -0
- package/schematics/{tasks → rules}/generate-library.js.map +1 -1
- package/schematics/{tasks → rules}/ng-new.js.map +1 -1
- package/schematics/{tasks → rules}/npm-install.js.map +1 -1
- package/schematics/schematics-util.d.ts +1 -2
- package/schematics/schematics-util.js +0 -13
- package/schematics/schematics-util.js.map +1 -1
- package/schematics/types/ng-package-json.d.ts +93 -0
- package/schematics/types/ng-package-json.js +3 -0
- package/schematics/types/ng-package-json.js.map +1 -0
- package/schematics/{types.d.ts → types/package-json.d.ts} +3 -0
- package/schematics/{types.js → types/package-json.js} +1 -1
- package/schematics/types/package-json.js.map +1 -0
- package/schematics/types/tsconfig-json.d.ts +69 -0
- package/schematics/types/tsconfig-json.js +3 -0
- package/schematics/types/tsconfig-json.js.map +1 -0
- package/schematics/tasks/copy-extensions-files.js.map +0 -1
- package/schematics/tasks/copy-files.d.ts +0 -2
- package/schematics/tasks/copy-files.js.map +0 -1
- package/schematics/tasks/copy-ui-files.d.ts +0 -2
- package/schematics/tasks/copy-ui-files.js.map +0 -1
- package/schematics/tasks/create-update-manifest.d.ts +0 -4
- package/schematics/tasks/create-update-manifest.js.map +0 -1
- package/schematics/tasks/update-angular-json.d.ts +0 -4
- package/schematics/tasks/update-angular-json.js +0 -105
- package/schematics/tasks/update-angular-json.js.map +0 -1
- package/schematics/tasks/update-app-config.d.ts +0 -2
- package/schematics/tasks/update-app-config.js +0 -69
- package/schematics/tasks/update-app-config.js.map +0 -1
- package/schematics/tasks/update-app-ng-package-json.d.ts +0 -2
- package/schematics/tasks/update-app-ng-package-json.js +0 -71
- package/schematics/tasks/update-app-ng-package-json.js.map +0 -1
- package/schematics/tasks/update-app-routes.js +0 -91
- package/schematics/tasks/update-app-routes.js.map +0 -1
- package/schematics/tasks/update-library-component.d.ts +0 -2
- package/schematics/tasks/update-library-component.js +0 -108
- package/schematics/tasks/update-library-component.js.map +0 -1
- package/schematics/tasks/update-library-public-api.d.ts +0 -2
- package/schematics/tasks/update-library-public-api.js +0 -38
- package/schematics/tasks/update-library-public-api.js.map +0 -1
- package/schematics/tasks/update-library-tsconfig.d.ts +0 -2
- package/schematics/tasks/update-library-tsconfig.js +0 -51
- package/schematics/tasks/update-library-tsconfig.js.map +0 -1
- package/schematics/tasks/update-package-json.d.ts +0 -2
- package/schematics/tasks/update-package-json.js +0 -32
- package/schematics/tasks/update-package-json.js.map +0 -1
- package/schematics/types.js.map +0 -1
- /package/schematics/{tasks → rules}/clean-up-ng-app.d.ts +0 -0
- /package/schematics/{tasks → rules}/clean-up-ng-app.js +0 -0
- /package/schematics/{tasks → rules}/generate-library.d.ts +0 -0
- /package/schematics/{tasks → rules}/generate-library.js +0 -0
- /package/schematics/{tasks → rules}/ng-new.d.ts +0 -0
- /package/schematics/{tasks → rules}/ng-new.js +0 -0
- /package/schematics/{tasks → rules}/npm-install.d.ts +0 -0
- /package/schematics/{tasks → rules}/npm-install.js +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Tree } from "@angular-devkit/schematics";
|
|
2
|
+
import { AssetPattern, NgPackageConfig } from "../types/ng-package-json";
|
|
3
|
+
/**
|
|
4
|
+
* Interface for commands that can be executed on an ng-package.json file.
|
|
5
|
+
* This interface defines a method to execute a command that modifies the ng-package.json file.
|
|
6
|
+
*/
|
|
7
|
+
export interface NgPackageJsonCommand {
|
|
8
|
+
execute(ngPackageJson: NgPackageConfig): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Composite command that executes multiple NgPackageJsonCommand instances.
|
|
12
|
+
* This class allows for the execution of a series of commands on an ng-package.json file.
|
|
13
|
+
*/
|
|
14
|
+
export declare class CompositeNgPackageJsonCommand implements NgPackageJsonCommand {
|
|
15
|
+
private readonly commands;
|
|
16
|
+
constructor(commands: NgPackageJsonCommand[]);
|
|
17
|
+
/**
|
|
18
|
+
* Executes all commands in the composite command.
|
|
19
|
+
* @param ngPackageJson The ng-package.json object to modify.
|
|
20
|
+
*/
|
|
21
|
+
execute(ngPackageJson: NgPackageConfig): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Adds assets to the ng-package.json file.
|
|
25
|
+
*/
|
|
26
|
+
export declare class AddAssetsCommand implements NgPackageJsonCommand {
|
|
27
|
+
private readonly assets;
|
|
28
|
+
constructor(assets: AssetPattern[]);
|
|
29
|
+
execute(ngPackageJson: NgPackageConfig): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Class for editing the ng-package.json file.
|
|
33
|
+
*/
|
|
34
|
+
export declare class NgPackageJsonEditor {
|
|
35
|
+
private readonly tree;
|
|
36
|
+
private readonly path;
|
|
37
|
+
private constructor();
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new instance of NgPackageJsonEditor.
|
|
40
|
+
* @param tree The Angular DevKit Tree object representing the file system.
|
|
41
|
+
* @param path The path to the ng-package.json file.
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
static create(tree: Tree, path: string): NgPackageJsonEditor;
|
|
45
|
+
/**
|
|
46
|
+
* Executes the given command on the ng-package.json file.
|
|
47
|
+
* @param command The command to execute on the ng-package.json file.
|
|
48
|
+
*/
|
|
49
|
+
run(command: NgPackageJsonCommand): void;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the content of the ng-package.json file.
|
|
52
|
+
* @returns The ng-package.json object.
|
|
53
|
+
*/
|
|
54
|
+
getContent(): NgPackageConfig;
|
|
55
|
+
/**
|
|
56
|
+
* Loads the ng-package.json file from the specified path.
|
|
57
|
+
* @returns The ng-package.json object loaded from the file.
|
|
58
|
+
* @throws {SchematicsException} If the ng-package.json file does not exist or cannot be read.
|
|
59
|
+
*/
|
|
60
|
+
private load;
|
|
61
|
+
/**
|
|
62
|
+
* Saves the ng-package.json file to the specified path
|
|
63
|
+
* @param ngPackageJson
|
|
64
|
+
* This method overwrites the existing ng-package.json file with the provided object.
|
|
65
|
+
*/
|
|
66
|
+
private save;
|
|
67
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NgPackageJsonEditor = exports.AddAssetsCommand = exports.CompositeNgPackageJsonCommand = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
/**
|
|
6
|
+
* Composite command that executes multiple NgPackageJsonCommand instances.
|
|
7
|
+
* This class allows for the execution of a series of commands on an ng-package.json file.
|
|
8
|
+
*/
|
|
9
|
+
class CompositeNgPackageJsonCommand {
|
|
10
|
+
constructor(commands) {
|
|
11
|
+
this.commands = commands;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Executes all commands in the composite command.
|
|
15
|
+
* @param ngPackageJson The ng-package.json object to modify.
|
|
16
|
+
*/
|
|
17
|
+
execute(ngPackageJson) {
|
|
18
|
+
this.commands.forEach(command => command.execute(ngPackageJson));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CompositeNgPackageJsonCommand = CompositeNgPackageJsonCommand;
|
|
22
|
+
/**
|
|
23
|
+
* Adds assets to the ng-package.json file.
|
|
24
|
+
*/
|
|
25
|
+
class AddAssetsCommand {
|
|
26
|
+
constructor(assets) {
|
|
27
|
+
this.assets = assets;
|
|
28
|
+
}
|
|
29
|
+
execute(ngPackageJson) {
|
|
30
|
+
var _a;
|
|
31
|
+
ngPackageJson.assets = (_a = ngPackageJson.assets) !== null && _a !== void 0 ? _a : [];
|
|
32
|
+
const newAssets = this.assets.filter(asset => {
|
|
33
|
+
return !ngPackageJson.assets.some(existing => typeof existing === 'object' && typeof asset === 'object' &&
|
|
34
|
+
existing.input === asset.input &&
|
|
35
|
+
existing.glob === asset.glob &&
|
|
36
|
+
existing.output === asset.output);
|
|
37
|
+
});
|
|
38
|
+
if (newAssets.length > 0) {
|
|
39
|
+
ngPackageJson.assets.push(...newAssets);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.AddAssetsCommand = AddAssetsCommand;
|
|
44
|
+
/**
|
|
45
|
+
* Class for editing the ng-package.json file.
|
|
46
|
+
*/
|
|
47
|
+
class NgPackageJsonEditor {
|
|
48
|
+
constructor(tree, path) {
|
|
49
|
+
this.tree = tree;
|
|
50
|
+
this.path = path;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new instance of NgPackageJsonEditor.
|
|
54
|
+
* @param tree The Angular DevKit Tree object representing the file system.
|
|
55
|
+
* @param path The path to the ng-package.json file.
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
static create(tree, path) {
|
|
59
|
+
return new NgPackageJsonEditor(tree, path);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Executes the given command on the ng-package.json file.
|
|
63
|
+
* @param command The command to execute on the ng-package.json file.
|
|
64
|
+
*/
|
|
65
|
+
run(command) {
|
|
66
|
+
const ngPackageJson = this.load();
|
|
67
|
+
command.execute(ngPackageJson);
|
|
68
|
+
this.save(ngPackageJson);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the content of the ng-package.json file.
|
|
72
|
+
* @returns The ng-package.json object.
|
|
73
|
+
*/
|
|
74
|
+
getContent() {
|
|
75
|
+
return this.load();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Loads the ng-package.json file from the specified path.
|
|
79
|
+
* @returns The ng-package.json object loaded from the file.
|
|
80
|
+
* @throws {SchematicsException} If the ng-package.json file does not exist or cannot be read.
|
|
81
|
+
*/
|
|
82
|
+
load() {
|
|
83
|
+
if (!this.tree.exists(this.path)) {
|
|
84
|
+
throw new schematics_1.SchematicsException(`ng-package.json not found at ${this.path}`);
|
|
85
|
+
}
|
|
86
|
+
const buffer = this.tree.read(this.path);
|
|
87
|
+
if (!buffer) {
|
|
88
|
+
throw new schematics_1.SchematicsException(`Failed to read ${this.path} at ${this.path}`);
|
|
89
|
+
}
|
|
90
|
+
return JSON.parse(buffer.toString('utf-8'));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Saves the ng-package.json file to the specified path
|
|
94
|
+
* @param ngPackageJson
|
|
95
|
+
* This method overwrites the existing ng-package.json file with the provided object.
|
|
96
|
+
*/
|
|
97
|
+
save(ngPackageJson) {
|
|
98
|
+
this.tree.overwrite(this.path, JSON.stringify(ngPackageJson, null, 2));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.NgPackageJsonEditor = NgPackageJsonEditor;
|
|
102
|
+
//# sourceMappingURL=ng-package-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-package-json.js","sourceRoot":"","sources":["../../../src/schematics/commands/ng-package-json.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AAWvE;;;GAGG;AACH,MAAa,6BAA6B;IACxC,YAA6B,QAAgC;QAAhC,aAAQ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I,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,OAA6B;QAC/B,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAClC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACK,IAAI;QACV,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,gCAAmB,CAAC,gCAAgC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,gCAAmB,CAAC,kBAAkB,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAoB,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACK,IAAI,CAAC,aAA8B;QACzC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;CACF;AAxDD,kDAwDC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Tree } from "@angular-devkit/schematics";
|
|
2
|
+
import { PackageJson } from "../types/package-json";
|
|
3
|
+
/**
|
|
4
|
+
* Interface for commands that can be executed on a PackageJson object.
|
|
5
|
+
*/
|
|
6
|
+
export interface PackageJsonCommand {
|
|
7
|
+
/**
|
|
8
|
+
* Executes the command on the provided package.json object.
|
|
9
|
+
* @param packageJson The package.json object to modify.
|
|
10
|
+
*/
|
|
11
|
+
execute(packageJson: PackageJson): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Composite command that executes multiple PackageJsonCommand instances.
|
|
15
|
+
*/
|
|
16
|
+
export declare class CompositePackageJsonCommand implements PackageJsonCommand {
|
|
17
|
+
private readonly commands;
|
|
18
|
+
constructor(commands: PackageJsonCommand[]);
|
|
19
|
+
/**
|
|
20
|
+
* Executes all commands in the composite command.
|
|
21
|
+
* @param packageJson The package.json object to modify.
|
|
22
|
+
*/
|
|
23
|
+
execute(packageJson: PackageJson): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Adds or updates dependencies with passed key-value pairs in the package.json file.
|
|
27
|
+
* Existing keys will be overwritten, and the resulting dependencies will be sorted alphabetically.
|
|
28
|
+
*/
|
|
29
|
+
export declare class AddDependenciesCommand implements PackageJsonCommand {
|
|
30
|
+
private readonly dependencies;
|
|
31
|
+
constructor(dependencies: Record<string, string>);
|
|
32
|
+
execute(packageJson: PackageJson): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Adds or updates devDependencies with passed key-value pairs in the package.json file.
|
|
36
|
+
* Existing keys will be overwritten, and the resulting devDependencies will be sorted alphabetically.
|
|
37
|
+
*/
|
|
38
|
+
export declare class AddDevDependenciesCommand implements PackageJsonCommand {
|
|
39
|
+
private readonly devDependencies;
|
|
40
|
+
constructor(devDependencies: Record<string, string>);
|
|
41
|
+
execute(packageJson: PackageJson): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Adds or updates scripts with passed key-value pairs in the package.json file.
|
|
45
|
+
* Existing keys will be overwritten, and the resulting scripts will be sorted alphabetically.
|
|
46
|
+
*/
|
|
47
|
+
export declare class AddScriptsCommand implements PackageJsonCommand {
|
|
48
|
+
private readonly scripts;
|
|
49
|
+
constructor(scripts: Record<string, string>);
|
|
50
|
+
execute(packageJson: PackageJson): void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Adds or enhances scripts in the package.json file.
|
|
54
|
+
* If a script already exists, it appends the new value using the specified operator ('&&' or '||').
|
|
55
|
+
* If the script does not exist, it adds it with the provided value.
|
|
56
|
+
* The operator can be used to chain commands together.
|
|
57
|
+
*/
|
|
58
|
+
export declare class AddOrEnhanceScriptsCommand implements PackageJsonCommand {
|
|
59
|
+
private readonly scripts;
|
|
60
|
+
private readonly operator;
|
|
61
|
+
constructor(scripts: Record<string, string>, operator?: '&&' | '||');
|
|
62
|
+
execute(packageJson: PackageJson): void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Class for editing a package.json file.
|
|
66
|
+
*/
|
|
67
|
+
export declare class PackageJsonEditor {
|
|
68
|
+
private readonly tree;
|
|
69
|
+
private readonly path;
|
|
70
|
+
private constructor();
|
|
71
|
+
/**
|
|
72
|
+
* Creates a new PackageJsonEditor instance.
|
|
73
|
+
* @param tree The Angular DevKit Tree to operate on.
|
|
74
|
+
* @param path The path to the package.json file. Defaults to 'package.json'.
|
|
75
|
+
* @returns A Promise that resolves to a new PackageJsonEditor instance.
|
|
76
|
+
*/
|
|
77
|
+
static create(tree: Tree, path?: string): Promise<PackageJsonEditor>;
|
|
78
|
+
/**
|
|
79
|
+
* Executes the given command on the package.json file.
|
|
80
|
+
* @param command The command to execute on the package.json file.
|
|
81
|
+
*/
|
|
82
|
+
run(command: PackageJsonCommand): void;
|
|
83
|
+
/**
|
|
84
|
+
* Gets the content of the package.json file.
|
|
85
|
+
* @returns The package.json object.
|
|
86
|
+
*/
|
|
87
|
+
getContent(): PackageJson;
|
|
88
|
+
/**
|
|
89
|
+
* Loads the package.json file from the specified path.
|
|
90
|
+
* If the file does not exist or cannot be read, it throws a SchematicsException.
|
|
91
|
+
* @returns The package.json object loaded from the file.
|
|
92
|
+
* @throws {SchematicsException} If the package.json file does not exist or cannot be read.
|
|
93
|
+
*/
|
|
94
|
+
private load;
|
|
95
|
+
/**
|
|
96
|
+
* Saves the package.json file to the specified path.
|
|
97
|
+
* @param packageJson The package.json object to save.
|
|
98
|
+
* This method overwrites the existing package.json file with the provided object.
|
|
99
|
+
* @throws {SchematicsException} If the package.json file cannot be written.
|
|
100
|
+
*/
|
|
101
|
+
private save;
|
|
102
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PackageJsonEditor = exports.AddOrEnhanceScriptsCommand = exports.AddScriptsCommand = exports.AddDevDependenciesCommand = exports.AddDependenciesCommand = exports.CompositePackageJsonCommand = void 0;
|
|
13
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
|
+
const project_util_1 = require("../project-util");
|
|
15
|
+
/**
|
|
16
|
+
* Composite command that executes multiple PackageJsonCommand instances.
|
|
17
|
+
*/
|
|
18
|
+
class CompositePackageJsonCommand {
|
|
19
|
+
constructor(commands) {
|
|
20
|
+
this.commands = commands;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Executes all commands in the composite command.
|
|
24
|
+
* @param packageJson The package.json object to modify.
|
|
25
|
+
*/
|
|
26
|
+
execute(packageJson) {
|
|
27
|
+
this.commands.forEach(command => command.execute(packageJson));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.CompositePackageJsonCommand = CompositePackageJsonCommand;
|
|
31
|
+
/**
|
|
32
|
+
* Adds or updates dependencies with passed key-value pairs in the package.json file.
|
|
33
|
+
* Existing keys will be overwritten, and the resulting dependencies will be sorted alphabetically.
|
|
34
|
+
*/
|
|
35
|
+
class AddDependenciesCommand {
|
|
36
|
+
constructor(dependencies) {
|
|
37
|
+
this.dependencies = dependencies;
|
|
38
|
+
}
|
|
39
|
+
execute(packageJson) {
|
|
40
|
+
packageJson.dependencies = Object.fromEntries(Object.entries(Object.assign(Object.assign({}, packageJson.dependencies), this.dependencies)).sort(([a], [b]) => a.localeCompare(b)));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.AddDependenciesCommand = AddDependenciesCommand;
|
|
44
|
+
/**
|
|
45
|
+
* Adds or updates devDependencies with passed key-value pairs in the package.json file.
|
|
46
|
+
* Existing keys will be overwritten, and the resulting devDependencies will be sorted alphabetically.
|
|
47
|
+
*/
|
|
48
|
+
class AddDevDependenciesCommand {
|
|
49
|
+
constructor(devDependencies) {
|
|
50
|
+
this.devDependencies = devDependencies;
|
|
51
|
+
}
|
|
52
|
+
execute(packageJson) {
|
|
53
|
+
packageJson.devDependencies = Object.fromEntries(Object.entries(Object.assign(Object.assign({}, packageJson.devDependencies), this.devDependencies)).sort(([a], [b]) => a.localeCompare(b)));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.AddDevDependenciesCommand = AddDevDependenciesCommand;
|
|
57
|
+
/**
|
|
58
|
+
* Adds or updates scripts with passed key-value pairs in the package.json file.
|
|
59
|
+
* Existing keys will be overwritten, and the resulting scripts will be sorted alphabetically.
|
|
60
|
+
*/
|
|
61
|
+
class AddScriptsCommand {
|
|
62
|
+
constructor(scripts) {
|
|
63
|
+
this.scripts = scripts;
|
|
64
|
+
}
|
|
65
|
+
execute(packageJson) {
|
|
66
|
+
packageJson.scripts = Object.fromEntries(Object.entries(Object.assign(Object.assign({}, packageJson.scripts), this.scripts)).sort(([a], [b]) => a.localeCompare(b)));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.AddScriptsCommand = AddScriptsCommand;
|
|
70
|
+
/**
|
|
71
|
+
* Adds or enhances scripts in the package.json file.
|
|
72
|
+
* If a script already exists, it appends the new value using the specified operator ('&&' or '||').
|
|
73
|
+
* If the script does not exist, it adds it with the provided value.
|
|
74
|
+
* The operator can be used to chain commands together.
|
|
75
|
+
*/
|
|
76
|
+
class AddOrEnhanceScriptsCommand {
|
|
77
|
+
constructor(scripts, operator = '&&') {
|
|
78
|
+
this.scripts = scripts;
|
|
79
|
+
this.operator = operator;
|
|
80
|
+
}
|
|
81
|
+
execute(packageJson) {
|
|
82
|
+
var _a;
|
|
83
|
+
packageJson.scripts = (_a = packageJson.scripts) !== null && _a !== void 0 ? _a : {};
|
|
84
|
+
Object.entries(this.scripts).forEach(([key, value]) => {
|
|
85
|
+
if (packageJson.scripts[key]) {
|
|
86
|
+
packageJson.scripts[key] += ` ${this.operator} ${value}`;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
packageJson.scripts[key] = value;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.AddOrEnhanceScriptsCommand = AddOrEnhanceScriptsCommand;
|
|
95
|
+
/**
|
|
96
|
+
* Class for editing a package.json file.
|
|
97
|
+
*/
|
|
98
|
+
class PackageJsonEditor {
|
|
99
|
+
constructor(tree, path) {
|
|
100
|
+
this.tree = tree;
|
|
101
|
+
this.path = path;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a new PackageJsonEditor instance.
|
|
105
|
+
* @param tree The Angular DevKit Tree to operate on.
|
|
106
|
+
* @param path The path to the package.json file. Defaults to 'package.json'.
|
|
107
|
+
* @returns A Promise that resolves to a new PackageJsonEditor instance.
|
|
108
|
+
*/
|
|
109
|
+
static create(tree, path) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const packageJsonPath = path !== null && path !== void 0 ? path : yield (0, project_util_1.getPackageJsonPath)(tree);
|
|
112
|
+
return new PackageJsonEditor(tree, packageJsonPath);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Executes the given command on the package.json file.
|
|
117
|
+
* @param command The command to execute on the package.json file.
|
|
118
|
+
*/
|
|
119
|
+
run(command) {
|
|
120
|
+
const packageJson = this.load();
|
|
121
|
+
command.execute(packageJson);
|
|
122
|
+
this.save(packageJson);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Gets the content of the package.json file.
|
|
126
|
+
* @returns The package.json object.
|
|
127
|
+
*/
|
|
128
|
+
getContent() {
|
|
129
|
+
return this.load();
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Loads the package.json file from the specified path.
|
|
133
|
+
* If the file does not exist or cannot be read, it throws a SchematicsException.
|
|
134
|
+
* @returns The package.json object loaded from the file.
|
|
135
|
+
* @throws {SchematicsException} If the package.json file does not exist or cannot be read.
|
|
136
|
+
*/
|
|
137
|
+
load() {
|
|
138
|
+
if (!this.tree.exists(this.path)) {
|
|
139
|
+
throw new schematics_1.SchematicsException(`package.json not found at ${this.path}`);
|
|
140
|
+
}
|
|
141
|
+
const content = this.tree.read(this.path);
|
|
142
|
+
if (!content) {
|
|
143
|
+
throw new schematics_1.SchematicsException(`Failed to read package.json at ${this.path}`);
|
|
144
|
+
}
|
|
145
|
+
return JSON.parse(content.toString());
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Saves the package.json file to the specified path.
|
|
149
|
+
* @param packageJson The package.json object to save.
|
|
150
|
+
* This method overwrites the existing package.json file with the provided object.
|
|
151
|
+
* @throws {SchematicsException} If the package.json file cannot be written.
|
|
152
|
+
*/
|
|
153
|
+
save(packageJson) {
|
|
154
|
+
this.tree.overwrite(this.path, JSON.stringify(packageJson, null, 2));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.PackageJsonEditor = PackageJsonEditor;
|
|
158
|
+
//# sourceMappingURL=package-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.js","sourceRoot":"","sources":["../../../src/schematics/commands/package-json.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAuE;AACvE,kDAAqD;AAcrD;;GAEG;AACH,MAAa,2BAA2B;IACtC,YAA6B,QAA8B;QAA9B,aAAQ,GAAR,QAAQ,CAAsB;IAAG,CAAC;IAC/D;;;OAGG;IACH,OAAO,CAAC,WAAwB;QAC9B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IACjE,CAAC;CACF;AATD,kEASC;AAED;;;GAGG;AACH,MAAa,sBAAsB;IACjC,YAA6B,YAAoC;QAApC,iBAAY,GAAZ,YAAY,CAAwB;IAAG,CAAC;IAErE,OAAO,CAAC,WAAwB;QAC9B,WAAW,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAC3C,MAAM,CAAC,OAAO,iCACT,WAAW,CAAC,YAAY,GACxB,IAAI,CAAC,YAAY,EACpB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAC1C,CAAC;IACJ,CAAC;CACF;AAXD,wDAWC;AAED;;;GAGG;AACH,MAAa,yBAAyB;IACpC,YAA6B,eAAuC;QAAvC,oBAAe,GAAf,eAAe,CAAwB;IAAG,CAAC;IAExE,OAAO,CAAC,WAAwB;QAC9B,WAAW,CAAC,eAAe,GAAG,MAAM,CAAC,WAAW,CAC9C,MAAM,CAAC,OAAO,iCACT,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,OAAO,CAAC,QAAQ,EAAE,CAAgB,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACK,IAAI,CAAC,WAAwB;QACnC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC;CACF;AA3DD,8CA2DC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Tree, UpdateRecorder } from "@angular-devkit/schematics";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for commands that can be executed on a public-api.ts file.
|
|
4
|
+
* This interface defines a method to execute a command that modifies the public-api.ts file.
|
|
5
|
+
*/
|
|
6
|
+
export interface PublicApiTsCommand {
|
|
7
|
+
/**
|
|
8
|
+
* Executes the command on the provided public-api.ts content.
|
|
9
|
+
* @param content The content of the public-api.ts file to modify.
|
|
10
|
+
* @param updateRecorder The UpdateRecorder to apply changes to the file.
|
|
11
|
+
*/
|
|
12
|
+
execute(content: string, updateRecorder: UpdateRecorder): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Composite command that executes multiple PublicApiTsCommand instances.
|
|
16
|
+
* This class allows for the execution of a series of commands on a public-api.ts file.
|
|
17
|
+
*/
|
|
18
|
+
export declare class CompositePublicApiTsCommand implements PublicApiTsCommand {
|
|
19
|
+
private readonly commands;
|
|
20
|
+
constructor(commands: PublicApiTsCommand[]);
|
|
21
|
+
/**
|
|
22
|
+
* Executes all commands in the composite command.
|
|
23
|
+
* @param content The content of the public-api.ts file to modify.
|
|
24
|
+
* @param updateRecorder The UpdateRecorder to apply changes to the file.
|
|
25
|
+
*/
|
|
26
|
+
execute(content: string, updateRecorder: UpdateRecorder): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Adds export statements to the public-api.ts file.
|
|
30
|
+
* This command allows for the addition of new export statements to the public-api.ts file.
|
|
31
|
+
*/
|
|
32
|
+
export declare class AddExportsCommand implements PublicApiTsCommand {
|
|
33
|
+
private readonly exports;
|
|
34
|
+
constructor(exports: string[]);
|
|
35
|
+
execute(content: string, updateRecorder: UpdateRecorder): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Edits the public-api.ts file.
|
|
39
|
+
*/
|
|
40
|
+
export declare class PublicApiTsEditor {
|
|
41
|
+
private readonly tree;
|
|
42
|
+
private readonly path;
|
|
43
|
+
private constructor();
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new instance of PublicApiTsEditor.
|
|
46
|
+
* @param tree The Angular DevKit Tree object representing the file system.
|
|
47
|
+
* @param path The path to the public-api.ts file.
|
|
48
|
+
* @returns A promise that resolves to a PublicApiTsEditor instance.
|
|
49
|
+
*/
|
|
50
|
+
static create(tree: Tree, path: string): Promise<PublicApiTsEditor>;
|
|
51
|
+
/**
|
|
52
|
+
* Runs the given command on the public-api.ts file.
|
|
53
|
+
* @param command The command to run.
|
|
54
|
+
*/
|
|
55
|
+
run(command: PublicApiTsCommand): void;
|
|
56
|
+
/**
|
|
57
|
+
* Gets the content of the public-api.ts file.
|
|
58
|
+
* @returns The content of the public-api.ts file.
|
|
59
|
+
*/
|
|
60
|
+
getContent(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Loads the content of the public-api.ts file.
|
|
63
|
+
* If the file does not exist or cannot be read, it throws a SchematicsException.
|
|
64
|
+
* @throws {SchematicsException} If the public-api.ts file does not exist or
|
|
65
|
+
* @returns The content of the public-api.ts file as a string.
|
|
66
|
+
*/
|
|
67
|
+
private load;
|
|
68
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PublicApiTsEditor = exports.AddExportsCommand = exports.CompositePublicApiTsCommand = void 0;
|
|
13
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
|
+
/**
|
|
15
|
+
* Composite command that executes multiple PublicApiTsCommand instances.
|
|
16
|
+
* This class allows for the execution of a series of commands on a public-api.ts file.
|
|
17
|
+
*/
|
|
18
|
+
class CompositePublicApiTsCommand {
|
|
19
|
+
constructor(commands) {
|
|
20
|
+
this.commands = commands;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Executes all commands in the composite command.
|
|
24
|
+
* @param content The content of the public-api.ts file to modify.
|
|
25
|
+
* @param updateRecorder The UpdateRecorder to apply changes to the file.
|
|
26
|
+
*/
|
|
27
|
+
execute(content, updateRecorder) {
|
|
28
|
+
this.commands.forEach(command => command.execute(content, updateRecorder));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.CompositePublicApiTsCommand = CompositePublicApiTsCommand;
|
|
32
|
+
/**
|
|
33
|
+
* Adds export statements to the public-api.ts file.
|
|
34
|
+
* This command allows for the addition of new export statements to the public-api.ts file.
|
|
35
|
+
*/
|
|
36
|
+
class AddExportsCommand {
|
|
37
|
+
constructor(exports) {
|
|
38
|
+
this.exports = exports;
|
|
39
|
+
}
|
|
40
|
+
execute(content, updateRecorder) {
|
|
41
|
+
const newExports = this.exports
|
|
42
|
+
.filter(exportStatement => !content.includes(exportStatement))
|
|
43
|
+
.map(statement => `\n${statement}`)
|
|
44
|
+
.join('');
|
|
45
|
+
if (newExports.length > 0) {
|
|
46
|
+
updateRecorder.insertRight(content.length, newExports + '\n');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.AddExportsCommand = AddExportsCommand;
|
|
51
|
+
/**
|
|
52
|
+
* Edits the public-api.ts file.
|
|
53
|
+
*/
|
|
54
|
+
class PublicApiTsEditor {
|
|
55
|
+
constructor(tree, path) {
|
|
56
|
+
this.tree = tree;
|
|
57
|
+
this.path = path;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new instance of PublicApiTsEditor.
|
|
61
|
+
* @param tree The Angular DevKit Tree object representing the file system.
|
|
62
|
+
* @param path The path to the public-api.ts file.
|
|
63
|
+
* @returns A promise that resolves to a PublicApiTsEditor instance.
|
|
64
|
+
*/
|
|
65
|
+
static create(tree, path) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
return new PublicApiTsEditor(tree, path);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Runs the given command on the public-api.ts file.
|
|
72
|
+
* @param command The command to run.
|
|
73
|
+
*/
|
|
74
|
+
run(command) {
|
|
75
|
+
const content = this.load();
|
|
76
|
+
const recorder = this.tree.beginUpdate(this.path);
|
|
77
|
+
command.execute(content, recorder);
|
|
78
|
+
this.tree.commitUpdate(recorder);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Gets the content of the public-api.ts file.
|
|
82
|
+
* @returns The content of the public-api.ts file.
|
|
83
|
+
*/
|
|
84
|
+
getContent() {
|
|
85
|
+
return this.load();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Loads the content of the public-api.ts file.
|
|
89
|
+
* If the file does not exist or cannot be read, it throws a SchematicsException.
|
|
90
|
+
* @throws {SchematicsException} If the public-api.ts file does not exist or
|
|
91
|
+
* @returns The content of the public-api.ts file as a string.
|
|
92
|
+
*/
|
|
93
|
+
load() {
|
|
94
|
+
const buffer = this.tree.read(this.path);
|
|
95
|
+
if (!buffer) {
|
|
96
|
+
throw new schematics_1.SchematicsException(`Failed to read ${this.path}`);
|
|
97
|
+
}
|
|
98
|
+
return buffer.toString('utf-8');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.PublicApiTsEditor = PublicApiTsEditor;
|
|
102
|
+
//# sourceMappingURL=public-api-ts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-api-ts.js","sourceRoot":"","sources":["../../../src/schematics/commands/public-api-ts.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAuF;AAevF;;;GAGG;AACH,MAAa,2BAA2B;IACtC,YAA6B,QAA8B;QAA9B,aAAQ,GAAR,QAAQ,CAAsB;IAAG,CAAC;IAE/D;;;;OAIG;IACH,OAAO,CAAC,OAAe,EAAE,cAA8B;QACrD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;IAC7E,CAAC;CACF;AAXD,kEAWC;AAED;;;GAGG;AACH,MAAa,iBAAiB;IAC5B,YAA6B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAClD,OAAO,CAAC,OAAe,EAAE,cAA8B;QACrD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO;aAC5B,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;aAC7D,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,SAAS,EAAE,CAAC;aAClC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,cAAc,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;CACF;AAZD,8CAYC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