ylcwf 0.3.0 → 0.5.0
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/CHANGELOG.md +81 -0
- package/README.md +133 -37
- package/dist/index.js +14366 -3522
- package/dist/l.js +52 -0
- package/package.json +13 -6
- package/scripts/install-app-macos.sh +73 -0
- package/scripts/install.ps1 +94 -0
- package/scripts/install.sh +104 -0
- package/ui-dist/assets/{index-CO4m3Mgh.js → index-B_FY7yA5.js} +22 -22
- package/ui-dist/assets/index-CFsU6qYJ.css +2 -0
- package/ui-dist/index.html +2 -2
- package/ui-dist/assets/index-CKR4uDQb.css +0 -2
package/dist/l.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __webpack_modules__ = {};
|
|
2
|
+
var __webpack_module_cache__ = {};
|
|
3
|
+
function __webpack_require__(moduleId) {
|
|
4
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
5
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
6
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
7
|
+
exports: {}
|
|
8
|
+
};
|
|
9
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
10
|
+
return module.exports;
|
|
11
|
+
}
|
|
12
|
+
__webpack_require__.m = __webpack_modules__;
|
|
13
|
+
(()=>{
|
|
14
|
+
__webpack_require__.n = (module)=>{
|
|
15
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
16
|
+
__webpack_require__.d(getter, {
|
|
17
|
+
a: getter
|
|
18
|
+
});
|
|
19
|
+
return getter;
|
|
20
|
+
};
|
|
21
|
+
})();
|
|
22
|
+
(()=>{
|
|
23
|
+
__webpack_require__.d = (exports, getters, values)=>{
|
|
24
|
+
var define = (defs, kind)=>{
|
|
25
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
[kind]: defs[key]
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
define(getters, "get");
|
|
31
|
+
define(values, "value");
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
(()=>{
|
|
35
|
+
__webpack_require__.add = function(modules) {
|
|
36
|
+
Object.assign(__webpack_require__.m, modules);
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
(()=>{
|
|
40
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
41
|
+
})();
|
|
42
|
+
(()=>{
|
|
43
|
+
__webpack_require__.r = (exports)=>{
|
|
44
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
45
|
+
value: 'Module'
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, '__esModule', {
|
|
48
|
+
value: true
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
})();
|
|
52
|
+
export { __webpack_require__ };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ylcwf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "研发工作流配置 CLI:文档仓库、开发者标识、默认角色与 PRD 终端 → 本地仓库映射",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"dist",
|
|
11
11
|
"index.js",
|
|
12
12
|
"CHANGELOG.md",
|
|
13
|
-
"ui-dist"
|
|
13
|
+
"ui-dist",
|
|
14
|
+
"scripts/install.sh",
|
|
15
|
+
"scripts/install.ps1",
|
|
16
|
+
"scripts/install-app-macos.sh"
|
|
14
17
|
],
|
|
15
18
|
"engines": {
|
|
16
19
|
"node": ">=22.12.0"
|
|
@@ -19,7 +22,7 @@
|
|
|
19
22
|
"build": "rslib build",
|
|
20
23
|
"dev": "rslib build --watch",
|
|
21
24
|
"typecheck": "tsc --noEmit",
|
|
22
|
-
"test": "node --import tsx --test src
|
|
25
|
+
"test": "node --import tsx --test \"src/**/*.test.ts\"",
|
|
23
26
|
"verify": "pnpm typecheck && pnpm typecheck:ui && pnpm typecheck:electron && pnpm test && pnpm build && pnpm build:ui",
|
|
24
27
|
"prepublishOnly": "pnpm verify",
|
|
25
28
|
"build:ui": "vite build --config ui/vite.config.ts",
|
|
@@ -30,7 +33,7 @@
|
|
|
30
33
|
"start:electron": "pnpm build && pnpm build:ui && pnpm build:electron && electron dist-electron/electron/main.js",
|
|
31
34
|
"dev:electron": "pnpm build:electron && YLCWF_DEV_URL=http://127.0.0.1:5173 electron dist-electron/electron/main.js",
|
|
32
35
|
"dist:mac": "pnpm build && pnpm build:ui && pnpm build:electron && electron-builder --mac dmg",
|
|
33
|
-
"dist:win": "pnpm build && pnpm build:ui && pnpm build:electron && electron-builder --win nsis",
|
|
36
|
+
"dist:win": "pnpm build && pnpm build:ui && pnpm build:electron && electron-builder --win nsis --x64",
|
|
34
37
|
"typecheck:electron": "tsc -p tsconfig.electron.json --noEmit",
|
|
35
38
|
"release": "node scripts/release.mjs"
|
|
36
39
|
},
|
|
@@ -124,11 +127,15 @@
|
|
|
124
127
|
]
|
|
125
128
|
}
|
|
126
129
|
],
|
|
127
|
-
"icon": "build/icon.png"
|
|
130
|
+
"icon": "build/icon.png",
|
|
131
|
+
"artifactName": "ylcwf-${version}-setup-${arch}.${ext}"
|
|
128
132
|
},
|
|
129
133
|
"nsis": {
|
|
130
134
|
"oneClick": false,
|
|
131
|
-
"allowToChangeInstallationDirectory": true
|
|
135
|
+
"allowToChangeInstallationDirectory": true,
|
|
136
|
+
"artifactName": "ylcwf-${version}-setup-${arch}.${ext}",
|
|
137
|
+
"shortcutName": "ylcwf",
|
|
138
|
+
"deleteAppDataOnUninstall": false
|
|
132
139
|
}
|
|
133
140
|
}
|
|
134
141
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# ylcwf macOS 桌面端安装脚本:挂载 dmg → 复制到 /Applications → 去除隔离 → 启动。
|
|
3
|
+
#
|
|
4
|
+
# 用法:
|
|
5
|
+
# sh install-app-macos.sh [dmg 路径]
|
|
6
|
+
# sh install-app-macos.sh # 自动在常见位置寻找最新的 ylcwf-*.dmg
|
|
7
|
+
#
|
|
8
|
+
# 可选环境变量:
|
|
9
|
+
# YLCWF_APP_DEST 安装目标(默认 /Applications/ylcwf.app)
|
|
10
|
+
# YLCWF_NO_OPEN=1 安装后不自动启动
|
|
11
|
+
|
|
12
|
+
set -eu
|
|
13
|
+
|
|
14
|
+
APP_NAME="ylcwf.app"
|
|
15
|
+
APP_DEST="${YLCWF_APP_DEST:-/Applications/$APP_NAME}"
|
|
16
|
+
DMG_PATH="${1:-}"
|
|
17
|
+
|
|
18
|
+
info() { printf '%s\n' "$*"; }
|
|
19
|
+
fail() { printf '错误:%s\n' "$*" >&2; exit 1; }
|
|
20
|
+
|
|
21
|
+
[ "$(uname -s)" = "Darwin" ] || fail "该脚本仅适用于 macOS"
|
|
22
|
+
|
|
23
|
+
# 架构检查:dmg 为 arm64 构建,Intel 机器无法运行
|
|
24
|
+
ARCH="$(uname -m)"
|
|
25
|
+
if [ "$ARCH" != "arm64" ]; then
|
|
26
|
+
fail "当前机器架构为 $ARCH,而安装包是 Apple Silicon(arm64)构建,无法运行。请联系维护者提供 x64 版本。"
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
# 定位 dmg
|
|
30
|
+
if [ -z "$DMG_PATH" ]; then
|
|
31
|
+
for dir in "$(pwd)" "$(pwd)/release" "$(dirname "$0")" "$(dirname "$0")/../release"; do
|
|
32
|
+
candidate="$(ls -t "$dir"/ylcwf-*.dmg 2>/dev/null | head -n 1 || true)"
|
|
33
|
+
if [ -n "$candidate" ]; then DMG_PATH="$candidate"; break; fi
|
|
34
|
+
done
|
|
35
|
+
fi
|
|
36
|
+
[ -n "$DMG_PATH" ] || fail "未找到 ylcwf-*.dmg,请把 dmg 路径作为参数传入"
|
|
37
|
+
[ -f "$DMG_PATH" ] || fail "dmg 不存在:$DMG_PATH"
|
|
38
|
+
|
|
39
|
+
info "安装包:$DMG_PATH"
|
|
40
|
+
info "目标位置:$APP_DEST"
|
|
41
|
+
|
|
42
|
+
MOUNT_POINT="$(mktemp -d)/ylcwf-mnt"
|
|
43
|
+
mkdir -p "$MOUNT_POINT"
|
|
44
|
+
cleanup() { hdiutil detach "$MOUNT_POINT" -quiet 2>/dev/null || true; }
|
|
45
|
+
trap cleanup EXIT INT TERM
|
|
46
|
+
|
|
47
|
+
hdiutil attach "$DMG_PATH" -nobrowse -quiet -mountpoint "$MOUNT_POINT" || fail "挂载失败"
|
|
48
|
+
[ -d "$MOUNT_POINT/$APP_NAME" ] || fail "安装包内未找到 $APP_NAME"
|
|
49
|
+
|
|
50
|
+
# 正在运行则先退出,避免复制时文件占用
|
|
51
|
+
if pgrep -x "ylcwf" >/dev/null 2>&1; then
|
|
52
|
+
info "检测到 ylcwf 正在运行,先退出…"
|
|
53
|
+
osascript -e 'quit app "ylcwf"' 2>/dev/null || true
|
|
54
|
+
sleep 1
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# 覆盖安装:先删旧版本(避免残留图标与资源)
|
|
58
|
+
mkdir -p "$(dirname "$APP_DEST")"
|
|
59
|
+
rm -rf "$APP_DEST"
|
|
60
|
+
cp -R "$MOUNT_POINT/$APP_NAME" "$APP_DEST" || fail "复制失败,请确认对 $(dirname "$APP_DEST") 有写权限"
|
|
61
|
+
|
|
62
|
+
# 去除 Gatekeeper 隔离属性(未签名 App 必须)
|
|
63
|
+
xattr -dr com.apple.quarantine "$APP_DEST" 2>/dev/null || true
|
|
64
|
+
|
|
65
|
+
VERSION="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP_DEST/Contents/Info.plist" 2>/dev/null || echo '未知')"
|
|
66
|
+
info ""
|
|
67
|
+
info "安装完成:ylcwf $VERSION → $APP_DEST"
|
|
68
|
+
|
|
69
|
+
if [ "${YLCWF_NO_OPEN:-0}" = "1" ]; then
|
|
70
|
+
info "(YLCWF_NO_OPEN=1,未自动启动)"
|
|
71
|
+
else
|
|
72
|
+
open -a ylcwf && info "已启动。"
|
|
73
|
+
fi
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# ylcwf Windows 安装脚本(PowerShell)
|
|
2
|
+
#
|
|
3
|
+
# 用法:
|
|
4
|
+
# irm https://cdn.jsdelivr.net/npm/ylcwf@latest/scripts/install.ps1 | iex
|
|
5
|
+
# $env:YLCWF_VERSION="0.3.0"; irm ... | iex
|
|
6
|
+
#
|
|
7
|
+
# 可选环境变量:
|
|
8
|
+
# YLCWF_VERSION 指定版本(默认 latest)
|
|
9
|
+
# YLCWF_INSTALL_DIR 安装根目录(默认 %LOCALAPPDATA%\ylcwf)
|
|
10
|
+
|
|
11
|
+
$ErrorActionPreference = 'Stop'
|
|
12
|
+
|
|
13
|
+
$Registry = if ($env:YLCWF_REGISTRY) { $env:YLCWF_REGISTRY } else { 'https://registry.npmjs.org' }
|
|
14
|
+
$InstallRoot = if ($env:YLCWF_INSTALL_DIR) { $env:YLCWF_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'ylcwf' }
|
|
15
|
+
$BinDir = Join-Path $InstallRoot 'bin'
|
|
16
|
+
|
|
17
|
+
function Fail([string]$Message) {
|
|
18
|
+
Write-Host "错误:$Message" -ForegroundColor Red
|
|
19
|
+
exit 1
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# 依赖检查
|
|
23
|
+
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
|
|
24
|
+
Fail '需要 Node.js(>= 22.12),请先安装:https://nodejs.org'
|
|
25
|
+
}
|
|
26
|
+
if (-not (Get-Command tar -ErrorAction SilentlyContinue)) {
|
|
27
|
+
Fail '需要 tar(Windows 10 1803+ 自带;旧系统请升级或用 npm install -g ylcwf)'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
$nodeVersion = (& node -p 'process.versions.node').Trim()
|
|
31
|
+
$parts = $nodeVersion.Split('.')
|
|
32
|
+
if ([int]$parts[0] -lt 22 -or ([int]$parts[0] -eq 22 -and [int]$parts[1] -lt 12)) {
|
|
33
|
+
Fail "Node 版本过低(当前 v$nodeVersion,需要 >= 22.12)"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# 解析版本
|
|
37
|
+
$Version = $env:YLCWF_VERSION
|
|
38
|
+
if ([string]::IsNullOrWhiteSpace($Version)) {
|
|
39
|
+
$meta = Invoke-RestMethod -Uri "$Registry/ylcwf/latest" -UseBasicParsing
|
|
40
|
+
$Version = $meta.version
|
|
41
|
+
}
|
|
42
|
+
if ([string]::IsNullOrWhiteSpace($Version)) { Fail '无法解析版本号' }
|
|
43
|
+
|
|
44
|
+
Write-Host "安装 ylcwf $Version"
|
|
45
|
+
Write-Host " 安装目录:$InstallRoot\$Version"
|
|
46
|
+
Write-Host " 可执行位置:$BinDir\ylcwf.cmd"
|
|
47
|
+
|
|
48
|
+
$target = Join-Path $InstallRoot $Version
|
|
49
|
+
$tarball = Join-Path $env:TEMP "ylcwf-$Version.tgz"
|
|
50
|
+
$extract = Join-Path $env:TEMP "ylcwf-$Version-extract"
|
|
51
|
+
|
|
52
|
+
Invoke-WebRequest -Uri "$Registry/ylcwf/-/ylcwf-$Version.tgz" -OutFile $tarball -UseBasicParsing
|
|
53
|
+
|
|
54
|
+
if (Test-Path $extract) { Remove-Item -Recurse -Force $extract }
|
|
55
|
+
New-Item -ItemType Directory -Path $extract -Force | Out-Null
|
|
56
|
+
& tar -xzf $tarball -C $extract
|
|
57
|
+
|
|
58
|
+
if (-not (Test-Path (Join-Path $extract 'package'))) { Fail '解压失败,包可能不完整' }
|
|
59
|
+
|
|
60
|
+
# 覆盖安装
|
|
61
|
+
if (Test-Path $target) { Remove-Item -Recurse -Force $target }
|
|
62
|
+
New-Item -ItemType Directory -Path $target -Force | Out-Null
|
|
63
|
+
Copy-Item -Path (Join-Path $extract 'package\*') -Destination $target -Recurse -Force
|
|
64
|
+
|
|
65
|
+
# 生成 .cmd 包装器(Windows 不便用软链,避免管理员权限)
|
|
66
|
+
New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
|
|
67
|
+
$cmdPath = Join-Path $BinDir 'ylcwf.cmd'
|
|
68
|
+
$entry = Join-Path $target 'index.js'
|
|
69
|
+
@"
|
|
70
|
+
@echo off
|
|
71
|
+
node "$entry" %*
|
|
72
|
+
"@ | Set-Content -Path $cmdPath -Encoding ASCII
|
|
73
|
+
|
|
74
|
+
# 校验
|
|
75
|
+
$installed = (& node $entry --version).Trim()
|
|
76
|
+
if ($installed -ne $Version) { Fail "安装校验失败(期望 $Version,实际 $installed)" }
|
|
77
|
+
|
|
78
|
+
# PATH(仅用户级,且不存在时才添加)
|
|
79
|
+
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
|
|
80
|
+
if ($userPath -notlike "*$BinDir*") {
|
|
81
|
+
[Environment]::SetEnvironmentVariable('Path', "$userPath;$BinDir", 'User')
|
|
82
|
+
Write-Host ''
|
|
83
|
+
Write-Host "已把 $BinDir 加入用户 PATH,重新打开终端后生效。" -ForegroundColor Yellow
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
# 清理
|
|
87
|
+
Remove-Item -Force $tarball -ErrorAction SilentlyContinue
|
|
88
|
+
Remove-Item -Recurse -Force $extract -ErrorAction SilentlyContinue
|
|
89
|
+
|
|
90
|
+
Write-Host ''
|
|
91
|
+
Write-Host "安装完成:ylcwf $installed" -ForegroundColor Green
|
|
92
|
+
Write-Host ''
|
|
93
|
+
Write-Host '下一步:ylcwf init'
|
|
94
|
+
Write-Host "卸载:Remove-Item -Recurse -Force `"$InstallRoot`""
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# ylcwf 安装脚本:把 CLI 安装到用户目录,无需 sudo,不依赖 npm 全局目录。
|
|
3
|
+
#
|
|
4
|
+
# 用法:
|
|
5
|
+
# curl -fsSL https://cdn.jsdelivr.net/npm/ylcwf@latest/scripts/install.sh | sh
|
|
6
|
+
# curl -fsSL https://cdn.jsdelivr.net/npm/ylcwf@latest/scripts/install.sh | sh -s -- --version 0.3.0
|
|
7
|
+
#
|
|
8
|
+
# 可选环境变量:
|
|
9
|
+
# YLCWF_VERSION 指定版本(默认 latest)
|
|
10
|
+
# YLCWF_INSTALL_DIR 安装根目录(默认 ~/.local/share/ylcwf)
|
|
11
|
+
# YLCWF_BIN_DIR 可执行文件目录(默认 ~/.local/bin)
|
|
12
|
+
|
|
13
|
+
set -eu
|
|
14
|
+
|
|
15
|
+
VERSION="${YLCWF_VERSION:-latest}"
|
|
16
|
+
INSTALL_ROOT="${YLCWF_INSTALL_DIR:-$HOME/.local/share/ylcwf}"
|
|
17
|
+
BIN_DIR="${YLCWF_BIN_DIR:-$HOME/.local/bin}"
|
|
18
|
+
REGISTRY="${YLCWF_REGISTRY:-https://registry.npmjs.org}"
|
|
19
|
+
|
|
20
|
+
info() { printf '%s\n' "$*"; }
|
|
21
|
+
fail() { printf '错误:%s\n' "$*" >&2; exit 1; }
|
|
22
|
+
|
|
23
|
+
# 解析参数
|
|
24
|
+
while [ $# -gt 0 ]; do
|
|
25
|
+
case "$1" in
|
|
26
|
+
--version) VERSION="${2:-}"; shift 2 ;;
|
|
27
|
+
--version=*) VERSION="${1#*=}"; shift ;;
|
|
28
|
+
-h|--help)
|
|
29
|
+
info "用法:install.sh [--version <版本>]"
|
|
30
|
+
exit 0
|
|
31
|
+
;;
|
|
32
|
+
*) fail "未知参数:$1" ;;
|
|
33
|
+
esac
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
# 依赖检查
|
|
37
|
+
command -v tar >/dev/null 2>&1 || fail "缺少 tar"
|
|
38
|
+
# 用函数而不是变量,避免 "$CMD" 被当成单个命令名
|
|
39
|
+
if command -v curl >/dev/null 2>&1; then
|
|
40
|
+
fetch() { curl -fsSL "$1"; }
|
|
41
|
+
elif command -v wget >/dev/null 2>&1; then
|
|
42
|
+
fetch() { wget -qO- "$1"; }
|
|
43
|
+
else
|
|
44
|
+
fail "需要 curl 或 wget"
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
command -v node >/dev/null 2>&1 || fail "需要 Node.js(>= 22.12),请先安装:https://nodejs.org"
|
|
48
|
+
|
|
49
|
+
NODE_MAJOR="$(node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo 0)"
|
|
50
|
+
NODE_MINOR="$(node -p 'process.versions.node.split(".")[1]' 2>/dev/null || echo 0)"
|
|
51
|
+
if [ "$NODE_MAJOR" -lt 22 ] || { [ "$NODE_MAJOR" -eq 22 ] && [ "$NODE_MINOR" -lt 12 ]; }; then
|
|
52
|
+
fail "Node 版本过低(当前 $(node -v),需要 >= 22.12)"
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
# 解析目标版本
|
|
56
|
+
if [ "$VERSION" = "latest" ]; then
|
|
57
|
+
META="$(fetch "$REGISTRY/ylcwf/latest" 2>/dev/null || true)"
|
|
58
|
+
[ -n "$META" ] || fail "无法访问 npm registry,请检查网络"
|
|
59
|
+
VERSION="$(printf '%s' "$META" | sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)"
|
|
60
|
+
[ -n "$VERSION" ] || fail "无法解析最新版本号"
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
info "安装 ylcwf $VERSION"
|
|
64
|
+
info " 安装目录:$INSTALL_ROOT/$VERSION"
|
|
65
|
+
info " 可执行位置:$BIN_DIR/ylcwf"
|
|
66
|
+
|
|
67
|
+
TARGET_DIR="$INSTALL_ROOT/$VERSION"
|
|
68
|
+
TARBALL_URL="$REGISTRY/ylcwf/-/ylcwf-$VERSION.tgz"
|
|
69
|
+
TMP_DIR="$(mktemp -d)"
|
|
70
|
+
trap 'rm -rf "$TMP_DIR"' EXIT INT TERM
|
|
71
|
+
|
|
72
|
+
fetch "$TARBALL_URL" > "$TMP_DIR/pkg.tgz" 2>/dev/null || fail "下载失败:$TARBALL_URL"
|
|
73
|
+
tar -xzf "$TMP_DIR/pkg.tgz" -C "$TMP_DIR" 2>/dev/null || fail "解压失败,包可能不完整"
|
|
74
|
+
|
|
75
|
+
mkdir -p "$TARGET_DIR"
|
|
76
|
+
# 覆盖安装:先清空目标目录内容,保留目录本身
|
|
77
|
+
rm -rf "$TARGET_DIR"/* 2>/dev/null || true
|
|
78
|
+
cp -R "$TMP_DIR/package/." "$TARGET_DIR/"
|
|
79
|
+
|
|
80
|
+
# 建立可执行入口
|
|
81
|
+
mkdir -p "$BIN_DIR"
|
|
82
|
+
ln -sfn "$TARGET_DIR/index.js" "$BIN_DIR/ylcwf"
|
|
83
|
+
chmod +x "$TARGET_DIR/index.js" 2>/dev/null || true
|
|
84
|
+
|
|
85
|
+
# 校验可用性
|
|
86
|
+
INSTALLED="$("$BIN_DIR/ylcwf" --version 2>/dev/null || true)"
|
|
87
|
+
[ "$INSTALLED" = "$VERSION" ] || fail "安装校验失败(期望 ${VERSION},实际 ${INSTALLED:-无输出})"
|
|
88
|
+
|
|
89
|
+
info ""
|
|
90
|
+
info "安装完成:ylcwf $INSTALLED"
|
|
91
|
+
|
|
92
|
+
case ":$PATH:" in
|
|
93
|
+
*":$BIN_DIR:"*) ;;
|
|
94
|
+
*)
|
|
95
|
+
info ""
|
|
96
|
+
info "注意:$BIN_DIR 不在 PATH 中,请加入 shell 配置:"
|
|
97
|
+
info " echo 'export PATH=\"$BIN_DIR:\$PATH\"' >> ~/.zshrc"
|
|
98
|
+
info " 然后执行:source ~/.zshrc"
|
|
99
|
+
;;
|
|
100
|
+
esac
|
|
101
|
+
|
|
102
|
+
info ""
|
|
103
|
+
info "下一步:ylcwf init"
|
|
104
|
+
info "卸载:rm -rf $INSTALL_ROOT $BIN_DIR/ylcwf"
|