@dhzh/foundry 1.0.0-beta.2 → 1.0.0-beta.3

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.d.mts CHANGED
@@ -1,6 +1,2 @@
1
1
 
2
- //#region src/cli/index.d.ts
3
- declare const foundryCommand: import("citty").CommandDef<import("citty").ArgsDef>;
4
- declare function runCli(rawArgs?: string[]): Promise<void>;
5
- //#endregion
6
- export { foundryCommand, runCli };
2
+ export {}
package/dist/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{t as e}from"./package-BksDGVza.mjs";import{defineCommand as t,renderUsage as n,runMain as r}from"citty";import i from"node:process";import{pathToFileURL as a}from"node:url";import o from"open";import{serve as s}from"@hono/node-server";import{serveStatic as c}from"@hono/node-server/serve-static";import{zValidator as l}from"@hono/zod-validator";import{existsSync as u}from"node:fs";import d from"node:path";import{Hono as f}from"hono";import{z as p}from"zod";const m={success:`SUCCESS`},h=p.strictObject({});function g(){return[d.resolve(import.meta.dirname,`app`),d.resolve(import.meta.dirname,`../../dist/app`)].find(e=>u(e))}function _(e={}){let t=new f;t.get(`/api/health`,l(`query`,h),e=>e.json({status:m.success,data:!0,message:`Service is healthy.`}));let n=e.webRoot??g();return n&&t.use(`*`,c({root:n})),t}const v=`127.0.0.1`;function y(e){return new Promise((t,n)=>{e.close(e=>{if(e){n(e);return}t()})})}async function b(e={}){let t=e.port??54321;return new Promise((e,n)=>{let r=e=>{n(e)},i=s({fetch:_().fetch,hostname:v,port:t},t=>{i.off(`error`,r);let n,a=t.port;e({close:()=>(n??=y(i),n),hostname:v,port:a,url:`http://${v}:${a}`})});i.once(`error`,r)})}function x(e,t){return e instanceof Error&&`code`in e&&e.code===`EADDRINUSE`?`Port ${t} is already in use on 127.0.0.1.`:`Could not start Foundry Server: ${e instanceof Error?e.message:String(e)}`}function S(e,t=i,n=console.error){let r=!1,a=()=>{r||(r=!0,t.off(`SIGINT`,a),t.off(`SIGTERM`,a),e.close().catch(e=>{n(`Could not stop Foundry Server: ${e instanceof Error?e.message:String(e)}`),t.exitCode=1}))};return t.once(`SIGINT`,a),t.once(`SIGTERM`,a),()=>{t.off(`SIGINT`,a),t.off(`SIGTERM`,a)}}const C={error:console.error,log:console.info,openBrowser:o,registerShutdown:e=>{S(e)},setExitCode:e=>{i.exitCode=e},startServer:b};function w(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n===`--port`){if(t+1>=e.length||e[t+1].startsWith(`--`))return`Missing value for option: --port`;t+=1;continue}if(!n.startsWith(`--port=`)&&n!==`--open`&&n!==`--no-open`)return`${n.startsWith(`-`)?`Unknown option`:`Unexpected argument`}: ${n}`}}function T(e){let t=Number(e);if(!Number.isSafeInteger(t)||t<1||t>65535)throw RangeError(`Port must be an integer between 1 and 65535. Received "${e}".`);return t}function E(e=C){return t({meta:{description:`Start the Local Web UI`,name:`ui`},args:{port:{default:`54321`,description:`Port for the Local Web UI`,type:`string`,valueHint:`port`},open:{default:!0,description:`Open the Local Web UI in the default browser`,negativeDescription:`Do not open the default browser`,type:`boolean`}},async run({args:t,rawArgs:n}){let r=w(n);if(r){e.error(`${r}\nRun \`foundry ui --help\` for usage.`),e.setExitCode(1);return}let i;try{i=T(t.port)}catch(t){e.error(`${t instanceof Error?t.message:String(t)}\nRun \`foundry ui --help\` for usage.`),e.setExitCode(1);return}let a;try{a=await e.startServer({port:i})}catch(t){e.error(x(t,i)),e.setExitCode(1);return}if(e.registerShutdown(a),e.log(`Foundry Local Web UI: ${a.url}`),t.open)try{await e.openBrowser(a.url)}catch{e.error(`Could not open the default browser. Open ${a.url} manually.`)}}})}const D=t({meta:{description:`An AI-native local developer runtime`,name:`foundry`,version:e},subCommands:{ui:E()}});function O(e){if(!e.some(e=>e===`--help`||e===`-h`)&&(e.length!==1||e[0]!==`--version`&&e[0]!==`-v`)&&!(e[0]===`ui`||!e[0]?.startsWith(`-`)))return`Unknown option: ${e[0]}`}async function k(e=i.argv.slice(2)){if(e.length===0){console.info(`${await n(D)}\n`);return}let t=O(e);if(t){console.error(`${t}\nRun \`foundry --help\` for usage.`),i.exitCode=1;return}await r(D,{rawArgs:e})}i.argv[1]&&a(i.argv[1]).href===import.meta.url&&k();export{D as foundryCommand,k as runCli};
2
+ import{t as e}from"./package-DjeQlIOf.mjs";import{defineCommand as t,renderUsage as n,runMain as r}from"citty";import i from"node:process";import a from"open";import{serve as o}from"@hono/node-server";import{serveStatic as s}from"@hono/node-server/serve-static";import{zValidator as c}from"@hono/zod-validator";import{existsSync as l}from"node:fs";import u from"node:path";import{Hono as d}from"hono";import{z as f}from"zod";const p={success:`SUCCESS`},m=f.strictObject({});function h(){return[u.resolve(import.meta.dirname,`app`),u.resolve(import.meta.dirname,`../../dist/app`)].find(e=>l(e))}function g(e={}){let t=new d;t.get(`/api/health`,c(`query`,m),e=>e.json({status:p.success,data:!0,message:`Service is healthy.`}));let n=e.webRoot??h();return n&&t.use(`*`,s({root:n})),t}const _=`127.0.0.1`;function v(e){return new Promise((t,n)=>{e.close(e=>{if(e){n(e);return}t()})})}async function y(e={}){let t=e.port??54321;return new Promise((e,n)=>{let r=e=>{n(e)},i=o({fetch:g().fetch,hostname:_,port:t},t=>{i.off(`error`,r);let n,a=t.port;e({close:()=>(n??=v(i),n),hostname:_,port:a,url:`http://${_}:${a}`})});i.once(`error`,r)})}function b(e,t){return e instanceof Error&&`code`in e&&e.code===`EADDRINUSE`?`Port ${t} is already in use on 127.0.0.1.`:`Could not start Foundry Server: ${e instanceof Error?e.message:String(e)}`}function x(e,t=i,n=console.error){let r=!1,a=()=>{r||(r=!0,t.off(`SIGINT`,a),t.off(`SIGTERM`,a),e.close().catch(e=>{n(`Could not stop Foundry Server: ${e instanceof Error?e.message:String(e)}`),t.exitCode=1}))};return t.once(`SIGINT`,a),t.once(`SIGTERM`,a),()=>{t.off(`SIGINT`,a),t.off(`SIGTERM`,a)}}const S={error:console.error,log:console.info,openBrowser:a,registerShutdown:e=>{x(e)},setExitCode:e=>{i.exitCode=e},startServer:y};function C(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n===`--port`){if(t+1>=e.length||e[t+1].startsWith(`--`))return`Missing value for option: --port`;t+=1;continue}if(!n.startsWith(`--port=`)&&n!==`--open`&&n!==`--no-open`)return`${n.startsWith(`-`)?`Unknown option`:`Unexpected argument`}: ${n}`}}function w(e){let t=Number(e);if(!Number.isSafeInteger(t)||t<1||t>65535)throw RangeError(`Port must be an integer between 1 and 65535. Received "${e}".`);return t}function T(e=S){return t({meta:{description:`Start the Local Web UI`,name:`ui`},args:{port:{default:`54321`,description:`Port for the Local Web UI`,type:`string`,valueHint:`port`},open:{default:!0,description:`Open the Local Web UI in the default browser`,negativeDescription:`Do not open the default browser`,type:`boolean`}},async run({args:t,rawArgs:n}){let r=C(n);if(r){e.error(`${r}\nRun \`foundry ui --help\` for usage.`),e.setExitCode(1);return}let i;try{i=w(t.port)}catch(t){e.error(`${t instanceof Error?t.message:String(t)}\nRun \`foundry ui --help\` for usage.`),e.setExitCode(1);return}let a;try{a=await e.startServer({port:i})}catch(t){e.error(b(t,i)),e.setExitCode(1);return}if(e.registerShutdown(a),e.log(`Foundry Local Web UI: ${a.url}`),t.open)try{await e.openBrowser(a.url)}catch{e.error(`Could not open the default browser. Open ${a.url} manually.`)}}})}const E=t({meta:{description:`An AI-native local developer runtime`,name:`foundry`,version:e},subCommands:{ui:T()}});function D(e){if(!e.some(e=>e===`--help`||e===`-h`)&&(e.length!==1||e[0]!==`--version`&&e[0]!==`-v`)&&!(e[0]===`ui`||!e[0]?.startsWith(`-`)))return`Unknown option: ${e[0]}`}async function O(e=i.argv.slice(2)){if(e.length===0){console.info(`${await n(E)}\n`);return}let t=D(e);if(t){console.error(`${t}\nRun \`foundry --help\` for usage.`),i.exitCode=1;return}await r(E,{rawArgs:e})}O();export{};
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
 
2
- import{t as e}from"./package-BksDGVza.mjs";function t(){return e}export{t as getVersion};
2
+ import{t as e}from"./package-DjeQlIOf.mjs";function t(){return e}export{t as getVersion};
@@ -0,0 +1,2 @@
1
+
2
+ var e=`1.0.0-beta.3`;export{e as t};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dhzh/foundry",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.2",
4
+ "version": "1.0.0-beta.3",
5
5
  "devEngines": {
6
6
  "packageManager": {
7
7
  "name": "pnpm",
@@ -1,2 +0,0 @@
1
-
2
- var e=`1.0.0-beta.2`;export{e as t};