From 347c720145525d6cda98af404cf1977efec52984 Mon Sep 17 00:00:00 2001 From: PtiCalin <143633151+PtiCalin@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:59:57 -0400 Subject: [PATCH] chore: adopt official obsidian plugin structure --- .github/ISSUE_TEMPLATE/bug_report.md | 21 ++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 14 +++++ .github/workflows/build.yml | 22 ++++++++ README.md | 11 ++-- dist/.gitkeep | 0 manifest.json | 10 ++++ package.json | 21 ++++++++ rollup.config.js | 22 ++++++++ src/main.ts | 63 +++++++++++++++++++++++ styles.css | 1 + tsconfig.json | 15 ++++++ 11 files changed, 196 insertions(+), 4 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/workflows/build.yml create mode 100644 dist/.gitkeep create mode 100644 manifest.json create mode 100644 package.json create mode 100644 rollup.config.js create mode 100644 src/main.ts create mode 100644 styles.css create mode 100644 tsconfig.json diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..788b3de --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,21 @@ +--- +name: Bug report +about: Create a report to help us improve the plugin +labels: bug +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Environment** + - OS: [e.g. Windows 11] + - Obsidian version: [e.g. 1.5.3] diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..5507def --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,14 @@ +--- +name: Feature request +about: Suggest an idea for this plugin +labels: enhancement +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4bce587 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,22 @@ +name: Build plugin + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - run: npm install + - run: npm run build + - uses: actions/upload-artifact@v3 + with: + name: dist + path: dist diff --git a/README.md b/README.md index 1a13bd0..866859f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This repo is crafted for structured development, modular scaling, and joyful col ## 🧰 Features - 🧠 Obsidian plugin scaffold in TypeScript -- ⚙️ VaultOS-ready modular structure (`src/`, `ops/`, `config/`, `dist/`) +- ✅ Follows the official Obsidian plugin folder structure (`src/`, `dist/`) - 📦 Rollup build system with `manifest.json` - 📁 Ready-to-use GitHub Actions and PR templates - 💬 Discussions and sponsor links for community-driven growth @@ -48,9 +48,12 @@ After building, copy the contents of `/dist` into your Obsidian vault’s `.obsi ```plaintext src/ → TypeScript plugin source dist/ → Compiled output used by Obsidian -ops/ → Plugin orchestration logic -config/ → Static metadata and module configs -.github/ → GitHub Actions, PR/issue templates +.github/ → Community files (issues, PR templates, CI) +manifest.json → Plugin manifest +package.json → Build and dependency config +rollup.config.js → Bundler setup +tsconfig.json → TypeScript options +styles.css → Optional styling ``` --- diff --git a/dist/.gitkeep b/dist/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..bacbe07 --- /dev/null +++ b/manifest.json @@ -0,0 +1,10 @@ +{ + "id": "temp-repo-obsidian-plugin", + "name": "Temp Repo Obsidian Plugin", + "version": "0.0.1", + "minAppVersion": "0.15.0", + "description": "Example plugin scaffold", + "author": "PtiCalin", + "authorUrl": "https://github.com/PtiCalin", + "isDesktopOnly": false +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..b427eff --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "temp_repo-obsidian-plugin", + "version": "0.0.1", + "description": "Obsidian plugin example", + "main": "dist/main.js", + "scripts": { + "dev": "rollup -c -w", + "build": "rollup -c" + }, + "devDependencies": { + "@rollup/plugin-commonjs": "^24.1.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-typescript": "^11.1.2", + "rollup": "^3.29.0", + "rollup-plugin-css-only": "^4.3.0", + "rollup-plugin-terser": "^7.0.2", + "typescript": "^5.0.4", + "obsidian": "1.5.3" + }, + "license": "MIT" +} diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..08bf5a0 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,22 @@ +import typescript from '@rollup/plugin-typescript'; +import { nodeResolve } from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; +import css from 'rollup-plugin-css-only'; +import { terser } from 'rollup-plugin-terser'; + +export default { + input: 'src/main.ts', + output: { + dir: 'dist', + sourcemap: false, + format: 'cjs' + }, + external: ['obsidian'], + plugins: [ + typescript(), + nodeResolve({ browser: true }), + commonjs(), + css({ output: 'styles.css' }), + terser() + ] +}; diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..1278f7b --- /dev/null +++ b/src/main.ts @@ -0,0 +1,63 @@ +import { App, Plugin, PluginSettingTab, Setting, Notice } from 'obsidian'; + +interface SamplePluginSettings { +mySetting: string; +} + +const DEFAULT_SETTINGS: SamplePluginSettings = { +mySetting: 'default' +}; + +export default class SamplePlugin extends Plugin { +settings: SamplePluginSettings; + +async onload() { +console.log('Loading plugin ' + this.manifest.id); +await this.loadSettings(); + +this.addCommand({ +id: 'sample-command', +name: 'Sample Command', +callback: () => new Notice('Sample command triggered'), +}); + +this.addSettingTab(new SampleSettingTab(this.app, this)); +} + +onunload() { +console.log('Unloading plugin ' + this.manifest.id); +} + +async loadSettings() { +this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); +} + +async saveSettings() { +await this.saveData(this.settings); +} +} + +class SampleSettingTab extends PluginSettingTab { +plugin: SamplePlugin; + +constructor(app: App, plugin: SamplePlugin) { +super(app, plugin); +this.plugin = plugin; +} + +display(): void { +const { containerEl } = this; +containerEl.empty(); + +new Setting(containerEl) +.setName('Sample Setting') +.setDesc('A simple example setting') +.addText(text => text +.setPlaceholder('Enter value') +.setValue(this.plugin.settings.mySetting) +.onChange(async (value) => { +this.plugin.settings.mySetting = value; +await this.plugin.saveSettings(); +})); +} +} diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..f8fa9c2 --- /dev/null +++ b/styles.css @@ -0,0 +1 @@ +/* Sample plugin styles */ diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..25c3822 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "ESNext", + "lib": ["ES2020", "DOM"], + "rootDir": "src", + "outDir": "dist", + "strict": true, + "moduleResolution": "node", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true + }, + "include": ["src"] +}