@tomflow/proflow-dev-tunnel 0.1.12 → 0.1.13
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/CHANGELOG.md +6 -0
- package/DOCS.md +33 -7
- package/SETUP.md +27 -4
- package/dist/deployment/adapter.d.ts +60 -14
- package/dist/deployment/adapter.js +50 -3
- package/dist/deployment/descriptor.d.ts +1 -1
- package/dist/deployment/descriptor.js +1 -1
- package/dist/src/cli.js +73 -14
- package/package.json +3 -3
- package/proflow.module.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @tomflow/proflow-dev-tunnel
|
|
2
2
|
|
|
3
|
+
## 0.1.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Upgrade the ProFlow terminal experience, stream Registry and package-manager progress, publish structured Chinese Module documentation, and provide numbered package-owned Setup assistants.
|
|
8
|
+
|
|
3
9
|
## 0.1.12
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/DOCS.md
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
# dev-tunnel
|
|
1
|
+
# dev-tunnel — 开发隧道
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 模块定位与作用
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
使用 Microsoft Dev Tunnels 把本地 Agent Gateway 安全映射为公开 HTTPS 入口,供 Custom GPT Actions 调用。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 主要能力
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- 检查 `devtunnel` CLI 与 Microsoft 登录状态。
|
|
10
|
+
- 列出、选择或创建持久 Tunnel,并管理端口映射和运行进程。
|
|
11
|
+
- 观察公开 HTTPS URL,将其发布为共享事实。
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
## 提供的 API 与 Public Contract
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
- 提供 `public-ingress` Contract,版本 `1.0.0`。
|
|
16
|
+
- 共享当前 Tunnel ID 与公开 Base URL,不暴露账号凭据。
|
|
17
|
+
|
|
18
|
+
## 依赖的 Module、Contract 和外部资源
|
|
19
|
+
|
|
20
|
+
- 依赖 Microsoft `devtunnel` CLI、账号登录、网络和本地 Platform Host 端口。
|
|
21
|
+
- 无上游 Module Contract 依赖。
|
|
22
|
+
|
|
23
|
+
## 运行形态与生命周期
|
|
24
|
+
|
|
25
|
+
类型为 External Resource,拥有可启动和停止的 Tunnel 子进程;持久 Tunnel 本身在卸载时保留。
|
|
26
|
+
|
|
27
|
+
## 使用方式
|
|
28
|
+
|
|
29
|
+
运行 `pnpm exec -- proflow-dev-tunnel setup`,向导会完成登录检查、Tunnel 选择/创建、端口映射和 URL 验证。
|
|
30
|
+
|
|
31
|
+
## 职责边界与限制
|
|
32
|
+
|
|
33
|
+
不拥有 Agent Gateway 业务、不复制 Role Key,也不把临时 Quick Tunnel 当成正式持久入口。
|
|
34
|
+
|
|
35
|
+
## 术语
|
|
36
|
+
|
|
37
|
+
- Tunnel(隧道):把本地端口映射到公网 HTTPS 地址的连接。
|
|
38
|
+
- Public Ingress(公网入口):外部服务访问本地 Gateway 的受控入口。
|
|
39
|
+
- Persistent Tunnel(持久隧道):具有稳定 ID、可重复启动的 Tunnel。
|
package/SETUP.md
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dev-tunnel Setup
|
|
2
2
|
|
|
3
|
-
## STEP-DEV-TUNNEL-01 —
|
|
3
|
+
## STEP-DEV-TUNNEL-01 — 检查 Dev Tunnel CLI 与登录
|
|
4
|
+
Responsible: USER
|
|
5
|
+
Interactive executable: `pnpm exec -- proflow-dev-tunnel setup 01`
|
|
6
|
+
Non-interactive executable: `pnpm exec -- proflow-dev-tunnel setup 01`
|
|
7
|
+
Required inputs: Microsoft 登录
|
|
8
|
+
Verify: `devtunnel user show`
|
|
9
|
+
Success condition: Microsoft 登录状态可被 CLI 观察。
|
|
10
|
+
|
|
11
|
+
## STEP-DEV-TUNNEL-02 — 选择或创建持久 Tunnel
|
|
12
|
+
Responsible: USER
|
|
13
|
+
Interactive executable: `pnpm exec -- proflow-dev-tunnel setup 02`
|
|
14
|
+
Non-interactive executable: `pnpm exec -- proflow-dev-tunnel setup 02 --tunnel-id <id>`
|
|
15
|
+
Required inputs: Tunnel ID
|
|
16
|
+
Verify: `devtunnel show <id>`
|
|
17
|
+
Success condition: 持久 Tunnel 可以被 devtunnel show 观察。
|
|
4
18
|
|
|
19
|
+
## STEP-DEV-TUNNEL-03 — 配置入口并保存公开 URL
|
|
5
20
|
Responsible: USER
|
|
6
|
-
Interactive executable: `pnpm exec -- proflow-dev-tunnel setup`
|
|
7
|
-
Non-interactive executable: `pnpm exec -- proflow-dev-tunnel setup --tunnel-id <id> --public-base-url <url>`
|
|
21
|
+
Interactive executable: `pnpm exec -- proflow-dev-tunnel setup 03`
|
|
22
|
+
Non-interactive executable: `pnpm exec -- proflow-dev-tunnel setup 03 --tunnel-id <id> --public-base-url <url>`
|
|
8
23
|
Required inputs: Tunnel ID、公开 HTTPS URL
|
|
9
24
|
Verify: `pnpm exec -- proflow-dev-tunnel verify`
|
|
25
|
+
Success condition: 公开 HTTPS URL 已保存并可验证。
|
|
26
|
+
|
|
27
|
+
## STEP-DEV-TUNNEL-04 — 验证 Dev Tunnel
|
|
28
|
+
Responsible: AI
|
|
29
|
+
Interactive executable: `pnpm exec -- proflow-dev-tunnel setup 04`
|
|
30
|
+
Non-interactive executable: `pnpm exec -- proflow-dev-tunnel verify`
|
|
31
|
+
Required inputs: none
|
|
32
|
+
Verify: `pnpm exec -- proflow-dev-tunnel verify`
|
|
10
33
|
Success condition: `dev-tunnel.setupStatus=READY`.
|
|
@@ -6,7 +6,7 @@ export declare const behaviorAdapter: {
|
|
|
6
6
|
readonly ok: true;
|
|
7
7
|
readonly status: "SUCCEEDED";
|
|
8
8
|
readonly moduleRef: "dev-tunnel";
|
|
9
|
-
readonly moduleVersion: "0.1.
|
|
9
|
+
readonly moduleVersion: "0.1.13";
|
|
10
10
|
};
|
|
11
11
|
observedEffects: never[];
|
|
12
12
|
}>;
|
|
@@ -16,14 +16,14 @@ export declare const behaviorAdapter: {
|
|
|
16
16
|
readonly ok: true;
|
|
17
17
|
readonly status: "SUCCEEDED";
|
|
18
18
|
readonly moduleRef: "dev-tunnel";
|
|
19
|
-
readonly moduleVersion: "0.1.
|
|
19
|
+
readonly moduleVersion: "0.1.13";
|
|
20
20
|
};
|
|
21
21
|
observedEffects: string[];
|
|
22
22
|
} | {
|
|
23
23
|
result: {
|
|
24
24
|
contract: "deployment.result.v1";
|
|
25
25
|
moduleRef: "dev-tunnel";
|
|
26
|
-
moduleVersion: "0.1.
|
|
26
|
+
moduleVersion: "0.1.13";
|
|
27
27
|
ok: false;
|
|
28
28
|
status: "FAILED";
|
|
29
29
|
error: {
|
|
@@ -40,7 +40,7 @@ export declare const behaviorAdapter: {
|
|
|
40
40
|
ok: true;
|
|
41
41
|
status: "SUCCEEDED";
|
|
42
42
|
moduleRef: "dev-tunnel";
|
|
43
|
-
moduleVersion: "0.1.
|
|
43
|
+
moduleVersion: "0.1.13";
|
|
44
44
|
data: {
|
|
45
45
|
setupStatus: "ACTION_REQUIRED" | "READY";
|
|
46
46
|
runtimeStatus: "FAILED" | "RUNNING" | "STOPPED";
|
|
@@ -52,18 +52,50 @@ export declare const behaviorAdapter: {
|
|
|
52
52
|
result: {
|
|
53
53
|
contract: "deployment.result.v1";
|
|
54
54
|
moduleRef: "dev-tunnel";
|
|
55
|
-
moduleVersion: "0.1.
|
|
55
|
+
moduleVersion: "0.1.13";
|
|
56
56
|
ok: false;
|
|
57
57
|
status: "ACTION_REQUIRED";
|
|
58
58
|
data: {
|
|
59
59
|
readonly steps: readonly [{
|
|
60
60
|
readonly id: "STEP-DEV-TUNNEL-01";
|
|
61
|
+
readonly title: "检查 Dev Tunnel CLI 与登录";
|
|
62
|
+
readonly description: "确认 CLI 可用,必要时启动 Microsoft 登录。";
|
|
63
|
+
readonly state: "TODO";
|
|
64
|
+
readonly responsible: "USER";
|
|
65
|
+
readonly execution: {
|
|
66
|
+
readonly interactive: "pnpm exec -- proflow-dev-tunnel setup 01";
|
|
67
|
+
readonly nonInteractive: "pnpm exec -- proflow-dev-tunnel setup 01";
|
|
68
|
+
};
|
|
69
|
+
readonly requiredInputs: readonly [];
|
|
70
|
+
readonly verify: "devtunnel user show";
|
|
71
|
+
readonly successCondition: "Microsoft 登录状态可被 CLI 观察";
|
|
72
|
+
readonly humanAction: "若浏览器打开 Microsoft 登录页,完成账号登录。";
|
|
73
|
+
}, {
|
|
74
|
+
readonly id: "STEP-DEV-TUNNEL-02";
|
|
61
75
|
readonly title: "选择或创建持久 Tunnel";
|
|
76
|
+
readonly description: "列出现有 Tunnel;不存在时由脚本创建。";
|
|
62
77
|
readonly state: "TODO";
|
|
63
78
|
readonly responsible: "USER";
|
|
64
79
|
readonly execution: {
|
|
65
|
-
readonly interactive: "pnpm exec -- proflow-dev-tunnel setup";
|
|
66
|
-
readonly nonInteractive: "pnpm exec -- proflow-dev-tunnel setup --tunnel-id <id>
|
|
80
|
+
readonly interactive: "pnpm exec -- proflow-dev-tunnel setup 02";
|
|
81
|
+
readonly nonInteractive: "pnpm exec -- proflow-dev-tunnel setup 02 --tunnel-id <id>";
|
|
82
|
+
};
|
|
83
|
+
readonly requiredInputs: readonly [{
|
|
84
|
+
readonly name: "tunnelId";
|
|
85
|
+
readonly description: "Tunnel ID";
|
|
86
|
+
readonly sensitive: false;
|
|
87
|
+
}];
|
|
88
|
+
readonly verify: "devtunnel show <id>";
|
|
89
|
+
readonly successCondition: "持久 Tunnel 可以被 devtunnel show 观察";
|
|
90
|
+
}, {
|
|
91
|
+
readonly id: "STEP-DEV-TUNNEL-03";
|
|
92
|
+
readonly title: "配置入口并保存公开 URL";
|
|
93
|
+
readonly description: "为 Platform Host 建立映射,保存公开 HTTPS URL。";
|
|
94
|
+
readonly state: "TODO";
|
|
95
|
+
readonly responsible: "USER";
|
|
96
|
+
readonly execution: {
|
|
97
|
+
readonly interactive: "pnpm exec -- proflow-dev-tunnel setup 03";
|
|
98
|
+
readonly nonInteractive: "pnpm exec -- proflow-dev-tunnel setup 03 --tunnel-id <id> --public-base-url <url>";
|
|
67
99
|
};
|
|
68
100
|
readonly requiredInputs: readonly [{
|
|
69
101
|
readonly name: "tunnelId";
|
|
@@ -75,7 +107,21 @@ export declare const behaviorAdapter: {
|
|
|
75
107
|
readonly sensitive: false;
|
|
76
108
|
}];
|
|
77
109
|
readonly verify: "pnpm exec -- proflow-dev-tunnel verify";
|
|
78
|
-
readonly successCondition: "
|
|
110
|
+
readonly successCondition: "公开 HTTPS URL 已保存并可验证";
|
|
111
|
+
readonly humanAction: "确认 Dev Tunnel 门户或 CLI 显示的公开 HTTPS URL。";
|
|
112
|
+
}, {
|
|
113
|
+
readonly id: "STEP-DEV-TUNNEL-04";
|
|
114
|
+
readonly title: "验证 Dev Tunnel";
|
|
115
|
+
readonly description: "检查登录、配置和公开入口。";
|
|
116
|
+
readonly state: "TODO";
|
|
117
|
+
readonly responsible: "AI";
|
|
118
|
+
readonly execution: {
|
|
119
|
+
readonly interactive: "pnpm exec -- proflow-dev-tunnel setup 04";
|
|
120
|
+
readonly nonInteractive: "pnpm exec -- proflow-dev-tunnel verify";
|
|
121
|
+
};
|
|
122
|
+
readonly requiredInputs: readonly [];
|
|
123
|
+
readonly verify: "pnpm exec -- proflow-dev-tunnel verify";
|
|
124
|
+
readonly successCondition: "dev-tunnel.setupStatus=READY";
|
|
79
125
|
}];
|
|
80
126
|
};
|
|
81
127
|
actionRequired: {
|
|
@@ -90,7 +136,7 @@ export declare const behaviorAdapter: {
|
|
|
90
136
|
readonly ok: true;
|
|
91
137
|
readonly status: "SUCCEEDED";
|
|
92
138
|
readonly moduleRef: "dev-tunnel";
|
|
93
|
-
readonly moduleVersion: "0.1.
|
|
139
|
+
readonly moduleVersion: "0.1.13";
|
|
94
140
|
};
|
|
95
141
|
observedEffects: never[];
|
|
96
142
|
}>;
|
|
@@ -100,7 +146,7 @@ export declare const behaviorAdapter: {
|
|
|
100
146
|
ok: true;
|
|
101
147
|
status: "SUCCEEDED";
|
|
102
148
|
moduleRef: "dev-tunnel";
|
|
103
|
-
moduleVersion: "0.1.
|
|
149
|
+
moduleVersion: "0.1.13";
|
|
104
150
|
data: {
|
|
105
151
|
docs: string;
|
|
106
152
|
};
|
|
@@ -111,7 +157,7 @@ export declare const behaviorAdapter: {
|
|
|
111
157
|
result: {
|
|
112
158
|
contract: "deployment.result.v1";
|
|
113
159
|
moduleRef: "dev-tunnel";
|
|
114
|
-
moduleVersion: "0.1.
|
|
160
|
+
moduleVersion: "0.1.13";
|
|
115
161
|
ok: false;
|
|
116
162
|
status: "FAILED";
|
|
117
163
|
error: {
|
|
@@ -127,7 +173,7 @@ export declare const behaviorAdapter: {
|
|
|
127
173
|
ok: true;
|
|
128
174
|
status: "SUCCEEDED";
|
|
129
175
|
moduleRef: "dev-tunnel";
|
|
130
|
-
moduleVersion: "0.1.
|
|
176
|
+
moduleVersion: "0.1.13";
|
|
131
177
|
data: import("../src/resource-adapter.ts").DevTunnelObservation;
|
|
132
178
|
};
|
|
133
179
|
observedEffects: string[];
|
|
@@ -138,14 +184,14 @@ export declare const behaviorAdapter: {
|
|
|
138
184
|
readonly ok: true;
|
|
139
185
|
readonly status: "SUCCEEDED";
|
|
140
186
|
readonly moduleRef: "dev-tunnel";
|
|
141
|
-
readonly moduleVersion: "0.1.
|
|
187
|
+
readonly moduleVersion: "0.1.13";
|
|
142
188
|
};
|
|
143
189
|
observedEffects: string[];
|
|
144
190
|
} | {
|
|
145
191
|
result: {
|
|
146
192
|
contract: "deployment.result.v1";
|
|
147
193
|
moduleRef: "dev-tunnel";
|
|
148
|
-
moduleVersion: "0.1.
|
|
194
|
+
moduleVersion: "0.1.13";
|
|
149
195
|
ok: false;
|
|
150
196
|
status: "FAILED";
|
|
151
197
|
error: {
|
|
@@ -15,12 +15,44 @@ const setupPlan = {
|
|
|
15
15
|
steps: [
|
|
16
16
|
{
|
|
17
17
|
id: "STEP-DEV-TUNNEL-01",
|
|
18
|
+
title: "检查 Dev Tunnel CLI 与登录",
|
|
19
|
+
description: "确认 CLI 可用,必要时启动 Microsoft 登录。",
|
|
20
|
+
state: "TODO",
|
|
21
|
+
responsible: "USER",
|
|
22
|
+
execution: {
|
|
23
|
+
interactive: "pnpm exec -- proflow-dev-tunnel setup 01",
|
|
24
|
+
nonInteractive: "pnpm exec -- proflow-dev-tunnel setup 01",
|
|
25
|
+
},
|
|
26
|
+
requiredInputs: [],
|
|
27
|
+
verify: "devtunnel user show",
|
|
28
|
+
successCondition: "Microsoft 登录状态可被 CLI 观察",
|
|
29
|
+
humanAction: "若浏览器打开 Microsoft 登录页,完成账号登录。",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "STEP-DEV-TUNNEL-02",
|
|
18
33
|
title: "选择或创建持久 Tunnel",
|
|
34
|
+
description: "列出现有 Tunnel;不存在时由脚本创建。",
|
|
19
35
|
state: "TODO",
|
|
20
36
|
responsible: "USER",
|
|
21
37
|
execution: {
|
|
22
|
-
interactive: "pnpm exec -- proflow-dev-tunnel setup",
|
|
23
|
-
nonInteractive: "pnpm exec -- proflow-dev-tunnel setup --tunnel-id <id>
|
|
38
|
+
interactive: "pnpm exec -- proflow-dev-tunnel setup 02",
|
|
39
|
+
nonInteractive: "pnpm exec -- proflow-dev-tunnel setup 02 --tunnel-id <id>",
|
|
40
|
+
},
|
|
41
|
+
requiredInputs: [
|
|
42
|
+
{ name: "tunnelId", description: "Tunnel ID", sensitive: false },
|
|
43
|
+
],
|
|
44
|
+
verify: "devtunnel show <id>",
|
|
45
|
+
successCondition: "持久 Tunnel 可以被 devtunnel show 观察",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "STEP-DEV-TUNNEL-03",
|
|
49
|
+
title: "配置入口并保存公开 URL",
|
|
50
|
+
description: "为 Platform Host 建立映射,保存公开 HTTPS URL。",
|
|
51
|
+
state: "TODO",
|
|
52
|
+
responsible: "USER",
|
|
53
|
+
execution: {
|
|
54
|
+
interactive: "pnpm exec -- proflow-dev-tunnel setup 03",
|
|
55
|
+
nonInteractive: "pnpm exec -- proflow-dev-tunnel setup 03 --tunnel-id <id> --public-base-url <url>",
|
|
24
56
|
},
|
|
25
57
|
requiredInputs: [
|
|
26
58
|
{ name: "tunnelId", description: "Tunnel ID", sensitive: false },
|
|
@@ -31,7 +63,22 @@ const setupPlan = {
|
|
|
31
63
|
},
|
|
32
64
|
],
|
|
33
65
|
verify: "pnpm exec -- proflow-dev-tunnel verify",
|
|
34
|
-
successCondition: "
|
|
66
|
+
successCondition: "公开 HTTPS URL 已保存并可验证",
|
|
67
|
+
humanAction: "确认 Dev Tunnel 门户或 CLI 显示的公开 HTTPS URL。",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "STEP-DEV-TUNNEL-04",
|
|
71
|
+
title: "验证 Dev Tunnel",
|
|
72
|
+
description: "检查登录、配置和公开入口。",
|
|
73
|
+
state: "TODO",
|
|
74
|
+
responsible: "AI",
|
|
75
|
+
execution: {
|
|
76
|
+
interactive: "pnpm exec -- proflow-dev-tunnel setup 04",
|
|
77
|
+
nonInteractive: "pnpm exec -- proflow-dev-tunnel verify",
|
|
78
|
+
},
|
|
79
|
+
requiredInputs: [],
|
|
80
|
+
verify: "pnpm exec -- proflow-dev-tunnel verify",
|
|
81
|
+
successCondition: "dev-tunnel.setupStatus=READY",
|
|
35
82
|
},
|
|
36
83
|
],
|
|
37
84
|
};
|
|
@@ -3,7 +3,7 @@ export declare const descriptor: {
|
|
|
3
3
|
readonly contractVersion: "1.0.0";
|
|
4
4
|
readonly moduleRef: "dev-tunnel";
|
|
5
5
|
readonly packageName: "@tomflow/proflow-dev-tunnel";
|
|
6
|
-
readonly moduleVersion: "0.1.
|
|
6
|
+
readonly moduleVersion: "0.1.13";
|
|
7
7
|
readonly kind: "external-resource";
|
|
8
8
|
readonly templateVersion: "1.0.0";
|
|
9
9
|
readonly platformCompatibility: ">=1.0.0 <2.0.0";
|
|
@@ -3,7 +3,7 @@ export const descriptor = {
|
|
|
3
3
|
contractVersion: "1.0.0",
|
|
4
4
|
moduleRef: "dev-tunnel",
|
|
5
5
|
packageName: "@tomflow/proflow-dev-tunnel",
|
|
6
|
-
moduleVersion: "0.1.
|
|
6
|
+
moduleVersion: "0.1.13",
|
|
7
7
|
kind: "external-resource",
|
|
8
8
|
templateVersion: "1.0.0",
|
|
9
9
|
platformCompatibility: ">=1.0.0 <2.0.0",
|
package/dist/src/cli.js
CHANGED
|
@@ -12,6 +12,55 @@ function option(args, name) {
|
|
|
12
12
|
const index = args.indexOf(name);
|
|
13
13
|
return index >= 0 ? args[index + 1] : undefined;
|
|
14
14
|
}
|
|
15
|
+
function ensureCliAndLogin() {
|
|
16
|
+
const version = spawnSync("devtunnel", ["--version"], { stdio: "ignore" });
|
|
17
|
+
if (version.error || version.status !== 0)
|
|
18
|
+
throw new Error("未找到 devtunnel CLI,请先安装 Microsoft Dev Tunnels CLI");
|
|
19
|
+
process.stdout.write("✓ 已找到 devtunnel CLI\n");
|
|
20
|
+
let login = spawnSync("devtunnel", ["user", "show"], { stdio: "ignore" });
|
|
21
|
+
if (login.status !== 0) {
|
|
22
|
+
process.stdout.write("◆ 需要 Microsoft 登录,正在启动登录流程…\n");
|
|
23
|
+
login = spawnSync("devtunnel", ["user", "login"], { stdio: "inherit" });
|
|
24
|
+
if (login.status !== 0)
|
|
25
|
+
throw new Error("Microsoft 登录未完成");
|
|
26
|
+
}
|
|
27
|
+
process.stdout.write("✓ Microsoft 登录已就绪\n");
|
|
28
|
+
}
|
|
29
|
+
async function selectTunnel(args) {
|
|
30
|
+
ensureCliAndLogin();
|
|
31
|
+
let tunnelId = option(args, "--tunnel-id");
|
|
32
|
+
if (!tunnelId && !process.stdin.isTTY)
|
|
33
|
+
throw new Error("非交互环境必须提供 --tunnel-id");
|
|
34
|
+
process.stdout.write("\n现有持久 Tunnel:\n");
|
|
35
|
+
spawnSync("devtunnel", ["list"], { stdio: "inherit" });
|
|
36
|
+
const prompt = createInterface({
|
|
37
|
+
input: process.stdin,
|
|
38
|
+
output: process.stdout,
|
|
39
|
+
});
|
|
40
|
+
try {
|
|
41
|
+
tunnelId ||= await prompt.question("\n◆ 输入要使用的 Tunnel ID\n> ");
|
|
42
|
+
const existing = spawnSync("devtunnel", ["show", tunnelId], {
|
|
43
|
+
stdio: "ignore",
|
|
44
|
+
});
|
|
45
|
+
if (existing.status !== 0) {
|
|
46
|
+
if (process.stdin.isTTY) {
|
|
47
|
+
const answer = await prompt.question(`未找到 ${tunnelId},现在创建?[Y/n] `);
|
|
48
|
+
if (answer.trim() && !/^y(es)?$/i.test(answer.trim()))
|
|
49
|
+
throw new Error("尚未选择持久 Tunnel");
|
|
50
|
+
}
|
|
51
|
+
const created = spawnSync("devtunnel", ["create", tunnelId], {
|
|
52
|
+
stdio: "inherit",
|
|
53
|
+
});
|
|
54
|
+
if (created.status !== 0)
|
|
55
|
+
throw new Error("创建持久 Tunnel 失败");
|
|
56
|
+
}
|
|
57
|
+
process.stdout.write(`✓ 持久 Tunnel 已就绪:${tunnelId}\n`);
|
|
58
|
+
return tunnelId;
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
prompt.close();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
15
64
|
async function inputs(args) {
|
|
16
65
|
let tunnelId = option(args, "--tunnel-id"), publicBaseUrl = option(args, "--public-base-url");
|
|
17
66
|
if ((!tunnelId || !publicBaseUrl) && !process.stdin.isTTY)
|
|
@@ -23,20 +72,8 @@ async function inputs(args) {
|
|
|
23
72
|
});
|
|
24
73
|
try {
|
|
25
74
|
process.stdout.write("\nDev Tunnel 配置\n\n 脚本将检查 CLI、完成 Microsoft 登录,并协助选择或创建持久 Tunnel(隧道)。\n\n");
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
if (version.error || version.status !== 0)
|
|
30
|
-
throw new Error("未找到 devtunnel CLI。请先按 Microsoft Dev Tunnels 文档安装,然后重新运行本命令");
|
|
31
|
-
process.stdout.write("✓ 已找到 devtunnel CLI\n");
|
|
32
|
-
let login = spawnSync("devtunnel", ["user", "show"], { stdio: "ignore" });
|
|
33
|
-
if (login.status !== 0) {
|
|
34
|
-
process.stdout.write("◆ 需要登录 Microsoft 账号,正在启动登录流程…\n");
|
|
35
|
-
login = spawnSync("devtunnel", ["user", "login"], { stdio: "inherit" });
|
|
36
|
-
if (login.status !== 0)
|
|
37
|
-
throw new Error("Microsoft 登录未完成");
|
|
38
|
-
}
|
|
39
|
-
process.stdout.write("✓ Microsoft 登录已就绪\n\n现有持久 Tunnel:\n");
|
|
75
|
+
ensureCliAndLogin();
|
|
76
|
+
process.stdout.write("\n现有持久 Tunnel:\n");
|
|
40
77
|
spawnSync("devtunnel", ["list"], { stdio: "inherit" });
|
|
41
78
|
tunnelId ||= await prompt.question("\n◆ 输入要使用的 Tunnel ID(不存在时可创建)\n> ");
|
|
42
79
|
const existing = spawnSync("devtunnel", ["show", tunnelId], {
|
|
@@ -68,6 +105,28 @@ const args = process.argv.slice(2), command = args[0] ?? "setup", workspaceRoot
|
|
|
68
105
|
if (args.includes("--json"))
|
|
69
106
|
throw new Error("不支持的选项 --json");
|
|
70
107
|
if (command === "setup") {
|
|
108
|
+
const step = args[1]?.startsWith("--") ? undefined : args[1];
|
|
109
|
+
if (step === "01") {
|
|
110
|
+
ensureCliAndLogin();
|
|
111
|
+
process.stdout.write("→ 下一步:setup 02(选择或创建持久 Tunnel)\n");
|
|
112
|
+
process.exit(0);
|
|
113
|
+
}
|
|
114
|
+
if (step === "02") {
|
|
115
|
+
await selectTunnel(args);
|
|
116
|
+
process.stdout.write("→ 下一步:setup 03(配置入口并保存公开 URL)\n");
|
|
117
|
+
process.exit(0);
|
|
118
|
+
}
|
|
119
|
+
if (step === "04") {
|
|
120
|
+
const result = await behaviorAdapter.status({ workspaceRoot });
|
|
121
|
+
process.stdout.write(result.result.data.setupStatus === "READY"
|
|
122
|
+
? "✓ Dev Tunnel 验证通过\n"
|
|
123
|
+
: "✕ Dev Tunnel 尚未就绪\n");
|
|
124
|
+
if (result.result.data.setupStatus !== "READY")
|
|
125
|
+
process.exitCode = 1;
|
|
126
|
+
process.exit();
|
|
127
|
+
}
|
|
128
|
+
if (step !== undefined && step !== "03")
|
|
129
|
+
throw new Error(`UNSUPPORTED_SETUP_STEP:${step}`);
|
|
71
130
|
const result = await behaviorAdapter.setup({
|
|
72
131
|
workspaceRoot,
|
|
73
132
|
input: await inputs(args),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomflow/proflow-dev-tunnel",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"SETUP.md"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@tomflow/proflow-module-contract": "^0.1.
|
|
25
|
+
"@tomflow/proflow-module-contract": "^0.1.11"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@tomflow/proflow-deployment-conformance": "^0.1.
|
|
28
|
+
"@tomflow/proflow-deployment-conformance": "^0.1.9"
|
|
29
29
|
},
|
|
30
30
|
"description": "Governs the Microsoft Dev Tunnel public HTTPS ingress resource and its managed local host process.",
|
|
31
31
|
"keywords": [
|
package/proflow.module.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"contractVersion": "1.0.0",
|
|
4
4
|
"moduleRef": "dev-tunnel",
|
|
5
5
|
"packageName": "@tomflow/proflow-dev-tunnel",
|
|
6
|
-
"moduleVersion": "0.1.
|
|
6
|
+
"moduleVersion": "0.1.13",
|
|
7
7
|
"kind": "external-resource",
|
|
8
8
|
"templateVersion": "1.0.0",
|
|
9
9
|
"platformCompatibility": ">=1.0.0 <2.0.0",
|