如何在Google App脚本中运行Google Docs插件?

时间:2020-08-26 18:08:27

标签: google-apps-script google-docs clasp

有一个很棒的Google文档插件Code Blocks,突出显示了代码块。不幸的是,尽管有隐私政策,但由于安全/隐私问题,我无法在公司的文档中使用它。相反,我想创建它并在我们自己的Google App脚本帐户中运行。我试图创建一个新项目,并将派生的代码推送到该项目中,但没有成功。用该代码实现可运行附件的分步说明是什么?

创建一个新的独立App Script项目,构建并将代码推送到其中会导致以下错误

  code: 400,
  errors:
   [ { message: 'A file with this name already exists in the current project: client/sidebar',
       domain: 'global',
       reason: 'badRequest' } ] }
└─ appsscript.json
└─ client/logo.svg.html
└─ client/sidebar.css.html
└─ client/sidebar.html
└─ client/sidebar.js
└─ dist/bundle.min.js.html
└─ dist/colors.js
└─ dist/constants.js
└─ dist/document.js
└─ dist/logo.svg.html
└─ dist/main.js
└─ dist/sidebar.css.html
└─ dist/sidebar.html
└─ dist/styles.html
└─ dist/util.js
└─ server/colors.js
└─ server/constants.js
└─ server/document.js
└─ server/main.js
└─ server/util.js
Pushed 20 files.

在App Script网页上打开这些文件时,在项目中找不到这些文件。它只有默认的Code.gs占位符文件。我什至不知道在哪里可以找到问题。

更新

在评论中感谢Oleg,添加了.claspignore,允许将其推送到Apps脚本,但在Google文档中运行测试会导致错误

Exception: No HTML file named sidebar was found

所有文件现在都位于dist/文件夹中,因此也许找不到它吗?我会错过一些配置以使其正确放置吗?

解决方案:

rootDir中将dist/设置为.clasp.json可解决此问题。

0 个答案:

没有答案