@stacksjs/tinker 0.70.86 → 0.70.88
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/package.json +1 -1
- package/dist/index.d.ts +0 -71
- package/dist/index.js +0 -138
package/package.json
CHANGED
package/dist/index.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { Subprocess } from 'bun';
|
|
2
|
-
export type { Subprocess };
|
|
3
|
-
/**
|
|
4
|
-
* Get the path to the tinker history file.
|
|
5
|
-
*/
|
|
6
|
-
export declare function getHistoryPath(config?: TinkerConfig): string;
|
|
7
|
-
/**
|
|
8
|
-
* Read history entries from file.
|
|
9
|
-
*/
|
|
10
|
-
export declare function readHistory(config?: TinkerConfig): string[];
|
|
11
|
-
/**
|
|
12
|
-
* Append a single entry to the history file.
|
|
13
|
-
*
|
|
14
|
-
* The history file lives at `~/.stacks_tinker_history` and accumulates
|
|
15
|
-
* every expression a developer types — including any one-off pasted
|
|
16
|
-
* tokens, API keys, or DB credentials. Forcing 0600 permissions keeps
|
|
17
|
-
* the file readable only by the file's owner so other users on a shared
|
|
18
|
-
* machine can't grep it for accidentally-committed secrets.
|
|
19
|
-
*/
|
|
20
|
-
export declare function appendHistory(entry: string, config?: TinkerConfig): void;
|
|
21
|
-
/**
|
|
22
|
-
* Clear the tinker history file.
|
|
23
|
-
*/
|
|
24
|
-
export declare function clearHistory(config?: TinkerConfig): void;
|
|
25
|
-
/**
|
|
26
|
-
* Start an interactive Stacks tinker session.
|
|
27
|
-
*
|
|
28
|
-
* Launches Bun's built-in REPL with all Stacks framework modules
|
|
29
|
-
* preloaded into the global scope. ORM models, database, config,
|
|
30
|
-
* logging, and other framework utilities are immediately available.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* import { startTinker } from '@stacksjs/tinker'
|
|
35
|
-
*
|
|
36
|
-
* await startTinker()
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* // Evaluate a single expression
|
|
42
|
-
* await startTinker({ eval: 'await User.count()' })
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```ts
|
|
47
|
-
* // Evaluate and print
|
|
48
|
-
* await startTinker({ print: 'await User.all()' })
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export declare function startTinker(config?: TinkerConfig): Promise<{ exitCode: number }>;
|
|
52
|
-
/**
|
|
53
|
-
* Convenience function to evaluate a single expression in tinker context
|
|
54
|
-
* and return the result.
|
|
55
|
-
*/
|
|
56
|
-
export declare function tinkerEval(expression: string, config?: TinkerConfig): Promise<{ exitCode: number }>;
|
|
57
|
-
/**
|
|
58
|
-
* Convenience function to evaluate and print a single expression.
|
|
59
|
-
*/
|
|
60
|
-
export declare function tinkerPrint(expression: string, config?: TinkerConfig): Promise<{ exitCode: number }>;
|
|
61
|
-
export declare interface TinkerConfig {
|
|
62
|
-
preload?: string[]
|
|
63
|
-
historyFile?: string
|
|
64
|
-
historySize?: number
|
|
65
|
-
cwd?: string
|
|
66
|
-
banner?: boolean
|
|
67
|
-
stacksPreload?: boolean
|
|
68
|
-
eval?: string
|
|
69
|
-
print?: string
|
|
70
|
-
verbose?: boolean
|
|
71
|
-
}
|
package/dist/index.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
var U=import.meta.require;import{existsSync as W,readFileSync as _,writeFileSync as M,appendFileSync as $,chmodSync as V}from"fs";import{homedir as b}from"os";import{join as Q}from"path";import L from"process";function X(q){let A=[];if(q.stacksPreload!==!1)A.push(`
|
|
3
|
-
// ---- Stacks Framework Preload ----
|
|
4
|
-
// ORM & Database
|
|
5
|
-
try {
|
|
6
|
-
const { db } = await import('@stacksjs/database')
|
|
7
|
-
globalThis.db = db
|
|
8
|
-
} catch {}
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
const orm = await import('@stacksjs/orm')
|
|
12
|
-
// Expose all ORM exports globally (User, Post, etc.)
|
|
13
|
-
for (const [key, value] of Object.entries(orm)) {
|
|
14
|
-
if (key !== 'default' && key !== 'db') {
|
|
15
|
-
globalThis[key] = value
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
} catch {}
|
|
19
|
-
|
|
20
|
-
// Config
|
|
21
|
-
try {
|
|
22
|
-
const config = await import('@stacksjs/config')
|
|
23
|
-
globalThis.config = config
|
|
24
|
-
} catch {}
|
|
25
|
-
|
|
26
|
-
// Path utilities
|
|
27
|
-
try {
|
|
28
|
-
const path = await import('@stacksjs/path')
|
|
29
|
-
globalThis.path = path
|
|
30
|
-
} catch {}
|
|
31
|
-
|
|
32
|
-
// Storage
|
|
33
|
-
try {
|
|
34
|
-
const storage = await import('@stacksjs/storage')
|
|
35
|
-
globalThis.storage = storage
|
|
36
|
-
} catch {}
|
|
37
|
-
|
|
38
|
-
// Validation
|
|
39
|
-
try {
|
|
40
|
-
const validation = await import('@stacksjs/validation')
|
|
41
|
-
globalThis.validation = validation
|
|
42
|
-
} catch {}
|
|
43
|
-
|
|
44
|
-
// Logging
|
|
45
|
-
try {
|
|
46
|
-
const { log } = await import('@stacksjs/cli')
|
|
47
|
-
globalThis.log = log
|
|
48
|
-
} catch {}
|
|
49
|
-
|
|
50
|
-
// Collections
|
|
51
|
-
try {
|
|
52
|
-
const collections = await import('@stacksjs/collections')
|
|
53
|
-
globalThis.collect = collections.collect ?? collections.default
|
|
54
|
-
} catch {}
|
|
55
|
-
|
|
56
|
-
// Strings
|
|
57
|
-
try {
|
|
58
|
-
const strings = await import('@stacksjs/strings')
|
|
59
|
-
globalThis.Str = strings
|
|
60
|
-
} catch {}
|
|
61
|
-
|
|
62
|
-
// Cache
|
|
63
|
-
try {
|
|
64
|
-
const cache = await import('@stacksjs/cache')
|
|
65
|
-
globalThis.cache = cache
|
|
66
|
-
} catch {}
|
|
67
|
-
|
|
68
|
-
// Queue / Jobs
|
|
69
|
-
try {
|
|
70
|
-
const queue = await import('@stacksjs/queue')
|
|
71
|
-
globalThis.queue = queue
|
|
72
|
-
} catch {}
|
|
73
|
-
|
|
74
|
-
// Events
|
|
75
|
-
try {
|
|
76
|
-
const events = await import('@stacksjs/events')
|
|
77
|
-
globalThis.events = events
|
|
78
|
-
} catch {}
|
|
79
|
-
|
|
80
|
-
// Router
|
|
81
|
-
try {
|
|
82
|
-
const router = await import('@stacksjs/router')
|
|
83
|
-
globalThis.router = router
|
|
84
|
-
} catch {}
|
|
85
|
-
|
|
86
|
-
// Auth
|
|
87
|
-
try {
|
|
88
|
-
const auth = await import('@stacksjs/auth')
|
|
89
|
-
globalThis.auth = auth
|
|
90
|
-
} catch {}
|
|
91
|
-
|
|
92
|
-
// Notifications
|
|
93
|
-
try {
|
|
94
|
-
const notifications = await import('@stacksjs/notifications')
|
|
95
|
-
globalThis.notifications = notifications
|
|
96
|
-
} catch {}
|
|
97
|
-
|
|
98
|
-
// Env / environment helpers
|
|
99
|
-
try {
|
|
100
|
-
const env = await import('@stacksjs/env')
|
|
101
|
-
globalThis.env = env
|
|
102
|
-
} catch {}
|
|
103
|
-
|
|
104
|
-
// validate() shortcut \u2014 paired with schema for fluent validation in REPL.
|
|
105
|
-
try {
|
|
106
|
-
const { validate } = await import('@stacksjs/validation')
|
|
107
|
-
globalThis.validate = validate
|
|
108
|
-
} catch {}
|
|
109
|
-
|
|
110
|
-
// Jobs facade \u2014 lets you fire jobs without remembering the dispatch builder.
|
|
111
|
-
try {
|
|
112
|
-
const { Jobs } = await import('@stacksjs/queue')
|
|
113
|
-
globalThis.Jobs = Jobs
|
|
114
|
-
} catch {}
|
|
115
|
-
|
|
116
|
-
// Request introspection \u2014 only useful inside an active request, but
|
|
117
|
-
// the proxy is safe to expose: outside a request scope every property
|
|
118
|
-
// returns a typed default (see request-context.ts).
|
|
119
|
-
try {
|
|
120
|
-
const { request, listRegisteredRoutes } = await import('@stacksjs/router')
|
|
121
|
-
globalThis.request = request
|
|
122
|
-
globalThis.routes = listRegisteredRoutes
|
|
123
|
-
} catch {}
|
|
124
|
-
|
|
125
|
-
// dump/dd helpers for quick inspection \u2014 a Laravel-ism that's always
|
|
126
|
-
// nice to have at the REPL when investigating a value.
|
|
127
|
-
globalThis.dump = (...args) => { console.dir(args.length === 1 ? args[0] : args, { depth: 6, colors: true }) }
|
|
128
|
-
globalThis.dd = (...args) => { console.dir(args.length === 1 ? args[0] : args, { depth: 6, colors: true }); process.exit(0) }
|
|
129
|
-
`);if(q.preload?.length)for(let D of q.preload){let E=D.replace(/[@/\-\.]/g,"_").replace(/^_+/,"");A.push(`try { globalThis.${E} = await import('${D}') } catch {}`)}return A.join(`
|
|
130
|
-
`)}function R(q){return q?.historyFile??Q(b(),".stacks_tinker_history")}function B(q){let A=R(q);if(!W(A))return[];return _(A,"utf-8").split(`
|
|
131
|
-
`).filter(Boolean)}function v(q,A){let D=R(A),E=!W(D);if($(D,`${q}
|
|
132
|
-
`),E)try{V(D,384)}catch{}let J=A?.historySize??5000,G=B(A);if(G.length>J){let K=G.slice(G.length-J);M(D,K.join(`
|
|
133
|
-
`)+`
|
|
134
|
-
`);try{V(D,384)}catch{}}}function H(q){let A=R(q);M(A,"")}function I(){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 Y(q={}){let A=q.cwd??L.cwd();if(q.eval||q.print)return z(q,A);if(q.banner!==!1)L.stdout.write(I());let D=X(q),E=Q(A,".tinker-preload.ts");M(E,D);let J=["repl"],K=await Bun.spawn(["bun",...J],{cwd:A,stdin:"inherit",stdout:"inherit",stderr:"inherit",env:{...L.env,BUN_PRELOAD:E}}).exited;try{let{unlinkSync:O}=await import("fs");O(E)}catch{}return{exitCode:K}}async function z(q,A){let D=X(q),E=q.print??q.eval??"",J=`${D}
|
|
136
|
-
|
|
137
|
-
const __result__ = await (async () => { return ${E} })()
|
|
138
|
-
${q.print?"console.log(__result__)":""}`,G=Q(A,".tinker-eval.ts");M(G,J);let O=await Bun.spawn(["bun","run",G],{cwd:A,stdin:"inherit",stdout:"inherit",stderr:"inherit",env:L.env}).exited;try{let{unlinkSync:Z}=await import("fs");Z(G)}catch{}return{exitCode:O}}async function u(q,A={}){return Y({...A,eval:q})}async function F(q,A={}){return Y({...A,print:q})}export{F as tinkerPrint,u as tinkerEval,Y as startTinker,B as readHistory,R as getHistoryPath,H as clearHistory,v as appendHistory};
|