@jamiexiongr/panda 0.1.6 → 0.1.8

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +109 -70
  2. package/package.json +3 -3
package/dist/cli.mjs CHANGED
@@ -1,9 +1,108 @@
1
+ // packages/provider-codex/src/tailscale.ts
2
+ import { execFileSync } from "child_process";
3
+ var ENABLED_ARGS = /* @__PURE__ */ new Set([
4
+ "tailscareserv",
5
+ "--tailscareserv",
6
+ "tailscale-serve",
7
+ "--tailscale-serve"
8
+ ]);
9
+ var PUBLIC_ARGS = /* @__PURE__ */ new Set([
10
+ "tailscareserv-pub",
11
+ "--tailscareserv-pub",
12
+ "tailscale-serve-pub",
13
+ "--tailscale-serve-pub",
14
+ "tailscalefunnel",
15
+ "--tailscalefunnel",
16
+ "tailscale-funnel",
17
+ "--tailscale-funnel"
18
+ ]);
19
+ var DISABLED_ARGS = /* @__PURE__ */ new Set([
20
+ "no-tailscareserv",
21
+ "--no-tailscareserv",
22
+ "no-tailscale-serve",
23
+ "--no-tailscale-serve",
24
+ "no-tailscareserv-pub",
25
+ "--no-tailscareserv-pub",
26
+ "no-tailscale-serve-pub",
27
+ "--no-tailscale-serve-pub",
28
+ "no-tailscalefunnel",
29
+ "--no-tailscalefunnel",
30
+ "no-tailscale-funnel",
31
+ "--no-tailscale-funnel"
32
+ ]);
33
+ var trimToNull = (value) => {
34
+ const normalized = value?.trim() ?? "";
35
+ return normalized ? normalized : null;
36
+ };
37
+ var parseBooleanLike = (value) => {
38
+ const normalized = trimToNull(value)?.toLowerCase();
39
+ if (!normalized) {
40
+ return null;
41
+ }
42
+ if (["1", "true", "yes", "on"].includes(normalized)) {
43
+ return true;
44
+ }
45
+ if (["0", "false", "no", "off"].includes(normalized)) {
46
+ return false;
47
+ }
48
+ return null;
49
+ };
50
+ var parsePublicationModeLike = (value) => {
51
+ const normalized = trimToNull(value)?.toLowerCase();
52
+ if (!normalized) {
53
+ return null;
54
+ }
55
+ if (["serve", "private", "tailnet"].includes(normalized)) {
56
+ return "serve";
57
+ }
58
+ if (["funnel", "public", "pub"].includes(normalized)) {
59
+ return "funnel";
60
+ }
61
+ if (["disabled", "none", "off"].includes(normalized)) {
62
+ return "disabled";
63
+ }
64
+ return null;
65
+ };
66
+ var resolveTailscalePublicationMode = (options) => {
67
+ const argv = options?.argv ?? [];
68
+ for (const candidate of argv) {
69
+ const normalized = candidate.trim().toLowerCase();
70
+ if (PUBLIC_ARGS.has(normalized)) {
71
+ return "funnel";
72
+ }
73
+ if (ENABLED_ARGS.has(normalized)) {
74
+ return "serve";
75
+ }
76
+ if (DISABLED_ARGS.has(normalized)) {
77
+ return "disabled";
78
+ }
79
+ }
80
+ const env = options?.env ?? process.env;
81
+ const scopedMode = options?.envPrefix ? parsePublicationModeLike(env[`${options.envPrefix}_TAILSCALE_PUBLISH_MODE`]) : null;
82
+ if (scopedMode) {
83
+ return scopedMode;
84
+ }
85
+ const genericMode = parsePublicationModeLike(env.PANDA_TAILSCALE_PUBLISH_MODE);
86
+ if (genericMode) {
87
+ return genericMode;
88
+ }
89
+ const scopedEnabled = options?.envPrefix ? parseBooleanLike(env[`${options.envPrefix}_TAILSCALE_SERVE`]) : null;
90
+ if (scopedEnabled !== null) {
91
+ return scopedEnabled ? "serve" : "disabled";
92
+ }
93
+ const envEnabled = parseBooleanLike(env.PANDA_TAILSCALE_SERVE);
94
+ if (envEnabled !== null) {
95
+ return envEnabled ? "serve" : "disabled";
96
+ }
97
+ return "disabled";
98
+ };
99
+
1
100
  // release/panda/src/cli.ts
2
101
  var printUsage = () => {
3
102
  console.log(`panda <command>
4
103
 
5
104
  Commands:
6
- agent [tailscareserv] [--hub-url=<url>] Start the Panda agent service
105
+ agent [tailscareserv|tailscareserv-pub] [--hub-url=<url>] Start the Panda agent service
7
106
  hub [tailscareserv|tailscareserv-pub] Start the Panda hub service with the bundled web UI
8
107
  help Show this message`);
9
108
  };
