@mushi-mushi/cli 0.43.1 → 0.44.0
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/README.md +5 -3
- package/dist/{chunk-WGMJHJAK.js → chunk-25YBYYYC.js} +3085 -345
- package/dist/{chunk-X64CFG54.js → chunk-2XODEIM4.js} +0 -1
- package/dist/chunk-6XKFNK4C.js +8 -0
- package/dist/{connect-MKDJTERU.js → chunk-NEFF6WK5.js} +40 -7
- package/dist/chunk-O6RN5FT5.js +178 -0
- package/dist/{chunk-5N33DJUL.js → chunk-T3Q44NPC.js} +444 -16
- package/dist/{chunk-QI2A4PGK.js → chunk-ZL2HSPR5.js} +12 -8
- package/dist/connect-HTAUIXDX.js +13 -0
- package/dist/{daemon-SA3MBHOQ.js → daemon-VDYY6GWG.js} +6 -5
- package/dist/{endpoint-KN5YEANQ.js → endpoint-BPPL6DJN.js} +3 -5
- package/dist/index.js +3413 -4840
- package/dist/init.js +6 -5
- package/dist/version.d.ts +6 -5
- package/dist/version.js +1 -1
- package/dist/wizard-bin.js +6 -5
- package/package.json +2 -2
- package/templates/node/.env.example +1 -1
- package/templates/svelte/.env.example +1 -1
- package/templates/svelte/src/App.svelte +1 -1
- package/templates/vue/.env.example +1 -1
- package/templates/vue/src/App.vue +1 -1
- package/dist/chunk-AGWQYT6I.js +0 -8
- package/dist/chunk-CG5KPP4S.js +0 -504
- package/dist/chunk-EHLZL2M2.js +0 -765
- package/dist/chunk-FUXYHTWF.js +0 -10
- package/dist/chunk-GNGVUQL3.js +0 -436
- package/dist/chunk-X6SC4JKO.js +0 -67
- package/dist/chunk-ZDAN3RYF.js +0 -85
- package/dist/connect-NUUPZ5ER.js +0 -13
- package/dist/detect-SOXPECZ3.js +0 -25
- package/dist/endpoint-XZHMF6EZ.js +0 -21
- package/dist/snippet-inject-BQO5I2RN.js +0 -15
- package/dist/version-YXVLZLBR.js +0 -9
package/dist/init.js
CHANGED
|
@@ -13,12 +13,13 @@ import {
|
|
|
13
13
|
sampleBugSnippet,
|
|
14
14
|
sanitizeSecret,
|
|
15
15
|
snippetTarget
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-T3Q44NPC.js";
|
|
17
|
+
import "./chunk-O6RN5FT5.js";
|
|
18
|
+
import "./chunk-ZL2HSPR5.js";
|
|
19
|
+
import "./chunk-6XKFNK4C.js";
|
|
20
20
|
import "./chunk-AWASJDQI.js";
|
|
21
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-2XODEIM4.js";
|
|
22
|
+
import "./chunk-LFP3NPZT.js";
|
|
22
23
|
export {
|
|
23
24
|
CLI_FRESHNESS_SOURCE,
|
|
24
25
|
applySnippetPlan,
|
package/dist/version.d.ts
CHANGED
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
declare const MUSHI_CLI_VERSION: string;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* npm spec for the MCP server written into persistent IDE configs (mcp.json,
|
|
12
|
+
* Zed settings): a caret range on the current minor (`^0.33` = 0.33.x), so
|
|
13
|
+
* patch fixes arrive without a config edit. Never `@latest` (supply-chain and
|
|
14
|
+
* cold-start costs on every editor launch); `mushi upgrade` / re-running
|
|
15
|
+
* setup moves the range to a new minor. Synced to packages/mcp/package.json by
|
|
15
16
|
* `scripts/sync-mcp-pin.mjs` — never hand-edit the version.
|
|
16
17
|
*/
|
|
17
|
-
declare const MUSHI_MCP_PIN_SPEC = "@mushi-mushi/mcp
|
|
18
|
+
declare const MUSHI_MCP_PIN_SPEC = "@mushi-mushi/mcp@^0.34";
|
|
18
19
|
|
|
19
20
|
export { MUSHI_CLI_VERSION, MUSHI_MCP_PIN_SPEC };
|
package/dist/version.js
CHANGED
package/dist/wizard-bin.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runInit
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-T3Q44NPC.js";
|
|
4
|
+
import "./chunk-O6RN5FT5.js";
|
|
5
|
+
import "./chunk-ZL2HSPR5.js";
|
|
6
|
+
import "./chunk-6XKFNK4C.js";
|
|
4
7
|
import {
|
|
5
8
|
FLAGS_HELP,
|
|
6
9
|
UNKNOWN_COMMAND_EXIT,
|
|
@@ -10,11 +13,9 @@ import {
|
|
|
10
13
|
parseArgs,
|
|
11
14
|
scaffoldTemplate
|
|
12
15
|
} from "./chunk-4JF7C3MY.js";
|
|
13
|
-
import "./chunk-LFP3NPZT.js";
|
|
14
|
-
import "./chunk-EHLZL2M2.js";
|
|
15
|
-
import "./chunk-AGWQYT6I.js";
|
|
16
16
|
import "./chunk-AWASJDQI.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-2XODEIM4.js";
|
|
18
|
+
import "./chunk-LFP3NPZT.js";
|
|
18
19
|
|
|
19
20
|
// src/wizard-bin.ts
|
|
20
21
|
import { spawnSync } from "child_process";
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mushi-mushi/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "The bug button for apps built with AI. Mushi Mushi CLI: SDK setup and MCP wiring. Open source.",
|
|
6
6
|
"bin": {
|
|
7
7
|
"mushi": "./dist/index.js"
|
|
8
8
|
},
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<button on:click={throwDemoError}>Throw a demo error</button>
|
|
14
14
|
<p>
|
|
15
15
|
Reports land in your
|
|
16
|
-
<a href="https://kensaur.us
|
|
16
|
+
<a href="https://mushi.kensaur.us" target="_blank" rel="noreferrer">
|
|
17
17
|
Mushi console</a
|
|
18
18
|
>, diagnosed in plain English.
|
|
19
19
|
</p>
|
|
@@ -14,7 +14,7 @@ function throwDemoError(): void {
|
|
|
14
14
|
<button @click="throwDemoError">Throw a demo error</button>
|
|
15
15
|
<p>
|
|
16
16
|
Reports land in your
|
|
17
|
-
<a href="https://kensaur.us
|
|
17
|
+
<a href="https://mushi.kensaur.us" target="_blank" rel="noreferrer">
|
|
18
18
|
Mushi console</a
|
|
19
19
|
>, diagnosed in plain English.
|
|
20
20
|
</p>
|
package/dist/chunk-AGWQYT6I.js
DELETED
package/dist/chunk-CG5KPP4S.js
DELETED
|
@@ -1,504 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/detect.ts
|
|
4
|
-
import { readFileSync, existsSync } from "fs";
|
|
5
|
-
import { join } from "path";
|
|
6
|
-
var FRAMEWORK_IDS = [
|
|
7
|
-
"next",
|
|
8
|
-
"react",
|
|
9
|
-
"cra",
|
|
10
|
-
"remix",
|
|
11
|
-
"astro",
|
|
12
|
-
"solid",
|
|
13
|
-
"vue",
|
|
14
|
-
"nuxt",
|
|
15
|
-
"svelte",
|
|
16
|
-
"sveltekit",
|
|
17
|
-
"angular",
|
|
18
|
-
"expo",
|
|
19
|
-
"react-native",
|
|
20
|
-
"capacitor",
|
|
21
|
-
"express",
|
|
22
|
-
"fastify",
|
|
23
|
-
"hono",
|
|
24
|
-
"vanilla"
|
|
25
|
-
];
|
|
26
|
-
function isFrameworkId(value) {
|
|
27
|
-
return typeof value === "string" && FRAMEWORK_IDS.includes(value);
|
|
28
|
-
}
|
|
29
|
-
var FRAMEWORKS = {
|
|
30
|
-
next: {
|
|
31
|
-
id: "next",
|
|
32
|
-
label: "Next.js",
|
|
33
|
-
packageName: "mushi-mushi",
|
|
34
|
-
importPath: "mushi-mushi/react",
|
|
35
|
-
needsWebPackage: false,
|
|
36
|
-
snippet: () => `// app/providers.tsx (or pages/_app.tsx for /pages router)
|
|
37
|
-
'use client'
|
|
38
|
-
import { MushiProvider } from 'mushi-mushi/react'
|
|
39
|
-
|
|
40
|
-
export function Providers({ children }: { children: React.ReactNode }) {
|
|
41
|
-
return (
|
|
42
|
-
<MushiProvider config={{
|
|
43
|
-
projectId: process.env.NEXT_PUBLIC_MUSHI_PROJECT_ID!,
|
|
44
|
-
apiKey: process.env.NEXT_PUBLIC_MUSHI_API_KEY!,
|
|
45
|
-
}}>
|
|
46
|
-
{children}
|
|
47
|
-
</MushiProvider>
|
|
48
|
-
)
|
|
49
|
-
}`
|
|
50
|
-
},
|
|
51
|
-
react: {
|
|
52
|
-
id: "react",
|
|
53
|
-
label: "React",
|
|
54
|
-
packageName: "mushi-mushi",
|
|
55
|
-
importPath: "mushi-mushi/react",
|
|
56
|
-
needsWebPackage: false,
|
|
57
|
-
snippet: () => `// src/main.tsx
|
|
58
|
-
import { MushiProvider } from 'mushi-mushi/react'
|
|
59
|
-
|
|
60
|
-
createRoot(document.getElementById('root')!).render(
|
|
61
|
-
<MushiProvider config={{
|
|
62
|
-
projectId: import.meta.env.VITE_MUSHI_PROJECT_ID,
|
|
63
|
-
apiKey: import.meta.env.VITE_MUSHI_API_KEY,
|
|
64
|
-
}}>
|
|
65
|
-
<App />
|
|
66
|
-
</MushiProvider>
|
|
67
|
-
)`
|
|
68
|
-
},
|
|
69
|
-
cra: {
|
|
70
|
-
id: "cra",
|
|
71
|
-
label: "Create React App",
|
|
72
|
-
packageName: "mushi-mushi",
|
|
73
|
-
importPath: "mushi-mushi/react",
|
|
74
|
-
needsWebPackage: false,
|
|
75
|
-
// CRA inlines only REACT_APP_*-prefixed vars into process.env at build time.
|
|
76
|
-
snippet: () => `// src/index.tsx
|
|
77
|
-
import { MushiProvider } from 'mushi-mushi/react'
|
|
78
|
-
|
|
79
|
-
root.render(
|
|
80
|
-
<MushiProvider config={{
|
|
81
|
-
projectId: process.env.REACT_APP_MUSHI_PROJECT_ID,
|
|
82
|
-
apiKey: process.env.REACT_APP_MUSHI_API_KEY,
|
|
83
|
-
}}>
|
|
84
|
-
<App />
|
|
85
|
-
</MushiProvider>
|
|
86
|
-
)`
|
|
87
|
-
},
|
|
88
|
-
remix: {
|
|
89
|
-
id: "remix",
|
|
90
|
-
label: "Remix",
|
|
91
|
-
packageName: "mushi-mushi",
|
|
92
|
-
importPath: "mushi-mushi/react",
|
|
93
|
-
needsWebPackage: false,
|
|
94
|
-
// Remix doesn't inline client env. Expose public values at runtime via the
|
|
95
|
-
// root loader + window.ENV (works on both the classic compiler and Vite).
|
|
96
|
-
snippet: () => `// app/root.tsx
|
|
97
|
-
import { MushiProvider } from 'mushi-mushi/react'
|
|
98
|
-
import { useLoaderData } from '@remix-run/react'
|
|
99
|
-
|
|
100
|
-
export async function loader() {
|
|
101
|
-
return { ENV: {
|
|
102
|
-
MUSHI_PROJECT_ID: process.env.MUSHI_PROJECT_ID,
|
|
103
|
-
MUSHI_API_KEY: process.env.MUSHI_API_KEY,
|
|
104
|
-
} }
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export default function App() {
|
|
108
|
-
const { ENV } = useLoaderData<typeof loader>()
|
|
109
|
-
return (
|
|
110
|
-
<html>
|
|
111
|
-
<body>
|
|
112
|
-
<MushiProvider config={{ projectId: ENV.MUSHI_PROJECT_ID, apiKey: ENV.MUSHI_API_KEY }}>
|
|
113
|
-
<Outlet />
|
|
114
|
-
</MushiProvider>
|
|
115
|
-
<Scripts />
|
|
116
|
-
</body>
|
|
117
|
-
</html>
|
|
118
|
-
)
|
|
119
|
-
}`
|
|
120
|
-
},
|
|
121
|
-
astro: {
|
|
122
|
-
id: "astro",
|
|
123
|
-
label: "Astro",
|
|
124
|
-
packageName: "mushi-mushi",
|
|
125
|
-
importPath: "mushi-mushi",
|
|
126
|
-
needsWebPackage: false,
|
|
127
|
-
// Astro exposes only PUBLIC_*-prefixed vars to client code (Vite-based).
|
|
128
|
-
snippet: () => `---
|
|
129
|
-
// src/layouts/Layout.astro (add this <script> once, e.g. in your base layout)
|
|
130
|
-
---
|
|
131
|
-
<script>
|
|
132
|
-
import { Mushi } from 'mushi-mushi'
|
|
133
|
-
Mushi.init({
|
|
134
|
-
projectId: import.meta.env.PUBLIC_MUSHI_PROJECT_ID,
|
|
135
|
-
apiKey: import.meta.env.PUBLIC_MUSHI_API_KEY,
|
|
136
|
-
})
|
|
137
|
-
</script>`
|
|
138
|
-
},
|
|
139
|
-
solid: {
|
|
140
|
-
id: "solid",
|
|
141
|
-
label: "Solid",
|
|
142
|
-
packageName: "mushi-mushi",
|
|
143
|
-
importPath: "mushi-mushi",
|
|
144
|
-
needsWebPackage: false,
|
|
145
|
-
// Solid / SolidStart are Vite-based → VITE_*-prefixed client env.
|
|
146
|
-
snippet: () => `// src/index.tsx (or src/app.tsx for SolidStart)
|
|
147
|
-
import { onMount } from 'solid-js'
|
|
148
|
-
import { Mushi } from 'mushi-mushi'
|
|
149
|
-
|
|
150
|
-
onMount(() => {
|
|
151
|
-
Mushi.init({
|
|
152
|
-
projectId: import.meta.env.VITE_MUSHI_PROJECT_ID,
|
|
153
|
-
apiKey: import.meta.env.VITE_MUSHI_API_KEY,
|
|
154
|
-
})
|
|
155
|
-
})`
|
|
156
|
-
},
|
|
157
|
-
vue: {
|
|
158
|
-
id: "vue",
|
|
159
|
-
label: "Vue 3",
|
|
160
|
-
packageName: "mushi-mushi",
|
|
161
|
-
importPath: "mushi-mushi/vue",
|
|
162
|
-
needsWebPackage: false,
|
|
163
|
-
snippet: () => `// src/main.ts
|
|
164
|
-
import { MushiPlugin } from 'mushi-mushi/vue'
|
|
165
|
-
|
|
166
|
-
app.use(MushiPlugin, {
|
|
167
|
-
projectId: import.meta.env.VITE_MUSHI_PROJECT_ID,
|
|
168
|
-
apiKey: import.meta.env.VITE_MUSHI_API_KEY,
|
|
169
|
-
})`
|
|
170
|
-
},
|
|
171
|
-
nuxt: {
|
|
172
|
-
id: "nuxt",
|
|
173
|
-
label: "Nuxt",
|
|
174
|
-
packageName: "mushi-mushi",
|
|
175
|
-
importPath: "mushi-mushi/vue",
|
|
176
|
-
needsWebPackage: false,
|
|
177
|
-
snippet: () => `// plugins/mushi.client.ts
|
|
178
|
-
import { MushiPlugin } from 'mushi-mushi/vue'
|
|
179
|
-
|
|
180
|
-
export default defineNuxtPlugin((nuxtApp) => {
|
|
181
|
-
nuxtApp.vueApp.use(MushiPlugin, {
|
|
182
|
-
projectId: import.meta.env.NUXT_PUBLIC_MUSHI_PROJECT_ID,
|
|
183
|
-
apiKey: import.meta.env.NUXT_PUBLIC_MUSHI_API_KEY,
|
|
184
|
-
})
|
|
185
|
-
})`
|
|
186
|
-
},
|
|
187
|
-
svelte: {
|
|
188
|
-
id: "svelte",
|
|
189
|
-
label: "Svelte",
|
|
190
|
-
packageName: "mushi-mushi",
|
|
191
|
-
importPath: "mushi-mushi/svelte",
|
|
192
|
-
needsWebPackage: false,
|
|
193
|
-
snippet: () => `// src/main.ts
|
|
194
|
-
import { initMushi } from 'mushi-mushi/svelte'
|
|
195
|
-
|
|
196
|
-
initMushi({
|
|
197
|
-
projectId: import.meta.env.VITE_MUSHI_PROJECT_ID,
|
|
198
|
-
apiKey: import.meta.env.VITE_MUSHI_API_KEY,
|
|
199
|
-
})`
|
|
200
|
-
},
|
|
201
|
-
sveltekit: {
|
|
202
|
-
id: "sveltekit",
|
|
203
|
-
label: "SvelteKit",
|
|
204
|
-
packageName: "mushi-mushi",
|
|
205
|
-
importPath: "mushi-mushi/svelte",
|
|
206
|
-
needsWebPackage: false,
|
|
207
|
-
snippet: () => `// src/routes/+layout.svelte
|
|
208
|
-
<script>
|
|
209
|
-
import { onMount } from 'svelte'
|
|
210
|
-
|
|
211
|
-
onMount(async () => {
|
|
212
|
-
const { initMushi } = await import('mushi-mushi/svelte')
|
|
213
|
-
initMushi({
|
|
214
|
-
projectId: import.meta.env.VITE_MUSHI_PROJECT_ID,
|
|
215
|
-
apiKey: import.meta.env.VITE_MUSHI_API_KEY,
|
|
216
|
-
})
|
|
217
|
-
})
|
|
218
|
-
</script>`
|
|
219
|
-
},
|
|
220
|
-
angular: {
|
|
221
|
-
id: "angular",
|
|
222
|
-
label: "Angular",
|
|
223
|
-
packageName: "mushi-mushi",
|
|
224
|
-
importPath: "mushi-mushi/angular",
|
|
225
|
-
needsWebPackage: false,
|
|
226
|
-
snippet: () => `// src/main.ts
|
|
227
|
-
import { provideMushi } from 'mushi-mushi/angular'
|
|
228
|
-
|
|
229
|
-
bootstrapApplication(AppComponent, {
|
|
230
|
-
providers: [
|
|
231
|
-
provideMushi({
|
|
232
|
-
projectId: import.meta.env.VITE_MUSHI_PROJECT_ID,
|
|
233
|
-
apiKey: import.meta.env.VITE_MUSHI_API_KEY,
|
|
234
|
-
}),
|
|
235
|
-
],
|
|
236
|
-
})`
|
|
237
|
-
},
|
|
238
|
-
expo: {
|
|
239
|
-
id: "expo",
|
|
240
|
-
label: "Expo",
|
|
241
|
-
packageName: "@mushi-mushi/react-native",
|
|
242
|
-
importPath: "@mushi-mushi/react-native",
|
|
243
|
-
needsWebPackage: false,
|
|
244
|
-
snippet: () => `// App.tsx
|
|
245
|
-
import { MushiProvider } from '@mushi-mushi/react-native'
|
|
246
|
-
|
|
247
|
-
export default function App() {
|
|
248
|
-
return (
|
|
249
|
-
<MushiProvider
|
|
250
|
-
projectId={process.env.EXPO_PUBLIC_MUSHI_PROJECT_ID!}
|
|
251
|
-
apiKey={process.env.EXPO_PUBLIC_MUSHI_API_KEY!}
|
|
252
|
-
>
|
|
253
|
-
<YourApp />
|
|
254
|
-
</MushiProvider>
|
|
255
|
-
)
|
|
256
|
-
}`
|
|
257
|
-
},
|
|
258
|
-
"react-native": {
|
|
259
|
-
id: "react-native",
|
|
260
|
-
label: "React Native",
|
|
261
|
-
packageName: "@mushi-mushi/react-native",
|
|
262
|
-
importPath: "@mushi-mushi/react-native",
|
|
263
|
-
needsWebPackage: false,
|
|
264
|
-
snippet: () => `// App.tsx
|
|
265
|
-
import { MushiProvider } from '@mushi-mushi/react-native'
|
|
266
|
-
|
|
267
|
-
export default function App() {
|
|
268
|
-
return (
|
|
269
|
-
<MushiProvider
|
|
270
|
-
projectId={process.env.MUSHI_PROJECT_ID!}
|
|
271
|
-
apiKey={process.env.MUSHI_API_KEY!}
|
|
272
|
-
>
|
|
273
|
-
<YourApp />
|
|
274
|
-
</MushiProvider>
|
|
275
|
-
)
|
|
276
|
-
}`
|
|
277
|
-
},
|
|
278
|
-
capacitor: {
|
|
279
|
-
id: "capacitor",
|
|
280
|
-
label: "Capacitor (Ionic)",
|
|
281
|
-
packageName: "@mushi-mushi/capacitor",
|
|
282
|
-
importPath: "@mushi-mushi/capacitor",
|
|
283
|
-
needsWebPackage: false,
|
|
284
|
-
/* The Capacitor plugin's public API is `Mushi.configure(...)`, not
|
|
285
|
-
* `Mushi.init(...)` — see packages/capacitor/src/definitions.ts. We
|
|
286
|
-
* shipped the wrong call here for two releases and users got a runtime
|
|
287
|
-
* `TypeError: Mushi.init is not a function`. The accompanying admin
|
|
288
|
-
* console snippet (apps/admin/src/lib/sdkSnippets.ts) emits the same
|
|
289
|
-
* `Mushi.configure(...)` shape; both are pinned by tests. */
|
|
290
|
-
snippet: () => `// src/main.ts \u2014 after install, run \`npx cap sync\`
|
|
291
|
-
import { Mushi } from '@mushi-mushi/capacitor'
|
|
292
|
-
|
|
293
|
-
await Mushi.configure({
|
|
294
|
-
projectId: import.meta.env.VITE_MUSHI_PROJECT_ID,
|
|
295
|
-
apiKey: import.meta.env.VITE_MUSHI_API_KEY,
|
|
296
|
-
})`
|
|
297
|
-
},
|
|
298
|
-
express: {
|
|
299
|
-
id: "express",
|
|
300
|
-
label: "Express",
|
|
301
|
-
packageName: "mushi-mushi",
|
|
302
|
-
importPath: "mushi-mushi/node",
|
|
303
|
-
needsWebPackage: false,
|
|
304
|
-
snippet: () => `// src/instrument.ts \u2014 load with: node --import ./dist/instrument.js
|
|
305
|
-
import { MushiNodeClient, attachUnhandledHook } from 'mushi-mushi/node'
|
|
306
|
-
import { mushiExpressErrorHandler } from 'mushi-mushi/node/express'
|
|
307
|
-
import type { Express } from 'express'
|
|
308
|
-
|
|
309
|
-
export const mushi = new MushiNodeClient({
|
|
310
|
-
projectId: process.env.MUSHI_PROJECT_ID!,
|
|
311
|
-
apiKey: process.env.MUSHI_API_KEY!,
|
|
312
|
-
environment: process.env.NODE_ENV ?? 'production',
|
|
313
|
-
})
|
|
314
|
-
attachUnhandledHook({ client: mushi })
|
|
315
|
-
|
|
316
|
-
export function attachMushi(app: Express) {
|
|
317
|
-
app.use(mushiExpressErrorHandler({ client: mushi }))
|
|
318
|
-
}`
|
|
319
|
-
},
|
|
320
|
-
fastify: {
|
|
321
|
-
id: "fastify",
|
|
322
|
-
label: "Fastify",
|
|
323
|
-
packageName: "mushi-mushi",
|
|
324
|
-
importPath: "mushi-mushi/node",
|
|
325
|
-
needsWebPackage: false,
|
|
326
|
-
snippet: () => `// src/instrument.ts \u2014 load with: node --import ./dist/instrument.js
|
|
327
|
-
import { MushiNodeClient, attachUnhandledHook } from 'mushi-mushi/node'
|
|
328
|
-
import { mushiFastifyPlugin } from 'mushi-mushi/node/fastify'
|
|
329
|
-
import Fastify from 'fastify'
|
|
330
|
-
|
|
331
|
-
export const mushi = new MushiNodeClient({
|
|
332
|
-
projectId: process.env.MUSHI_PROJECT_ID!,
|
|
333
|
-
apiKey: process.env.MUSHI_API_KEY!,
|
|
334
|
-
environment: process.env.NODE_ENV ?? 'production',
|
|
335
|
-
})
|
|
336
|
-
attachUnhandledHook({ client: mushi })
|
|
337
|
-
|
|
338
|
-
const app = Fastify()
|
|
339
|
-
mushiFastifyPlugin(app, { client: mushi })`
|
|
340
|
-
},
|
|
341
|
-
hono: {
|
|
342
|
-
id: "hono",
|
|
343
|
-
label: "Hono",
|
|
344
|
-
packageName: "mushi-mushi",
|
|
345
|
-
importPath: "mushi-mushi/node",
|
|
346
|
-
needsWebPackage: false,
|
|
347
|
-
snippet: () => `// src/instrument.ts \u2014 load with: node --import ./dist/instrument.js
|
|
348
|
-
import { MushiNodeClient, attachUnhandledHook } from 'mushi-mushi/node'
|
|
349
|
-
import { mushiHonoErrorHandler } from 'mushi-mushi/node/hono'
|
|
350
|
-
import { Hono } from 'hono'
|
|
351
|
-
|
|
352
|
-
export const mushi = new MushiNodeClient({
|
|
353
|
-
projectId: process.env.MUSHI_PROJECT_ID!,
|
|
354
|
-
apiKey: process.env.MUSHI_API_KEY!,
|
|
355
|
-
environment: process.env.NODE_ENV ?? 'production',
|
|
356
|
-
})
|
|
357
|
-
attachUnhandledHook({ client: mushi })
|
|
358
|
-
|
|
359
|
-
const app = new Hono()
|
|
360
|
-
app.onError(
|
|
361
|
-
mushiHonoErrorHandler({ client: mushi }, (err, c) =>
|
|
362
|
-
c.text('Internal Server Error', 500),
|
|
363
|
-
),
|
|
364
|
-
)`
|
|
365
|
-
},
|
|
366
|
-
vanilla: {
|
|
367
|
-
id: "vanilla",
|
|
368
|
-
label: "Vanilla JS / unknown",
|
|
369
|
-
packageName: "mushi-mushi",
|
|
370
|
-
importPath: "mushi-mushi",
|
|
371
|
-
needsWebPackage: false,
|
|
372
|
-
snippet: () => `// Anywhere in your client bundle
|
|
373
|
-
import { Mushi } from 'mushi-mushi'
|
|
374
|
-
|
|
375
|
-
Mushi.init({
|
|
376
|
-
projectId: import.meta.env.VITE_MUSHI_PROJECT_ID,
|
|
377
|
-
apiKey: import.meta.env.VITE_MUSHI_API_KEY,
|
|
378
|
-
})`
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
var UMBRELLA_PACKAGE = "mushi-mushi";
|
|
382
|
-
function isMushiSdkPackage(name) {
|
|
383
|
-
return name === UMBRELLA_PACKAGE || name.startsWith("@mushi-mushi/");
|
|
384
|
-
}
|
|
385
|
-
function isLauncherOnly(name, spec) {
|
|
386
|
-
if (name !== UMBRELLA_PACKAGE || !spec) return false;
|
|
387
|
-
const m = /^[\^~>=<\sv]*(\d+)\./.exec(spec);
|
|
388
|
-
return m ? Number(m[1]) === 0 : false;
|
|
389
|
-
}
|
|
390
|
-
function readPackageJson(cwd) {
|
|
391
|
-
const path = join(cwd, "package.json");
|
|
392
|
-
if (!existsSync(path)) return null;
|
|
393
|
-
try {
|
|
394
|
-
return JSON.parse(readFileSync(path, "utf-8"));
|
|
395
|
-
} catch {
|
|
396
|
-
return null;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
function detectFramework(cwd, pkg) {
|
|
400
|
-
const deps = collectDeps(pkg);
|
|
401
|
-
if (deps.has("next")) return FRAMEWORKS.next;
|
|
402
|
-
if (deps.has("nuxt")) return FRAMEWORKS.nuxt;
|
|
403
|
-
if (deps.has("@sveltejs/kit")) return FRAMEWORKS.sveltekit;
|
|
404
|
-
if (deps.has("@angular/core")) return FRAMEWORKS.angular;
|
|
405
|
-
if (deps.has("expo")) return FRAMEWORKS.expo;
|
|
406
|
-
if (deps.has("react-native")) return FRAMEWORKS["react-native"];
|
|
407
|
-
if (deps.has("@remix-run/react") || deps.has("@remix-run/node") || deps.has("@remix-run/serve")) {
|
|
408
|
-
return FRAMEWORKS.remix;
|
|
409
|
-
}
|
|
410
|
-
if (deps.has("astro")) return FRAMEWORKS.astro;
|
|
411
|
-
if (deps.has("@solidjs/start") || deps.has("solid-js")) return FRAMEWORKS.solid;
|
|
412
|
-
if (deps.has("@capacitor/core") && deps.has("react")) return FRAMEWORKS.react;
|
|
413
|
-
if (deps.has("@capacitor/core")) return FRAMEWORKS.capacitor;
|
|
414
|
-
if (deps.has("svelte")) return FRAMEWORKS.svelte;
|
|
415
|
-
if (deps.has("vue")) return FRAMEWORKS.vue;
|
|
416
|
-
if (deps.has("react-scripts")) return FRAMEWORKS.cra;
|
|
417
|
-
if (deps.has("react")) return FRAMEWORKS.react;
|
|
418
|
-
if (deps.has("express")) return FRAMEWORKS.express;
|
|
419
|
-
if (deps.has("fastify")) return FRAMEWORKS.fastify;
|
|
420
|
-
if (deps.has("hono") || deps.has("@hono/hono")) return FRAMEWORKS.hono;
|
|
421
|
-
if (existsSync(join(cwd, "next.config.js")) || existsSync(join(cwd, "next.config.ts"))) {
|
|
422
|
-
return FRAMEWORKS.next;
|
|
423
|
-
}
|
|
424
|
-
if (existsSync(join(cwd, "nuxt.config.ts")) || existsSync(join(cwd, "nuxt.config.js"))) {
|
|
425
|
-
return FRAMEWORKS.nuxt;
|
|
426
|
-
}
|
|
427
|
-
if (existsSync(join(cwd, "svelte.config.js"))) return FRAMEWORKS.svelte;
|
|
428
|
-
if (existsSync(join(cwd, "angular.json"))) return FRAMEWORKS.angular;
|
|
429
|
-
if (existsSync(join(cwd, "remix.config.js")) || existsSync(join(cwd, "remix.config.ts"))) {
|
|
430
|
-
return FRAMEWORKS.remix;
|
|
431
|
-
}
|
|
432
|
-
if (existsSync(join(cwd, "astro.config.mjs")) || existsSync(join(cwd, "astro.config.ts")) || existsSync(join(cwd, "astro.config.js"))) {
|
|
433
|
-
return FRAMEWORKS.astro;
|
|
434
|
-
}
|
|
435
|
-
return FRAMEWORKS.vanilla;
|
|
436
|
-
}
|
|
437
|
-
function detectPackageManager(cwd) {
|
|
438
|
-
if (existsSync(join(cwd, "bun.lockb")) || existsSync(join(cwd, "bun.lock"))) return "bun";
|
|
439
|
-
if (existsSync(join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
440
|
-
if (existsSync(join(cwd, "yarn.lock"))) return "yarn";
|
|
441
|
-
if (existsSync(join(cwd, "package-lock.json"))) return "npm";
|
|
442
|
-
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
443
|
-
if (userAgent.startsWith("bun")) return "bun";
|
|
444
|
-
if (userAgent.startsWith("pnpm")) return "pnpm";
|
|
445
|
-
if (userAgent.startsWith("yarn")) return "yarn";
|
|
446
|
-
return "npm";
|
|
447
|
-
}
|
|
448
|
-
function installCommand(pm, packages) {
|
|
449
|
-
const verb = pm === "npm" ? "install" : "add";
|
|
450
|
-
return `${pm} ${verb} ${packages.join(" ")}`;
|
|
451
|
-
}
|
|
452
|
-
var SERVER_FRAMEWORK_IDS = /* @__PURE__ */ new Set(["express", "fastify", "hono"]);
|
|
453
|
-
function envVarsToWrite(apiKey, projectId, framework, endpoint) {
|
|
454
|
-
const CLOUD_ENDPOINT = "https://dxptnwrhwsqckaftyymj.supabase.co/functions/v1/api";
|
|
455
|
-
const endpointLine = endpoint && endpoint !== CLOUD_ENDPOINT ? `MUSHI_API_ENDPOINT=${endpoint}` : null;
|
|
456
|
-
if (SERVER_FRAMEWORK_IDS.has(framework.id)) {
|
|
457
|
-
return [
|
|
458
|
-
`MUSHI_PROJECT_ID=${projectId}`,
|
|
459
|
-
`MUSHI_API_KEY=${apiKey}`,
|
|
460
|
-
endpointLine
|
|
461
|
-
].filter(Boolean).join("\n");
|
|
462
|
-
}
|
|
463
|
-
if (framework.id === "react-native" || framework.id === "remix") {
|
|
464
|
-
return [
|
|
465
|
-
`MUSHI_PROJECT_ID=${projectId}`,
|
|
466
|
-
`MUSHI_API_KEY=${apiKey}`,
|
|
467
|
-
endpointLine
|
|
468
|
-
].filter(Boolean).join("\n");
|
|
469
|
-
}
|
|
470
|
-
if (framework.id === "expo") {
|
|
471
|
-
return [
|
|
472
|
-
`EXPO_PUBLIC_MUSHI_PROJECT_ID=${projectId}`,
|
|
473
|
-
`EXPO_PUBLIC_MUSHI_API_KEY=${apiKey}`,
|
|
474
|
-
endpointLine ? `EXPO_PUBLIC_${endpointLine}` : null
|
|
475
|
-
].filter(Boolean).join("\n");
|
|
476
|
-
}
|
|
477
|
-
const prefix = framework.id === "next" ? "NEXT_PUBLIC_" : framework.id === "nuxt" ? "NUXT_PUBLIC_" : framework.id === "cra" ? "REACT_APP_" : framework.id === "astro" ? "PUBLIC_" : "VITE_";
|
|
478
|
-
return [
|
|
479
|
-
`${prefix}MUSHI_PROJECT_ID=${projectId}`,
|
|
480
|
-
`${prefix}MUSHI_API_KEY=${apiKey}`,
|
|
481
|
-
endpointLine ? `${prefix}${endpointLine}` : null
|
|
482
|
-
].filter(Boolean).join("\n");
|
|
483
|
-
}
|
|
484
|
-
function collectDeps(pkg) {
|
|
485
|
-
if (!pkg) return /* @__PURE__ */ new Set();
|
|
486
|
-
return /* @__PURE__ */ new Set([
|
|
487
|
-
...Object.keys(pkg.dependencies ?? {}),
|
|
488
|
-
...Object.keys(pkg.devDependencies ?? {}),
|
|
489
|
-
...Object.keys(pkg.peerDependencies ?? {})
|
|
490
|
-
]);
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
export {
|
|
494
|
-
FRAMEWORK_IDS,
|
|
495
|
-
isFrameworkId,
|
|
496
|
-
FRAMEWORKS,
|
|
497
|
-
isMushiSdkPackage,
|
|
498
|
-
isLauncherOnly,
|
|
499
|
-
readPackageJson,
|
|
500
|
-
detectFramework,
|
|
501
|
-
detectPackageManager,
|
|
502
|
-
installCommand,
|
|
503
|
-
envVarsToWrite
|
|
504
|
-
};
|