虽然有线上 IDE,但是不好用,无法分模块开发。bun 的编译速度很快,配置一个开发模板。
首先安装 windows 版本的 bun
windows 版本的 bun 无法进行包安装,可以结合 npm 一起使用。
创建一个空目录 example001
cd example001
bun init
burn run index.ts
# burn install 在 windows 下失败,改用 npm
npm install -D clasp typescript @google/clasp @types/google-apps-script
clasp login
# 创建一个 google sheets,这个 sheets 文件名会以目录名命名
clasp create --type sheets
修改 .clasp.json
修改 rootDir 为编译目录
{
"scriptId": "xxxxxxxxxxxxxxxxxxxxxx",
"rootDir": "./dist"
}
修改 package.json,添加编译命令
"scripts": {
"build": "bun build ./index.ts --outdir ./dist",
"push": "clasp push",
"open": "clasp open",
"deploy": "bun run build && bun run push"
},
测试
bun run deploy
bun run open
其他
- https://github.com/ashtonfei/google-apps-script-projects 一个 youtube 播主的示例
- https://github.com/tanaikech/taking-advantage-of-Web-Apps-with-google-apps-script 通过 Google Apps 脚本利用 Web 应用
- https://tanaikech.github.io/topics/ 这个博客写了很多 GAS 脚本
- https://auto-worker.com/blog/