rari 0.10.11 → 0.10.12
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.mjs +37 -37
- package/package.json +6 -6
package/dist/cli.mjs
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{getBinaryPath as e,getInstallationInstructions as t}from"./platform.mjs";import{existsSync as n,readFileSync as r}from"node:fs";import{resolve as
|
|
3
|
-
`)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.match(
|
|
2
|
+
import{getBinaryPath as e,getInstallationInstructions as t}from"./platform.mjs";import{existsSync as n,readFileSync as r,realpathSync as i}from"node:fs";import{resolve as a}from"node:path";import o from"node:process";import{spawn as s}from"node:child_process";import{fileURLToPath as c}from"node:url";import{styleText as l}from"node:util";function u(e){console.warn(`${l(`blue`,`info`)} ${e}`)}function d(e){console.warn(`${l(`green`,`✓`)} ${e}`)}function f(e){console.error(`${l(`red`,`✗`)} ${e}`)}function p(e){console.warn(`${l(`yellow`,`⚠`)} ${e}`)}const m=/^([^=]+)=(.*)$/;function h(){let e=a(o.cwd(),`.env`);if(n(e)){let t=r(e,`utf-8`);for(let e of t.split(`
|
|
3
|
+
`)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.match(m);if(n){let[,e,t]=n,r=e.trim(),i=t.trim();(i.startsWith(`"`)&&i.endsWith(`"`)||i.startsWith(`'`)&&i.endsWith(`'`))&&(i=i.slice(1,-1)),o.env[r]||(o.env[r]=i)}}}}h();const[,,g,..._]=o.argv;function v(){let e=o.cwd(),t=a(`/`),i=0;for(;e!==t&&i<20;){if(i++,n(a(e,`pnpm-lock.yaml`)))return`pnpm`;if(n(a(e,`yarn.lock`)))return`yarn`;if(n(a(e,`bun.lockb`)))return`bun`;if(n(a(e,`package-lock.json`)))return`npm`;try{let t=a(e,`package.json`);if(n(t)){let e=JSON.parse(r(t,`utf-8`));if(e.packageManager?.startsWith(`pnpm`))return`pnpm`;if(e.packageManager?.startsWith(`yarn`))return`yarn`;if(e.packageManager?.startsWith(`bun`))return`bun`;if(e.packageManager?.startsWith(`npm`))return`npm`}}catch{}let t=a(e,`..`);if(t===e)break;e=t}return`npm`}function y(){let e=v(),t=o.platform===`win32`;switch(e){case`bun`:return t?`bun.cmd`:`bun`;case`pnpm`:return t?`pnpm.cmd`:`pnpm`;case`yarn`:return t?`yarn.cmd`:`yarn`;default:return t?`npx.cmd`:`npx`}}function b(e,t,n={}){let r=o.platform===`win32`;if(e===`npx`){let e=y();if(e.includes(`bun`))return s(r?`bunx.cmd`:`bunx`,t,{...n,shell:r});if(e.includes(`pnpm`))return s(e,[`exec`,...t],{...n,shell:r});if(e.includes(`yarn`))return s(e,[`dlx`,...t],{...n,shell:r})}return r&&e===`npx`?s(`npx.cmd`,t,{...n,shell:!0}):s(e,t,n)}function x(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function S(){return!!(o.env.RAILWAY_ENVIRONMENT||o.env.RAILWAY_PROJECT_ID||o.env.RAILWAY_SERVICE_ID)}function C(){return!!(o.env.RENDER||o.env.RENDER_SERVICE_ID||o.env.RENDER_SERVICE_NAME)}function w(){return S()||C()}function T(){return S()?`Railway`:C()?`Render`:`local`}function E(){return{port:o.env.PORT||o.env.RSC_PORT||`3000`,mode:o.env.NODE_ENV||`production`,host:w()?`0.0.0.0`:`127.0.0.1`}}async function D(){let{existsSync:e,rmSync:t}=await import(`node:fs`),{resolve:n}=await import(`node:path`),r=n(o.cwd(),`dist`);e(r)&&(u(`Cleaning dist folder...`),t(r,{recursive:!0,force:!0})),u(`Type checking...`);let i=b(`npx`,[`tsgo`],{stdio:`inherit`,cwd:o.cwd()});await new Promise((e,t)=>{i.on(`exit`,n=>{n===0?(d(`Type check passed`),e()):(f(`Type check failed with code ${n}`),t(Error(`Type check failed with code ${n}`)))}),i.on(`error`,t)}),u(`Building for production...`);let a=b(`npx`,[`vite`,`build`],{stdio:`inherit`,cwd:o.cwd()});await new Promise((e,t)=>{a.on(`exit`,n=>{n===0?(d(`Build complete`),e()):(f(`Build failed with code ${n}`),t(Error(`Build failed with code ${n}`)))}),a.on(`error`,t)}),await O()}async function O(){if(n(a(o.cwd(),`dist`,`server`,`image.json`))&&n(a(o.cwd(),`public`)))try{let t=s(e(),[`optimize-images`],{stdio:`inherit`,cwd:o.cwd(),shell:!1});await new Promise(e=>{t.on(`exit`,t=>{t===0||p(`Image pre-optimization exited with code ${t}`),e()}),t.on(`error`,t=>{p(`Image pre-optimization error: ${x(t)}`),e()})})}catch(e){p(`Could not pre-optimize images: ${x(e)}`)}}async function k(){let{existsSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`);if(!e(t(o.cwd(),`dist`))){u(`First run detected - building project...`);let e=b(`npx`,[`vite`,`build`,`--mode`,`development`],{stdio:`inherit`,cwd:o.cwd()});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(d(`Initial build complete`),t()):(f(`Build failed with code ${e}`),n(Error(`Build failed with code ${e}`)))}),e.on(`error`,n)})}u(`Starting Vite dev server...`);let n=b(`npx`,[`vite`],{stdio:`inherit`,cwd:o.cwd()}),r=()=>{u(`Shutting down dev server...`),n.kill(`SIGTERM`)};return o.on(`SIGINT`,r),o.on(`SIGTERM`,r),n.on(`error`,e=>{f(`Failed to start Vite: ${e.message}`),o.exit(1)}),n.on(`exit`,e=>{e!==0&&e!==null&&(f(`Vite exited with code ${e}`),o.exit(e))}),new Promise(()=>{})}async function A(){let n;try{n=e()}catch{f(`Failed to obtain rari binary`),f(t()),o.exit(1)}let{port:r,mode:i,host:a}=E();if(w()){let e=T();u(`${e} environment detected`),u(`Starting rari server for ${e} deployment...`),u(`Mode: ${i}, Host: ${a}, Port: ${r}`),u(`using binary: ${n}`)}let c=s(n,[`--mode`,i,`--port`,r,`--host`,a],{stdio:`inherit`,cwd:o.cwd(),env:{...o.env,RUST_LOG:o.env.RUST_LOG||`error`}}),l=()=>{u(`shutting down...`),c.kill(`SIGTERM`)};return o.on(`SIGINT`,l),o.on(`SIGTERM`,l),c.on(`error`,e=>{f(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&f(`Binary not found. Please ensure rari is properly installed.`),o.exit(1)}),c.on(`exit`,(e,t)=>{t?u(`server stopped by signal ${t}`):e===0?d(`server stopped successfully`):(f(`server exited with code ${e}`),o.exit(e||1))}),new Promise(()=>{})}async function j(){u(`Setting up Railway deployment...`),w()&&(f(`Already running in ${T()} environment. Use "rari start" instead.`),o.exit(1));let{createRailwayDeployment:e}=await import(`./railway-UP19UVM3.mjs`);await e()}async function M(){u(`Setting up Render deployment...`),w()&&(f(`Already running in ${T()} environment. Use "rari start" instead.`),o.exit(1));let{createRenderDeployment:e}=await import(`./render-CL95kAwR.mjs`);await e()}async function N(){switch(g){case void 0:case`help`:case`--help`:case`-h`:console.warn(`${l(`bold`,`rari CLI`)}
|
|
4
4
|
|
|
5
|
-
${
|
|
6
|
-
${
|
|
7
|
-
${
|
|
8
|
-
${
|
|
9
|
-
${
|
|
10
|
-
${
|
|
11
|
-
${
|
|
5
|
+
${l(`bold`,`Usage:`)}
|
|
6
|
+
${l(`cyan`,`rari dev`)} Start the development server with Vite
|
|
7
|
+
${l(`cyan`,`rari build`)} Build for production
|
|
8
|
+
${l(`cyan`,`rari start`)} Start the rari server (defaults to production)
|
|
9
|
+
${l(`cyan`,`rari deploy railway`)} Setup Railway deployment
|
|
10
|
+
${l(`cyan`,`rari deploy render`)} Setup Render deployment
|
|
11
|
+
${l(`cyan`,`rari help`)} Show this help message
|
|
12
12
|
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${
|
|
16
|
-
${
|
|
17
|
-
${
|
|
13
|
+
${l(`bold`,`Environment Variables:`)}
|
|
14
|
+
${l(`yellow`,`PORT`)} Server port (default: 3000)
|
|
15
|
+
${l(`yellow`,`RSC_PORT`)} Alternative server port
|
|
16
|
+
${l(`yellow`,`NODE_ENV`)} Environment (default: production for start, development for dev)
|
|
17
|
+
${l(`yellow`,`RUST_LOG`)} Rust logging level (default: info)
|
|
18
18
|
|
|
19
|
-
${
|
|
20
|
-
${
|
|
21
|
-
${
|
|
19
|
+
${l(`bold`,`Examples:`)}
|
|
20
|
+
${l(`gray`,`# Start development server with Vite`)}
|
|
21
|
+
${l(`cyan`,`rari dev`)}
|
|
22
22
|
|
|
23
|
-
${
|
|
24
|
-
${
|
|
23
|
+
${l(`gray`,`# Build for production`)}
|
|
24
|
+
${l(`cyan`,`rari build`)}
|
|
25
25
|
|
|
26
|
-
${
|
|
27
|
-
${
|
|
26
|
+
${l(`gray`,`# Start production server (default)`)}
|
|
27
|
+
${l(`cyan`,`rari start`)}
|
|
28
28
|
|
|
29
|
-
${
|
|
30
|
-
${
|
|
29
|
+
${l(`gray`,`# Start in development mode`)}
|
|
30
|
+
${l(`cyan`,`NODE_ENV=development rari start`)}
|
|
31
31
|
|
|
32
|
-
${
|
|
33
|
-
${
|
|
32
|
+
${l(`gray`,`# Start production server on port 8080`)}
|
|
33
|
+
${l(`cyan`,`PORT=8080 rari start`)}
|
|
34
34
|
|
|
35
|
-
${
|
|
36
|
-
${
|
|
35
|
+
${l(`gray`,`# Setup Railway deployment`)}
|
|
36
|
+
${l(`cyan`,`rari deploy railway`)}
|
|
37
37
|
|
|
38
|
-
${
|
|
39
|
-
${
|
|
38
|
+
${l(`gray`,`# Setup Render deployment`)}
|
|
39
|
+
${l(`cyan`,`rari deploy render`)}
|
|
40
40
|
|
|
41
|
-
${
|
|
42
|
-
${
|
|
41
|
+
${l(`gray`,`# Start with debug logging`)}
|
|
42
|
+
${l(`cyan`,`RUST_LOG=debug rari start`)}
|
|
43
43
|
|
|
44
|
-
${
|
|
45
|
-
${
|
|
46
|
-
${
|
|
44
|
+
${l(`bold`,`Deployment:`)}
|
|
45
|
+
${l(`cyan`,`rari deploy railway`)} Creates Railway deployment files
|
|
46
|
+
${l(`cyan`,`rari deploy render`)} Creates Render deployment files
|
|
47
47
|
|
|
48
48
|
Platform deployment automatically detects the environment and configures:
|
|
49
49
|
- Host binding (0.0.0.0 for platforms, 127.0.0.1 for local)
|
|
50
50
|
- Port from platform's PORT environment variable
|
|
51
51
|
- Production mode optimization
|
|
52
52
|
|
|
53
|
-
${
|
|
53
|
+
${l(`bold`,`Binary Resolution:`)}
|
|
54
54
|
1. Platform-specific package (rari-{platform}-{arch})
|
|
55
55
|
2. Global binary in PATH
|
|
56
56
|
3. Install from source with Cargo
|
|
57
57
|
|
|
58
|
-
${
|
|
58
|
+
${l(`bold`,`Notes:`)}
|
|
59
59
|
- 'rari start' defaults to production mode unless NODE_ENV is set
|
|
60
60
|
- 'rari dev' runs in development mode with Vite hot reload
|
|
61
61
|
- 'rari build' cleans, type checks, and builds for production
|
|
@@ -63,4 +63,4 @@ ${s(`bold`,`Notes:`)}
|
|
|
63
63
|
- Platform deployment is automatically detected and configured
|
|
64
64
|
- Use Ctrl+C to stop the server gracefully
|
|
65
65
|
|
|
66
|
-
`);break;case`dev`:await
|
|
66
|
+
`);break;case`dev`:await k();break;case`build`:await D();break;case`start`:await A();break;case`deploy`:_[0]===`railway`?await j():_[0]===`render`?await M():(f(`Unknown deployment target. Available: railway, render`),o.exit(1));break;default:console.error(`${l(`bold`,`Unknown command:`)} ${g}`),console.warn(`Run "${l(`cyan`,`rari help`)}" for available commands`),o.exit(1)}}const P=o.argv[1]?i(a(o.argv[1])):``,F=i(c(import.meta.url));P&&F===P&&N().catch(e=>{f(`CLI Error: ${x(e)}`),console.error(e),o.exit(1)});export{};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rari",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.12",
|
|
5
5
|
"description": "Runtime Accelerated Rendering Infrastructure (rari)",
|
|
6
6
|
"author": "Ryan Skinner",
|
|
7
7
|
"license": "MIT",
|
|
@@ -106,11 +106,11 @@
|
|
|
106
106
|
"rolldown": "1.0.0-rc.5"
|
|
107
107
|
},
|
|
108
108
|
"optionalDependencies": {
|
|
109
|
-
"rari-darwin-arm64": "0.10.
|
|
110
|
-
"rari-darwin-x64": "0.10.
|
|
111
|
-
"rari-linux-arm64": "0.10.
|
|
112
|
-
"rari-linux-x64": "0.10.
|
|
113
|
-
"rari-win32-x64": "0.10.
|
|
109
|
+
"rari-darwin-arm64": "0.10.12",
|
|
110
|
+
"rari-darwin-x64": "0.10.12",
|
|
111
|
+
"rari-linux-arm64": "0.10.12",
|
|
112
|
+
"rari-linux-x64": "0.10.12",
|
|
113
|
+
"rari-win32-x64": "0.10.12"
|
|
114
114
|
},
|
|
115
115
|
"devDependencies": {
|
|
116
116
|
"@types/node": "^25.3.3",
|