Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# DAN CLI Installation Scripts

This repository includes cross-platform installation scripts for the DAN CLI tool to make installation easier across different operating systems.

## Installation Scripts

### Linux/macOS
- **File**: `install-dan-cli.sh`
- **Usage**:
```bash
chmod +x install-dan-cli.sh
./install-dan-cli.sh
```

### Windows
- **File**: `install-dan-cli.ps1`
- **Usage**:
```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
.\install-dan-cli.ps1
```

## Prerequisites

- Node.js version 20 or higher
- npm (comes with Node.js)
- Git (for source installation method)

## Installation Methods

The scripts offer two installation methods:

1. **Install from npm** (recommended):
- Downloads and installs the latest published version from npm
- Faster installation
- Stable release

2. **Install from source**:
- Clones the repository and builds from source code
- Gets the latest development version
- Requires more time and resources

## What the Scripts Do

### For npm installation:
- Checks for Node.js and npm prerequisites
- Installs the `@qwen-code/qwen-code` package globally using npm
- Makes the `dan` and `qwen` commands available system-wide

### For source installation:
- Checks for Node.js, npm, and Git
- Clones the DAN CLI repository
- Installs dependencies
- Builds the project
- Installs globally

## After Installation

After successful installation, you can use the CLI by running either:
- `dan` - Main command
- `qwen` - Alternative command

## Troubleshooting

If you encounter issues:

1. Make sure you have the required prerequisites (Node.js >= 20)
2. Ensure your npm installation has proper permissions
3. If installing globally fails, try running the command with appropriate permissions (e.g., using npx instead, or configuring npm for global packages without sudo)

For more information about the DAN CLI, visit the [main repository](https://github.com/somdipto/DAN-cli).
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ npm install
npm install -g .
```

### Install using Installation Scripts

For an automated installation experience across different platforms, you can use our installation scripts:

#### Linux/macOS
```bash
curl -fsSL https://raw.githubusercontent.com/somdipto/DAN-cli/main/install-dan-cli.sh -o install-dan-cli.sh
chmod +x install-dan-cli.sh
./install-dan-cli.sh
```

#### Windows
```powershell
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/somdipto/DAN-cli/main/install-dan-cli.ps1" -OutFile "install-dan-cli.ps1"
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
.\install-dan-cli.ps1
```

### Install globally with Homebrew (macOS/Linux)

```bash
Expand Down
85 changes: 85 additions & 0 deletions docs/development/installation-scripts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Installation Scripts

This project provides cross-platform installation scripts to make it easier to install the DAN CLI on different operating systems.

## Overview

Instead of manually installing via npm, you can use our installation scripts which automate the process and provide additional options for installation.

## Installation Scripts

### Linux/macOS
- **File**: `install-dan-cli.sh`
- **Usage**:
```bash
chmod +x install-dan-cli.sh
./install-dan-cli.sh
```

### Windows
- **File**: `install-dan-cli.ps1`
- **Usage**:
```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
.\install-dan-cli.ps1
```

## Installation Methods

The scripts offer two installation methods:

1. **Install from npm** (recommended):
- Downloads and installs the latest published version from npm
- Faster installation
- Stable release

2. **Install from source**:
- Clones the repository and builds from source code
- Gets the latest development version
- Requires more time and resources

## Prerequisites

- Node.js version 20 or higher
- npm (comes with Node.js)
- Git (for source installation method)

## Quick Installation

For a streamlined experience, you can also use the quick installation script:

```bash
# Linux/macOS
./quick-install.sh
```

This script automatically detects your operating system and runs the appropriate installer.

## What the Scripts Do

### For npm installation:
- Checks for Node.js and npm prerequisites
- Installs the `@qwen-code/qwen-code` package globally using npm
- Makes the `dan` and `qwen` commands available system-wide

### For source installation:
- Checks for Node.js, npm, and Git
- Clones the DAN CLI repository
- Installs dependencies
- Builds the project
- Installs globally

## After Installation

After successful installation, you can use the CLI by running either:
- `dan` - Main command
- `qwen` - Alternative command

## Troubleshooting

If you encounter issues:

1. Make sure you have the required prerequisites (Node.js >= 20)
2. Ensure your npm installation has proper permissions
3. If installing globally fails, try running the command with appropriate permissions
4. Check that git is installed if using the source installation method
1 change: 1 addition & 0 deletions docs/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"label": "Development",
"items": [
{ "label": "NPM", "slug": "docs/npm" },
{ "label": "Installation Scripts", "slug": "docs/development/installation-scripts" },
{ "label": "Releases", "slug": "docs/releases" }
]
},
Expand Down
193 changes: 193 additions & 0 deletions install-dan-cli.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# DAN CLI Installation Script for Windows (PowerShell)
# This script installs the DAN CLI either from npm or by building from source

