@naarang/ccc 2.2.0 → 3.0.0-beta.2
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 +261 -261
- package/bin/ccc.cjs +82 -82
- package/dist/index.js +116 -101
- package/dist/scripts/build-binaries.ts +539 -533
- package/dist/scripts/build-dist.ts +36 -36
- package/dist/scripts/install.ps1 +208 -208
- package/dist/scripts/postinstall.cjs +84 -84
- package/package.json +88 -86
- package/scripts/build-binaries.ts +539 -533
- package/scripts/build-dist.ts +36 -36
- package/scripts/install.ps1 +208 -208
- package/scripts/postinstall.cjs +84 -84
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build script for creating the npm distribution with embedded version
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { $ } from 'bun';
|
|
6
|
-
import { readFileSync, rmSync, existsSync, cpSync } from 'fs';
|
|
7
|
-
import { join } from 'path';
|
|
8
|
-
|
|
9
|
-
// Read version from package.json
|
|
10
|
-
const packageJson = JSON.parse(readFileSync(join(import.meta.dir, '..', 'package.json'), 'utf-8'));
|
|
11
|
-
const VERSION = packageJson.version;
|
|
12
|
-
|
|
13
|
-
console.log(`Building CCC v${VERSION} for npm distribution`);
|
|
14
|
-
|
|
15
|
-
// Clean dist directory
|
|
16
|
-
const distDir = join(import.meta.dir, '..', 'dist');
|
|
17
|
-
if (existsSync(distDir)) {
|
|
18
|
-
rmSync(distDir, { recursive: true });
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Build with version define
|
|
22
|
-
try {
|
|
23
|
-
await $`bun build src/index.ts --outdir dist --target bun --minify --external bun-pty --external expo-server-sdk --external @ngrok/ngrok --define BUILD_VERSION='"${VERSION}"'`;
|
|
24
|
-
console.log('✓ Built dist/index.js');
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error('✗ Build failed:', error);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Copy scripts (cross-platform)
|
|
31
|
-
const scriptsDir = join(import.meta.dir, '..', 'scripts');
|
|
32
|
-
const distScriptsDir = join(distDir, 'scripts');
|
|
33
|
-
cpSync(scriptsDir, distScriptsDir, { recursive: true });
|
|
34
|
-
console.log('✓ Copied scripts to dist/scripts');
|
|
35
|
-
|
|
36
|
-
console.log('\nBuild complete!');
|
|
1
|
+
/**
|
|
2
|
+
* Build script for creating the npm distribution with embedded version
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { $ } from 'bun';
|
|
6
|
+
import { readFileSync, rmSync, existsSync, cpSync } from 'fs';
|
|
7
|
+
import { join } from 'path';
|
|
8
|
+
|
|
9
|
+
// Read version from package.json
|
|
10
|
+
const packageJson = JSON.parse(readFileSync(join(import.meta.dir, '..', 'package.json'), 'utf-8'));
|
|
11
|
+
const VERSION = packageJson.version;
|
|
12
|
+
|
|
13
|
+
console.log(`Building CCC v${VERSION} for npm distribution`);
|
|
14
|
+
|
|
15
|
+
// Clean dist directory
|
|
16
|
+
const distDir = join(import.meta.dir, '..', 'dist');
|
|
17
|
+
if (existsSync(distDir)) {
|
|
18
|
+
rmSync(distDir, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Build with version define
|
|
22
|
+
try {
|
|
23
|
+
await $`bun build src/index.ts --outdir dist --target bun --minify --external bun-pty --external expo-server-sdk --external @ngrok/ngrok --define BUILD_VERSION='"${VERSION}"'`;
|
|
24
|
+
console.log('✓ Built dist/index.js');
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error('✗ Build failed:', error);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Copy scripts (cross-platform)
|
|
31
|
+
const scriptsDir = join(import.meta.dir, '..', 'scripts');
|
|
32
|
+
const distScriptsDir = join(distDir, 'scripts');
|
|
33
|
+
cpSync(scriptsDir, distScriptsDir, { recursive: true });
|
|
34
|
+
console.log('✓ Copied scripts to dist/scripts');
|
|
35
|
+
|
|
36
|
+
console.log('\nBuild complete!');
|
package/dist/scripts/install.ps1
CHANGED
|
@@ -1,208 +1,208 @@
|
|
|
1
|
-
# CCC - Code Chat Connect Installer for Windows
|
|
2
|
-
# https://github.com/naarang/ccc
|
|
3
|
-
#
|
|
4
|
-
# Usage:
|
|
5
|
-
# irm https://getc3.app/install.ps1 | iex # Install stable
|
|
6
|
-
# $env:CCC_CHANNEL='beta'; irm https://getc3.app/install.ps1 | iex # Install beta
|
|
7
|
-
# $env:CCC_CHANNEL='alpha'; irm https://getc3.app/install.ps1 | iex # Install alpha
|
|
8
|
-
|
|
9
|
-
$ErrorActionPreference = "Stop"
|
|
10
|
-
|
|
11
|
-
# Configuration
|
|
12
|
-
# Public releases repository (binaries are published here for public access)
|
|
13
|
-
$GITHUB_REPO = "vishal-android-freak/ccc-releases"
|
|
14
|
-
$INSTALL_DIR = if ($env:CCC_INSTALL_DIR) { $env:CCC_INSTALL_DIR } else { "$env:USERPROFILE\.local" }
|
|
15
|
-
$BIN_DIR = "$INSTALL_DIR\bin"
|
|
16
|
-
|
|
17
|
-
# Channel selection (stable, beta, alpha) - set via CCC_CHANNEL env var
|
|
18
|
-
$Channel = if ($env:CCC_CHANNEL) { $env:CCC_CHANNEL.ToLower() } else { "stable" }
|
|
19
|
-
if ($Channel -notin @("stable", "beta", "alpha")) {
|
|
20
|
-
Write-Host "Invalid channel: $Channel. Using 'stable'." -ForegroundColor Yellow
|
|
21
|
-
$Channel = "stable"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function Write-ColorOutput($ForegroundColor) {
|
|
25
|
-
$fc = $host.UI.RawUI.ForegroundColor
|
|
26
|
-
$host.UI.RawUI.ForegroundColor = $ForegroundColor
|
|
27
|
-
if ($args) {
|
|
28
|
-
Write-Output $args
|
|
29
|
-
}
|
|
30
|
-
$host.UI.RawUI.ForegroundColor = $fc
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function Print-Banner {
|
|
34
|
-
Write-Host ""
|
|
35
|
-
Write-Host " ____ ____ ____ " -ForegroundColor Cyan
|
|
36
|
-
Write-Host " / ___/ ___/ ___|" -ForegroundColor Cyan
|
|
37
|
-
Write-Host " | | | | | | " -ForegroundColor Cyan
|
|
38
|
-
Write-Host " | |__| |__| |___ " -ForegroundColor Cyan
|
|
39
|
-
Write-Host " \____\____\____|" -ForegroundColor Cyan
|
|
40
|
-
Write-Host ""
|
|
41
|
-
Write-Host "Code Chat Connect" -ForegroundColor White -NoNewline
|
|
42
|
-
Write-Host " - Control Claude Code from your mobile" -ForegroundColor Gray
|
|
43
|
-
Write-Host ""
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function Detect-Platform {
|
|
47
|
-
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
|
|
48
|
-
|
|
49
|
-
switch ($arch) {
|
|
50
|
-
"X64" {
|
|
51
|
-
$script:ARCH = "x64"
|
|
52
|
-
}
|
|
53
|
-
"Arm64" {
|
|
54
|
-
$script:ARCH = "arm64"
|
|
55
|
-
}
|
|
56
|
-
default {
|
|
57
|
-
Write-Host "Error: Unsupported architecture: $arch" -ForegroundColor Red
|
|
58
|
-
exit 1
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
$script:BINARY_NAME = "ccc-windows-$ARCH.exe"
|
|
63
|
-
Write-Host "Detected platform: " -ForegroundColor Blue -NoNewline
|
|
64
|
-
Write-Host "windows-$ARCH"
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function Get-LatestVersion {
|
|
68
|
-
Write-Host "Fetching latest $Channel version..." -ForegroundColor Blue
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
if ($Channel -eq "stable") {
|
|
72
|
-
# For stable, use /releases/latest (excludes prereleases)
|
|
73
|
-
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/$GITHUB_REPO/releases/latest" -Method Get
|
|
74
|
-
$script:VERSION = $response.tag_name -replace '^v', ''
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
# For beta/alpha, fetch all releases and find matching prerelease
|
|
78
|
-
# Sort by version to get the actual latest (API doesn't return in version order)
|
|
79
|
-
$releases = Invoke-RestMethod -Uri "https://api.github.com/repos/$GITHUB_REPO/releases?per_page=50" -Method Get
|
|
80
|
-
$matchingReleases = $releases | Where-Object {
|
|
81
|
-
$_.prerelease -eq $true -and $_.tag_name -match $Channel
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if ($null -eq $matchingReleases -or $matchingReleases.Count -eq 0) {
|
|
85
|
-
throw "No $Channel release found"
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
# Sort by version number and get the highest
|
|
89
|
-
$matchingRelease = $matchingReleases | Sort-Object {
|
|
90
|
-
$v = $_.tag_name -replace '^v', '' -replace '-.*$', ''
|
|
91
|
-
$preNum = if ($_.tag_name -match '\.(\d+)$') { [int]$Matches[1] } else { 0 }
|
|
92
|
-
[version]::new($v + ".0") * 1000 + $preNum
|
|
93
|
-
} -Descending | Select-Object -First 1
|
|
94
|
-
|
|
95
|
-
$script:VERSION = $matchingRelease.tag_name -replace '^v', ''
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
Write-Host "Latest version: " -ForegroundColor Green -NoNewline
|
|
99
|
-
Write-Host "$VERSION ($Channel)"
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
Write-Host "Error: Could not find a $Channel release" -ForegroundColor Red
|
|
103
|
-
if ($Channel -eq "stable") {
|
|
104
|
-
Write-Host "No stable release available yet. Try: `$env:CCC_CHANNEL='beta'; irm https://getc3.app/install.ps1 | iex"
|
|
105
|
-
}
|
|
106
|
-
exit 1
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function Download-Binary {
|
|
111
|
-
Write-Host "Downloading CCC $VERSION for windows-$ARCH..." -ForegroundColor Blue
|
|
112
|
-
|
|
113
|
-
# Create directories
|
|
114
|
-
if (!(Test-Path $BIN_DIR)) {
|
|
115
|
-
New-Item -ItemType Directory -Path $BIN_DIR -Force | Out-Null
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
$downloadUrl = "https://github.com/$GITHUB_REPO/releases/download/v$VERSION/$BINARY_NAME"
|
|
119
|
-
$binaryPath = "$BIN_DIR\ccc.exe"
|
|
120
|
-
|
|
121
|
-
try {
|
|
122
|
-
# Download with progress
|
|
123
|
-
$ProgressPreference = 'SilentlyContinue'
|
|
124
|
-
Invoke-WebRequest -Uri $downloadUrl -OutFile $binaryPath -UseBasicParsing
|
|
125
|
-
$ProgressPreference = 'Continue'
|
|
126
|
-
|
|
127
|
-
Write-Host "Downloaded to: " -ForegroundColor Green -NoNewline
|
|
128
|
-
Write-Host $binaryPath
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
Write-Host "Error: Failed to download binary" -ForegroundColor Red
|
|
132
|
-
Write-Host $_.Exception.Message
|
|
133
|
-
exit 1
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function Setup-Path {
|
|
138
|
-
# Check if already in PATH
|
|
139
|
-
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
140
|
-
|
|
141
|
-
if ($currentPath -notlike "*$BIN_DIR*") {
|
|
142
|
-
$script:PATH_IN_ENV = $false
|
|
143
|
-
# Update current session only (don't modify user PATH automatically)
|
|
144
|
-
$env:Path = "$BIN_DIR;$env:Path"
|
|
145
|
-
} else {
|
|
146
|
-
$script:PATH_IN_ENV = $true
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function Verify-Installation {
|
|
151
|
-
$binaryPath = "$BIN_DIR\ccc.exe"
|
|
152
|
-
|
|
153
|
-
if (Test-Path $binaryPath) {
|
|
154
|
-
try {
|
|
155
|
-
$version = & $binaryPath --version 2>$null
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
$version = "unknown"
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
Write-Host ""
|
|
162
|
-
Write-Host "Installation complete!" -ForegroundColor Green
|
|
163
|
-
Write-Host "Version: " -ForegroundColor Cyan -NoNewline
|
|
164
|
-
Write-Host $version
|
|
165
|
-
Write-Host "Location: " -ForegroundColor Cyan -NoNewline
|
|
166
|
-
Write-Host $binaryPath
|
|
167
|
-
Write-Host ""
|
|
168
|
-
Write-Host "Run " -NoNewline
|
|
169
|
-
Write-Host "ccc" -ForegroundColor White -NoNewline
|
|
170
|
-
Write-Host " to start the server."
|
|
171
|
-
Write-Host "Run " -NoNewline
|
|
172
|
-
Write-Host "ccc --help" -ForegroundColor White -NoNewline
|
|
173
|
-
Write-Host " for usage information."
|
|
174
|
-
Write-Host ""
|
|
175
|
-
|
|
176
|
-
# Show PATH instructions if not already in PATH
|
|
177
|
-
if (-not $script:PATH_IN_ENV) {
|
|
178
|
-
Write-Host "Note: " -ForegroundColor Yellow -NoNewline
|
|
179
|
-
Write-Host "~\.local\bin is not in your PATH" -ForegroundColor Yellow
|
|
180
|
-
Write-Host ""
|
|
181
|
-
Write-Host "Add it to your PATH by running one of the following commands:" -ForegroundColor White
|
|
182
|
-
Write-Host ""
|
|
183
|
-
Write-Host " # Add to user PATH permanently (recommended):" -ForegroundColor Cyan
|
|
184
|
-
Write-Host " [Environment]::SetEnvironmentVariable('Path', `"`$env:USERPROFILE\.local\bin;`$([Environment]::GetEnvironmentVariable('Path', 'User'))`", 'User')" -ForegroundColor Gray
|
|
185
|
-
Write-Host ""
|
|
186
|
-
Write-Host " # Or add to current session only:" -ForegroundColor Cyan
|
|
187
|
-
Write-Host " `$env:Path = `"`$env:USERPROFILE\.local\bin;`$env:Path`"" -ForegroundColor Gray
|
|
188
|
-
Write-Host ""
|
|
189
|
-
Write-Host "Then restart your terminal for the changes to take effect." -ForegroundColor Yellow
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
Write-Host "Installation failed. Please try again." -ForegroundColor Red
|
|
194
|
-
exit 1
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
# Main
|
|
199
|
-
function Main {
|
|
200
|
-
Print-Banner
|
|
201
|
-
Detect-Platform
|
|
202
|
-
Get-LatestVersion
|
|
203
|
-
Download-Binary
|
|
204
|
-
Setup-Path
|
|
205
|
-
Verify-Installation
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
Main
|
|
1
|
+
# CCC - Code Chat Connect Installer for Windows
|
|
2
|
+
# https://github.com/naarang/ccc
|
|
3
|
+
#
|
|
4
|
+
# Usage:
|
|
5
|
+
# irm https://getc3.app/install.ps1 | iex # Install stable
|
|
6
|
+
# $env:CCC_CHANNEL='beta'; irm https://getc3.app/install.ps1 | iex # Install beta
|
|
7
|
+
# $env:CCC_CHANNEL='alpha'; irm https://getc3.app/install.ps1 | iex # Install alpha
|
|
8
|
+
|
|
9
|
+
$ErrorActionPreference = "Stop"
|
|
10
|
+
|
|
11
|
+
# Configuration
|
|
12
|
+
# Public releases repository (binaries are published here for public access)
|
|
13
|
+
$GITHUB_REPO = "vishal-android-freak/ccc-releases"
|
|
14
|
+
$INSTALL_DIR = if ($env:CCC_INSTALL_DIR) { $env:CCC_INSTALL_DIR } else { "$env:USERPROFILE\.local" }
|
|
15
|
+
$BIN_DIR = "$INSTALL_DIR\bin"
|
|
16
|
+
|
|
17
|
+
# Channel selection (stable, beta, alpha) - set via CCC_CHANNEL env var
|
|
18
|
+
$Channel = if ($env:CCC_CHANNEL) { $env:CCC_CHANNEL.ToLower() } else { "stable" }
|
|
19
|
+
if ($Channel -notin @("stable", "beta", "alpha")) {
|
|
20
|
+
Write-Host "Invalid channel: $Channel. Using 'stable'." -ForegroundColor Yellow
|
|
21
|
+
$Channel = "stable"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function Write-ColorOutput($ForegroundColor) {
|
|
25
|
+
$fc = $host.UI.RawUI.ForegroundColor
|
|
26
|
+
$host.UI.RawUI.ForegroundColor = $ForegroundColor
|
|
27
|
+
if ($args) {
|
|
28
|
+
Write-Output $args
|
|
29
|
+
}
|
|
30
|
+
$host.UI.RawUI.ForegroundColor = $fc
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function Print-Banner {
|
|
34
|
+
Write-Host ""
|
|
35
|
+
Write-Host " ____ ____ ____ " -ForegroundColor Cyan
|
|
36
|
+
Write-Host " / ___/ ___/ ___|" -ForegroundColor Cyan
|
|
37
|
+
Write-Host " | | | | | | " -ForegroundColor Cyan
|
|
38
|
+
Write-Host " | |__| |__| |___ " -ForegroundColor Cyan
|
|
39
|
+
Write-Host " \____\____\____|" -ForegroundColor Cyan
|
|
40
|
+
Write-Host ""
|
|
41
|
+
Write-Host "Code Chat Connect" -ForegroundColor White -NoNewline
|
|
42
|
+
Write-Host " - Control Claude Code from your mobile" -ForegroundColor Gray
|
|
43
|
+
Write-Host ""
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function Detect-Platform {
|
|
47
|
+
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
|
|
48
|
+
|
|
49
|
+
switch ($arch) {
|
|
50
|
+
"X64" {
|
|
51
|
+
$script:ARCH = "x64"
|
|
52
|
+
}
|
|
53
|
+
"Arm64" {
|
|
54
|
+
$script:ARCH = "arm64"
|
|
55
|
+
}
|
|
56
|
+
default {
|
|
57
|
+
Write-Host "Error: Unsupported architecture: $arch" -ForegroundColor Red
|
|
58
|
+
exit 1
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
$script:BINARY_NAME = "ccc-windows-$ARCH.exe"
|
|
63
|
+
Write-Host "Detected platform: " -ForegroundColor Blue -NoNewline
|
|
64
|
+
Write-Host "windows-$ARCH"
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function Get-LatestVersion {
|
|
68
|
+
Write-Host "Fetching latest $Channel version..." -ForegroundColor Blue
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
if ($Channel -eq "stable") {
|
|
72
|
+
# For stable, use /releases/latest (excludes prereleases)
|
|
73
|
+
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/$GITHUB_REPO/releases/latest" -Method Get
|
|
74
|
+
$script:VERSION = $response.tag_name -replace '^v', ''
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
# For beta/alpha, fetch all releases and find matching prerelease
|
|
78
|
+
# Sort by version to get the actual latest (API doesn't return in version order)
|
|
79
|
+
$releases = Invoke-RestMethod -Uri "https://api.github.com/repos/$GITHUB_REPO/releases?per_page=50" -Method Get
|
|
80
|
+
$matchingReleases = $releases | Where-Object {
|
|
81
|
+
$_.prerelease -eq $true -and $_.tag_name -match $Channel
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if ($null -eq $matchingReleases -or $matchingReleases.Count -eq 0) {
|
|
85
|
+
throw "No $Channel release found"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# Sort by version number and get the highest
|
|
89
|
+
$matchingRelease = $matchingReleases | Sort-Object {
|
|
90
|
+
$v = $_.tag_name -replace '^v', '' -replace '-.*$', ''
|
|
91
|
+
$preNum = if ($_.tag_name -match '\.(\d+)$') { [int]$Matches[1] } else { 0 }
|
|
92
|
+
[version]::new($v + ".0") * 1000 + $preNum
|
|
93
|
+
} -Descending | Select-Object -First 1
|
|
94
|
+
|
|
95
|
+
$script:VERSION = $matchingRelease.tag_name -replace '^v', ''
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
Write-Host "Latest version: " -ForegroundColor Green -NoNewline
|
|
99
|
+
Write-Host "$VERSION ($Channel)"
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
Write-Host "Error: Could not find a $Channel release" -ForegroundColor Red
|
|
103
|
+
if ($Channel -eq "stable") {
|
|
104
|
+
Write-Host "No stable release available yet. Try: `$env:CCC_CHANNEL='beta'; irm https://getc3.app/install.ps1 | iex"
|
|
105
|
+
}
|
|
106
|
+
exit 1
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function Download-Binary {
|
|
111
|
+
Write-Host "Downloading CCC $VERSION for windows-$ARCH..." -ForegroundColor Blue
|
|
112
|
+
|
|
113
|
+
# Create directories
|
|
114
|
+
if (!(Test-Path $BIN_DIR)) {
|
|
115
|
+
New-Item -ItemType Directory -Path $BIN_DIR -Force | Out-Null
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
$downloadUrl = "https://github.com/$GITHUB_REPO/releases/download/v$VERSION/$BINARY_NAME"
|
|
119
|
+
$binaryPath = "$BIN_DIR\ccc.exe"
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
# Download with progress
|
|
123
|
+
$ProgressPreference = 'SilentlyContinue'
|
|
124
|
+
Invoke-WebRequest -Uri $downloadUrl -OutFile $binaryPath -UseBasicParsing
|
|
125
|
+
$ProgressPreference = 'Continue'
|
|
126
|
+
|
|
127
|
+
Write-Host "Downloaded to: " -ForegroundColor Green -NoNewline
|
|
128
|
+
Write-Host $binaryPath
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
Write-Host "Error: Failed to download binary" -ForegroundColor Red
|
|
132
|
+
Write-Host $_.Exception.Message
|
|
133
|
+
exit 1
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function Setup-Path {
|
|
138
|
+
# Check if already in PATH
|
|
139
|
+
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
140
|
+
|
|
141
|
+
if ($currentPath -notlike "*$BIN_DIR*") {
|
|
142
|
+
$script:PATH_IN_ENV = $false
|
|
143
|
+
# Update current session only (don't modify user PATH automatically)
|
|
144
|
+
$env:Path = "$BIN_DIR;$env:Path"
|
|
145
|
+
} else {
|
|
146
|
+
$script:PATH_IN_ENV = $true
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function Verify-Installation {
|
|
151
|
+
$binaryPath = "$BIN_DIR\ccc.exe"
|
|
152
|
+
|
|
153
|
+
if (Test-Path $binaryPath) {
|
|
154
|
+
try {
|
|
155
|
+
$version = & $binaryPath --version 2>$null
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
$version = "unknown"
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
Write-Host ""
|
|
162
|
+
Write-Host "Installation complete!" -ForegroundColor Green
|
|
163
|
+
Write-Host "Version: " -ForegroundColor Cyan -NoNewline
|
|
164
|
+
Write-Host $version
|
|
165
|
+
Write-Host "Location: " -ForegroundColor Cyan -NoNewline
|
|
166
|
+
Write-Host $binaryPath
|
|
167
|
+
Write-Host ""
|
|
168
|
+
Write-Host "Run " -NoNewline
|
|
169
|
+
Write-Host "ccc" -ForegroundColor White -NoNewline
|
|
170
|
+
Write-Host " to start the server."
|
|
171
|
+
Write-Host "Run " -NoNewline
|
|
172
|
+
Write-Host "ccc --help" -ForegroundColor White -NoNewline
|
|
173
|
+
Write-Host " for usage information."
|
|
174
|
+
Write-Host ""
|
|
175
|
+
|
|
176
|
+
# Show PATH instructions if not already in PATH
|
|
177
|
+
if (-not $script:PATH_IN_ENV) {
|
|
178
|
+
Write-Host "Note: " -ForegroundColor Yellow -NoNewline
|
|
179
|
+
Write-Host "~\.local\bin is not in your PATH" -ForegroundColor Yellow
|
|
180
|
+
Write-Host ""
|
|
181
|
+
Write-Host "Add it to your PATH by running one of the following commands:" -ForegroundColor White
|
|
182
|
+
Write-Host ""
|
|
183
|
+
Write-Host " # Add to user PATH permanently (recommended):" -ForegroundColor Cyan
|
|
184
|
+
Write-Host " [Environment]::SetEnvironmentVariable('Path', `"`$env:USERPROFILE\.local\bin;`$([Environment]::GetEnvironmentVariable('Path', 'User'))`", 'User')" -ForegroundColor Gray
|
|
185
|
+
Write-Host ""
|
|
186
|
+
Write-Host " # Or add to current session only:" -ForegroundColor Cyan
|
|
187
|
+
Write-Host " `$env:Path = `"`$env:USERPROFILE\.local\bin;`$env:Path`"" -ForegroundColor Gray
|
|
188
|
+
Write-Host ""
|
|
189
|
+
Write-Host "Then restart your terminal for the changes to take effect." -ForegroundColor Yellow
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
Write-Host "Installation failed. Please try again." -ForegroundColor Red
|
|
194
|
+
exit 1
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
# Main
|
|
199
|
+
function Main {
|
|
200
|
+
Print-Banner
|
|
201
|
+
Detect-Platform
|
|
202
|
+
Get-LatestVersion
|
|
203
|
+
Download-Binary
|
|
204
|
+
Setup-Path
|
|
205
|
+
Verify-Installation
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
Main
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Postinstall script (CommonJS version for npm compatibility)
|
|
4
|
-
*
|
|
5
|
-
* This script checks if bun-pty is working correctly.
|
|
6
|
-
* bun-pty is a Bun-native PTY implementation that doesn't require node-gyp.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const { existsSync } = require('fs');
|
|
10
|
-
const { join } = require('path');
|
|
11
|
-
const { spawn } = require('child_process');
|
|
12
|
-
|
|
13
|
-
const ROOT_PATH = join(__dirname, '..');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Check if Bun is available
|
|
17
|
-
*/
|
|
18
|
-
function checkBun() {
|
|
19
|
-
return new Promise((resolve) => {
|
|
20
|
-
const result = spawn('bun', ['--version'], { stdio: 'pipe', shell: true });
|
|
21
|
-
result.on('close', (code) => resolve(code === 0));
|
|
22
|
-
result.on('error', () => resolve(false));
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Check if bun-pty works (requires Bun runtime)
|
|
28
|
-
*/
|
|
29
|
-
async function checkBunPty() {
|
|
30
|
-
const hasBun = await checkBun();
|
|
31
|
-
if (!hasBun) {
|
|
32
|
-
console.log('[postinstall] Bun not found, skipping bun-pty check');
|
|
33
|
-
console.log('[postinstall] Install Bun for full functionality: https://bun.sh');
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return new Promise((resolve) => {
|
|
38
|
-
// Run a simple Bun script to test bun-pty
|
|
39
|
-
const testScript = `
|
|
40
|
-
try {
|
|
41
|
-
const { spawn } = require('bun-pty');
|
|
42
|
-
const shell = process.platform === 'win32' ? 'cmd.exe' : 'sh';
|
|
43
|
-
const pty = spawn(shell, [], { cols: 80, rows: 24 });
|
|
44
|
-
pty.kill();
|
|
45
|
-
console.log('bun-pty is working correctly');
|
|
46
|
-
process.exit(0);
|
|
47
|
-
} catch (e) {
|
|
48
|
-
console.error('bun-pty check failed:', e.message);
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
`;
|
|
52
|
-
|
|
53
|
-
const testProcess = spawn('bun', ['-e', testScript], {
|
|
54
|
-
cwd: ROOT_PATH,
|
|
55
|
-
stdio: 'inherit',
|
|
56
|
-
shell: true,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
testProcess.on('close', (code) => resolve(code === 0));
|
|
60
|
-
testProcess.on('error', () => resolve(false));
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async function main() {
|
|
65
|
-
console.log('[postinstall] Code Chat Connect v2 - Post-installation check\n');
|
|
66
|
-
|
|
67
|
-
// Check bun-pty
|
|
68
|
-
const ptyWorks = await checkBunPty();
|
|
69
|
-
|
|
70
|
-
if (ptyWorks) {
|
|
71
|
-
console.log('\n[postinstall] All checks passed!');
|
|
72
|
-
} else {
|
|
73
|
-
console.log('\n[postinstall] Terminal functionality may be limited.');
|
|
74
|
-
console.log('[postinstall] Ensure Bun is installed: https://bun.sh');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
console.log('\n[postinstall] Run "ccc" to start the server.\n');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
main().catch((err) => {
|
|
81
|
-
console.error('[postinstall] Error:', err.message);
|
|
82
|
-
// Don't fail the install on postinstall errors
|
|
83
|
-
process.exit(0);
|
|
84
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Postinstall script (CommonJS version for npm compatibility)
|
|
4
|
+
*
|
|
5
|
+
* This script checks if bun-pty is working correctly.
|
|
6
|
+
* bun-pty is a Bun-native PTY implementation that doesn't require node-gyp.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { existsSync } = require('fs');
|
|
10
|
+
const { join } = require('path');
|
|
11
|
+
const { spawn } = require('child_process');
|
|
12
|
+
|
|
13
|
+
const ROOT_PATH = join(__dirname, '..');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Check if Bun is available
|
|
17
|
+
*/
|
|
18
|
+
function checkBun() {
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
const result = spawn('bun', ['--version'], { stdio: 'pipe', shell: true });
|
|
21
|
+
result.on('close', (code) => resolve(code === 0));
|
|
22
|
+
result.on('error', () => resolve(false));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Check if bun-pty works (requires Bun runtime)
|
|
28
|
+
*/
|
|
29
|
+
async function checkBunPty() {
|
|
30
|
+
const hasBun = await checkBun();
|
|
31
|
+
if (!hasBun) {
|
|
32
|
+
console.log('[postinstall] Bun not found, skipping bun-pty check');
|
|
33
|
+
console.log('[postinstall] Install Bun for full functionality: https://bun.sh');
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
// Run a simple Bun script to test bun-pty
|
|
39
|
+
const testScript = `
|
|
40
|
+
try {
|
|
41
|
+
const { spawn } = require('bun-pty');
|
|
42
|
+
const shell = process.platform === 'win32' ? 'cmd.exe' : 'sh';
|
|
43
|
+
const pty = spawn(shell, [], { cols: 80, rows: 24 });
|
|
44
|
+
pty.kill();
|
|
45
|
+
console.log('bun-pty is working correctly');
|
|
46
|
+
process.exit(0);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
console.error('bun-pty check failed:', e.message);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
const testProcess = spawn('bun', ['-e', testScript], {
|
|
54
|
+
cwd: ROOT_PATH,
|
|
55
|
+
stdio: 'inherit',
|
|
56
|
+
shell: true,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
testProcess.on('close', (code) => resolve(code === 0));
|
|
60
|
+
testProcess.on('error', () => resolve(false));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function main() {
|
|
65
|
+
console.log('[postinstall] Code Chat Connect v2 - Post-installation check\n');
|
|
66
|
+
|
|
67
|
+
// Check bun-pty
|
|
68
|
+
const ptyWorks = await checkBunPty();
|
|
69
|
+
|
|
70
|
+
if (ptyWorks) {
|
|
71
|
+
console.log('\n[postinstall] All checks passed!');
|
|
72
|
+
} else {
|
|
73
|
+
console.log('\n[postinstall] Terminal functionality may be limited.');
|
|
74
|
+
console.log('[postinstall] Ensure Bun is installed: https://bun.sh');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log('\n[postinstall] Run "ccc" to start the server.\n');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
main().catch((err) => {
|
|
81
|
+
console.error('[postinstall] Error:', err.message);
|
|
82
|
+
// Don't fail the install on postinstall errors
|
|
83
|
+
process.exit(0);
|
|
84
|
+
});
|