google-apps-script - 将 Google Apps 脚本项目切换到 V8 运行时时的范围问题
问题描述
由于 Google Apps Script 强行将“Rhino”推送到“V8”引擎,应用程序正在自动从 Rhino 迁移到 V8。所以我们的应用程序正在询问需要在“ appscript.json ”文件中手动指定的“范围”。
请检查下图:
文件 :-
当我像下面这样更新时,它工作正常。
我们担心的是我们有超过 100 个生产应用程序,我们不能每次都手动更新。你能帮助我们如何在生产中没有任何问题的更新吗?
解决方案
Using clasp
You can update the manifest files in batch by using the CLASP project (it uses Apps Script API under the hood) and a utility script in Node.js or your poison of choice to control the workflow. General steps you need to take are:
- Clone a project with
clasp clone "YourScriptIdHere"
- Update the
appsscript.json
file with the required scopes. Since manifest is saved at the root of the project, I would do something like this (with Node.js):
const { writeFile } = require("fs").promises;
const addScope = async (scopes) => {
const pathToManifest = "appscript.json";
const manifest = require(pathToManifest);
const { oauthScopes = [] } = manifest;
oauthScopes || ( manifest.oauthScopes = oauthScopes ); //guard against first scope
oauthScopes.push(...scopes);
await writeFile(pathToManifest, JSON.stringify(manifest));
}
- Push the updates to the project with
clasp push
. Since you are changing the manifest, use the--force
option or you will have to approve each upload. Note that as of 2020, the project does not yet support partial updates, so all files will be replaced. Use.claspignore
file to ensure you do not accidentally push the wholenode_modules
folder or similar.
- Redeploy the projects with
clasp deploy
. The command is customizable, so do not worry about having multiple deployments.
推荐阅读
- c - 如何使用 C 在 windows 中的创建进程函数中更改环境变量?
- tensorflow - 计算张量流中所有梯度的总和
- swift - 可解码强制超级开放类实现初始化器
- python - 安装后pip安装方法不起作用
- r - R Markdown没有显示其他引擎的执行按钮
- c++ - C++ 我的文件在我尝试将它们移动到源文件之前一直在工作,现在没有错误,也没有显示任何内容
- r - 忽略 d(b)plyr 动词中的大小写
- rest - 控制器以 415 响应对 application/json 以外的任何 MIME 类型进行响应
- php - Jquery Ajax日历每隔一个月跳过一次
- django - 如果已登录则重定向