# Exit on any error
$ErrorActionPreference = "Stop"

# Function to print colored output
function Write-Info {
param([string]$Message)
Write-Host "[INFO] $Message" -ForegroundColor Blue
}

function Write-Success {
param([string]$Message)
Write-Host "[SUCCESS] $Message" -ForegroundColor Green
}

function Write-Warning {
param([string]$Message)
Write-Host "[WARNING] $Message" -ForegroundColor Yellow
}

function Write-Error {
param([string]$Message)
Write-Host "[ERROR] $Message" -ForegroundColor Red
exit 1
}

# Check if running on Windows
if ($env:OS -ne "Windows_NT") {
Write-Error "This script is designed for Windows only. Please use install-dan-cli.sh on Linux/macOS."
}

# Check if Node.js is installed
function Check-Node {
try {
$nodeVersion = node --version
Write-Info "Node.js $nodeVersion detected."
}
catch {
Write-Error "Node.js is not installed. Please install Node.js version 20 or higher from https://nodejs.org/"
}

# Extract major version
$versionStr = $nodeVersion.TrimStart('v')
$majorVersion = [int]$versionStr.Split('.')[0]

if ($majorVersion -lt 20) {
Write-Error "Node.js version $versionStr is not supported. Please upgrade to Node.js version 20 or higher."
}
}

# Check if npm is installed
function Check-Npm {
try {
$npmVersion = npm --version
Write-Info "npm $npmVersion detected."
}
catch {
Write-Error "npm is not installed. Please ensure npm is installed with Node.js."
}
}

# Install from npm
function Install-FromNpm {
Write-Info "Installing DAN CLI from npm..."

# Check if we're in development mode (inside the project directory)
if (Test-Path "package.json") {
$packageJson = Get-Content "package.json" -Raw | ConvertFrom-Json
if ($packageJson.name -eq "@qwen-code/qwen-code") {
Write-Warning "You are in the project directory. Installing the package globally from the current directory."
npm install -g . --silent
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to install from current directory."
}
}
}
else {
# Install the latest version from npm
npm install -g @qwen-code/qwen-code@latest --silent
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to install from npm."
}
}

Write-Success "DAN CLI installed successfully!"
Write-Info "You can now run: dan or qwen"
}

# Install from source
function Install-FromSource {
Write-Info "Installing DAN CLI from source..."

# Check if git is installed
try {
git --version | Out-Null
Write-Info "Git detected."
}
catch {
Write-Error "Git is not installed. Please install git first."
}

# Ask for installation directory
$installDir = Read-Host "Enter the directory where you want to install the source code (default: $env:USERPROFILE\dan-cli)"
if ([string]::IsNullOrWhiteSpace($installDir)) {
$installDir = "$env:USERPROFILE\dan-cli"
}

# Create directory if it doesn't exist
if (!(Test-Path $installDir)) {
New-Item -ItemType Directory -Path $installDir -Force | Out-Null
}

# Clone the repository if it doesn't exist
$gitDirPath = Join-Path $installDir ".git"
if (!(Test-Path $gitDirPath)) {
Write-Info "Cloning DAN CLI repository to $installDir..."
git clone https://github.com/somdipto/DAN-cli.git $installDir
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to clone the repository."
}
}
else {
Write-Info "Repository already exists. Pulling latest changes..."
Set-Location $installDir
git pull
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to pull latest changes."
}
}

# Change directory to the installation directory
Set-Location $installDir

Write-Info "Installing dependencies..."
npm install
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to install dependencies."
}

Write-Info "Building the project..."
npm run build
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to build the project."
}

Write-Info "Installing globally..."
npm install -g .
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to install globally."
}

Write-Success "DAN CLI installed successfully from source!"
Write-Info "You can now run: dan or qwen"
Write-Info "The source code is available in: $installDir"
}

# Main function
function Main {
Write-Info "DAN CLI Installation Script"
Write-Info "============================"

Check-Node
Check-Npm

Write-Host ""
Write-Host "Choose an installation method:"
Write-Host "1. Install from npm (recommended, faster)"
Write-Host "2. Install from source (latest development version)"

$choice = Read-Host "Enter your choice (1 or 2)"

switch ($choice) {
"1" {
Install-FromNpm
}
"2" {
Install-FromSource
}
default {
Write-Error "Invalid choice. Please enter 1 or 2."
}
}

Write-Host ""
Write-Success "Installation completed successfully!"
Write-Info "Run 'dan' or 'qwen' to start using the CLI."
Write-Info "Visit https://github.com/somdipto/DAN-cli for documentation."
}

# Run the main function
Main
Loading
Loading