@sentry/junior 0.12.1 → 0.14.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 +11 -17
- package/dist/{chunk-Y2LVMCQ3.js → chunk-5JHLDXBN.js} +38 -591
- package/dist/{chunk-SCG4PCEG.js → chunk-ESPIOJPM.js} +11 -2
- package/dist/{chunk-IH4T747D.js → chunk-KTBQH6L5.js} +4 -2
- package/dist/chunk-RBB2MZAN.js +342 -0
- package/dist/cli/check.js +3 -2
- package/dist/cli/init.js +42 -11
- package/dist/cli/snapshot-warmup.js +3 -2
- package/dist/nitro.d.ts +13 -0
- package/dist/nitro.js +69 -0
- package/dist/vercel.d.ts +2 -8
- package/dist/vercel.js +12 -5
- package/package.json +3 -1
- package/dist/chunk-ZLVM4R7R.js +0 -25
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
getPluginRuntimeDependencies,
|
|
3
3
|
getPluginRuntimePostinstall,
|
|
4
4
|
withSpan
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5JHLDXBN.js";
|
|
6
6
|
|
|
7
7
|
// src/chat/state/adapter.ts
|
|
8
8
|
import { createMemoryState } from "@chat-adapter/state-memory";
|
|
@@ -176,7 +176,16 @@ var NON_INTERACTIVE_ENV = {
|
|
|
176
176
|
GH_SPINNER_DISABLED: "1",
|
|
177
177
|
GIT_TERMINAL_PROMPT: "0",
|
|
178
178
|
GCM_INTERACTIVE: "never",
|
|
179
|
-
DEBIAN_FRONTEND: "noninteractive"
|
|
179
|
+
DEBIAN_FRONTEND: "noninteractive",
|
|
180
|
+
// Git credential isolation: prevent git from sending its own auth so the
|
|
181
|
+
// sandbox network proxy's header transforms are the sole credential source.
|
|
182
|
+
GIT_ASKPASS: "/bin/true",
|
|
183
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
184
|
+
GIT_CONFIG_COUNT: "2",
|
|
185
|
+
GIT_CONFIG_KEY_0: "credential.helper",
|
|
186
|
+
GIT_CONFIG_VALUE_0: "",
|
|
187
|
+
GIT_CONFIG_KEY_1: "http.emptyAuth",
|
|
188
|
+
GIT_CONFIG_VALUE_1: "true"
|
|
180
189
|
};
|
|
181
190
|
function shellQuote(value) {
|
|
182
191
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
@@ -4,9 +4,11 @@ import {
|
|
|
4
4
|
getPluginForSkillPath,
|
|
5
5
|
getPluginSkillRoots,
|
|
6
6
|
logInfo,
|
|
7
|
-
logWarn
|
|
7
|
+
logWarn
|
|
8
|
+
} from "./chunk-5JHLDXBN.js";
|
|
9
|
+
import {
|
|
8
10
|
skillRoots
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-RBB2MZAN.js";
|
|
10
12
|
|
|
11
13
|
// src/chat/skills.ts
|
|
12
14
|
import fs from "fs/promises";
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
// src/chat/plugins/package-discovery.ts
|
|
2
|
+
import path2 from "path";
|
|
3
|
+
|
|
4
|
+
// src/chat/discovery.ts
|
|
5
|
+
import fs, { statSync } from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
function isDirectory(targetPath) {
|
|
9
|
+
try {
|
|
10
|
+
return statSync(targetPath).isDirectory();
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function isFile(targetPath) {
|
|
16
|
+
try {
|
|
17
|
+
return statSync(targetPath).isFile();
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function normalizePath(targetPath) {
|
|
23
|
+
return path.resolve(targetPath);
|
|
24
|
+
}
|
|
25
|
+
function uniqueResolvedPathsInOrder(values) {
|
|
26
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27
|
+
const resolved = [];
|
|
28
|
+
for (const value of values) {
|
|
29
|
+
const normalized = normalizePath(value);
|
|
30
|
+
if (seen.has(normalized)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
seen.add(normalized);
|
|
34
|
+
resolved.push(normalized);
|
|
35
|
+
}
|
|
36
|
+
return resolved;
|
|
37
|
+
}
|
|
38
|
+
function isNodeModulesPath(candidatePath) {
|
|
39
|
+
return path.basename(candidatePath) === "node_modules";
|
|
40
|
+
}
|
|
41
|
+
function isInsidePnpmStore(candidatePath) {
|
|
42
|
+
return candidatePath.split(path.sep).includes(".pnpm");
|
|
43
|
+
}
|
|
44
|
+
function runningFromInstalledPackage() {
|
|
45
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
46
|
+
const marker = `${path.sep}node_modules${path.sep}@sentry${path.sep}junior${path.sep}`;
|
|
47
|
+
return currentFile.includes(marker);
|
|
48
|
+
}
|
|
49
|
+
function listInstalledPackageNodeModulesDirs() {
|
|
50
|
+
if (!runningFromInstalledPackage()) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const dirs = [];
|
|
54
|
+
let current = path.resolve(path.dirname(fileURLToPath(import.meta.url)));
|
|
55
|
+
while (true) {
|
|
56
|
+
if (isNodeModulesPath(current) && !isInsidePnpmStore(current) && isDirectory(current)) {
|
|
57
|
+
dirs.push(current);
|
|
58
|
+
}
|
|
59
|
+
const parent = path.dirname(current);
|
|
60
|
+
if (parent === current) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
current = parent;
|
|
64
|
+
}
|
|
65
|
+
return dirs;
|
|
66
|
+
}
|
|
67
|
+
function listCwdAncestorNodeModulesDirs(cwd) {
|
|
68
|
+
const resolvedCwd = normalizePath(cwd);
|
|
69
|
+
const dirs = [];
|
|
70
|
+
let current = resolvedCwd;
|
|
71
|
+
while (true) {
|
|
72
|
+
const nodeModulesDir = path.join(current, "node_modules");
|
|
73
|
+
if (isDirectory(nodeModulesDir)) {
|
|
74
|
+
dirs.push(nodeModulesDir);
|
|
75
|
+
}
|
|
76
|
+
if (isFile(path.join(current, "package.json"))) {
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
const parent = path.dirname(current);
|
|
80
|
+
if (parent === current) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
current = parent;
|
|
84
|
+
}
|
|
85
|
+
return dirs;
|
|
86
|
+
}
|
|
87
|
+
function discoverNodeModulesDirs(cwd = process.cwd(), options) {
|
|
88
|
+
const explicit = options?.candidateDirs?.filter((dir) => isDirectory(dir)) ?? [];
|
|
89
|
+
if (explicit.length > 0) {
|
|
90
|
+
return uniqueResolvedPathsInOrder(explicit);
|
|
91
|
+
}
|
|
92
|
+
return uniqueResolvedPathsInOrder([
|
|
93
|
+
...listInstalledPackageNodeModulesDirs(),
|
|
94
|
+
...listCwdAncestorNodeModulesDirs(cwd)
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
function discoverProjectRoots(cwd = process.cwd(), options) {
|
|
98
|
+
const roots = discoverNodeModulesDirs(
|
|
99
|
+
cwd,
|
|
100
|
+
options?.nodeModulesDirs ? { candidateDirs: options.nodeModulesDirs } : void 0
|
|
101
|
+
).map((nodeModulesDir) => path.dirname(nodeModulesDir));
|
|
102
|
+
return uniqueResolvedPathsInOrder([cwd, ...roots]);
|
|
103
|
+
}
|
|
104
|
+
function unique(values) {
|
|
105
|
+
return [...new Set(values)];
|
|
106
|
+
}
|
|
107
|
+
function pathExists(targetPath) {
|
|
108
|
+
try {
|
|
109
|
+
fs.accessSync(targetPath);
|
|
110
|
+
return true;
|
|
111
|
+
} catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function hasAnyDataMarkers(appDir) {
|
|
116
|
+
return pathExists(path.join(appDir, "SOUL.md")) || pathExists(path.join(appDir, "ABOUT.md"));
|
|
117
|
+
}
|
|
118
|
+
function scoreAppCandidate(appDir) {
|
|
119
|
+
let score = 0;
|
|
120
|
+
if (pathExists(path.join(appDir, "SOUL.md"))) {
|
|
121
|
+
score += 4;
|
|
122
|
+
}
|
|
123
|
+
if (pathExists(path.join(appDir, "ABOUT.md"))) {
|
|
124
|
+
score += 2;
|
|
125
|
+
}
|
|
126
|
+
if (pathExists(path.join(appDir, "skills"))) {
|
|
127
|
+
score += 1;
|
|
128
|
+
}
|
|
129
|
+
if (pathExists(path.join(appDir, "plugins"))) {
|
|
130
|
+
score += 1;
|
|
131
|
+
}
|
|
132
|
+
return score;
|
|
133
|
+
}
|
|
134
|
+
function resolveCandidateAppDirs(cwd, projectRoots) {
|
|
135
|
+
const roots = projectRoots ?? discoverProjectRoots(cwd);
|
|
136
|
+
const resolved = [];
|
|
137
|
+
const seen = /* @__PURE__ */ new Set();
|
|
138
|
+
for (const root of roots) {
|
|
139
|
+
const appDir = path.resolve(root, "app");
|
|
140
|
+
if (!pathExists(appDir)) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (seen.has(appDir)) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
seen.add(appDir);
|
|
147
|
+
resolved.push(appDir);
|
|
148
|
+
}
|
|
149
|
+
return resolved;
|
|
150
|
+
}
|
|
151
|
+
function homeDir() {
|
|
152
|
+
return resolveHomeDir();
|
|
153
|
+
}
|
|
154
|
+
function resolveHomeDir(cwd = process.cwd(), options) {
|
|
155
|
+
const resolvedCwd = path.resolve(cwd);
|
|
156
|
+
const directApp = path.resolve(resolvedCwd, "app");
|
|
157
|
+
if (pathExists(directApp) && hasAnyDataMarkers(directApp)) {
|
|
158
|
+
return directApp;
|
|
159
|
+
}
|
|
160
|
+
const candidates = resolveCandidateAppDirs(
|
|
161
|
+
resolvedCwd,
|
|
162
|
+
options?.projectRoots
|
|
163
|
+
);
|
|
164
|
+
if (candidates.length === 0) {
|
|
165
|
+
return directApp;
|
|
166
|
+
}
|
|
167
|
+
candidates.sort((left, right) => {
|
|
168
|
+
const leftScore = scoreAppCandidate(left);
|
|
169
|
+
const rightScore = scoreAppCandidate(right);
|
|
170
|
+
if (leftScore !== rightScore) {
|
|
171
|
+
return rightScore - leftScore;
|
|
172
|
+
}
|
|
173
|
+
const leftDistance = path.relative(resolvedCwd, left).split(path.sep).length;
|
|
174
|
+
const rightDistance = path.relative(resolvedCwd, right).split(path.sep).length;
|
|
175
|
+
if (leftDistance !== rightDistance) {
|
|
176
|
+
return leftDistance - rightDistance;
|
|
177
|
+
}
|
|
178
|
+
return left.localeCompare(right);
|
|
179
|
+
});
|
|
180
|
+
return candidates[0];
|
|
181
|
+
}
|
|
182
|
+
function resolveContentRoots(subdir) {
|
|
183
|
+
if (subdir === "data") {
|
|
184
|
+
return [homeDir()];
|
|
185
|
+
}
|
|
186
|
+
return [path.join(homeDir(), subdir)];
|
|
187
|
+
}
|
|
188
|
+
function dataRoots() {
|
|
189
|
+
return unique(resolveContentRoots("data"));
|
|
190
|
+
}
|
|
191
|
+
function skillRoots() {
|
|
192
|
+
return unique(resolveContentRoots("skills"));
|
|
193
|
+
}
|
|
194
|
+
function pluginRoots() {
|
|
195
|
+
return unique(resolveContentRoots("plugins"));
|
|
196
|
+
}
|
|
197
|
+
function soulPathCandidates() {
|
|
198
|
+
const candidates = dataRoots().map((root) => path.join(root, "SOUL.md"));
|
|
199
|
+
return unique(candidates);
|
|
200
|
+
}
|
|
201
|
+
function aboutPathCandidates() {
|
|
202
|
+
const candidates = dataRoots().map((root) => path.join(root, "ABOUT.md"));
|
|
203
|
+
return unique(candidates);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/chat/plugins/package-discovery.ts
|
|
207
|
+
function normalizeForGlob(targetPath) {
|
|
208
|
+
return targetPath.split(path2.sep).join("/");
|
|
209
|
+
}
|
|
210
|
+
function uniqueStringsInOrder(values) {
|
|
211
|
+
const seen = /* @__PURE__ */ new Set();
|
|
212
|
+
const resolved = [];
|
|
213
|
+
for (const value of values) {
|
|
214
|
+
if (seen.has(value)) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
seen.add(value);
|
|
218
|
+
resolved.push(value);
|
|
219
|
+
}
|
|
220
|
+
return resolved;
|
|
221
|
+
}
|
|
222
|
+
function pathForTracingInclude(cwd, targetPath) {
|
|
223
|
+
const relative = path2.relative(cwd, targetPath);
|
|
224
|
+
if (!relative || path2.isAbsolute(relative)) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const normalized = normalizeForGlob(relative);
|
|
228
|
+
return normalized.startsWith(".") ? normalized : `./${normalized}`;
|
|
229
|
+
}
|
|
230
|
+
var configuredPluginPackages;
|
|
231
|
+
function setPluginPackages(packages) {
|
|
232
|
+
configuredPluginPackages = packages;
|
|
233
|
+
}
|
|
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
|
+
};
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
function readPluginPackageFlags(dir) {
|
|
247
|
+
const hasRootPluginManifest = isFile(path2.join(dir, "plugin.yaml"));
|
|
248
|
+
const hasPluginsDir = isDirectory(path2.join(dir, "plugins"));
|
|
249
|
+
const hasSkillsDir = isDirectory(path2.join(dir, "skills"));
|
|
250
|
+
if (!hasRootPluginManifest && !hasPluginsDir && !hasSkillsDir) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
hasRootPluginManifest,
|
|
255
|
+
hasPluginsDir,
|
|
256
|
+
hasSkillsDir
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function discoverDeclaredPackages(packageNames, candidateNodeModulesDirs) {
|
|
260
|
+
const discovered = [];
|
|
261
|
+
const seenPackageNames = /* @__PURE__ */ new Set();
|
|
262
|
+
const seenPackageDirs = /* @__PURE__ */ new Set();
|
|
263
|
+
for (const packageName of packageNames) {
|
|
264
|
+
const resolved = resolvePackageDirFromName(
|
|
265
|
+
packageName,
|
|
266
|
+
candidateNodeModulesDirs
|
|
267
|
+
);
|
|
268
|
+
if (!resolved) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (seenPackageNames.has(packageName) || seenPackageDirs.has(resolved.dir)) {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const pluginFlags = readPluginPackageFlags(resolved.dir);
|
|
275
|
+
if (!pluginFlags) {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
seenPackageNames.add(packageName);
|
|
279
|
+
seenPackageDirs.add(resolved.dir);
|
|
280
|
+
discovered.push({
|
|
281
|
+
name: packageName,
|
|
282
|
+
dir: resolved.dir,
|
|
283
|
+
nodeModulesDir: resolved.nodeModulesDir,
|
|
284
|
+
...pluginFlags
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
return discovered;
|
|
288
|
+
}
|
|
289
|
+
function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
|
|
290
|
+
const resolvedCwd = path2.resolve(cwd);
|
|
291
|
+
const packageNames = options?.packageNames ?? configuredPluginPackages ?? [];
|
|
292
|
+
const nodeModulesDirs = options?.nodeModulesDirs ?? discoverNodeModulesDirs(resolvedCwd);
|
|
293
|
+
const discoveredPackages = discoverDeclaredPackages(
|
|
294
|
+
packageNames,
|
|
295
|
+
nodeModulesDirs
|
|
296
|
+
);
|
|
297
|
+
const manifestRoots = [];
|
|
298
|
+
const skillRoots2 = [];
|
|
299
|
+
const tracingIncludes = [];
|
|
300
|
+
for (const pkg of discoveredPackages) {
|
|
301
|
+
const tracingBasePath = pkg.nodeModulesDir ? pathForTracingInclude(
|
|
302
|
+
resolvedCwd,
|
|
303
|
+
path2.join(pkg.nodeModulesDir, ...pkg.name.split("/"))
|
|
304
|
+
) : pathForTracingInclude(resolvedCwd, pkg.dir);
|
|
305
|
+
if (pkg.hasRootPluginManifest) {
|
|
306
|
+
manifestRoots.push(pkg.dir);
|
|
307
|
+
if (tracingBasePath) {
|
|
308
|
+
tracingIncludes.push(`${tracingBasePath}/plugin.yaml`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (pkg.hasPluginsDir) {
|
|
312
|
+
manifestRoots.push(path2.join(pkg.dir, "plugins"));
|
|
313
|
+
if (tracingBasePath) {
|
|
314
|
+
tracingIncludes.push(`${tracingBasePath}/plugins/**/*`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (pkg.hasSkillsDir) {
|
|
318
|
+
skillRoots2.push(path2.join(pkg.dir, "skills"));
|
|
319
|
+
if (tracingBasePath) {
|
|
320
|
+
tracingIncludes.push(`${tracingBasePath}/skills/**/*`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return {
|
|
325
|
+
packageNames: uniqueStringsInOrder(
|
|
326
|
+
discoveredPackages.map((pkg) => pkg.name)
|
|
327
|
+
),
|
|
328
|
+
manifestRoots: uniqueStringsInOrder(manifestRoots),
|
|
329
|
+
skillRoots: uniqueStringsInOrder(skillRoots2),
|
|
330
|
+
tracingIncludes: uniqueStringsInOrder(tracingIncludes)
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export {
|
|
335
|
+
homeDir,
|
|
336
|
+
skillRoots,
|
|
337
|
+
pluginRoots,
|
|
338
|
+
soulPathCandidates,
|
|
339
|
+
aboutPathCandidates,
|
|
340
|
+
setPluginPackages,
|
|
341
|
+
discoverInstalledPluginPackageContent
|
|
342
|
+
};
|
package/dist/cli/check.js
CHANGED
|
@@ -1,10 +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-RBB2MZAN.js";
|
|
8
9
|
import "../chunk-2KG3PWR4.js";
|
|
9
10
|
|
|
10
11
|
// src/cli/check.ts
|
package/dist/cli/init.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
juniorVercelConfig
|
|
3
|
-
} from "../chunk-ZLVM4R7R.js";
|
|
4
1
|
import "../chunk-2KG3PWR4.js";
|
|
5
2
|
|
|
6
3
|
// src/cli/init.ts
|
|
@@ -9,9 +6,7 @@ import path from "path";
|
|
|
9
6
|
function writeServerEntry(targetDir) {
|
|
10
7
|
fs.writeFileSync(
|
|
11
8
|
path.join(targetDir, "server.ts"),
|
|
12
|
-
|
|
13
|
-
import "hono";
|
|
14
|
-
import { initSentry } from "@sentry/junior/instrumentation";
|
|
9
|
+
`import { initSentry } from "@sentry/junior/instrumentation";
|
|
15
10
|
initSentry();
|
|
16
11
|
|
|
17
12
|
import { createApp } from "@sentry/junior";
|
|
@@ -22,11 +17,41 @@ export default app;
|
|
|
22
17
|
`
|
|
23
18
|
);
|
|
24
19
|
}
|
|
20
|
+
function writeNitroConfig(targetDir) {
|
|
21
|
+
fs.writeFileSync(
|
|
22
|
+
path.join(targetDir, "nitro.config.ts"),
|
|
23
|
+
`import { defineConfig } from "nitro";
|
|
24
|
+
import { juniorNitro } from "@sentry/junior/nitro";
|
|
25
|
+
|
|
26
|
+
export default defineConfig({
|
|
27
|
+
preset: "vercel",
|
|
28
|
+
modules: [juniorNitro()],
|
|
29
|
+
routes: {
|
|
30
|
+
"/api/**": { handler: "./server.ts" },
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
function writeViteConfig(targetDir) {
|
|
37
|
+
fs.writeFileSync(
|
|
38
|
+
path.join(targetDir, "vite.config.ts"),
|
|
39
|
+
`import { defineConfig } from "vite";
|
|
40
|
+
import { nitro } from "nitro/vite";
|
|
41
|
+
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
server: {
|
|
44
|
+
allowedHosts: true,
|
|
45
|
+
},
|
|
46
|
+
plugins: [nitro()],
|
|
47
|
+
});
|
|
48
|
+
`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
25
51
|
function writeVercelJson(targetDir) {
|
|
26
|
-
const config = juniorVercelConfig();
|
|
27
52
|
fs.writeFileSync(
|
|
28
53
|
path.join(targetDir, "vercel.json"),
|
|
29
|
-
`${JSON.stringify(
|
|
54
|
+
`${JSON.stringify({ framework: "nitro", buildCommand: "pnpm build" }, null, 2)}
|
|
30
55
|
`
|
|
31
56
|
);
|
|
32
57
|
}
|
|
@@ -54,7 +79,8 @@ async function runInit(dir, log = console.log) {
|
|
|
54
79
|
private: true,
|
|
55
80
|
type: "module",
|
|
56
81
|
scripts: {
|
|
57
|
-
|
|
82
|
+
dev: "vite dev",
|
|
83
|
+
build: "junior snapshot create && vite build"
|
|
58
84
|
},
|
|
59
85
|
dependencies: {
|
|
60
86
|
"@sentry/junior": "latest",
|
|
@@ -62,8 +88,9 @@ async function runInit(dir, log = console.log) {
|
|
|
62
88
|
hono: "^4.12.0"
|
|
63
89
|
},
|
|
64
90
|
devDependencies: {
|
|
91
|
+
nitro: "3.0.260311-beta",
|
|
65
92
|
typescript: "^5.9.0",
|
|
66
|
-
|
|
93
|
+
vite: "^8.0.3"
|
|
67
94
|
}
|
|
68
95
|
};
|
|
69
96
|
fs.writeFileSync(
|
|
@@ -97,6 +124,8 @@ Describe what ${name} helps users do.
|
|
|
97
124
|
path.join(target, ".gitignore"),
|
|
98
125
|
`node_modules/
|
|
99
126
|
.vercel/
|
|
127
|
+
.output/
|
|
128
|
+
.nitro/
|
|
100
129
|
.env
|
|
101
130
|
.env.local
|
|
102
131
|
`
|
|
@@ -113,10 +142,12 @@ SENTRY_DSN=
|
|
|
113
142
|
`
|
|
114
143
|
);
|
|
115
144
|
writeServerEntry(target);
|
|
145
|
+
writeNitroConfig(target);
|
|
146
|
+
writeViteConfig(target);
|
|
116
147
|
writeVercelJson(target);
|
|
117
148
|
log(`Created ${name} at ${target}`);
|
|
118
149
|
log("");
|
|
119
|
-
log(` cd ${targetDir} && pnpm install &&
|
|
150
|
+
log(` cd ${targetDir} && pnpm install && pnpm dev`);
|
|
120
151
|
log("");
|
|
121
152
|
}
|
|
122
153
|
export {
|
|
@@ -1,13 +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-RBB2MZAN.js";
|
|
11
12
|
import "../chunk-2KG3PWR4.js";
|
|
12
13
|
|
|
13
14
|
// src/cli/snapshot-warmup.ts
|
package/dist/nitro.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface JuniorNitroOptions {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
maxDuration?: number;
|
|
4
|
+
pluginPackages?: string[];
|
|
5
|
+
}
|
|
6
|
+
/** Nitro module that copies app and plugin content into the Vercel build output. */
|
|
7
|
+
declare function juniorNitro(options?: JuniorNitroOptions): {
|
|
8
|
+
nitro: {
|
|
9
|
+
setup(nitro: unknown): void;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { type JuniorNitroOptions, juniorNitro };
|
package/dist/nitro.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
discoverInstalledPluginPackageContent
|
|
3
|
+
} from "./chunk-RBB2MZAN.js";
|
|
4
|
+
import "./chunk-2KG3PWR4.js";
|
|
5
|
+
|
|
6
|
+
// src/nitro.ts
|
|
7
|
+
import { cpSync, existsSync, mkdirSync } from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
function juniorNitro(options = {}) {
|
|
10
|
+
return {
|
|
11
|
+
nitro: {
|
|
12
|
+
setup(nitro) {
|
|
13
|
+
const cwd = path.resolve(
|
|
14
|
+
options.cwd ?? nitro.options.rootDir ?? process.cwd()
|
|
15
|
+
);
|
|
16
|
+
nitro.options.vercel ??= {};
|
|
17
|
+
nitro.options.vercel.functions ??= {};
|
|
18
|
+
nitro.options.vercel.functions.maxDuration ??= options.maxDuration ?? 800;
|
|
19
|
+
nitro.hooks.hook("compiled", () => {
|
|
20
|
+
copyAppAndPluginContent(
|
|
21
|
+
cwd,
|
|
22
|
+
nitro.options.output.serverDir,
|
|
23
|
+
options.pluginPackages
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function copyAppAndPluginContent(cwd, serverRoot, pluginPackages) {
|
|
31
|
+
copyIfExists(path.join(cwd, "app"), path.join(serverRoot, "app"));
|
|
32
|
+
const packagedContent = discoverInstalledPluginPackageContent(cwd, {
|
|
33
|
+
packageNames: pluginPackages
|
|
34
|
+
});
|
|
35
|
+
for (const root of packagedContent.manifestRoots) {
|
|
36
|
+
if (existsSync(path.join(root, "plugin.yaml"))) {
|
|
37
|
+
const relative = path.relative(cwd, root);
|
|
38
|
+
if (!relative || path.isAbsolute(relative) || relative.startsWith("..")) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
copyIfExists(
|
|
42
|
+
path.join(root, "plugin.yaml"),
|
|
43
|
+
path.join(serverRoot, relative, "plugin.yaml")
|
|
44
|
+
);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
copyRootIntoServerOutput(cwd, serverRoot, root);
|
|
48
|
+
}
|
|
49
|
+
for (const root of packagedContent.skillRoots) {
|
|
50
|
+
copyRootIntoServerOutput(cwd, serverRoot, root);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function copyIfExists(source, target) {
|
|
54
|
+
if (!existsSync(source)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
mkdirSync(path.dirname(target), { recursive: true });
|
|
58
|
+
cpSync(source, target, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
function copyRootIntoServerOutput(cwd, serverRoot, root) {
|
|
61
|
+
const relative = path.relative(cwd, root);
|
|
62
|
+
if (!relative || path.isAbsolute(relative) || relative.startsWith("..")) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
copyIfExists(root, path.join(serverRoot, relative));
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
juniorNitro
|
|
69
|
+
};
|
package/dist/vercel.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
/** Default glob for bundling app content and plugin packages into the Vercel function. */
|
|
2
|
-
/** Default glob for bundling app content and plugin package assets into the Vercel function. */
|
|
3
|
-
declare const DEFAULT_INCLUDE_FILES = "{./app/**,./node_modules/@sentry/junior*/plugin.yaml,./node_modules/@sentry/junior*/skills/**,./node_modules/@sentry/junior*/plugins/**}";
|
|
4
1
|
interface JuniorVercelConfigOptions {
|
|
5
|
-
entrypoint?: string;
|
|
6
|
-
maxDuration?: number;
|
|
7
|
-
includeFiles?: string;
|
|
8
2
|
buildCommand?: string | null;
|
|
9
3
|
}
|
|
10
|
-
/** Return
|
|
4
|
+
/** Return a minimal Vercel config for scaffolded Junior apps. */
|
|
11
5
|
declare function juniorVercelConfig(options?: JuniorVercelConfigOptions): Record<string, unknown>;
|
|
12
6
|
|
|
13
|
-
export {
|
|
7
|
+
export { type JuniorVercelConfigOptions, juniorVercelConfig };
|
package/dist/vercel.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_INCLUDE_FILES,
|
|
3
|
-
juniorVercelConfig
|
|
4
|
-
} from "./chunk-ZLVM4R7R.js";
|
|
5
1
|
import "./chunk-2KG3PWR4.js";
|
|
2
|
+
|
|
3
|
+
// src/vercel.ts
|
|
4
|
+
function juniorVercelConfig(options = {}) {
|
|
5
|
+
const buildCommand = options.buildCommand === void 0 ? "pnpm build" : options.buildCommand;
|
|
6
|
+
const config = {
|
|
7
|
+
framework: "nitro"
|
|
8
|
+
};
|
|
9
|
+
if (buildCommand !== null) {
|
|
10
|
+
config.buildCommand = buildCommand;
|
|
11
|
+
}
|
|
12
|
+
return config;
|
|
13
|
+
}
|
|
6
14
|
export {
|
|
7
|
-
DEFAULT_INCLUDE_FILES,
|
|
8
15
|
juniorVercelConfig
|
|
9
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": "./dist/app.js",
|
|
14
14
|
"./instrumentation": "./dist/instrumentation.js",
|
|
15
|
+
"./nitro": "./dist/nitro.js",
|
|
15
16
|
"./vercel": "./dist/vercel.js"
|
|
16
17
|
},
|
|
17
18
|
"files": [
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
"@sentry/node": "^10.46.0",
|
|
47
48
|
"@types/node": "^25.5.0",
|
|
48
49
|
"msw": "^2.12.14",
|
|
50
|
+
"nitro": "3.0.260311-beta",
|
|
49
51
|
"tsup": "^8.5.1",
|
|
50
52
|
"typescript": "^5.9.3",
|
|
51
53
|
"vercel": "^50.37.3",
|
package/dist/chunk-ZLVM4R7R.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// src/vercel.ts
|
|
2
|
-
var DEFAULT_INCLUDE_FILES = "{./app/**,./node_modules/@sentry/junior*/plugin.yaml,./node_modules/@sentry/junior*/skills/**,./node_modules/@sentry/junior*/plugins/**}";
|
|
3
|
-
function juniorVercelConfig(options = {}) {
|
|
4
|
-
const entrypoint = options.entrypoint ?? "server.ts";
|
|
5
|
-
const maxDuration = options.maxDuration ?? 800;
|
|
6
|
-
const buildCommand = options.buildCommand === void 0 ? "pnpm build" : options.buildCommand;
|
|
7
|
-
const config = {
|
|
8
|
-
framework: "hono",
|
|
9
|
-
functions: {
|
|
10
|
-
[entrypoint]: {
|
|
11
|
-
maxDuration,
|
|
12
|
-
includeFiles: options.includeFiles ?? DEFAULT_INCLUDE_FILES
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
if (buildCommand !== null) {
|
|
17
|
-
config.buildCommand = buildCommand;
|
|
18
|
-
}
|
|
19
|
-
return config;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
DEFAULT_INCLUDE_FILES,
|
|
24
|
-
juniorVercelConfig
|
|
25
|
-
};
|