Files
superwork/vscode/esbuild.mjs
T
cruldra 499cfad7d7 ✨ feat(vscode): 工单移交的会话包改走阿里云 OSS、换 xz 压缩,两边进度一步步显示
- 会话包传到 OSS 的 spx-handoff/<owner>/<repo>/issue-<N>-<时间>.tar.xz,上传时对象设成私有;不再挂 Gitea 工单附件
- 新命令「配置移交存储」:endpoint、bucket 存扩展设置,AccessKey 存密钥存储;没配时移交 / 接管直接提示,什么都不改
- 共享 state 字段 handoffAttachmentId 改名 handoffBundleKey(含 spx CLI 与 schema)
- 打包换成 xz 1 级(tar -cJf),去掉 100MB 上限检查和先试压一遍的重复压缩
- 发送方提示打包 / 上传了多少 MB;接管方同一条提示依次显示下载、解包、建 worktree、装会话,完成前不消失
- 会话交接(单会话)仍走 Gitea 附件,Gitea 附件白名单没有 .xz,单独保留 gzip 打包
2026-10-08 07:17:26 +08:00

69 lines
2.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* eslint-disable no-console -- 构建脚本,向终端打印进度是它的正当输出 */
import { copyFileSync, mkdirSync } from 'node:fs'
import { createRequire } from 'node:module'
import path from 'node:path'
import process from 'node:process'
import * as esbuild from 'esbuild'
import { getWasmPath } from 'tree-sitter-wasm'
const production = process.argv.includes('--production')
const watch = process.argv.includes('--watch')
/** @type {import('esbuild').BuildOptions} */
const options = {
entryPoints: ['src/extension.ts'],
bundle: true,
outfile: 'dist/index.cjs',
// proxy-agent:ali-oss 底下的 urllib 只在显式开代理时才去 require 它,我们不开,也没装
external: ['vscode', 'proxy-agent'],
format: 'cjs',
platform: 'node',
target: 'node20',
sourcemap: !production,
minify: production,
logLevel: 'info',
}
// 代码阅读的解析运行时(web-tree-sitter,由 esbuild 打进 index.cjs)和它要加载的 wasm:
// 运行时按 __dirname 找 dist/tree-sitter/,语法包只带用到的几种语言
const TREE_SITTER_WASM = [
'tree-sitter.wasm',
'tree-sitter-typescript.wasm',
'tree-sitter-tsx.wasm',
'tree-sitter-javascript.wasm',
'tree-sitter-python.wasm',
'tree-sitter-bash.wasm',
// 包入口就在 wasm/(main 指向 wasm/tree-sitter.js),rust 的语法包和 python 的在同一层
'tree-sitter-rust.wasm',
]
// @vscode/tree-sitter-wasm 没有的语法包,从 tree-sitter-wasm(预编译、签过名的各家语法包)拿:语言名 → 它的 wasm
const EXTRA_GRAMMARS = ['dockerfile']
function copyTreeSitterWasm() {
const from = path.dirname(createRequire(import.meta.url).resolve('@vscode/tree-sitter-wasm'))
const to = 'dist/tree-sitter'
mkdirSync(to, { recursive: true })
for (const file of TREE_SITTER_WASM)
copyFileSync(path.join(from, file), path.join(to, file))
for (const language of EXTRA_GRAMMARS)
copyFileSync(getWasmPath(language), path.join(to, `tree-sitter-${language}.wasm`))
}
async function main() {
copyTreeSitterWasm()
if (watch) {
const ctx = await esbuild.context(options)
await ctx.watch()
console.log('[esbuild] watching...')
}
else {
await esbuild.build(options)
}
}
main().catch((err) => {
console.error(err)
process.exit(1)
})