@@ -22,77 +121,17 @@ var resolveCliOptionValue = (argv, aliases) => {
22
121
  }
23
122
  return null;
24
123
  };
25
- var resolveTailscaleServeArg = (argv) => {
26
- for (const arg of argv) {
27
- const normalized = arg.trim().toLowerCase();
28
- if (["tailscareserv", "--tailscareserv", "tailscale-serve", "--tailscale-serve"].includes(
29
- normalized
30
- )) {
31
- return true;
32
- }
33
- if (["no-tailscareserv", "--no-tailscareserv", "no-tailscale-serve", "--no-tailscale-serve"].includes(normalized)) {
34
- return false;
35
- }
36
- }
37
- const envValue = process.env.PANDA_TAILSCALE_SERVE?.trim().toLowerCase();
38
- if (envValue && ["1", "true", "yes", "on"].includes(envValue)) {
39
- return true;
40
- }
41
- if (envValue && ["0", "false", "no", "off"].includes(envValue)) {
42
- return false;
43
- }
44
- return false;
45
- };
46
- var resolveHubPublicationMode = (argv) => {
47
- for (const arg of argv) {
48
- const normalized = arg.trim().toLowerCase();
49
- if ([
50
- "tailscareserv-pub",
51
- "--tailscareserv-pub",
52
- "tailscale-serve-pub",
53
- "--tailscale-serve-pub",
54
- "tailscalefunnel",
55
- "--tailscalefunnel",
56
- "tailscale-funnel",
57
- "--tailscale-funnel"
58
- ].includes(normalized)) {
59
- return "funnel";
60
- }
61
- if (["tailscareserv", "--tailscareserv", "tailscale-serve", "--tailscale-serve"].includes(
62
- normalized
63
- )) {
64
- return "serve";
65
- }
66
- if ([
67
- "no-tailscareserv",
68
- "--no-tailscareserv",
69
- "no-tailscale-serve",
70
- "--no-tailscale-serve",
71
- "no-tailscareserv-pub",
72
- "--no-tailscareserv-pub",
73
- "no-tailscale-funnel",
74
- "--no-tailscale-funnel"
75
- ].includes(normalized)) {
76
- return "disabled";
77
- }
78
- }
79
- const envMode = process.env.PANDA_HUB_TAILSCALE_PUBLISH_MODE?.trim().toLowerCase();
80
- if (envMode && ["funnel", "public", "pub"].includes(envMode)) {
81
- return "funnel";
82
- }
83
- if (envMode && ["serve", "private", "tailnet"].includes(envMode)) {
84
- return "serve";
85
- }
86
- if (envMode && ["disabled", "none", "off"].includes(envMode)) {
87
- return "disabled";
88
- }
89
- return resolveTailscaleServeArg(argv) ? "serve" : "disabled";
90
- };
91
124
  var main = async () => {
92
125
  const command = process.argv[2]?.trim().toLowerCase() ?? "help";
93
126
  const commandArgs = process.argv.slice(3);
94
- const tailscaleServe = resolveTailscaleServeArg(commandArgs);
95
- const hubPublicationMode = resolveHubPublicationMode(commandArgs);
127
+ const agentPublicationMode = resolveTailscalePublicationMode({
128
+ argv: commandArgs,
129
+ envPrefix: "PANDA_AGENT"
130
+ });
131
+ const hubPublicationMode = resolveTailscalePublicationMode({
132
+ argv: commandArgs,
133
+ envPrefix: "PANDA_HUB"
134
+ });
96
135
  if (command === "help" || command === "--help" || command === "-h") {
97
136
  printUsage();
98
137
  return;
@@ -100,7 +139,7 @@ var main = async () => {
100
139
  if (command === "agent") {
101
140
  const { startJamiexiongrAgent } = await import("@jamiexiongr/panda-agent");
102
141
  await startJamiexiongrAgent({
103
- tailscaleServe,
142
+ tailscalePublicationMode: agentPublicationMode,
104
143
  hubUrl: resolveCliOptionValue(commandArgs, [
105
144
  "hub",
106
145
  "--hub",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamiexiongr/panda",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Panda combined installer",
@@ -8,8 +8,8 @@
8
8
  "panda": "./bin/panda.cjs"
9
9
  },
10
10
  "dependencies": {
11
- "@jamiexiongr/panda-agent": "0.1.6",
12
- "@jamiexiongr/panda-hub": "0.1.6"
11
+ "@jamiexiongr/panda-agent": "0.1.8",
12
+ "@jamiexiongr/panda-hub": "0.1.8"
13
13
  },
14
14
  "files": [
15
15
  "bin",