@nextclaw/app-runtime 0.1.0 → 0.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 +125 -3
- package/dist/bundle/app-bundle.service.d.ts +27 -0
- package/dist/bundle/app-bundle.service.js +133 -0
- package/dist/bundle/app-bundle.types.d.ts +24 -0
- package/dist/cli/app-runtime-cli.service.d.ts +27 -0
- package/dist/cli/app-runtime-cli.service.js +281 -0
- package/dist/cli/app-runtime-options.service.d.ts +60 -0
- package/dist/cli/app-runtime-options.service.js +215 -0
- package/dist/commands/create.controller.d.ts +14 -0
- package/dist/commands/create.controller.js +23 -0
- package/dist/commands/grant.controller.d.ts +16 -0
- package/dist/commands/grant.controller.js +25 -0
- package/dist/commands/info.controller.d.ts +14 -0
- package/dist/commands/info.controller.js +27 -0
- package/dist/commands/install.controller.d.ts +15 -0
- package/dist/commands/install.controller.js +24 -0
- package/dist/commands/list.controller.d.ts +13 -0
- package/dist/commands/list.controller.js +25 -0
- package/dist/commands/pack.controller.d.ts +15 -0
- package/dist/commands/pack.controller.js +25 -0
- package/dist/commands/permissions.controller.d.ts +14 -0
- package/dist/commands/permissions.controller.js +26 -0
- package/dist/commands/registry.controller.d.ts +16 -0
- package/dist/commands/registry.controller.js +27 -0
- package/dist/commands/revoke.controller.d.ts +15 -0
- package/dist/commands/revoke.controller.js +24 -0
- package/dist/commands/run.controller.js +14 -6
- package/dist/commands/uninstall.controller.d.ts +15 -0
- package/dist/commands/uninstall.controller.js +23 -0
- package/dist/commands/update.controller.d.ts +16 -0
- package/dist/commands/update.controller.js +29 -0
- package/dist/host/app-instance.service.d.ts +3 -1
- package/dist/host/app-instance.service.js +2 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +23 -2
- package/dist/install/app-installation.service.d.ts +37 -0
- package/dist/install/app-installation.service.js +255 -0
- package/dist/install/app-installation.types.d.ts +62 -0
- package/dist/main.js +5 -108
- package/dist/package.js +1 -1
- package/dist/paths/app-home.service.d.ts +16 -0
- package/dist/paths/app-home.service.js +42 -0
- package/dist/permissions/app-grant.service.d.ts +22 -0
- package/dist/permissions/app-grant.service.js +63 -0
- package/dist/permissions/app-permissions.service.d.ts +3 -1
- package/dist/permissions/app-permissions.service.js +12 -5
- package/dist/permissions/app-permissions.types.d.ts +28 -1
- package/dist/registry/app-registry-config.service.d.ts +16 -0
- package/dist/registry/app-registry-config.service.js +84 -0
- package/dist/registry/app-registry.service.d.ts +38 -0
- package/dist/registry/app-registry.service.js +115 -0
- package/dist/registry/app-registry.types.d.ts +33 -0
- package/dist/registry/app-remote-registry-client.service.d.ts +28 -0
- package/dist/registry/app-remote-registry-client.service.js +114 -0
- package/dist/registry/app-remote-registry.types.d.ts +52 -0
- package/dist/registry/app-remote-registry.types.js +4 -0
- package/dist/scaffold/app-scaffold.service.d.ts +19 -0
- package/dist/scaffold/app-scaffold.service.js +260 -0
- package/package.json +4 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AppDocumentGrantMap } from "../permissions/app-permissions.types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/app-runtime-options.service.d.ts
|
|
4
|
+
type RuntimeCliOptions = {
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
json: boolean;
|
|
8
|
+
documentGrantMap: AppDocumentGrantMap;
|
|
9
|
+
};
|
|
10
|
+
type CreateCliOptions = {
|
|
11
|
+
json: boolean;
|
|
12
|
+
};
|
|
13
|
+
type PackCliOptions = {
|
|
14
|
+
json: boolean;
|
|
15
|
+
outputPath?: string;
|
|
16
|
+
};
|
|
17
|
+
type JsonOnlyCliOptions = {
|
|
18
|
+
json: boolean;
|
|
19
|
+
};
|
|
20
|
+
type InstallCliOptions = {
|
|
21
|
+
json: boolean;
|
|
22
|
+
registryUrl?: string;
|
|
23
|
+
};
|
|
24
|
+
type UpdateCliOptions = {
|
|
25
|
+
json: boolean;
|
|
26
|
+
registryUrl?: string;
|
|
27
|
+
version?: string;
|
|
28
|
+
};
|
|
29
|
+
type UninstallCliOptions = {
|
|
30
|
+
json: boolean;
|
|
31
|
+
purgeData: boolean;
|
|
32
|
+
};
|
|
33
|
+
type GrantCliOptions = {
|
|
34
|
+
json: boolean;
|
|
35
|
+
documentGrantMap: AppDocumentGrantMap;
|
|
36
|
+
};
|
|
37
|
+
type RevokeCliOptions = {
|
|
38
|
+
json: boolean;
|
|
39
|
+
documentScopeIds: string[];
|
|
40
|
+
};
|
|
41
|
+
declare class AppRuntimeOptionsService {
|
|
42
|
+
readTarget: (command: string, rawArgs: string[]) => {
|
|
43
|
+
target: string;
|
|
44
|
+
optionArgs: string[];
|
|
45
|
+
};
|
|
46
|
+
readCreateOptions: (rawArgs: string[]) => CreateCliOptions;
|
|
47
|
+
readPackOptions: (rawArgs: string[]) => PackCliOptions;
|
|
48
|
+
readJsonOnlyOptions: (rawArgs: string[]) => JsonOnlyCliOptions;
|
|
49
|
+
readInstallOptions: (rawArgs: string[]) => InstallCliOptions;
|
|
50
|
+
readUpdateOptions: (rawArgs: string[]) => UpdateCliOptions;
|
|
51
|
+
readUninstallOptions: (rawArgs: string[]) => UninstallCliOptions;
|
|
52
|
+
readRuntimeOptions: (rawArgs: string[]) => RuntimeCliOptions;
|
|
53
|
+
readGrantOptions: (rawArgs: string[]) => GrantCliOptions;
|
|
54
|
+
readRevokeOptions: (rawArgs: string[]) => RevokeCliOptions;
|
|
55
|
+
private assignDocumentGrant;
|
|
56
|
+
private readDocumentScopeId;
|
|
57
|
+
private requireOptionValue;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { AppRuntimeOptionsService, CreateCliOptions, GrantCliOptions, InstallCliOptions, JsonOnlyCliOptions, PackCliOptions, RevokeCliOptions, RuntimeCliOptions, UninstallCliOptions, UpdateCliOptions };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
//#region src/cli/app-runtime-options.service.ts
|
|
2
|
+
var AppRuntimeOptionsService = class {
|
|
3
|
+
readTarget = (command, rawArgs) => {
|
|
4
|
+
const [target, ...optionArgs] = rawArgs;
|
|
5
|
+
if (!target || target.startsWith("--")) throw new Error(`${command} 缺少目标参数。`);
|
|
6
|
+
return {
|
|
7
|
+
target,
|
|
8
|
+
optionArgs
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
readCreateOptions = (rawArgs) => {
|
|
12
|
+
const options = { json: false };
|
|
13
|
+
for (const current of rawArgs) {
|
|
14
|
+
if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
|
|
15
|
+
switch (current) {
|
|
16
|
+
case "--json":
|
|
17
|
+
options.json = true;
|
|
18
|
+
break;
|
|
19
|
+
default: throw new Error(`未知参数:${current}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return options;
|
|
23
|
+
};
|
|
24
|
+
readPackOptions = (rawArgs) => {
|
|
25
|
+
const options = { json: false };
|
|
26
|
+
for (let index = 0; index < rawArgs.length; index += 1) {
|
|
27
|
+
const current = rawArgs[index];
|
|
28
|
+
if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
|
|
29
|
+
const nextValue = rawArgs[index + 1];
|
|
30
|
+
switch (current) {
|
|
31
|
+
case "--json":
|
|
32
|
+
options.json = true;
|
|
33
|
+
break;
|
|
34
|
+
case "--out":
|
|
35
|
+
options.outputPath = this.requireOptionValue(current, nextValue);
|
|
36
|
+
index += 1;
|
|
37
|
+
break;
|
|
38
|
+
default: throw new Error(`未知参数:${current}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return options;
|
|
42
|
+
};
|
|
43
|
+
readJsonOnlyOptions = (rawArgs) => {
|
|
44
|
+
const options = { json: false };
|
|
45
|
+
for (const current of rawArgs) {
|
|
46
|
+
if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
|
|
47
|
+
switch (current) {
|
|
48
|
+
case "--json":
|
|
49
|
+
options.json = true;
|
|
50
|
+
break;
|
|
51
|
+
default: throw new Error(`未知参数:${current}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return options;
|
|
55
|
+
};
|
|
56
|
+
readInstallOptions = (rawArgs) => {
|
|
57
|
+
const options = { json: false };
|
|
58
|
+
for (let index = 0; index < rawArgs.length; index += 1) {
|
|
59
|
+
const current = rawArgs[index];
|
|
60
|
+
if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
|
|
61
|
+
const nextValue = rawArgs[index + 1];
|
|
62
|
+
switch (current) {
|
|
63
|
+
case "--json":
|
|
64
|
+
options.json = true;
|
|
65
|
+
break;
|
|
66
|
+
case "--registry":
|
|
67
|
+
options.registryUrl = this.requireOptionValue(current, nextValue);
|
|
68
|
+
index += 1;
|
|
69
|
+
break;
|
|
70
|
+
default: throw new Error(`未知参数:${current}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return options;
|
|
74
|
+
};
|
|
75
|
+
readUpdateOptions = (rawArgs) => {
|
|
76
|
+
const options = { json: false };
|
|
77
|
+
for (let index = 0; index < rawArgs.length; index += 1) {
|
|
78
|
+
const current = rawArgs[index];
|
|
79
|
+
if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
|
|
80
|
+
const nextValue = rawArgs[index + 1];
|
|
81
|
+
switch (current) {
|
|
82
|
+
case "--json":
|
|
83
|
+
options.json = true;
|
|
84
|
+
break;
|
|
85
|
+
case "--registry":
|
|
86
|
+
options.registryUrl = this.requireOptionValue(current, nextValue);
|
|
87
|
+
index += 1;
|
|
88
|
+
break;
|
|
89
|
+
case "--version":
|
|
90
|
+
options.version = this.requireOptionValue(current, nextValue);
|
|
91
|
+
index += 1;
|
|
92
|
+
break;
|
|
93
|
+
default: throw new Error(`未知参数:${current}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return options;
|
|
97
|
+
};
|
|
98
|
+
readUninstallOptions = (rawArgs) => {
|
|
99
|
+
const options = {
|
|
100
|
+
json: false,
|
|
101
|
+
purgeData: false
|
|
102
|
+
};
|
|
103
|
+
for (const current of rawArgs) {
|
|
104
|
+
if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
|
|
105
|
+
switch (current) {
|
|
106
|
+
case "--json":
|
|
107
|
+
options.json = true;
|
|
108
|
+
break;
|
|
109
|
+
case "--purge-data":
|
|
110
|
+
options.purgeData = true;
|
|
111
|
+
break;
|
|
112
|
+
default: throw new Error(`未知参数:${current}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return options;
|
|
116
|
+
};
|
|
117
|
+
readRuntimeOptions = (rawArgs) => {
|
|
118
|
+
const options = {
|
|
119
|
+
host: "127.0.0.1",
|
|
120
|
+
port: 3100,
|
|
121
|
+
json: false,
|
|
122
|
+
documentGrantMap: {}
|
|
123
|
+
};
|
|
124
|
+
for (let index = 0; index < rawArgs.length; index += 1) {
|
|
125
|
+
const current = rawArgs[index];
|
|
126
|
+
if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
|
|
127
|
+
const nextValue = rawArgs[index + 1];
|
|
128
|
+
switch (current) {
|
|
129
|
+
case "--host":
|
|
130
|
+
options.host = this.requireOptionValue(current, nextValue);
|
|
131
|
+
index += 1;
|
|
132
|
+
break;
|
|
133
|
+
case "--port":
|
|
134
|
+
options.port = Number.parseInt(this.requireOptionValue(current, nextValue), 10);
|
|
135
|
+
if (Number.isNaN(options.port) || options.port < 0) throw new Error("--port 必须是非负整数。");
|
|
136
|
+
index += 1;
|
|
137
|
+
break;
|
|
138
|
+
case "--json":
|
|
139
|
+
options.json = true;
|
|
140
|
+
break;
|
|
141
|
+
case "--document":
|
|
142
|
+
this.assignDocumentGrant(options.documentGrantMap, this.requireOptionValue(current, nextValue));
|
|
143
|
+
index += 1;
|
|
144
|
+
break;
|
|
145
|
+
default: throw new Error(`未知参数:${current}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return options;
|
|
149
|
+
};
|
|
150
|
+
readGrantOptions = (rawArgs) => {
|
|
151
|
+
const options = {
|
|
152
|
+
json: false,
|
|
153
|
+
documentGrantMap: {}
|
|
154
|
+
};
|
|
155
|
+
for (let index = 0; index < rawArgs.length; index += 1) {
|
|
156
|
+
const current = rawArgs[index];
|
|
157
|
+
if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
|
|
158
|
+
const nextValue = rawArgs[index + 1];
|
|
159
|
+
switch (current) {
|
|
160
|
+
case "--json":
|
|
161
|
+
options.json = true;
|
|
162
|
+
break;
|
|
163
|
+
case "--document":
|
|
164
|
+
this.assignDocumentGrant(options.documentGrantMap, this.requireOptionValue(current, nextValue));
|
|
165
|
+
index += 1;
|
|
166
|
+
break;
|
|
167
|
+
default: throw new Error(`未知参数:${current}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (Object.keys(options.documentGrantMap).length === 0) throw new Error("grant 至少需要一个 --document scope=/path。");
|
|
171
|
+
return options;
|
|
172
|
+
};
|
|
173
|
+
readRevokeOptions = (rawArgs) => {
|
|
174
|
+
const options = {
|
|
175
|
+
json: false,
|
|
176
|
+
documentScopeIds: []
|
|
177
|
+
};
|
|
178
|
+
for (let index = 0; index < rawArgs.length; index += 1) {
|
|
179
|
+
const current = rawArgs[index];
|
|
180
|
+
if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
|
|
181
|
+
const nextValue = rawArgs[index + 1];
|
|
182
|
+
switch (current) {
|
|
183
|
+
case "--json":
|
|
184
|
+
options.json = true;
|
|
185
|
+
break;
|
|
186
|
+
case "--document":
|
|
187
|
+
options.documentScopeIds.push(this.readDocumentScopeId(this.requireOptionValue(current, nextValue)));
|
|
188
|
+
index += 1;
|
|
189
|
+
break;
|
|
190
|
+
default: throw new Error(`未知参数:${current}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (options.documentScopeIds.length === 0) throw new Error("revoke 至少需要一个 --document scope。");
|
|
194
|
+
return options;
|
|
195
|
+
};
|
|
196
|
+
assignDocumentGrant = (documentGrantMap, rawGrant) => {
|
|
197
|
+
const delimiterIndex = rawGrant.indexOf("=");
|
|
198
|
+
if (delimiterIndex < 1) throw new Error("--document 必须使用 scopeId=/absolute/or/relative/path 格式。");
|
|
199
|
+
const scopeId = rawGrant.slice(0, delimiterIndex).trim();
|
|
200
|
+
const directoryPath = rawGrant.slice(delimiterIndex + 1).trim();
|
|
201
|
+
if (!scopeId || !directoryPath) throw new Error("--document 缺少 scopeId 或 path。");
|
|
202
|
+
documentGrantMap[scopeId] = directoryPath;
|
|
203
|
+
};
|
|
204
|
+
readDocumentScopeId = (scopeId) => {
|
|
205
|
+
const normalized = scopeId.trim();
|
|
206
|
+
if (!normalized || normalized.includes("=")) throw new Error("--document 必须使用 scopeId 格式。");
|
|
207
|
+
return normalized;
|
|
208
|
+
};
|
|
209
|
+
requireOptionValue = (flag, nextValue) => {
|
|
210
|
+
if (!nextValue || nextValue.startsWith("--")) throw new Error(`${flag} 缺少值。`);
|
|
211
|
+
return nextValue;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
//#endregion
|
|
215
|
+
export { AppRuntimeOptionsService };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AppScaffoldService } from "../scaffold/app-scaffold.service.js";
|
|
2
|
+
|
|
3
|
+
//#region src/commands/create.controller.d.ts
|
|
4
|
+
declare class CreateCommand {
|
|
5
|
+
private readonly scaffoldService;
|
|
6
|
+
constructor(scaffoldService?: AppScaffoldService);
|
|
7
|
+
run: (params: {
|
|
8
|
+
appDirectory: string;
|
|
9
|
+
json: boolean;
|
|
10
|
+
write: (text: string) => void;
|
|
11
|
+
}) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { CreateCommand };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AppScaffoldService } from "../scaffold/app-scaffold.service.js";
|
|
2
|
+
//#region src/commands/create.controller.ts
|
|
3
|
+
var CreateCommand = class {
|
|
4
|
+
constructor(scaffoldService = new AppScaffoldService()) {
|
|
5
|
+
this.scaffoldService = scaffoldService;
|
|
6
|
+
}
|
|
7
|
+
run = async (params) => {
|
|
8
|
+
const { appDirectory, json, write } = params;
|
|
9
|
+
const result = await this.scaffoldService.scaffold(appDirectory);
|
|
10
|
+
if (json) {
|
|
11
|
+
write(`${JSON.stringify({
|
|
12
|
+
ok: true,
|
|
13
|
+
created: result
|
|
14
|
+
}, null, 2)}\n`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
write(`Created app scaffold at ${result.appDirectory}\n`);
|
|
18
|
+
write(`Manifest: ${result.manifestPath}\n`);
|
|
19
|
+
write("Next: napp inspect <app-dir> && napp run <app-dir>\n");
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { CreateCommand };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AppDocumentGrantMap } from "../permissions/app-permissions.types.js";
|
|
2
|
+
import { AppGrantService } from "../permissions/app-grant.service.js";
|
|
3
|
+
|
|
4
|
+
//#region src/commands/grant.controller.d.ts
|
|
5
|
+
declare class GrantCommand {
|
|
6
|
+
private readonly grantService;
|
|
7
|
+
constructor(grantService?: AppGrantService);
|
|
8
|
+
run: (params: {
|
|
9
|
+
appId: string;
|
|
10
|
+
documentGrantMap: AppDocumentGrantMap;
|
|
11
|
+
json: boolean;
|
|
12
|
+
write: (text: string) => void;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { GrantCommand };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AppGrantService } from "../permissions/app-grant.service.js";
|
|
2
|
+
//#region src/commands/grant.controller.ts
|
|
3
|
+
var GrantCommand = class {
|
|
4
|
+
constructor(grantService = new AppGrantService()) {
|
|
5
|
+
this.grantService = grantService;
|
|
6
|
+
}
|
|
7
|
+
run = async (params) => {
|
|
8
|
+
const { appId, documentGrantMap, json, write } = params;
|
|
9
|
+
const results = await Promise.all(Object.entries(documentGrantMap).map(([scopeId, directoryPath]) => this.grantService.grantDocumentScope({
|
|
10
|
+
appId,
|
|
11
|
+
scopeId,
|
|
12
|
+
directoryPath
|
|
13
|
+
})));
|
|
14
|
+
if (json) {
|
|
15
|
+
write(`${JSON.stringify({
|
|
16
|
+
ok: true,
|
|
17
|
+
grants: results
|
|
18
|
+
}, null, 2)}\n`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
for (const result of results) write(`Granted ${result.scopeId} -> ${result.grantedPath}\n`);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { GrantCommand };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AppInstallationService } from "../install/app-installation.service.js";
|
|
2
|
+
|
|
3
|
+
//#region src/commands/info.controller.d.ts
|
|
4
|
+
declare class InfoCommand {
|
|
5
|
+
private readonly installationService;
|
|
6
|
+
constructor(installationService?: AppInstallationService);
|
|
7
|
+
run: (params: {
|
|
8
|
+
appId: string;
|
|
9
|
+
json: boolean;
|
|
10
|
+
write: (text: string) => void;
|
|
11
|
+
}) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { InfoCommand };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AppInstallationService } from "../install/app-installation.service.js";
|
|
2
|
+
//#region src/commands/info.controller.ts
|
|
3
|
+
var InfoCommand = class {
|
|
4
|
+
constructor(installationService = new AppInstallationService()) {
|
|
5
|
+
this.installationService = installationService;
|
|
6
|
+
}
|
|
7
|
+
run = async (params) => {
|
|
8
|
+
const { appId, json, write } = params;
|
|
9
|
+
const result = await this.installationService.info(appId);
|
|
10
|
+
if (json) {
|
|
11
|
+
write(`${JSON.stringify({
|
|
12
|
+
ok: true,
|
|
13
|
+
app: result
|
|
14
|
+
}, null, 2)}\n`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
write(`App: ${result.name} (${result.appId})\n`);
|
|
18
|
+
write(`Active version: ${result.activeVersion}\n`);
|
|
19
|
+
write(`Data: ${result.dataDirectory}\n`);
|
|
20
|
+
write(`Installed versions: ${result.installedVersions.map((item) => item.version).join(", ")}\n`);
|
|
21
|
+
const activeVersion = result.installedVersions.find((item) => item.version === result.activeVersion);
|
|
22
|
+
if (activeVersion?.registryUrl) write(`Registry: ${activeVersion.registryUrl}\n`);
|
|
23
|
+
if (activeVersion?.publisher) write(`Publisher: ${activeVersion.publisher.name} (${activeVersion.publisher.id})\n`);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { InfoCommand };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AppInstallationService } from "../install/app-installation.service.js";
|
|
2
|
+
|
|
3
|
+
//#region src/commands/install.controller.d.ts
|
|
4
|
+
declare class InstallCommand {
|
|
5
|
+
private readonly installationService;
|
|
6
|
+
constructor(installationService?: AppInstallationService);
|
|
7
|
+
run: (params: {
|
|
8
|
+
appSource: string;
|
|
9
|
+
registryUrl?: string;
|
|
10
|
+
json: boolean;
|
|
11
|
+
write: (text: string) => void;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { InstallCommand };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AppInstallationService } from "../install/app-installation.service.js";
|
|
2
|
+
//#region src/commands/install.controller.ts
|
|
3
|
+
var InstallCommand = class {
|
|
4
|
+
constructor(installationService = new AppInstallationService()) {
|
|
5
|
+
this.installationService = installationService;
|
|
6
|
+
}
|
|
7
|
+
run = async (params) => {
|
|
8
|
+
const { appSource, registryUrl, json, write } = params;
|
|
9
|
+
const result = await this.installationService.install(appSource, { registryUrl });
|
|
10
|
+
if (json) {
|
|
11
|
+
write(`${JSON.stringify({
|
|
12
|
+
ok: true,
|
|
13
|
+
installation: result
|
|
14
|
+
}, null, 2)}\n`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
write(`Installed ${result.name} (${result.appId}) ${result.version}\n`);
|
|
18
|
+
write(`Code: ${result.installDirectory}\n`);
|
|
19
|
+
write(`Data: ${result.dataDirectory}\n`);
|
|
20
|
+
if (result.registryUrl) write(`Registry: ${result.registryUrl}\n`);
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { InstallCommand };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AppInstallationService } from "../install/app-installation.service.js";
|
|
2
|
+
|
|
3
|
+
//#region src/commands/list.controller.d.ts
|
|
4
|
+
declare class ListCommand {
|
|
5
|
+
private readonly installationService;
|
|
6
|
+
constructor(installationService?: AppInstallationService);
|
|
7
|
+
run: (params: {
|
|
8
|
+
json: boolean;
|
|
9
|
+
write: (text: string) => void;
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ListCommand };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AppInstallationService } from "../install/app-installation.service.js";
|
|
2
|
+
//#region src/commands/list.controller.ts
|
|
3
|
+
var ListCommand = class {
|
|
4
|
+
constructor(installationService = new AppInstallationService()) {
|
|
5
|
+
this.installationService = installationService;
|
|
6
|
+
}
|
|
7
|
+
run = async (params) => {
|
|
8
|
+
const { json, write } = params;
|
|
9
|
+
const result = await this.installationService.list();
|
|
10
|
+
if (json) {
|
|
11
|
+
write(`${JSON.stringify({
|
|
12
|
+
ok: true,
|
|
13
|
+
apps: result
|
|
14
|
+
}, null, 2)}\n`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (result.length === 0) {
|
|
18
|
+
write("No installed apps.\n");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
for (const appItem of result) write(`${appItem.appId} ${appItem.activeVersion} ${appItem.sourceKind} ${appItem.name}\n`);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ListCommand };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AppBundleService } from "../bundle/app-bundle.service.js";
|
|
2
|
+
|
|
3
|
+
//#region src/commands/pack.controller.d.ts
|
|
4
|
+
declare class PackCommand {
|
|
5
|
+
private readonly bundleService;
|
|
6
|
+
constructor(bundleService?: AppBundleService);
|
|
7
|
+
run: (params: {
|
|
8
|
+
appDirectory: string;
|
|
9
|
+
outputPath?: string;
|
|
10
|
+
json: boolean;
|
|
11
|
+
write: (text: string) => void;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { PackCommand };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AppBundleService } from "../bundle/app-bundle.service.js";
|
|
2
|
+
//#region src/commands/pack.controller.ts
|
|
3
|
+
var PackCommand = class {
|
|
4
|
+
constructor(bundleService = new AppBundleService()) {
|
|
5
|
+
this.bundleService = bundleService;
|
|
6
|
+
}
|
|
7
|
+
run = async (params) => {
|
|
8
|
+
const { appDirectory, outputPath, json, write } = params;
|
|
9
|
+
const result = await this.bundleService.packAppDirectory({
|
|
10
|
+
appDirectory,
|
|
11
|
+
outputPath
|
|
12
|
+
});
|
|
13
|
+
if (json) {
|
|
14
|
+
write(`${JSON.stringify({
|
|
15
|
+
ok: true,
|
|
16
|
+
bundle: result
|
|
17
|
+
}, null, 2)}\n`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
write(`Packed ${result.metadata.name} ${result.metadata.version}\n`);
|
|
21
|
+
write(`Bundle: ${result.bundlePath}\n`);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { PackCommand };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AppGrantService } from "../permissions/app-grant.service.js";
|
|
2
|
+
|
|
3
|
+
//#region src/commands/permissions.controller.d.ts
|
|
4
|
+
declare class PermissionsCommand {
|
|
5
|
+
private readonly grantService;
|
|
6
|
+
constructor(grantService?: AppGrantService);
|
|
7
|
+
run: (params: {
|
|
8
|
+
appId: string;
|
|
9
|
+
json: boolean;
|
|
10
|
+
write: (text: string) => void;
|
|
11
|
+
}) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { PermissionsCommand };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AppGrantService } from "../permissions/app-grant.service.js";
|
|
2
|
+
//#region src/commands/permissions.controller.ts
|
|
3
|
+
var PermissionsCommand = class {
|
|
4
|
+
constructor(grantService = new AppGrantService()) {
|
|
5
|
+
this.grantService = grantService;
|
|
6
|
+
}
|
|
7
|
+
run = async (params) => {
|
|
8
|
+
const { appId, json, write } = params;
|
|
9
|
+
const result = await this.grantService.summarize(appId);
|
|
10
|
+
if (json) {
|
|
11
|
+
write(`${JSON.stringify({
|
|
12
|
+
ok: true,
|
|
13
|
+
permissions: result
|
|
14
|
+
}, null, 2)}\n`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
write(`Permissions: ${result.name} (${result.appId}) ${result.activeVersion}\n`);
|
|
18
|
+
if (result.documentAccess.length === 0) write("Document access: none\n");
|
|
19
|
+
else for (const scope of result.documentAccess) write(`Document ${scope.id} ${scope.mode} ${scope.granted ? scope.grantedPath : "[missing]"}\n`);
|
|
20
|
+
write(`Allowed domains: ${result.allowedDomains.length > 0 ? result.allowedDomains.join(", ") : "none"}\n`);
|
|
21
|
+
write(`Storage: ${result.storage.enabled ? result.storage.namespace ?? "enabled" : "disabled"}\n`);
|
|
22
|
+
write(`Host bridge: ${result.capabilities.hostBridge ? "enabled" : "disabled"}\n`);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { PermissionsCommand };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AppRegistryConfigService } from "../registry/app-registry-config.service.js";
|
|
2
|
+
|
|
3
|
+
//#region src/commands/registry.controller.d.ts
|
|
4
|
+
declare class RegistryCommand {
|
|
5
|
+
private readonly configService;
|
|
6
|
+
constructor(configService?: AppRegistryConfigService);
|
|
7
|
+
run: (params: {
|
|
8
|
+
action: "get" | "set" | "reset";
|
|
9
|
+
registryUrl?: string;
|
|
10
|
+
json: boolean;
|
|
11
|
+
write: (text: string) => void;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
private requireRegistryUrl;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { RegistryCommand };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AppRegistryConfigService } from "../registry/app-registry-config.service.js";
|
|
2
|
+
//#region src/commands/registry.controller.ts
|
|
3
|
+
var RegistryCommand = class {
|
|
4
|
+
constructor(configService = new AppRegistryConfigService()) {
|
|
5
|
+
this.configService = configService;
|
|
6
|
+
}
|
|
7
|
+
run = async (params) => {
|
|
8
|
+
const { action, registryUrl, json, write } = params;
|
|
9
|
+
const snapshot = action === "set" ? await this.configService.setRegistryUrl(this.requireRegistryUrl(registryUrl)) : action === "reset" ? await this.configService.resetRegistryUrl() : await this.configService.getSnapshot();
|
|
10
|
+
if (json) {
|
|
11
|
+
write(`${JSON.stringify({
|
|
12
|
+
ok: true,
|
|
13
|
+
registry: snapshot
|
|
14
|
+
}, null, 2)}\n`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
write(`Registry: ${snapshot.currentUrl}\n`);
|
|
18
|
+
write(`Source: ${snapshot.source}\n`);
|
|
19
|
+
write(`Default: ${snapshot.defaultUrl}\n`);
|
|
20
|
+
};
|
|
21
|
+
requireRegistryUrl = (registryUrl) => {
|
|
22
|
+
if (!registryUrl) throw new Error("registry set 缺少 URL。");
|
|
23
|
+
return registryUrl;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { RegistryCommand };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AppGrantService } from "../permissions/app-grant.service.js";
|
|
2
|
+
|
|
3
|
+
//#region src/commands/revoke.controller.d.ts
|
|
4
|
+
declare class RevokeCommand {
|
|
5
|
+
private readonly grantService;
|
|
6
|
+
constructor(grantService?: AppGrantService);
|
|
7
|
+
run: (params: {
|
|
8
|
+
appId: string;
|
|
9
|
+
documentScopeIds: string[];
|
|
10
|
+
json: boolean;
|
|
11
|
+
write: (text: string) => void;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { RevokeCommand };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AppGrantService } from "../permissions/app-grant.service.js";
|
|
2
|
+
//#region src/commands/revoke.controller.ts
|
|
3
|
+
var RevokeCommand = class {
|
|
4
|
+
constructor(grantService = new AppGrantService()) {
|
|
5
|
+
this.grantService = grantService;
|
|
6
|
+
}
|
|
7
|
+
run = async (params) => {
|
|
8
|
+
const { appId, documentScopeIds, json, write } = params;
|
|
9
|
+
const results = await Promise.all(documentScopeIds.map((scopeId) => this.grantService.revokeDocumentScope({
|
|
10
|
+
appId,
|
|
11
|
+
scopeId
|
|
12
|
+
})));
|
|
13
|
+
if (json) {
|
|
14
|
+
write(`${JSON.stringify({
|
|
15
|
+
ok: true,
|
|
16
|
+
revocations: results
|
|
17
|
+
}, null, 2)}\n`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
for (const result of results) write(`Revoked ${result.scopeId}: ${result.removed ? "yes" : "no"}\n`);
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { RevokeCommand };
|