@ng-desktop/builders 0.0.0-stage → 0.4.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/LICENSE +21 -0
- package/README.md +13 -2
- package/bin/ng-desktop.mjs +200 -0
- package/builders.json +15 -0
- package/fesm2022/application-builder.d.mts +62 -0
- package/fesm2022/application-builder.mjs +58 -0
- package/fesm2022/ast-metadata-extractor.d.mts +40 -0
- package/fesm2022/ast-metadata-extractor.mjs +460 -0
- package/fesm2022/build-bundle.d.mts +45 -0
- package/fesm2022/build-bundle.mjs +462 -0
- package/fesm2022/builder.d.ts +66 -0
- package/fesm2022/builder.js +123 -0
- package/fesm2022/dev-server-builder.d.mts +26 -0
- package/fesm2022/dev-server-builder.mjs +24 -0
- package/fesm2022/dev-server.mjs +47 -0
- package/fesm2022/hmr-client.d.mts +24 -0
- package/fesm2022/hmr-client.mjs +84 -0
- package/fesm2022/icon-compiler.d.mts +6 -0
- package/fesm2022/icon-compiler.mjs +148 -0
- package/fesm2022/index.d.ts +13 -0
- package/fesm2022/index.js +13 -0
- package/fesm2022/permission-analyzer.d.mts +45 -0
- package/fesm2022/permission-analyzer.mjs +333 -0
- package/fesm2022/resolve-engine-binary.d.mts +35 -0
- package/fesm2022/resolve-engine-binary.mjs +130 -0
- package/fesm2022/server-compiler.d.mts +29 -0
- package/fesm2022/server-compiler.mjs +236 -0
- package/fesm2022/style-compiler.d.mts +26 -0
- package/fesm2022/style-compiler.mjs +258 -0
- package/fesm2022/template-compiler.d.mts +53 -0
- package/fesm2022/template-compiler.mjs +892 -0
- package/fesm2022/workspace-resolver.d.mts +24 -0
- package/fesm2022/workspace-resolver.mjs +199 -0
- package/package.json +79 -4
- package/schema/angular-native-schema.json +52 -0
- package/schema/native-builder-schema.json +97 -0
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.d.mts +20 -0
- package/schematics/ng-add/index.mjs +56 -0
- package/schematics/ng-add/schema.json +24 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type WorkspaceKind = 'angular' | 'nx' | 'runtime';
|
|
2
|
+
|
|
3
|
+
export interface ResolveWorkspaceOptions {
|
|
4
|
+
cwd?: string;
|
|
5
|
+
configPath?: string;
|
|
6
|
+
projectName?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ResolvedWorkspaceProject {
|
|
10
|
+
workspaceKind: WorkspaceKind;
|
|
11
|
+
workspaceRoot: string;
|
|
12
|
+
configFile: string;
|
|
13
|
+
projectName: string;
|
|
14
|
+
projectRoot: string;
|
|
15
|
+
sourceRoot: string;
|
|
16
|
+
outputPath: string;
|
|
17
|
+
version: string;
|
|
18
|
+
buildOptions: Record<string, unknown>;
|
|
19
|
+
nativeOptions: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function resolveWorkspaceProject(
|
|
23
|
+
options?: ResolveWorkspaceOptions,
|
|
24
|
+
): ResolvedWorkspaceProject;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { dirname, relative, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
|
|
7
|
+
function readJsonSafe(filePath) {
|
|
8
|
+
return JSON.parse(readFileSync(filePath, 'utf8'));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function readPackageVersion(workspaceRoot, projectRoot) {
|
|
12
|
+
const candidates = [];
|
|
13
|
+
if (projectRoot && projectRoot !== '.') {
|
|
14
|
+
candidates.push(resolve(workspaceRoot, projectRoot, 'package.json'));
|
|
15
|
+
}
|
|
16
|
+
candidates.push(resolve(workspaceRoot, 'package.json'));
|
|
17
|
+
for (const pkgPath of candidates) {
|
|
18
|
+
if (existsSync(pkgPath)) {
|
|
19
|
+
try {
|
|
20
|
+
const pkg = readJsonSafe(pkgPath);
|
|
21
|
+
if (typeof pkg.version === 'string' && pkg.version.trim()) {
|
|
22
|
+
return pkg.version.trim();
|
|
23
|
+
}
|
|
24
|
+
} catch {
|
|
25
|
+
// Ignore malformed package.json and continue fallback chain
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return '0.4.0';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function findNxProjectJsonFiles(workspaceRoot) {
|
|
33
|
+
const found = [];
|
|
34
|
+
const rootProjectJson = resolve(workspaceRoot, 'project.json');
|
|
35
|
+
if (existsSync(rootProjectJson)) {
|
|
36
|
+
found.push(rootProjectJson);
|
|
37
|
+
}
|
|
38
|
+
for (const container of ['apps', 'projects', 'packages', 'examples']) {
|
|
39
|
+
const containerDir = resolve(workspaceRoot, container);
|
|
40
|
+
if (!existsSync(containerDir)) continue;
|
|
41
|
+
for (const entry of readdirSync(containerDir)) {
|
|
42
|
+
const candidateDir = resolve(containerDir, entry);
|
|
43
|
+
if (!statSync(candidateDir).isDirectory()) continue;
|
|
44
|
+
const projectJson = resolve(candidateDir, 'project.json');
|
|
45
|
+
if (existsSync(projectJson)) {
|
|
46
|
+
found.push(projectJson);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return found;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function resolveFromAngularJson(workspaceRoot, configFile, angularJson, requestedProject) {
|
|
54
|
+
const projects = angularJson.projects ?? {};
|
|
55
|
+
const projectKeys = Object.keys(projects);
|
|
56
|
+
if (projectKeys.length === 0) {
|
|
57
|
+
throw new Error(`No projects defined in '${configFile}'`);
|
|
58
|
+
}
|
|
59
|
+
const projectName =
|
|
60
|
+
requestedProject && projects[requestedProject]
|
|
61
|
+
? requestedProject
|
|
62
|
+
: angularJson.defaultProject && projects[angularJson.defaultProject]
|
|
63
|
+
? angularJson.defaultProject
|
|
64
|
+
: projectKeys[0];
|
|
65
|
+
|
|
66
|
+
const projectCfg = projects[projectName];
|
|
67
|
+
if (!projectCfg) {
|
|
68
|
+
throw new Error(`Project '${projectName}' not found in '${configFile}'`);
|
|
69
|
+
}
|
|
70
|
+
const projectRoot = projectCfg.root ?? '.';
|
|
71
|
+
const sourceRoot = projectCfg.sourceRoot ?? (projectRoot === '.' ? 'src' : `${projectRoot}/src`);
|
|
72
|
+
const buildOptions = projectCfg.architect?.build?.options ?? {};
|
|
73
|
+
const nativeOptions = projectCfg.architect?.native?.options ?? {};
|
|
74
|
+
const outputPath = nativeOptions.outputPath || buildOptions.outputPath || `dist/${projectName}`;
|
|
75
|
+
const version = nativeOptions.version || readPackageVersion(workspaceRoot, projectRoot);
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
workspaceKind: 'angular',
|
|
79
|
+
workspaceRoot,
|
|
80
|
+
configFile,
|
|
81
|
+
projectName,
|
|
82
|
+
projectRoot,
|
|
83
|
+
sourceRoot,
|
|
84
|
+
outputPath,
|
|
85
|
+
version,
|
|
86
|
+
buildOptions,
|
|
87
|
+
nativeOptions,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function resolveFromNxProjectJson(workspaceRoot, configFile, projectJson) {
|
|
92
|
+
const projectName = projectJson.name;
|
|
93
|
+
if (!projectName || typeof projectName !== 'string') {
|
|
94
|
+
throw new Error(`Missing 'name' in Nx project config '${configFile}'`);
|
|
95
|
+
}
|
|
96
|
+
const relDir = relative(workspaceRoot, dirname(configFile));
|
|
97
|
+
const projectRoot = relDir === '' ? '.' : relDir;
|
|
98
|
+
const sourceRoot = projectJson.sourceRoot ?? (projectRoot === '.' ? 'src' : `${projectRoot}/src`);
|
|
99
|
+
const buildOptions = projectJson.targets?.build?.options ?? {};
|
|
100
|
+
const nativeOptions = projectJson.targets?.native?.options ?? {};
|
|
101
|
+
const outputPath =
|
|
102
|
+
nativeOptions.outputPath ||
|
|
103
|
+
buildOptions.outputPath ||
|
|
104
|
+
(projectRoot === '.' ? `dist/${projectName}` : `dist/${projectRoot}`);
|
|
105
|
+
const version = nativeOptions.version || readPackageVersion(workspaceRoot, projectRoot);
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
workspaceKind: 'nx',
|
|
109
|
+
workspaceRoot,
|
|
110
|
+
configFile,
|
|
111
|
+
projectName,
|
|
112
|
+
projectRoot,
|
|
113
|
+
sourceRoot,
|
|
114
|
+
outputPath,
|
|
115
|
+
version,
|
|
116
|
+
buildOptions,
|
|
117
|
+
nativeOptions,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function resolveFromRuntimeManifest(workspaceRoot, configFile, runtimeJson) {
|
|
122
|
+
const projectName = runtimeJson.projectName;
|
|
123
|
+
if (!projectName || typeof projectName !== 'string') {
|
|
124
|
+
throw new Error(`Missing 'projectName' in runtime manifest '${configFile}'`);
|
|
125
|
+
}
|
|
126
|
+
const outputPath = runtimeJson.outputPath || `dist/${projectName}`;
|
|
127
|
+
const version = runtimeJson.version || readPackageVersion(workspaceRoot, '.');
|
|
128
|
+
return {
|
|
129
|
+
workspaceKind: 'runtime',
|
|
130
|
+
workspaceRoot,
|
|
131
|
+
configFile,
|
|
132
|
+
projectName,
|
|
133
|
+
projectRoot: runtimeJson.projectRoot || '.',
|
|
134
|
+
sourceRoot: runtimeJson.sourceRoot || 'src',
|
|
135
|
+
outputPath,
|
|
136
|
+
version,
|
|
137
|
+
buildOptions: {},
|
|
138
|
+
nativeOptions: {
|
|
139
|
+
targetPlatform: runtimeJson.targetPlatform,
|
|
140
|
+
outputPath,
|
|
141
|
+
version,
|
|
142
|
+
permissions: runtimeJson.permissions,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Resolves workspace configuration across Angular CLI (`angular.json`), Nx (`project.json` / `nx.json`),
|
|
149
|
+
* and serialized builder runtime manifests (`ng-desktop.runtime.json`) without hardcoded literals.
|
|
150
|
+
*/
|
|
151
|
+
export function resolveWorkspaceProject({ cwd = process.cwd(), configPath, projectName } = {}) {
|
|
152
|
+
if (configPath) {
|
|
153
|
+
const absConfig = resolve(cwd, configPath);
|
|
154
|
+
if (!existsSync(absConfig)) {
|
|
155
|
+
throw new Error(`Workspace config file not found: '${absConfig}'`);
|
|
156
|
+
}
|
|
157
|
+
const raw = readJsonSafe(absConfig);
|
|
158
|
+
if (raw.projects && typeof raw.projects === 'object') {
|
|
159
|
+
return resolveFromAngularJson(dirname(absConfig), absConfig, raw, projectName);
|
|
160
|
+
}
|
|
161
|
+
if (raw.projectName && !raw.targets) {
|
|
162
|
+
return resolveFromRuntimeManifest(dirname(absConfig), absConfig, raw);
|
|
163
|
+
}
|
|
164
|
+
return resolveFromNxProjectJson(dirname(absConfig), absConfig, raw);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const candidateRoots = [cwd, resolve(__dirname, '../../..')];
|
|
168
|
+
for (const root of candidateRoots) {
|
|
169
|
+
const angularFile = resolve(root, 'angular.json');
|
|
170
|
+
if (existsSync(angularFile)) {
|
|
171
|
+
return resolveFromAngularJson(root, angularFile, readJsonSafe(angularFile), projectName);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const directProjectJson = resolve(root, 'project.json');
|
|
175
|
+
if (existsSync(directProjectJson)) {
|
|
176
|
+
const parsed = readJsonSafe(directProjectJson);
|
|
177
|
+
if (!projectName || parsed.name === projectName) {
|
|
178
|
+
return resolveFromNxProjectJson(root, directProjectJson, parsed);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (existsSync(resolve(root, 'nx.json'))) {
|
|
183
|
+
const nxProjects = findNxProjectJsonFiles(root);
|
|
184
|
+
const parsedList = nxProjects.map((file) => ({ file, json: readJsonSafe(file) }));
|
|
185
|
+
const selected =
|
|
186
|
+
(projectName && parsedList.find((item) => item.json.name === projectName)) ||
|
|
187
|
+
parsedList.find((item) => item.json.targets?.native) ||
|
|
188
|
+
parsedList.find((item) => item.json.projectType === 'application') ||
|
|
189
|
+
parsedList[0];
|
|
190
|
+
if (selected) {
|
|
191
|
+
return resolveFromNxProjectJson(root, selected.file, selected.json);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
throw new Error(
|
|
197
|
+
`No Angular ('angular.json') or Nx ('project.json' / 'nx.json') workspace found from '${cwd}'`,
|
|
198
|
+
);
|
|
199
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,81 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-desktop/builders",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Angular 22+ CLI & Nx Architect builder, AST permission analyzer, CLI, and schematics",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"angular",
|
|
8
|
+
"angular22",
|
|
9
|
+
"desktop",
|
|
10
|
+
"native",
|
|
11
|
+
"gtk4",
|
|
12
|
+
"winui3",
|
|
13
|
+
"appkit",
|
|
14
|
+
"rust"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/Gaspar1992/ng-desktop-engine",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/Gaspar1992/ng-desktop-engine/issues"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/Gaspar1992/ng-desktop-engine.git",
|
|
23
|
+
"directory": "packages/builders-native"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"files": [
|
|
31
|
+
"fesm2022",
|
|
32
|
+
"bin",
|
|
33
|
+
"builders.json",
|
|
34
|
+
"schema",
|
|
35
|
+
"schematics",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE",
|
|
38
|
+
"!**/*.map"
|
|
39
|
+
],
|
|
40
|
+
"main": "./fesm2022/index.js",
|
|
41
|
+
"module": "./fesm2022/index.js",
|
|
42
|
+
"types": "./fesm2022/index.d.ts",
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"types": "./fesm2022/index.d.ts",
|
|
46
|
+
"default": "./fesm2022/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./package.json": {
|
|
49
|
+
"default": "./package.json"
|
|
50
|
+
},
|
|
51
|
+
"./schema/*": {
|
|
52
|
+
"default": "./schema/*"
|
|
53
|
+
},
|
|
54
|
+
"./schematics": {
|
|
55
|
+
"default": "./schematics/collection.json"
|
|
56
|
+
},
|
|
57
|
+
"./builders": {
|
|
58
|
+
"default": "./builders.json"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"builders": "./builders.json",
|
|
62
|
+
"bin": {
|
|
63
|
+
"ng-desktop": "bin/ng-desktop.mjs"
|
|
64
|
+
},
|
|
65
|
+
"schematics": "./schematics/collection.json",
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"@angular/core": ">=22.0.0"
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@angular/compiler": ">=22.0.0",
|
|
71
|
+
"oxc-parser": ">=0.159.0",
|
|
72
|
+
"postcss": ">=8.5.0"
|
|
73
|
+
},
|
|
74
|
+
"optionalDependencies": {
|
|
75
|
+
"@ng-desktop/engine-linux-x64-gnu": "0.4.0",
|
|
76
|
+
"@ng-desktop/engine-linux-arm64-gnu": "0.4.0",
|
|
77
|
+
"@ng-desktop/engine-win32-x64-msvc": "0.4.0",
|
|
78
|
+
"@ng-desktop/engine-darwin-arm64": "0.4.0",
|
|
79
|
+
"@ng-desktop/engine-darwin-x64": "0.4.0"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "ng-desktop://config/angular-native-schema.json",
|
|
4
|
+
"title": "Angular + NgDesktop Extended Workspace Configuration",
|
|
5
|
+
"description": "Extends the official Angular CLI workspace schema with minimal native desktop OS, CPU architecture, and packaging configuration.",
|
|
6
|
+
"allOf": [
|
|
7
|
+
{
|
|
8
|
+
"$ref": "../../../node_modules/@angular/cli/lib/config/schema.json"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"projects": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"additionalProperties": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"properties": {
|
|
18
|
+
"architect": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"properties": {
|
|
21
|
+
"native": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"builder": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"enum": [
|
|
27
|
+
"@ng-desktop/builders:application",
|
|
28
|
+
"@ng-desktop/builders:build",
|
|
29
|
+
"@ng-desktop/builders:engine",
|
|
30
|
+
"@ng-desktop/builders:dev-server"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"options": {
|
|
34
|
+
"$ref": "./native-builder-schema.json"
|
|
35
|
+
},
|
|
36
|
+
"configurations": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"additionalProperties": {
|
|
39
|
+
"$ref": "./native-builder-schema.json"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Angular Native Application Builder Options",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"os": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"enum": ["auto", "linux", "windows", "macos"],
|
|
9
|
+
"default": "auto",
|
|
10
|
+
"description": "Target desktop operating system. Defaults to the current host OS and derives the native toolkit automatically."
|
|
11
|
+
},
|
|
12
|
+
"arch": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"enum": ["auto", "x86_64", "aarch64", "universal"],
|
|
15
|
+
"default": "auto",
|
|
16
|
+
"description": "Target CPU architecture for the compiled native binary."
|
|
17
|
+
},
|
|
18
|
+
"cpu": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"enum": ["auto", "native", "baseline", "avx2", "neon"],
|
|
21
|
+
"default": "auto",
|
|
22
|
+
"description": "Target CPU instruction profile for ahead-of-time Rust codegen."
|
|
23
|
+
},
|
|
24
|
+
"targetPlatform": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"enum": ["linux-gtk4", "windows-winui", "macos-appkit"],
|
|
27
|
+
"description": "Optional explicit native UI backend override (derived automatically from 'os' when omitted)."
|
|
28
|
+
},
|
|
29
|
+
"jsEngine": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"enum": ["jsc", "quickjs"],
|
|
32
|
+
"description": "Optional embedded JavaScript engine override (defaults to 'jsc' on Linux/macOS and 'quickjs' on Windows)."
|
|
33
|
+
},
|
|
34
|
+
"outputPath": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "Optional output directory override (defaults to 'dist/<projectName>' inherited from architect.build)."
|
|
37
|
+
},
|
|
38
|
+
"main": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "Optional main entrypoint override (inherited from architect.build.options.browser)."
|
|
41
|
+
},
|
|
42
|
+
"projectName": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "Target workspace project name when invoked outside an explicit Architect target."
|
|
45
|
+
},
|
|
46
|
+
"configPath": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"description": "Optional path to angular.json or project.json."
|
|
49
|
+
},
|
|
50
|
+
"rebuildIcons": {
|
|
51
|
+
"type": "boolean",
|
|
52
|
+
"default": true,
|
|
53
|
+
"description": "Whether to regenerate multi-resolution OS application icons during compilation."
|
|
54
|
+
},
|
|
55
|
+
"watch": {
|
|
56
|
+
"type": "boolean",
|
|
57
|
+
"default": false,
|
|
58
|
+
"description": "Watch source files and push incremental HMR updates over IPC when running dev-server."
|
|
59
|
+
},
|
|
60
|
+
"version": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "Application release version propagated to runtime config and OS installers."
|
|
63
|
+
},
|
|
64
|
+
"permissions": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"description": "Build-time static capability analysis policy and manual allow/deny overrides.",
|
|
67
|
+
"properties": {
|
|
68
|
+
"mode": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"enum": ["auto", "strict"],
|
|
71
|
+
"default": "auto",
|
|
72
|
+
"description": "'auto' infers capabilities from AST usage + overrides; 'strict' grants only 'allow'."
|
|
73
|
+
},
|
|
74
|
+
"allow": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"items": { "type": "string" },
|
|
77
|
+
"description": "Capabilities explicitly granted (e.g. 'network', 'sqlite', 'filesystem:dialogs')."
|
|
78
|
+
},
|
|
79
|
+
"deny": {
|
|
80
|
+
"type": "array",
|
|
81
|
+
"items": { "type": "string" },
|
|
82
|
+
"description": "Capabilities explicitly revoked even if detected in source files."
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"additionalProperties": false
|
|
86
|
+
},
|
|
87
|
+
"packageFormats": {
|
|
88
|
+
"type": "array",
|
|
89
|
+
"items": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"enum": ["deb", "appimage", "flatpak", "msi", "dmg"]
|
|
92
|
+
},
|
|
93
|
+
"description": "Distribution package formats emitted by the native packager."
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"additionalProperties": false
|
|
97
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"ng-add": {
|
|
5
|
+
"description": "Configure Angular Desktop Engine (@ng-desktop/*) with workspace-agnostic native build and least-privilege permission analysis.",
|
|
6
|
+
"factory": "./ng-add/index.mjs",
|
|
7
|
+
"schema": "./ng-add/schema.json"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface SchematicTreeLike {
|
|
2
|
+
exists(path: string): boolean;
|
|
3
|
+
read(path: string): Buffer | string | null;
|
|
4
|
+
overwrite(path: string, content: string): void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface NgAddSchematicOptions {
|
|
8
|
+
project?: string;
|
|
9
|
+
targetPlatform?: 'linux-gtk4' | 'windows-winui' | 'macos-appkit';
|
|
10
|
+
permissionsMode?: 'auto' | 'strict';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function applyNgAddToTree<T extends SchematicTreeLike>(
|
|
14
|
+
tree: T,
|
|
15
|
+
options?: NgAddSchematicOptions,
|
|
16
|
+
): T;
|
|
17
|
+
|
|
18
|
+
export default function ngAddSchematic(
|
|
19
|
+
options?: NgAddSchematicOptions,
|
|
20
|
+
): <T extends SchematicTreeLike>(tree: T) => T;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure schematic tree helper usable by `ng add @ng-desktop/builders` or direct unit verification.
|
|
3
|
+
*/
|
|
4
|
+
export function applyNgAddToTree(tree, options = {}) {
|
|
5
|
+
const targetPlatform = options.targetPlatform || 'linux-gtk4';
|
|
6
|
+
const permissionsMode = options.permissionsMode || 'auto';
|
|
7
|
+
|
|
8
|
+
if (tree.exists('/package.json')) {
|
|
9
|
+
const pkgRaw = tree.read('/package.json')?.toString('utf8') ?? '{}';
|
|
10
|
+
const pkg = JSON.parse(pkgRaw);
|
|
11
|
+
pkg.dependencies ??= {};
|
|
12
|
+
pkg.dependencies['@ng-desktop/platform'] ??= '>=0.4.0';
|
|
13
|
+
pkg.devDependencies ??= {};
|
|
14
|
+
pkg.devDependencies['@ng-desktop/builders'] ??= '>=0.4.0';
|
|
15
|
+
tree.overwrite('/package.json', `${JSON.stringify(pkg, null, 2)}\n`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const builderOptions = {
|
|
19
|
+
targetPlatform,
|
|
20
|
+
permissions: {
|
|
21
|
+
mode: permissionsMode,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
if (tree.exists('/angular.json')) {
|
|
26
|
+
const raw = JSON.parse(tree.read('/angular.json').toString('utf8'));
|
|
27
|
+
const projectName = options.project || raw.defaultProject || Object.keys(raw.projects ?? {})[0];
|
|
28
|
+
if (projectName && raw.projects?.[projectName]) {
|
|
29
|
+
raw.projects[projectName].architect ??= {};
|
|
30
|
+
raw.projects[projectName].architect.native ??= {
|
|
31
|
+
builder: '@ng-desktop/builders:application',
|
|
32
|
+
options: builderOptions,
|
|
33
|
+
};
|
|
34
|
+
tree.overwrite('/angular.json', `${JSON.stringify(raw, null, 2)}\n`);
|
|
35
|
+
}
|
|
36
|
+
return tree;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const nxProjectPath = options.project ? `/apps/${options.project}/project.json` : '/project.json';
|
|
40
|
+
const fallbackPath = tree.exists(nxProjectPath) ? nxProjectPath : '/project.json';
|
|
41
|
+
if (tree.exists(fallbackPath)) {
|
|
42
|
+
const projectJson = JSON.parse(tree.read(fallbackPath).toString('utf8'));
|
|
43
|
+
projectJson.targets ??= {};
|
|
44
|
+
projectJson.targets.native ??= {
|
|
45
|
+
executor: '@ng-desktop/builders:application',
|
|
46
|
+
options: builderOptions,
|
|
47
|
+
};
|
|
48
|
+
tree.overwrite(fallbackPath, `${JSON.stringify(projectJson, null, 2)}\n`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return tree;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default function ngAddSchematic(options = {}) {
|
|
55
|
+
return (tree) => applyNgAddToTree(tree, options);
|
|
56
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "NgDesktopNgAddSchema",
|
|
4
|
+
"title": "ng add @ng-desktop/builders",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Target Angular or Nx project name to configure."
|
|
10
|
+
},
|
|
11
|
+
"targetPlatform": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"enum": ["linux-gtk4", "windows-winui", "macos-appkit"],
|
|
14
|
+
"default": "linux-gtk4",
|
|
15
|
+
"description": "Primary desktop platform target."
|
|
16
|
+
},
|
|
17
|
+
"permissionsMode": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"enum": ["auto", "strict"],
|
|
20
|
+
"default": "auto",
|
|
21
|
+
"description": "Build-time OS permission inference policy."
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|