@vltpkg/vsr 0.0.0-26
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/DEPLOY.md +163 -0
- package/LICENSE +119 -0
- package/README.md +314 -0
- package/config.ts +221 -0
- package/drizzle.config.js +40 -0
- package/info/COMPARISONS.md +37 -0
- package/info/CONFIGURATION.md +143 -0
- package/info/CONTRIBUTING.md +32 -0
- package/info/DATABASE_SETUP.md +108 -0
- package/info/GRANULAR_ACCESS_TOKENS.md +160 -0
- package/info/PROJECT_STRUCTURE.md +291 -0
- package/info/ROADMAP.md +27 -0
- package/info/SUPPORT.md +39 -0
- package/info/TESTING.md +301 -0
- package/info/USER_SUPPORT.md +31 -0
- package/package.json +77 -0
- package/scripts/build-assets.js +31 -0
- package/scripts/build-bin.js +62 -0
- package/scripts/prepack.js +27 -0
- package/src/assets/public/images/bg.png +0 -0
- package/src/assets/public/images/clients/logo-bun.png +0 -0
- package/src/assets/public/images/clients/logo-deno.png +0 -0
- package/src/assets/public/images/clients/logo-npm.png +0 -0
- package/src/assets/public/images/clients/logo-pnpm.png +0 -0
- package/src/assets/public/images/clients/logo-vlt.png +0 -0
- package/src/assets/public/images/clients/logo-yarn.png +0 -0
- package/src/assets/public/images/favicon/apple-touch-icon.png +0 -0
- package/src/assets/public/images/favicon/favicon-96x96.png +0 -0
- package/src/assets/public/images/favicon/favicon.ico +0 -0
- package/src/assets/public/images/favicon/favicon.svg +3 -0
- package/src/assets/public/images/favicon/site.webmanifest +21 -0
- package/src/assets/public/images/favicon/web-app-manifest-192x192.png +0 -0
- package/src/assets/public/images/favicon/web-app-manifest-512x512.png +0 -0
- package/src/assets/public/styles/styles.css +231 -0
- package/src/bin/demo/package.json +6 -0
- package/src/bin/demo/vlt.json +1 -0
- package/src/bin/vsr.ts +484 -0
- package/src/db/client.ts +590 -0
- package/src/db/migrations/0000_faulty_ricochet.sql +14 -0
- package/src/db/migrations/0000_initial.sql +29 -0
- package/src/db/migrations/0001_uuid_validation.sql +35 -0
- package/src/db/migrations/0001_wealthy_magdalene.sql +7 -0
- package/src/db/migrations/drop.sql +3 -0
- package/src/db/migrations/meta/0000_snapshot.json +104 -0
- package/src/db/migrations/meta/0001_snapshot.json +155 -0
- package/src/db/migrations/meta/_journal.json +20 -0
- package/src/db/schema.ts +43 -0
- package/src/index.ts +434 -0
- package/src/middleware/config.ts +79 -0
- package/src/middleware/telemetry.ts +43 -0
- package/src/queue/index.ts +97 -0
- package/src/routes/access.ts +852 -0
- package/src/routes/docs.ts +63 -0
- package/src/routes/misc.ts +469 -0
- package/src/routes/packages.ts +2823 -0
- package/src/routes/ping.ts +39 -0
- package/src/routes/search.ts +131 -0
- package/src/routes/static.ts +74 -0
- package/src/routes/tokens.ts +259 -0
- package/src/routes/users.ts +68 -0
- package/src/utils/auth.ts +202 -0
- package/src/utils/cache.ts +587 -0
- package/src/utils/config.ts +50 -0
- package/src/utils/database.ts +69 -0
- package/src/utils/docs.ts +146 -0
- package/src/utils/packages.ts +453 -0
- package/src/utils/response.ts +125 -0
- package/src/utils/routes.ts +64 -0
- package/src/utils/spa.ts +52 -0
- package/src/utils/tracing.ts +52 -0
- package/src/utils/upstream.ts +172 -0
- package/test/access.test.ts +705 -0
- package/test/audit.test.ts +828 -0
- package/test/dashboard.test.ts +693 -0
- package/test/dist-tags.test.ts +678 -0
- package/test/manifest.test.ts +436 -0
- package/test/packument.test.ts +530 -0
- package/test/ping.test.ts +41 -0
- package/test/search.test.ts +472 -0
- package/test/setup.ts +130 -0
- package/test/static.test.ts +646 -0
- package/test/tokens.test.ts +389 -0
- package/test/utils/auth.test.ts +214 -0
- package/test/utils/packages.test.ts +235 -0
- package/test/utils/response.test.ts +184 -0
- package/test/whoami.test.ts +119 -0
- package/tsconfig.json +16 -0
- package/tsconfig.worker.json +3 -0
- package/typedoc.mjs +2 -0
- package/types.ts +598 -0
- package/vitest.config.ts +25 -0
- package/vlt.json.example +56 -0
- package/wrangler.json +65 -0
package/config.ts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// get openapi schema
|
|
2
|
+
import wranglerJson from './wrangler.json' with { type: 'json' }
|
|
3
|
+
import packageJson from './package.json' with { type: 'json' }
|
|
4
|
+
import { apiBody } from './src/utils/docs.ts'
|
|
5
|
+
import type {
|
|
6
|
+
OriginConfig,
|
|
7
|
+
CookieOptions,
|
|
8
|
+
ApiDocsConfig,
|
|
9
|
+
} from './types.ts'
|
|
10
|
+
|
|
11
|
+
export const YEAR = new Date().getFullYear()
|
|
12
|
+
|
|
13
|
+
export const WRANGLER_CONFIG = wranglerJson.dev
|
|
14
|
+
|
|
15
|
+
export const PORT = WRANGLER_CONFIG.port || (1337 as number)
|
|
16
|
+
|
|
17
|
+
export const TELEMETRY_ENABLED = true as boolean
|
|
18
|
+
|
|
19
|
+
export const HELP_ENABLED = false as boolean
|
|
20
|
+
|
|
21
|
+
// Sentry configuration for error reporting (when telemetry is enabled)
|
|
22
|
+
export const SENTRY_CONFIG = {
|
|
23
|
+
dsn: 'https://909b085eb764c00250ad312660c2fdf1@o4506397716054016.ingest.us.sentry.io/4509492612300800',
|
|
24
|
+
sendDefaultPii: true,
|
|
25
|
+
environment: 'development', // Will be overridden by environment variable
|
|
26
|
+
sampleRate: 1.0,
|
|
27
|
+
tracesSampleRate: 0.1, // Lower sample rate for performance traces
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const DEBUG_ENABLED = false as boolean
|
|
31
|
+
|
|
32
|
+
export const API_DOCS_ENABLED = true as boolean
|
|
33
|
+
|
|
34
|
+
export const DAEMON_ENABLED = true as boolean
|
|
35
|
+
|
|
36
|
+
export const DAEMON_PORT = 3000 as number
|
|
37
|
+
|
|
38
|
+
// Runtime configuration is now handled by configMiddleware
|
|
39
|
+
// which enriches c.env with computed values like DAEMON_ENABLED, TELEMETRY_ENABLED, etc.
|
|
40
|
+
|
|
41
|
+
export const DAEMON_URL = `http://localhost:${DAEMON_PORT}`
|
|
42
|
+
|
|
43
|
+
export const VERSION: string = packageJson.version
|
|
44
|
+
|
|
45
|
+
export const URL = `http://localhost:${PORT}`
|
|
46
|
+
|
|
47
|
+
export const REDIRECT_URI = `${URL}/-/auth/callback`
|
|
48
|
+
|
|
49
|
+
// how to handle packages requests
|
|
50
|
+
export const ORIGIN_CONFIG: OriginConfig = {
|
|
51
|
+
default: 'local',
|
|
52
|
+
upstreams: {
|
|
53
|
+
local: {
|
|
54
|
+
type: 'local',
|
|
55
|
+
url: URL,
|
|
56
|
+
allowPublish: true,
|
|
57
|
+
},
|
|
58
|
+
npm: {
|
|
59
|
+
type: 'npm',
|
|
60
|
+
url: 'https://registry.npmjs.org',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Reserved route prefixes that cannot be used as upstream names
|
|
66
|
+
export const RESERVED_ROUTES: string[] = [
|
|
67
|
+
'-',
|
|
68
|
+
'user',
|
|
69
|
+
'docs',
|
|
70
|
+
'search',
|
|
71
|
+
'tokens',
|
|
72
|
+
'auth',
|
|
73
|
+
'ping',
|
|
74
|
+
'package',
|
|
75
|
+
'v1',
|
|
76
|
+
'api',
|
|
77
|
+
'admin',
|
|
78
|
+
'*', // Reserved for hash-based routes
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
// Backward compatibility - maintain old PROXY behavior
|
|
82
|
+
export const PROXY: boolean =
|
|
83
|
+
Object.keys(ORIGIN_CONFIG.upstreams).length > 1
|
|
84
|
+
|
|
85
|
+
export const PROXY_URL: string | undefined =
|
|
86
|
+
ORIGIN_CONFIG.upstreams[ORIGIN_CONFIG.default]?.url
|
|
87
|
+
|
|
88
|
+
// the time in seconds to cache the registry
|
|
89
|
+
export const REQUEST_TIMEOUT: number = 60 * 1000
|
|
90
|
+
|
|
91
|
+
// cookie options
|
|
92
|
+
export const COOKIE_OPTIONS: CookieOptions = {
|
|
93
|
+
path: '/',
|
|
94
|
+
httpOnly: true,
|
|
95
|
+
secure: true,
|
|
96
|
+
sameSite: 'strict',
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// OpenAPI Docs
|
|
100
|
+
export const OPEN_API_CONFIG = {
|
|
101
|
+
openapi: '3.1.0',
|
|
102
|
+
info: {
|
|
103
|
+
title: 'vlt serverless registry',
|
|
104
|
+
version: VERSION,
|
|
105
|
+
description: 'The vlt serverless registry API',
|
|
106
|
+
},
|
|
107
|
+
tags: [
|
|
108
|
+
{
|
|
109
|
+
name: 'Health Check',
|
|
110
|
+
description: 'Registry health and status endpoints',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'Authentication',
|
|
114
|
+
description: 'User authentication and token management',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'Packages',
|
|
118
|
+
description: 'Package publishing, downloading, and management',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'Dist-Tags',
|
|
122
|
+
description: 'Package version tagging and lifecycle management',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'Access Control',
|
|
126
|
+
description:
|
|
127
|
+
'Package access permissions and collaborator management',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'Search',
|
|
131
|
+
description: 'Package discovery and search functionality',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'Security',
|
|
135
|
+
description: 'Security auditing and vulnerability scanning',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'Dashboard',
|
|
139
|
+
description: 'Registry dashboard and administration',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'Static Assets',
|
|
143
|
+
description: 'Static file serving and web assets',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'NPM Compatibility',
|
|
147
|
+
description: 'Legacy npm client compatibility redirects',
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// the docs configuration for the API reference
|
|
153
|
+
export const SCALAR_API_CONFIG: ApiDocsConfig = {
|
|
154
|
+
metaData: {
|
|
155
|
+
title: 'vlt serverless registry',
|
|
156
|
+
},
|
|
157
|
+
hideModels: false,
|
|
158
|
+
hideDownloadButton: false,
|
|
159
|
+
darkMode: false,
|
|
160
|
+
favicon: '/public/images/favicon/favicon.svg',
|
|
161
|
+
defaultHttpClient: {
|
|
162
|
+
targetKey: 'curl',
|
|
163
|
+
clientKey: 'fetch',
|
|
164
|
+
},
|
|
165
|
+
authentication: {
|
|
166
|
+
http: {
|
|
167
|
+
bearer: {
|
|
168
|
+
token: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
|
169
|
+
},
|
|
170
|
+
basic: {
|
|
171
|
+
username: 'user',
|
|
172
|
+
password: 'pass',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
hiddenClients: {
|
|
177
|
+
python: true,
|
|
178
|
+
c: true,
|
|
179
|
+
go: true,
|
|
180
|
+
java: true,
|
|
181
|
+
ruby: true,
|
|
182
|
+
shell: ['httpie', 'wget', 'fetch'],
|
|
183
|
+
clojure: true,
|
|
184
|
+
csharp: true,
|
|
185
|
+
kotlin: true,
|
|
186
|
+
objc: true,
|
|
187
|
+
swift: true,
|
|
188
|
+
r: true,
|
|
189
|
+
powershell: false,
|
|
190
|
+
ocaml: true,
|
|
191
|
+
curl: false,
|
|
192
|
+
http: true,
|
|
193
|
+
php: true,
|
|
194
|
+
node: ['request', 'unirest'],
|
|
195
|
+
javascript: ['xhr', 'jquery'],
|
|
196
|
+
},
|
|
197
|
+
spec: {
|
|
198
|
+
content: {
|
|
199
|
+
openapi: OPEN_API_CONFIG.openapi,
|
|
200
|
+
servers: [
|
|
201
|
+
{
|
|
202
|
+
url: URL,
|
|
203
|
+
description: 'localhost',
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
info: {
|
|
207
|
+
title: 'vlt serverless registry',
|
|
208
|
+
version: VERSION,
|
|
209
|
+
license: {
|
|
210
|
+
identifier: 'FSL-1.1-MIT',
|
|
211
|
+
name: 'Functional Source License, Version 1.1, MIT Future License',
|
|
212
|
+
url: 'https://fsl.software/FSL-1.1-MIT.template.md',
|
|
213
|
+
},
|
|
214
|
+
description: apiBody({ YEAR }),
|
|
215
|
+
},
|
|
216
|
+
// Include tag ordering and descriptions
|
|
217
|
+
tags: OPEN_API_CONFIG.tags,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
customCss: `@import '${URL}/public/styles/styles.css';`,
|
|
221
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineConfig } from 'drizzle-kit'
|
|
2
|
+
import { join } from 'path'
|
|
3
|
+
import { existsSync, readdirSync } from 'fs'
|
|
4
|
+
|
|
5
|
+
// Find the actual SQLite database file in the miniflare-D1DatabaseObject directory
|
|
6
|
+
const miniflareDir = join(
|
|
7
|
+
import.meta.dirname,
|
|
8
|
+
'./local-store',
|
|
9
|
+
'v3',
|
|
10
|
+
'd1',
|
|
11
|
+
'miniflare-D1DatabaseObject',
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
if (!existsSync(miniflareDir)) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Miniflare directory not found at ${miniflareDir}. Make sure to run \`pnpm run db:setup\` first.`,
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
// Look for the most recently modified SQLite file
|
|
20
|
+
const file = readdirSync(miniflareDir, { withFileTypes: true })
|
|
21
|
+
.filter(file => file.isFile() && file.name.endsWith('.sqlite'))
|
|
22
|
+
.sort((a, b) => b.mtime.getTime() - a.mtime.getTime())
|
|
23
|
+
.map(file => join(file.parentPath, file.name))
|
|
24
|
+
.find(file => existsSync(file))
|
|
25
|
+
|
|
26
|
+
if (!file) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`No SQLite file found in ${miniflareDir}. Make sure to run \`pnpm run db:setup\` first.`,
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// For Drizzle Kit
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
schema: './src/db/schema.ts',
|
|
35
|
+
out: './src/db/migrations',
|
|
36
|
+
dialect: 'sqlite',
|
|
37
|
+
dbCredentials: {
|
|
38
|
+
url: file,
|
|
39
|
+
},
|
|
40
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Registry Comparisons
|
|
2
|
+
|
|
3
|
+
| Feature | **vsr** | **npm** | **GitHub** | **Verdaccio** | **JSR** | **jFrog** | **Sonatype** | **Cloudsmith** | **Buildkite** | **Bit** |
|
|
4
|
+
| ---------------------------- | :-----------: | :-------------: | :-------------: | :-----------: | :-----: | :-------------: | :-------------: | :-------------: | :-------------: | :-------------: |
|
|
5
|
+
| License | `FSL-1.1-MIT` | `Closed Source` | `Closed Source` | `MIT` | `MIT` | `Closed Source` | `Closed Source` | `Closed Source` | `Closed Source` | `Closed Source` |
|
|
6
|
+
| Authored Language | `JavaScript` | `JavaScript` | `Ruby`/`Go` | `TypeScript` | `Rust` | `-` | `-` | `-` | `-` | `-` |
|
|
7
|
+
| Publishing | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
8
|
+
| Installation | ✅ | ✅ | ✅ | ✅ | ✴️ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
9
|
+
| Search | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
10
|
+
| Scoped Packages | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
11
|
+
| Unscoped Packages | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
12
|
+
| Proxying Upstream Sources | ✅ | ❌ | ✴️ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
13
|
+
| Hosted Instance | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
14
|
+
| Hosted Instance Cost | `$` | `-` | `$$$$` | `-` | `-` | `$$$$` | `$$$$` | `$$$$` | `$$$` | `$$$` |
|
|
15
|
+
| Self-Hosted Instance | ✅ | ❌ | ✴️ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
|
|
16
|
+
| Self-Hosted Instance Cost | 🆓 | `-` | `$$$$$` | `$` | `$` | `$$$$$` | `$$$$$` | `-` | `-` | `-` |
|
|
17
|
+
| Hosted Public Packages | ⏳ | ✅ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
18
|
+
| Hosted Private Packages | ⏳ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
19
|
+
| Hosted Private Package Cost | `-` | `$$` | 🆓 | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | 🆓 |
|
|
20
|
+
| Granular Access/Permissions | ✅ | ✴️ | ❌ | ✅ | ❌ | ✴️ | ✴️ | ✴️ | ✴️ | ❌ |
|
|
21
|
+
| Manifest Validation | ✅ | ✴️ | ❌ | ❌ | ✴️ | ✴️ | ✴️ | ❌ | ❌ | ❌ |
|
|
22
|
+
| Audit | 🕤 | ✴️ | ❌ | ✴️ | ✴️ | ✴️ | ✴️ | ✴️ | ❌ | ❌ |
|
|
23
|
+
| Events/Hooks | 🕤 | ❌ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
24
|
+
| Plugins | 🕤 | ❌ | ❌ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
25
|
+
| Multi-Cloud | 🕤 | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
26
|
+
| Documentation Generation | 🕤 | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✴️ |
|
|
27
|
+
| Unpackaged Files/ESM Imports | 🕤 | ❌ | ❌ | ❌ | ✴️ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
28
|
+
| Variant Support | 🕤 | ❌ | ❌ | ❌ | ✴️ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
29
|
+
|
|
30
|
+
#### Legend:
|
|
31
|
+
|
|
32
|
+
- ✅ implemented
|
|
33
|
+
- ✴️ supported with caveats
|
|
34
|
+
- ⏳ in-progress
|
|
35
|
+
- 🕤 planned
|
|
36
|
+
- ❌ unsupported
|
|
37
|
+
- `$` expense estimation (0-5)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
You can use `vsr` as a private local registry, a proxy registry, or
|
|
4
|
+
both. If you want to publish into or consume from the local registry
|
|
5
|
+
you can use `http://localhost:<port>`.
|
|
6
|
+
|
|
7
|
+
To proxy requests to `npm` you can just add `npm` to the pathname (ex.
|
|
8
|
+
`http://localhost:<port>/npm` will proxy all requests to `npmjs.org`)
|
|
9
|
+
|
|
10
|
+
## CLI Configuration
|
|
11
|
+
|
|
12
|
+
VSR supports both development and deployment commands with various
|
|
13
|
+
configuration options:
|
|
14
|
+
|
|
15
|
+
### Development Server (`vsr dev`)
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Start with defaults
|
|
19
|
+
vsr dev
|
|
20
|
+
|
|
21
|
+
# Custom configuration
|
|
22
|
+
vsr dev --port 3000 --debug --config ./vlt.json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Deployment (`vsr deploy`)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Deploy to default environment (dev)
|
|
29
|
+
vsr deploy
|
|
30
|
+
|
|
31
|
+
# Deploy to specific environment
|
|
32
|
+
vsr deploy --env=prod
|
|
33
|
+
|
|
34
|
+
# Override resource names
|
|
35
|
+
vsr deploy --env=staging --db-name=custom-db --bucket-name=custom-bucket
|
|
36
|
+
|
|
37
|
+
# Preview deployment
|
|
38
|
+
vsr deploy --dry-run --env=prod
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Configuration File (`vlt.json`)
|
|
42
|
+
|
|
43
|
+
VSR can be configured using a `vlt.json` file that supports both
|
|
44
|
+
development and deployment settings:
|
|
45
|
+
|
|
46
|
+
### Development Configuration
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"registry": {
|
|
51
|
+
"port": 4000,
|
|
52
|
+
"debug": true,
|
|
53
|
+
"telemetry": false,
|
|
54
|
+
"daemon": true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Deployment Configuration
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"registry": {
|
|
64
|
+
"deploy": {
|
|
65
|
+
"sentry": {
|
|
66
|
+
"dsn": "https://your-default-sentry-dsn@sentry.io/project-id",
|
|
67
|
+
"sampleRate": 1.0,
|
|
68
|
+
"tracesSampleRate": 0.1
|
|
69
|
+
},
|
|
70
|
+
"environments": {
|
|
71
|
+
"dev": {
|
|
72
|
+
"databaseName": "vsr-dev-database",
|
|
73
|
+
"bucketName": "vsr-dev-bucket",
|
|
74
|
+
"queueName": "vsr-dev-cache-refresh-queue",
|
|
75
|
+
"sentry": {
|
|
76
|
+
"environment": "development"
|
|
77
|
+
},
|
|
78
|
+
"vars": {
|
|
79
|
+
"CUSTOM_VAR": "dev-value"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"staging": {
|
|
83
|
+
"databaseName": "vsr-staging-database",
|
|
84
|
+
"bucketName": "vsr-staging-bucket",
|
|
85
|
+
"queueName": "vsr-staging-cache-refresh-queue",
|
|
86
|
+
"sentry": {
|
|
87
|
+
"environment": "staging"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"prod": {
|
|
91
|
+
"databaseName": "vsr-prod-database",
|
|
92
|
+
"bucketName": "vsr-prod-bucket",
|
|
93
|
+
"queueName": "vsr-prod-cache-refresh-queue",
|
|
94
|
+
"sentry": {
|
|
95
|
+
"environment": "production",
|
|
96
|
+
"dsn": "https://your-prod-sentry-dsn@sentry.io/project-id",
|
|
97
|
+
"sampleRate": 0.1,
|
|
98
|
+
"tracesSampleRate": 0.01
|
|
99
|
+
},
|
|
100
|
+
"vars": {
|
|
101
|
+
"API_BASE_URL": "https://api.example.com"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
See the [Deployment Guide](../DEPLOY.md) for complete deployment
|
|
111
|
+
configuration documentation.
|
|
112
|
+
|
|
113
|
+
## Package Manager Integration
|
|
114
|
+
|
|
115
|
+
##### For `vlt`:
|
|
116
|
+
|
|
117
|
+
In your project or user-level `vlt.json` file add the relevant
|
|
118
|
+
configuration.
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"registries": {
|
|
123
|
+
"npm": "http://localhost:1337/npm",
|
|
124
|
+
"local": "http://localhost:1337"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
##### For `npm`, `pnpm`, `yarn` & `bun`:
|
|
130
|
+
|
|
131
|
+
To use `vsr` as your registry you must either pass a registry config
|
|
132
|
+
through a client-specific flag (ex. `--registry=...` for `npm`) or
|
|
133
|
+
define client-specific configuration which stores the reference to
|
|
134
|
+
your registry (ex. `.npmrc` for `npm`). Access to the registry &
|
|
135
|
+
packages is private by default although an `"admin"` user is created
|
|
136
|
+
during setup locally (for development purposes) with a default auth
|
|
137
|
+
token of `"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`.
|
|
138
|
+
|
|
139
|
+
```ini
|
|
140
|
+
; .npmrc
|
|
141
|
+
registry=http://localhost:1337
|
|
142
|
+
//localhost:1337/:_authToken=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|
143
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# VSR Contributing Docs
|
|
2
|
+
|
|
3
|
+
### Getting Started
|
|
4
|
+
|
|
5
|
+
#### Installing
|
|
6
|
+
|
|
7
|
+
- `pnpm install`
|
|
8
|
+
|
|
9
|
+
#### Building
|
|
10
|
+
|
|
11
|
+
- `pnpm build` - will build all parts of the project
|
|
12
|
+
- `pnpm build:dist` - will build dist directories
|
|
13
|
+
- `pnpm build:assets` - will build & move static assets
|
|
14
|
+
- `pnpm build:bin` - will build the bin script
|
|
15
|
+
- `pnpm build:worker` - will build the worker
|
|
16
|
+
|
|
17
|
+
#### Database Operations
|
|
18
|
+
|
|
19
|
+
- `pnpm db:setup`
|
|
20
|
+
- `pnpm db:drop`
|
|
21
|
+
- `pnpm db:studio`
|
|
22
|
+
- `pnpm db:generate`
|
|
23
|
+
- `pnpm db:migrate`
|
|
24
|
+
- `pnpm db:push`
|
|
25
|
+
|
|
26
|
+
#### Serving
|
|
27
|
+
|
|
28
|
+
- `pnpm serve:build` - will build & start the services
|
|
29
|
+
- `pnpm serve:death` - will kill any hanging `wrangler` processes
|
|
30
|
+
(which can happen if you're developing with agents a lot)
|
|
31
|
+
- Post-build you can also directly link/run the bin from
|
|
32
|
+
`./dist/bin/vsr.js`
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# VSR Database Setup Guide
|
|
2
|
+
|
|
3
|
+
This guide explains how to set up the local database for the vlt
|
|
4
|
+
serverless registry.
|
|
5
|
+
|
|
6
|
+
## Quick Setup
|
|
7
|
+
|
|
8
|
+
For a fresh installation, run:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm run db:setup
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
This command will:
|
|
15
|
+
|
|
16
|
+
1. Create the initial database tables (`packages`, `tokens`,
|
|
17
|
+
`versions`)
|
|
18
|
+
2. Apply all necessary schema migrations
|
|
19
|
+
3. Insert a default admin token
|
|
20
|
+
|
|
21
|
+
## Manual Setup
|
|
22
|
+
|
|
23
|
+
If you need to set up the database manually:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Create initial tables
|
|
27
|
+
pnpm exec wrangler d1 execute vsr-local-database --file=src/db/migrations/0000_initial.sql --local --persist-to=local-store --no-remote
|
|
28
|
+
|
|
29
|
+
# Apply schema updates (adds columns: last_updated, origin, upstream, cached_at)
|
|
30
|
+
pnpm exec wrangler d1 execute vsr-local-database --file=src/db/migrations/0001_wealthy_magdalene.sql --local --persist-to=local-store --no-remote
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Database Schema
|
|
34
|
+
|
|
35
|
+
The database includes three main tables:
|
|
36
|
+
|
|
37
|
+
### `packages`
|
|
38
|
+
|
|
39
|
+
- `name` (TEXT, PRIMARY KEY) - Package name (e.g., "lodash",
|
|
40
|
+
"@types/node")
|
|
41
|
+
- `tags` (TEXT) - JSON string of dist-tags (e.g.,
|
|
42
|
+
`{"latest": "1.0.0"}`)
|
|
43
|
+
- `last_updated` (TEXT) - ISO timestamp of last update
|
|
44
|
+
- `origin` (TEXT) - Either "local" or "upstream"
|
|
45
|
+
- `upstream` (TEXT) - Name of upstream registry (for cached packages)
|
|
46
|
+
- `cached_at` (TEXT) - ISO timestamp when cached from upstream
|
|
47
|
+
|
|
48
|
+
### `tokens`
|
|
49
|
+
|
|
50
|
+
- `token` (TEXT, PRIMARY KEY) - Authentication token
|
|
51
|
+
- `uuid` (TEXT) - User identifier
|
|
52
|
+
- `scope` (TEXT) - JSON string of token permissions
|
|
53
|
+
|
|
54
|
+
### `versions`
|
|
55
|
+
|
|
56
|
+
- `spec` (TEXT, PRIMARY KEY) - Package version spec (e.g.,
|
|
57
|
+
"lodash@4.17.21")
|
|
58
|
+
- `manifest` (TEXT) - JSON string of package.json manifest
|
|
59
|
+
- `published_at` (TEXT) - ISO timestamp when version was published
|
|
60
|
+
- `origin` (TEXT) - Either "local" or "upstream"
|
|
61
|
+
- `upstream` (TEXT) - Name of upstream registry (for cached versions)
|
|
62
|
+
- `cached_at` (TEXT) - ISO timestamp when cached from upstream
|
|
63
|
+
|
|
64
|
+
## Common Issues
|
|
65
|
+
|
|
66
|
+
### "no such table: packages"
|
|
67
|
+
|
|
68
|
+
This error means the database hasn't been initialized. Run:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm run db:setup
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### "table packages has no column named last_updated"
|
|
75
|
+
|
|
76
|
+
This means the initial migration ran but the schema update didn't.
|
|
77
|
+
Run:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pnpm exec wrangler d1 execute vsr-local-database --file=src/db/migrations/0001_wealthy_magdalene.sql --local --persist-to=local-store --no-remote
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Reset Database
|
|
84
|
+
|
|
85
|
+
To completely reset the database:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pnpm run db:drop
|
|
89
|
+
pnpm run db:setup
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Database Location
|
|
93
|
+
|
|
94
|
+
The local database is stored in:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
./local-store/v3/d1/miniflare-D1DatabaseObject/
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Default Admin Token
|
|
101
|
+
|
|
102
|
+
The setup creates a default admin token:
|
|
103
|
+
|
|
104
|
+
- **Token**: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`
|
|
105
|
+
- **UUID**: `admin`
|
|
106
|
+
- **Permissions**: Full read/write access to all packages and users
|
|
107
|
+
|
|
108
|
+
⚠️ **Security Note**: Change this token in production environments!
|