Skip to content

Commit cbd4ea9

Browse files
committed
chore: wip
1 parent 5527858 commit cbd4ea9

11 files changed

+66
-57
lines changed

packages/launchpad/src/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-console */
2-
import type { CacheMetadata, SupportedFormat } from './types'
2+
import type { CacheMetadata } from './types'
33
import fs from 'node:fs'
44
import path from 'node:path'
55
import process from 'node:process'

packages/launchpad/src/install-helpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
import fs from 'node:fs'
23
import path from 'node:path'
34
import { config } from './config'

packages/launchpad/src/install-main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
/* eslint-disable no-console */
12
import type { PackageSpec } from './types'
23
import fs from 'node:fs'
34
import { config } from './config'
4-
import { logUniqueMessage, clearMessageCache } from './logging'
55
import { resolveAllDependencies } from './dependency-resolution'
6+
import { installPackage } from './install-core'
7+
import { clearMessageCache, logUniqueMessage } from './logging'
68
import { parsePackageSpec } from './package-resolution'
79
import { install_prefix } from './utils'
8-
import { installPackage } from './install-core'
910

1011
// Global tracker for deduplicating packages across all install calls
1112
const globalInstalledTracker = new Set<string>()

packages/launchpad/src/install.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import type { aliases, packages } from 'ts-pkgx'
21
import { cleanupCache, getCacheStats } from './cache'
32
import { resolveAllDependencies } from './dependency-resolution'
43
import { downloadPackage } from './install-core'
54
import { install } from './install-main'
65
import { cleanupSpinner, resetInstalledTracker } from './logging'
7-
import { getAllPackageAliases, getAllPackageDomains, getAllPackageNames, getAvailableVersions, getLatestVersion, getPackageInfo, isPackageAlias, isPackageDomain, isVersionAvailable, isValidPackageName, listAvailablePackages, parsePackageSpec, resolvePackageName, resolveVersion } from './package-resolution'
6+
import { getAllPackageAliases, getAllPackageDomains, getAllPackageNames, getAvailableVersions, getLatestVersion, getPackageInfo, isPackageAlias, isPackageDomain, isValidPackageName, isVersionAvailable, listAvailablePackages, parsePackageSpec, resolvePackageName, resolveVersion } from './package-resolution'
87
import { buildSqliteFromSource, installDependenciesOnly, testPhpBinary } from './special-installers'
98
import { DISTRIBUTION_CONFIG } from './types'
109
import { install_prefix } from './utils'
@@ -28,8 +27,8 @@ export {
2827
installDependenciesOnly,
2928
isPackageAlias,
3029
isPackageDomain,
31-
isVersionAvailable,
3230
isValidPackageName,
31+
isVersionAvailable,
3332
listAvailablePackages,
3433
parsePackageSpec,
3534
resetInstalledTracker,

packages/launchpad/src/services/manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import process from 'node:process'
88
import { config } from '../config'
99
import { findBinaryInEnvironment, findBinaryInPath } from '../utils'
1010
import { createDefaultServiceConfig, getServiceDefinition } from './definitions'
11-
import { generateLaunchdPlist, generateSystemdService, getServiceFilePath, isPlatformSupported, removeServiceFile, writeLaunchdPlist, writeSystemdService } from './platform'
11+
import { generateLaunchdPlist, generateSystemdService, getServiceFilePath, isPlatformSupported, writeLaunchdPlist, writeSystemdService } from './platform'
1212

1313
// Global service manager state
1414
let serviceManagerState: ServiceManagerState | null = null

packages/launchpad/src/special-installers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable no-console */
2-
import type { SupportedArchitecture, SupportedPlatform } from './types'
32
import { Buffer } from 'node:buffer'
43
import { execSync } from 'node:child_process'
54
import fs from 'node:fs'

packages/launchpad/test/config.test.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('Config', () => {
5858
// Check that activation message contains expected text (may have ANSI codes)
5959
// Strip ANSI escape sequences for testing
6060
const ansiEscapeRegex = new RegExp(`${String.fromCharCode(27)}\\[[\\d;]*m`, 'g')
61-
const cleanMessage = defaultConfig.shellActivationMessage.replace(ansiEscapeRegex, '')
61+
const cleanMessage = defaultConfig.shellActivationMessage?.replace(ansiEscapeRegex, '') || ''
6262
expect(cleanMessage).toContain('Environment activated for {path}')
6363
expect(defaultConfig.shellDeactivationMessage).toBe('⚪ Environment deactivated')
6464
})
@@ -88,10 +88,10 @@ describe('Config', () => {
8888

8989
it('should have valid installation path', () => {
9090
expect(typeof defaultConfig.installPath).toBe('string')
91-
expect(defaultConfig.installPath?.length).toBeGreaterThan(0)
91+
expect(defaultConfig.installPath!.length).toBeGreaterThan(0)
9292

9393
expect(defaultConfig.shimPath).toBeDefined()
94-
expect(defaultConfig.shimPath?.length).toBeGreaterThan(0)
94+
expect(defaultConfig.shimPath!.length).toBeGreaterThan(0)
9595
})
9696

9797
it('should have activation message with path placeholder', () => {
@@ -175,7 +175,7 @@ describe('Config', () => {
175175
it('should have reasonable values', () => {
176176
expect(config.maxRetries).toBeGreaterThan(0)
177177
expect(config.timeout).toBeGreaterThan(0)
178-
expect(config.installPath?.length).toBeGreaterThan(0)
178+
expect((config.installPath ?? '').length).toBeGreaterThan(0)
179179
expect(config.shimPath?.length).toBeGreaterThan(0)
180180
// Shell message validation
181181
expect(config.shellActivationMessage?.length).toBeGreaterThan(0)
@@ -186,7 +186,7 @@ describe('Config', () => {
186186
expect(config).toBeDefined()
187187
expect(config.installPath).toBeDefined()
188188
expect(typeof config.installPath).toBe('string')
189-
expect(config.installPath.length).toBeGreaterThan(0)
189+
expect((config.installPath ?? '').length).toBeGreaterThan(0)
190190

191191
expect(config.shimPath).toBeDefined()
192192
expect(config.shimPath?.length).toBeGreaterThan(0)
@@ -209,18 +209,18 @@ describe('Config', () => {
209209
it('should have valid message content', () => {
210210
const message = config.shellActivationMessage
211211
expect(message).toBeDefined()
212-
expect(message?.length).toBeGreaterThan(0)
212+
expect((message ?? '').length).toBeGreaterThan(0)
213213

214214
const deactivationMessage = config.shellDeactivationMessage
215215
expect(deactivationMessage).toBeDefined()
216-
expect(deactivationMessage?.length).toBeGreaterThan(0)
216+
expect((deactivationMessage ?? '').length).toBeGreaterThan(0)
217217
})
218218

219219
it('should have valid shell message format', () => {
220220
if (config.shellActivationMessage?.includes('{path}')) {
221221
// Test that the message contains valid characters
222-
const validChars = /^[a-zA-Z0-9\s\x1B\[[0-9;]*[a-zA-Z]\{\}\-\_\.\,\:\;\?\!\(\)\[\]\|\/\~`@#$%^&*+=<>"']+$/
223-
expect(validChars.test(config.shellActivationMessage || '')).toBe(true)
222+
const validChars = /^[\w\s{}\-.,:;?!()[\]|/~`@#$%^&*+=<>"']+$/
223+
expect(validChars.test(config.shellActivationMessage ?? '')).toBe(true)
224224

225225
// Test for specific characters that should be present
226226
const requiredChars = ['{', '}', 'p', 'a', 't', 'h']
@@ -233,8 +233,8 @@ describe('Config', () => {
233233

234234
if (config.shellDeactivationMessage) {
235235
// Test that the message contains valid characters
236-
const validChars = /^[a-zA-Z0-9\s\x1B\[[0-9;]*[a-zA-Z]\{\}\-\_\.\,\:\;\?\!\(\)\[\]\|\/\~`@#$%^&*+=<>"']+$/
237-
expect(validChars.test(config.shellDeactivationMessage || '')).toBe(true)
236+
const validChars = /^[\w\s{}\-.,:;?!()[\]|/~`@#$%^&*+=<>"']+$/
237+
expect(validChars.test(config.shellDeactivationMessage ?? '')).toBe(true)
238238
}
239239

240240
expect(config.shellActivationMessage?.trim().length).toBeGreaterThan(0)
@@ -250,15 +250,15 @@ describe('Config', () => {
250250
it('should have valid shim path', () => {
251251
const homePath = process.env.HOME || process.env.USERPROFILE || '~'
252252
const isUnderHome = config.shimPath?.startsWith(homePath) || config.shimPath?.startsWith('~')
253-
const isUnderInstall = config.shimPath?.startsWith(config.installPath)
253+
const isUnderInstall = (config.shimPath ?? '').startsWith(config.installPath ?? '')
254254

255255
expect(config.shimPath).toBeDefined()
256256
expect(config.shimPath?.length).toBeGreaterThan(0)
257257
expect(isUnderHome || isUnderInstall).toBe(true)
258258
})
259259

260260
it('should have valid configuration structure', () => {
261-
expect(config.installPath.length).toBeGreaterThan(0)
261+
expect((config.installPath ?? '').length).toBeGreaterThan(0)
262262
expect(config.shimPath?.length).toBeGreaterThan(0)
263263
})
264264
})
@@ -279,23 +279,23 @@ describe('Config', () => {
279279
it('should handle custom activation messages', () => {
280280
// The activation message should be customizable
281281
const message = config.shellActivationMessage
282-
expect(message.length).toBeGreaterThan(0)
282+
expect((message ?? '').length).toBeGreaterThan(0)
283283
// Should be a valid string that can be used in shell scripts
284284
expect(message).not.toContain('\n')
285285
})
286286

287287
it('should handle custom deactivation messages', () => {
288288
// The deactivation message should be customizable
289289
const message = config.shellDeactivationMessage
290-
expect(message.length).toBeGreaterThan(0)
290+
expect((message ?? '').length).toBeGreaterThan(0)
291291
// Should be a valid string that can be used in shell scripts
292292
expect(message).not.toContain('\n')
293293
})
294294

295295
it('should preserve {path} placeholder in activation message', () => {
296296
// If the activation message contains {path}, it should be preserved
297-
if (config.shellActivationMessage.includes('{path}')) {
298-
expect(config.shellActivationMessage).toContain('{path}')
297+
if ((config.shellActivationMessage ?? '').includes('{path}')) {
298+
expect((config.shellActivationMessage ?? '').includes('{path}')).toBe(true)
299299
}
300300
})
301301

@@ -305,7 +305,7 @@ describe('Config', () => {
305305

306306
// Check activation message
307307
for (const char of unsafeChars) {
308-
if (config.shellActivationMessage.includes(char)) {
308+
if ((config.shellActivationMessage ?? '').includes(char)) {
309309
// If it contains special chars, they should be properly escaped
310310
// This is a warning rather than a hard failure since some messages might intentionally use these
311311
console.warn(`Activation message contains potentially unsafe character: ${char}`)
@@ -314,7 +314,7 @@ describe('Config', () => {
314314

315315
// Check deactivation message
316316
for (const char of unsafeChars) {
317-
if (config.shellDeactivationMessage.includes(char)) {
317+
if ((config.shellDeactivationMessage ?? '').includes(char)) {
318318
console.warn(`Deactivation message contains potentially unsafe character: ${char}`)
319319
}
320320
}
@@ -348,7 +348,7 @@ describe('Config', () => {
348348
// Shim path should typically be under the installation path or home directory
349349
const homePath = process.env.HOME || process.env.USERPROFILE || '~'
350350
const isUnderHome = config.shimPath?.startsWith(homePath) || config.shimPath?.startsWith('~')
351-
const isUnderInstall = config.shimPath?.startsWith(config.installPath)
351+
const isUnderInstall = (config.shimPath ?? '').startsWith(config.installPath ?? '')
352352
expect(isUnderHome || isUnderInstall).toBe(true)
353353
})
354354
})
@@ -362,7 +362,7 @@ describe('Config', () => {
362362

363363
it('should use fallback values when needed', () => {
364364
// Installation path should never be empty
365-
expect(config.installPath?.length).toBeGreaterThan(0)
365+
expect((config.installPath ?? '').length).toBeGreaterThan(0)
366366
expect(config.shimPath?.length).toBeGreaterThan(0)
367367
})
368368
})

packages/launchpad/test/database-auto-creation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import type { ServiceInstance } from '../src/types'
12
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
23
import fs from 'node:fs'
34
import { tmpdir } from 'node:os'
45
import path from 'node:path'
56
import process from 'node:process'
6-
import type { ServiceInstance } from '../src/types'
77

88
// TDD Tests for Database Auto-Creation Functionality
99

packages/launchpad/test/service-auto-setup-regression.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import type { ServiceInstance } from '../src/types'
12
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
23
import fs from 'node:fs'
34
import { tmpdir } from 'node:os'
45
import path from 'node:path'
56
import process from 'node:process'
6-
import type { ServiceInstance } from '../src/types'
77

88
// Mock environment to prevent actual service operations
99
const ORIGINAL_NODE_ENV = process.env.NODE_ENV
@@ -180,6 +180,7 @@ describe('Service Auto-Setup - Regression Tests', () => {
180180
const { resolveServiceTemplateVariables } = await import('../src/services/manager')
181181

182182
const mockService = {
183+
name: 'postgres',
183184
definition: {
184185
name: 'postgres',
185186
displayName: 'PostgreSQL',
@@ -217,6 +218,7 @@ describe('Service Auto-Setup - Regression Tests', () => {
217218
const { resolveServiceTemplateVariables } = await import('../src/services/manager')
218219

219220
const mockService = {
221+
name: 'postgres',
220222
definition: {
221223
name: 'postgres',
222224
displayName: 'PostgreSQL',

0 commit comments

Comments
 (0)