sparkecoder 0.1.100 → 0.1.102
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/dist/cli.js +207 -43
- package/dist/cli.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/package.json +16 -15
- package/web/.next/BUILD_ID +1 -1
- package/web/.next/standalone/web/.next/BUILD_ID +1 -1
- package/web/.next/standalone/web/.next/build-manifest.json +2 -2
- package/web/.next/standalone/web/.next/prerender-manifest.json +3 -3
- package/web/.next/standalone/web/.next/server/app/_global-error.html +2 -2
- package/web/.next/standalone/web/.next/server/app/_global-error.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.html +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/agents.html +1 -1
- package/web/.next/standalone/web/.next/server/app/agents.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/agents.segments/!KG1haW4p/agents/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/agents.segments/!KG1haW4p/agents.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/agents.segments/!KG1haW4p.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/agents.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/agents.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/agents.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/agents.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs/installation.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs/skills.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs/tools.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.html +1 -1
- package/web/.next/standalone/web/.next/server/app/index.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/settings.html +1 -1
- package/web/.next/standalone/web/.next/server/app/settings.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/settings.segments/!KG1haW4p/settings/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/settings.segments/!KG1haW4p/settings.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/settings.segments/!KG1haW4p.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/settings.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/settings.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/pages/404.html +1 -1
- package/web/.next/standalone/web/.next/server/pages/500.html +2 -2
- package/web/.next/standalone/web/.next/server/server-reference-manifest.js +1 -1
- package/web/.next/standalone/web/.next/server/server-reference-manifest.json +1 -1
- /package/web/.next/standalone/web/.next/static/{eyxBRyMA8Zq36Pfen3Ylj → static/wV0cf4IbCdyxPIPIWZqMD}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{eyxBRyMA8Zq36Pfen3Ylj → static/wV0cf4IbCdyxPIPIWZqMD}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/{eyxBRyMA8Zq36Pfen3Ylj → static/wV0cf4IbCdyxPIPIWZqMD}/_ssgManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{static/eyxBRyMA8Zq36Pfen3Ylj → wV0cf4IbCdyxPIPIWZqMD}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{static/eyxBRyMA8Zq36Pfen3Ylj → wV0cf4IbCdyxPIPIWZqMD}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/{static/eyxBRyMA8Zq36Pfen3Ylj → wV0cf4IbCdyxPIPIWZqMD}/_ssgManifest.js +0 -0
- /package/web/.next/static/{eyxBRyMA8Zq36Pfen3Ylj → wV0cf4IbCdyxPIPIWZqMD}/_buildManifest.js +0 -0
- /package/web/.next/static/{eyxBRyMA8Zq36Pfen3Ylj → wV0cf4IbCdyxPIPIWZqMD}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{eyxBRyMA8Zq36Pfen3Ylj → wV0cf4IbCdyxPIPIWZqMD}/_ssgManifest.js +0 -0
package/dist/cli.js
CHANGED
|
@@ -16828,53 +16828,217 @@ program.command("slack-setup").description("Interactively configure Slack integr
|
|
|
16828
16828
|
process.exit(1);
|
|
16829
16829
|
}
|
|
16830
16830
|
});
|
|
16831
|
-
program.command("cloudflared-setup").description("
|
|
16831
|
+
program.command("cloudflared-setup").description("Auto-detect cloudflared + set up a tunnel to this sparkecoder (interactive)").option("--port <port>", "Local sparkecoder web UI port", "6969").option("--api-port <port>", "Local sparkecoder API port", "3141").option("--hostname <host>", "Public hostname you want to assign (e.g. sf-mac-1.example.com)").option("--tunnel-name <name>", "Tunnel name to reuse or create", "sparkecoder").option("--team <team>", "Your Cloudflare Access team subdomain (e.g. studyfetch -> studyfetch.cloudflareaccess.com)").option("--allowed-emails <emails>", "Comma-separated allow-listed emails").option("-y, --yes", "Skip confirmations and do everything non-interactively", false).option("--print-only", "Skip auto-setup and just print the copy/paste recipe", false).action(async (options) => {
|
|
16832
|
+
const { execSync: execSync2, spawnSync } = await import("child_process");
|
|
16833
|
+
const { homedir: homedir2 } = await import("os");
|
|
16834
|
+
const { copyFileSync } = await import("fs");
|
|
16832
16835
|
const port = options.port || "6969";
|
|
16833
16836
|
const apiPort = options.apiPort || "3141";
|
|
16834
|
-
const
|
|
16837
|
+
const tunnelName = options.tunnelName || "sparkecoder";
|
|
16835
16838
|
const team = options.team || "<your-team>";
|
|
16836
16839
|
const emails = (options.allowedEmails || "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
|
|
16841
|
-
|
|
16842
|
-
|
|
16843
|
-
|
|
16844
|
-
|
|
16845
|
-
`));
|
|
16846
|
-
|
|
16847
|
-
|
|
16848
|
-
|
|
16849
|
-
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
|
|
16853
|
-
|
|
16854
|
-
|
|
16855
|
-
|
|
16856
|
-
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
|
|
16862
|
-
|
|
16863
|
-
|
|
16864
|
-
|
|
16865
|
-
|
|
16866
|
-
|
|
16867
|
-
|
|
16868
|
-
|
|
16869
|
-
|
|
16870
|
-
|
|
16871
|
-
|
|
16872
|
-
|
|
16873
|
-
|
|
16874
|
-
|
|
16875
|
-
|
|
16876
|
-
|
|
16877
|
-
|
|
16840
|
+
const yes = !!options.yes;
|
|
16841
|
+
if (options.printOnly) {
|
|
16842
|
+
const hostname = options.hostname || "<your-public-hostname>";
|
|
16843
|
+
console.log(chalk.bold("Cloudflared + Cloudflare Access setup (manual)\n"));
|
|
16844
|
+
console.log(chalk.dim("1. brew install cloudflared"));
|
|
16845
|
+
console.log(chalk.dim("2. cloudflared tunnel login"));
|
|
16846
|
+
console.log(chalk.dim(`3. cloudflared tunnel create ${tunnelName}`));
|
|
16847
|
+
console.log(chalk.dim(`4. cloudflared tunnel route dns ${tunnelName} ${hostname}`));
|
|
16848
|
+
console.log(chalk.dim(`5. write ~/.cloudflared/config.yml pointing ${hostname} -> http://localhost:${port}, api-${hostname} -> http://localhost:${apiPort}`));
|
|
16849
|
+
console.log(chalk.dim(`6. cloudflared tunnel run ${tunnelName}`));
|
|
16850
|
+
console.log(chalk.dim("7. Cloudflare Zero Trust -> add a self-hosted Access app on the hostname"));
|
|
16851
|
+
console.log(chalk.dim("8. Paste the AUD into sparkecoder.config.json under auth.cfAccess"));
|
|
16852
|
+
return;
|
|
16853
|
+
}
|
|
16854
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
16855
|
+
const ask = (q, def) => new Promise((res) => {
|
|
16856
|
+
const prompt = def ? `${q} ${chalk.dim(`[${def}]`)} ` : `${q} `;
|
|
16857
|
+
rl.question(prompt, (a) => res((a || "").trim() || def || ""));
|
|
16858
|
+
});
|
|
16859
|
+
const confirm = async (q, def = true) => {
|
|
16860
|
+
if (yes) return true;
|
|
16861
|
+
const a = (await ask(`${q} ${chalk.dim(def ? "(Y/n)" : "(y/N)")}`)).toLowerCase();
|
|
16862
|
+
if (!a) return def;
|
|
16863
|
+
return a.startsWith("y");
|
|
16864
|
+
};
|
|
16865
|
+
const which = (bin) => {
|
|
16866
|
+
try {
|
|
16867
|
+
return execSync2(`command -v ${bin}`, { stdio: ["ignore", "pipe", "ignore"] }).toString().trim() || null;
|
|
16868
|
+
} catch {
|
|
16869
|
+
return null;
|
|
16870
|
+
}
|
|
16871
|
+
};
|
|
16872
|
+
const run = (cmd, args, opts = {}) => {
|
|
16873
|
+
const r = spawnSync(cmd, args, { stdio: opts.inheritIO ? "inherit" : ["ignore", "pipe", "pipe"], encoding: "utf8" });
|
|
16874
|
+
if (opts.check && r.status !== 0) {
|
|
16875
|
+
throw new Error(`${cmd} ${args.join(" ")} failed (${r.status}): ${r.stderr || r.stdout}`);
|
|
16876
|
+
}
|
|
16877
|
+
return r;
|
|
16878
|
+
};
|
|
16879
|
+
try {
|
|
16880
|
+
console.log(chalk.bold("Cloudflared auto-setup\n"));
|
|
16881
|
+
let cfPath = which("cloudflared");
|
|
16882
|
+
if (!cfPath) {
|
|
16883
|
+
console.log(chalk.yellow("cloudflared is not installed."));
|
|
16884
|
+
if (process.platform === "darwin" && which("brew")) {
|
|
16885
|
+
if (await confirm("Install it now via `brew install cloudflared`?", true)) {
|
|
16886
|
+
run("brew", ["install", "cloudflared"], { inheritIO: true, check: true });
|
|
16887
|
+
cfPath = which("cloudflared");
|
|
16888
|
+
}
|
|
16889
|
+
}
|
|
16890
|
+
if (!cfPath) {
|
|
16891
|
+
console.log(chalk.red("Install cloudflared from https://github.com/cloudflare/cloudflared/releases and re-run."));
|
|
16892
|
+
rl.close();
|
|
16893
|
+
return;
|
|
16894
|
+
}
|
|
16895
|
+
}
|
|
16896
|
+
const verOut = run("cloudflared", ["--version"]).stdout?.toString().split("\n")[0] || "installed";
|
|
16897
|
+
console.log(chalk.green("\u2713"), "cloudflared:", chalk.dim(verOut));
|
|
16898
|
+
const cfDir = join16(homedir2(), ".cloudflared");
|
|
16899
|
+
const certPath = join16(cfDir, "cert.pem");
|
|
16900
|
+
if (!existsSync21(certPath)) {
|
|
16901
|
+
console.log(chalk.yellow("No Cloudflare login cert found."));
|
|
16902
|
+
if (await confirm("Run `cloudflared tunnel login` now (opens a browser)?", true)) {
|
|
16903
|
+
run("cloudflared", ["tunnel", "login"], { inheritIO: true, check: true });
|
|
16904
|
+
} else {
|
|
16905
|
+
console.log(chalk.red("Login required to continue."));
|
|
16906
|
+
rl.close();
|
|
16907
|
+
return;
|
|
16908
|
+
}
|
|
16909
|
+
} else {
|
|
16910
|
+
console.log(chalk.green("\u2713"), "logged in:", chalk.dim(certPath));
|
|
16911
|
+
}
|
|
16912
|
+
let tunnels = [];
|
|
16913
|
+
try {
|
|
16914
|
+
const out = run("cloudflared", ["tunnel", "list", "--output", "json"]).stdout || "[]";
|
|
16915
|
+
tunnels = JSON.parse(out);
|
|
16916
|
+
} catch {
|
|
16917
|
+
}
|
|
16918
|
+
let tunnel = tunnels.find((t) => t.name === tunnelName);
|
|
16919
|
+
if (tunnel) {
|
|
16920
|
+
console.log(chalk.green("\u2713"), `reusing existing tunnel "${tunnelName}":`, chalk.dim(tunnel.id));
|
|
16921
|
+
} else {
|
|
16922
|
+
if (!await confirm(`No tunnel named "${tunnelName}" found. Create it?`, true)) {
|
|
16923
|
+
rl.close();
|
|
16924
|
+
return;
|
|
16925
|
+
}
|
|
16926
|
+
const r = run("cloudflared", ["tunnel", "create", tunnelName], { inheritIO: true });
|
|
16927
|
+
if (r.status !== 0) {
|
|
16928
|
+
console.log(chalk.red("Tunnel create failed."));
|
|
16929
|
+
rl.close();
|
|
16930
|
+
return;
|
|
16931
|
+
}
|
|
16932
|
+
try {
|
|
16933
|
+
const out = run("cloudflared", ["tunnel", "list", "--output", "json"]).stdout || "[]";
|
|
16934
|
+
tunnels = JSON.parse(out);
|
|
16935
|
+
tunnel = tunnels.find((t) => t.name === tunnelName);
|
|
16936
|
+
} catch {
|
|
16937
|
+
}
|
|
16938
|
+
if (!tunnel) {
|
|
16939
|
+
console.log(chalk.red("Could not locate freshly-created tunnel. Check `cloudflared tunnel list`."));
|
|
16940
|
+
rl.close();
|
|
16941
|
+
return;
|
|
16942
|
+
}
|
|
16943
|
+
}
|
|
16944
|
+
const credsFile = tunnel.credentials_file || join16(cfDir, `${tunnel.id}.json`);
|
|
16945
|
+
if (!existsSync21(credsFile)) {
|
|
16946
|
+
console.log(chalk.yellow(`Credentials file not found at ${credsFile}. The tunnel may still work via cert.pem.`));
|
|
16947
|
+
}
|
|
16948
|
+
let hostname = options.hostname;
|
|
16949
|
+
if (!hostname) {
|
|
16950
|
+
hostname = await ask("Public hostname for this sparkecoder (e.g. sf-mac-1.example.com):");
|
|
16951
|
+
}
|
|
16952
|
+
if (!hostname) {
|
|
16953
|
+
console.log(chalk.red("A hostname is required to route DNS."));
|
|
16954
|
+
rl.close();
|
|
16955
|
+
return;
|
|
16956
|
+
}
|
|
16957
|
+
const dnsR = run("cloudflared", ["tunnel", "route", "dns", tunnelName, hostname]);
|
|
16958
|
+
if (dnsR.status === 0) {
|
|
16959
|
+
console.log(chalk.green("\u2713"), `DNS routed: ${hostname} -> ${tunnelName}`);
|
|
16960
|
+
} else {
|
|
16961
|
+
const err = (dnsR.stderr || dnsR.stdout || "").toString();
|
|
16962
|
+
if (/already exists|with the same/i.test(err)) {
|
|
16963
|
+
console.log(chalk.green("\u2713"), `DNS already routed for ${hostname}`);
|
|
16964
|
+
} else {
|
|
16965
|
+
console.log(chalk.yellow("DNS route warning:"), err.trim().split("\n").slice(-2).join(" "));
|
|
16966
|
+
}
|
|
16967
|
+
}
|
|
16968
|
+
const configPath = join16(cfDir, "config.yml");
|
|
16969
|
+
const configBody = `tunnel: ${tunnel.id}
|
|
16970
|
+
credentials-file: ${credsFile}
|
|
16971
|
+
ingress:
|
|
16972
|
+
- hostname: ${hostname}
|
|
16973
|
+
service: http://localhost:${port}
|
|
16974
|
+
- hostname: api-${hostname}
|
|
16975
|
+
service: http://localhost:${apiPort}
|
|
16976
|
+
- service: http_status:404
|
|
16977
|
+
`;
|
|
16978
|
+
let wroteConfig = false;
|
|
16979
|
+
if (existsSync21(configPath)) {
|
|
16980
|
+
const existing = readFileSync10(configPath, "utf8");
|
|
16981
|
+
if (existing.trim() === configBody.trim()) {
|
|
16982
|
+
console.log(chalk.green("\u2713"), `config.yml already up to date: ${configPath}`);
|
|
16983
|
+
wroteConfig = true;
|
|
16984
|
+
} else if (await confirm(`A different ${configPath} exists. Overwrite (a backup will be saved)?`, false)) {
|
|
16985
|
+
copyFileSync(configPath, `${configPath}.bak.${Date.now()}`);
|
|
16986
|
+
writeFileSync6(configPath, configBody);
|
|
16987
|
+
console.log(chalk.green("\u2713"), `wrote ${configPath} (previous saved as .bak.*)`);
|
|
16988
|
+
wroteConfig = true;
|
|
16989
|
+
} else {
|
|
16990
|
+
console.log(chalk.dim("Skipping config write. Suggested contents:"));
|
|
16991
|
+
console.log(chalk.cyan(configBody));
|
|
16992
|
+
}
|
|
16993
|
+
} else {
|
|
16994
|
+
writeFileSync6(configPath, configBody);
|
|
16995
|
+
console.log(chalk.green("\u2713"), `wrote ${configPath}`);
|
|
16996
|
+
wroteConfig = true;
|
|
16997
|
+
}
|
|
16998
|
+
let alreadyRunning = false;
|
|
16999
|
+
try {
|
|
17000
|
+
const psOut = execSync2("ps -axo command", { stdio: ["ignore", "pipe", "ignore"] }).toString();
|
|
17001
|
+
alreadyRunning = /cloudflared.*tunnel.*run/.test(psOut);
|
|
17002
|
+
} catch {
|
|
17003
|
+
}
|
|
17004
|
+
if (alreadyRunning) {
|
|
17005
|
+
console.log(chalk.green("\u2713"), "cloudflared tunnel process detected \u2014 you may need to restart it to pick up config changes.");
|
|
17006
|
+
} else if (wroteConfig) {
|
|
17007
|
+
if (await confirm("Install cloudflared as a background service (`sudo cloudflared service install`)?", false)) {
|
|
17008
|
+
run("sudo", ["cloudflared", "service", "install"], { inheritIO: true });
|
|
17009
|
+
} else {
|
|
17010
|
+
console.log(chalk.dim("Start it manually with:"), chalk.cyan(`cloudflared tunnel run ${tunnelName}`));
|
|
17011
|
+
}
|
|
17012
|
+
}
|
|
17013
|
+
console.log("");
|
|
17014
|
+
console.log(chalk.bold("Cloudflare Access (one manual step)"));
|
|
17015
|
+
console.log(chalk.dim(` 1. Open https://one.dash.cloudflare.com -> Access -> Applications -> Add an application.`));
|
|
17016
|
+
console.log(chalk.dim(` 2. Self-hosted, application domain = ${hostname} (and api-${hostname} if you also want the API protected).`));
|
|
17017
|
+
console.log(
|
|
17018
|
+
chalk.dim(' 3. Add an "Allow" policy with emails:'),
|
|
17019
|
+
chalk.cyan(emails.length ? emails.join(", ") : "you@example.com")
|
|
17020
|
+
);
|
|
17021
|
+
console.log(chalk.dim(" 4. Copy the application AUD tag from the dashboard."));
|
|
17022
|
+
console.log(chalk.dim(` 5. Paste it into sparkecoder.config.json:`));
|
|
17023
|
+
console.log(chalk.cyan(` {
|
|
17024
|
+
"auth": {
|
|
17025
|
+
"cfAccess": {
|
|
17026
|
+
"enabled": true,
|
|
17027
|
+
"teamDomain": "${team}.cloudflareaccess.com",
|
|
17028
|
+
"audTag": "<paste-aud-from-cf-dashboard>"
|
|
17029
|
+
},
|
|
17030
|
+
"allowedEmails": [${emails.length ? emails.map((e) => `"${e}"`).join(", ") : '"you@example.com"'}]
|
|
17031
|
+
}
|
|
17032
|
+
}`));
|
|
17033
|
+
console.log(chalk.dim(" (/api/slack/events, /api/inbox/* and /health are exempt from CF Access automatically.)"));
|
|
17034
|
+
console.log("");
|
|
17035
|
+
console.log(chalk.green("Done."), `Your sparkecoder should now be reachable at`, chalk.cyan(`https://${hostname}`));
|
|
17036
|
+
} catch (err) {
|
|
17037
|
+
console.error(chalk.red("Setup failed:"), err?.message || err);
|
|
17038
|
+
process.exitCode = 1;
|
|
17039
|
+
} finally {
|
|
17040
|
+
rl.close();
|
|
17041
|
+
}
|
|
16878
17042
|
});
|
|
16879
17043
|
program.command("sessions").description("List all sessions").option("-l, --limit <limit>", "Number of sessions to show", "20").option("-p, --port <port>", "Server port", "3141").option("-H, --host <host>", "Server host", "127.0.0.1").action(async (options) => {
|
|
16880
17044
|
const baseUrl = `http://${options.host}:${options.port}`;
|