@nexus_js/cli 0.7.1

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/dist/create.js ADDED
@@ -0,0 +1,275 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * create-nexus — scaffolding CLI for new Nexus projects.
4
+ * Usage: npm create @nexus_js/nexus@latest my-app
5
+ * npx @nexus_js/create-nexus my-app
6
+ * npm exec --package=@nexus_js/cli -- create-nexus my-app
7
+ */
8
+ import { readFileSync } from 'node:fs';
9
+ import { mkdir, writeFile } from 'node:fs/promises';
10
+ import { dirname, join, resolve } from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+ /** Same version as the published @nexus_js/cli (peer @nexus_js/* packages stay in sync). */
13
+ function getPublishedCliVersion() {
14
+ const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
15
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
16
+ return pkg.version;
17
+ }
18
+ const CYAN = '\x1b[36m';
19
+ const GREEN = '\x1b[32m';
20
+ const YELLOW = '\x1b[33m';
21
+ const RESET = '\x1b[0m';
22
+ const BOLD = '\x1b[1m';
23
+ const DIM = '\x1b[2m';
24
+ const BANNER = `
25
+ ${CYAN}◆ create-nexus${RESET}
26
+
27
+ The Definitive Full-Stack Framework
28
+ Islands × Runes × Server Actions
29
+ `;
30
+ async function main() {
31
+ console.log(BANNER);
32
+ const projectName = process.argv[2] ?? 'my-nexus-app';
33
+ const targetDir = resolve(process.cwd(), projectName);
34
+ console.log(` Creating ${BOLD}${projectName}${RESET}...\n`);
35
+ // Create directory structure
36
+ const dirs = [
37
+ 'src/routes',
38
+ 'src/routes/blog/[slug]',
39
+ 'src/routes/api/users',
40
+ 'src/components',
41
+ 'src/islands',
42
+ 'src/lib',
43
+ 'public',
44
+ ];
45
+ for (const dir of dirs) {
46
+ await mkdir(join(targetDir, dir), { recursive: true });
47
+ }
48
+ // Write project files
49
+ await writeProjectFiles(targetDir, projectName);
50
+ console.log(` ${GREEN}✓${RESET} Project created at ${BOLD}${projectName}/${RESET}\n`);
51
+ console.log(` Next steps:\n`);
52
+ console.log(` ${DIM}cd${RESET} ${projectName}`);
53
+ console.log(` ${DIM}npm install${RESET} ${DIM}(or pnpm install / yarn)${RESET}`);
54
+ console.log(` ${DIM}npm run dev${RESET} ${DIM}(or pnpm dev)${RESET}\n`);
55
+ console.log(` ${CYAN}◆${RESET} Docs: ${BOLD}https://nexusjs.dev${RESET}\n`);
56
+ }
57
+ async function writeProjectFiles(dir, name) {
58
+ const v = getPublishedCliVersion();
59
+ const range = `^${v}`;
60
+ const files = {
61
+ 'package.json': JSON.stringify({
62
+ name,
63
+ version: '0.1.0',
64
+ private: true,
65
+ type: 'module',
66
+ scripts: {
67
+ dev: 'nexus dev',
68
+ build: 'nexus build',
69
+ start: 'nexus start',
70
+ check: 'nexus check',
71
+ },
72
+ dependencies: {
73
+ '@nexus_js/runtime': range,
74
+ },
75
+ devDependencies: {
76
+ '@nexus_js/cli': range,
77
+ '@nexus_js/compiler': range,
78
+ typescript: '^5.5.0',
79
+ },
80
+ }, null, 2),
81
+ 'tsconfig.json': JSON.stringify({
82
+ compilerOptions: {
83
+ target: 'ES2022',
84
+ module: 'NodeNext',
85
+ moduleResolution: 'NodeNext',
86
+ strict: true,
87
+ skipLibCheck: true,
88
+ noEmit: true,
89
+ paths: { '$lib/*': ['./src/lib/*'] },
90
+ },
91
+ include: ['nexus.config.ts', 'src/**/*.ts'],
92
+ }, null, 2),
93
+ 'nexus.config.ts': `import type { NexusConfig } from '@nexus_js/cli';
94
+
95
+ export default {
96
+ // Islands hydration strategy defaults
97
+ defaultHydration: 'client:visible',
98
+
99
+ // Image optimization
100
+ images: {
101
+ formats: ['avif', 'webp'],
102
+ sizes: [640, 1280, 1920],
103
+ },
104
+
105
+ // Server options
106
+ server: {
107
+ port: 3000,
108
+ },
109
+
110
+ // Build output
111
+ build: {
112
+ outDir: '.nexus/output',
113
+ sourcemap: false,
114
+ },
115
+ } satisfies NexusConfig;
116
+ `,
117
+ 'src/routes/+layout.nx': `---
118
+ // Root layout — server-only
119
+ const appName = "My Nexus App";
120
+ ---
121
+
122
+ <html lang="en">
123
+ <head>
124
+ <meta charset="UTF-8">
125
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
126
+ <title>{appName}</title>
127
+ </head>
128
+ <body>
129
+ <nav>
130
+ <a href="/">Home</a>
131
+ <a href="/blog">Blog</a>
132
+ </nav>
133
+ <main>
134
+ <!--nexus:slot-->
135
+ </main>
136
+ </body>
137
+ </html>
138
+ `,
139
+ 'src/routes/+page.nx': `---
140
+ // Index page — runs on server only
141
+ const greeting = "Welcome to Nexus";
142
+ const features = [
143
+ { icon: "🏝️", title: "Islands Architecture", desc: "Zero JS by default" },
144
+ { icon: "⚡", title: "Svelte 5 Runes", desc: "Fine-grained reactivity" },
145
+ { icon: "🔧", title: "Server Actions", desc: "Type-safe mutations" },
146
+ ];
147
+ ---
148
+
149
+ <script>
150
+ // Client island — only this code reaches the browser
151
+ let count = $state(0);
152
+ let doubled = $derived(count * 2);
153
+ </script>
154
+
155
+ <section class="hero">
156
+ <h1>{greeting}</h1>
157
+ <p>Islands × Runes × Server Actions</p>
158
+ </section>
159
+
160
+ <section class="features">
161
+ {#each features as f}
162
+ <div class="card">
163
+ <span>{f.icon}</span>
164
+ <h3>{f.title}</h3>
165
+ <p>{f.desc}</p>
166
+ </div>
167
+ {/each}
168
+ </section>
169
+
170
+ <div class="counter" client:visible>
171
+ <button onclick={() => count++}>
172
+ Clicked {count} times (×2 = {doubled})
173
+ </button>
174
+ </div>
175
+
176
+ <style>
177
+ .hero { text-align: center; padding: 4rem 2rem; }
178
+ .features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
179
+ .card { padding: 1.5rem; border: 1px solid #eee; border-radius: 8px; }
180
+ .counter { text-align: center; margin-top: 2rem; }
181
+ button { padding: 0.75rem 2rem; font-size: 1rem; cursor: pointer; }
182
+ </style>
183
+ `,
184
+ 'src/routes/blog/+page.nx': `---
185
+ // Blog listing page
186
+ const posts = [
187
+ { slug: "hello-nexus", title: "Hello Nexus", date: "2026-04-03" },
188
+ { slug: "islands-arch", title: "Islands Architecture Deep Dive", date: "2026-04-01" },
189
+ ];
190
+ ---
191
+
192
+ <h1>Blog</h1>
193
+ <ul>
194
+ {#each posts as post}
195
+ <li>
196
+ <a href="/blog/{post.slug}">{post.title}</a>
197
+ <time>{post.date}</time>
198
+ </li>
199
+ {/each}
200
+ </ul>
201
+ `,
202
+ 'src/routes/blog/[slug]/+page.nx': `---
203
+ // Dynamic blog post page
204
+ // params.slug is injected by the router
205
+ const { slug } = ctx.params;
206
+ const post = { title: \`Post: \${slug}\`, content: "Post content here..." };
207
+ ---
208
+
209
+ <article>
210
+ <h1>{post.title}</h1>
211
+ <p>{post.content}</p>
212
+ <a href="/blog">← Back to Blog</a>
213
+ </article>
214
+ `,
215
+ 'src/routes/api/users/+server.nx': `---
216
+ // API route — returns JSON
217
+ // GET /api/users
218
+ const users = [
219
+ { id: 1, name: "Alice" },
220
+ { id: 2, name: "Bob" },
221
+ ];
222
+ ---
223
+
224
+ // Export GET handler
225
+ export async function GET(ctx) {
226
+ return Response.json({ users });
227
+ }
228
+
229
+ // POST /api/users
230
+ export async function POST(ctx) {
231
+ const body = await ctx.request.json();
232
+ // Create user logic...
233
+ return Response.json({ created: true }, { status: 201 });
234
+ }
235
+ `,
236
+ 'src/lib/db.ts': `// Database client placeholder
237
+ // Replace with your preferred ORM (Prisma, Drizzle, etc.)
238
+
239
+ export const db = {
240
+ user: {
241
+ async findFirst() {
242
+ return { id: 1, name: 'Demo User', email: 'demo@nexusjs.dev' };
243
+ },
244
+ async findMany() {
245
+ return [{ id: 1, name: 'Demo User', email: 'demo@nexusjs.dev' }];
246
+ },
247
+ async update(args: { where?: unknown; data: unknown }) {
248
+ return { ...args.data };
249
+ },
250
+ async create(args: { data: unknown }) {
251
+ return args.data;
252
+ },
253
+ },
254
+ };
255
+ `,
256
+ 'public/favicon.svg': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
257
+ <text y="28" font-size="28">◆</text>
258
+ </svg>`,
259
+ '.gitignore': `node_modules/
260
+ .nexus/
261
+ dist/
262
+ *.js.map
263
+ `,
264
+ };
265
+ for (const [filepath, content] of Object.entries(files)) {
266
+ const fullPath = join(dir, filepath);
267
+ await writeFile(fullPath, content, 'utf-8');
268
+ console.log(` ${GREEN}+${RESET} ${filepath}`);
269
+ }
270
+ }
271
+ main().catch((err) => {
272
+ console.error('\x1b[31m[create-nexus Error]\x1b[0m', err);
273
+ process.exit(1);
274
+ });
275
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,4FAA4F;AAC5F,SAAS,sBAAsB;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACpF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAwB,CAAC;IAC9E,OAAO,GAAG,CAAC,OAAO,CAAC;AACrB,CAAC;AAED,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB,MAAM,MAAM,GAAG,UAAU,CAAC;AAC1B,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,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;;;;;;;CAqB5B;QAEG,qBAAqB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4C1B;QAEG,0BAA0B,EAAE;;;;;;;;;;;;;;;;;CAiB/B;QAEG,iCAAiC,EAAE;;;;;;;;;;;;CAYtC;QAEG,iCAAiC,EAAE;;;;;;;;;;;;;;;;;;;;CAoBtC;QAEG,eAAe,EAAE;;;;;;;;;;;;;;;;;;;CAmBpB;QAEG,oBAAoB,EAAE;;OAEnB;QAEH,YAAY,EAAE;;;;CAIjB;KACE,CAAC;IAEF,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACrC,MAAM,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,IAAI,KAAK,IAAI,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,GAAG,CAAC,CAAC;IAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/dist/fix.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * nexus fix — Automatic Vulnerability Remediation.
3
+ *
4
+ * Reads package.json, queries OSV for vulnerable packages,
5
+ * finds the patched version for each, updates package.json,
6
+ * runs the package manager install, and re-runs audit to verify.
7
+ *
8
+ * Unlike `npm audit fix` which is coarse-grained, `nexus fix`:
9
+ * - Only updates SPECIFICALLY the vulnerable package (not all transitive deps)
10
+ * - Targets the MINIMUM patched version (not always latest)
11
+ * - Respects your semver range preferences (^x.y.z → ^x.y.fix)
12
+ * - Shows a before/after diff
13
+ * - Offers a --dry-run mode (no changes written)
14
+ * - Re-audits after fixing to confirm 0 critical CVEs remain
15
+ */
16
+ export interface FixOptions {
17
+ root: string;
18
+ dryRun?: boolean;
19
+ force?: boolean;
20
+ }
21
+ export declare function runFix(opts: FixOptions): Promise<void>;
22
+ //# sourceMappingURL=fix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fix.d.ts","sourceRoot":"","sources":["../src/fix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiDH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAK,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAG,OAAO,CAAC;CAClB;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAgK5D"}
package/dist/fix.js ADDED
@@ -0,0 +1,199 @@
1
+ /**
2
+ * nexus fix — Automatic Vulnerability Remediation.
3
+ *
4
+ * Reads package.json, queries OSV for vulnerable packages,
5
+ * finds the patched version for each, updates package.json,
6
+ * runs the package manager install, and re-runs audit to verify.
7
+ *
8
+ * Unlike `npm audit fix` which is coarse-grained, `nexus fix`:
9
+ * - Only updates SPECIFICALLY the vulnerable package (not all transitive deps)
10
+ * - Targets the MINIMUM patched version (not always latest)
11
+ * - Respects your semver range preferences (^x.y.z → ^x.y.fix)
12
+ * - Shows a before/after diff
13
+ * - Offers a --dry-run mode (no changes written)
14
+ * - Re-audits after fixing to confirm 0 critical CVEs remain
15
+ */
16
+ import { readFile } from 'node:fs/promises';
17
+ import { join } from 'node:path';
18
+ import { execSync } from 'node:child_process';
19
+ // ── ANSI ──────────────────────────────────────────────────────────────────────
20
+ const c = {
21
+ reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m',
22
+ red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m',
23
+ cyan: '\x1b[36m', mag: '\x1b[35m', gray: '\x1b[90m',
24
+ };
25
+ const log = {
26
+ ok: (...a) => console.log(` \x1b[32m✔\x1b[0m`, ...a),
27
+ warn: (...a) => console.log(` \x1b[33m⚠\x1b[0m`, ...a),
28
+ error: (...a) => console.error(` \x1b[31m✖\x1b[0m`, ...a),
29
+ info: (...a) => console.log(` \x1b[36mℹ\x1b[0m`, ...a),
30
+ step: (...a) => console.log(` \x1b[35m◆\x1b[0m`, ...a),
31
+ };
32
+ // ── Package manager detection ─────────────────────────────────────────────────
33
+ function detectPackageManager(root) {
34
+ const { existsSync } = require('node:fs');
35
+ if (existsSync(join(root, 'pnpm-lock.yaml')))
36
+ return 'pnpm';
37
+ if (existsSync(join(root, 'yarn.lock')))
38
+ return 'yarn';
39
+ return 'npm';
40
+ }
41
+ function installCmd(pm, pkg, version) {
42
+ const spec = `${pkg}@${version}`;
43
+ if (pm === 'pnpm')
44
+ return `pnpm add ${spec}`;
45
+ if (pm === 'yarn')
46
+ return `yarn add ${spec}`;
47
+ return `npm install ${spec}`;
48
+ }
49
+ // ── Semver helpers ────────────────────────────────────────────────────────────
50
+ function preserveRange(oldRange, newVersion) {
51
+ const prefix = oldRange.match(/^([~^>=<]+)/)?.[1] ?? '';
52
+ // If old range used ^, preserve it so minor updates still work
53
+ if (prefix === '^')
54
+ return `^${newVersion}`;
55
+ if (prefix === '~')
56
+ return `~${newVersion}`;
57
+ return newVersion;
58
+ }
59
+ export async function runFix(opts) {
60
+ const { root, dryRun = false } = opts;
61
+ console.log();
62
+ log.step(`${c.bold}Nexus Fix${c.reset} ${c.dim}—${c.reset} automatic vulnerability remediation`);
63
+ if (dryRun)
64
+ log.warn('Dry run mode — no changes will be written');
65
+ console.log();
66
+ // Load audit engine (dynamic — gracefully fails if not installed)
67
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
+ let audit;
69
+ try {
70
+ audit = await import('@nexus_js/audit');
71
+ }
72
+ catch {
73
+ log.error('@nexus_js/audit not installed. Run: pnpm add -D @nexus_js/audit');
74
+ process.exitCode = 1;
75
+ return;
76
+ }
77
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
+ const auditDependencies = audit.auditDependencies;
79
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ const filterVulnerable = audit.filterVulnerable;
81
+ // Read package.json
82
+ const pkgPath = join(root, 'package.json');
83
+ let pkgJson;
84
+ try {
85
+ pkgJson = JSON.parse(await readFile(pkgPath, 'utf-8'));
86
+ }
87
+ catch {
88
+ log.error(`Cannot read ${pkgPath}`);
89
+ process.exitCode = 1;
90
+ return;
91
+ }
92
+ const deps = { ...pkgJson.dependencies, ...pkgJson.devDependencies };
93
+ const isDev = new Set(Object.keys(pkgJson.devDependencies ?? {}));
94
+ log.info(`Scanning ${Object.keys(deps).length} packages via OSV...`);
95
+ const results = await auditDependencies(deps);
96
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
+ const vulnerable = filterVulnerable(results).filter((r) => !opts.force ? (r.vulns[0]?.severity === 'critical' || r.vulns[0]?.severity === 'high') : true);
98
+ if (vulnerable.length === 0) {
99
+ log.ok('No critical/high vulnerabilities found — nothing to fix!');
100
+ console.log();
101
+ return;
102
+ }
103
+ console.log(` Found ${c.red}${vulnerable.length}${c.reset} vulnerable package${vulnerable.length > 1 ? 's' : ''}:\n`);
104
+ // Collect fix actions
105
+ const fixes = [];
106
+ const noFix = [];
107
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
108
+ for (const result of vulnerable) {
109
+ const topVuln = result.vulns[0];
110
+ if (!topVuln)
111
+ continue;
112
+ const currentRange = deps[result.package] ?? '*';
113
+ const fixedIn = topVuln.fixedIn;
114
+ console.log(` ${c.bold}${result.package}${c.reset} ${c.dim}(current: ${currentRange})${c.reset}\n` +
115
+ ` ${topVuln.id} ${topVuln.severity.toUpperCase()} ${topVuln.summary}`);
116
+ if (fixedIn) {
117
+ const newRange = preserveRange(currentRange, fixedIn);
118
+ console.log(` ${c.green}→ Update to v${fixedIn}${c.reset} (range: ${newRange})\n`);
119
+ fixes.push({
120
+ pkg: result.package,
121
+ oldVersion: currentRange,
122
+ newVersion: newRange,
123
+ cve: topVuln.id,
124
+ isDev: isDev.has(result.package),
125
+ });
126
+ }
127
+ else {
128
+ console.log(` ${c.yellow}→ No patched version available in OSV data${c.reset}`);
129
+ console.log(` Consider: replacing, removing, or adding an allowVulnerable override\n`);
130
+ noFix.push({
131
+ pkg: result.package,
132
+ cve: topVuln.id,
133
+ reason: 'No patched version in OSV database',
134
+ });
135
+ }
136
+ }
137
+ if (fixes.length === 0) {
138
+ log.warn('No automatic fixes available. Review the packages above manually.');
139
+ console.log();
140
+ return;
141
+ }
142
+ if (dryRun) {
143
+ console.log(` ${c.dim}─────────────────────────────────────${c.reset}`);
144
+ console.log(` ${c.cyan}Dry run — would apply ${fixes.length} fix${fixes.length > 1 ? 'es' : ''}:${c.reset}`);
145
+ for (const f of fixes) {
146
+ console.log(` ${f.pkg}: ${f.oldVersion} → ${f.newVersion}`);
147
+ }
148
+ console.log();
149
+ return;
150
+ }
151
+ // Apply fixes to package.json
152
+ const pm = detectPackageManager(root);
153
+ let applied = 0;
154
+ for (const fix of fixes) {
155
+ log.step(`Updating ${c.bold}${fix.pkg}${c.reset} ${fix.oldVersion} → ${c.green}${fix.newVersion}${c.reset}`);
156
+ try {
157
+ const cmd = installCmd(pm, fix.pkg, fix.newVersion.replace(/^[\^~]/, ''));
158
+ execSync(cmd, { cwd: root, stdio: 'inherit' });
159
+ applied++;
160
+ log.ok(`${fix.pkg} updated`);
161
+ }
162
+ catch {
163
+ log.error(`Failed to update ${fix.pkg}. Try manually: ${pm} add ${fix.pkg}@${fix.newVersion}`);
164
+ }
165
+ }
166
+ console.log();
167
+ // Re-audit to verify
168
+ if (applied > 0) {
169
+ log.step('Re-auditing after fixes...');
170
+ const updatedPkg = JSON.parse(await readFile(pkgPath, 'utf-8'));
171
+ const updatedDeps = { ...updatedPkg.dependencies, ...updatedPkg.devDependencies };
172
+ const reCheck = await auditDependencies(updatedDeps);
173
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
174
+ const stillVulnerable = filterVulnerable(reCheck).filter((r) => r.vulns[0]?.severity === 'critical' || r.vulns[0]?.severity === 'high');
175
+ if (stillVulnerable.length === 0) {
176
+ log.ok(`${c.green}${c.bold}All critical/high vulnerabilities resolved!${c.reset}`);
177
+ }
178
+ else {
179
+ log.warn(`${stillVulnerable.length} vulnerability/vulnerabilities remain:`);
180
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
181
+ for (const r of stillVulnerable) {
182
+ const v = r.vulns[0];
183
+ if (v)
184
+ log.error(` ${r.package} — ${v.id} (${v.severity})`);
185
+ }
186
+ log.info('Run `nexus audit` for full details. Some may require manual intervention.');
187
+ }
188
+ }
189
+ if (noFix.length > 0) {
190
+ console.log();
191
+ log.warn(`${noFix.length} package${noFix.length > 1 ? 's have' : ' has'} no automatic fix:`);
192
+ for (const n of noFix) {
193
+ console.log(` ${c.yellow}${n.pkg}${c.reset} ${n.cve} — ${n.reason}`);
194
+ }
195
+ log.info('Consider adding an allowVulnerable override in nexus.config.ts with an expiry date.');
196
+ }
197
+ console.log();
198
+ }
199
+ //# sourceMappingURL=fix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fix.js","sourceRoot":"","sources":["../src/fix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAa,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAqB,WAAW,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAiB,oBAAoB,CAAC;AAEzD,iFAAiF;AACjF,MAAM,CAAC,GAAG;IACR,KAAK,EAAG,SAAS,EAAE,IAAI,EAAG,SAAS,EAAE,GAAG,EAAG,SAAS;IACpD,GAAG,EAAK,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU;IACzD,IAAI,EAAI,UAAU,EAAE,G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AAI,KAAK,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1E,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,qFAAqF,CAAC,CAAC;IAClG,CAAC;IAED,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type { NexusConfig } from './config.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Nexus Studio — Real-time developer dashboard.
3
+ *
4
+ * Launched via `nexus studio` or automatically as a panel within `nexus dev`.
5
+ * Runs a lightweight WebSocket server alongside the main dev server.
6
+ * The browser UI connects to ws://localhost:${STUDIO_PORT}/_nexus/studio
7
+ *
8
+ * Panels:
9
+ * 1. Layout Tree — Visual nested layout hierarchy for the current route.
10
+ * 2. Island Map — All live islands on screen, their state, hydration strategy.
11
+ * 3. Action Log — Real-time stream of Server Action calls, payloads, timings.
12
+ * 4. JS Cost — Bundle analysis for the current route (mirrors nexus analyze).
13
+ * 5. Cache Inspector — Current cache entries, TTLs, hit/miss ratio.
14
+ * 6. Store Viewer — Live snapshot of the Global State Store.
15
+ */
16
+ export declare const STUDIO_PORT = 4000;
17
+ export declare const STUDIO_WS_PATH = "/_nexus/studio";
18
+ export type StudioEvent = {
19
+ type: 'route:change';
20
+ payload: RouteInfo;
21
+ } | {
22
+ type: 'island:mounted';
23
+ payload: IslandInfo;
24
+ } | {
25
+ type: 'island:destroyed';
26
+ payload: {
27
+ id: string;
28
+ };
29
+ } | {
30
+ type: 'island:state';
31
+ payload: {
32
+ id: string;
33
+ state: unknown;
34
+ };
35
+ } | {
36
+ type: 'action:call';
37
+ payload: ActionCall;
38
+ } | {
39
+ type: 'action:result';
40
+ payload: ActionResult;
41
+ } | {
42
+ type: 'action:error';
43
+ payload: ActionError;
44
+ } | {
45
+ type: 'cache:set';
46
+ payload: CacheEntry;
47
+ } | {
48
+ type: 'cache:hit';
49
+ payload: {
50
+ key: string;
51
+ };
52
+ } | {
53
+ type: 'cache:miss';
54
+ payload: {
55
+ key: string;
56
+ };
57
+ } | {
58
+ type: 'store:update';
59
+ payload: {
60
+ key: string;
61
+ value: unknown;
62
+ };
63
+ } | {
64
+ type: 'hmr:update';
65
+ payload: {
66
+ file: string;
67
+ time: number;
68
+ };
69
+ } | {
70
+ type: 'build:complete';
71
+ payload: BuildInfo;
72
+ };
73
+ export interface RouteInfo {
74
+ path: string;
75
+ params: Record<string, string>;
76
+ layouts: string[];
77
+ page: string;
78
+ cacheTtl: number;
79
+ cacheStrategy: string;
80
+ jsCost: {
81
+ raw: number;
82
+ gzip: number;
83
+ budget: number;
84
+ overBudget: boolean;
85
+ };
86
+ }
87
+ export interface IslandInfo {
88
+ id: string;
89
+ component: string;
90
+ strategy: string;
91
+ state: unknown;
92
+ props: unknown;
93
+ el?: string;
94
+ }
95
+ export interface ActionCall {
96
+ id: string;
97
+ name: string;
98
+ islandId?: string;
99
+ input: unknown;
100
+ timestamp: number;
101
+ idempotencyKey?: string;
102
+ }
103
+ export interface ActionResult {
104
+ id: string;
105
+ name: string;
106
+ output: unknown;
107
+ duration: number;
108
+ cached: boolean;
109
+ }
110
+ export interface ActionError {
111
+ id: string;
112
+ name: string;
113
+ error: string;
114
+ code?: string;
115
+ duration: number;
116
+ }
117
+ export interface CacheEntry {
118
+ key: string;
119
+ tags: string[];
120
+ ttl: number;
121
+ size: number;
122
+ }
123
+ export interface BuildInfo {
124
+ routes: number;
125
+ islands: number;
126
+ totalSize: number;
127
+ duration: number;
128
+ }
129
+ export declare function broadcast(event: StudioEvent): void;
130
+ export interface StudioServer {
131
+ port: number;
132
+ close: () => void;
133
+ broadcast: typeof broadcast;
134
+ }
135
+ export declare function startStudio(preferredPort?: number): Promise<StudioServer>;
136
+ //# sourceMappingURL=studio.d.ts.map