feat(cli): curl/irl installation scripts and docs (#9835)
* feat: curl/irl scripts for installing Continue CLI * fix: address code review comments for installation scripts - Fix CLEANUP_FNM to only mark for cleanup if fnm dir doesn't pre-exist - Guard FNM_DIR expansion with parameter substitution to avoid set -u errors - Persist fnm PATH to user environment in PowerShell for future sessions - Persist npm global bin PATH to user environment in PowerShell Co-authored-by: dallin <dallin@continue.dev> Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev> * feat: use CLIInstall component throughout guides and docs * fix: cubic feedback typo * docs: move node installation path into tab * docs: move node installation path into tab * fix: address cubic feedback --------- Co-authored-by: RomneyDa <RomneyDa@users.noreply.github.com> Co-authored-by: Continue <noreply@continue.dev> Co-authored-by: continue[bot] <230936708+continue[bot]@users.noreply.github.com>
This commit is contained in:
parent
a7a5351b9c
commit
d585c3b8e8
24 changed files with 900 additions and 72 deletions
19
README.md
19
README.md
|
|
@ -32,8 +32,27 @@ Get started in [Mission Control](https://continue.dev/hub?type=agents), [CLI (He
|
|||
|
||||
### Quick Install
|
||||
|
||||
**macOS / Linux:**
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/continuedev/continue/main/extensions/cli/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
**Windows (PowerShell):**
|
||||
|
||||
```powershell
|
||||
irm https://raw.githubusercontent.com/continuedev/continue/main/extensions/cli/scripts/install.ps1 | iex
|
||||
```
|
||||
|
||||
Or with npm:
|
||||
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
|
||||
Then run:
|
||||
|
||||
```bash
|
||||
cn
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Get Continue CLI installed and configured for command-line AI codi
|
|||
sidebarTitle: "Install"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<iframe
|
||||
width="100%"
|
||||
height="400"
|
||||
|
|
@ -14,18 +19,9 @@ sidebarTitle: "Install"
|
|||
allowfullscreen
|
||||
></iframe>
|
||||
|
||||
<Info>
|
||||
Make sure you have [Node.js 18 or higher
|
||||
installed](https://nodejs.org/en/download/).
|
||||
</Info>
|
||||
|
||||
## Installation
|
||||
|
||||
Install Continue CLI globally using npm:
|
||||
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
|
||||
## Two Ways to Use Continue CLI
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Command-line interface for automated coding tasks, scripting, and
|
|||
sidebarTitle: "Overview"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Frame>
|
||||
<img src="/images/cn-demo.gif" />
|
||||
</Frame>
|
||||
|
|
@ -22,20 +27,14 @@ Prerequisites:
|
|||
- [Node.js 18 or newer](https://nodejs.org/en/download/)
|
||||
- A [Continue Mission Control](https://continue.dev) account (recommended) or local configuration
|
||||
|
||||
```bash npm
|
||||
# Install Continue CLI
|
||||
npm install -g @continuedev/cli
|
||||
<CLIInstall />
|
||||
|
||||
# Navigate to your project
|
||||
Then navigate to your project and start coding:
|
||||
|
||||
```bash
|
||||
cd your-awesome-project
|
||||
|
||||
# Start coding with Continue
|
||||
|
||||
cn
|
||||
|
||||
# You'll be prompted to set up on first use
|
||||
|
||||
```
|
||||
|
||||
That's it! You're ready to start automating with Continue CLI.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Use Continue and the Atlassian Rovo MCP to search, summarize, and
|
|||
sidebarTitle: "Atlassian Workflows with Continue"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Card title="What You'll Build" icon="atlassian">
|
||||
An Atlassian workflow assistant that uses Continue with the Atlassian Rovo MCP to:
|
||||
- Search and summarize Jira issues across projects
|
||||
|
|
@ -36,9 +41,7 @@ Before starting, ensure you have:
|
|||
For all options, first:
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
|
||||
<Step title="Understand OAuth Flow">
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Measure and optimize web performance with Chrome DevTools MCP, aut
|
|||
sidebarTitle: "Chrome DevTools MCP for Performance"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Card title="Debug Performance Like a Pro" icon="gauge-high">
|
||||
Use AI to automatically trace performance, analyze Core Web Vitals, diagnose bottlenecks, and get actionable optimization suggestions directly from Chrome DevTools
|
||||
</Card>
|
||||
|
|
@ -36,7 +41,7 @@ This cookbook teaches you to:
|
|||
- Chrome browser installed
|
||||
- Web project with a running development server (or deployed URL)
|
||||
- Node.js 20+ installed
|
||||
- [Continue CLI](https://docs.continue.dev/guides/cli) (`npm i -g @continuedev/cli`)
|
||||
- [Continue CLI](https://docs.continue.dev/guides/cli)
|
||||
- [Chrome DevTools MCP](https://continue.dev) configured
|
||||
|
||||
## Quick Setup
|
||||
|
|
@ -44,9 +49,7 @@ This cookbook teaches you to:
|
|||
For all options, first:
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ sidebarTitle: "Continue CLI (cn)"
|
|||
description: "Learn how to use Continue's command-line interface for context engineering, automated coding tasks, and headless development workflows with customizable models, rules, and tools"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
`cn` is an open-source, modular coding agent for the command line.
|
||||
|
||||
It provides a battle-tested agent loop so you can simply plug in your model, rules, and tools.
|
||||
|
|
@ -12,15 +17,11 @@ It provides a battle-tested agent loop so you can simply plug in your model, rul
|
|||
|
||||
## Quick Start
|
||||
|
||||
<Info>
|
||||
Make sure you have [Node.js 18 or higher
|
||||
installed](https://nodejs.org/en/download/).
|
||||
</Info>
|
||||
<CLIInstall />
|
||||
|
||||
Then start using it:
|
||||
|
||||
```bash
|
||||
# Install
|
||||
npm i -g @continuedev/cli
|
||||
|
||||
# Interactive mode
|
||||
cn
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ title: "Continuous AI: A Developer's Guide"
|
|||
description: "Learn how to integrate intelligent automation into development workflows, making AI assistance as natural as syntax highlighting. Implement systematic AI workflows that compound productivity gains over time."
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
Continuous AI is the integration of intelligent automation directly into development workflows, making AI assistance as natural and reliable as syntax highlighting or code completion. Its purpose is to amplify developer intent at every stage of the coding process.
|
||||
|
||||
Think of it this way: DevOps automated the mechanical aspects of software delivery—building, testing, deploying. Continuous AI automates the intelligence aspects—understanding context, making suggestions, adapting to patterns, and learning from developer feedback.
|
||||
|
|
@ -179,7 +184,7 @@ Track how often you need to correct AI output. Lower intervention rates mean hig
|
|||
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash npm i -g @continuedev/cli ```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
|
||||
<Step title="Pick One Workflow">Choose a daily friction point to automate</Step>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Set up an AI-powered data engineering workflow that helps you deve
|
|||
sidebarTitle: "dlt Data Pipelines with Continue"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Card title="What You'll Build" icon="database">
|
||||
An AI-powered data pipeline development system that uses Continue's AI agent with dlt
|
||||
MCP to inspect pipeline execution, retrieve schemas, analyze datasets, and debug load errors - all through simple natural language prompts
|
||||
|
|
@ -22,9 +27,7 @@ Before starting, ensure you have:
|
|||
For all options, first:
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
|
||||
<Step title="Install dlt">
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ sidebarTitle: "Automating Documentation Updates with Continue CLI"
|
|||
description: "Learn how to create automated documentation generation workflows using Continue CLI. Set up AI agents to analyze code changes and generate or update documentation automatically in GitHub workflows or local development."
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<iframe
|
||||
width="560"
|
||||
height="315"
|
||||
|
|
@ -43,11 +48,10 @@ This process utilizes the **Continue CLI** (`cn`) in **headless mode** to analyz
|
|||
## Prerequisites
|
||||
|
||||
<CardGroup cols={1}>
|
||||
<Card title="Node.js 18+" icon="node-js">
|
||||
Continue CLI requires Node.js 18 or higher. Install globally with:
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<Card title="Install Continue CLI" icon="terminal">
|
||||
Continue CLI requires Node.js 20 or higher.
|
||||
|
||||
<CLIInstall />
|
||||
</Card>
|
||||
|
||||
<Card title="Continue API Key" icon="key">
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Use Continue and the GitHub MCP to list, summarize, and act on ope
|
|||
sidebarTitle: "GitHub Issues with Continue"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Card title="What You'll Build" icon="github">
|
||||
A GitHub workflow assistant that uses Continue with the GitHub MCP to:
|
||||
- List, filter, and summarize open issues
|
||||
|
|
@ -27,9 +32,7 @@ Before starting, ensure you have:
|
|||
For all options, first:
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
|
||||
<Step title="Configure GitHub Token">
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Use Continue and Klavis AI's Strata MCP to automate communication
|
|||
sidebarTitle: "Klavis AI with Continue"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Card title="What You'll Build" icon="wand-magic-sparkles">
|
||||
A communication workflow assistant that uses Continue CLI with Klavis AI's Strata MCP to manage and automate multi-platform workflows including Slack and Gmail—all through simple natural language prompts.
|
||||
</Card>
|
||||
|
|
@ -24,9 +29,7 @@ Before starting, ensure you have:
|
|||
For all options, first:
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
|
||||
<Step title="Get Klavis AI's Strata URL">
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Optimize web performance with A/B testing, automated monitoring, a
|
|||
sidebarTitle: "Using Netlify MCP for Performance Optimization"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Card title="Ship Faster Code, Not Slower Sites" icon="gauge-high">
|
||||
Use AI to automatically monitor performance metrics, run A/B tests between
|
||||
branches, and get actionable optimization suggestions based on real user data
|
||||
|
|
@ -44,7 +49,7 @@ This cookbook teaches you to:
|
|||
- GitHub repository with a web project
|
||||
- [Netlify account](https://netlify.com) (free tier works)
|
||||
- Node.js 22+ installed (required for Netlify)
|
||||
- [Continue CLI](https://docs.continue.dev/guides/cli) (`npm i -g @continuedev/cli`)
|
||||
- [Continue CLI](https://docs.continue.dev/guides/cli)
|
||||
- [Netlify MCP](https://continue.dev/netlify/netlify-mcp) configured
|
||||
- [Netlify Development Rules](https://continue.dev/netlify/netlify-development) (recommended)
|
||||
|
||||
|
|
@ -61,9 +66,7 @@ This cookbook teaches you to:
|
|||
For all options, first:
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
|
||||
<Step title="Install Netlify CLI">
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Use Continue CLI with Notion to generate docs, manage tasks, and a
|
|||
sidebarTitle: "Notion with Continue"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Card title="What You'll Build" icon="notion">
|
||||
|
||||
A workflow that lets you query, update, and create Notion pages or database
|
||||
|
|
@ -25,7 +30,7 @@ This guide teaches you to:
|
|||
|
||||
Before starting, ensure you have:
|
||||
|
||||
- [Continue CLI](https://docs.continue.dev/cli/overview) installed (`npm i -g @continuedev/cli`)
|
||||
- [Continue CLI](https://docs.continue.dev/cli/overview) installed
|
||||
- A [Notion workspace](https://notion.so) with Editor (or higher) access
|
||||
- Node.js 18+ installed locally
|
||||
- [Continue account](https://continue.dev) with **Hub access**
|
||||
|
|
@ -40,9 +45,8 @@ Before starting, ensure you have:
|
|||
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
|
||||
Verify installation:
|
||||
```bash
|
||||
cn --version
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Build an automated system that continuously monitors PostHog analy
|
|||
sidebarTitle: "PostHog Analytics with Continue CLI"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Card title="What You'll Build" icon="robot">
|
||||
A fully automated workflow that uses Continue CLI with the PostHog MCP to fetch analytics data, analyze user experience issues with AI, and automatically create GitHub
|
||||
issues with the GitHub CLI.
|
||||
|
|
@ -36,9 +41,7 @@ Before starting, ensure you have:
|
|||
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
|
||||
<Step title="Set up Continue CLI Account & API Key">
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ description: "Set up version-controlled agents in your repository and run them w
|
|||
|
||||
Before starting, ensure you have:
|
||||
|
||||
- [Continue CLI installed](/cli/install) (`npm i -g @continuedev/cli`)
|
||||
- [Continue CLI installed](/cli/install)
|
||||
- `ANTHROPIC_API_KEY` environment variable set
|
||||
- [GitHub CLI](https://cli.github.com/) installed locally if your agents interact with GitHub (pre-installed on GitHub-hosted runners)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Set up an AI-powered content management workflow that helps you ma
|
|||
sidebarTitle: "Sanity CMS with Continue"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Card title="What You'll Build" icon="database">
|
||||
An AI-powered content management system workflow that uses Continue's AI agent with Sanity
|
||||
MCP to manage schemas, execute GROQ queries, handle migrations, and maintain documentation - all through simple natural language prompts
|
||||
|
|
@ -22,9 +27,7 @@ Before starting, ensure you have:
|
|||
For all options, first:
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
|
||||
<Step title="Install Sanity CLI">
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Build an AI-powered error monitoring workflow that analyzes Sentry
|
|||
sidebarTitle: "Sentry Automated Error Analysis with MCP"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Note>
|
||||
|
||||
**🚀 New: Sentry Mission Control Integration with Continuous AI**
|
||||
|
|
@ -48,9 +53,7 @@ Before starting, ensure you have:
|
|||
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
|
||||
<Step title="Set up Continue CLI Account & API Key">
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Set up an AI-powered security workflow that automatically scans yo
|
|||
sidebarTitle: "Snyk Security Scanning with Continue"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Note>
|
||||
|
||||
**🚀 New: Snyk Mission Control Integration with Continuous AI**
|
||||
|
|
@ -53,9 +58,7 @@ Before starting, ensure you have:
|
|||
For all options, first:
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
|
||||
<Step title="Add Your Project to Snyk">
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ description: "Learn how to audit Row Level Security in your Supabase database, i
|
|||
sidebarTitle: "Supabase RLS Security Audit"
|
||||
---
|
||||
|
||||
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
import CLIInstall from '/snippets/cli-install.mdx'
|
||||
|
||||
<OSAutoDetect />
|
||||
|
||||
<Card title="What You'll Build" icon="shield-check">
|
||||
A security audit workflow that uses Continue CLI with Supabase MCP to identify RLS vulnerabilities, generate secure policies, fix permission issues, and ensure your database follows security best practices.
|
||||
</Card>
|
||||
|
|
@ -29,9 +34,7 @@ Before starting, ensure you have:
|
|||
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
<CLIInstall />
|
||||
</Step>
|
||||
|
||||
<Step title="Set up Continue CLI Account & API Key">
|
||||
|
|
|
|||
35
docs/snippets/OSAutoDetect.jsx
Normal file
35
docs/snippets/OSAutoDetect.jsx
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// Auto-selects the appropriate tab based on the user's OS
|
||||
// Import with: import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx'
|
||||
// Usage: <OSAutoDetect /> at the top of a page with OS-specific tabs
|
||||
// Tab order: 0 = macOS/Linux, 1 = Windows, 2 = npm (default)
|
||||
|
||||
export const OSAutoDetect = () => {
|
||||
return (
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('load', function() {
|
||||
const ua = navigator.userAgent.toLowerCase();
|
||||
const isWindows = ua.includes('win');
|
||||
const isMac = ua.includes('mac');
|
||||
const isLinux = ua.includes('linux');
|
||||
// macOS/Linux (0), Windows (1), npm (2 - default)
|
||||
let tabIndex = 2;
|
||||
if (isMac || isLinux) {
|
||||
tabIndex = 0;
|
||||
} else if (isWindows) {
|
||||
tabIndex = 1;
|
||||
}
|
||||
|
||||
const tabButtons = document.querySelectorAll('[role="tablist"] button');
|
||||
if (tabButtons && tabButtons[tabIndex]) {
|
||||
tabButtons[tabIndex].click();
|
||||
}
|
||||
});
|
||||
}
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
18
docs/snippets/cli-install.mdx
Normal file
18
docs/snippets/cli-install.mdx
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<Tabs>
|
||||
<Tab title="macOS / Linux">
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/continuedev/continue/main/extensions/cli/scripts/install.sh | bash
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Windows">
|
||||
```powershell
|
||||
irm https://raw.githubusercontent.com/continuedev/continue/main/extensions/cli/scripts/install.ps1 | iex
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="npm (cross-platform)">
|
||||
If you already have Node.js 20+:
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
|
@ -6,6 +6,20 @@ The Continue CLI (`cn`) is a customizable command line coding agent.
|
|||
|
||||
## Installation
|
||||
|
||||
**macOS / Linux:**
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/continuedev/continue/main/extensions/cli/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
**Windows (PowerShell):**
|
||||
|
||||
```powershell
|
||||
irm https://raw.githubusercontent.com/continuedev/continue/main/extensions/cli/scripts/install.ps1 | iex
|
||||
```
|
||||
|
||||
Or install with npm if you have Node.js 20+:
|
||||
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
|
|
|
|||
371
extensions/cli/scripts/install.ps1
Normal file
371
extensions/cli/scripts/install.ps1
Normal file
|
|
@ -0,0 +1,371 @@
|
|||
#Requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Continue CLI Installer for Windows
|
||||
.DESCRIPTION
|
||||
Installs Node.js (if needed) and the Continue CLI globally
|
||||
.EXAMPLE
|
||||
irm https://continue.dev/install.ps1 | iex
|
||||
.NOTES
|
||||
Supports Windows 10/11, Windows Server 2016+
|
||||
Requires internet connectivity
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[switch]$Force,
|
||||
[int]$Timeout = 60
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$ProgressPreference = 'SilentlyContinue' # Faster downloads
|
||||
|
||||
$script:RequiredNodeVersion = [version]"20.19.0"
|
||||
$script:PackageName = "@continuedev/cli"
|
||||
$script:CliCommand = "cn"
|
||||
$script:FnmInstalled = $false
|
||||
$script:FnmPath = "$env:LOCALAPPDATA\fnm"
|
||||
|
||||
function Write-Info { param($Message) Write-Host "==> " -ForegroundColor Cyan -NoNewline; Write-Host $Message }
|
||||
function Write-Success { param($Message) Write-Host "==> " -ForegroundColor Green -NoNewline; Write-Host $Message }
|
||||
function Write-Warn { param($Message) Write-Host "==> Warning: " -ForegroundColor Yellow -NoNewline; Write-Host $Message }
|
||||
function Write-Err { param($Message) Write-Host "==> Error: " -ForegroundColor Red -NoNewline; Write-Host $Message }
|
||||
|
||||
function Test-InternetConnection {
|
||||
try {
|
||||
$request = [System.Net.WebRequest]::Create("https://registry.npmjs.org")
|
||||
$request.Timeout = 5000
|
||||
$request.Method = "HEAD"
|
||||
$response = $request.GetResponse()
|
||||
$response.Close()
|
||||
return $true
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-SafeWebRequest {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Uri,
|
||||
[string]$OutFile
|
||||
)
|
||||
|
||||
$webClient = New-Object System.Net.WebClient
|
||||
try {
|
||||
if ($OutFile) {
|
||||
$webClient.DownloadFile($Uri, $OutFile)
|
||||
} else {
|
||||
return $webClient.DownloadString($Uri)
|
||||
}
|
||||
} catch [System.Net.WebException] {
|
||||
Write-Err "Failed to download from $Uri`: $($_.Exception.Message)"
|
||||
throw
|
||||
} finally {
|
||||
$webClient.Dispose()
|
||||
}
|
||||
}
|
||||
|
||||
function Remove-FnmInstallation {
|
||||
if ($script:FnmInstalled -and (Test-Path $script:FnmPath)) {
|
||||
Write-Warn "Cleaning up partial fnm installation..."
|
||||
Remove-Item -Path $script:FnmPath -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
function Get-NodeVersion {
|
||||
try {
|
||||
$nodeOutput = & node -v 2>$null
|
||||
if ($nodeOutput -match '^v?(\d+\.\d+\.\d+)') {
|
||||
return [version]$Matches[1]
|
||||
}
|
||||
} catch {}
|
||||
return $null
|
||||
}
|
||||
|
||||
function Test-NodeInstalled {
|
||||
$currentVersion = Get-NodeVersion
|
||||
if ($null -eq $currentVersion) {
|
||||
Write-Warn "Node.js is not installed"
|
||||
return $false
|
||||
}
|
||||
|
||||
Write-Info "Found Node.js v$currentVersion"
|
||||
if ($currentVersion -ge $RequiredNodeVersion) {
|
||||
Write-Success "Node.js meets requirements (>= v$RequiredNodeVersion)"
|
||||
return $true
|
||||
}
|
||||
|
||||
Write-Warn "Node.js v$currentVersion is below required v$RequiredNodeVersion"
|
||||
return $false
|
||||
}
|
||||
|
||||
function Install-Fnm {
|
||||
Write-Info "Installing fnm (Fast Node Manager)..."
|
||||
|
||||
$fnmInstalled = $false
|
||||
|
||||
# Method 1: Try winget (preferred - more reliable)
|
||||
if (Get-Command winget -ErrorAction SilentlyContinue) {
|
||||
Write-Info "Using winget to install fnm..."
|
||||
try {
|
||||
$wingetResult = winget install Schniz.fnm --accept-package-agreements --accept-source-agreements -h 2>&1
|
||||
if ($LASTEXITCODE -eq 0 -or $wingetResult -match "already installed") {
|
||||
$fnmInstalled = $true
|
||||
} else {
|
||||
Write-Warn "winget installation returned non-zero exit code, trying alternative method..."
|
||||
}
|
||||
} catch {
|
||||
Write-Warn "winget failed: $($_.Exception.Message). Trying alternative method..."
|
||||
}
|
||||
}
|
||||
|
||||
# Method 2: Direct binary download (safer than executing remote script)
|
||||
if (-not $fnmInstalled) {
|
||||
Write-Info "Downloading fnm binary directly..."
|
||||
try {
|
||||
$arch = if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" }
|
||||
$fnmZipUrl = "https://github.com/Schniz/fnm/releases/latest/download/fnm-windows.zip"
|
||||
$tempZip = Join-Path $env:TEMP "fnm-windows.zip"
|
||||
$extractPath = $script:FnmPath
|
||||
|
||||
# Download the zip file
|
||||
Invoke-SafeWebRequest -Uri $fnmZipUrl -OutFile $tempZip
|
||||
|
||||
# Create fnm directory if it doesn't exist
|
||||
if (-not (Test-Path $extractPath)) {
|
||||
New-Item -ItemType Directory -Path $extractPath -Force | Out-Null
|
||||
}
|
||||
|
||||
# Extract the zip
|
||||
Expand-Archive -Path $tempZip -DestinationPath $extractPath -Force
|
||||
|
||||
# Clean up temp file
|
||||
Remove-Item -Path $tempZip -Force -ErrorAction SilentlyContinue
|
||||
|
||||
if (Test-Path "$extractPath\fnm.exe") {
|
||||
$fnmInstalled = $true
|
||||
$script:FnmInstalled = $true
|
||||
}
|
||||
} catch {
|
||||
Write-Warn "Direct download failed: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $fnmInstalled) {
|
||||
Write-Err "Failed to install fnm using all available methods."
|
||||
Write-Err "Please install Node.js manually from https://nodejs.org or install fnm from https://github.com/Schniz/fnm"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Add fnm to current session PATH and persist it
|
||||
$fnmPaths = @(
|
||||
$script:FnmPath,
|
||||
"$env:LOCALAPPDATA\Microsoft\WinGet\Packages\Schniz.fnm_*",
|
||||
"$env:USERPROFILE\.fnm",
|
||||
"$env:APPDATA\fnm"
|
||||
)
|
||||
|
||||
foreach ($pathPattern in $fnmPaths) {
|
||||
$resolvedPaths = Resolve-Path -Path $pathPattern -ErrorAction SilentlyContinue
|
||||
foreach ($resolvedPath in $resolvedPaths) {
|
||||
if (Test-Path "$resolvedPath\fnm.exe") {
|
||||
$env:PATH = "$resolvedPath;$env:PATH"
|
||||
Write-Info "Found fnm at: $resolvedPath"
|
||||
|
||||
# Persist fnm to user PATH if not already there
|
||||
$userPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
|
||||
if ($userPath -notlike "*$resolvedPath*") {
|
||||
Write-Info "Adding fnm to user PATH for future sessions..."
|
||||
[Environment]::SetEnvironmentVariable('PATH', "$resolvedPath;$userPath", 'User')
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Install-Node {
|
||||
Install-Fnm
|
||||
|
||||
if (-not (Get-Command fnm -ErrorAction SilentlyContinue)) {
|
||||
Remove-FnmInstallation
|
||||
Write-Err "Failed to install fnm. Please install Node.js manually from https://nodejs.org"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Info "Installing Node.js v$RequiredNodeVersion..."
|
||||
|
||||
try {
|
||||
# Initialize fnm for current session
|
||||
$fnmEnvOutput = fnm env --use-on-cd 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "fnm env failed: $fnmEnvOutput"
|
||||
}
|
||||
$fnmEnvOutput | Out-String | Invoke-Expression
|
||||
|
||||
# Install Node.js
|
||||
$installOutput = fnm install $RequiredNodeVersion.ToString() 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "fnm install failed: $installOutput"
|
||||
}
|
||||
|
||||
fnm use $RequiredNodeVersion.ToString()
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "fnm use failed"
|
||||
}
|
||||
|
||||
fnm default $RequiredNodeVersion.ToString()
|
||||
|
||||
# Re-initialize to pick up the new node
|
||||
fnm env --use-on-cd | Out-String | Invoke-Expression
|
||||
|
||||
# Verify node is now available
|
||||
$nodeVersion = Get-NodeVersion
|
||||
if ($null -eq $nodeVersion) {
|
||||
throw "Node.js installation completed but node command not found"
|
||||
}
|
||||
|
||||
Write-Success "Node.js v$nodeVersion installed"
|
||||
|
||||
# Add fnm setup to PowerShell profile
|
||||
Add-ToProfile
|
||||
} catch {
|
||||
Remove-FnmInstallation
|
||||
Write-Err "Failed to install Node.js: $($_.Exception.Message)"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Add-ToProfile {
|
||||
$profileDir = Split-Path $PROFILE -Parent
|
||||
if (-not (Test-Path $profileDir)) {
|
||||
New-Item -ItemType Directory -Path $profileDir -Force | Out-Null
|
||||
}
|
||||
|
||||
if (-not (Test-Path $PROFILE)) {
|
||||
New-Item -ItemType File -Path $PROFILE -Force | Out-Null
|
||||
}
|
||||
|
||||
$fnmInit = 'fnm env --use-on-cd | Out-String | Invoke-Expression'
|
||||
$profileContent = Get-Content $PROFILE -Raw -ErrorAction SilentlyContinue
|
||||
|
||||
if ($profileContent -notmatch 'fnm env') {
|
||||
Write-Info "Adding fnm to PowerShell profile..."
|
||||
Add-Content -Path $PROFILE -Value "`n# fnm (Node version manager)`n$fnmInit"
|
||||
}
|
||||
}
|
||||
|
||||
function Install-Cli {
|
||||
Write-Info "Installing $PackageName..."
|
||||
|
||||
if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
|
||||
Write-Err "npm not found. Please restart PowerShell and try again."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check npm global directory permissions
|
||||
$npmPrefix = npm config get prefix 2>$null
|
||||
if ($npmPrefix -and (Test-Path $npmPrefix)) {
|
||||
try {
|
||||
$testFile = Join-Path $npmPrefix "_continue_test_write"
|
||||
[IO.File]::WriteAllText($testFile, "test")
|
||||
Remove-Item $testFile -Force
|
||||
} catch {
|
||||
Write-Warn "Cannot write to npm global directory. Configuring user-local prefix..."
|
||||
$userNpmDir = "$env:USERPROFILE\.npm-global"
|
||||
if (-not (Test-Path $userNpmDir)) {
|
||||
New-Item -ItemType Directory -Path $userNpmDir -Force | Out-Null
|
||||
}
|
||||
npm config set prefix $userNpmDir
|
||||
$env:PATH = "$userNpmDir;$env:PATH"
|
||||
|
||||
# Persist npm global bin to user PATH
|
||||
$userPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
|
||||
if ($userPath -notlike "*$userNpmDir*") {
|
||||
Write-Info "Adding npm global directory to user PATH for future sessions..."
|
||||
[Environment]::SetEnvironmentVariable('PATH', "$userNpmDir;$userPath", 'User')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$npmOutput = npm install -g $PackageName 2>&1
|
||||
$npmExitCode = $LASTEXITCODE
|
||||
|
||||
if ($npmExitCode -ne 0) {
|
||||
Write-Host $npmOutput -ForegroundColor Red
|
||||
Write-Err "Failed to install $PackageName (exit code: $npmExitCode)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Verify the CLI was installed
|
||||
$npmBinPath = npm config get prefix 2>$null
|
||||
if ($npmBinPath) {
|
||||
$env:PATH = "$npmBinPath;$env:PATH"
|
||||
}
|
||||
|
||||
Write-Success "$PackageName installed!"
|
||||
}
|
||||
|
||||
function Show-Complete {
|
||||
Write-Host ""
|
||||
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
|
||||
Write-Success "Continue CLI installation complete!"
|
||||
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Check if CLI is available
|
||||
if (Get-Command $CliCommand -ErrorAction SilentlyContinue) {
|
||||
Write-Success "Ready! Run: $CliCommand --help"
|
||||
} else {
|
||||
Write-Host "Restart PowerShell, then run: " -NoNewline
|
||||
Write-Host "$CliCommand --help" -ForegroundColor White
|
||||
}
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
function Main {
|
||||
Write-Host ""
|
||||
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
|
||||
Write-Host " Continue CLI Installer" -ForegroundColor White
|
||||
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Detect architecture properly
|
||||
$arch = if ([Environment]::Is64BitOperatingSystem) {
|
||||
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x64" }
|
||||
} else {
|
||||
"x86"
|
||||
}
|
||||
Write-Info "Detected platform: Windows-$arch"
|
||||
|
||||
# Check internet connectivity
|
||||
Write-Info "Checking internet connectivity..."
|
||||
if (-not (Test-InternetConnection)) {
|
||||
Write-Err "Cannot reach npm registry. Please check your internet connection and try again."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check Windows version
|
||||
$osVersion = [Environment]::OSVersion.Version
|
||||
if ($osVersion.Major -lt 10) {
|
||||
Write-Warn "Windows version $osVersion may not be fully supported. Windows 10 or later is recommended."
|
||||
}
|
||||
|
||||
if (-not (Test-NodeInstalled)) {
|
||||
Install-Node
|
||||
}
|
||||
|
||||
Install-Cli
|
||||
Show-Complete
|
||||
}
|
||||
|
||||
# Run main function
|
||||
try {
|
||||
Main
|
||||
} catch {
|
||||
Remove-FnmInstallation
|
||||
Write-Err "Installation failed: $($_.Exception.Message)"
|
||||
Write-Host $_.ScriptStackTrace -ForegroundColor DarkGray
|
||||
exit 1
|
||||
}
|
||||
329
extensions/cli/scripts/install.sh
Normal file
329
extensions/cli/scripts/install.sh
Normal file
|
|
@ -0,0 +1,329 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Continue CLI Installer - Unix (macOS, Linux, WSL, Git Bash)
|
||||
# curl -fsSL https://continue.dev/install.sh | bash
|
||||
|
||||
REQUIRED_NODE_VERSION="20.19.0"
|
||||
PACKAGE_NAME="@continuedev/cli"
|
||||
CLI_COMMAND="cn"
|
||||
NETWORK_TIMEOUT=60
|
||||
FNM_INSTALL_DIR="$HOME/.local/share/fnm"
|
||||
|
||||
# Cleanup tracking
|
||||
CLEANUP_FNM=false
|
||||
|
||||
# Colors
|
||||
if [ -t 1 ] && [ "$(tput colors 2>/dev/null || echo 0)" -ge 8 ]; then
|
||||
RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m' BOLD='\033[1m' NC='\033[0m'
|
||||
else
|
||||
RED='' GREEN='' YELLOW='' BLUE='' BOLD='' NC=''
|
||||
fi
|
||||
|
||||
info() { printf "${BLUE}==>${NC} ${BOLD}%s${NC}\n" "$1"; }
|
||||
success() { printf "${GREEN}==>${NC} ${BOLD}%s${NC}\n" "$1"; }
|
||||
warn() { printf "${YELLOW}==> Warning:${NC} %s\n" "$1"; }
|
||||
error() { printf "${RED}==> Error:${NC} %s\n" "$1" >&2; exit 1; }
|
||||
|
||||
cleanup() {
|
||||
local exit_code=$?
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
warn "Installation failed. Cleaning up..."
|
||||
if [ "$CLEANUP_FNM" = true ] && [ -d "$FNM_INSTALL_DIR" ]; then
|
||||
rm -rf "$FNM_INSTALL_DIR" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
exit $exit_code
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
PLATFORM=""
|
||||
ARCH=""
|
||||
SHELL_PROFILE=""
|
||||
SHELL_TYPE=""
|
||||
|
||||
check_dependencies() {
|
||||
local missing_deps=()
|
||||
|
||||
if ! command -v curl &>/dev/null && ! command -v wget &>/dev/null; then
|
||||
missing_deps+=("curl or wget")
|
||||
fi
|
||||
|
||||
if ! command -v tar &>/dev/null; then
|
||||
missing_deps+=("tar")
|
||||
fi
|
||||
|
||||
if ! command -v unzip &>/dev/null; then
|
||||
missing_deps+=("unzip")
|
||||
fi
|
||||
|
||||
if [ ${#missing_deps[@]} -gt 0 ]; then
|
||||
error "Missing required dependencies: ${missing_deps[*]}. Please install them first."
|
||||
fi
|
||||
}
|
||||
|
||||
download() {
|
||||
local url="$1"
|
||||
local output="${2:-}"
|
||||
|
||||
if command -v curl &>/dev/null; then
|
||||
if [ -n "$output" ]; then
|
||||
curl -fsSL --connect-timeout "$NETWORK_TIMEOUT" --max-time $((NETWORK_TIMEOUT * 3)) -o "$output" "$url"
|
||||
else
|
||||
curl -fsSL --connect-timeout "$NETWORK_TIMEOUT" --max-time $((NETWORK_TIMEOUT * 3)) "$url"
|
||||
fi
|
||||
elif command -v wget &>/dev/null; then
|
||||
if [ -n "$output" ]; then
|
||||
wget -q --timeout="$NETWORK_TIMEOUT" -O "$output" "$url"
|
||||
else
|
||||
wget -q --timeout="$NETWORK_TIMEOUT" -O - "$url"
|
||||
fi
|
||||
else
|
||||
error "Neither curl nor wget found. Please install one of them."
|
||||
fi
|
||||
}
|
||||
|
||||
detect_platform() {
|
||||
local os arch
|
||||
os="$(uname -s)"
|
||||
arch="$(uname -m)"
|
||||
|
||||
case "$os" in
|
||||
Linux*) PLATFORM="linux" ;;
|
||||
Darwin*) PLATFORM="darwin" ;;
|
||||
MINGW*|MSYS*|CYGWIN*|Windows_NT) PLATFORM="windows" ;;
|
||||
*) error "Unsupported OS: $os. Use install.ps1 for Windows." ;;
|
||||
esac
|
||||
|
||||
case "$arch" in
|
||||
x86_64|amd64) ARCH="x64" ;;
|
||||
arm64|aarch64) ARCH="arm64" ;;
|
||||
armv7l) ARCH="armv7l" ;;
|
||||
i386|i686) error "32-bit systems are not supported" ;;
|
||||
*) error "Unsupported architecture: $arch" ;;
|
||||
esac
|
||||
|
||||
info "Detected platform: $PLATFORM-$ARCH"
|
||||
}
|
||||
|
||||
detect_shell_profile() {
|
||||
local current_shell
|
||||
current_shell="$(basename "${SHELL:-/bin/bash}")"
|
||||
SHELL_TYPE="$current_shell"
|
||||
|
||||
case "$current_shell" in
|
||||
zsh) SHELL_PROFILE="$HOME/.zshrc" ;;
|
||||
bash)
|
||||
if [ "$PLATFORM" = "darwin" ]; then
|
||||
SHELL_PROFILE="$HOME/.bash_profile"
|
||||
else
|
||||
SHELL_PROFILE="$HOME/.bashrc"
|
||||
fi
|
||||
;;
|
||||
fish)
|
||||
SHELL_PROFILE="$HOME/.config/fish/config.fish"
|
||||
mkdir -p "$HOME/.config/fish"
|
||||
;;
|
||||
*)
|
||||
for f in "$HOME/.bashrc" "$HOME/.bash_profile" "$HOME/.profile"; do
|
||||
[ -f "$f" ] && SHELL_PROFILE="$f" && break
|
||||
done
|
||||
[ -z "$SHELL_PROFILE" ] && SHELL_PROFILE="$HOME/.bashrc"
|
||||
;;
|
||||
esac
|
||||
touch "$SHELL_PROFILE"
|
||||
info "Using shell profile: $SHELL_PROFILE"
|
||||
}
|
||||
|
||||
version_gte() {
|
||||
[ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]
|
||||
}
|
||||
|
||||
source_nvm() {
|
||||
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
}
|
||||
|
||||
source_fnm() {
|
||||
for fnm_path in "$HOME/.local/share/fnm" "$HOME/.fnm" "${FNM_DIR:-}"; do
|
||||
if [ -n "$fnm_path" ] && [ -d "$fnm_path" ]; then
|
||||
export PATH="$fnm_path:$PATH"
|
||||
break
|
||||
fi
|
||||
done
|
||||
command -v fnm &>/dev/null && eval "$(fnm env --shell bash 2>/dev/null || true)"
|
||||
}
|
||||
|
||||
check_node() {
|
||||
source_nvm
|
||||
source_fnm
|
||||
|
||||
if command -v node &>/dev/null; then
|
||||
local current_version
|
||||
current_version=$(node -v 2>/dev/null | sed 's/^v//')
|
||||
|
||||
if [ -n "$current_version" ]; then
|
||||
info "Found Node.js v$current_version"
|
||||
if version_gte "$current_version" "$REQUIRED_NODE_VERSION"; then
|
||||
success "Node.js meets requirements (>= v$REQUIRED_NODE_VERSION)"
|
||||
return 0
|
||||
fi
|
||||
warn "Node.js v$current_version is below required v$REQUIRED_NODE_VERSION"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
warn "Node.js is not installed"
|
||||
return 1
|
||||
}
|
||||
|
||||
install_node() {
|
||||
# Only mark for cleanup if fnm directory doesn't already exist
|
||||
if [ ! -d "$FNM_INSTALL_DIR" ]; then
|
||||
CLEANUP_FNM=true
|
||||
fi
|
||||
info "Installing fnm (Fast Node Manager)..."
|
||||
|
||||
mkdir -p "$FNM_INSTALL_DIR"
|
||||
|
||||
if ! download "https://fnm.vercel.app/install" | bash -s -- --install-dir "$FNM_INSTALL_DIR" --skip-shell; then
|
||||
error "Failed to install fnm. Check your network connection and try again."
|
||||
fi
|
||||
|
||||
if [ ! -x "$FNM_INSTALL_DIR/fnm" ]; then
|
||||
error "fnm installation failed - binary not found at $FNM_INSTALL_DIR/fnm"
|
||||
fi
|
||||
|
||||
export PATH="$FNM_INSTALL_DIR:$PATH"
|
||||
|
||||
# Initialize fnm for current session
|
||||
if ! eval "$(fnm env --shell bash 2>/dev/null)"; then
|
||||
error "Failed to initialize fnm environment"
|
||||
fi
|
||||
|
||||
info "Installing Node.js v$REQUIRED_NODE_VERSION..."
|
||||
if ! fnm install "$REQUIRED_NODE_VERSION"; then
|
||||
error "Failed to install Node.js v$REQUIRED_NODE_VERSION"
|
||||
fi
|
||||
|
||||
fnm use "$REQUIRED_NODE_VERSION"
|
||||
fnm default "$REQUIRED_NODE_VERSION"
|
||||
|
||||
# Verify node is working
|
||||
if ! command -v node &>/dev/null; then
|
||||
error "Node.js installation succeeded but 'node' command not found in PATH"
|
||||
fi
|
||||
|
||||
# Add to shell profile with shell-specific syntax
|
||||
add_fnm_to_profile
|
||||
|
||||
CLEANUP_FNM=false
|
||||
success "Node.js v$REQUIRED_NODE_VERSION installed"
|
||||
}
|
||||
|
||||
add_fnm_to_profile() {
|
||||
case "$SHELL_TYPE" in
|
||||
fish)
|
||||
add_to_profile "set -gx PATH \"$FNM_INSTALL_DIR\" \$PATH" "$FNM_INSTALL_DIR"
|
||||
add_to_profile 'fnm env --use-on-cd --shell fish | source' 'fnm env'
|
||||
;;
|
||||
zsh|bash|*)
|
||||
add_to_profile "export PATH=\"$FNM_INSTALL_DIR:\$PATH\"" "$FNM_INSTALL_DIR"
|
||||
add_to_profile "eval \"\$(fnm env --use-on-cd --shell $SHELL_TYPE)\"" 'fnm env'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
add_to_profile() {
|
||||
local line="$1" check="$2"
|
||||
grep -q "$check" "$SHELL_PROFILE" 2>/dev/null || echo "$line" >> "$SHELL_PROFILE"
|
||||
}
|
||||
|
||||
setup_npm_path() {
|
||||
local npm_bin
|
||||
npm_bin="$(npm config get prefix 2>/dev/null)/bin"
|
||||
[ -d "$npm_bin" ] && export PATH="$npm_bin:$PATH"
|
||||
}
|
||||
|
||||
check_npm_permissions() {
|
||||
local npm_prefix
|
||||
npm_prefix="$(npm config get prefix 2>/dev/null)"
|
||||
|
||||
# Check if we can write to npm global directory
|
||||
if [ -d "$npm_prefix/lib" ] && [ ! -w "$npm_prefix/lib" ]; then
|
||||
warn "Cannot write to npm global directory: $npm_prefix/lib"
|
||||
info "Attempting to fix npm permissions..."
|
||||
|
||||
# Try to use npm prefix in user directory
|
||||
local user_npm_dir="$HOME/.npm-global"
|
||||
mkdir -p "$user_npm_dir"
|
||||
npm config set prefix "$user_npm_dir"
|
||||
export PATH="$user_npm_dir/bin:$PATH"
|
||||
|
||||
add_to_profile "export PATH=\"$user_npm_dir/bin:\$PATH\"" ".npm-global/bin"
|
||||
info "Configured npm to use $user_npm_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
install_cli() {
|
||||
info "Installing $PACKAGE_NAME..."
|
||||
|
||||
check_npm_permissions
|
||||
|
||||
local npm_output
|
||||
local npm_exit_code=0
|
||||
|
||||
npm_output=$(npm install -g "$PACKAGE_NAME" 2>&1) || npm_exit_code=$?
|
||||
|
||||
if [ $npm_exit_code -ne 0 ]; then
|
||||
echo "$npm_output" >&2
|
||||
error "Failed to install $PACKAGE_NAME (exit code: $npm_exit_code)"
|
||||
fi
|
||||
|
||||
# Verify installation
|
||||
setup_npm_path
|
||||
if ! command -v "$CLI_COMMAND" &>/dev/null; then
|
||||
warn "$CLI_COMMAND not found in PATH after installation"
|
||||
warn "You may need to restart your shell or source your profile"
|
||||
fi
|
||||
|
||||
success "$PACKAGE_NAME installed!"
|
||||
}
|
||||
|
||||
finalize() {
|
||||
echo ""
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
success "Continue CLI installation complete!"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo ""
|
||||
|
||||
if command -v "$CLI_COMMAND" &>/dev/null; then
|
||||
success "Ready! Run: $CLI_COMMAND --help"
|
||||
else
|
||||
printf "Run ${BOLD}source %s${NC} or open a new terminal\n" "$SHELL_PROFILE"
|
||||
printf "Then: ${BOLD}%s --help${NC}\n" "$CLI_COMMAND"
|
||||
fi
|
||||
echo ""
|
||||
}
|
||||
|
||||
main() {
|
||||
echo ""
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
printf "${BOLD} Continue CLI Installer${NC}\n"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo ""
|
||||
|
||||
check_dependencies
|
||||
detect_platform
|
||||
detect_shell_profile
|
||||
check_node || install_node
|
||||
setup_npm_path
|
||||
install_cli
|
||||
finalize
|
||||
}
|
||||
|
||||
# Allow sourcing without running
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]] || [ -z "${BASH_SOURCE[0]:-}" ]; then
|
||||
main "$@"
|
||||
fi
|
||||
Loading…
Add table
Reference in a new issue