ts-pantry 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/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # ts-pantry
2
+
3
+ TypeScript types for Pantry package manager configuration with **full type validation** for package names and versions.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add -d ts-pantry ts-pkgx
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import type { PantryConfig } from 'ts-pantry'
15
+
16
+ export const config: PantryConfig = {
17
+ dependencies: {
18
+ 'bun.com': '^1.3.0', // ✅ Valid
19
+ 'sqlite.org': '^3.47.2', // ✅ Valid
20
+ // 'bun.com': '^999.999.999', // ❌ TypeScript error: invalid version!
21
+ // 'fake-pkg': 'latest', // ❌ TypeScript error: package doesn't exist!
22
+ },
23
+
24
+ services: {
25
+ enabled: true,
26
+ autoStart: true,
27
+ database: {
28
+ connection: 'sqlite',
29
+ name: 'myapp',
30
+ },
31
+ },
32
+
33
+ verbose: true,
34
+ }
35
+
36
+ export default config
37
+ ```
38
+
39
+ ## Features
40
+
41
+ - **Full Type Validation**: Package names and versions are validated at compile time
42
+ - **IntelliSense Support**: Get autocomplete for all 3000+ packages from the pkgx registry
43
+ - **Version Validation**: Invalid versions trigger TypeScript errors
44
+ - **Zero Configuration**: Just import and use - no additional setup required
45
+
46
+ ## Type Definitions
47
+
48
+ ### `PantryConfig`
49
+
50
+ Main configuration interface for Pantry with all available options.
51
+
52
+ ### `Dependencies`
53
+
54
+ Type-safe dependency specification with version constraints.
55
+
56
+ ### Helper Functions
57
+
58
+ - `definePantryConfig(config)` - Helper to define configuration with full type safety
59
+ - `defineDependencies(deps)` - Helper to define dependencies with type checking
60
+ - `definePackageList(packages)` - Helper to define package arrays
61
+
62
+ ## License
63
+
64
+ MIT
@@ -0,0 +1,417 @@
1
+ import type { Dependencies, PackageAlias, PackageDomain, PackageName, Packages, } from 'ts-pkgx';
2
+ export type {
3
+ PackageAlias,
4
+ PackageDomain,
5
+ PackageName,
6
+ Packages,
7
+ };
8
+ export type { Dependencies, CleanDependencies } from 'ts-pkgx';
9
+ /**
10
+ * Helper function to create fully typed dependencies with package name and version validation
11
+ *
12
+ * This function provides IntelliSense and type safety for both package names AND versions!
13
+ * Invalid package names or versions will cause TypeScript errors.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { defineDependencies } from 'ts-pantry'
18
+ *
19
+ * const deps = defineDependencies({
20
+ * 'bun.com': '^1.3.0', // ✅ Valid
21
+ * 'sqlite.org': '^3.47.2', // ✅ Valid
22
+ * // 'bun.com': '^999.0.0', // ❌ Error: invalid version
23
+ * // 'fake-pkg': 'latest', // ❌ Error: package doesn't exist
24
+ * })
25
+ * ```
26
+ */
27
+ export declare function defineDependencies<const T extends Dependencies>(deps: T): T;
28
+ /**
29
+ * Helper function to create a fully typed dependencies array
30
+ */
31
+ export declare function definePackageList<T extends readonly PackageName[]>(packages: T): T;
32
+ /**
33
+ * Helper function to define Pantry configuration with full type safety
34
+ */
35
+ export declare function definePantryConfig(config: PantryConfig): PantryConfig;
36
+ /**
37
+ * Configuration for the package manager
38
+ */
39
+ export declare const DISTRIBUTION_CONFIG: {
40
+ baseUrl: 'https://dist.pkgx.dev';
41
+ // Future: unknown
42
+ };
43
+ // Type for package dependency specification in config
44
+ export declare interface PackageDependencySpec {
45
+ version?: string
46
+ global?: boolean
47
+ }
48
+ /**
49
+ * Cache metadata structure
50
+ */
51
+ export declare interface CacheMetadata {
52
+ version: string
53
+ packages: Record<string, {
54
+ domain: string
55
+ version: string
56
+ format: string
57
+ downloadedAt: string
58
+ size: number
59
+ checksum?: string
60
+ lastAccessed: string
61
+ }>
62
+ }
63
+ /**
64
+ * GitHub release interface
65
+ */
66
+ export declare interface GitHubRelease {
67
+ tag_name: string
68
+ assets?: Array<{
69
+ name: string
70
+ browser_download_url: string
71
+ }>
72
+ }
73
+ /**
74
+ * Service health check configuration
75
+ */
76
+ export declare interface ServiceHealthCheck {
77
+ command: string | string[]
78
+ interval: number
79
+ timeout: number
80
+ retries: number
81
+ expectedExitCode?: number
82
+ }
83
+ /**
84
+ * Service definition
85
+ */
86
+ export declare interface ServiceDefinition {
87
+ name?: string
88
+ displayName?: string
89
+ description?: string
90
+ packageDomain?: string
91
+ executable: string
92
+ args?: string[]
93
+ env?: Record<string, string>
94
+ dataDirectory?: string
95
+ configFile?: string
96
+ logFile?: string
97
+ pidFile?: string
98
+ port?: number
99
+ workingDirectory?: string
100
+ dependencies?: string[]
101
+ postStartCommands?: string[][]
102
+ healthCheck?: ServiceHealthCheck
103
+ initCommand?: string[]
104
+ supportsGracefulShutdown?: boolean
105
+ config?: Record<string, any>
106
+ extensions?: Record<string, any>
107
+ }
108
+ /**
109
+ * Service instance
110
+ */
111
+ export declare interface ServiceInstance {
112
+ name: string
113
+ status: ServiceStatus
114
+ pid?: number
115
+ startTime?: Date
116
+ lastHealthCheck?: Date
117
+ lastCheckedAt?: Date
118
+ startedAt?: Date
119
+ enabled?: boolean
120
+ definition?: ServiceDefinition
121
+ logFile?: string
122
+ dataDir?: string
123
+ configFile?: string
124
+ config?: Record<string, any>
125
+ }
126
+ /**
127
+ * Service manager state
128
+ */
129
+ export declare interface ServiceManagerState {
130
+ services: Map<string, ServiceInstance>
131
+ operations: ServiceOperation[]
132
+ config?: Record<string, any>
133
+ lastScanTime?: Date
134
+ }
135
+ /**
136
+ * Service operation
137
+ */
138
+ export declare interface ServiceOperation {
139
+ action: 'start' | 'stop' | 'restart' | 'enable' | 'disable'
140
+ serviceName: string
141
+ timestamp: Date
142
+ status: 'pending' | 'running' | 'completed' | 'failed'
143
+ result?: any
144
+ duration?: number
145
+ error?: string
146
+ }
147
+ /**
148
+ * Service configuration
149
+ */
150
+ export declare interface ServiceConfig {
151
+ name: string
152
+ definition: ServiceDefinition
153
+ instances: ServiceInstance[]
154
+ }
155
+ /**
156
+ * Post-setup command configuration
157
+ */
158
+ export declare interface PostSetupCommand {
159
+ name?: string
160
+ command: string
161
+ args?: string[]
162
+ description?: string
163
+ condition?: string
164
+ runInBackground?: boolean
165
+ required?: boolean
166
+ }
167
+ /**
168
+ * Lifecycle hooks configuration
169
+ */
170
+ export declare interface LifecycleHooks {
171
+ enabled?: boolean
172
+ commands?: PostSetupCommand[]
173
+ }
174
+ /**
175
+ * Base Pantry configuration interface without dependencies
176
+ */
177
+ declare interface PantryConfigBase {
178
+ installPath?: string
179
+ forceReinstall?: boolean
180
+ autoAddToPath?: boolean
181
+ autoInstall?: boolean
182
+ installDependencies?: boolean
183
+ installBuildDeps?: boolean | string | string[]
184
+ }
185
+ /**
186
+ * Pantry configuration interface (formerly LaunchpadConfig)
187
+ *
188
+ * FULLY TYPED with validation for both package names AND versions
189
+ */
190
+ export declare interface PantryConfig extends PantryConfigBase {
191
+ dependencies?: Dependencies
192
+ global?: boolean
193
+ shellMessages?: {
194
+ activation?: string
195
+ deactivation?: string
196
+ }
197
+ sudoPassword?: string
198
+ devAware?: boolean
199
+ maxRetries?: number
200
+ timeout?: number
201
+ symlinkVersions?: boolean
202
+ shimPath?: string
203
+ showShellMessages?: boolean
204
+ shellActivationMessage?: string
205
+ shellDeactivationMessage?: string
206
+ useRegistry?: boolean
207
+ installMethod?: string
208
+ cache?: {
209
+ /** Enable caching */
210
+ enabled?: boolean
211
+ /** Maximum cache size in MB */
212
+ maxSize?: number
213
+ /** Cache TTL in hours */
214
+ ttlHours?: number
215
+ /** Auto-cleanup when cache exceeds maxSize */
216
+ autoCleanup?: boolean
217
+ /** Directory for cache storage */
218
+ directory?: string
219
+ /** Enable compression for cached files */
220
+ compression?: boolean
221
+ }
222
+ network?: {
223
+ /** Connection timeout in milliseconds */
224
+ timeout?: number
225
+ /** Max concurrent downloads */
226
+ maxConcurrent?: number
227
+ /** Max retries for failed downloads */
228
+ retries?: number
229
+ /** Proxy configuration */
230
+ proxy?: {
231
+ http?: string
232
+ https?: string
233
+ /** Comma-separated list of hosts to bypass proxy */
234
+ bypass?: string
235
+ }
236
+ /** User agent string for HTTP requests */
237
+ userAgent?: string
238
+ /** Follow redirects */
239
+ followRedirects?: boolean
240
+ }
241
+ security?: {
242
+ /** Verify package signatures */
243
+ verifySignatures?: boolean
244
+ /** Trusted package sources */
245
+ trustedSources?: string[]
246
+ /** Allow packages from untrusted sources */
247
+ allowUntrusted?: boolean
248
+ /** Check for package vulnerabilities */
249
+ checkVulnerabilities?: boolean
250
+ }
251
+ logging?: {
252
+ /** Log level */
253
+ level?: 'debug' | 'info' | 'warn' | 'error'
254
+ /** Log to file */
255
+ toFile?: boolean
256
+ /** Log file path */
257
+ filePath?: string
258
+ /** Max log file size in MB */
259
+ maxFileSize?: number
260
+ /** Number of log files to keep */
261
+ keepFiles?: number
262
+ /** Include timestamps in logs */
263
+ timestamps?: boolean
264
+ /** JSON format logs */
265
+ json?: boolean
266
+ }
267
+ updates?: {
268
+ /** Check for package updates */
269
+ checkForUpdates?: boolean
270
+ /** Auto-update packages */
271
+ autoUpdate?: boolean
272
+ /** Update check frequency in hours */
273
+ checkFrequency?: number
274
+ /** Include pre-release versions */
275
+ includePrereleases?: boolean
276
+ /** Channels to check */
277
+ channels?: ('stable' | 'beta' | 'nightly')[]
278
+ }
279
+ resources?: {
280
+ /** Max disk space for packages in MB */
281
+ maxDiskUsage?: number
282
+ /** Max memory usage for operations in MB */
283
+ maxMemoryUsage?: number
284
+ /** Cleanup old versions automatically */
285
+ autoCleanup?: boolean
286
+ /** Keep N latest versions of each package */
287
+ keepVersions?: number
288
+ }
289
+ profiles?: {
290
+ /** Current active profile */
291
+ active?: string
292
+ /** Development profile settings */
293
+ development?: Partial<PantryConfig>
294
+ /** Production profile settings */
295
+ production?: Partial<PantryConfig>
296
+ /** CI profile settings */
297
+ ci?: Partial<PantryConfig>
298
+ /** Custom profiles */
299
+ custom?: Record<string, Partial<PantryConfig>>
300
+ }
301
+ preSetup?: LifecycleHooks
302
+ postSetup?: LifecycleHooks
303
+ preActivation?: LifecycleHooks
304
+ postActivation?: LifecycleHooks
305
+ services?: {
306
+ /** Enable service management */
307
+ enabled?: boolean
308
+ /** Auto-start services */
309
+ autoStart?: boolean
310
+ /** Alias for autoStart */
311
+ shouldAutoStart?: boolean
312
+ /** Data directory for services */
313
+ dataDir?: string
314
+ /** Log directory for services */
315
+ logDir?: string
316
+ /** Config directory for services */
317
+ configDir?: string
318
+ /** Auto-restart failed services */
319
+ autoRestart?: boolean
320
+ /** Startup timeout in milliseconds */
321
+ startupTimeout?: number
322
+ /** Shutdown timeout in milliseconds */
323
+ shutdownTimeout?: number
324
+ /** Infer services from framework config */
325
+ infer?: boolean
326
+
327
+ /**
328
+ * Database configuration
329
+ */
330
+ database?: {
331
+ /** Database connection type */
332
+ connection?: 'mysql' | 'postgres' | 'postgresql' | 'mariadb' | 'redis' | 'mongodb' | 'sqlite'
333
+ /** Database name to create */
334
+ name?: string
335
+ /** Database username */
336
+ username?: string
337
+ /** Database password */
338
+ password?: string
339
+ /** Authentication method */
340
+ authMethod?: 'trust' | 'md5' | 'scram-sha-256'
341
+ }
342
+
343
+ /**
344
+ * Commands to run after database setup
345
+ * e.g., migrations, seeding
346
+ */
347
+ postDatabaseSetup?: string | string[]
348
+
349
+ /**
350
+ * Framework-specific service detection
351
+ */
352
+ frameworks?: {
353
+ enabled?: boolean
354
+ stacks?: {
355
+ enabled?: boolean
356
+ autoDetect?: boolean
357
+ }
358
+ }
359
+ }
360
+ verbose?: boolean
361
+ }
362
+ export declare interface LaunchdPlist {
363
+ Label: string
364
+ ProgramArguments: string[]
365
+ RunAtLoad: boolean
366
+ KeepAlive?: boolean | {
367
+ SuccessfulExit?: boolean
368
+ NetworkState?: boolean
369
+ }
370
+ StandardOutPath?: string
371
+ StandardErrorPath?: string
372
+ WorkingDirectory?: string
373
+ EnvironmentVariables?: Record<string, string>
374
+ UserName?: string
375
+ }
376
+ export declare interface SystemdService {
377
+ Unit: {
378
+ Description: string
379
+ After?: string[]
380
+ Wants?: string[]
381
+ }
382
+ Service: {
383
+ Type: string
384
+ ExecStart: string
385
+ ExecStop?: string
386
+ WorkingDirectory?: string
387
+ Environment?: string[]
388
+ User?: string
389
+ Restart?: string
390
+ RestartSec?: number
391
+ TimeoutStartSec?: number
392
+ TimeoutStopSec?: number
393
+ PIDFile?: string
394
+ }
395
+ Install: {
396
+ WantedBy: string[]
397
+ }
398
+ }
399
+ /**
400
+ * Pantry dependencies type with FULL validation
401
+ *
402
+ * Uses Dependencies from ts-pkgx which provides full type safety
403
+ * for package names and versions without the Record<string, never> constraint
404
+ * that causes issues when types cross module boundaries.
405
+ */
406
+ export type PantryDependencies = Dependencies
407
+ // Type for package with optional version (allowing string for flexibility)
408
+ export type PackageSpec = string
409
+ // Supported distribution formats
410
+ export type SupportedFormat = 'tar.xz' | 'tar.gz'
411
+ export type SupportedPlatform = 'darwin' | 'linux' | 'windows'
412
+ export type SupportedArchitecture = 'x86-64' | 'aarch64' | 'armv7l'
413
+ /**
414
+ * Service status
415
+ */
416
+ export type ServiceStatus = 'running' | 'stopped' | 'starting' | 'stopping' | 'failed' | 'unknown'
417
+ export default definePantryConfig;
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ // src/index.ts
2
+ function defineDependencies(deps) {
3
+ return deps;
4
+ }
5
+ function definePackageList(packages) {
6
+ return packages;
7
+ }
8
+ var DISTRIBUTION_CONFIG = {
9
+ baseUrl: "https://dist.pkgx.dev"
10
+ };
11
+ function definePantryConfig(config) {
12
+ return config;
13
+ }
14
+ var src_default = definePantryConfig;
15
+ export {
16
+ definePantryConfig,
17
+ definePackageList,
18
+ defineDependencies,
19
+ src_default as default,
20
+ DISTRIBUTION_CONFIG
21
+ };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "ts-pantry",
3
+ "version": "0.7.1",
4
+ "description": "TypeScript types for Pantry package manager configuration",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src"
18
+ ],
19
+ "scripts": {
20
+ "build": "bun build.ts",
21
+ "build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
22
+ "dev": "bun build src/index.ts --outdir dist --target node --format esm --watch",
23
+ "prepublishOnly": "bun run build"
24
+ },
25
+ "keywords": [
26
+ "pantry",
27
+ "package-manager",
28
+ "configuration",
29
+ "types",
30
+ "typescript"
31
+ ],
32
+ "author": "Chris Breuer <chris@stacksjs.org>",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/stacksjs/pantry.git",
37
+ "directory": "packages/ts-pantry"
38
+ },
39
+ "devDependencies": {
40
+ "better-dx": "^0.2.2",
41
+ "ts-pkgx": "^0.4.120",
42
+ "typescript": "^5.9.3"
43
+ }
44
+ }
package/src/index.ts ADDED
@@ -0,0 +1,638 @@
1
+ /**
2
+ * Pantry Configuration Types
3
+ *
4
+ * Comprehensive type definitions for Pantry package manager configuration.
5
+ * Based on the original LaunchpadConfig interface with enhanced documentation.
6
+ *
7
+ * @module ts-pantry
8
+ */
9
+
10
+ import type {
11
+ Dependencies,
12
+ PackageAlias,
13
+ PackageDomain,
14
+ PackageName,
15
+ Packages,
16
+ } from 'ts-pkgx'
17
+
18
+ export type {
19
+ PackageAlias,
20
+ PackageDomain,
21
+ PackageName,
22
+ Packages,
23
+ }
24
+
25
+ // Re-export key types from ts-pkgx
26
+ export type { Dependencies, CleanDependencies } from 'ts-pkgx'
27
+
28
+ /**
29
+ * Pantry dependencies type with FULL validation
30
+ *
31
+ * Uses Dependencies from ts-pkgx which provides full type safety
32
+ * for package names and versions without the Record<string, never> constraint
33
+ * that causes issues when types cross module boundaries.
34
+ */
35
+ export type PantryDependencies = Dependencies
36
+
37
+ /**
38
+ * Helper function to create fully typed dependencies with package name and version validation
39
+ *
40
+ * This function provides IntelliSense and type safety for both package names AND versions!
41
+ * Invalid package names or versions will cause TypeScript errors.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * import { defineDependencies } from 'ts-pantry'
46
+ *
47
+ * const deps = defineDependencies({
48
+ * 'bun.com': '^1.3.0', // ✅ Valid
49
+ * 'sqlite.org': '^3.47.2', // ✅ Valid
50
+ * // 'bun.com': '^999.0.0', // ❌ Error: invalid version
51
+ * // 'fake-pkg': 'latest', // ❌ Error: package doesn't exist
52
+ * })
53
+ * ```
54
+ */
55
+ export function defineDependencies<const T extends Dependencies>(deps: T): T {
56
+ return deps
57
+ }
58
+
59
+ /**
60
+ * Helper function to create a fully typed dependencies array
61
+ */
62
+ export function definePackageList<T extends readonly PackageName[]>(packages: T): T {
63
+ return packages
64
+ }
65
+
66
+ // Type for package with optional version (allowing string for flexibility)
67
+ export type PackageSpec = string
68
+
69
+ // Type for package dependency specification in config
70
+ export interface PackageDependencySpec {
71
+ version?: string
72
+ global?: boolean
73
+ }
74
+
75
+ // Supported distribution formats
76
+ export type SupportedFormat = 'tar.xz' | 'tar.gz'
77
+ export type SupportedPlatform = 'darwin' | 'linux' | 'windows'
78
+ export type SupportedArchitecture = 'x86-64' | 'aarch64' | 'armv7l'
79
+
80
+ /**
81
+ * Configuration for the package manager
82
+ */
83
+ export const DISTRIBUTION_CONFIG = {
84
+ baseUrl: 'https://dist.pkgx.dev',
85
+ // Future: we can switch this to our own endpoint
86
+ // baseUrl: 'https://dist.launchpad.dev',
87
+ }
88
+
89
+ /**
90
+ * Cache metadata structure
91
+ */
92
+ export interface CacheMetadata {
93
+ version: string
94
+ packages: Record<string, {
95
+ domain: string
96
+ version: string
97
+ format: string
98
+ downloadedAt: string
99
+ size: number
100
+ checksum?: string
101
+ lastAccessed: string
102
+ }>
103
+ }
104
+
105
+ /**
106
+ * GitHub release interface
107
+ */
108
+ export interface GitHubRelease {
109
+ tag_name: string
110
+ assets?: Array<{
111
+ name: string
112
+ browser_download_url: string
113
+ }>
114
+ }
115
+
116
+ /**
117
+ * Service health check configuration
118
+ */
119
+ export interface ServiceHealthCheck {
120
+ command: string | string[]
121
+ interval: number
122
+ timeout: number
123
+ retries: number
124
+ expectedExitCode?: number
125
+ }
126
+
127
+ /**
128
+ * Service definition
129
+ */
130
+ export interface ServiceDefinition {
131
+ name?: string
132
+ displayName?: string
133
+ description?: string
134
+ packageDomain?: string
135
+ executable: string
136
+ args?: string[]
137
+ env?: Record<string, string>
138
+ dataDirectory?: string
139
+ configFile?: string
140
+ logFile?: string
141
+ pidFile?: string
142
+ port?: number
143
+ workingDirectory?: string
144
+ dependencies?: string[]
145
+ postStartCommands?: string[][]
146
+ healthCheck?: ServiceHealthCheck
147
+ initCommand?: string[]
148
+ supportsGracefulShutdown?: boolean
149
+ config?: Record<string, any>
150
+ extensions?: Record<string, any>
151
+ }
152
+
153
+ /**
154
+ * Service status
155
+ */
156
+ export type ServiceStatus = 'running' | 'stopped' | 'starting' | 'stopping' | 'failed' | 'unknown'
157
+
158
+ /**
159
+ * Service instance
160
+ */
161
+ export interface ServiceInstance {
162
+ name: string
163
+ status: ServiceStatus
164
+ pid?: number
165
+ startTime?: Date
166
+ lastHealthCheck?: Date
167
+ lastCheckedAt?: Date
168
+ startedAt?: Date
169
+ enabled?: boolean
170
+ definition?: ServiceDefinition
171
+ logFile?: string
172
+ dataDir?: string
173
+ configFile?: string
174
+ config?: Record<string, any>
175
+ }
176
+
177
+ /**
178
+ * Service manager state
179
+ */
180
+ export interface ServiceManagerState {
181
+ services: Map<string, ServiceInstance>
182
+ operations: ServiceOperation[]
183
+ config?: Record<string, any>
184
+ lastScanTime?: Date
185
+ }
186
+
187
+ /**
188
+ * Service operation
189
+ */
190
+ export interface ServiceOperation {
191
+ action: 'start' | 'stop' | 'restart' | 'enable' | 'disable'
192
+ serviceName: string
193
+ timestamp: Date
194
+ status: 'pending' | 'running' | 'completed' | 'failed'
195
+ result?: any
196
+ duration?: number
197
+ error?: string
198
+ }
199
+
200
+ /**
201
+ * Service configuration
202
+ */
203
+ export interface ServiceConfig {
204
+ name: string
205
+ definition: ServiceDefinition
206
+ instances: ServiceInstance[]
207
+ }
208
+
209
+ /**
210
+ * Post-setup command configuration
211
+ */
212
+ export interface PostSetupCommand {
213
+ /** Human-readable name for the command */
214
+ name?: string
215
+ /** Command to execute */
216
+ command: string
217
+ /** Command arguments */
218
+ args?: string[]
219
+ /** Description of what the command does */
220
+ description?: string
221
+ /** Condition that must be met for command to run */
222
+ condition?: string
223
+ /** Whether to run the command in the background */
224
+ runInBackground?: boolean
225
+ /** Whether the command is required to succeed */
226
+ required?: boolean
227
+ }
228
+
229
+ /**
230
+ * Lifecycle hooks configuration
231
+ */
232
+ export interface LifecycleHooks {
233
+ /** Enable lifecycle hooks */
234
+ enabled?: boolean
235
+ /** Commands to run */
236
+ commands?: PostSetupCommand[]
237
+ }
238
+
239
+ /**
240
+ * Base Pantry configuration interface without dependencies
241
+ */
242
+ interface PantryConfigBase {
243
+ /**
244
+ * Installation path for packages
245
+ * @default System-dependent
246
+ */
247
+ installPath?: string
248
+
249
+ /**
250
+ * Force reinstall packages even if they exist
251
+ * @default false
252
+ */
253
+ forceReinstall?: boolean
254
+
255
+ /**
256
+ * Automatically add installed binaries to PATH
257
+ * @default true
258
+ */
259
+ autoAddToPath?: boolean
260
+
261
+ /**
262
+ * Auto-install tools/binaries when referenced
263
+ * @default true
264
+ */
265
+ autoInstall?: boolean
266
+
267
+ /**
268
+ * Install runtime dependencies of requested packages
269
+ * - false: only install explicitly requested packages
270
+ * - true: resolve and install full dependency graphs
271
+ * @default false
272
+ */
273
+ installDependencies?: boolean
274
+
275
+ /**
276
+ * Install package-declared build-time dependencies
277
+ * - false: do not install build-time deps
278
+ * - true: install for all packages
279
+ * - string | string[]: install only for listed package(s)
280
+ * @default false
281
+ */
282
+ installBuildDeps?: boolean | string | string[]
283
+ }
284
+
285
+ /**
286
+ * Pantry configuration interface (formerly LaunchpadConfig)
287
+ *
288
+ * FULLY TYPED with validation for both package names AND versions
289
+ */
290
+ export interface PantryConfig extends PantryConfigBase {
291
+ /**
292
+ * Package dependencies to install (similar to deps.yaml)
293
+ * FULLY TYPED package names AND versions from ts-pkgx
294
+ *
295
+ * Supports both domain names ('bun.com') and aliases ('bun')
296
+ * Invalid package names and versions will cause TypeScript errors
297
+ *
298
+ * @example
299
+ * ```ts
300
+ * dependencies: {
301
+ * 'bun.com': '^1.3.0',
302
+ * 'sqlite.org': '^3.47.2',
303
+ * }
304
+ * ```
305
+ */
306
+ dependencies?: Dependencies
307
+
308
+ /**
309
+ * Install all dependencies globally (system-wide)
310
+ * @default false
311
+ */
312
+ global?: boolean
313
+
314
+ /**
315
+ * Shell activation/deactivation messages
316
+ */
317
+ shellMessages?: {
318
+ activation?: string
319
+ deactivation?: string
320
+ }
321
+
322
+ /**
323
+ * Sudo password for operations requiring elevated privileges
324
+ */
325
+ sudoPassword?: string
326
+
327
+ /**
328
+ * Enable development-aware features
329
+ * @default false
330
+ */
331
+ devAware?: boolean
332
+
333
+ /**
334
+ * Maximum retries for failed operations
335
+ * @default 3
336
+ */
337
+ maxRetries?: number
338
+
339
+ /**
340
+ * Operation timeout in milliseconds
341
+ * @default 30000
342
+ */
343
+ timeout?: number
344
+
345
+ /**
346
+ * Create symlinks for different package versions
347
+ * @default false
348
+ */
349
+ symlinkVersions?: boolean
350
+
351
+ /**
352
+ * Path for shell shims
353
+ */
354
+ shimPath?: string
355
+
356
+ /**
357
+ * Show shell activation/deactivation messages
358
+ * @default true
359
+ */
360
+ showShellMessages?: boolean
361
+
362
+ /**
363
+ * Custom shell activation message
364
+ */
365
+ shellActivationMessage?: string
366
+
367
+ /**
368
+ * Custom shell deactivation message
369
+ */
370
+ shellDeactivationMessage?: string
371
+
372
+ /**
373
+ * Use package registry for lookups
374
+ * @default true
375
+ */
376
+ useRegistry?: boolean
377
+
378
+ /**
379
+ * Installation method to use
380
+ */
381
+ installMethod?: string
382
+
383
+ /**
384
+ * Cache configuration
385
+ */
386
+ cache?: {
387
+ /** Enable caching */
388
+ enabled?: boolean
389
+ /** Maximum cache size in MB */
390
+ maxSize?: number
391
+ /** Cache TTL in hours */
392
+ ttlHours?: number
393
+ /** Auto-cleanup when cache exceeds maxSize */
394
+ autoCleanup?: boolean
395
+ /** Directory for cache storage */
396
+ directory?: string
397
+ /** Enable compression for cached files */
398
+ compression?: boolean
399
+ }
400
+
401
+ /**
402
+ * Network and download configuration
403
+ */
404
+ network?: {
405
+ /** Connection timeout in milliseconds */
406
+ timeout?: number
407
+ /** Max concurrent downloads */
408
+ maxConcurrent?: number
409
+ /** Max retries for failed downloads */
410
+ retries?: number
411
+ /** Proxy configuration */
412
+ proxy?: {
413
+ http?: string
414
+ https?: string
415
+ /** Comma-separated list of hosts to bypass proxy */
416
+ bypass?: string
417
+ }
418
+ /** User agent string for HTTP requests */
419
+ userAgent?: string
420
+ /** Follow redirects */
421
+ followRedirects?: boolean
422
+ }
423
+
424
+ /**
425
+ * Security configuration
426
+ */
427
+ security?: {
428
+ /** Verify package signatures */
429
+ verifySignatures?: boolean
430
+ /** Trusted package sources */
431
+ trustedSources?: string[]
432
+ /** Allow packages from untrusted sources */
433
+ allowUntrusted?: boolean
434
+ /** Check for package vulnerabilities */
435
+ checkVulnerabilities?: boolean
436
+ }
437
+
438
+ /**
439
+ * Logging configuration
440
+ */
441
+ logging?: {
442
+ /** Log level */
443
+ level?: 'debug' | 'info' | 'warn' | 'error'
444
+ /** Log to file */
445
+ toFile?: boolean
446
+ /** Log file path */
447
+ filePath?: string
448
+ /** Max log file size in MB */
449
+ maxFileSize?: number
450
+ /** Number of log files to keep */
451
+ keepFiles?: number
452
+ /** Include timestamps in logs */
453
+ timestamps?: boolean
454
+ /** JSON format logs */
455
+ json?: boolean
456
+ }
457
+
458
+ /**
459
+ * Update policies
460
+ */
461
+ updates?: {
462
+ /** Check for package updates */
463
+ checkForUpdates?: boolean
464
+ /** Auto-update packages */
465
+ autoUpdate?: boolean
466
+ /** Update check frequency in hours */
467
+ checkFrequency?: number
468
+ /** Include pre-release versions */
469
+ includePrereleases?: boolean
470
+ /** Channels to check */
471
+ channels?: ('stable' | 'beta' | 'nightly')[]
472
+ }
473
+
474
+ /**
475
+ * Resource management
476
+ */
477
+ resources?: {
478
+ /** Max disk space for packages in MB */
479
+ maxDiskUsage?: number
480
+ /** Max memory usage for operations in MB */
481
+ maxMemoryUsage?: number
482
+ /** Cleanup old versions automatically */
483
+ autoCleanup?: boolean
484
+ /** Keep N latest versions of each package */
485
+ keepVersions?: number
486
+ }
487
+
488
+ /**
489
+ * Environment profiles for different contexts
490
+ */
491
+ profiles?: {
492
+ /** Current active profile */
493
+ active?: string
494
+ /** Development profile settings */
495
+ development?: Partial<PantryConfig>
496
+ /** Production profile settings */
497
+ production?: Partial<PantryConfig>
498
+ /** CI profile settings */
499
+ ci?: Partial<PantryConfig>
500
+ /** Custom profiles */
501
+ custom?: Record<string, Partial<PantryConfig>>
502
+ }
503
+
504
+ /**
505
+ * Commands to run before any installation/services
506
+ */
507
+ preSetup?: LifecycleHooks
508
+
509
+ /**
510
+ * Commands to run after environment is prepared
511
+ */
512
+ postSetup?: LifecycleHooks
513
+
514
+ /**
515
+ * Commands to run just before activation
516
+ */
517
+ preActivation?: LifecycleHooks
518
+
519
+ /**
520
+ * Commands to run right after activation completes
521
+ */
522
+ postActivation?: LifecycleHooks
523
+
524
+ /**
525
+ * Service management configuration
526
+ */
527
+ services?: {
528
+ /** Enable service management */
529
+ enabled?: boolean
530
+ /** Auto-start services */
531
+ autoStart?: boolean
532
+ /** Alias for autoStart */
533
+ shouldAutoStart?: boolean
534
+ /** Data directory for services */
535
+ dataDir?: string
536
+ /** Log directory for services */
537
+ logDir?: string
538
+ /** Config directory for services */
539
+ configDir?: string
540
+ /** Auto-restart failed services */
541
+ autoRestart?: boolean
542
+ /** Startup timeout in milliseconds */
543
+ startupTimeout?: number
544
+ /** Shutdown timeout in milliseconds */
545
+ shutdownTimeout?: number
546
+ /** Infer services from framework config */
547
+ infer?: boolean
548
+
549
+ /**
550
+ * Database configuration
551
+ */
552
+ database?: {
553
+ /** Database connection type */
554
+ connection?: 'mysql' | 'postgres' | 'postgresql' | 'mariadb' | 'redis' | 'mongodb' | 'sqlite'
555
+ /** Database name to create */
556
+ name?: string
557
+ /** Database username */
558
+ username?: string
559
+ /** Database password */
560
+ password?: string
561
+ /** Authentication method */
562
+ authMethod?: 'trust' | 'md5' | 'scram-sha-256'
563
+ }
564
+
565
+ /**
566
+ * Commands to run after database setup
567
+ * e.g., migrations, seeding
568
+ */
569
+ postDatabaseSetup?: string | string[]
570
+
571
+ /**
572
+ * Framework-specific service detection
573
+ */
574
+ frameworks?: {
575
+ enabled?: boolean
576
+ stacks?: {
577
+ enabled?: boolean
578
+ autoDetect?: boolean
579
+ }
580
+ }
581
+ }
582
+
583
+ /**
584
+ * Enable verbose output
585
+ * @default false
586
+ */
587
+ verbose?: boolean
588
+ }
589
+
590
+ export interface LaunchdPlist {
591
+ Label: string
592
+ ProgramArguments: string[]
593
+ RunAtLoad: boolean
594
+ KeepAlive?: boolean | {
595
+ SuccessfulExit?: boolean
596
+ NetworkState?: boolean
597
+ }
598
+ StandardOutPath?: string
599
+ StandardErrorPath?: string
600
+ WorkingDirectory?: string
601
+ EnvironmentVariables?: Record<string, string>
602
+ UserName?: string
603
+ }
604
+
605
+ export interface SystemdService {
606
+ Unit: {
607
+ Description: string
608
+ After?: string[]
609
+ Wants?: string[]
610
+ }
611
+ Service: {
612
+ Type: string
613
+ ExecStart: string
614
+ ExecStop?: string
615
+ WorkingDirectory?: string
616
+ Environment?: string[]
617
+ User?: string
618
+ Restart?: string
619
+ RestartSec?: number
620
+ TimeoutStartSec?: number
621
+ TimeoutStopSec?: number
622
+ PIDFile?: string
623
+ }
624
+ Install: {
625
+ WantedBy: string[]
626
+ }
627
+ }
628
+
629
+ /**
630
+ * Helper function to define Pantry configuration with full type safety
631
+ */
632
+ export function definePantryConfig(
633
+ config: PantryConfig
634
+ ): PantryConfig {
635
+ return config
636
+ }
637
+
638
+ export default definePantryConfig