Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio authored Feb 11, 2024
0 parents commit 11c81dd
Show file tree
Hide file tree
Showing 19 changed files with 2,646 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
tab_width = 4
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/

main.js
25 changes: 25 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"env": { "node": true },
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-inferrable-types": ["error", { "ignoreParameters": true, "ignoreProperties": true }]
}
}
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
github: RyotaUshio
custom: ['https://www.buymeacoffee.com/ryotaushio']
ko_fi: ryotaushio
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Obsidian plugin

on:
push:
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"

- name: Build plugin
run: |
npm install
npm run build
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${GITHUB_REF#refs/tags/}"
gh release create "$tag" \
--title="$tag" \
--draft \
main.js manifest.json styles.css
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# vscode
.vscode

# Intellij
*.iml
.idea

# npm
node_modules

# Don't include the compiled main.js file in the repo.
# They should be uploaded to GitHub releases instead.
main.js

# Exclude sourcemaps
*.map

# obsidian
data.json

# Exclude macOS Finder (System Explorer) View States
.DS_Store
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tag-version-prefix=""
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Obsidian Sample Plugin

This is a modified version of https://github.com/obsidianmd/obsidian-sample-plugin.

## Differences from the original sample plugin

- `*.ts` files are put in the `src` directory
- The plugin class definition and settings-related code are separated into `main.ts` and `settings.ts`
- [Release GitHub action](https://docs.obsidian.md/Plugins/Releasing/Release+your+plugin+with+GitHub+Actions) is already there
- Don't forget to go to `Settings > Actions > General > Workflow permissions` and turn on `Read and write permissions`
- The default branch has been renamed `main`

## Usage

1. Create a new repository using this template ("Use this template" > "Create a new repository")
2. Clone the created repository
3. Modify at least the `id` & `name` fields in `manifest.json`.
4. Modify `package.json` accordingly.
5. Run `npm i` to install the dependencies
6. Run `npm run dev` or `npm run build` to compile your plugin

### Releasing your plugin

1. If you haven't, go to `Settings > Actions > General > Workflow permissions` and turn on `Read and write permissions`
2. Bump the version in `manifest.json` (and `package.json`) and then commit & push the change
3. `git tag -a <version> -m "<version>"`
4. `git push origin <version>`. This triggers the release action.
5. When the action is completed, go to the release page of your repository. You will find a newly created draft release.
6. Release the draft when you're ready.
48 changes: 48 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";

const banner =
`/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;

const prod = (process.argv[2] === "production");

const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ["src/main.ts"],
bundle: true,
external: [
"obsidian",
"electron",
"@codemirror/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins],
format: "cjs",
target: "es2018",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
});

if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}
15 changes: 15 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"id": "",
"name": "",
"version": "0.1.0",
"minAppVersion": "1.3.5",
"description": "",
"author": "Ryota Ushio",
"authorUrl": "https://github.com/RyotaUshio",
"fundingUrl": {
"GitHub Sponsor": "https://github.com/sponsors/RyotaUshio",
"Buy Me a Coffee": "https://www.buymeacoffee.com/ryotaushio",
"Ko-fi": "https://ko-fi.com/ryotaushio"
},
"isDesktopOnly": false
}
Loading

0 comments on commit 11c81dd

Please sign in to comment.