Skip to content

Commit ecfd2e0

Browse files
committed
chore: wip
1 parent 9d697c7 commit ecfd2e0

10 files changed

+295
-9
lines changed

check-git-versions.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bun
2+
/* eslint-disable no-console */
3+
4+
import { packages } from 'ts-pkgx'
5+
6+
// Check if git-scm.com exists in the packages
7+
if (packages['git-scm.com']) {
8+
console.log('Git versions available in ts-pkgx:')
9+
console.log(JSON.stringify(packages['git-scm.com'], null, 2))
10+
}
11+
else {
12+
console.log('git-scm.com not found in ts-pkgx packages')
13+
14+
// Check if git is available as an alias
15+
const { aliases } = await import('ts-pkgx')
16+
if (aliases.git) {
17+
console.log(`Git is aliased to: ${aliases.git}`)
18+
19+
// Check if the aliased package exists
20+
const aliasedPackage = aliases.git
21+
if (packages[aliasedPackage]) {
22+
console.log(`Aliased package versions:`, JSON.stringify(packages[aliasedPackage], null, 2))
23+
}
24+
else {
25+
console.log(`Aliased package ${aliasedPackage} not found in packages`)
26+
}
27+
}
28+
else {
29+
console.log('git is not defined as an alias in ts-pkgx')
30+
}
31+
32+
// List all available packages starting with git
33+
console.log('\nPackages related to git:')
34+
for (const pkg in packages) {
35+
if (pkg.includes('git')) {
36+
console.log(`- ${pkg}`)
37+
}
38+
}
39+
}

packages/launchpad/check-aliases.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bun
2+
/* eslint-disable no-console */
3+
4+
import { aliases } from 'ts-pkgx'
5+
import { resolvePackageName } from './src/package-resolution'
6+
7+
// Check git alias
8+
console.log('Git alias in ts-pkgx:', aliases.git)
9+
console.log('Resolved git to:', resolvePackageName('git'))
10+
11+
// Check if the alias is correctly mapped
12+
if (aliases.git === 'git-scm.com' && resolvePackageName('git') === 'git-scm.com') {
13+
console.log('\n⚠️ Problem detected: The git alias points to git-scm.com but the actual package is git-scm.org')
14+
console.log('This is causing the installation failure.')
15+
}
16+
17+
// Check all aliases to find git-related ones
18+
console.log('\nAll aliases in ts-pkgx:')
19+
for (const [alias, domain] of Object.entries(aliases)) {
20+
console.log(`${alias} -> ${domain}`)
21+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bun
2+
/* eslint-disable no-console */
3+
4+
import { aliases, packages } from 'ts-pkgx'
5+
6+
// Check all aliases to find git-related ones
7+
console.log('Git-related aliases in ts-pkgx:')
8+
for (const [alias, domain] of Object.entries(aliases)) {
9+
if (alias.includes('git')) {
10+
console.log(`${alias} -> ${domain}`)
11+
}
12+
}
13+
14+
// Check for git-scm.org domain
15+
if (packages['git-scm.org']) {
16+
console.log('\nGit versions available in ts-pkgx (git-scm.org):')
17+
console.log(JSON.stringify(packages['git-scm.org'], null, 2))
18+
}
19+
20+
// Check for git package
21+
if (packages.git) {
22+
console.log('\nGit package info:')
23+
console.log(JSON.stringify(packages.git, null, 2))
24+
}
25+
26+
// Check for git in packages
27+
const gitPackage = Object.keys(packages).find(pkg => pkg === 'git')
28+
if (gitPackage) {
29+
console.log(`\nFound git package: ${gitPackage}`)
30+
console.log(JSON.stringify(packages[gitPackage], null, 2))
31+
}
32+
33+
// Find any package that might be git
34+
console.log('\nSearching for exact git packages:')
35+
for (const pkg in packages) {
36+
if (pkg === 'git' || pkg.endsWith('/git')) {
37+
console.log(`- ${pkg}:`, JSON.stringify(packages[pkg], null, 2))
38+
}
39+
}

packages/launchpad/check-git-scm.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bun
2+
/* eslint-disable no-console */
3+
4+
import { aliases, packages } from 'ts-pkgx'
5+
import { getAvailableVersions, getLatestVersion, resolvePackageName } from './src/package-resolution'
6+
7+
console.log('Git alias in ts-pkgx:', aliases.git)
8+
console.log('Resolved git to:', resolvePackageName('git'))
9+
10+
// Check for git-scm.com in packages
11+
console.log('\nIs git-scm.com in packages?', 'git-scm.com' in packages)
12+
13+
// Check latest version
14+
console.log('\nLatest version of git-scm.com:', getLatestVersion('git-scm.com'))
15+
16+
// Check available versions
17+
console.log('\nAvailable versions of git-scm.com:', getAvailableVersions('git-scm.com'))
18+
19+
// Dump all package keys
20+
console.log('\nAll package keys (first 20):')
21+
console.log(Object.keys(packages).slice(0, 20))
22+
23+
// Check if git-scm.org exists
24+
console.log('\nIs git-scm.org in packages?', 'git-scm.org' in packages)
25+
26+
// Check if gitscm.org exists
27+
console.log('\nIs gitscm.org in packages?', 'gitscm.org' in packages)
28+
29+
// Check if git exists
30+
console.log('\nIs git in packages?', 'git' in packages)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bun
2+
/* eslint-disable no-console */
3+
4+
import { aliases, packages } from 'ts-pkgx'
5+
6+
console.log('Git alias in ts-pkgx:', aliases.git)
7+
8+
// Check for git-scm.com domain
9+
if (packages['git-scm.com']) {
10+
console.log('\nGit versions available in ts-pkgx:')
11+
console.log(JSON.stringify(packages['git-scm.com'], null, 2))
12+
}
13+
else {
14+
console.log('\ngit-scm.com not found in ts-pkgx packages')
15+
}
16+
17+
// Check for git-scm.org domain
18+
if (packages['git-scm.org']) {
19+
console.log('\nGit versions available in ts-pkgx (git-scm.org):')
20+
console.log(JSON.stringify(packages['git-scm.org'], null, 2))
21+
}
22+
else {
23+
console.log('\ngit-scm.org not found in ts-pkgx packages')
24+
}
25+
26+
// Check for gitscm.org domain
27+
if (packages['gitscm.org']) {
28+
console.log('\nGit versions available in ts-pkgx (gitscm.org):')
29+
console.log(JSON.stringify(packages['gitscm.org'], null, 2))
30+
}
31+
else {
32+
console.log('\ngitscm.org not found in ts-pkgx packages')
33+
}
34+
35+
// List all git-related packages with versions
36+
console.log('\nGit-related packages with versions:')
37+
const gitPackages = Object.keys(packages).filter(pkg => pkg.includes('git'))
38+
39+
for (const pkg of gitPackages.slice(0, 5)) {
40+
console.log(`\n${pkg}:`, JSON.stringify(packages[pkg], null, 2))
41+
}

packages/launchpad/src/dev/shellcode.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,16 @@ __launchpad_switch_environment() {
105105
fi
106106
107107
# Step 2: Always ensure global paths are available (even in projects)
108+
# Use ~/.local/bin first, then launchpad global bin to ensure proper path priority
109+
local local_bin="$HOME/.local/bin"
108110
local global_bin="$HOME/.local/share/launchpad/global/bin"
111+
112+
# Add ~/.local/bin to PATH if not already there
113+
if [[ -d "$local_bin" && ":$PATH:" != *":$local_bin:"* ]]; then
114+
export PATH="$local_bin:$PATH"
115+
fi
116+
117+
# Add launchpad global bin to PATH if not already there
109118
if [[ -d "$global_bin" && ":$PATH:" != *":$global_bin:"* ]]; then
110119
export PATH="$global_bin:$PATH"
111120
fi

packages/launchpad/src/install-helpers.ts

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -948,14 +948,20 @@ export async function createGlobalBinarySymlinks(globalEnvDir: string): Promise<
948948
const globalBinDir = path.join(globalEnvDir, 'bin')
949949
const localBinDir = path.join(homedir(), '.local', 'bin')
950950

951-
// Ensure ~/.local/bin exists
951+
// Ensure ~/.local/bin exists and is in PATH
952952
await fs.promises.mkdir(localBinDir, { recursive: true })
953953

954+
// Add ~/.local/bin to PATH if not already there (for this process)
955+
if (!process.env.PATH?.includes(localBinDir)) {
956+
process.env.PATH = `${localBinDir}:${process.env.PATH || ''}`
957+
}
958+
954959
if (!fs.existsSync(globalBinDir)) {
955960
return // No global binaries to link
956961
}
957962

958963
const binaries = await fs.promises.readdir(globalBinDir)
964+
const createdSymlinks: string[] = []
959965

960966
for (const binary of binaries) {
961967
const sourcePath = path.join(globalBinDir, binary)
@@ -967,14 +973,43 @@ export async function createGlobalBinarySymlinks(globalEnvDir: string): Promise<
967973
continue
968974
}
969975

970-
// Remove existing symlink if it exists
971-
if (fs.existsSync(targetPath)) {
972-
await fs.promises.unlink(targetPath)
976+
try {
977+
// Remove existing symlink if it exists
978+
if (fs.existsSync(targetPath)) {
979+
// Check if it's already a symlink to our source
980+
if (fs.lstatSync(targetPath).isSymbolicLink()) {
981+
const currentTarget = fs.readlinkSync(targetPath)
982+
if (currentTarget === sourcePath) {
983+
// Already correctly linked, skip
984+
continue
985+
}
986+
}
987+
await fs.promises.unlink(targetPath)
988+
}
989+
990+
// Create new symlink
991+
await fs.promises.symlink(sourcePath, targetPath)
992+
createdSymlinks.push(binary)
993+
994+
// Ensure the symlink is executable
995+
await fs.promises.chmod(targetPath, 0o755)
996+
}
997+
catch (err) {
998+
if (config.verbose) {
999+
console.warn(`Failed to create symlink for ${binary}:`, err)
1000+
}
9731001
}
1002+
}
9741003

975-
// Create new symlink
976-
await fs.promises.symlink(sourcePath, targetPath)
1004+
if (config.verbose && createdSymlinks.length > 0) {
1005+
console.log(`Created ${createdSymlinks.length} symlinks in ~/.local/bin`)
9771006
}
1007+
1008+
// Create a marker file to trigger shell refresh
1009+
const cacheDir = path.join(homedir(), '.cache', 'launchpad', 'shell_cache')
1010+
await fs.promises.mkdir(cacheDir, { recursive: true })
1011+
const refreshMarker = path.join(cacheDir, 'global_refresh_needed')
1012+
await fs.promises.writeFile(refreshMarker, new Date().toISOString())
9781013
}
9791014
catch (error) {
9801015
// Don't fail the whole installation if symlink creation fails

packages/launchpad/src/package-resolution.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { config } from './config'
99
export function resolvePackageName(packageName: string): string {
1010
// First check for known incorrect aliases that need to be overridden
1111
const overrideAliases: Record<string, string> = {
12-
// ts-pkgx correctly maps git to git-scm.com, so no override needed
12+
// Fix git domain mismatch between ts-pkgx alias (git-scm.com) and actual package domain (git-scm.org)
13+
'git-scm.com': 'git-scm.org',
14+
'git': 'git-scm.org',
1315
}
1416

1517
if (overrideAliases[packageName]) {
@@ -134,7 +136,13 @@ export function resolvePackageName(packageName: string): string {
134136
* Gets the latest version for a package
135137
*/
136138
export function getLatestVersion(packageName: string): string | null {
137-
const domain = resolvePackageName(packageName)
139+
// Handle special case for git-scm.com -> git-scm.org mapping
140+
let domain = resolvePackageName(packageName)
141+
142+
// Special handling for git-scm.com which should map to git-scm.org
143+
if (domain === 'git-scm.com') {
144+
domain = 'git-scm.org'
145+
}
138146

139147
// First, try to find the package by iterating through all packages and matching the domain
140148
for (const [_, pkg] of Object.entries(packages)) {
@@ -165,7 +173,13 @@ export function getLatestVersion(packageName: string): string | null {
165173
* Gets all available versions for a package
166174
*/
167175
export function getAvailableVersions(packageName: string): string[] {
168-
const domain = resolvePackageName(packageName)
176+
// Handle special case for git-scm.com -> git-scm.org mapping
177+
let domain = resolvePackageName(packageName)
178+
179+
// Special handling for git-scm.com which should map to git-scm.org
180+
if (domain === 'git-scm.com') {
181+
domain = 'git-scm.org'
182+
}
169183

170184
// First, try to find the package by iterating through all packages and matching the domain
171185
for (const [_, pkg] of Object.entries(packages)) {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bun
2+
/* eslint-disable no-console */
3+
4+
import { getAvailableVersions, getLatestVersion, resolvePackageName } from './src/package-resolution'
5+
6+
console.log('Testing git package resolution fix:')
7+
console.log('----------------------------------')
8+
9+
// Test git alias resolution
10+
console.log('Resolving git package name:')
11+
console.log(`git -> ${resolvePackageName('git')}`)
12+
console.log(`git-scm.com -> ${resolvePackageName('git-scm.com')}`)
13+
console.log(`git-scm.org -> ${resolvePackageName('git-scm.org')}`)
14+
15+
// Test latest version resolution
16+
console.log('\nGetting latest version:')
17+
console.log(`git: ${getLatestVersion('git')}`)
18+
console.log(`git-scm.com: ${getLatestVersion('git-scm.com')}`)
19+
console.log(`git-scm.org: ${getLatestVersion('git-scm.org')}`)
20+
21+
// Test available versions
22+
console.log('\nGetting available versions:')
23+
console.log(`git: ${getAvailableVersions('git').slice(0, 5).join(', ')}... (${getAvailableVersions('git').length} versions)`)
24+
console.log(`git-scm.com: ${getAvailableVersions('git-scm.com').slice(0, 5).join(', ')}... (${getAvailableVersions('git-scm.com').length} versions)`)
25+
console.log(`git-scm.org: ${getAvailableVersions('git-scm.org').slice(0, 5).join(', ')}... (${getAvailableVersions('git-scm.org').length} versions)`)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { describe, expect, it } from 'bun:test'
2+
import { getAvailableVersions, getLatestVersion, resolvePackageName } from '../src/package-resolution'
3+
4+
describe('Git package resolution', () => {
5+
it('should resolve git to git-scm.org', () => {
6+
expect(resolvePackageName('git')).toBe('git-scm.org')
7+
})
8+
9+
it('should resolve git-scm.com to git-scm.org', () => {
10+
expect(resolvePackageName('git-scm.com')).toBe('git-scm.org')
11+
})
12+
13+
it('should get the latest version of git', () => {
14+
const latestVersion = getLatestVersion('git')
15+
expect(latestVersion).toBeTruthy()
16+
expect(typeof latestVersion).toBe('string')
17+
})
18+
19+
it('should get available versions for git', () => {
20+
const versions = getAvailableVersions('git')
21+
expect(versions.length).toBeGreaterThan(0)
22+
expect(Array.isArray(versions)).toBe(true)
23+
})
24+
25+
it('should get the same versions for git, git-scm.com, and git-scm.org', () => {
26+
const gitVersions = getAvailableVersions('git')
27+
const gitScmComVersions = getAvailableVersions('git-scm.com')
28+
const gitScmOrgVersions = getAvailableVersions('git-scm.org')
29+
30+
expect(gitVersions).toEqual(gitScmOrgVersions)
31+
expect(gitScmComVersions).toEqual(gitScmOrgVersions)
32+
})
33+
})

0 commit comments

Comments
 (0)