@sentry/junior 0.13.0 → 0.15.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 +1 -1
- package/dist/app.js +227 -25
- package/dist/{chunk-WZXIUH5S.js → chunk-5JHLDXBN.js} +1 -1
- package/dist/{chunk-C4N7XWDT.js → chunk-ESPIOJPM.js} +1 -1
- package/dist/{chunk-7YFFZCL4.js → chunk-KTBQH6L5.js} +2 -2
- package/dist/{chunk-XH7TV4JS.js → chunk-RBB2MZAN.js} +22 -240
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +11 -4
- package/dist/cli/snapshot-warmup.js +3 -3
- package/dist/nitro.d.ts +14 -21
- package/dist/nitro.js +73 -25
- package/dist/vercel.js +3 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ export default app;
|
|
|
25
25
|
|
|
26
26
|
Run `junior init my-bot` to scaffold a complete project including `vercel.json` for Vercel deployment.
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Use `juniorNitro({ pluginPackages: [...] })` in `nitro.config.ts` to declare which plugin packages to bundle and load at runtime.
|
|
29
29
|
|
|
30
30
|
## Full docs
|
|
31
31
|
|
package/dist/app.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
logCapabilityCatalogLoadedOnce,
|
|
8
8
|
parseSkillInvocation,
|
|
9
9
|
stripFrontmatter
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-KTBQH6L5.js";
|
|
11
11
|
import {
|
|
12
12
|
SANDBOX_SKILLS_ROOT,
|
|
13
13
|
SANDBOX_WORKSPACE_ROOT,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
runNonInteractiveCommand,
|
|
27
27
|
sandboxSkillDir,
|
|
28
28
|
toOptionalTrimmed
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-ESPIOJPM.js";
|
|
30
30
|
import {
|
|
31
31
|
CredentialUnavailableError,
|
|
32
32
|
buildOAuthTokenRequest,
|
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
toOptionalString,
|
|
55
55
|
withContext,
|
|
56
56
|
withSpan
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-5JHLDXBN.js";
|
|
58
58
|
import "./chunk-Z3YD6NHK.js";
|
|
59
59
|
import {
|
|
60
60
|
aboutPathCandidates,
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
homeDir,
|
|
63
63
|
setPluginPackages,
|
|
64
64
|
soulPathCandidates
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-RBB2MZAN.js";
|
|
66
66
|
import "./chunk-2KG3PWR4.js";
|
|
67
67
|
|
|
68
68
|
// src/app.ts
|
|
@@ -95,6 +95,11 @@ async function GET() {
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// src/chat/xml.ts
|
|
99
|
+
function escapeXml(value) {
|
|
100
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
101
|
+
}
|
|
102
|
+
|
|
98
103
|
// src/handlers/health.ts
|
|
99
104
|
function GET2() {
|
|
100
105
|
return Response.json({
|
|
@@ -104,6 +109,200 @@ function GET2() {
|
|
|
104
109
|
});
|
|
105
110
|
}
|
|
106
111
|
|
|
112
|
+
// src/handlers/diagnostics-dashboard.ts
|
|
113
|
+
async function GET3() {
|
|
114
|
+
let health;
|
|
115
|
+
let discovery;
|
|
116
|
+
try {
|
|
117
|
+
const res = await GET2();
|
|
118
|
+
health = {
|
|
119
|
+
ok: res.ok,
|
|
120
|
+
data: await res.json()
|
|
121
|
+
};
|
|
122
|
+
} catch (e) {
|
|
123
|
+
health = { ok: false, error: String(e) };
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
const res = await GET();
|
|
127
|
+
if (res.ok) {
|
|
128
|
+
discovery = {
|
|
129
|
+
ok: true,
|
|
130
|
+
data: await res.json()
|
|
131
|
+
};
|
|
132
|
+
} else {
|
|
133
|
+
discovery = { ok: false, error: `${res.status} ${res.statusText}` };
|
|
134
|
+
}
|
|
135
|
+
} catch (e) {
|
|
136
|
+
discovery = { ok: false, error: String(e) };
|
|
137
|
+
}
|
|
138
|
+
const d = discovery.ok ? discovery.data : null;
|
|
139
|
+
let html = `<!DOCTYPE html>
|
|
140
|
+
<html lang="en">
|
|
141
|
+
<head>
|
|
142
|
+
<meta charset="utf-8" />
|
|
143
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
144
|
+
<title>Junior</title>
|
|
145
|
+
<style>
|
|
146
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
147
|
+
body {
|
|
148
|
+
font-family: "SF Mono", "Cascadia Code", "Fira Code", Menlo, monospace;
|
|
149
|
+
background: #0d1117; color: #c9d1d9; padding: 2rem;
|
|
150
|
+
font-size: 14px; line-height: 1.6;
|
|
151
|
+
}
|
|
152
|
+
h1 { color: #58a6ff; font-size: 1.1rem; margin-bottom: 0.25rem; }
|
|
153
|
+
.subtitle { color: #8b949e; font-size: 0.85rem; margin-bottom: 1.5rem; }
|
|
154
|
+
.section { max-width: 720px; margin-bottom: 1.25rem; }
|
|
155
|
+
.section-title {
|
|
156
|
+
color: #8b949e; font-size: 0.75rem; text-transform: uppercase;
|
|
157
|
+
letter-spacing: 0.08em; margin-bottom: 0.5rem; padding-bottom: 0.25rem;
|
|
158
|
+
border-bottom: 1px solid #21262d;
|
|
159
|
+
}
|
|
160
|
+
.status-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
|
|
161
|
+
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
|
|
162
|
+
.dot-ok { background: #2dd4bf; }
|
|
163
|
+
.dot-err { background: #f87171; }
|
|
164
|
+
.label { color: #8b949e; }
|
|
165
|
+
.value { color: #e6edf3; }
|
|
166
|
+
.detail-row { display: flex; gap: 0.5rem; margin-bottom: 0.25rem; font-size: 0.85rem; }
|
|
167
|
+
.detail-key { color: #8b949e; min-width: 7rem; }
|
|
168
|
+
.detail-val { color: #c9d1d9; }
|
|
169
|
+
.skill-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; }
|
|
170
|
+
.skill-tag {
|
|
171
|
+
background: #161b22; border: 1px solid #30363d; border-radius: 4px;
|
|
172
|
+
padding: 0.2rem 0.5rem; font-size: 0.8rem; color: #c9d1d9;
|
|
173
|
+
}
|
|
174
|
+
.skill-provider { color: #8b949e; font-size: 0.7rem; margin-left: 0.15rem; }
|
|
175
|
+
.provider-list, .package-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
|
|
176
|
+
.provider-tag {
|
|
177
|
+
background: #1b2332; border: 1px solid #1f3a5f; border-radius: 4px;
|
|
178
|
+
padding: 0.2rem 0.5rem; font-size: 0.8rem; color: #58a6ff;
|
|
179
|
+
}
|
|
180
|
+
.package-tag {
|
|
181
|
+
background: #1a1e2a; border: 1px solid #2d3548; border-radius: 4px;
|
|
182
|
+
padding: 0.2rem 0.5rem; font-size: 0.78rem; color: #a5b4cf;
|
|
183
|
+
}
|
|
184
|
+
.endpoint-list { list-style: none; }
|
|
185
|
+
.endpoint-list li { margin-bottom: 0.2rem; font-size: 0.85rem; }
|
|
186
|
+
.method {
|
|
187
|
+
display: inline-block; font-size: 0.7rem; font-weight: 600;
|
|
188
|
+
padding: 0.1rem 0.35rem; border-radius: 3px; margin-right: 0.4rem;
|
|
189
|
+
min-width: 2.5rem; text-align: center;
|
|
190
|
+
}
|
|
191
|
+
.method-get { background: #1b3a2d; color: #2dd4bf; }
|
|
192
|
+
.method-post { background: #3b2e1a; color: #f0b952; }
|
|
193
|
+
.endpoint-link { color: #c9d1d9; text-decoration: none; }
|
|
194
|
+
.endpoint-link:hover { color: #58a6ff; text-decoration: underline; }
|
|
195
|
+
.error-msg { color: #f87171; font-size: 0.85rem; }
|
|
196
|
+
</style>
|
|
197
|
+
</head>
|
|
198
|
+
<body>
|
|
199
|
+
<h1>> junior</h1>`;
|
|
200
|
+
if (d?.aboutText) {
|
|
201
|
+
html += `
|
|
202
|
+
<div class="subtitle">${escapeXml(String(d.aboutText))}</div>`;
|
|
203
|
+
}
|
|
204
|
+
html += `
|
|
205
|
+
<div class="section">
|
|
206
|
+
<div class="section-title">Status</div>
|
|
207
|
+
<div class="status-row">
|
|
208
|
+
<span class="dot ${health.ok ? "dot-ok" : "dot-err"}"></span>
|
|
209
|
+
<span class="value">${health.ok ? "Healthy" : "Unreachable"}</span>`;
|
|
210
|
+
if (health.ok && health.data?.timestamp) {
|
|
211
|
+
html += `
|
|
212
|
+
<span class="label">· ${escapeXml(new Date(health.data.timestamp).toLocaleTimeString())}</span>`;
|
|
213
|
+
}
|
|
214
|
+
html += `
|
|
215
|
+
</div>`;
|
|
216
|
+
if (d) {
|
|
217
|
+
html += `
|
|
218
|
+
<div class="detail-row"><span class="detail-key">service</span><span class="detail-val">${escapeXml(String(health.data?.service ?? "junior"))}</span></div>`;
|
|
219
|
+
html += `
|
|
220
|
+
<div class="detail-row"><span class="detail-key">cwd</span><span class="detail-val">${escapeXml(String(d.cwd))}</span></div>`;
|
|
221
|
+
html += `
|
|
222
|
+
<div class="detail-row"><span class="detail-key">home</span><span class="detail-val">${escapeXml(String(d.homeDir))}</span></div>`;
|
|
223
|
+
}
|
|
224
|
+
html += `
|
|
225
|
+
</div>`;
|
|
226
|
+
const endpoints = [
|
|
227
|
+
{ method: "GET", path: "/api/health" },
|
|
228
|
+
{ method: "GET", path: "/api/__junior/discovery" },
|
|
229
|
+
{ method: "GET", path: "/api/oauth/callback/mcp/:provider" },
|
|
230
|
+
{ method: "GET", path: "/api/oauth/callback/:provider" },
|
|
231
|
+
{ method: "POST", path: "/api/webhooks/:platform" }
|
|
232
|
+
];
|
|
233
|
+
html += `
|
|
234
|
+
<div class="section">
|
|
235
|
+
<div class="section-title">Endpoints</div>
|
|
236
|
+
<ul class="endpoint-list">`;
|
|
237
|
+
for (const ep of endpoints) {
|
|
238
|
+
const cls = ep.method === "GET" ? "method-get" : "method-post";
|
|
239
|
+
const link = ep.path.includes(":") ? `<span>${escapeXml(ep.path)}</span>` : `<a class="endpoint-link" href="${escapeXml(ep.path)}" target="_blank">${escapeXml(ep.path)}</a>`;
|
|
240
|
+
html += `
|
|
241
|
+
<li><span class="method ${cls}">${escapeXml(ep.method)}</span>${link}</li>`;
|
|
242
|
+
}
|
|
243
|
+
html += `
|
|
244
|
+
</ul>
|
|
245
|
+
</div>`;
|
|
246
|
+
if (d) {
|
|
247
|
+
const providers = d.providers;
|
|
248
|
+
const packagedContent = d.packagedContent;
|
|
249
|
+
const skills = d.skills;
|
|
250
|
+
if (providers?.length) {
|
|
251
|
+
html += `
|
|
252
|
+
<div class="section">
|
|
253
|
+
<div class="section-title">Plugins <span class="label">(${providers.length})</span></div>
|
|
254
|
+
<div class="provider-list">`;
|
|
255
|
+
for (const p of providers) {
|
|
256
|
+
html += `
|
|
257
|
+
<span class="provider-tag">${escapeXml(p)}</span>`;
|
|
258
|
+
}
|
|
259
|
+
html += `
|
|
260
|
+
</div>`;
|
|
261
|
+
if (packagedContent?.packageNames?.length) {
|
|
262
|
+
html += `
|
|
263
|
+
<div style="margin-top:0.5rem"><div class="package-list">`;
|
|
264
|
+
for (const pkg of packagedContent.packageNames) {
|
|
265
|
+
html += `
|
|
266
|
+
<span class="package-tag">${escapeXml(pkg)}</span>`;
|
|
267
|
+
}
|
|
268
|
+
html += `
|
|
269
|
+
</div></div>`;
|
|
270
|
+
}
|
|
271
|
+
html += `
|
|
272
|
+
</div>`;
|
|
273
|
+
}
|
|
274
|
+
if (skills?.length) {
|
|
275
|
+
html += `
|
|
276
|
+
<div class="section">
|
|
277
|
+
<div class="section-title">Skills <span class="label">(${skills.length})</span></div>
|
|
278
|
+
<div class="skill-grid">`;
|
|
279
|
+
for (const s of skills) {
|
|
280
|
+
html += `
|
|
281
|
+
<span class="skill-tag">${escapeXml(s.name)}`;
|
|
282
|
+
if (s.pluginProvider) {
|
|
283
|
+
html += ` <span class="skill-provider">${escapeXml(s.pluginProvider)}</span>`;
|
|
284
|
+
}
|
|
285
|
+
html += `</span>`;
|
|
286
|
+
}
|
|
287
|
+
html += `
|
|
288
|
+
</div>
|
|
289
|
+
</div>`;
|
|
290
|
+
}
|
|
291
|
+
} else if (!discovery.ok) {
|
|
292
|
+
html += `
|
|
293
|
+
<div class="section">
|
|
294
|
+
<div class="section-title">Discovery</div>
|
|
295
|
+
<span class="error-msg">unavailable · ${escapeXml(discovery.error ?? "unknown")}</span>
|
|
296
|
+
</div>`;
|
|
297
|
+
}
|
|
298
|
+
html += `
|
|
299
|
+
</body>
|
|
300
|
+
</html>`;
|
|
301
|
+
return new Response(html, {
|
|
302
|
+
headers: { "content-type": "text/html; charset=utf-8" }
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
107
306
|
// src/handlers/mcp-oauth-callback.ts
|
|
108
307
|
import { Buffer as Buffer2 } from "buffer";
|
|
109
308
|
|
|
@@ -2421,13 +2620,6 @@ import { Agent } from "@mariozechner/pi-agent-core";
|
|
|
2421
2620
|
|
|
2422
2621
|
// src/chat/prompt.ts
|
|
2423
2622
|
import fs from "fs";
|
|
2424
|
-
|
|
2425
|
-
// src/chat/xml.ts
|
|
2426
|
-
function escapeXml(value) {
|
|
2427
|
-
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
// src/chat/prompt.ts
|
|
2431
2623
|
var DEFAULT_SOUL = "You are Junior, a practical and concise assistant.";
|
|
2432
2624
|
function getLoggedMarkdownFiles() {
|
|
2433
2625
|
const globalState = globalThis;
|
|
@@ -9770,7 +9962,7 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
9770
9962
|
}
|
|
9771
9963
|
});
|
|
9772
9964
|
}
|
|
9773
|
-
async function
|
|
9965
|
+
async function GET4(request, provider, waitUntil) {
|
|
9774
9966
|
const url = new URL(request.url);
|
|
9775
9967
|
const state = url.searchParams.get("state")?.trim();
|
|
9776
9968
|
const code = url.searchParams.get("code")?.trim();
|
|
@@ -10011,7 +10203,7 @@ async function resumePendingOAuthMessage(stored) {
|
|
|
10011
10203
|
}
|
|
10012
10204
|
});
|
|
10013
10205
|
}
|
|
10014
|
-
async function
|
|
10206
|
+
async function GET5(request, provider, waitUntil) {
|
|
10015
10207
|
const providerConfig = getPluginOAuthConfig(provider);
|
|
10016
10208
|
if (!providerConfig) {
|
|
10017
10209
|
return htmlErrorResponse(
|
|
@@ -11846,12 +12038,6 @@ function createReplyToThread(deps) {
|
|
|
11846
12038
|
}
|
|
11847
12039
|
} else {
|
|
11848
12040
|
await streamedReplyPromise;
|
|
11849
|
-
if (reply.diagnostics.outcome !== "success" && reply.text.trim().length > 0) {
|
|
11850
|
-
await postThreadReply(
|
|
11851
|
-
buildSlackOutputMessage(reply.text),
|
|
11852
|
-
"thread_reply_after_stream_failure"
|
|
11853
|
-
);
|
|
11854
|
-
}
|
|
11855
12041
|
}
|
|
11856
12042
|
}
|
|
11857
12043
|
const shouldPersistArtifacts = Object.keys(artifactStatePatch).length > 0;
|
|
@@ -12758,8 +12944,25 @@ async function defaultWaitUntil() {
|
|
|
12758
12944
|
};
|
|
12759
12945
|
}
|
|
12760
12946
|
}
|
|
12947
|
+
async function resolveBuildPluginPackages() {
|
|
12948
|
+
try {
|
|
12949
|
+
const mod = await import("#junior/config");
|
|
12950
|
+
return mod.pluginPackages;
|
|
12951
|
+
} catch {
|
|
12952
|
+
const env = process.env.JUNIOR_PLUGIN_PACKAGES;
|
|
12953
|
+
if (env) {
|
|
12954
|
+
try {
|
|
12955
|
+
return JSON.parse(env);
|
|
12956
|
+
} catch {
|
|
12957
|
+
}
|
|
12958
|
+
}
|
|
12959
|
+
return void 0;
|
|
12960
|
+
}
|
|
12961
|
+
}
|
|
12761
12962
|
async function createApp(options) {
|
|
12762
|
-
setPluginPackages(
|
|
12963
|
+
setPluginPackages(
|
|
12964
|
+
options?.pluginPackages ?? await resolveBuildPluginPackages()
|
|
12965
|
+
);
|
|
12763
12966
|
const waitUntil = options?.waitUntil ?? await defaultWaitUntil();
|
|
12764
12967
|
const app = new Hono().basePath("/api");
|
|
12765
12968
|
app.onError((err, c) => {
|
|
@@ -12767,14 +12970,13 @@ async function createApp(options) {
|
|
|
12767
12970
|
return c.text("Internal Server Error", 500);
|
|
12768
12971
|
});
|
|
12769
12972
|
app.get("/health", () => GET2());
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
}
|
|
12973
|
+
app.get("/__junior/discovery", () => GET());
|
|
12974
|
+
app.get("/__junior/dashboard", () => GET3());
|
|
12773
12975
|
app.get("/oauth/callback/mcp/:provider", (c) => {
|
|
12774
|
-
return
|
|
12976
|
+
return GET4(c.req.raw, c.req.param("provider"), waitUntil);
|
|
12775
12977
|
});
|
|
12776
12978
|
app.get("/oauth/callback/:provider", (c) => {
|
|
12777
|
-
return
|
|
12979
|
+
return GET5(c.req.raw, c.req.param("provider"), waitUntil);
|
|
12778
12980
|
});
|
|
12779
12981
|
app.post("/webhooks/:platform", (c) => {
|
|
12780
12982
|
return POST(c.req.raw, c.req.param("platform"), waitUntil);
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
getPluginSkillRoots,
|
|
6
6
|
logInfo,
|
|
7
7
|
logWarn
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5JHLDXBN.js";
|
|
9
9
|
import {
|
|
10
10
|
skillRoots
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-RBB2MZAN.js";
|
|
12
12
|
|
|
13
13
|
// src/chat/skills.ts
|
|
14
14
|
import fs from "fs/promises";
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// src/chat/plugins/package-discovery.ts
|
|
2
|
-
import { readFileSync, readdirSync as readdirSync2 } from "fs";
|
|
3
2
|
import path2 from "path";
|
|
4
|
-
import { parse as parseYaml } from "yaml";
|
|
5
3
|
|
|
6
4
|
// src/chat/discovery.ts
|
|
7
|
-
import fs, {
|
|
5
|
+
import fs, { statSync } from "fs";
|
|
8
6
|
import path from "path";
|
|
9
7
|
import { fileURLToPath } from "url";
|
|
10
8
|
function isDirectory(targetPath) {
|
|
@@ -103,37 +101,6 @@ function discoverProjectRoots(cwd = process.cwd(), options) {
|
|
|
103
101
|
).map((nodeModulesDir) => path.dirname(nodeModulesDir));
|
|
104
102
|
return uniqueResolvedPathsInOrder([cwd, ...roots]);
|
|
105
103
|
}
|
|
106
|
-
function listTopLevelPackages(nodeModulesDir) {
|
|
107
|
-
const entries = readdirSync(nodeModulesDir, { withFileTypes: true }).filter(
|
|
108
|
-
(entry) => !entry.name.startsWith(".") && entry.name !== ".bin" && entry.name !== ".pnpm"
|
|
109
|
-
).sort((left, right) => left.name.localeCompare(right.name));
|
|
110
|
-
const packages = [];
|
|
111
|
-
for (const entry of entries) {
|
|
112
|
-
const entryPath = path.join(nodeModulesDir, entry.name);
|
|
113
|
-
if (entry.name.startsWith("@")) {
|
|
114
|
-
if (!isDirectory(entryPath)) {
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
const scopedEntries = readdirSync(entryPath, {
|
|
118
|
-
withFileTypes: true
|
|
119
|
-
}).sort((left, right) => left.name.localeCompare(right.name));
|
|
120
|
-
for (const scopedEntry of scopedEntries) {
|
|
121
|
-
const packageName = `${entry.name}/${scopedEntry.name}`;
|
|
122
|
-
const packagePath = path.join(entryPath, scopedEntry.name);
|
|
123
|
-
if (!isDirectory(packagePath)) {
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
packages.push({ name: packageName, dir: packagePath });
|
|
127
|
-
}
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
if (!isDirectory(entryPath)) {
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
packages.push({ name: entry.name, dir: entryPath });
|
|
134
|
-
}
|
|
135
|
-
return packages;
|
|
136
|
-
}
|
|
137
104
|
function unique(values) {
|
|
138
105
|
return [...new Set(values)];
|
|
139
106
|
}
|
|
@@ -260,93 +227,21 @@ function pathForTracingInclude(cwd, targetPath) {
|
|
|
260
227
|
const normalized = normalizeForGlob(relative);
|
|
261
228
|
return normalized.startsWith(".") ? normalized : `./${normalized}`;
|
|
262
229
|
}
|
|
263
|
-
function parseRuntimeConfiguredPackageNames(value) {
|
|
264
|
-
if (!Array.isArray(value)) {
|
|
265
|
-
return null;
|
|
266
|
-
}
|
|
267
|
-
const parsed = value.filter(
|
|
268
|
-
(entry) => typeof entry === "string" && entry.trim().length > 0
|
|
269
|
-
);
|
|
270
|
-
return uniqueStringsInOrder(parsed.map((entry) => entry.trim()));
|
|
271
|
-
}
|
|
272
230
|
var configuredPluginPackages;
|
|
273
231
|
function setPluginPackages(packages) {
|
|
274
232
|
configuredPluginPackages = packages;
|
|
275
233
|
}
|
|
276
|
-
function
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
try {
|
|
285
|
-
return parseRuntimeConfiguredPackageNames(JSON.parse(raw)) ?? [];
|
|
286
|
-
} catch {
|
|
287
|
-
return [];
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
function findWorkspaceRoot(cwd) {
|
|
291
|
-
let current = path2.resolve(cwd);
|
|
292
|
-
while (true) {
|
|
293
|
-
const candidate = path2.join(current, "pnpm-workspace.yaml");
|
|
294
|
-
if (isFile(candidate)) {
|
|
295
|
-
return current;
|
|
296
|
-
}
|
|
297
|
-
const parent = path2.dirname(current);
|
|
298
|
-
if (parent === current) {
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
current = parent;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
function listWorkspacePackageDirs(cwd) {
|
|
305
|
-
const workspaceRoot = findWorkspaceRoot(cwd);
|
|
306
|
-
if (!workspaceRoot) {
|
|
307
|
-
return [];
|
|
308
|
-
}
|
|
309
|
-
let packagePatterns = [];
|
|
310
|
-
try {
|
|
311
|
-
const raw = readFileSync(
|
|
312
|
-
path2.join(workspaceRoot, "pnpm-workspace.yaml"),
|
|
313
|
-
"utf8"
|
|
314
|
-
);
|
|
315
|
-
const parsed = parseYaml(raw);
|
|
316
|
-
packagePatterns = Array.isArray(parsed.packages) ? parsed.packages.filter(
|
|
317
|
-
(entry) => typeof entry === "string" && entry.trim().length > 0
|
|
318
|
-
) : [];
|
|
319
|
-
} catch {
|
|
320
|
-
return [];
|
|
321
|
-
}
|
|
322
|
-
const discovered = [];
|
|
323
|
-
const seen = /* @__PURE__ */ new Set();
|
|
324
|
-
const addDir = (candidate) => {
|
|
325
|
-
const normalized = path2.resolve(candidate);
|
|
326
|
-
if (seen.has(normalized) || !isDirectory(normalized)) {
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
seen.add(normalized);
|
|
330
|
-
discovered.push(normalized);
|
|
331
|
-
};
|
|
332
|
-
for (const pattern of packagePatterns) {
|
|
333
|
-
const trimmed = pattern.trim();
|
|
334
|
-
if (!trimmed) {
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
if (trimmed.endsWith("/*")) {
|
|
338
|
-
const baseDir = path2.join(workspaceRoot, trimmed.slice(0, -2));
|
|
339
|
-
if (!isDirectory(baseDir)) {
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
for (const entry of readdirSync2(baseDir)) {
|
|
343
|
-
addDir(path2.join(baseDir, entry));
|
|
344
|
-
}
|
|
345
|
-
continue;
|
|
234
|
+
function resolvePackageDirFromName(packageName, candidateNodeModulesDirs) {
|
|
235
|
+
for (const nodeModulesDir of candidateNodeModulesDirs) {
|
|
236
|
+
const packageDir = path2.join(nodeModulesDir, ...packageName.split("/"));
|
|
237
|
+
if (isDirectory(packageDir)) {
|
|
238
|
+
return {
|
|
239
|
+
dir: path2.resolve(packageDir),
|
|
240
|
+
nodeModulesDir: path2.resolve(nodeModulesDir)
|
|
241
|
+
};
|
|
346
242
|
}
|
|
347
|
-
addDir(path2.join(workspaceRoot, trimmed));
|
|
348
243
|
}
|
|
349
|
-
return
|
|
244
|
+
return null;
|
|
350
245
|
}
|
|
351
246
|
function readPluginPackageFlags(dir) {
|
|
352
247
|
const hasRootPluginManifest = isFile(path2.join(dir, "plugin.yaml"));
|
|
@@ -361,45 +256,7 @@ function readPluginPackageFlags(dir) {
|
|
|
361
256
|
hasSkillsDir
|
|
362
257
|
};
|
|
363
258
|
}
|
|
364
|
-
function
|
|
365
|
-
if (packageNames !== null) {
|
|
366
|
-
return [];
|
|
367
|
-
}
|
|
368
|
-
return listWorkspacePackageDirs(cwd).filter(
|
|
369
|
-
(candidate) => readPluginPackageFlags(candidate) !== null
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
function readWorkspacePackageName(dir) {
|
|
373
|
-
try {
|
|
374
|
-
const raw = readFileSync(path2.join(dir, "package.json"), "utf8");
|
|
375
|
-
const name = JSON.parse(raw).name;
|
|
376
|
-
return typeof name === "string" && name.trim().length > 0 ? name : null;
|
|
377
|
-
} catch {
|
|
378
|
-
return null;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
function resolveWorkspacePackageDirFromName(cwd, packageName) {
|
|
382
|
-
for (const candidate of listWorkspacePackageDirs(cwd)) {
|
|
383
|
-
if (readWorkspacePackageName(candidate) !== packageName) {
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
|
-
return candidate;
|
|
387
|
-
}
|
|
388
|
-
return null;
|
|
389
|
-
}
|
|
390
|
-
function resolvePackageDirFromName(packageName, candidateNodeModulesDirs) {
|
|
391
|
-
for (const nodeModulesDir of candidateNodeModulesDirs) {
|
|
392
|
-
const packageDir = path2.join(nodeModulesDir, ...packageName.split("/"));
|
|
393
|
-
if (isDirectory(packageDir)) {
|
|
394
|
-
return {
|
|
395
|
-
dir: path2.resolve(packageDir),
|
|
396
|
-
nodeModulesDir: path2.resolve(nodeModulesDir)
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return null;
|
|
401
|
-
}
|
|
402
|
-
function discoverDeclaredPackages(cwd, packageNames, candidateNodeModulesDirs) {
|
|
259
|
+
function discoverDeclaredPackages(packageNames, candidateNodeModulesDirs) {
|
|
403
260
|
const discovered = [];
|
|
404
261
|
const seenPackageNames = /* @__PURE__ */ new Set();
|
|
405
262
|
const seenPackageDirs = /* @__PURE__ */ new Set();
|
|
@@ -408,88 +265,34 @@ function discoverDeclaredPackages(cwd, packageNames, candidateNodeModulesDirs) {
|
|
|
408
265
|
packageName,
|
|
409
266
|
candidateNodeModulesDirs
|
|
410
267
|
);
|
|
411
|
-
|
|
412
|
-
if (!resolved && !workspaceDir) {
|
|
268
|
+
if (!resolved) {
|
|
413
269
|
continue;
|
|
414
270
|
}
|
|
415
|
-
|
|
416
|
-
if (seenPackageNames.has(packageName) || seenPackageDirs.has(packageDir)) {
|
|
271
|
+
if (seenPackageNames.has(packageName) || seenPackageDirs.has(resolved.dir)) {
|
|
417
272
|
continue;
|
|
418
273
|
}
|
|
419
|
-
const pluginFlags = readPluginPackageFlags(
|
|
274
|
+
const pluginFlags = readPluginPackageFlags(resolved.dir);
|
|
420
275
|
if (!pluginFlags) {
|
|
421
276
|
continue;
|
|
422
277
|
}
|
|
423
278
|
seenPackageNames.add(packageName);
|
|
424
|
-
seenPackageDirs.add(
|
|
279
|
+
seenPackageDirs.add(resolved.dir);
|
|
425
280
|
discovered.push({
|
|
426
281
|
name: packageName,
|
|
427
|
-
dir:
|
|
428
|
-
nodeModulesDir: resolved
|
|
282
|
+
dir: resolved.dir,
|
|
283
|
+
nodeModulesDir: resolved.nodeModulesDir,
|
|
429
284
|
...pluginFlags
|
|
430
285
|
});
|
|
431
286
|
}
|
|
432
287
|
return discovered;
|
|
433
288
|
}
|
|
434
|
-
function discoverInstalledJuniorContentPackages(cwd = process.cwd(), nodeModulesDirs, packageNames) {
|
|
435
|
-
const resolvedCwd = path2.resolve(cwd);
|
|
436
|
-
const candidateNodeModulesDirs = nodeModulesDirs ?? discoverNodeModulesDirs(resolvedCwd);
|
|
437
|
-
const configuredPackageNames = packageNames ?? readNextRuntimeConfiguredPackageNames();
|
|
438
|
-
const declaredPackages = discoverDeclaredPackages(
|
|
439
|
-
resolvedCwd,
|
|
440
|
-
configuredPackageNames ?? [],
|
|
441
|
-
candidateNodeModulesDirs
|
|
442
|
-
);
|
|
443
|
-
const useFallbackScan = configuredPackageNames === null;
|
|
444
|
-
const discovered = [...declaredPackages];
|
|
445
|
-
const seenPackageNames = /* @__PURE__ */ new Set();
|
|
446
|
-
const seenPackageDirs = /* @__PURE__ */ new Set();
|
|
447
|
-
for (const pkg of declaredPackages) {
|
|
448
|
-
seenPackageNames.add(pkg.name);
|
|
449
|
-
seenPackageDirs.add(pkg.dir);
|
|
450
|
-
}
|
|
451
|
-
if (!useFallbackScan) {
|
|
452
|
-
return discovered;
|
|
453
|
-
}
|
|
454
|
-
for (const nodeModulesDir of candidateNodeModulesDirs) {
|
|
455
|
-
for (const pkg of listTopLevelPackages(nodeModulesDir)) {
|
|
456
|
-
const resolvedDir = path2.resolve(pkg.dir);
|
|
457
|
-
if (seenPackageNames.has(pkg.name) || seenPackageDirs.has(resolvedDir)) {
|
|
458
|
-
continue;
|
|
459
|
-
}
|
|
460
|
-
seenPackageNames.add(pkg.name);
|
|
461
|
-
seenPackageDirs.add(resolvedDir);
|
|
462
|
-
const hasRootPluginManifest = isFile(
|
|
463
|
-
path2.join(resolvedDir, "plugin.yaml")
|
|
464
|
-
);
|
|
465
|
-
const hasPluginsDir = isDirectory(path2.join(resolvedDir, "plugins"));
|
|
466
|
-
const hasSkillsDir = isDirectory(path2.join(resolvedDir, "skills"));
|
|
467
|
-
if (!hasRootPluginManifest && !hasPluginsDir && !hasSkillsDir) {
|
|
468
|
-
continue;
|
|
469
|
-
}
|
|
470
|
-
discovered.push({
|
|
471
|
-
name: pkg.name,
|
|
472
|
-
dir: resolvedDir,
|
|
473
|
-
nodeModulesDir: path2.resolve(nodeModulesDir),
|
|
474
|
-
hasRootPluginManifest,
|
|
475
|
-
hasPluginsDir,
|
|
476
|
-
hasSkillsDir
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
return discovered;
|
|
481
|
-
}
|
|
482
289
|
function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
483
290
|
const resolvedCwd = path2.resolve(cwd);
|
|
484
|
-
const
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
);
|
|
490
|
-
const workspacePluginDirs = discoverWorkspacePluginPackageDirs(
|
|
491
|
-
resolvedCwd,
|
|
492
|
-
configuredPackageNames
|
|
291
|
+
const packageNames = options?.packageNames ?? configuredPluginPackages ?? [];
|
|
292
|
+
const nodeModulesDirs = options?.nodeModulesDirs ?? discoverNodeModulesDirs(resolvedCwd);
|
|
293
|
+
const discoveredPackages = discoverDeclaredPackages(
|
|
294
|
+
packageNames,
|
|
295
|
+
nodeModulesDirs
|
|
493
296
|
);
|
|
494
297
|
const manifestRoots = [];
|
|
495
298
|
const skillRoots2 = [];
|
|
@@ -518,27 +321,6 @@ function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
|
518
321
|
}
|
|
519
322
|
}
|
|
520
323
|
}
|
|
521
|
-
for (const pluginDir of workspacePluginDirs) {
|
|
522
|
-
const tracingBasePath = pathForTracingInclude(resolvedCwd, pluginDir);
|
|
523
|
-
if (isFile(path2.join(pluginDir, "plugin.yaml"))) {
|
|
524
|
-
manifestRoots.push(pluginDir);
|
|
525
|
-
if (tracingBasePath) {
|
|
526
|
-
tracingIncludes.push(`${tracingBasePath}/plugin.yaml`);
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
if (isDirectory(path2.join(pluginDir, "plugins"))) {
|
|
530
|
-
manifestRoots.push(path2.join(pluginDir, "plugins"));
|
|
531
|
-
if (tracingBasePath) {
|
|
532
|
-
tracingIncludes.push(`${tracingBasePath}/plugins/**/*`);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
if (isDirectory(path2.join(pluginDir, "skills"))) {
|
|
536
|
-
skillRoots2.push(path2.join(pluginDir, "skills"));
|
|
537
|
-
if (tracingBasePath) {
|
|
538
|
-
tracingIncludes.push(`${tracingBasePath}/skills/**/*`);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
324
|
return {
|
|
543
325
|
packageNames: uniqueStringsInOrder(
|
|
544
326
|
discoveredPackages.map((pkg) => pkg.name)
|
package/dist/cli/check.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseSkillFile
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-KTBQH6L5.js";
|
|
4
4
|
import {
|
|
5
5
|
parsePluginManifest
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-5JHLDXBN.js";
|
|
7
7
|
import "../chunk-Z3YD6NHK.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-RBB2MZAN.js";
|
|
9
9
|
import "../chunk-2KG3PWR4.js";
|
|
10
10
|
|
|
11
11
|
// src/cli/check.ts
|
package/dist/cli/init.js
CHANGED
|
@@ -20,10 +20,16 @@ export default app;
|
|
|
20
20
|
function writeNitroConfig(targetDir) {
|
|
21
21
|
fs.writeFileSync(
|
|
22
22
|
path.join(targetDir, "nitro.config.ts"),
|
|
23
|
-
`import {
|
|
24
|
-
import {
|
|
23
|
+
`import { defineConfig } from "nitro";
|
|
24
|
+
import { juniorNitro } from "@sentry/junior/nitro";
|
|
25
25
|
|
|
26
|
-
export default defineConfig(
|
|
26
|
+
export default defineConfig({
|
|
27
|
+
preset: "vercel",
|
|
28
|
+
modules: [juniorNitro()],
|
|
29
|
+
routes: {
|
|
30
|
+
"/api/**": { handler: "./server.ts" },
|
|
31
|
+
},
|
|
32
|
+
});
|
|
27
33
|
`
|
|
28
34
|
);
|
|
29
35
|
}
|
|
@@ -45,7 +51,7 @@ export default defineConfig({
|
|
|
45
51
|
function writeVercelJson(targetDir) {
|
|
46
52
|
fs.writeFileSync(
|
|
47
53
|
path.join(targetDir, "vercel.json"),
|
|
48
|
-
`${JSON.stringify({ buildCommand: "pnpm build" }, null, 2)}
|
|
54
|
+
`${JSON.stringify({ framework: "nitro", buildCommand: "pnpm build" }, null, 2)}
|
|
49
55
|
`
|
|
50
56
|
);
|
|
51
57
|
}
|
|
@@ -82,6 +88,7 @@ async function runInit(dir, log = console.log) {
|
|
|
82
88
|
hono: "^4.12.0"
|
|
83
89
|
},
|
|
84
90
|
devDependencies: {
|
|
91
|
+
jiti: "^2.6.1",
|
|
85
92
|
nitro: "3.0.260311-beta",
|
|
86
93
|
typescript: "^5.9.0",
|
|
87
94
|
vite: "^8.0.3"
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
disconnectStateAdapter,
|
|
3
3
|
resolveRuntimeDependencySnapshot
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-ESPIOJPM.js";
|
|
5
5
|
import {
|
|
6
6
|
getPluginProviders,
|
|
7
7
|
getPluginRuntimeDependencies,
|
|
8
8
|
getPluginRuntimePostinstall
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-5JHLDXBN.js";
|
|
10
10
|
import "../chunk-Z3YD6NHK.js";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-RBB2MZAN.js";
|
|
12
12
|
import "../chunk-2KG3PWR4.js";
|
|
13
13
|
|
|
14
14
|
// src/cli/snapshot-warmup.ts
|
package/dist/nitro.d.ts
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface JuniorNitroOptions {
|
|
2
2
|
cwd?: string;
|
|
3
3
|
maxDuration?: number;
|
|
4
|
+
pluginPackages?: string[];
|
|
5
|
+
/**
|
|
6
|
+
* Extra file patterns to copy into the server output for files that the
|
|
7
|
+
* bundler cannot trace (e.g. dynamically imported providers).
|
|
8
|
+
* Each entry is `"<package-name>/<subpath-glob>"`, resolved via Node
|
|
9
|
+
* module resolution. Example: `"@mariozechner/pi-ai/dist/providers/*.js"`
|
|
10
|
+
*/
|
|
11
|
+
includeFiles?: string[];
|
|
4
12
|
}
|
|
5
|
-
/**
|
|
6
|
-
declare function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
functions: {
|
|
10
|
-
maxDuration: number;
|
|
11
|
-
};
|
|
13
|
+
/** Nitro module that copies app and plugin content into the Vercel build output. */
|
|
14
|
+
declare function juniorNitro(options?: JuniorNitroOptions): {
|
|
15
|
+
nitro: {
|
|
16
|
+
setup(nitro: unknown): void;
|
|
12
17
|
};
|
|
13
|
-
modules: {
|
|
14
|
-
setup(nitro: {
|
|
15
|
-
hooks: {
|
|
16
|
-
hook(name: "compiled", callback: () => void): void;
|
|
17
|
-
};
|
|
18
|
-
options: {
|
|
19
|
-
output: {
|
|
20
|
-
serverDir: string;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
}): void;
|
|
24
|
-
}[];
|
|
25
18
|
};
|
|
26
19
|
|
|
27
|
-
export { type
|
|
20
|
+
export { type JuniorNitroOptions, juniorNitro };
|
package/dist/nitro.js
CHANGED
|
@@ -1,14 +1,43 @@
|
|
|
1
1
|
import {
|
|
2
2
|
discoverInstalledPluginPackageContent
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RBB2MZAN.js";
|
|
4
4
|
import "./chunk-2KG3PWR4.js";
|
|
5
5
|
|
|
6
6
|
// src/nitro.ts
|
|
7
|
-
import { cpSync, existsSync, mkdirSync } from "fs";
|
|
7
|
+
import { cpSync, existsSync, mkdirSync, readdirSync } from "fs";
|
|
8
8
|
import path from "path";
|
|
9
|
-
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
function juniorNitro(options = {}) {
|
|
11
|
+
return {
|
|
12
|
+
nitro: {
|
|
13
|
+
setup(nitro) {
|
|
14
|
+
const cwd = path.resolve(
|
|
15
|
+
options.cwd ?? nitro.options.rootDir ?? process.cwd()
|
|
16
|
+
);
|
|
17
|
+
nitro.options.vercel ??= {};
|
|
18
|
+
nitro.options.vercel.functions ??= {};
|
|
19
|
+
nitro.options.vercel.functions.maxDuration ??= options.maxDuration ?? 800;
|
|
20
|
+
nitro.options.virtual["#junior/config"] = `export const pluginPackages = ${JSON.stringify(options.pluginPackages ?? [])};`;
|
|
21
|
+
nitro.hooks.hook("compiled", () => {
|
|
22
|
+
copyAppAndPluginContent(
|
|
23
|
+
cwd,
|
|
24
|
+
nitro.options.output.serverDir,
|
|
25
|
+
options.pluginPackages
|
|
26
|
+
);
|
|
27
|
+
copyIncludedFiles(
|
|
28
|
+
nitro.options.output.serverDir,
|
|
29
|
+
options.includeFiles
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function copyAppAndPluginContent(cwd, serverRoot, pluginPackages) {
|
|
10
37
|
copyIfExists(path.join(cwd, "app"), path.join(serverRoot, "app"));
|
|
11
|
-
const packagedContent = discoverInstalledPluginPackageContent(cwd
|
|
38
|
+
const packagedContent = discoverInstalledPluginPackageContent(cwd, {
|
|
39
|
+
packageNames: pluginPackages
|
|
40
|
+
});
|
|
12
41
|
for (const root of packagedContent.manifestRoots) {
|
|
13
42
|
if (existsSync(path.join(root, "plugin.yaml"))) {
|
|
14
43
|
const relative = path.relative(cwd, root);
|
|
@@ -27,6 +56,45 @@ function copyAppAndPluginContent(cwd, serverRoot) {
|
|
|
27
56
|
copyRootIntoServerOutput(cwd, serverRoot, root);
|
|
28
57
|
}
|
|
29
58
|
}
|
|
59
|
+
function resolvePackageDir(pkgName) {
|
|
60
|
+
try {
|
|
61
|
+
const resolved = import.meta.resolve(pkgName);
|
|
62
|
+
const entry = resolved.startsWith("file://") ? fileURLToPath(resolved) : resolved;
|
|
63
|
+
let dir = path.dirname(entry);
|
|
64
|
+
while (dir !== path.dirname(dir)) {
|
|
65
|
+
if (existsSync(path.join(dir, "package.json"))) return dir;
|
|
66
|
+
dir = path.dirname(dir);
|
|
67
|
+
}
|
|
68
|
+
} catch {
|
|
69
|
+
}
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
72
|
+
function copyIncludedFiles(serverRoot, patterns) {
|
|
73
|
+
if (!patterns?.length) return;
|
|
74
|
+
for (const pattern of patterns) {
|
|
75
|
+
const normalized = pattern.replace(/^node_modules\//, "");
|
|
76
|
+
const parts = normalized.split("/");
|
|
77
|
+
const pkgName = parts[0].startsWith("@") ? `${parts[0]}/${parts[1]}` : parts[0];
|
|
78
|
+
const subpath = parts.slice(pkgName.includes("/") ? 2 : 1).join("/");
|
|
79
|
+
const fileGlob = path.basename(subpath);
|
|
80
|
+
const subDir = path.dirname(subpath);
|
|
81
|
+
const pkgDir = resolvePackageDir(pkgName);
|
|
82
|
+
if (!pkgDir) continue;
|
|
83
|
+
const sourceDir = path.join(pkgDir, subDir);
|
|
84
|
+
if (!existsSync(sourceDir)) continue;
|
|
85
|
+
const entries = readdirSync(sourceDir);
|
|
86
|
+
const re = fileGlob.includes("*") ? new RegExp(
|
|
87
|
+
`^${fileGlob.replace(/[\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*")}$`
|
|
88
|
+
) : null;
|
|
89
|
+
for (const entry of entries) {
|
|
90
|
+
if (re ? !re.test(entry) : entry !== fileGlob) continue;
|
|
91
|
+
copyIfExists(
|
|
92
|
+
path.join(sourceDir, entry),
|
|
93
|
+
path.join(serverRoot, "node_modules", pkgName, subDir, entry)
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
30
98
|
function copyIfExists(source, target) {
|
|
31
99
|
if (!existsSync(source)) {
|
|
32
100
|
return;
|
|
@@ -41,26 +109,6 @@ function copyRootIntoServerOutput(cwd, serverRoot, root) {
|
|
|
41
109
|
}
|
|
42
110
|
copyIfExists(root, path.join(serverRoot, relative));
|
|
43
111
|
}
|
|
44
|
-
function juniorNitroConfig(options = {}) {
|
|
45
|
-
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
46
|
-
return {
|
|
47
|
-
preset: "vercel",
|
|
48
|
-
vercel: {
|
|
49
|
-
functions: {
|
|
50
|
-
maxDuration: options.maxDuration ?? 800
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
modules: [
|
|
54
|
-
{
|
|
55
|
-
setup(nitro) {
|
|
56
|
-
nitro.hooks.hook("compiled", () => {
|
|
57
|
-
copyAppAndPluginContent(cwd, nitro.options.output.serverDir);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
112
|
export {
|
|
65
|
-
|
|
113
|
+
juniorNitro
|
|
66
114
|
};
|
package/dist/vercel.js
CHANGED
|
@@ -3,7 +3,9 @@ import "./chunk-2KG3PWR4.js";
|
|
|
3
3
|
// src/vercel.ts
|
|
4
4
|
function juniorVercelConfig(options = {}) {
|
|
5
5
|
const buildCommand = options.buildCommand === void 0 ? "pnpm build" : options.buildCommand;
|
|
6
|
-
const config = {
|
|
6
|
+
const config = {
|
|
7
|
+
framework: "nitro"
|
|
8
|
+
};
|
|
7
9
|
if (buildCommand !== null) {
|
|
8
10
|
config.buildCommand = buildCommand;
|
|
9
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@sentry/node": "^10.46.0",
|
|
48
48
|
"@types/node": "^25.5.0",
|
|
49
49
|
"msw": "^2.12.14",
|
|
50
|
+
"nitro": "3.0.260311-beta",
|
|
50
51
|
"tsup": "^8.5.1",
|
|
51
52
|
"typescript": "^5.9.3",
|
|
52
53
|
"vercel": "^50.37.3",
|