openclawsetup 1.0.0 → 1.0.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 CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  ## 功能
6
6
 
7
+ - 自动检测并安装 Node.js(如果未安装)
7
8
  - 自动安装 OpenClaw CLI
8
9
  - 自动创建配置文件和 workspace
9
10
  - 自动配置服务持久化(开机自启动)
@@ -12,10 +13,26 @@
12
13
 
13
14
  ## 快速开始
14
15
 
16
+ ### 方式一:一键脚本(推荐,自动安装 Node.js)
17
+
18
+ **macOS / Linux:**
19
+ ```bash
20
+ curl -fsSL https://unpkg.com/openclawsetup/install.sh | bash
21
+ ```
22
+
23
+ **Windows PowerShell:**
24
+ ```powershell
25
+ irm https://unpkg.com/openclawsetup/install.ps1 | iex
26
+ ```
27
+
28
+ ### 方式二:npx(需要已安装 Node.js 18+)
29
+
15
30
  ```bash
16
31
  npx openclawsetup
17
32
  ```
18
33
 
34
+ 如果提示 `npx: command not found`,说明未安装 Node.js,请使用方式一。
35
+
19
36
  ## 安装选项
20
37
 
21
38
  ### 环境变量
@@ -41,6 +58,10 @@ npx openclawsetup
41
58
  ### 默认安装(推荐)
42
59
 
43
60
  ```bash
61
+ # macOS/Linux - 一键脚本
62
+ curl -fsSL https://unpkg.com/openclawsetup/install.sh | bash
63
+
64
+ # 或者 npx(需要 Node.js)
44
65
  npx openclawsetup
45
66
  ```
46
67
 
@@ -189,9 +210,8 @@ systemctl --user daemon-reload
189
210
 
190
211
  ## 系统要求
191
212
 
192
- - Node.js 18+
193
- - npm 或 npx
194
- - macOS / Linux / Windows (WSL2 推荐)
213
+ - macOS / Linux / Windows
214
+ - Node.js 18+(一键脚本会自动安装)
195
215
 
196
216
  ## License
197
217
 
