1.9.1 • Published 9 months ago

@lisandra-dev/create-obsidian-plugin v1.9.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

create-obsidian-plugin

A tool to easily create plugins for obsidian

Getting started

Run one of the following command, depending of your favorite package manager:

  • npm init @lisandra-dev/obsidian-plugin or npx @lisandra-dev/create-obsidian-plugin
  • yarn create @lisandra-dev/obsidian-plugin
  • pnpm create @lisandra-dev/obsidian-plugin

Info
In Yaml V2+, you can't use automatically the post and pre scripts and must be manually used, as npm run bump && npm run postbump. See here for more information. As the package detect your package manager, the package.json will use another scripts for Yarn.

And a plugin will be created in your current directory. It'll prompt you for needed info (like plugin-id, name, etc).

You can optionally pass a plugin-id to the command like

yarn create obsidian-plugin my-plugin

In this case a plugin with the id my-plugin will be created in the current directory. Afterwards, follow the directions from the plugin to get started

Scripts

Prepend the following command with your package manager (npm, yarn, pnpm, etc…).

  1. Build : build
  2. Build and watch : dev
  3. Export to your vault : export - You must set the path to your vault in the .env file. The plugin will be build and exported to your vault.
  4. Bump version with pushing to repository
    • In npm or pnpm : bump
    • In yarn : push
  5. Bump version (w/o push)
    • In npm or pnpm : bump --ignore-scripts
    • In yarn : bump
  6. Upgrade - Update the version number, and export to your main repository : upgrade

Fork difference

The fork separates the settings, interfaces and the main.ts. It also adds :

  • i18next for translation
  • commit-and-tag-version to automatically commit and tag the version based on the commit message (it must respect the conventional commit format)
  • A GitHub workflows to automatically build and publish the plugin when a new tag is added.
  • A JavaScript that allows you to export the built plugin to your obsidian Vault. To do that you must add the path to your Vault (root) in the .env file.
  • A better dev workflow using .env file and dev.js file.

Moreover, the creating adds:

  • Funding information in the manifest (cf funding)
  • Desktop only question
  • Initialize a git repository
  • If you have GitHub CLI installed, you can also choose to create a new repository on GitHub. Obviously, you need to init a git repository before. The created repository will be public by default and use the same name as the plugin id.

i18next : Translation support

This fork adds support for i18next for Obsidian, allowing translation of your plugin in different languages. If you need to add translation, just create a new lang.json in i18n/locales and update i18n/i18nex.ts to add the new language, as follows :

import { moment } from "obsidian";
import * as en from "./locales/en.json";
import * as fr from "./locales/fr.json";
import * as newLang from "./locales/newLang.json";

export const resources = {
	en: { translation: en },
	fr: { translation: fr },
	newLang: { translation: newLang },
} as const;

export const translationLanguage = Object.keys(resources).find(
	i => i == moment.locale()) ? moment.locale() : "en";

Useful environments variables :

If you want to quickly create a plugin without rewrite each time the same information, you can set environment variable with the following name:

  • obsidian_plugin_author_name : Your author name
  • obsidian_plugin_author_url : Your author url (website, social media account, etc…)
  • obsidian_plugin_vault_path : The path to your obsidian vault (root)
  • obsidian_plugin_dev_vault : The path to your obsidian vault (root) for development
  • obsidian_plugin_funding_url : Link to your funding page (Patreon, Paypal, Kofi, etc…)
  • obsidian_plugin_license : Your favorite license by their identifier (MIT, Apache-2.0, etc…). See here for the complete list of identifier.
1.9.1

9 months ago

1.9.0

9 months ago

1.8.1

9 months ago

1.8.0

11 months ago

1.7.1

11 months ago

1.7.0

12 months ago

1.6.4

12 months ago

1.6.3

12 months ago

1.6.2

12 months ago

1.6.1

12 months ago

1.6.0

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.3.3

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago