Generate an obsidian plugin project quickly

Even though the official maintains a plugin template so that developers can create a standard plugin project, we still need to go through the operation of pulling code and modifying package.json and manifest.json files.

Therefore I have developed a tool named obsidian-plugin-generator for the obsidian plugin project quickly generating.

I hope it helps~

3 Likes

This looks really interesting but I just keep getting this error…

Cloning into ‘test-opg’…
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I tried creating a new repo on Github first then running this but I just keep getting this error?

Is there something I’m missing?

This may be caused by SSH.

Could you clone the obsidian-sample-plugin from https://github.com/obsidianmd/obsidian-sample-plugin.git?

I added a new directive called --https/-H.

You can install v1.0.4 of obsidian-plugin-generator and try again through opg -Hi command.

Getting a different error now…

TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined

Strange thing is it does actually work now. The repo is successfully downloaded.

Oh, I see~

I used process.env.PWD as the first parameter of the path.resolve() method, and this value may be undefined(For example, under the windows system).

I have done compatibility processing, and when its value is undefined, process.pwd() will be taken as the first parameter.

(Version 1.0.5 has been released and bless no more bugs… :ghost:)

I got it working, you just need one small change in index.js.
The line…

await $"cd ${id} && rm -rf .git && git init"

Needs the double quotes I added above and no more errors!
Thanks, this is a nice tool to have.

Spoke to soon… While wrapping it in quotes gets rid of the errors, the commands are not actually executed. So the .git folder is not removed and reinitialized. Still playing with this but powershell can be a real pain sometimes. The main thing is the repo is successfully cloned. I can always just delete the .git folder manually.

Because “id” is a variable. If double quotes are used, then it becomes a string. So it will report an error.

Thank you for your patience and feedback~ :grinning:

Finally got it working in Powershell, this is the line I am using.

await $cd ${id}; rm -r -fo .git; git init

I used semi-colon to replace ‘&&’ and ‘rm -r -fo’ to replace ‘rm -rf’ (Powershell does not undestand the -rf switch)

This works really great! Thanks for providing this tool.