Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: mv dist/ and testTmp/ to .scaffold/, cache test lib, drop config.test.port #71

Merged
merged 4 commits into from
Dec 18, 2024

Conversation

northword
Copy link
Owner

@northword northword commented Dec 15, 2024

ref: #66

Tasks

  • Mocha Framework on the User Side
  • Test Cases May Not Need Compilation into a Single File
  • Rerunning Tests After Source/Test Code Reload

Changes

  1. move temporary test plugins, temporary profiles, etc. out of dist and place them under .scaffold for now.
  2. mocha prioritizes the version installed on the user's side, and gives a prompt to download it if it is not available. 3. chai's installation from npm does not seem to work for Zotero.
  3. chai installed from npm doesn't seem to work for Zotero, it still uses the downloaded one. It seems to be related to ESM, Documentation about loading chai in browser is wrong chaijs/chai#1624 , consuming chai as ES6 module in browser chaijs/chai#1391
  4. the built unit test file is put into the plugin directory content/units, and introduced in index.xhtml in order.
  5. The port of HTTP Server does not need to be provided by the user, so we can find the free TCP port directly.

Breaking Changes

  1. Default value of config.dist changed from build to .scaffold/build.

@northword northword marked this pull request as draft December 15, 2024 16:46
@windingwind
Copy link
Collaborator

将临时插件、临时 profile 等文件从 dist 移出,当前放置在 node_modules/.scaffold 下,有无必要放在项目根目录而非 node_modules 中?

这个的目的是啥,有点不太了解。因为报错信息会来自编译后的测试文件,有时候会需要翻编译后的源码来对照,放得太深可能不是很方便,node_modules下面东西太多了。另外node_modules/.scaffold也许会和其他什么东西冲突,scaffold这个名字太通用了

chai 从 npm 安装的似乎无法用于 Zotero,仍使用下载的。似乎与 ESM 有关

是的

其他感觉挺好

@northword
Copy link
Owner Author

这个的目的是啥,有点不太了解。因为报错信息会来自编译后的测试文件,有时候会需要翻编译后的源码来对照,放得太深可能不是很方便,node_modules下面东西太多了。另外node_modules/.scaffold也许会和其他什么东西冲突,scaffold这个名字太通用了

为了后面做reload。
插件完整编译的时候会清空 build 文件夹,所以 test 相关的东西放在 build 里也会被清空。

那要不项目根目录建一个 .scaffold ?
然后把build(breaking change)、profile、test-plugin、log之类的都都进去。

@windingwind
Copy link
Collaborator

这个的目的是啥,有点不太了解。因为报错信息会来自编译后的测试文件,有时候会需要翻编译后的源码来对照,放得太深可能不是很方便,node_modules下面东西太多了。另外node_modules/.scaffold也许会和其他什么东西冲突,scaffold这个名字太通用了

为了后面做reload。 插件完整编译的时候会清空 build 文件夹,所以 test 相关的东西放在 build 里也会被清空。

那要不项目根目录建一个 .scaffold ? 然后把build(breaking change)、profile、test-plugin、log之类的都都进去。

感觉可以,不过build仍然可以单独有一个设置项,可以允许和其他的分开,这样不会影响现有的项目

@northword
Copy link
Owner Author

不过build仍然可以单独有一个设置项,可以允许和其他的分开,这样不会影响现有的项目

是的,config.dist 这个配置仍然保留,只是默认值从 build 修改为 .scaffold/build,如果用户使用 scaffold 提供的 serve、build、release 流程,应该不会有任何影响。

如果用户自行实现发布流程,需要修改 xpi/updatejson的路径。

@northword northword changed the title fix: move testPluginDir out build, use user's mocha.js, cache chai.js fix!: move testPluginDir out build, use user's mocha.js, cache chai.js Dec 16, 2024
@northword northword changed the title fix!: move testPluginDir out build, use user's mocha.js, cache chai.js fix!: mv dist/ and testTmp/ to .scaffold/, cache test lib, drop config.test.port Dec 16, 2024
@northword
Copy link
Owner Author

northword commented Dec 16, 2024

把 test 产生的各种文件都移到了 .scaffold/ 中,build 目录也被默认修改到了 .scaffold。目前的目录为:

PixPin_2024-12-16_19-13-05

后面可以考虑把 Zotero 的 stdout/stderr 也写到 .scaffold/logs/{runTime.log} 里。

由于目前所有用 Scaffold 的都是从模板生成的,模板里面默认设置了 config.dist=build ,所以这次修改理论上不会影响任何用户。

如果用户要手动修改为默认值,那可能需要把 esbuild 的 output 里也要对应修改一下。

Tester 的 --watch and reload 计划之后再做,不在这个 PR 的范围里了,想看看能怎么更好地把 serve 里的代码复用起来。

如果这个 PR 的修改没有其他问题我们就合并?

@northword northword marked this pull request as ready for review December 16, 2024 11:06
@northword northword merged commit 54ad99e into main Dec 18, 2024
1 check passed
@northword northword deleted the refactor-test branch December 18, 2024 01:16
northword added a commit that referenced this pull request Dec 28, 2024
… config.test.port (#71)

* fix: move testPluginDir out build, use user's mocha.js, cache chai.js

* fix!: mv paths of `dist` and `test` to `.scaffold`, ensure gitignore

* chore: clean code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants