diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bfe88566..cc4dc363 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,27 +4,6 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false -catalogs: - default: - '@types/node': - specifier: ^20.14.2 - version: 20.14.2 - marked: - specifier: ^12.0.2 - version: 12.0.2 - prettier: - specifier: ^3.3.1 - version: 3.3.1 - typescript: - specifier: ^5.4.5 - version: 5.4.5 - ws: - specifier: ^8.17.0 - version: 8.17.0 - zod: - specifier: ^3.23.8 - version: 3.23.8 - importers: .: @@ -310,6 +289,9 @@ importers: marked: specifier: 'catalog:' version: 12.0.2 + open: + specifier: ^10.1.0 + version: 10.1.0 posthog-node: specifier: ^4.0.1 version: 4.0.1 @@ -2182,6 +2164,10 @@ packages: buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + bundle-name@4.1.0: + resolution: {integrity: sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==} + engines: {node: '>=18'} + bytes@3.1.2: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} @@ -2365,10 +2351,22 @@ packages: deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} + default-browser-id@5.0.0: + resolution: {integrity: sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==} + engines: {node: '>=18'} + + default-browser@5.2.1: + resolution: {integrity: sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==} + engines: {node: '>=18'} + define-data-property@1.1.4: resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} engines: {node: '>= 0.4'} + define-lazy-prop@3.0.0: + resolution: {integrity: sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==} + engines: {node: '>=12'} + delayed-stream@1.0.0: resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} engines: {node: '>=0.4.0'} @@ -2954,6 +2952,11 @@ packages: is-core-module@2.13.1: resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} + is-docker@3.0.0: + resolution: {integrity: sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + hasBin: true + is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} @@ -2966,6 +2969,11 @@ packages: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} + is-inside-container@1.0.0: + resolution: {integrity: sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==} + engines: {node: '>=14.16'} + hasBin: true + is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} @@ -2985,6 +2993,10 @@ packages: resolution: {integrity: sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==} engines: {node: '>=0.10.0'} + is-wsl@3.1.0: + resolution: {integrity: sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==} + engines: {node: '>=16'} + isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} @@ -3269,6 +3281,10 @@ packages: resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} engines: {node: '>=12'} + open@10.1.0: + resolution: {integrity: sha512-mnkeQ1qP5Ue2wd+aivTD3NHd/lZ96Lu0jgf0pwktLPtx6cTZiH7tyeGRRHs0zX0rbrahXPnXlUnbeXyaBBuIaw==} + engines: {node: '>=18'} + openai@4.52.3: resolution: {integrity: sha512-IyQLYKGYoEEkUCEm2frPzwHDJ3Ym663KtivnY6pWCzuoi6/HgSIMMxpcuTRS81GH6tiULPYGmTxIvzXdmPIWOw==} hasBin: true @@ -3598,6 +3614,10 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + run-applescript@7.0.0: + resolution: {integrity: sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A==} + engines: {node: '>=18'} + run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} @@ -4115,6 +4135,27 @@ packages: zod@3.23.8: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} +catalogs: + default: + '@types/node': + specifier: ^20.14.2 + version: 20.14.2 + marked: + specifier: ^12.0.2 + version: 12.0.2 + prettier: + specifier: ^3.3.1 + version: 3.3.1 + typescript: + specifier: ^5.4.5 + version: 5.4.5 + ws: + specifier: ^8.17.0 + version: 8.17.0 + zod: + specifier: ^3.23.8 + version: 3.23.8 + snapshots: '@ai-sdk/openai@0.0.34(zod@3.23.8)': @@ -5924,6 +5965,10 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 + bundle-name@4.1.0: + dependencies: + run-applescript: 7.0.0 + bytes@3.1.2: {} cac@6.7.14: {} @@ -6113,12 +6158,21 @@ snapshots: deep-is@0.1.4: {} + default-browser-id@5.0.0: {} + + default-browser@5.2.1: + dependencies: + bundle-name: 4.1.0 + default-browser-id: 5.0.0 + define-data-property@1.1.4: dependencies: es-define-property: 1.0.0 es-errors: 1.3.0 gopd: 1.0.1 + define-lazy-prop@3.0.0: {} + delayed-stream@1.0.0: {} depcheck@1.4.7: @@ -6742,6 +6796,8 @@ snapshots: dependencies: hasown: 2.0.2 + is-docker@3.0.0: {} + is-extglob@2.1.1: {} is-fullwidth-code-point@3.0.0: {} @@ -6750,6 +6806,10 @@ snapshots: dependencies: is-extglob: 2.1.1 + is-inside-container@1.0.0: + dependencies: + is-docker: 3.0.0 + is-number@7.0.0: {} is-path-inside@3.0.3: {} @@ -6762,6 +6822,10 @@ snapshots: is-windows@1.0.2: {} + is-wsl@3.1.0: + dependencies: + is-inside-container: 1.0.0 + isexe@2.0.0: {} jackspeak@3.4.0: @@ -6986,6 +7050,13 @@ snapshots: dependencies: mimic-fn: 4.0.0 + open@10.1.0: + dependencies: + default-browser: 5.2.1 + define-lazy-prop: 3.0.0 + is-inside-container: 1.0.0 + is-wsl: 3.1.0 + openai@4.52.3: dependencies: '@types/node': 18.19.39 @@ -7338,6 +7409,8 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.18.0 fsevents: 2.3.3 + run-applescript@7.0.0: {} + run-parallel@1.2.0: dependencies: queue-microtask: 1.2.3 diff --git a/srcbook/index.mjs b/srcbook/index.mjs index 0c9a10cd..2f06cde2 100644 --- a/srcbook/index.mjs +++ b/srcbook/index.mjs @@ -14,13 +14,15 @@ import './lib/db/index.mjs'; * */ import readline from 'node:readline'; -import express from 'express'; +import fs from 'node:fs'; +import path from 'node:path'; import http from 'node:http'; -import { fileURLToPath } from 'url'; -import path from 'path'; +import { fileURLToPath } from 'node:url'; +import express from 'express'; import { WebSocketServer as WsWebSocketServer } from 'ws'; import { wss, app, posthog } from './lib/index.mjs'; import chalk from 'chalk'; +import open from 'open'; function clearScreen() { const repeatCount = process.stdout.rows - 2; @@ -56,11 +58,18 @@ app.get('*', (_req, res) => res.sendFile(INDEX_HTML)); console.log(chalk.green('Initialization complete.')); const port = process.env.PORT || 2150; +const url = `http://localhost:${port}`; posthog.capture({ event: 'user started Srcbook application' }); +const packageJsonPath = path.join(__dirname, 'package.json'); +const packageJson = fs.readFileSync(packageJsonPath, 'utf-8'); +const { name, version } = JSON.parse(packageJson); + server.listen(port, () => { - console.log(`Running at http://localhost:${port}`); + console.log(`${name}@${version} running at ${url}`); + const noop = () => {}; + open(url).catch(noop); }); process.on('SIGINT', async function () { diff --git a/srcbook/package.json b/srcbook/package.json index 32b00a19..50245adf 100644 --- a/srcbook/package.json +++ b/srcbook/package.json @@ -23,6 +23,7 @@ "drizzle-orm": "^0.31.2", "express": "^4.19.2", "marked": "catalog:", + "open": "^10.1.0", "posthog-node": "^4.0.1", "ws": "catalog:", "zod": "catalog:"