Vending Machine Kata implemented as an Obsidian.md plugin.
The Vending Machine Kata is described here:
The instructions used in this implementation are in the file INSTRUCTIONS.md.
- Clone this repo to a local development folder. For convenience, you can place or symlink this folder in
VaultFolder/.obsidian/plugins/obsidian-vending-machine
. - Install NodeJS, then run
npm i
in the command line under your repo folder. - Run
npm run dev
to compile your plugin frommain.ts
tomain.js
. - Make changes to
main.ts
(or create new.ts
files). Those changes should be automatically compiled intomain.js
. - Reload Obsidian to load the new version of your plugin.
- Enable plugin in settings window.
- Clone this repo.
- Make sure your NodeJS is at least v16 (
node --version
). npm i
oryarn
to install dependencies.npm run dev
to start compilation in watch mode.
There is a setup for writing unit tests using Jest
. To run the test suite you can run
npm run test
or in watch mode
npm run test:watch
Due to the Obsidian source code not being open-source Jest's more common mocking patterns don't work, such as jest.mock('obsidian')
. Instead we use Jest's manual mocks by writing a partial mock module in __mocks__/obsidian.js
. Note that it does not contain a full mock of obsidian
and you might need to extend it to test your plugin. If you do, please consider adding your extension to this repo.
- Copy over
main.js
,styles.css
,manifest.json
to your vaultVaultFolder/.obsidian/plugins/obsidian-vending-machine
.
- ESLint is a tool that analyzes your code to quickly find problems. You can run ESLint against your plugin to find common bugs and ways to improve your code.
- To use eslint with this project, make sure to install eslint from terminal:
npm install -g eslint
- To use eslint to analyze this project use this command:
eslint main.ts
- eslint will then create a report with suggestions for code improvement by file and line number.
- If your source code is in a folder, such as
src
, you can use eslint with this command to analyze all files in that folder:eslint .\src\