Skip to content

Commit bf5033a

Browse files
committed
fix: install CLI from GitHub instead of npm
1 parent 02106fd commit bf5033a

2 files changed

Lines changed: 99 additions & 6 deletions

File tree

packages/cli/install.ps1

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,63 @@ $nodeVersion = node -v
114114
$npmVersion = npm -v
115115
Write-ColorOutput Green "✅ Node.js $nodeVersion and npm $npmVersion detected"
116116

117-
# Install CLI globally
117+
# Check if git is available
118+
if (-not (Test-CommandExists "git")) {
119+
Write-ColorOutput Red "❌ Git is required but not found."
120+
Write-ColorOutput Yellow "Please install Git and run this script again."
121+
Write-ColorOutput Cyan " https://git-scm.com/downloads"
122+
exit 1
123+
}
124+
125+
# Install CLI globally from GitHub
118126
Write-Output ""
119-
Write-ColorOutput Cyan "📦 Installing DesterLib CLI..."
120-
npm install -g @desterlib/cli@latest
127+
Write-ColorOutput Cyan "📦 Installing DesterLib CLI from GitHub..."
128+
129+
# Create temporary directory
130+
$TempDir = New-TemporaryFile | ForEach-Object { Remove-Item $_; New-Item -ItemType Directory -Path $_ }
131+
132+
try {
133+
# Clone repository
134+
Write-ColorOutput Cyan "Cloning repository..."
135+
$cloneResult = git clone --depth 1 --branch main https://github.com/DesterLib/desterlib.git "$TempDir\desterlib" 2>&1
136+
if ($LASTEXITCODE -ne 0) {
137+
Write-ColorOutput Red "❌ Failed to clone repository."
138+
exit 1
139+
}
140+
141+
# Navigate to CLI package and install
142+
Push-Location "$TempDir\desterlib\packages\cli"
143+
144+
# Install dependencies and build
145+
Write-ColorOutput Cyan "Building CLI..."
146+
npm install
147+
if ($LASTEXITCODE -ne 0) {
148+
Write-ColorOutput Red "❌ Failed to install dependencies."
149+
exit 1
150+
}
151+
152+
npm run build
153+
if ($LASTEXITCODE -ne 0) {
154+
Write-ColorOutput Red "❌ Failed to build CLI."
155+
exit 1
156+
}
157+
158+
# Install globally
159+
Write-ColorOutput Cyan "Installing CLI globally..."
160+
npm install -g .
161+
if ($LASTEXITCODE -ne 0) {
162+
Write-ColorOutput Red "❌ Failed to install CLI globally."
163+
exit 1
164+
}
165+
166+
Pop-Location
167+
} catch {
168+
Write-ColorOutput Red "❌ Error during installation: $_"
169+
exit 1
170+
} finally {
171+
# Clean up
172+
Remove-Item -Recurse -Force $TempDir -ErrorAction SilentlyContinue
173+
}
121174

122175
# Verify installation
123176
if (Test-CommandExists "desterlib") {

packages/cli/install.sh

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,50 @@ NODE_VERSION=$(node -v)
145145
NPM_VERSION=$(npm -v)
146146
echo -e "${GREEN}✅ Node.js $NODE_VERSION and npm $NPM_VERSION detected${NC}"
147147

148-
# Install CLI globally
148+
# Check if git is available
149+
if ! command_exists git; then
150+
echo -e "${RED}❌ Git is required but not found.${NC}"
151+
echo -e "${YELLOW}Please install Git and run this script again.${NC}"
152+
echo -e "${CYAN} https://git-scm.com/downloads${NC}"
153+
exit 1
154+
fi
155+
156+
# Install CLI globally from GitHub
149157
echo ""
150-
echo -e "${CYAN}📦 Installing DesterLib CLI...${NC}"
151-
npm install -g @desterlib/cli@latest
158+
echo -e "${CYAN}📦 Installing DesterLib CLI from GitHub...${NC}"
159+
160+
# Create temporary directory
161+
TEMP_DIR=$(mktemp -d)
162+
trap "rm -rf $TEMP_DIR" EXIT
163+
164+
# Clone repository
165+
echo -e "${CYAN}Cloning repository...${NC}"
166+
if ! git clone --depth 1 --branch main https://github.com/DesterLib/desterlib.git "$TEMP_DIR/desterlib"; then
167+
echo -e "${RED}❌ Failed to clone repository.${NC}"
168+
exit 1
169+
fi
170+
171+
# Navigate to CLI package and install
172+
cd "$TEMP_DIR/desterlib/packages/cli"
173+
174+
# Install dependencies and build
175+
echo -e "${CYAN}Building CLI...${NC}"
176+
if ! npm install; then
177+
echo -e "${RED}❌ Failed to install dependencies.${NC}"
178+
exit 1
179+
fi
180+
181+
if ! npm run build; then
182+
echo -e "${RED}❌ Failed to build CLI.${NC}"
183+
exit 1
184+
fi
185+
186+
# Install globally
187+
echo -e "${CYAN}Installing CLI globally...${NC}"
188+
if ! npm install -g .; then
189+
echo -e "${RED}❌ Failed to install CLI globally.${NC}"
190+
exit 1
191+
fi
152192

153193
# Verify installation
154194
if command_exists desterlib; then

0 commit comments

Comments
 (0)