package/install.ps1 ADDED
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env pwsh
2
+ # OpenClaw 一键安装脚本 (Windows PowerShell)
3
+ # 用法: irm https://raw.githubusercontent.com/xxx/openclawsetup/main/install.ps1 | iex
4
+
5
+ $ErrorActionPreference = "Stop"
6
+
7
+ Write-Host ""
8
+ Write-Host "🦞 OpenClaw 一键安装" -ForegroundColor Cyan
9
+ Write-Host ""
10
+
11
+ # 检查 Node.js
12
+ function Test-Node {
13
+ try {
14
+ $version = node -v 2>$null
15
+ if ($version) {
16
+ $major = [int]($version -replace 'v(\d+)\..*', '$1')
17
+ if ($major -ge 18) {
18
+ Write-Host "✓ Node.js 已安装: $version" -ForegroundColor Green
19
+ return $true
20
+ } else {
21
+ Write-Host "⚠ Node.js 版本过低: $version (需要 18+)" -ForegroundColor Yellow
22
+ return $false
23
+ }
24
+ }
25
+ } catch {
26
+ Write-Host "⚠ 未检测到 Node.js" -ForegroundColor Yellow
27
+ return $false
28
+ }
29
+ return $false
30
+ }
31
+
32
+ # 安装 Node.js
33
+ function Install-Node {
34
+ Write-Host "正在安装 Node.js..." -ForegroundColor Cyan
35
+
36
+ # 检查 winget
37
+ if (Get-Command winget -ErrorAction SilentlyContinue) {
38
+ Write-Host "使用 winget 安装..." -ForegroundColor Cyan
39
+ winget install OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements
40
+ }
41
+ # 检查 choco
42
+ elseif (Get-Command choco -ErrorAction SilentlyContinue) {
43
+ Write-Host "使用 Chocolatey 安装..." -ForegroundColor Cyan
44
+ choco install nodejs-lts -y
45
+ }
46
+ # 检查 scoop
47
+ elseif (Get-Command scoop -ErrorAction SilentlyContinue) {
48
+ Write-Host "使用 Scoop 安装..." -ForegroundColor Cyan
49
+ scoop install nodejs-lts
50
+ }
51
+ else {
52
+ Write-Host ""
53
+ Write-Host "========================================" -ForegroundColor Red
54
+ Write-Host "❌ 错误: 未检测到 Node.js" -ForegroundColor Red
55
+ Write-Host "========================================" -ForegroundColor Red
56
+ Write-Host ""
57
+ Write-Host "请手动安装 Node.js 22+:" -ForegroundColor Cyan
58
+ Write-Host " 1. 访问 https://nodejs.org/" -ForegroundColor White
59
+ Write-Host " 2. 下载 LTS 版本" -ForegroundColor White
60
+ Write-Host " 3. 安装后重新运行此脚本" -ForegroundColor White
61
+ Write-Host ""
62
+ Write-Host "或使用包管理器安装:" -ForegroundColor Cyan
63
+ Write-Host " winget install OpenJS.NodeJS.LTS" -ForegroundColor Yellow
64
+ Write-Host " choco install nodejs-lts" -ForegroundColor Yellow
65
+ Write-Host ""
66
+ exit 1
67
+ }
68
+
69
+ # 刷新环境变量
70
+ $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
71
+
72
+ # 验证安装
73
+ if (Test-Node) {
74
+ Write-Host "✓ Node.js 安装完成" -ForegroundColor Green
75
+ } else {
76
+ Write-Host "❌ Node.js 安装失败,请手动安装" -ForegroundColor Red
77
+ Write-Host " https://nodejs.org/" -ForegroundColor Yellow
78
+ exit 1
79
+ }
80
+ }
81
+
82
+ # 检查 npm
83
+ function Test-Npm {
84
+ try {
85
+ $version = npm -v 2>$null
86
+ if ($version) {
87
+ Write-Host "✓ npm 已安装: $version" -ForegroundColor Green
88
+ return $true
89
+ }
90
+ } catch {}
91
+ Write-Host "❌ npm 未找到" -ForegroundColor Red
92
+ return $false
93
+ }
94
+
95
+ # 主流程
96
+ function Main {
97
+ # 1. 检查/安装 Node.js
98
+ if (-not (Test-Node)) {
99
+ Write-Host ""
100
+ Write-Host "需要安装 Node.js 才能继续..." -ForegroundColor Cyan
101
+ Write-Host ""
102
+ Install-Node
103
+ Write-Host ""
104
+ }
105
+
106
+ # 2. 检查 npm
107
+ if (-not (Test-Npm)) {
108
+ Write-Host "npm 安装异常,请检查 Node.js 安装" -ForegroundColor Red
109
+ exit 1
110
+ }
111
+
112
+ # 3. 运行 npx openclawsetup
113
+ Write-Host ""
114
+ Write-Host "开始安装 OpenClaw..." -ForegroundColor Cyan
115
+ Write-Host ""
116
+
117
+ npx openclawsetup@latest
118
+ }
119
+
120
+ Main
package/install.sh ADDED
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env bash
2
+ # OpenClaw 一键安装脚本
3
+ # 用法: curl -fsSL https://raw.githubusercontent.com/xxx/openclawsetup/main/install.sh | bash
4
+
5
+ set -e
6
+
7
+ # 颜色
8
+ RED='\033[0;31m'
9
+ GREEN='\033[0;32m'
10
+ YELLOW='\033[0;33m'
11
+ CYAN='\033[0;36m'
12
+ NC='\033[0m' # No Color
13
+
14
+ log_info() { echo -e "${CYAN}$1${NC}"; }
15
+ log_success() { echo -e "${GREEN}✓ $1${NC}"; }
16
+ log_warn() { echo -e "${YELLOW}⚠ $1${NC}"; }
17
+ log_error() { echo -e "${RED}✗ $1${NC}"; }
18
+
19
+ echo ""
20
+ echo -e "${CYAN}🦞 OpenClaw 一键安装${NC}"
21
+ echo ""
22
+
23
+ # 检测操作系统
24
+ OS="unknown"
25
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
26
+ OS="linux"
27
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
28
+ OS="macos"
29
+ elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
30
+ OS="windows"
31
+ fi
32
+
33
+ log_info "检测到操作系统: $OS"
34
+
35
+ # 检测包管理器 (Linux)
36
+ PM=""
37
+ if command -v apt-get &> /dev/null; then
38
+ PM="apt"
39
+ elif command -v dnf &> /dev/null; then
40
+ PM="dnf"
41
+ elif command -v yum &> /dev/null; then
42
+ PM="yum"
43
+ elif command -v pacman &> /dev/null; then
44
+ PM="pacman"
45
+ elif command -v apk &> /dev/null; then
46
+ PM="apk"
47
+ fi
48
+
49
+ # 检查 Node.js
50
+ check_node() {
51
+ if command -v node &> /dev/null; then
52
+ NODE_VERSION=$(node -v | tr -d 'v')
53
+ NODE_MAJOR=${NODE_VERSION%%.*}
54
+ if [ "$NODE_MAJOR" -ge 18 ]; then
55
+ log_success "Node.js 已安装: v$NODE_VERSION"
56
+ return 0
57
+ else
58
+ log_warn "Node.js 版本过低: v$NODE_VERSION (需要 18+)"
59
+ return 1
60
+ fi
61
+ else
62
+ log_warn "未检测到 Node.js"
63
+ return 1
64
+ fi
65
+ }
66
+
67
+ # 安装 Node.js
68
+ install_node() {
69
+ log_info "正在安装 Node.js 22..."
70
+
71
+ if [ "$OS" == "macos" ]; then
72
+ # macOS - 使用 Homebrew 或 nvm
73
+ if command -v brew &> /dev/null; then
74
+ brew install node@22
75
+ brew link --overwrite --force node@22
76
+ else
77
+ log_info "安装 nvm..."
78
+ curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
79
+ export NVM_DIR="$HOME/.nvm"
80
+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
81
+ nvm install 22
82
+ nvm alias default 22
83
+ fi
84
+ elif [ "$OS" == "linux" ]; then
85
+ # Linux - 根据包管理器安装
86
+ case "$PM" in
87
+ apt)
88
+ log_info "使用 NodeSource 安装..."
89
+ curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
90
+ apt-get install -y nodejs
91
+ ;;
92
+ dnf)
93
+ curl -fsSL https://rpm.nodesource.com/setup_22.x | bash -
94
+ dnf install -y nodejs
95
+ ;;
96
+ yum)
97
+ curl -fsSL https://rpm.nodesource.com/setup_22.x | bash -
98
+ yum install -y nodejs
99
+ ;;
100
+ pacman)
101
+ pacman -Sy --noconfirm nodejs npm
102
+ ;;
103
+ apk)
104
+ apk add --no-cache nodejs npm
105
+ ;;
106
+ *)
107
+ log_info "使用 nvm 安装..."
108
+ curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
109
+ export NVM_DIR="$HOME/.nvm"
110
+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
111
+ nvm install 22
112
+ nvm alias default 22
113
+ ;;
114
+ esac
115
+ else
116
+ log_error "不支持的操作系统: $OS"
117
+ echo ""
118
+ echo "请手动安装 Node.js 22+:"
119
+ echo " https://nodejs.org/"
120
+ echo ""
121
+ exit 1
122
+ fi
123
+
124
+ # 验证安装
125
+ if command -v node &> /dev/null; then
126
+ log_success "Node.js 安装完成: $(node -v)"
127
+ else
128
+ log_error "Node.js 安装失败"
129
+ echo ""
130
+ echo "请手动安装 Node.js 22+:"
131
+ echo " https://nodejs.org/"
132
+ echo ""
133
+ exit 1
134
+ fi
135
+ }
136
+
137
+ # 检查 npm/npx
138
+ check_npm() {
139
+ if command -v npm &> /dev/null && command -v npx &> /dev/null; then
140
+ log_success "npm 已安装: $(npm -v)"
141
+ return 0
142
+ else
143
+ log_error "npm/npx 未找到"
144
+ return 1
145
+ fi
146
+ }
147
+
148
+ # 主流程
149
+ main() {
150
+ # 1. 检查/安装 Node.js
151
+ if ! check_node; then
152
+ echo ""
153
+ log_info "需要安装 Node.js 才能继续..."
154
+ echo ""
155
+ install_node
156
+ echo ""
157
+ fi
158
+
159
+ # 2. 检查 npm
160
+ if ! check_npm; then
161
+ log_error "npm 安装异常,请检查 Node.js 安装"
162
+ exit 1
163
+ fi
164
+
165
+ # 3. 运行 npx openclawsetup
166
+ echo ""
167
+ log_info "开始安装 OpenClaw..."
168
+ echo ""
169
+
170
+ npx openclawsetup@latest
171
+ }
172
+
173
+ main "$@"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclawsetup",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "一键安装 OpenClaw - 自动完成基础部署,无需交互",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,6 +11,8 @@
11
11
  },
