@yuuvis/client-cli 19.4.0 → 19.6.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 +25 -6
- package/cli/commands/generate/widget.d.ts +6 -0
- package/cli/commands/generate/widget.js +46 -0
- package/cli/commands/generate/widget.js.map +1 -0
- package/cli/options/options-generate-widget.json +19 -0
- package/cli/utils.d.ts +6 -0
- package/cli/utils.js +24 -0
- package/cli/utils.js.map +1 -1
- package/package.json +2 -1
- package/schematics/app-manifest.d.ts +4 -1
- package/schematics/app-manifest.js +3 -2
- package/schematics/app-manifest.js.map +1 -1
- package/schematics/commands/angular-json.d.ts +8 -2
- package/schematics/commands/angular-json.js +36 -13
- package/schematics/commands/angular-json.js.map +1 -1
- package/schematics/commands/app-requirements-ts.d.ts +11 -0
- package/schematics/commands/app-requirements-ts.js +59 -0
- package/schematics/commands/app-requirements-ts.js.map +1 -0
- package/schematics/commands/typescript-file.d.ts +25 -0
- package/schematics/commands/typescript-file.js +95 -14
- package/schematics/commands/typescript-file.js.map +1 -1
- package/schematics/factories/add-app/index.d.ts +1 -1
- package/schematics/factories/add-app/index.js +8 -0
- package/schematics/factories/add-app/index.js.map +1 -1
- package/schematics/factories/collection.json +5 -0
- package/schematics/factories/generate-app/index.js +1 -0
- package/schematics/factories/generate-app/index.js.map +1 -1
- package/schematics/factories/generate-widget/index.d.ts +11 -0
- package/schematics/factories/generate-widget/index.js +67 -0
- package/schematics/factories/generate-widget/index.js.map +1 -0
- package/schematics/factories/generate-widget/schema.json +41 -0
- package/schematics/factories/new/index.js +18 -22
- package/schematics/factories/new/index.js.map +1 -1
- package/schematics/files/_scripts/i18n-collect.js +1 -2
- package/schematics/files/_src/main.ts.template +2 -1
- package/schematics/files/_src/styles.scss +2 -5
- package/schematics/files/_src_app/app.component.ts.template +4 -3
- package/schematics/files/_src_app/app.requirements.ts.template +3 -0
- package/schematics/files/_src_styles/global.scss +4 -0
- package/schematics/project-util.d.ts +6 -0
- package/schematics/project-util.js +25 -0
- package/schematics/project-util.js.map +1 -1
- package/schematics/rules/copy-resources.d.ts +1 -0
- package/schematics/rules/copy-resources.js +16 -0
- package/schematics/rules/copy-resources.js.map +1 -1
- package/schematics/rules/generate-component.d.ts +2 -0
- package/schematics/rules/generate-component.js +18 -0
- package/schematics/rules/generate-component.js.map +1 -0
- package/schematics/rules/update-app-requirements.d.ts +2 -0
- package/schematics/rules/update-app-requirements.js +27 -0
- package/schematics/rules/update-app-requirements.js.map +1 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ This CLI package follows a synchronized versioning strategy with the Angular fra
|
|
|
13
13
|
- `v18` of `@yuuvis/client-cli` is compatible with Angular 18 and corresponds to major version 1 of `@yuuvis/client-shell`
|
|
14
14
|
- `v19` of `@yuuvis/client-cli` is compatible with Angular 19 and corresponds to major version 2 of `@yuuvis/client-shell`
|
|
15
15
|
|
|
16
|
-
Make sure to install a CLI version that matches both your Angular version and the required
|
|
16
|
+
Make sure to install a CLI version that matches both your Angular version and the required `@yuuvis/client-shell` version for full compatibility.
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
@@ -43,6 +43,7 @@ yuv new <name> [options]
|
|
|
43
43
|
`<name>`: The name of the project.
|
|
44
44
|
|
|
45
45
|
#### Options
|
|
46
|
+
- `--shell-version`: The version of the shell to use. If not specified, you will be prompted to enter it.
|
|
46
47
|
- `--skip-git`: Do not initialize a git repository.
|
|
47
48
|
- `--skip-install`: Do not install dependency packages.
|
|
48
49
|
- `--skip-tests`: Do not generate `spec.ts` test files for the new project.
|
|
@@ -63,12 +64,30 @@ yuv g a <name> [options]
|
|
|
63
64
|
|
|
64
65
|
#### Options
|
|
65
66
|
- `--app-header`: Use the shell's app header layout.
|
|
66
|
-
- `--app-id`: The ID of the app.
|
|
67
|
-
- `--hide-from-nav`: Do not show the app icon
|
|
68
|
-
- `--prefix`: A prefix to apply to generated selectors.
|
|
69
|
-
- `--route`: The route
|
|
67
|
+
- `--app-id`: The ID of the app. If not specified, you will be prompted to enter it.
|
|
68
|
+
- `--hide-from-nav`: Do not show the app icon in the navigation bar.
|
|
69
|
+
- `--prefix`: A prefix to apply to generated selectors. If not specified, you will be prompted to enter it.
|
|
70
|
+
- `--route`: The route under which the app is registered in the client. If not specified, you will be prompted to enter it.
|
|
70
71
|
- `--skip-extension`: Do not create extension for the app.
|
|
71
72
|
|
|
73
|
+
### generate widget
|
|
74
|
+
|
|
75
|
+
Creates a new widget in the current workspace. This command works similar to Angular's `ng generate component` and uses the same naming conventions.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
yuv generate widget <name> [options]
|
|
79
|
+
|
|
80
|
+
# short form
|
|
81
|
+
yuv g w <name> [options]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`<name>`: The name of the widget. The name can include a path (e.g., `widgets/my-widget`) to specify where the widget should be created, similar to how Angular's component generator works.
|
|
85
|
+
|
|
86
|
+
#### Options
|
|
87
|
+
- `--generate-setup-component` or `-gsc`: If set, a setup component for the widget will be generated.
|
|
88
|
+
- `--path`: The path where the widget component should be created (equivalent to Angular's `ng generate component --path`).
|
|
89
|
+
- `--prefix`: A prefix to apply to generated selectors (equivalent to Angular's `ng generate component --prefix`).
|
|
90
|
+
- `--project`: The name of the project where the component should be added. If not specified, the CLI will determine the project from the current directory (equivalent to Angular's `ng generate component --project`).
|
|
72
91
|
|
|
73
92
|
### add app
|
|
74
93
|
|
|
@@ -81,7 +100,7 @@ yuv add app <name>
|
|
|
81
100
|
yuv a a <name>
|
|
82
101
|
```
|
|
83
102
|
|
|
84
|
-
`<name>`: The name of the app. Similar to `npm install`, you can use `[<@scope>/]<name>@<version>` or `[<@scope>/]<name>@<tag>` for adding a specific version or tag of the app, e.
|
|
103
|
+
`<name>`: The name of the app. Similar to `npm install`, you can use `[<@scope>/]<name>@<version>` or `[<@scope>/]<name>@<tag>` for adding a specific version or tag of the app, e.g.:
|
|
85
104
|
|
|
86
105
|
```bash
|
|
87
106
|
yuv add app @myscope/mylib@1.0.0
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CommandBuilder, Options } from "yargs";
|
|
2
|
+
export declare const command: string;
|
|
3
|
+
export declare const aliases: string[];
|
|
4
|
+
export declare const desc: string;
|
|
5
|
+
export declare const builder: CommandBuilder<Options>;
|
|
6
|
+
export declare const handler: (argv: any) => Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
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.handler = exports.builder = exports.desc = exports.aliases = exports.command = void 0;
|
|
16
|
+
const child_process_1 = require("child_process");
|
|
17
|
+
const utils_1 = require("../../utils");
|
|
18
|
+
const options_generate_widget_json_1 = __importDefault(require("../../options/options-generate-widget.json"));
|
|
19
|
+
const config_1 = require("@angular/cli/src/utilities/config");
|
|
20
|
+
const path_1 = require("path");
|
|
21
|
+
exports.command = "widget <name>";
|
|
22
|
+
exports.aliases = ["w"];
|
|
23
|
+
exports.desc = "Generate a new widget component.";
|
|
24
|
+
const builder = (yargs) => {
|
|
25
|
+
return yargs.string("widget").version(false).options(options_generate_widget_json_1.default);
|
|
26
|
+
};
|
|
27
|
+
exports.builder = builder;
|
|
28
|
+
const handler = (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
if (!argv.project) {
|
|
30
|
+
const workspace = yield (0, config_1.getWorkspace)('local');
|
|
31
|
+
if (!workspace) {
|
|
32
|
+
throw new Error('Could not find Angular workspace configuration.');
|
|
33
|
+
}
|
|
34
|
+
argv.project = (0, config_1.getProjectByCwd)(workspace);
|
|
35
|
+
}
|
|
36
|
+
const currentCwd = process.cwd();
|
|
37
|
+
const workspaceRoot = (0, utils_1.findWorkspaceRoot)(currentCwd);
|
|
38
|
+
if (!workspaceRoot) {
|
|
39
|
+
throw new Error('Could not find Angular workspace root (angular.json not found)');
|
|
40
|
+
}
|
|
41
|
+
const workingdirectory = (0, path_1.relative)(workspaceRoot, currentCwd) || undefined;
|
|
42
|
+
(0, child_process_1.execSync)(`${(0, utils_1.getSchematicsBin)()} @yuuvis/client-cli:generate-widget ${(0, utils_1.serializeOptions)(Object.assign(Object.assign({}, argv), { workingdirectory }))}`, { cwd: workspaceRoot, stdio: "inherit" });
|
|
43
|
+
console.log(`Widget '${argv.name}' created successfully!`);
|
|
44
|
+
});
|
|
45
|
+
exports.handler = handler;
|
|
46
|
+
//# sourceMappingURL=widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../../../../src/cli/commands/generate/widget.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,iDAAyC;AACzC,uCAAoF;AACpF,8GAAiE;AACjE,8DAAkF;AAClF,+BAAgC;AAEnB,QAAA,OAAO,GAAW,eAAe,CAAC;AAClC,QAAA,OAAO,GAAa,CAAC,GAAG,CAAC,CAAC;AAC1B,QAAA,IAAI,GAAW,kCAAkC,CAAC;AAExD,MAAM,OAAO,GAA4B,CAAC,KAAU,EAAE,EAAE;IAC7D,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,C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
|
+
"path": {
|
|
8
|
+
"describe": "The path where the widget component should be created.",
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"project": {
|
|
12
|
+
"describe": "The name of the project where the widget component should be added. If not specified, the CLI will determine the project from the current directory.",
|
|
13
|
+
"type": "string"
|
|
14
|
+
},
|
|
15
|
+
"prefix": {
|
|
16
|
+
"describe": "A prefix to be added to the widget components's selector.",
|
|
17
|
+
"type": "string"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/cli/utils.d.ts
CHANGED
|
@@ -5,3 +5,9 @@ export declare function getSchematicsBin(): string;
|
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
7
|
export declare function serializeOptions(options: any): string;
|
|
8
|
+
/**
|
|
9
|
+
* Find the workspace root by looking for angular.json upwards from the startPath
|
|
10
|
+
* @param startPath
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function findWorkspaceRoot(startPath: string): string | null;
|
package/cli/utils.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSchematicsBin = getSchematicsBin;
|
|
4
4
|
exports.serializeOptions = serializeOptions;
|
|
5
|
+
exports.findWorkspaceRoot = findWorkspaceRoot;
|
|
6
|
+
const fs_1 = require("fs");
|
|
5
7
|
const path_1 = require("path");
|
|
6
8
|
function getSchematicsBin() {
|
|
7
9
|
return (0, path_1.join)(__dirname, '../node_modules/.bin/schematics');
|
|
@@ -15,6 +17,7 @@ function serializeOptions(options) {
|
|
|
15
17
|
return Object.entries(options)
|
|
16
18
|
.filter(([key]) => key !== '_' && key !== '$0') // delete yargs internal keys
|
|
17
19
|
.filter(([key]) => key === key.toLowerCase()) // keep only lowercase keys
|
|
20
|
+
.filter(([, value]) => value !== undefined) // skip undefined values
|
|
18
21
|
.map(([key, value]) => {
|
|
19
22
|
if (typeof value === 'boolean') {
|
|
20
23
|
if (value)
|
|
@@ -25,4 +28,25 @@ function serializeOptions(options) {
|
|
|
25
28
|
})
|
|
26
29
|
.join(' ');
|
|
27
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Find the workspace root by looking for angular.json upwards from the startPath
|
|
33
|
+
* @param startPath
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
function findWorkspaceRoot(startPath) {
|
|
37
|
+
const ANGULAR_JSON = 'angular.json';
|
|
38
|
+
let currentPath = (0, path_1.resolve)(startPath);
|
|
39
|
+
while (true) {
|
|
40
|
+
const angularJsonPath = (0, path_1.join)(currentPath, ANGULAR_JSON);
|
|
41
|
+
if ((0, fs_1.existsSync)(angularJsonPath)) {
|
|
42
|
+
return currentPath;
|
|
43
|
+
}
|
|
44
|
+
const parentPath = (0, path_1.dirname)(currentPath);
|
|
45
|
+
if (parentPath === currentPath) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
currentPath = parentPath;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
28
52
|
//# sourceMappingURL=utils.js.map
|
package/cli/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":";;AAGA,4CAEC;AAOD,4CAaC;AAOD,8CAiBC;AAjDD,2BAAgC;AAChC,+BAAwD;AAExD,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,WAAI,EAAC,SAAS,EAAE,iCAAiC,CAAC,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,OAAY;IAC3C,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;SAC3B,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,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
"version": "19.
|
|
3
|
+
"version": "19.6.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"schematics": "./schematics/factories/collection.json",
|
|
6
6
|
"bin": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@angular-devkit/core": "^19.2.1",
|
|
21
21
|
"@angular-devkit/schematics": "^19.2.1",
|
|
22
22
|
"@angular-devkit/schematics-cli": "^19.2.1",
|
|
23
|
+
"@angular/cli": "^19.2.19",
|
|
23
24
|
"@schematics/angular": "^19.2.1",
|
|
24
25
|
"cli-table3": "^0.6.5",
|
|
25
26
|
"inquirer": "^12.4.3",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
declare const ManifestSchema: z.ZodObject<{
|
|
3
3
|
id: z.ZodString;
|
|
4
4
|
title: z.ZodString;
|
|
5
|
+
requires: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
5
6
|
ui: z.ZodOptional<z.ZodObject<{
|
|
6
7
|
path: z.ZodString;
|
|
7
8
|
svgIcon: z.ZodOptional<z.ZodString>;
|
|
@@ -45,6 +46,7 @@ declare const ManifestSchema: z.ZodObject<{
|
|
|
45
46
|
}, "strip", z.ZodTypeAny, {
|
|
46
47
|
id: string;
|
|
47
48
|
title: string;
|
|
49
|
+
requires?: string[] | undefined;
|
|
48
50
|
ui?: {
|
|
49
51
|
path: string;
|
|
50
52
|
routes: string;
|
|
@@ -60,6 +62,7 @@ declare const ManifestSchema: z.ZodObject<{
|
|
|
60
62
|
}, {
|
|
61
63
|
id: string;
|
|
62
64
|
title: string;
|
|
65
|
+
requires?: string[] | undefined;
|
|
63
66
|
ui?: {
|
|
64
67
|
path: string;
|
|
65
68
|
routes: string;
|
|
@@ -22,8 +22,9 @@ const UiData = zod_1.z.object({
|
|
|
22
22
|
const ManifestSchema = zod_1.z.object({
|
|
23
23
|
id: zod_1.z.string(),
|
|
24
24
|
title: zod_1.z.string(),
|
|
25
|
+
requires: zod_1.z.array(zod_1.z.string()).optional(),
|
|
25
26
|
ui: UiData.optional(),
|
|
26
|
-
extension: zod_1.z.string().optional()
|
|
27
|
+
extension: zod_1.z.string().optional()
|
|
27
28
|
});
|
|
28
29
|
function parseManifest(content) {
|
|
29
30
|
const jsonData = JSON.parse(content);
|
|
@@ -31,7 +32,7 @@ function parseManifest(content) {
|
|
|
31
32
|
}
|
|
32
33
|
function writeManifest(filePath, manifest) {
|
|
33
34
|
try {
|
|
34
|
-
fs_1.default.writeFileSync(filePath, JSON.stringify(manifest, null, 2),
|
|
35
|
+
fs_1.default.writeFileSync(filePath, JSON.stringify(manifest, null, 2), 'utf-8');
|
|
35
36
|
}
|
|
36
37
|
catch (error) {
|
|
37
38
|
throw new Error(`Error writing manifest file $: ${error}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-manifest.js","sourceRoot":"","sources":["../../src/schematics/app-manifest.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"app-manifest.js","sourceRoot":"","sources":["../../src/schematics/app-manifest.ts"],"names":[],"mappings":";;;;;AA2BA,sCAGC;AAED,sCAMC;AAtCD,4CAAoB;AACpB,6BAAwB;AAExB,MAAM,SAAS,GAAG,OAAC,CAAC,MAAM,CAAC;IACzB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,SAAS,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACjC,WAAW,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,OAAC,CAAC,MAAM,CAAC;IACtB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,OAAO,EAAE,SAAS,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9B,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxC,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE;IACrB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAIH,SAAgB,aAAa,CAAC,OAAe;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,SAAgB,aAAa,CAAC,QAAgB,EAAE,QAAqB;IACnE,IAAI,CAAC;QACH,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tree } from
|
|
1
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
2
2
|
export type ComponentStyle = 'css' | 'scss' | 'sass' | 'less' | 'styl' | 'stylus';
|
|
3
3
|
/**
|
|
4
4
|
* Interface for commands that can be executed on an angular.json object.
|
|
@@ -43,7 +43,7 @@ export declare class AddBuildOptionsScriptsToProjectCommand implements AngularJs
|
|
|
43
43
|
/**
|
|
44
44
|
* Adds allowedCommonJsDependencies for a specific project in angular.json.
|
|
45
45
|
*/
|
|
46
|
-
export declare class
|
|
46
|
+
export declare class AddAllowedCommonJsDependenciesToProjectCommand implements AngularJsonCommand {
|
|
47
47
|
private readonly projectName;
|
|
48
48
|
private readonly dependencies;
|
|
49
49
|
constructor(projectName: string, dependencies: string[]);
|
|
@@ -82,6 +82,12 @@ export declare class SetStyleForProjectCommand implements AngularJsonCommand {
|
|
|
82
82
|
constructor(projectName: string, style: ComponentStyle);
|
|
83
83
|
execute(angularJson: any): void;
|
|
84
84
|
}
|
|
85
|
+
export declare class UpdateStylePreprocessorOptionsForTestsCommand implements AngularJsonCommand {
|
|
86
|
+
private readonly projectName;
|
|
87
|
+
private readonly includePaths;
|
|
88
|
+
constructor(projectName: string, includePaths: string[]);
|
|
89
|
+
execute(angularJson: any): void;
|
|
90
|
+
}
|
|
85
91
|
/**
|
|
86
92
|
* Class for editing the angular.json file.
|
|
87
93
|
*/
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AngularJsonEditor = exports.SetStyleForProjectCommand = exports.UpdateDevFileReplacementsForProjectCommand = exports.UpdateInitialBudgetForProjectCommand = exports.
|
|
12
|
+
exports.AngularJsonEditor = exports.UpdateStylePreprocessorOptionsForTestsCommand = exports.SetStyleForProjectCommand = exports.UpdateDevFileReplacementsForProjectCommand = exports.UpdateInitialBudgetForProjectCommand = exports.AddAllowedCommonJsDependenciesToProjectCommand = exports.AddBuildOptionsScriptsToProjectCommand = exports.AddBuildOptionsAssetsToProjectCommand = exports.CompositeAngularJsonCommand = void 0;
|
|
13
13
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
14
|
const project_util_1 = require("../project-util");
|
|
15
15
|
/**
|
|
@@ -24,7 +24,7 @@ class CompositeAngularJsonCommand {
|
|
|
24
24
|
* @param angularJson The angular.json object to modify.
|
|
25
25
|
*/
|
|
26
26
|
execute(angularJson) {
|
|
27
|
-
this.commands.forEach(command => command.execute(angularJson));
|
|
27
|
+
this.commands.forEach((command) => command.execute(angularJson));
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
exports.CompositeAngularJsonCommand = CompositeAngularJsonCommand;
|
|
@@ -69,7 +69,7 @@ exports.AddBuildOptionsScriptsToProjectCommand = AddBuildOptionsScriptsToProject
|
|
|
69
69
|
/**
|
|
70
70
|
* Adds allowedCommonJsDependencies for a specific project in angular.json.
|
|
71
71
|
*/
|
|
72
|
-
class
|
|
72
|
+
class AddAllowedCommonJsDependenciesToProjectCommand {
|
|
73
73
|
constructor(projectName, dependencies) {
|
|
74
74
|
this.projectName = projectName;
|
|
75
75
|
this.dependencies = dependencies;
|
|
@@ -84,7 +84,7 @@ class AdddAllowedCommonJsDependenciesToProjectCommand {
|
|
|
84
84
|
buildOptions.allowedCommonJsDependencies.push(...this.dependencies);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
exports.
|
|
87
|
+
exports.AddAllowedCommonJsDependenciesToProjectCommand = AddAllowedCommonJsDependenciesToProjectCommand;
|
|
88
88
|
/**
|
|
89
89
|
* Updates the initial budget for a specific project in angular.json.
|
|
90
90
|
*/
|
|
@@ -99,7 +99,7 @@ class UpdateInitialBudgetForProjectCommand {
|
|
|
99
99
|
const budgets = (_b = (_a = project.architect) === null || _a === void 0 ? void 0 : _a.build) === null || _b === void 0 ? void 0 : _b.configurations.production.budgets;
|
|
100
100
|
const initialBudget = budgets.find((b) => b.type === 'initial');
|
|
101
101
|
if (initialBudget) {
|
|
102
|
-
['maximumWarning', 'maximumError'].forEach(key => {
|
|
102
|
+
['maximumWarning', 'maximumError'].forEach((key) => {
|
|
103
103
|
if (this.budget[key] !== undefined) {
|
|
104
104
|
initialBudget[key] = this.budget[key];
|
|
105
105
|
}
|
|
@@ -108,7 +108,6 @@ class UpdateInitialBudgetForProjectCommand {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
exports.UpdateInitialBudgetForProjectCommand = UpdateInitialBudgetForProjectCommand;
|
|
111
|
-
;
|
|
112
111
|
/**
|
|
113
112
|
* Updates the file replacements for the development configuration of a specific project in angular.json.
|
|
114
113
|
*/
|
|
@@ -149,6 +148,30 @@ class SetStyleForProjectCommand {
|
|
|
149
148
|
}
|
|
150
149
|
}
|
|
151
150
|
exports.SetStyleForProjectCommand = SetStyleForProjectCommand;
|
|
151
|
+
class UpdateStylePreprocessorOptionsForTestsCommand {
|
|
152
|
+
constructor(projectName, includePaths) {
|
|
153
|
+
this.projectName = projectName;
|
|
154
|
+
this.includePaths = includePaths;
|
|
155
|
+
}
|
|
156
|
+
execute(angularJson) {
|
|
157
|
+
var _a, _b, _c, _d;
|
|
158
|
+
var _e, _f, _g;
|
|
159
|
+
const project = getProject(angularJson, this.projectName);
|
|
160
|
+
if (!((_a = project.architect) === null || _a === void 0 ? void 0 : _a.test)) {
|
|
161
|
+
throw new schematics_1.SchematicsException(`Test target not found for project "${this.projectName}" in angular.json.`);
|
|
162
|
+
}
|
|
163
|
+
(_b = (_e = project.architect.test).options) !== null && _b !== void 0 ? _b : (_e.options = {});
|
|
164
|
+
(_c = (_f = project.architect.test.options).stylePreprocessorOptions) !== null && _c !== void 0 ? _c : (_f.stylePreprocessorOptions = { includePaths: [] });
|
|
165
|
+
(_d = (_g = project.architect.test.options.stylePreprocessorOptions).includePaths) !== null && _d !== void 0 ? _d : (_g.includePaths = []);
|
|
166
|
+
// Add new includePaths without duplicates
|
|
167
|
+
this.includePaths.forEach((path) => {
|
|
168
|
+
if (!project.architect.test.options.stylePreprocessorOptions.includePaths.includes(path)) {
|
|
169
|
+
project.architect.test.options.stylePreprocessorOptions.includePaths.push(path);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.UpdateStylePreprocessorOptionsForTestsCommand = UpdateStylePreprocessorOptionsForTestsCommand;
|
|
152
175
|
/**
|
|
153
176
|
* Class for editing the angular.json file.
|
|
154
177
|
*/
|
|
@@ -165,7 +188,7 @@ class AngularJsonEditor {
|
|
|
165
188
|
*/
|
|
166
189
|
static create(tree, path) {
|
|
167
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
const angularJsonPath = path !== null && path !== void 0 ? path : yield (0, project_util_1.getAngularJsonPath)(tree);
|
|
191
|
+
const angularJsonPath = path !== null && path !== void 0 ? path : (yield (0, project_util_1.getAngularJsonPath)(tree));
|
|
169
192
|
return new AngularJsonEditor(tree, angularJsonPath);
|
|
170
193
|
});
|
|
171
194
|
}
|
|
@@ -212,12 +235,12 @@ class AngularJsonEditor {
|
|
|
212
235
|
}
|
|
213
236
|
exports.AngularJsonEditor = AngularJsonEditor;
|
|
214
237
|
/**
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
238
|
+
* Retrieves a project from the angular.json file by its name.
|
|
239
|
+
* @param angularJson The angular.json object to search in.
|
|
240
|
+
* @param projectName The name of the project to retrieve.
|
|
241
|
+
* @returns The project object if found.
|
|
242
|
+
* @throws {SchematicsException} If the project is not found.
|
|
243
|
+
*/
|
|
221
244
|
function getProject(angularJson, projectName) {
|
|
222
245
|
const project = angularJson.projects[projectName];
|
|
223
246
|
if (!project) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-json.js","sourceRoot":"","sources":["../../../src/schematics/commands/angular-json.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAuE;AACvE,kDAAqD;AAerD;;GAEG;AACH,MAAa,2BAA2B;IACtC,YAA6B,QAA8B;QAA9B,aAAQ,GAAR,QAAQ,CAAsB;IAAG,CAAC;IAE/D;;;OAGG;IACH,OAAO,CAAC,WAAgB;QACtB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"angular-json.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AC;QAC1E,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,gCAAmB,CAAC,kCAAkC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACK,IAAI,CAAC,WAAgB;QAC3B,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;AA1DD,8CA0DC;AAED;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,WAAgB,EAAE,WAAmB;IACvD,MAAM,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAClD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,gCAAmB,CAAC,YAAY,WAAW,8BAA8B,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { UpdateRecorder, SchematicContext } from "@angular-devkit/schematics";
|
|
3
|
+
import { TypeScriptFileCommand } from "./typescript-file";
|
|
4
|
+
export interface AppRequirementsTsCommand extends TypeScriptFileCommand {
|
|
5
|
+
}
|
|
6
|
+
export declare class UpdateAppRequirementsCommand implements AppRequirementsTsCommand {
|
|
7
|
+
private readonly appId;
|
|
8
|
+
private readonly requirements;
|
|
9
|
+
constructor(appId: string, requirements: string[]);
|
|
10
|
+
execute(sourceFile: ts.SourceFile, recorder: UpdateRecorder, filePath: string, context: SchematicContext): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UpdateAppRequirementsCommand = void 0;
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
9
|
+
class UpdateAppRequirementsCommand {
|
|
10
|
+
constructor(appId, requirements) {
|
|
11
|
+
this.appId = appId;
|
|
12
|
+
this.requirements = requirements;
|
|
13
|
+
}
|
|
14
|
+
execute(sourceFile, recorder, filePath, context) {
|
|
15
|
+
// Find the 'requirements' variable declaration
|
|
16
|
+
const requirementsDeclaration = sourceFile.statements.find((s) => typescript_1.default.isVariableStatement(s) && s.declarationList.declarations.some((d) => d.name.getText() === 'requirements'));
|
|
17
|
+
// Someone tampered with the file structure
|
|
18
|
+
if (!requirementsDeclaration) {
|
|
19
|
+
throw new schematics_1.SchematicsException(`Could not find 'requirements' variable in ${filePath}`);
|
|
20
|
+
}
|
|
21
|
+
// Get the object literal initializer
|
|
22
|
+
const declaration = requirementsDeclaration.declarationList.declarations.find((d) => d.name.getText() === 'requirements');
|
|
23
|
+
// Someone tampered with the file structure
|
|
24
|
+
if (!declaration || !declaration.initializer || !typescript_1.default.isObjectLiteralExpression(declaration.initializer)) {
|
|
25
|
+
throw new schematics_1.SchematicsException(`'requirements' is not an object literal in ${filePath}`);
|
|
26
|
+
}
|
|
27
|
+
const objectLiteral = declaration.initializer;
|
|
28
|
+
const properties = objectLiteral.properties;
|
|
29
|
+
// Check if property for the given appId already exists
|
|
30
|
+
const existingProp = properties.find((p) => {
|
|
31
|
+
const nameProp = p.name;
|
|
32
|
+
if (!nameProp)
|
|
33
|
+
return false;
|
|
34
|
+
let text = nameProp.getText();
|
|
35
|
+
// strip quotes
|
|
36
|
+
text = text.replace(/^['"](.*)['"]$/, '$1');
|
|
37
|
+
return text === this.appId;
|
|
38
|
+
});
|
|
39
|
+
if (existingProp && typescript_1.default.isPropertyAssignment(existingProp)) {
|
|
40
|
+
// Replace the value
|
|
41
|
+
const init = existingProp.initializer;
|
|
42
|
+
recorder.remove(init.getStart(), init.getWidth());
|
|
43
|
+
recorder.insertRight(init.getStart(), JSON.stringify(this.requirements, null, 2));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Append property
|
|
47
|
+
if (properties.length > 0) {
|
|
48
|
+
const lastProp = properties[properties.length - 1];
|
|
49
|
+
recorder.insertRight(lastProp.end, `,\n '${this.appId}': ${JSON.stringify(this.requirements, null, 2)}`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Empty object
|
|
53
|
+
recorder.insertRight(objectLiteral.getStart() + 1, `\n '${this.appId}': ${JSON.stringify(this.requirements, null, 2)}\n`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.UpdateAppRequirementsCommand = UpdateAppRequirementsCommand;
|
|
59
|
+
//# sourceMappingURL=app-requirements-ts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-requirements-ts.js","sourceRoot":"","sources":["../../../src/schematics/commands/app-requirements-ts.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAC5B,2DAAmG;AAKnG,MAAa,4BAA4B;IACvC,YAA6B,KAAa,EAAmB,YAAsB;QAAtD,UAAK,GAAL,KAAK,CAAQ;QAAmB,iBAAY,GAAZ,YAAY,CAAU;IAAG,CAAC;IAEvF,OAAO,CAAC,UAAyB,EAAE,QAAwB,EAAE,QAAgB,EAAE,OAAyB;QACtG,+CAA+C;QAC/C,MAAM,uBAAuB,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CACxD,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAE,CAAC,mBAAmB,CAAC,CAAC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CAAC,oBAAoB,CAAC,YAAY,CAAC,EAAE,CAAC;YAC1D,oBAAoB;YACpB,MAAM,IAAI,GAAG,YAAY,CAAC,WAAW,CAAC;YACtC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAClD,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACpF,CAAC;aAAM,CAAC;YACN,kBAAkB;YAClB,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,MAAM,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBACnD,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAC5G,CAAC;iBAAM,CAAC;gBACN,eAAe;gBACf,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,QAAQ,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;YAC7H,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAlDD,oEAkDC"}
|
|
@@ -30,6 +30,31 @@ export declare class AddImportToFileCommand implements TypeScriptFileCommand {
|
|
|
30
30
|
constructor(className: string, moduleName: string);
|
|
31
31
|
execute(sourceFile: ts.SourceFile, recorder: UpdateRecorder, filePath: string): void;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Adds an implements clause to a TypeScript class. If the class already implements the interface, no changes are made.
|
|
35
|
+
*/
|
|
36
|
+
export declare class AddImplementsClauseToClassCommand implements TypeScriptFileCommand {
|
|
37
|
+
private readonly fullInterfaceName;
|
|
38
|
+
constructor(interfaceName: string, genericType?: string);
|
|
39
|
+
execute(sourceFile: ts.SourceFile, recorder: UpdateRecorder, filePath: string): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Adds a property statement to a TypeScript class. If the property already exists, no changes are made.
|
|
43
|
+
* Takes the complete property statement as a string for maximum flexibility.
|
|
44
|
+
*
|
|
45
|
+
* Examples:
|
|
46
|
+
* new AddPropertyToClassCommand('widgetConfig = input<any>()')
|
|
47
|
+
* new AddPropertyToClassCommand('name: string = "default"')
|
|
48
|
+
* new AddPropertyToClassCommand('private count = 0')
|
|
49
|
+
* new AddPropertyToClassCommand('readonly items: string[]')
|
|
50
|
+
*/
|
|
51
|
+
export declare class AddPropertyToClassCommand implements TypeScriptFileCommand {
|
|
52
|
+
private readonly propertyStatement;
|
|
53
|
+
private readonly propertyName;
|
|
54
|
+
constructor(propertyStatement: string);
|
|
55
|
+
private extractPropertyName;
|
|
56
|
+
execute(sourceFile: ts.SourceFile, recorder: UpdateRecorder, filePath: string): void;
|
|
57
|
+
}
|
|
33
58
|
/**
|
|
34
59
|
* Class for editing a typescript file.
|
|
35
60
|
*/
|