retorquere / generator-zotero-plugin

Generate zotero plugin build scaffolding
MIT License
30 stars 7 forks source link

problem building bootstrap.js? #35

Closed vancleve closed 1 year ago

vancleve commented 1 year ago

I'm trying to building a new plugin using the generator and the make-it-red template and with no changes to the template, it doesn't seem to be building the bootstrap.js file correctly.

I follow the instructions to

[zotero] path = /Applications/Zotero7.app/Contents/MacOS/zotero

[plugin] source = build

- run `npm run build`

After doing so, the contents of `build/bootstrap.js` are:

var Zotero;

var { } = (() => { })();


And the plugin doesn't work when running `npm start` (after adding "start": "zotero-start" to `package.json` and shows the follow debug info at the terminal related to the plugin:
<img width="678" alt="image" src="https://github.com/retorquere/generator-zotero-plugin/assets/1442334/d72f7bca-2d0b-4627-9d8e-f74d010e5908">
retorquere commented 1 year ago

Thanks for reporting, I'll fix the templates, but for now just make the following changes to bootstrap.js: for each of the lines

async function install() {
async function startup({ id, version, resourceURI, rootURI = resourceURI.spec }) {
function shutdown() {
function uninstall() {

add export in front of it.

retorquere commented 1 year ago

New version is out, but it will just do what I described in the previous comment.

vancleve commented 1 year ago

Great, thank you so much for the rapid response!!!

I installed the new generator-zotero-pluging but this error below from the linter:

image

Is this normal for make-it-red template?

Also, I'm very new to javascript, typescript and npm, so I'll try ask a minimum of very basic questions, but I wanted to pose one regarding the zotero-plugin build system vis-a-via what I see in the make-it-red template. Should I expect to see the contents of the make-it-red bootstrap.js in the build/bootstrap.js after running npm run build?

thanks again!

retorquere commented 1 year ago

Is this normal for make-it-red template?

It shouldn't be normal, I think. I tried to make minimal changes to the MiR template, but having it error out is perhaps too pedantic. A new version is up, but I can also just explain what changes I made if you want to keep what you have.

I'm still working to add the src-1.0 template, which I've just found out is a better base than the src-1.1 template. Disappointing, but it is what it is.

Also, I'm very new to javascript, typescript and npm, so I'll try ask a minimum of very basic questions

Don't worry about it, ask away.

I wanted to pose one regarding the zotero-plugin build system vis-a-via what I see in the make-it-red template. Should I expect to see the contents of the make-it-red bootstrap.js in the build/bootstrap.js after running npm run build?

Sort of. It should be recognizable but not exactly the same; it should have the exact same result when ran. But you should really only look at the generated javascript when debugging. For authoring, the typescript sources are what you'd be working with.

I realize this is a heavily opinionated choice, but I much prefer typescript over javascript, it has saved me from so much problems, and I do use the generator myself to bootstrap (ha!) new plugins.

You can use the make-it-red template from Zotero as-is together with the zotero-plugin package. You don't need to use typescript if it's not a good match for how you work.

vancleve commented 1 year ago

Ah ok, got it I think :-). I'm happy to go with typescript and the development tools that comes with it. Thanks again!

vancleve commented 1 year ago

Ok, great, got the make-it-red working! Onto learning more about zotero and typescript and plugins!