12
12
  "files": [
13
13
  "bin/",
14
+ "install.sh",
15
+ "install.ps1",
14
16
  "README.md",
15
17
  "使用说明.md"
16
18
  ],
@@ -2,13 +2,34 @@
2
2
 
3
3
  ## 快速开始
4
4
 
5
- **方式一:默认安装(推荐)**
5
+ ### 方式一:一键脚本(推荐)
6
+
7
+ 自动检测并安装 Node.js,无需任何前置条件。
8
+
9
+ **Linux (Debian/Ubuntu/CentOS 等):**
10
+ ```bash
11
+ curl -fsSL https://unpkg.com/openclawsetup/install.sh | bash
12
+ ```
13
+
14
+ **macOS:**
15
+ ```bash
16
+ curl -fsSL https://unpkg.com/openclawsetup/install.sh | bash
17
+ ```
18
+
19
+ **Windows PowerShell:**
20
+ ```powershell
21
+ irm https://unpkg.com/openclawsetup/install.ps1 | iex
22
+ ```
23
+
24
+ ### 方式二:npx(需要已安装 Node.js)
25
+
6
26
  ```bash
7
27
  npx openclawsetup
8
28
  ```
9
- 自动完成所有配置,无需输入任何内容。
10
29
 
11
- **方式二:指定端口**
30
+ ⚠️ 如果提示 `npx: command not found`,说明未安装 Node.js,请使用方式一。
31
+
32
+ ### 方式三:指定端口
12
33
  ```bash
13
34
  # macOS/Linux
14
35
  OPENCLAW_PORT=8080 npx openclawsetup
@@ -41,6 +62,32 @@ set OPENCLAW_PORT=8080 && npx openclawsetup
41
62
 
42
63
  ## 常见问题
43
64
 
65
+ ### 错误:npx: command not found
66
+ **现象**:运行 `npx openclawsetup` 提示 `npx: command not found`
67
+ **原因**:未安装 Node.js
68
+ **解决**:使用一键脚本安装(会自动安装 Node.js)
69
+ ```bash
70
+ curl -fsSL https://unpkg.com/openclawsetup/install.sh | bash
71
+ ```
72
+
73
+ ---
74
+
75
+ ### 错误:curl: command not found
76
+ **现象**:运行一键脚本提示 `curl: command not found`
77
+ **解决**:先安装 curl
78
+ ```bash
79
+ # Debian/Ubuntu
80
+ apt-get update && apt-get install -y curl
81
+
82
+ # CentOS/RHEL
83
+ yum install -y curl
84
+
85
+ # Alpine
86
+ apk add curl
87
+ ```
88
+
89
+ ---
90
+
44
91
  ### 错误:Node.js 版本过低
45
92
  **现象**:提示 "Node.js 版本过低"
46
93
  **解决**: