@stacksjs/tinker 0.74.34 → 0.74.35

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/index.js +7 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{existsSync as d,readFileSync as y,writeFileSync as c,appendFileSync as f,chmodSync as p}from"fs";import{homedir as k}from"os";import{join as u}from"path";import n from"process";function g(t){let e=[];if(t.stacksPreload!==!1)e.push(`
2
+ var p=import.meta.require;import{existsSync as g,readFileSync as f,writeFileSync as c,appendFileSync as k,chmodSync as d}from"fs";import{homedir as v}from"os";import{join as u}from"path";import n from"process";function m(t){let e=[];if(t.stacksPreload!==!1)e.push(`
3
3
  // ---- Stacks Framework Preload ----
4
4
  // ORM & Database
5
5
  try {
@@ -127,12 +127,12 @@ try {
127
127
  globalThis.dump = (...args) => { console.dir(args.length === 1 ? args[0] : args, { depth: 6, colors: true }) }
128
128
  globalThis.dd = (...args) => { console.dir(args.length === 1 ? args[0] : args, { depth: 6, colors: true }); process.exit(0) }
129
129
  `);if(t.preload?.length)for(let s of t.preload){let o=s.replace(/[@/\-\.]/g,"_").replace(/^_+/,"");e.push(`try { globalThis.${o} = await import('${s}') } catch {}`)}return e.join(`
130
- `)}function h(t){return t?.historyFile??u(k(),".stacks_tinker_history")}function v(t){let e=h(t);if(!d(e))return[];return y(e,"utf-8").split(`
131
- `).filter(Boolean)}function C(t,e){let s=h(e),o=!d(s);if(f(s,`${t}
132
- `),o)try{p(s,384)}catch{}let i=e?.historySize??5000,r=v(e);if(r.length>i){let a=r.slice(r.length-i);c(s,a.join(`
130
+ `)}function h(t){return t?.historyFile??u(v(),".stacks_tinker_history")}function w(t){let e=h(t);if(!g(e))return[];return f(e,"utf-8").split(`
131
+ `).filter(Boolean)}function R(t,e){let s=h(e),o=!g(s);if(k(s,`${t}
132
+ `),o)try{d(s,384)}catch{}let i=e?.historySize??5000,r=w(e);if(r.length>i){let a=r.slice(r.length-i);c(s,a.join(`
133
133
  `)+`
134
- `);try{p(s,384)}catch{}}}function q(t){let e=h(t);c(e,"")}function w(){return["",` \x1B[36mStacks Tinker\x1B[0m (Bun v${typeof Bun<"u"?Bun.version:"unknown"})`," Interactive REPL with Stacks framework preloaded.",""," \x1B[2mAvailable globals: db, config, path, storage, log, Str,"," cache, queue, events, router, auth, collect, env, request,"," validate, Jobs, routes, dump, dd"," + all ORM models (User, Post, etc.)\x1B[0m",""," \x1B[2mType .help for REPL commands. Press Ctrl+D to exit.\x1B[0m",""].join(`
135
- `)}async function m(t={}){let e=t.cwd??n.cwd();if(t.eval||t.print)return T(t,e);if(t.banner!==!1)n.stdout.write(w());let s=g(t),o=u(e,".tinker-preload.ts");c(o,s);let i=["repl"],a=await Bun.spawn(["bun",...i],{cwd:e,stdin:"inherit",stdout:"inherit",stderr:"inherit",env:{...n.env,BUN_PRELOAD:o}}).exited;try{let{unlinkSync:l}=await import("fs");l(o)}catch{}return{exitCode:a}}async function T(t,e){let s=g(t),o=t.print??t.eval??"",i=`${s}
134
+ `);try{d(s,384)}catch{}}}function _(t){let e=h(t);c(e,"")}function T(){return["",` \x1B[36mStacks Tinker\x1B[0m (Bun v${typeof Bun<"u"?Bun.version:"unknown"})`," Interactive REPL with Stacks framework preloaded.",""," \x1B[2mAvailable globals: db, config, path, storage, log, Str,"," cache, queue, events, router, auth, collect, env, request,"," validate, Jobs, routes, dump, dd"," + all ORM models (User, Post, etc.)\x1B[0m",""," \x1B[2mType .help for REPL commands. Press Ctrl+D to exit.\x1B[0m",""].join(`
135
+ `)}async function b(t={}){let e=t.cwd??n.cwd();if(t.eval||t.print)return x(t,e);if(t.banner!==!1)n.stdout.write(T());let s=m(t),o=u(e,".tinker-preload.ts");c(o,s);let i=["repl"],a=await Bun.spawn(["bun",...i],{cwd:e,stdin:"inherit",stdout:"inherit",stderr:"inherit",env:{...n.env,BUN_PRELOAD:o}}).exited;try{let{unlinkSync:l}=await import("fs");l(o)}catch{}return{exitCode:a}}async function x(t,e){let s=m(t),o=t.print??t.eval??"",i=`${s}
136
136
 
137
137
  const __result__ = await (async () => { return ${o} })()
138
- ${t.print?"console.log(__result__)":""}`,r=u(e,".tinker-eval.ts");c(r,i);let l=await Bun.spawn(["bun","run",r],{cwd:e,stdin:"inherit",stdout:"inherit",stderr:"inherit",env:n.env}).exited;try{let{unlinkSync:b}=await import("fs");b(r)}catch{}return{exitCode:l}}async function R(t,e={}){return m({...e,eval:t})}async function _(t,e={}){return m({...e,print:t})}export{C as appendHistory,q as clearHistory,h as getHistoryPath,v as readHistory,m as startTinker,R as tinkerEval,_ as tinkerPrint};
138
+ ${t.print?"console.log(__result__)":""}`,r=u(e,".tinker-eval.ts");c(r,i);let l=await Bun.spawn(["bun","run",r],{cwd:e,stdin:"inherit",stdout:"inherit",stderr:"inherit",env:n.env}).exited;try{let{unlinkSync:y}=await import("fs");y(r)}catch{}return{exitCode:l}}async function E(t,e={}){return b({...e,eval:t})}async function B(t,e={}){return b({...e,print:t})}export{R as appendHistory,_ as clearHistory,h as getHistoryPath,w as readHistory,b as startTinker,E as tinkerEval,B as tinkerPrint};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/tinker",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.74.34",
5
+ "version": "0.74.35",
6
6
  "description": "Interactive REPL with Stacks framework preloaded.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [