mirror of
https://github.com/4source/open-editors-obsidian-plugin.git
synced 2026-07-22 05:32:44 +00:00
Initial commit
This commit is contained in:
commit
55530d4563
26 changed files with 6730 additions and 0 deletions
3
.eslintignore
Normal file
3
.eslintignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
node_modules/
|
||||
|
||||
main.js
|
||||
108
.eslintrc
Normal file
108
.eslintrc
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"@stylistic/eslint-plugin"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"@stylistic/indent": [
|
||||
"error",
|
||||
"tab"
|
||||
],
|
||||
"@stylistic/indent-binary-ops": [
|
||||
"error",
|
||||
"tab"
|
||||
],
|
||||
"@stylistic/quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"@stylistic/semi": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"@stylistic/brace-style": [
|
||||
"error",
|
||||
"stroustrup",
|
||||
{
|
||||
"allowSingleLine": true
|
||||
}
|
||||
],
|
||||
"@stylistic/comma-dangle": [
|
||||
"error",
|
||||
"always-multiline"
|
||||
],
|
||||
"@stylistic/dot-location": [
|
||||
"error",
|
||||
"property"
|
||||
],
|
||||
"@stylistic/function-call-argument-newline": [
|
||||
"error",
|
||||
"consistent"
|
||||
],
|
||||
"@stylistic/function-call-spacing": "error",
|
||||
"@stylistic/implicit-arrow-linebreak": "error",
|
||||
"@stylistic/key-spacing": "error",
|
||||
"@stylistic/lines-around-comment": "error",
|
||||
"@stylistic/new-parens": "error",
|
||||
"@stylistic/no-confusing-arrow": "error",
|
||||
"@stylistic/no-extra-semi": "error",
|
||||
"@stylistic/no-floating-decimal": "error",
|
||||
"@stylistic/no-mixed-operators": "error",
|
||||
"@stylistic/no-mixed-spaces-and-tabs": "error",
|
||||
"@stylistic/no-multi-spaces": "error",
|
||||
"@stylistic/no-multiple-empty-lines": [
|
||||
"error",
|
||||
{
|
||||
"max": 1,
|
||||
"maxEOF": 0,
|
||||
"maxBOF": 0
|
||||
}
|
||||
],
|
||||
"@stylistic/no-trailing-spaces": [
|
||||
"error",
|
||||
{
|
||||
"skipBlankLines": true
|
||||
}
|
||||
],
|
||||
"@stylistic/nonblock-statement-body-position": "error",
|
||||
"@stylistic/operator-linebreak": [
|
||||
"error",
|
||||
"after"
|
||||
],
|
||||
"@stylistic/padded-blocks": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"@stylistic/padding-line-between-statements": "error",
|
||||
"@stylistic/rest-spread-spacing": "error",
|
||||
"@stylistic/semi-spacing": "error",
|
||||
"@stylistic/semi-style": "error",
|
||||
"@stylistic/space-before-blocks": "error",
|
||||
"@stylistic/space-before-function-paren": "error",
|
||||
"@stylistic/arrow-spacing": "error",
|
||||
"@stylistic/space-in-parens": "error",
|
||||
"@stylistic/space-infix-ops": "error",
|
||||
"@stylistic/space-unary-ops": "error",
|
||||
"@stylistic/spaced-comment": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"@stylistic/switch-colon-spacing": "error",
|
||||
"@stylistic/template-curly-spacing": "error",
|
||||
"@stylistic/type-generic-spacing": "error",
|
||||
"@stylistic/type-named-tuple-spacing": "error"
|
||||
}
|
||||
}
|
||||
74
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
Normal file
74
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
name: Bug report
|
||||
description: Create a bug report to help us improve
|
||||
title: "[Bug]: "
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: textarea
|
||||
id: bug-description
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: A clear and concise description of what the bug is.
|
||||
placeholder: Tell us what happened that you didn't expect...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: bug-reproduce-steps
|
||||
attributes:
|
||||
label: How to Reproduce
|
||||
description: Steps to reproduce the behavior.
|
||||
placeholder: |
|
||||
1. In this environment...
|
||||
2. With this config...
|
||||
3. Run...
|
||||
4. See error...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: A clear and concise description of what you expected to happen.
|
||||
placeholder: Tell us what you think should have happened...
|
||||
validations:
|
||||
required: false
|
||||
- type: input
|
||||
id: operating-system
|
||||
attributes:
|
||||
label: OS of your device
|
||||
description: What operating system is your device runnging
|
||||
placeholder: e.g. Win10
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: obsidian-version
|
||||
attributes:
|
||||
label: Obsidian Version
|
||||
description: What version of obsidian are you running?
|
||||
placeholder: v1.5.0
|
||||
validations:
|
||||
required: true
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "This could be found in Settings>General>App>Current version"
|
||||
- type: input
|
||||
id: plugin-version
|
||||
attributes:
|
||||
label: Plugin Version
|
||||
description: What version of our plugin are you running?
|
||||
placeholder: "1.5.0"
|
||||
validations:
|
||||
required: true
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "This could be found in Settings>Community plugins>Installed plugins>SettingsProfiles>Version"
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context about the problem here. You can also add pictures or videos if it helps show the bug.
|
||||
placeholder: Explain any additional context...
|
||||
validations:
|
||||
required: false
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "Thanks for taking the time to fill out this bug report!"
|
||||
11
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
11
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Community Support
|
||||
url: https://github.com/4Source/obsidian-plugin-template/discussions/new/choose
|
||||
about: Please ask and answer questions here.
|
||||
- name: Documentation
|
||||
url: https://github.com/4Source/obsidian-plugin-template/wiki
|
||||
about: Check out the documentation if you want to know what's possible.
|
||||
- name: Contributing
|
||||
url: https://github.com/4Source/obsidian-plugin-template/blob/master/.github/CONTRIBUTING.md
|
||||
about: Overview of the contribution workflow
|
||||
35
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
Normal file
35
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
name: Feature request
|
||||
description: Suggest an idea for this project
|
||||
title: "[FEAT]: "
|
||||
labels: ["enhancement"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "### If your feature request is to resolve unexpected behavior, use *Bug Report* instead."
|
||||
- type: textarea
|
||||
id: related-problem
|
||||
attributes:
|
||||
label: Description of the unfavorable solution
|
||||
description: A clear and concise description of what you want to be different.
|
||||
placeholder: I'm always frustrated when ...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: feature
|
||||
attributes:
|
||||
label: Describe the feature you would like to have
|
||||
description: A clear and concise description of the function and its behavior. The more precisely you describe it, the easier it is to implement your idea.
|
||||
placeholder: Tell us what the feature will do...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context about the problem here. You can also add pictures or videos if it helps show the feature you like.
|
||||
placeholder: Explain any additional context...
|
||||
validations:
|
||||
required: false
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "Thanks for taking the time to fill out this feature request!"
|
||||
14
.github/pull_request_template.md
vendored
Normal file
14
.github/pull_request_template.md
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<!-- In the title above, provide a meaningful summary with [FIX] for bug fix and [FEAT] for new feature --->
|
||||
|
||||
## Describe your changes
|
||||
<!-- Describe your changes in detail --->
|
||||
|
||||
## Related Issues
|
||||
Fixes # <!-- Issue number --->
|
||||
|
||||
## Checklist before requesting a review
|
||||
- [ ] I have performed a self-review of my code
|
||||
- [ ] My code follows the style guidelines of this project
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] My code fixes the feature discussed in [Related Issues](#related-issues)
|
||||
71
.github/workflows/cd.yml
vendored
Normal file
71
.github/workflows/cd.yml
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
name: Continuous Deployment
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.pull_request.merged == true
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js 18.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.x
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Bump version
|
||||
id: version-bump
|
||||
uses: 4Source/version-control-action@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repository: ${{ github.event.repository.name }}
|
||||
pr_number: ${{ github.event.number }}
|
||||
tag_prefix: ''
|
||||
dry_run: true
|
||||
|
||||
- name: Configure git
|
||||
run: |
|
||||
git config --global user.name "4Source"
|
||||
git config --global user.email "38220764+4Source@users.noreply.github.com."
|
||||
|
||||
- name: Change version in files
|
||||
run: |
|
||||
npm run version -- --new_version=${{ steps.version-bump.outputs.new_version }}
|
||||
|
||||
- name: Commit and push changes
|
||||
run: |
|
||||
git commit -a -m "Apply version ${{ steps.version-bump.outputs.new_version }}"
|
||||
git push -f
|
||||
|
||||
- name: Push version tag
|
||||
run: |
|
||||
git tag -a ${{ steps.version-bump.outputs.new_version }} -m "${{ steps.version-bump.outputs.new_version }}"
|
||||
git push -f origin ${{ steps.version-bump.outputs.new_version }}
|
||||
|
||||
- name: Build plugin
|
||||
run: npm run build
|
||||
|
||||
- name: Create release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
gh release create "${{ steps.version-bump.outputs.new_version }}" \
|
||||
--title="${{ steps.version-bump.outputs.new_version }}" \
|
||||
--draft \
|
||||
main.js manifest.json styles.css
|
||||
97
.github/workflows/ci.yml
vendored
Normal file
97
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'src/**'
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'src/**'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||
|
||||
name: Run unit tests
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js "18.x"
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18.x"
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Run Tests
|
||||
run: npm run test
|
||||
|
||||
lint:
|
||||
name: Run linter
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js 18.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18.x"
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Run linter
|
||||
run: npm run lint
|
||||
|
||||
build:
|
||||
name: Build Plugin
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js 18.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "18.x"
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Run Build
|
||||
run: npm run build
|
||||
|
||||
version:
|
||||
name: Version Bump
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'pull_request'
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Bump version
|
||||
uses: 4Source/version-control-action@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repository: ${{ github.event.repository.name }}
|
||||
pr_number: ${{ github.event.number }}
|
||||
tag_prefix: ''
|
||||
dry_run: true
|
||||
77
.github/workflows/manual_release.yml
vendored
Normal file
77
.github/workflows/manual_release.yml
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
name: Manual Realease
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version_increase:
|
||||
description: 'Level of changes for new version'
|
||||
required: true
|
||||
default: 'patch'
|
||||
type: choice
|
||||
options:
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js 18.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.x
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Bump version
|
||||
id: version-bump
|
||||
uses: 4Source/version-control-action@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repository: ${{ github.event.repository.name }}
|
||||
version_increase: ${{ inputs.version_increase }}
|
||||
tag_prefix: ''
|
||||
dry_run: true
|
||||
|
||||
- name: Configure git
|
||||
run: |
|
||||
git config --global user.name "4Source"
|
||||
git config --global user.email "38220764+4Source@users.noreply.github.com."
|
||||
|
||||
- name: Change version in files
|
||||
run: |
|
||||
npm run version -- --new_version=${{ steps.version-bump.outputs.new_version }}
|
||||
git add manifest.json versions.json package.json
|
||||
|
||||
- name: Commit and push changes
|
||||
run: |
|
||||
git commit -a -m "Apply version ${{ steps.version-bump.outputs.new_version }}"
|
||||
git push -f
|
||||
|
||||
- name: Push version tag
|
||||
run: |
|
||||
git tag -a ${{ steps.version-bump.outputs.new_version }} -m "${{ steps.version-bump.outputs.new_version }}"
|
||||
git push -f origin ${{ steps.version-bump.outputs.new_version }}
|
||||
|
||||
- name: Build plugin
|
||||
run: npm run build
|
||||
|
||||
- name: Create release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
gh release create "${{ steps.version-bump.outputs.new_version }}" \
|
||||
--title="${{ steps.version-bump.outputs.new_version }}" \
|
||||
--draft \
|
||||
main.js manifest.json styles.css
|
||||
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# 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
|
||||
|
||||
# Jest Testing
|
||||
coverage
|
||||
1
.npmrc
Normal file
1
.npmrc
Normal file
|
|
@ -0,0 +1 @@
|
|||
tag-version-prefix=""
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2024 4Source
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
51
README.md
Normal file
51
README.md
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# This is a template repository
|
||||
This is a template repository for [Obsidian](https://obsidian.md) plugins.
|
||||
|
||||
# Features
|
||||
- Linting Setup
|
||||
- Testing Setup with Jest
|
||||
- Auto Version bump
|
||||
- Auto Version update
|
||||
|
||||
# Getting started
|
||||
- Clone this repo.
|
||||
- Make sure your NodeJS is at least v16 (node --version).
|
||||
- npm i or yarn to install dependencies.
|
||||
- npm run dev to start compilation in watch mode.
|
||||
|
||||
## Need to change
|
||||
### [package.json](https://github.com/4Source/obsidian-plugin-template/blob/caf33126008642a2be32e3696f1cba34b04657fd/package.json)
|
||||
- name
|
||||
- description
|
||||
- author
|
||||
- license (optional)
|
||||
### [manifest.json](https://github.com/4Source/obsidian-plugin-template/blob/caf33126008642a2be32e3696f1cba34b04657fd/manifest.json)
|
||||
- id
|
||||
- name
|
||||
- description
|
||||
- author
|
||||
- authorUrl
|
||||
- fundingUrl
|
||||
- minAppVersion (optional)
|
||||
- isDesktopOnly (optional)
|
||||
### [LICENSE](https://github.com/4Source/obsidian-plugin-template/blob/caf33126008642a2be32e3696f1cba34b04657fd/LICENSE) (optional)
|
||||
### [.github/workflows/cd.yml](https://github.com/4Source/obsidian-plugin-template/blob/caf33126008642a2be32e3696f1cba34b04657fd/.github/workflows/cd.yml)
|
||||
versioning > Configure git
|
||||
```
|
||||
git config --global user.name "YOUR-USER"
|
||||
git config --global user.email "YOUR-EMAIL"
|
||||
```
|
||||
## Need to add
|
||||
### New labels
|
||||
- ``major``
|
||||
- ``minor``
|
||||
- ``patch``
|
||||
|
||||
# Usage
|
||||
1. Create feature branch
|
||||
2. Make changes
|
||||
3. Push feature branch
|
||||
4. Create pull request
|
||||
5. Add desired [label](#new-labels) to pull request
|
||||
6. Merge pull request
|
||||
7. Publish draft release
|
||||
48
esbuild.config.mjs
Normal file
48
esbuild.config.mjs
Normal file
|
|
@ -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();
|
||||
}
|
||||
7
jest.config.js
Normal file
7
jest.config.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'jsdom',
|
||||
moduleNameMapper: {
|
||||
'src/(.*)': '<rootDir>/src/$1',
|
||||
},
|
||||
};
|
||||
11
manifest.json
Normal file
11
manifest.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"id": "obsidian-plugin-template",
|
||||
"name": "Obsidian plugin template",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "",
|
||||
"author": "4Source",
|
||||
"authorUrl": "https://github.com/4Source",
|
||||
"isDesktopOnly": false,
|
||||
"fundingUrl": "https://www.buymeacoffee.com/4Source",
|
||||
"version": "0.0.1"
|
||||
}
|
||||
5887
package-lock.json
generated
Normal file
5887
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
34
package.json
Normal file
34
package.json
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "obsidian-plugin-template",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "node esbuild.config.mjs",
|
||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||
"lint": "eslint .",
|
||||
"lint-fix": "eslint . --fix",
|
||||
"version": "node version-change.mjs",
|
||||
"test": "jest --silent"
|
||||
},
|
||||
"author": "4Source",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@stylistic/eslint-plugin": "^1.6.3",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20.10.7",
|
||||
"@types/obsidian-typings": "npm:obsidian-typings@^1.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
||||
"@typescript-eslint/parser": "^7.1.0",
|
||||
"builtin-modules": "3.3.0",
|
||||
"esbuild": "0.17.3",
|
||||
"eslint": "^8.57.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"obsidian": "latest",
|
||||
"semver": "^7.6.0",
|
||||
"ts-jest": "^29.1.2",
|
||||
"tslib": "2.4.0",
|
||||
"typescript": "4.7.4"
|
||||
},
|
||||
"version": "0.0.1"
|
||||
}
|
||||
26
src/main.ts
Normal file
26
src/main.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { Plugin } from 'obsidian';
|
||||
import { DEFAULT_SETTINGS, Settings } from './settings/SettingsInterface';
|
||||
import { MyPluginSettingTab } from './settings/SettingsTab';
|
||||
|
||||
export default class MyPlugin extends Plugin {
|
||||
settings: Settings;
|
||||
|
||||
async onload () {
|
||||
await this.loadSettings();
|
||||
|
||||
// This adds a settings tab so the user can configure various aspects of the plugin
|
||||
this.addSettingTab(new MyPluginSettingTab(this.app, this));
|
||||
}
|
||||
|
||||
onunload () {
|
||||
|
||||
}
|
||||
|
||||
async loadSettings () {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
}
|
||||
|
||||
async saveSettings () {
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
}
|
||||
7
src/settings/SettingsInterface.ts
Normal file
7
src/settings/SettingsInterface.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export interface Settings {
|
||||
mySetting: string;
|
||||
}
|
||||
|
||||
export const DEFAULT_SETTINGS: Settings = {
|
||||
mySetting: 'default',
|
||||
};
|
||||
31
src/settings/SettingsTab.ts
Normal file
31
src/settings/SettingsTab.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { App, PluginSettingTab, Setting } from 'obsidian';
|
||||
import MyPlugin from 'src/main';
|
||||
|
||||
export class MyPluginSettingTab extends PluginSettingTab {
|
||||
plugin: MyPlugin;
|
||||
|
||||
constructor (
|
||||
app: App,
|
||||
plugin: MyPlugin
|
||||
) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
display (): void {
|
||||
const { containerEl } = this;
|
||||
|
||||
containerEl.empty();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Setting #1')
|
||||
.setDesc('It\'s a secret')
|
||||
.addText(text => text
|
||||
.setPlaceholder('Enter your secret')
|
||||
.setValue(this.plugin.settings.mySetting)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.mySetting = value;
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
}
|
||||
}
|
||||
8
styles.css
Normal file
8
styles.css
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
|
||||
This CSS file will be included with your plugin, and
|
||||
available in the app when your plugin is enabled.
|
||||
|
||||
If your plugin does not need CSS, delete this file.
|
||||
|
||||
*/
|
||||
9
test/version.test.ts
Normal file
9
test/version.test.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { version as manifestVersion, minAppVersion as manifestMinAppVersion } from '../manifest.json';
|
||||
import { version as packageVersion } from '../package.json';
|
||||
import versions from '../versions.json';
|
||||
|
||||
test('Versions matching', () => {
|
||||
expect(manifestVersion).toBe(packageVersion);
|
||||
expect(Object.keys(versions).find(value => value === manifestVersion)).toBe(manifestVersion);
|
||||
expect(Object.entries(versions).find(value => value[0] === manifestVersion)?.[1]).toBe(manifestMinAppVersion);
|
||||
});
|
||||
26
tsconfig.json
Normal file
26
tsconfig.json
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"inlineSourceMap": true,
|
||||
"inlineSources": true,
|
||||
"module": "ESNext",
|
||||
"target": "ES6",
|
||||
"allowJs": true,
|
||||
"noImplicitAny": true,
|
||||
"moduleResolution": "node",
|
||||
"importHelpers": true,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"strictNullChecks": true,
|
||||
"lib": [
|
||||
"DOM",
|
||||
"ES5",
|
||||
"ES6",
|
||||
"ES7"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
]
|
||||
}
|
||||
45
version-change.mjs
Normal file
45
version-change.mjs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { readFileSync, writeFileSync } from "fs";
|
||||
import { valid } from "semver";
|
||||
|
||||
const newVersion = process.argv.find(value => value.startsWith('--new_version'));
|
||||
if (!newVersion) {
|
||||
throw Error('Param --new_version is missing!');
|
||||
}
|
||||
const targetVersion = newVersion.split('=')[1];
|
||||
if (!targetVersion) {
|
||||
throw Error('Param --new_version is empty!');
|
||||
}
|
||||
if (!valid(targetVersion)) {
|
||||
throw Error('New version is invalid!')
|
||||
}
|
||||
|
||||
// read minAppVersion from manifest.json
|
||||
let manifestFile = JSON.parse(readFileSync("manifest.json", "utf8"));
|
||||
const { minAppVersion } = manifestFile;
|
||||
if (!minAppVersion || minAppVersion === "") {
|
||||
throw Error('Missing minAppVersion in "manifest.json"');
|
||||
}
|
||||
|
||||
// update version to target version
|
||||
manifestFile.version = targetVersion;
|
||||
writeFileSync("manifest.json", JSON.stringify(manifestFile, null, "\t"));
|
||||
|
||||
// update version in package
|
||||
let packageFile = JSON.parse(readFileSync("package.json", "utf8"));
|
||||
packageFile.version = targetVersion;
|
||||
writeFileSync("package.json", JSON.stringify(packageFile, null, "\t"));
|
||||
|
||||
// read versions file
|
||||
let versionsFile = JSON.parse(readFileSync("versions.json", "utf8"));
|
||||
let keys = Object.keys(versionsFile);
|
||||
|
||||
// remove existing versions with same minAppVersion
|
||||
keys.forEach(key => {
|
||||
if (minAppVersion === versionsFile[key]) {
|
||||
delete versionsFile[key];
|
||||
}
|
||||
});
|
||||
|
||||
// update versions.json with target version and minAppVersion from manifest.json
|
||||
versionsFile[targetVersion] = minAppVersion;
|
||||
writeFileSync("versions.json", JSON.stringify(versionsFile, null, "\t"));
|
||||
3
versions.json
Normal file
3
versions.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"0.0.1": "0.15.0"
|
||||
}
|
||||
Loading…
Reference in a new issue