siluzan-website-cli 1.0.1-beta.1

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.
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # siluzan-website-cli - One-click install script
4
+ # Supported: macOS, Linux, Windows (WSL)
5
+ # =============================================================================
6
+
7
+ set -euo pipefail
8
+
9
+ # -- Package info (injected at build time) ------------------------------------
10
+ readonly PKG_NAME="siluzan-website-cli"
11
+ # PKG_VERSION 锁定到与本脚本同批构建产物一致的版本,避免与 dist/skill 错位
12
+ readonly PKG_VERSION="1.0.1-beta.1"
13
+ readonly CLI_BIN="siluzan-website"
14
+ readonly SKILL_LABEL="Siluzan Website"
15
+ readonly INSTALL_CMD="npm install -g siluzan-website-cli@beta"
16
+ readonly WEB_BASE="https://www-ci.siluzan.com"
17
+
18
+ # -- Constants ----------------------------------------------------------------
19
+ readonly NODE_MAJOR_MIN=18
20
+ readonly NPM_MIRROR="https://registry.npmmirror.com"
21
+
22
+ RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'
23
+ BOLD='\033[1m'; DIM='\033[2m'; NC='\033[0m'
24
+
25
+ info() { printf "${GREEN}[OK]${NC} %s\n" "$1"; }
26
+ warn() { printf "${YELLOW}[!]${NC} %s\n" "$1"; }
27
+ error() { printf "${RED}[X]${NC} %s\n" "$1" >&2; }
28
+ step() { printf "\n${BOLD}-- %s --${NC}\n" "$1"; }
29
+
30
+ # -- Detect OS ----------------------------------------------------------------
31
+ detect_os() {
32
+ local uname_out
33
+ uname_out=$(uname -s 2>/dev/null || echo "Unknown")
34
+ case "$uname_out" in
35
+ Darwin*) echo "macos" ;;
36
+ Linux*) echo "linux" ;;
37
+ MINGW*|MSYS*|CYGWIN*) echo "gitbash" ;;
38
+ *) echo "unknown" ;;
39
+ esac
40
+ }
41
+
42
+ # -- Node.js ------------------------------------------------------------------
43
+ node_version_ok() {
44
+ command -v node >/dev/null 2>&1 || return 1
45
+ local major
46
+ major=$(node -v | tr -d 'v' | cut -d. -f1)
47
+ [ "$major" -ge "$NODE_MAJOR_MIN" ]
48
+ }
49
+
50
+ install_node() {
51
+ local os_type
52
+ os_type=$(detect_os)
53
+ case "$os_type" in
54
+ macos)
55
+ if command -v brew >/dev/null 2>&1; then
56
+ info "Installing Node.js LTS via Homebrew..."
57
+ brew install node@22
58
+ brew link --overwrite node@22 2>/dev/null || true
59
+ else
60
+ info "Installing Node.js LTS via install-node.vercel.app..."
61
+ curl -fsSL https://install-node.vercel.app/lts | bash -s -- --yes
62
+ fi
63
+ ;;
64
+ linux)
65
+ if command -v apt-get >/dev/null 2>&1; then
66
+ info "Installing Node.js 22.x via NodeSource (apt)..."
67
+ curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
68
+ sudo apt-get install -y nodejs
69
+ elif command -v yum >/dev/null 2>&1; then
70
+ info "Installing Node.js 22.x via NodeSource (yum)..."
71
+ curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo -E bash -
72
+ sudo yum install -y nodejs
73
+ else
74
+ info "Installing Node.js LTS via install-node.vercel.app..."
75
+ curl -fsSL https://install-node.vercel.app/lts | bash -s -- --yes
76
+ fi
77
+ ;;
78
+ gitbash)
79
+ error "Cannot auto-install Node.js in Git Bash. Please use the PowerShell script or install manually."
80
+ echo " https://nodejs.org/en/download/"
81
+ exit 1
82
+ ;;
83
+ *)
84
+ error "Unsupported OS. Please install Node.js >= ${NODE_MAJOR_MIN} manually:"
85
+ echo " https://nodejs.org/en/download/"
86
+ exit 1
87
+ ;;
88
+ esac
89
+
90
+ export PATH="$HOME/.local/bin:$HOME/.nodejs/bin:/usr/local/bin:$PATH"
91
+ hash -r 2>/dev/null || true
92
+
93
+ if ! node_version_ok; then
94
+ error "Node.js installation failed. Please install manually:"
95
+ echo " https://nodejs.org/en/download/"
96
+ exit 1
97
+ fi
98
+ }
99
+
100
+ # -- Main ---------------------------------------------------------------------
101
+ main() {
102
+ echo ""
103
+ echo -e "${BOLD}+---------------------------------------------+${NC}"
104
+ echo -e "${BOLD}| ${SKILL_LABEL} -- Install |${NC}"
105
+ echo -e "${BOLD}+---------------------------------------------+${NC}"
106
+ echo ""
107
+
108
+ # Step 1: Environment check
109
+ step "Step 1/4: Environment check"
110
+
111
+ if node_version_ok; then
112
+ info "Node.js $(node -v) found"
113
+ else
114
+ if command -v node >/dev/null 2>&1; then
115
+ warn "Node.js $(node -v) is too old (need >= ${NODE_MAJOR_MIN}), upgrading..."
116
+ else
117
+ warn "Node.js not found, installing..."
118
+ fi
119
+ install_node
120
+ info "Node.js $(node -v) installed"
121
+ fi
122
+
123
+ if command -v pnpm >/dev/null 2>&1; then
124
+ PKG_MANAGER="pnpm"
125
+ elif command -v npm >/dev/null 2>&1; then
126
+ PKG_MANAGER="npm"
127
+ else
128
+ error "npm not found (Node.js installation may be incomplete)"
129
+ exit 1
130
+ fi
131
+ info "$PKG_MANAGER ready"
132
+
133
+ local current_registry
134
+ current_registry=$(npm config get registry 2>/dev/null || echo "")
135
+ if [ "$current_registry" != "$NPM_MIRROR" ] && [ "$current_registry" != "${NPM_MIRROR}/" ]; then
136
+ info "Switching npm registry to China mirror for faster downloads..."
137
+ npm config set registry "$NPM_MIRROR"
138
+ info "npm registry set to $NPM_MIRROR"
139
+ else
140
+ info "npm registry already set to China mirror"
141
+ fi
142
+
143
+ # Step 2: Install CLI
144
+ step "Step 2/4: Install ${PKG_NAME}"
145
+
146
+ # 用打包时锁定的 PKG_VERSION,保证脚本与同批 dist/skill 行为对齐
147
+ local install_target="${PKG_NAME}@${PKG_VERSION}"
148
+ info "Running: $PKG_MANAGER install -g ${install_target}"
149
+ $PKG_MANAGER install -g "${install_target}"
150
+ info "${install_target} installed"
151
+
152
+ info "Registering Skill to all AI platform global directories..."
153
+ ${CLI_BIN} init --global --force
154
+
155
+ if [ "${CLI_BIN}" = "siluzan-seo" ]; then
156
+ info "siluzan-seo does not require login; skipping API Key setup."
157
+ else
158
+ step "Step 3/4: Configure API Key"
159
+ echo ""
160
+ ${CLI_BIN} login
161
+ fi
162
+
163
+ # Step 4: Done
164
+ step "Step 4/4: Complete"
165
+ echo ""
166
+ echo -e " ${GREEN}${SKILL_LABEL} installed successfully!${NC}"
167
+ echo ""
168
+ echo " Skill registered to these global directories (all AI assistants):"
169
+ echo -e " ${DIM}~/.cursor/skills/ ~/.claude/skills/ ~/.agents/skills/"
170
+ echo -e " ~/.gemini/skills/ ~/.codex/skills/ ~/.kilo/skills/"
171
+ echo -e " ~/.codeium/windsurf/skills/ ~/.config/opencode/skills/"
172
+ echo -e " ~/.openclaw/skills/ ~/.workbuddy/skills/${NC}"
173
+ echo ""
174
+ echo " Update CLI & Skill files: ${CLI_BIN} update"
175
+ echo ""
176
+ info "Need help? Visit ${WEB_BASE}"
177
+ echo ""
178
+ }
179
+
180
+ main "$@"
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "siluzan-website-cli",
3
+ "version": "1.0.1-beta.1",
4
+ "description": "Siluzan WordPress 站点管理 Skill CLI — 列出站点、新增/编辑页面、查看插件。",
5
+ "keywords": [
6
+ "ai-skill",
7
+ "cli",
8
+ "cursor",
9
+ "openclaw",
10
+ "siluzan",
11
+ "skill",
12
+ "website",
13
+ "wordpress"
14
+ ],
15
+ "homepage": "https://www.siluzan.com",
16
+ "bugs": {
17
+ "url": "https://dev.azure.com/jack4it/Sammamish/_git/siluzan-skill/issues"
18
+ },
19
+ "license": "UNLICENSED",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://dev.azure.com/jack4it/Sammamish/_git/siluzan-skill",
23
+ "directory": "website-cli"
24
+ },
25
+ "bin": {
26
+ "siluzan-website": "./dist/index.js"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "README.md",
31
+ "scripts/postinstall.mjs"
32
+ ],
33
+ "type": "module",
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "dependencies": {
38
+ "cli-table3": "^0.6.5",
39
+ "commander": "^12.1.0",
40
+ "proper-lockfile": "^4.1.2"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^22.10.0",
44
+ "tsup": "^8.3.0",
45
+ "typescript": "^5.7.2",
46
+ "siluzan-cli-common": "1.0.0"
47
+ },
48
+ "engines": {
49
+ "node": ">=18"
50
+ },
51
+ "scripts": {
52
+ "postinstall": "node scripts/postinstall.mjs",
53
+ "build": "node scripts/write-defaults.mjs --env production && tsup && node scripts/copy-skill-assets.mjs --env production",
54
+ "build:prod": "node scripts/write-defaults.mjs --env production && tsup && node scripts/copy-skill-assets.mjs --env production",
55
+ "build:test": "node scripts/write-defaults.mjs --env test && tsup && node scripts/copy-skill-assets.mjs --env test",
56
+ "start": "node dist/index.js",
57
+ "typecheck": "tsc --noEmit -p tsconfig.json"
58
+ }
59
+ }
@@ -0,0 +1,3 @@
1
+ console.log(
2
+ "[siluzan-website]: 安装成功。运行 siluzan-website init 将 Skill 写入 AI 助手目录;首次使用请 siluzan-website login。",
3
+ );