-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.ps1
More file actions
42 lines (34 loc) · 1.37 KB
/
deploy.ps1
File metadata and controls
42 lines (34 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 一键部署脚本
# 功能:自动增加版本号 -> 编译 -> 打包 -> 安装到当前 VS Code
Write-Host "🚀 开始部署流程..."
# 1. 增加补丁版本号 (例如 0.0.1 -> 0.0.2)
# --no-git-tag-version: 不创建 git tag
Write-Host "1️⃣ 更新版本号..."
npm version patch --no-git-tag-version
# 2. 编译代码
Write-Host "2️⃣ 编译 TypeScript..."
npm run compile
# 3. 打包扩展 (.vsix)
# 检查 vsce 是否安装
if (!(Get-Command "vsce" -ErrorAction SilentlyContinue)) {
Write-Host "⚠️ 未检测到 vsce,正在安装..."
npm install -g @vscode/vsce
}
Write-Host "3️⃣ 打包扩展..."
# 自动确认 yes (例如覆盖旧文件)
# --no-dependencies: 加速打包 (假设依赖已安装)
# --no-yarn: 强制不使用 yarn
# --allow-missing-repository: 忽略缺少 github 仓库配置的警告
vsce package --no-yarn --no-dependencies --allow-missing-repository
# 4. 获取生成的 vsix 文件名
$vsix = Get-ChildItem *.vsix | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if ($vsix) {
# 5. 安装到 VS Code
Write-Host "4️⃣ 安装扩展: $($vsix.Name)..."
code --install-extension $vsix.FullName --force
Write-Host "✅ 部署成功!"
Write-Host "👉 请在 VS Code 窗口中按 [Ctrl+R] 重新加载以应用更改。"
}
else {
Write-Host "❌ 打包失败,未找到 .vsix 文件"
}