@yuuvis/client-cli 19.2.0 → 19.3.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/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/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,71 @@
|
|
|
1
|
+
import { AngularTsConfig } from "../types/tsconfig-json";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for commands that can be executed on an Angular tsconfig file.
|
|
4
|
+
* This interface defines a method to execute a command that modifies the tsconfig file.
|
|
5
|
+
*/
|
|
6
|
+
export interface TsConfigJsonCommand {
|
|
7
|
+
/**
|
|
8
|
+
* Executes the command on the provided Angular tsconfig object.
|
|
9
|
+
* @param tsConfigJson The Angular tsconfig object to modify.
|
|
10
|
+
*/
|
|
11
|
+
execute(tsConfigJson: AngularTsConfig): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Composite command that executes multiple TsConfigJsonCommand instances.
|
|
15
|
+
* This class allows for the execution of a series of commands on an Angular tsconfig file.
|
|
16
|
+
*/
|
|
17
|
+
export declare class CompositeTsConfigJsonCommand implements TsConfigJsonCommand {
|
|
18
|
+
private readonly commands;
|
|
19
|
+
constructor(commands: TsConfigJsonCommand[]);
|
|
20
|
+
/**
|
|
21
|
+
* Executes all commands in the composite command.
|
|
22
|
+
* @param tsConfigJson The Angular tsconfig.json object to modify.
|
|
23
|
+
*/
|
|
24
|
+
execute(tsConfigJson: AngularTsConfig): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Adds or updates paths in the compilerOptions of the tsconfig file.
|
|
28
|
+
* This command allows for the addition or modification of paths in the compilerOptions section.
|
|
29
|
+
*/
|
|
30
|
+
export declare class AddPathsToCompilierOptionsCommand implements TsConfigJsonCommand {
|
|
31
|
+
private readonly paths;
|
|
32
|
+
constructor(paths: Record<string, string[]>);
|
|
33
|
+
execute(tsConfigJson: AngularTsConfig): void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Edits the tsconfig file.
|
|
37
|
+
*/
|
|
38
|
+
export declare class TsConfigEditor {
|
|
39
|
+
private readonly tree;
|
|
40
|
+
private readonly path;
|
|
41
|
+
private comment;
|
|
42
|
+
private constructor();
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new instance of TsConfigEditor.
|
|
45
|
+
* @param tree The Angular DevKit Tree object representing the file system.
|
|
46
|
+
* @param path The path to the tsconfig.json file.
|
|
47
|
+
* @returns A promise that resolves to a TsConfigEditor instance.
|
|
48
|
+
*/
|
|
49
|
+
static create(tree: any, path?: string): Promise<TsConfigEditor>;
|
|
50
|
+
/**
|
|
51
|
+
* Runs the given command on the tsconfig.json file.
|
|
52
|
+
* @param command The command to run.
|
|
53
|
+
*/
|
|
54
|
+
run(command: TsConfigJsonCommand): void;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the content of the tsconfig.json file.
|
|
57
|
+
* @returns The tsconfig.json object.
|
|
58
|
+
*/
|
|
59
|
+
getContent(): AngularTsConfig;
|
|
60
|
+
/**
|
|
61
|
+
* Loads the contents of the tsconfig.json file.
|
|
62
|
+
* @throws {SchematicsException} If the tsconfig file does not exist or
|
|
63
|
+
* @returns The content of the tsconfig file (excluding comments).
|
|
64
|
+
*/
|
|
65
|
+
private load;
|
|
66
|
+
/**
|
|
67
|
+
* Saves the contents of the tsconfig file.
|
|
68
|
+
* @param tsConfigJson The Angular tsconfig object to save.
|
|
69
|
+
*/
|
|
70
|
+
private save;
|
|
71
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
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.TsConfigEditor = exports.AddPathsToCompilierOptionsCommand = exports.CompositeTsConfigJsonCommand = void 0;
|
|
13
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
|
+
/**
|
|
15
|
+
* Composite command that executes multiple TsConfigJsonCommand instances.
|
|
16
|
+
* This class allows for the execution of a series of commands on an Angular tsconfig file.
|
|
17
|
+
*/
|
|
18
|
+
class CompositeTsConfigJsonCommand {
|
|
19
|
+
constructor(commands) {
|
|
20
|
+
this.commands = commands;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Executes all commands in the composite command.
|
|
24
|
+
* @param tsConfigJson The Angular tsconfig.json object to modify.
|
|
25
|
+
*/
|
|
26
|
+
execute(tsConfigJson) {
|
|
27
|
+
this.commands.forEach(command => command.execute(tsConfigJson));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.CompositeTsConfigJsonCommand = CompositeTsConfigJsonCommand;
|
|
31
|
+
/**
|
|
32
|
+
* Adds or updates paths in the compilerOptions of the tsconfig file.
|
|
33
|
+
* This command allows for the addition or modification of paths in the compilerOptions section.
|
|
34
|
+
*/
|
|
35
|
+
class AddPathsToCompilierOptionsCommand {
|
|
36
|
+
constructor(paths) {
|
|
37
|
+
this.paths = paths;
|
|
38
|
+
}
|
|
39
|
+
execute(tsConfigJson) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
var _c;
|
|
42
|
+
(_a = tsConfigJson.compilerOptions) !== null && _a !== void 0 ? _a : (tsConfigJson.compilerOptions = {});
|
|
43
|
+
(_b = (_c = tsConfigJson.compilerOptions).paths) !== null && _b !== void 0 ? _b : (_c.paths = {});
|
|
44
|
+
Object.entries(this.paths).forEach(([key, value]) => {
|
|
45
|
+
tsConfigJson.compilerOptions.paths[key] = value;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.AddPathsToCompilierOptionsCommand = AddPathsToCompilierOptionsCommand;
|
|
50
|
+
/**
|
|
51
|
+
* Edits the tsconfig file.
|
|
52
|
+
*/
|
|
53
|
+
class TsConfigEditor {
|
|
54
|
+
constructor(tree, path) {
|
|
55
|
+
this.tree = tree;
|
|
56
|
+
this.path = path;
|
|
57
|
+
this.comment = '';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new instance of TsConfigEditor.
|
|
61
|
+
* @param tree The Angular DevKit Tree object representing the file system.
|
|
62
|
+
* @param path The path to the tsconfig.json file.
|
|
63
|
+
* @returns A promise that resolves to a TsConfigEditor instance.
|
|
64
|
+
*/
|
|
65
|
+
static create(tree, path) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
path = path !== null && path !== void 0 ? path : '/tsconfig.json';
|
|
68
|
+
return new TsConfigEditor(tree, path);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Runs the given command on the tsconfig.json file.
|
|
73
|
+
* @param command The command to run.
|
|
74
|
+
*/
|
|
75
|
+
run(command) {
|
|
76
|
+
const tsConfigJson = this.load();
|
|
77
|
+
command.execute(tsConfigJson);
|
|
78
|
+
this.save(tsConfigJson);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Gets the content of the tsconfig.json file.
|
|
82
|
+
* @returns The tsconfig.json object.
|
|
83
|
+
*/
|
|
84
|
+
getContent() {
|
|
85
|
+
return this.load();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Loads the contents of the tsconfig.json file.
|
|
89
|
+
* @throws {SchematicsException} If the tsconfig file does not exist or
|
|
90
|
+
* @returns The content of the tsconfig file (excluding comments).
|
|
91
|
+
*/
|
|
92
|
+
load() {
|
|
93
|
+
if (!this.tree.exists(this.path)) {
|
|
94
|
+
throw new schematics_1.SchematicsException(`tsconfig file not found at ${this.path}`);
|
|
95
|
+
}
|
|
96
|
+
const tsconfigBuffer = this.tree.read(this.path);
|
|
97
|
+
const tsconfig = tsconfigBuffer.toString('utf8');
|
|
98
|
+
const startIndex = tsconfig.indexOf('{');
|
|
99
|
+
const endIndex = tsconfig.lastIndexOf('}');
|
|
100
|
+
try {
|
|
101
|
+
this.comment = tsconfig.substring(0, startIndex).trim();
|
|
102
|
+
const jsonPart = tsconfig.substring(startIndex, endIndex + 1);
|
|
103
|
+
return JSON.parse(jsonPart);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw new schematics_1.SchematicsException(`Failed to parse tsconfig file at ${this.path}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Saves the contents of the tsconfig file.
|
|
111
|
+
* @param tsConfigJson The Angular tsconfig object to save.
|
|
112
|
+
*/
|
|
113
|
+
save(tsConfigJson) {
|
|
114
|
+
this.tree.overwrite(this.path, `${this.comment}\n${JSON.stringify(tsConfigJson, null, 2)}\n`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.TsConfigEditor = TsConfigEditor;
|
|
118
|
+
//# sourceMappingURL=tsconfig-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig-json.js","sourceRoot":"","sources":["../../../src/schematics/commands/tsconfig-json.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAiE;AAejE;;;GAGG;AACH,MAAa,4BAA4B;IACvC,YAA6B,QAA+B;QAA/B,aAAQ,GAAR,QAAQ,CAAuB;IAAG,CAAC;IAEhE;;;OAGG;IACH,OAAO,CAAC,YAA6B;QACnC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IAClE,CAAC;CACF;AAVD,oEAUC;AAED;;;GAGG;AACH,MAAa,iCAAiC;IAC5C,YAA6B,KAA+B;QAA/B,UAAK,GAAL,KAAK,CAA0B;IAAG,CAAC;IAChE,OAAO,CAAC,YAA6B;;;QACnC,MAAA,YAAY,CAAC,eAAe,oC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C;QAED,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,UAAU,GAAW,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAW,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACnD,IAAI,CAAC;YACH,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;YACxD,MAAM,QAAQ,GAAW,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAA;YAErE,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAoB,CAAC;QACjD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,gCAAmB,CAAC,oCAAoC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;IAED;;;OAGG;IACK,IAAI,CAAC,YAA6B;QACxC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAChG,CAAC;CACF;AAhED,wCAgEC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { SchematicContext, Tree, UpdateRecorder } from "@angular-devkit/schematics";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
/**
|
|
4
|
+
* Interface for commands that can be executed on any TypeScript file.
|
|
5
|
+
*/
|
|
6
|
+
export interface TypeScriptFileCommand {
|
|
7
|
+
execute(sourceFile: ts.SourceFile, recorder: UpdateRecorder, filePath: string, context: SchematicContext): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Composite command that executes multiple TypeScriptFileCommand instances.
|
|
11
|
+
* This class allows for the execution of a series of commands on a typescript file.
|
|
12
|
+
*/
|
|
13
|
+
export declare class CompositeTypeScriptFileCommand implements TypeScriptFileCommand {
|
|
14
|
+
private readonly commands;
|
|
15
|
+
constructor(commands: TypeScriptFileCommand[]);
|
|
16
|
+
/**
|
|
17
|
+
* Executes all commands in the composite command.
|
|
18
|
+
* @param sourceFile The TypeScript source file representing the typescript file.
|
|
19
|
+
* @param recorder The UpdateRecorder to apply changes to the file.
|
|
20
|
+
* @param filePath The path of the typescript file.
|
|
21
|
+
*/
|
|
22
|
+
execute(sourceFile: ts.SourceFile, recorder: UpdateRecorder, filePath: string, context: SchematicContext): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Adds an import statement to a typescript file if it doesn't already exist.
|
|
26
|
+
*/
|
|
27
|
+
export declare class AddImportToFileCommand implements TypeScriptFileCommand {
|
|
28
|
+
private readonly className;
|
|
29
|
+
private readonly moduleName;
|
|
30
|
+
constructor(className: string, moduleName: string);
|
|
31
|
+
execute(sourceFile: ts.SourceFile, recorder: UpdateRecorder, filePath: string): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Class for editing a typescript file.
|
|
35
|
+
*/
|
|
36
|
+
export declare class TypeScriptFileEditor {
|
|
37
|
+
private readonly tree;
|
|
38
|
+
private readonly path;
|
|
39
|
+
private constructor();
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new instance of TypeScriptFileEditor.
|
|
42
|
+
* @param tree The Angular DevKit Tree object representing the file system.
|
|
43
|
+
* @param path The path to the typescript file.
|
|
44
|
+
* @returns A promise that resolves to a TypeScriptFileEditor instance.
|
|
45
|
+
*/
|
|
46
|
+
static create(tree: Tree, path: string): Promise<TypeScriptFileEditor>;
|
|
47
|
+
/**
|
|
48
|
+
* Executes the given command on the typescript file.
|
|
49
|
+
* @param command The command to execute on the typescript file.
|
|
50
|
+
*/
|
|
51
|
+
run(command: TypeScriptFileCommand, context: SchematicContext): void;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the content of the typescript file.
|
|
54
|
+
* @returns The content of the typescript file as a string.
|
|
55
|
+
*/
|
|
56
|
+
getContent(): string;
|
|
57
|
+
/**
|
|
58
|
+
* Loads the typescript file from the specified path.
|
|
59
|
+
* If the file does not exist or cannot be read, it throws a SchematicsException.
|
|
60
|
+
* @returns The content of the typescript file as a string.
|
|
61
|
+
* @throws {SchematicsException} If the typescript file does not exist or cannot be read.
|
|
62
|
+
*/
|
|
63
|
+
private load;
|
|
64
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TypeScriptFileEditor = exports.AddImportToFileCommand = exports.CompositeTypeScriptFileCommand = void 0;
|
|
16
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
17
|
+
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
|
|
18
|
+
const change_1 = require("@schematics/angular/utility/change");
|
|
19
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
20
|
+
/**
|
|
21
|
+
* Composite command that executes multiple TypeScriptFileCommand instances.
|
|
22
|
+
* This class allows for the execution of a series of commands on a typescript file.
|
|
23
|
+
*/
|
|
24
|
+
class CompositeTypeScriptFileCommand {
|
|
25
|
+
constructor(commands) {
|
|
26
|
+
this.commands = commands;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Executes all commands in the composite command.
|
|
30
|
+
* @param sourceFile The TypeScript source file representing the typescript file.
|
|
31
|
+
* @param recorder The UpdateRecorder to apply changes to the file.
|
|
32
|
+
* @param filePath The path of the typescript file.
|
|
33
|
+
*/
|
|
34
|
+
execute(sourceFile, recorder, filePath, context) {
|
|
35
|
+
this.commands.forEach(command => command.execute(sourceFile, recorder, filePath, context));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.CompositeTypeScriptFileCommand = CompositeTypeScriptFileCommand;
|
|
39
|
+
/**
|
|
40
|
+
* Adds an import statement to a typescript file if it doesn't already exist.
|
|
41
|
+
*/
|
|
42
|
+
class AddImportToFileCommand {
|
|
43
|
+
constructor(className, moduleName) {
|
|
44
|
+
this.className = className;
|
|
45
|
+
this.moduleName = moduleName;
|
|
46
|
+
}
|
|
47
|
+
execute(sourceFile, recorder, filePath) {
|
|
48
|
+
// Check if the import already exists
|
|
49
|
+
const hasExistingImport = sourceFile.statements.some(statement => {
|
|
50
|
+
var _a;
|
|
51
|
+
return typescript_1.default.isImportDeclaration(statement) &&
|
|
52
|
+
statement.moduleSpecifier &&
|
|
53
|
+
typescript_1.default.isStringLiteral(statement.moduleSpecifier) &&
|
|
54
|
+
statement.moduleSpecifier.text === this.moduleName &&
|
|
55
|
+
((_a = statement.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings) &&
|
|
56
|
+
typescript_1.default.isNamedImports(statement.importClause.namedBindings) &&
|
|
57
|
+
statement.importClause.namedBindings.elements.some(element => element.name.text === this.className);
|
|
58
|
+
});
|
|
59
|
+
if (hasExistingImport) {
|
|
60
|
+
return; // the class is already imported
|
|
61
|
+
}
|
|
62
|
+
const importChange = (0, ast_utils_1.insertImport)(sourceFile, filePath, this.className, this.moduleName);
|
|
63
|
+
if (importChange) {
|
|
64
|
+
(0, change_1.applyToUpdateRecorder)(recorder, [importChange]);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
throw new schematics_1.SchematicsException(`Cannot insert import statement of ${this.className} to ${filePath}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.AddImportToFileCommand = AddImportToFileCommand;
|
|
72
|
+
/**
|
|
73
|
+
* Class for editing a typescript file.
|
|
74
|
+
*/
|
|
75
|
+
class TypeScriptFileEditor {
|
|
76
|
+
constructor(tree, path) {
|
|
77
|
+
this.tree = tree;
|
|
78
|
+
this.path = path;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates a new instance of TypeScriptFileEditor.
|
|
82
|
+
* @param tree The Angular DevKit Tree object representing the file system.
|
|
83
|
+
* @param path The path to the typescript file.
|
|
84
|
+
* @returns A promise that resolves to a TypeScriptFileEditor instance.
|
|
85
|
+
*/
|
|
86
|
+
static create(tree, path) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
return new TypeScriptFileEditor(tree, path);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Executes the given command on the typescript file.
|
|
93
|
+
* @param command The command to execute on the typescript file.
|
|
94
|
+
*/
|
|
95
|
+
run(command, context) {
|
|
96
|
+
const content = this.load();
|
|
97
|
+
const sourceFile = typescript_1.default.createSourceFile(this.path, content, typescript_1.default.ScriptTarget.Latest, true);
|
|
98
|
+
const recorder = this.tree.beginUpdate(this.path);
|
|
99
|
+
command.execute(sourceFile, recorder, this.path, context);
|
|
100
|
+
this.tree.commitUpdate(recorder);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Gets the content of the typescript file.
|
|
104
|
+
* @returns The content of the typescript file as a string.
|
|
105
|
+
*/
|
|
106
|
+
getContent() {
|
|
107
|
+
return this.load();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Loads the typescript file from the specified path.
|
|
111
|
+
* If the file does not exist or cannot be read, it throws a SchematicsException.
|
|
112
|
+
* @returns The content of the typescript file as a string.
|
|
113
|
+
* @throws {SchematicsException} If the typescript file does not exist or cannot be read.
|
|
114
|
+
*/
|
|
115
|
+
load() {
|
|
116
|
+
if (!this.tree.exists(this.path)) {
|
|
117
|
+
throw new schematics_1.SchematicsException(`Typescript file not found at ${this.path}`);
|
|
118
|
+
}
|
|
119
|
+
const buffer = this.tree.read(this.path);
|
|
120
|
+
if (!buffer) {
|
|
121
|
+
throw new schematics_1.SchematicsException(`Failed to read ${this.path}`);
|
|
122
|
+
}
|
|
123
|
+
return buffer.toString('utf-8');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.TypeScriptFileEditor = TypeScriptFileEditor;
|
|
127
|
+
//# sourceMappingURL=typescript-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-file.js","sourceRoot":"","sources":["../../../src/schematics/commands/typescript-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2DAAoH;AACpH,qEAAqE;AACrE,+DAA2E;AAC3E,4DAA4B;AAS5B;;;GAGG;AACH,MAAa,8BAA8B;IACzC,YAA6B,QAAiC;QAAjC,aAAQ,GAAR,QAAQ,CAAyB;IAAG,CAAC;IAElE;;;;;OAKG;IACH,OAAO,CAAC,UAAyB,EAAE,QAAwB,EAAE,QAAgB,EAAE,OAAyB;QACtG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7F,CAAC;CACF;AAZD,wEAYC;AAED;;GAEG;AACH,MAAa,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B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;CACF;AAlDD,oDAkDC"}
|
|
@@ -16,9 +16,9 @@ exports.addApp = addApp;
|
|
|
16
16
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
17
17
|
const schematics_util_1 = require("../../schematics-util");
|
|
18
18
|
const utils_1 = require("../../utils");
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const npm_install_1 = __importDefault(require("../../
|
|
19
|
+
const app_routes_1 = require("../../rules/app-routes");
|
|
20
|
+
const app_config_1 = require("../../rules/app-config");
|
|
21
|
+
const npm_install_1 = __importDefault(require("../../rules/npm-install"));
|
|
22
22
|
const project_metadata_1 = require("../../project-metadata");
|
|
23
23
|
function addApp(options) {
|
|
24
24
|
return (tree, context) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -31,10 +31,11 @@ function addApp(options) {
|
|
|
31
31
|
context.logger.info(`Found manifest file for package ${options.name}.`);
|
|
32
32
|
const rules = [];
|
|
33
33
|
if (!!appManifest.ui) {
|
|
34
|
-
rules.push((0,
|
|
34
|
+
rules.push((0, app_routes_1.updateAppRoutesRule)(parsedPackageName.libraryFullName, appManifest));
|
|
35
35
|
}
|
|
36
36
|
if (!!appManifest.extension) {
|
|
37
|
-
|
|
37
|
+
const extensionsEntryPoint = `${parsedPackageName.libraryFullName}/extensions`;
|
|
38
|
+
rules.push((0, app_config_1.updateAppConfigRule)(appManifest.id, appManifest.extension, extensionsEntryPoint));
|
|
38
39
|
}
|
|
39
40
|
rules.push((0, npm_install_1.default)('./', options.name));
|
|
40
41
|
return (0, schematics_1.chain)(rules);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schematics/factories/add-app/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAQA,
|
|
1
|
+
{"version":3,"file":"index.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AED,KAAK,CAAC,IAAI,CAAC,IAAA,qBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAE3C,OAAO,IAAA,kBAAK,EAAC,KAAK,CAAC,CAAC;IACtB,CAAC,CAAA,CAAC;AACJ,CAAC"}
|
|
@@ -8,89 +8,55 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.generateApp = generateApp;
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
13
17
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
18
|
const utils_1 = require("../../utils");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
19
|
+
const generate_library_1 = require("../../rules/generate-library");
|
|
20
|
+
const create_update_manifest_1 = require("../../rules/create-update-manifest");
|
|
21
|
+
const app_routes_1 = require("../../rules/app-routes");
|
|
22
|
+
const app_config_1 = require("../../rules/app-config");
|
|
23
|
+
const angular_json_1 = require("../../commands/angular-json");
|
|
24
|
+
const tsconfig_json_1 = require("../../commands/tsconfig-json");
|
|
25
|
+
const project_metadata_1 = require("../../project-metadata");
|
|
26
|
+
const public_api_ts_1 = require("../../commands/public-api-ts");
|
|
27
|
+
const ng_package_json_1 = require("../../commands/ng-package-json");
|
|
28
|
+
const library_component_1 = require("../../commands/library-component");
|
|
29
|
+
const typescript_file_1 = require("../../commands/typescript-file");
|
|
30
|
+
const copy_resources_1 = require("../../rules/copy-resources");
|
|
27
31
|
function generateApp(options) {
|
|
28
32
|
return (tree, context) => __awaiter(this, void 0, void 0, function* () {
|
|
29
33
|
validateOptions(options);
|
|
34
|
+
const projectName = options.name;
|
|
30
35
|
const parsedPackageName = (0, utils_1.parsePackageName)(options.name);
|
|
31
36
|
options.namespace = parsedPackageName.namespace;
|
|
32
37
|
options.componentName = parsedPackageName.libraryName;
|
|
33
38
|
options.shortName = parsedPackageName.shortName;
|
|
34
39
|
const appManifest = createAppManifest(options.componentName, options.route, options.appId, options.skipExtension, options.appHeader, options.hideFromNav);
|
|
35
|
-
const libraryMetadata = yield inspectLibrary(tree, options.name);
|
|
36
|
-
options.libraryRoot = !!libraryMetadata.libraryRoot ? libraryMetadata.libraryRoot : (0, utils_1.getLibraryPathFromName)(options.name);
|
|
37
40
|
const rules = [
|
|
38
41
|
(0, generate_library_1.generateLibrary)(options),
|
|
39
|
-
(0, create_update_manifest_1.createOrUpdateManifest)(options, appManifest
|
|
40
|
-
(0,
|
|
41
|
-
(
|
|
42
|
-
(
|
|
43
|
-
(
|
|
44
|
-
(
|
|
45
|
-
(
|
|
46
|
-
(0,
|
|
42
|
+
(0, create_update_manifest_1.createOrUpdateManifest)(options.name, appManifest),
|
|
43
|
+
(0, copy_resources_1.copyUiFiles)(options),
|
|
44
|
+
updatePublicApiTsRule(projectName),
|
|
45
|
+
updateTsConfigJsonRule(projectName, options.skipExtension),
|
|
46
|
+
updateLibraryComponentRule(projectName, options.componentName),
|
|
47
|
+
updateAngularJsonRule(projectName),
|
|
48
|
+
updateNgPackageJsonRule(projectName, options.skipExtension),
|
|
49
|
+
(0, app_routes_1.updateAppRoutesRule)(projectName, appManifest)
|
|
47
50
|
];
|
|
48
51
|
if (!options.skipExtension) {
|
|
49
|
-
const
|
|
50
|
-
rules.push((0,
|
|
51
|
-
rules.push((0,
|
|
52
|
+
const extensionsEntryPoint = `${projectName}/extensions`;
|
|
53
|
+
rules.push((0, copy_resources_1.copyExtensionsFiles)(options));
|
|
54
|
+
rules.push((0, app_config_1.updateAppConfigRule)(appManifest.id, appManifest.extension, extensionsEntryPoint));
|
|
52
55
|
}
|
|
53
56
|
return (0, schematics_1.chain)(rules);
|
|
54
57
|
});
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
let errorMessage = null;
|
|
59
|
-
const libMetadata = {
|
|
60
|
-
libraryExists: false,
|
|
61
|
-
isUiAvailable: false,
|
|
62
|
-
isExtensionAvailable: false,
|
|
63
|
-
libraryRoot: null
|
|
64
|
-
};
|
|
65
|
-
const workspace = yield (0, utility_1.readWorkspace)(tree);
|
|
66
|
-
libMetadata.libraryExists = workspace.projects.has(libraryName);
|
|
67
|
-
if (libMetadata.libraryExists) {
|
|
68
|
-
const project = workspace.projects.get(libraryName);
|
|
69
|
-
const libraryRoot = project.root;
|
|
70
|
-
if (!!libraryRoot) {
|
|
71
|
-
libMetadata.libraryRoot = libraryRoot;
|
|
72
|
-
const manifestPath = `${libraryRoot}/yuv-manifest.json`;
|
|
73
|
-
if (tree.exists(manifestPath)) {
|
|
74
|
-
const manifest = tree.readJson(manifestPath);
|
|
75
|
-
libMetadata.isUiAvailable = manifest.ui !== undefined;
|
|
76
|
-
libMetadata.isExtensionAvailable = manifest.extension !== undefined;
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
// TODO: generate manifest file for legacy libs?
|
|
80
|
-
// errorMessage = `Manifest file not found for: ${libraryName}`;
|
|
81
|
-
console.log(`Manifest file not found for: ${libraryName}`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
errorMessage = `Library root not found for: ${libraryName}`;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (!!errorMessage) {
|
|
89
|
-
throw new Error(errorMessage);
|
|
90
|
-
}
|
|
91
|
-
return libMetadata;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
59
|
+
// TODO: Find a better way to create the manifest
|
|
94
60
|
function createAppManifest(componentName, route, appId, skipExtension, appHeader, hideFromNav) {
|
|
95
61
|
const manifest = {
|
|
96
62
|
id: `${appId}`,
|
|
@@ -122,4 +88,82 @@ function validateOptions(options) {
|
|
|
122
88
|
throw new Error(errorMessage);
|
|
123
89
|
}
|
|
124
90
|
}
|
|
91
|
+
function updateAngularJsonRule(projectName) {
|
|
92
|
+
return (tree) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const command = new angular_json_1.SetStyleForProjectCommand(projectName, 'scss');
|
|
94
|
+
const editor = yield angular_json_1.AngularJsonEditor.create(tree);
|
|
95
|
+
editor.run(command);
|
|
96
|
+
return tree;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function updateTsConfigJsonRule(projectName, skipExtension) {
|
|
100
|
+
return (tree) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const project = yield project_metadata_1.ProjectMetadata.fromTree(tree);
|
|
102
|
+
const projectRoot = project.projectRoot;
|
|
103
|
+
const libraryRoot = yield project.getLibraryRoot(projectName);
|
|
104
|
+
const librarySourceRoot = yield project.getLibrarySourceRoot(projectName);
|
|
105
|
+
const filePath = (0, utils_1.buildPath)(projectRoot, 'tsconfig.json');
|
|
106
|
+
const paths = {
|
|
107
|
+
[projectName]: [`./${librarySourceRoot}/public-api.ts`]
|
|
108
|
+
};
|
|
109
|
+
if (!skipExtension) {
|
|
110
|
+
paths[`${projectName}/extensions`] = [`./${libraryRoot}/extensions/src/index.ts`];
|
|
111
|
+
}
|
|
112
|
+
const command = new tsconfig_json_1.AddPathsToCompilierOptionsCommand(paths);
|
|
113
|
+
const editor = yield tsconfig_json_1.TsConfigEditor.create(tree, filePath);
|
|
114
|
+
editor.run(command);
|
|
115
|
+
return tree;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function updatePublicApiTsRule(projectName) {
|
|
119
|
+
return (tree) => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const project = yield project_metadata_1.ProjectMetadata.fromTree(tree);
|
|
121
|
+
const librarySourceRoot = yield project.getLibrarySourceRoot(projectName);
|
|
122
|
+
const filePath = (0, utils_1.buildPath)(librarySourceRoot, 'public-api.ts');
|
|
123
|
+
const command = new public_api_ts_1.AddExportsCommand([`export * from './lib/lib.routes';`]);
|
|
124
|
+
const editor = yield public_api_ts_1.PublicApiTsEditor.create(tree, filePath);
|
|
125
|
+
editor.run(command);
|
|
126
|
+
return tree;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function updateNgPackageJsonRule(projectName, skipExtension) {
|
|
130
|
+
return (tree) => __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
const project = yield project_metadata_1.ProjectMetadata.fromTree(tree);
|
|
132
|
+
const libraryRoot = yield project.getLibraryRoot(projectName);
|
|
133
|
+
const librarySourceRoot = yield project.getLibrarySourceRoot(projectName);
|
|
134
|
+
const relativeSrcPath = path_1.default.relative(libraryRoot, librarySourceRoot);
|
|
135
|
+
const filePath = (0, utils_1.buildPath)(libraryRoot, 'ng-package.json');
|
|
136
|
+
const assets = [
|
|
137
|
+
{ input: './', glob: 'yuv-manifest.json', output: './' },
|
|
138
|
+
{ input: `./${relativeSrcPath}/assets`, glob: '**/*', output: 'lib/assets' }
|
|
139
|
+
];
|
|
140
|
+
if (!skipExtension) {
|
|
141
|
+
assets.push({ input: './extensions/src/assets', glob: '**/*', output: '/extensions/lib/assets' });
|
|
142
|
+
}
|
|
143
|
+
const command = new ng_package_json_1.AddAssetsCommand(assets);
|
|
144
|
+
const editor = ng_package_json_1.NgPackageJsonEditor.create(tree, filePath);
|
|
145
|
+
editor.run(command);
|
|
146
|
+
return tree;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function updateLibraryComponentRule(projectName, componentName) {
|
|
150
|
+
return (tree, context) => __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
const project = yield project_metadata_1.ProjectMetadata.fromTree(tree);
|
|
152
|
+
const librarySourceRoot = yield project.getLibrarySourceRoot(projectName);
|
|
153
|
+
const filePath = (0, utils_1.buildPath)(librarySourceRoot, 'lib', `${schematics_1.strings.dasherize(componentName)}.component.ts`);
|
|
154
|
+
const template = ` \`
|
|
155
|
+
<p>
|
|
156
|
+
{{ '${schematics_1.strings.dasherize(componentName)}.works' | translate }}
|
|
157
|
+
</p>
|
|
158
|
+
\``;
|
|
159
|
+
const command = new typescript_file_1.CompositeTypeScriptFileCommand([
|
|
160
|
+
new typescript_file_1.AddImportToFileCommand('TranslateModule', '@yuuvis/client-core'),
|
|
161
|
+
new library_component_1.AddImportToComponentDecoratorCommand('TranslateModule'),
|
|
162
|
+
new library_component_1.AddInlineTemplateToComponentDecoratorCommand(template)
|
|
163
|
+
]);
|
|
164
|
+
const editor = yield typescript_file_1.TypeScriptFileEditor.create(tree, filePath);
|
|
165
|
+
editor.run(command, context);
|
|
166
|
+
return tree;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
125
169
|
//# sourceMappingURL=index.js.map
|