skillfree 0.1.70 → 0.1.71
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/install.sh +35 -8
- package/package.json +1 -1
package/install.sh
CHANGED
|
@@ -149,15 +149,27 @@ fi
|
|
|
149
149
|
echo ""
|
|
150
150
|
success "SkillFree CLI 安装完成"
|
|
151
151
|
|
|
152
|
-
# 刷新 PATH
|
|
152
|
+
# 刷新 PATH(尝试多种方式)
|
|
153
153
|
hash -r 2>/dev/null || true
|
|
154
|
-
|
|
154
|
+
NPM_BIN="$(npm bin -g 2>/dev/null || npm root -g | sed 's|/node_modules||')/.bin"
|
|
155
|
+
export PATH="$(npm root -g)/../bin:$NPM_BIN:$PATH"
|
|
155
156
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
# 找到 skillfree 可执行路径(用于后续调用)
|
|
158
|
+
SKILLFREE_BIN=""
|
|
159
|
+
if command -v skillfree &>/dev/null; then
|
|
160
|
+
SKILLFREE_BIN="skillfree"
|
|
161
|
+
else
|
|
162
|
+
# 尝试从 npm 全局 bin 目录找
|
|
163
|
+
_SF_PATH="$(npm root -g 2>/dev/null)/../bin/skillfree"
|
|
164
|
+
if [ -x "$_SF_PATH" ]; then
|
|
165
|
+
SKILLFREE_BIN="$_SF_PATH"
|
|
166
|
+
fi
|
|
167
|
+
fi
|
|
168
|
+
|
|
169
|
+
if [ -z "$SKILLFREE_BIN" ]; then
|
|
170
|
+
warn "CLI 已安装,但当前终端 PATH 未更新,继续完成配置..."
|
|
171
|
+
# 用 node 直接执行 CLI
|
|
172
|
+
SKILLFREE_BIN="node $(npm root -g 2>/dev/null)/skillfree/bin/skillfree.js"
|
|
161
173
|
fi
|
|
162
174
|
|
|
163
175
|
# ── Step 4: 登录(从 /dev/tty 读取,兼容 curl | bash)────────────────────────
|
|
@@ -189,7 +201,22 @@ while true; do
|
|
|
189
201
|
done
|
|
190
202
|
|
|
191
203
|
if [ -n "$API_KEY" ]; then
|
|
192
|
-
SKILLFREE_API_KEY="$API_KEY" SKILLFREE_PLATFORMS="$SKILLFREE_PLATFORMS"
|
|
204
|
+
SKILLFREE_API_KEY="$API_KEY" SKILLFREE_PLATFORMS="$SKILLFREE_PLATFORMS" $SKILLFREE_BIN auth save "$API_KEY"
|
|
205
|
+
fi
|
|
206
|
+
|
|
207
|
+
# ── 安装完成提示:PATH 问题 ────────────────────────────────────────────────────
|
|
208
|
+
if [ "$SKILLFREE_BIN" != "skillfree" ]; then
|
|
209
|
+
echo ""
|
|
210
|
+
warn "当前终端 PATH 未包含 npm 全局 bin,请运行以下命令之一让 skillfree 全局生效:"
|
|
211
|
+
echo ""
|
|
212
|
+
echo -e " ${CYAN} 方式一(推荐,重启终端永久生效):${NC}"
|
|
213
|
+
echo -e " ${DIM} 将以下内容加入 ~/.zshrc 或 ~/.bash_profile:${NC}"
|
|
214
|
+
NPM_PREFIX=$(npm config get prefix 2>/dev/null)
|
|
215
|
+
echo -e " ${DIM} export PATH=\"$NPM_PREFIX/bin:\$PATH\"${NC}"
|
|
216
|
+
echo ""
|
|
217
|
+
echo -e " ${CYAN} 方式二(仅当前终端临时生效):${NC}"
|
|
218
|
+
echo -e " ${DIM} export PATH=\"$NPM_PREFIX/bin:\$PATH\"${NC}"
|
|
219
|
+
echo ""
|
|
193
220
|
fi
|
|
194
221
|
|
|
195
222
|
# ── 完成 ──────────────────────────────────────────────────────────────────────
|