diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e5ec5f6 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: [hananoshikayomaru] +custom: https://www.buymeacoffee.com/yomaru diff --git a/README.md b/README.md index 6e55bcd..3a0947f 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ for example, the following frontmatter template ```ts { - folder: file.parent.path; - title: file.basename; - test: ["1", "2"]; + folder: file.parent.path; + title: file.basename; + test: ["1", "2"]; } ``` @@ -29,7 +29,7 @@ test: - "2" ``` -Demo: https://youtu.be/Cz9d5e1WQVM +Demo: ## Advanced usage @@ -37,20 +37,20 @@ Demo: https://youtu.be/Cz9d5e1WQVM ```ts file.properties?.type === "kanban" - ? { - folder: file.parent.path, - title: file.basename, - } - : {}; + ? { + folder: file.parent.path, + title: file.basename, + } + : {}; ``` ### function ```ts { - test: (() => { - return { test: "test" }; - })(); + test: (() => { + return { test: "test" }; + })(); } ``` @@ -58,7 +58,7 @@ file.properties?.type === "kanban" ```ts { - numberOfPages: dv.pages("#ai").length; + numberOfPages: dv.pages("#ai").length; } ``` @@ -70,21 +70,17 @@ It could be a json or a javascript expression that return an object. ^ even functions work -![](https://share.cleanshot.com/2bH8BXRg+) - -^ async function doesn't work - ## Variable that it can access -- `file`, the [`TFile`](https://docs.obsidian.md/Reference/TypeScript+API/TFile/TFile) object -- `file.properties` will access the yaml object of the current file -- `dv`, the [dataview](https://blacksmithgu.github.io/obsidian-dataview/) object (you can only access this if you install and enable the dataview plugin) +- `file`, the [`TFile`](https://docs.obsidian.md/Reference/TypeScript+API/TFile/TFile) object +- `file.properties` will access the yaml object of the current file +- `dv`, the [dataview](https://blacksmithgu.github.io/obsidian-dataview/) object (you can only access this if you install and enable the dataview plugin) ## Installation ### Install on obsidian plugin marketplace -⏳ Still waiting for review and approval: https://github.com/obsidianmd/obsidian-releases/pull/2502 +⏳ Still waiting for review and approval: ### Manual Install diff --git a/bun.lockb b/bun.lockb index 29a40b0..9ef9e76 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/manifest.json b/manifest.json index acd3b91..77b9150 100644 --- a/manifest.json +++ b/manifest.json @@ -1,11 +1,11 @@ { "id": "frontmatter-generator", "name": "Frontmatter generator", - "version": "1.0.4", + "version": "1.0.5", "minAppVersion": "0.15.0", "description": "Generate frontmatter for your notes from json and javascript", "author": "Hananoshika Yomaru", "authorUrl": "https://yomaru.dev", "fundingUrl": "https://www.buymeacoffee.com/yomaru", "isDesktopOnly": false -} +} \ No newline at end of file diff --git a/package.json b/package.json index b00acdb..03cd438 100644 --- a/package.json +++ b/package.json @@ -1,55 +1,58 @@ { - "name": "obsidian-frontmatter-generator", - "version": "1.0.5", - "description": "A plugin for Obsidian that generates frontmatter for notes.", - "main": "main.js", - "scripts": { - "dev": "bun esbuild.config.mjs", - "build": "bun esbuild.config.mjs production", - "version": "bun version-bump.mjs && git add manifest.json versions.json", - "prepare": "husky install" - }, - "keywords": [ - "obsidian", - "plugin", - "frontmatter", - "generator", - "yaml", - "dataview" - ], - "author": "Hananoshika Yomaru", - "license": "MIT", - "devDependencies": { - "@types/diff-match-patch": "^1.0.34", - "@types/js-yaml": "^4.0.6", - "@types/node": "^16.11.6", - "@typescript-eslint/eslint-plugin": "5.29.0", - "@typescript-eslint/parser": "5.29.0", - "builtin-modules": "3.3.0", - "bun-types": "^1.0.3", - "esbuild": "0.17.3", - "husky": "^8.0.3", - "obsidian": "latest", - "tslib": "2.4.0", - "typescript": "^5.0.5" - }, - "dependencies": { - "@total-typescript/ts-reset": "^0.5.1", - "diff-match-patch": "^1.0.5", - "js-yaml": "^4.1.0", - "mdast-util-from-markdown": "^1.2.0", - "mdast-util-gfm-footnote": "^1.0.1", - "mdast-util-gfm-task-list-item": "^1.0.1", - "mdast-util-math": "^2.0.1", - "micromark-extension-gfm-footnote": "^1.0.4", - "micromark-extension-gfm-task-list-item": "^1.0.3", - "micromark-extension-math": "^2.0.2", - "micromark-util-combine-extensions": "^1.0.0", - "obsidian-dataview": "^0.5.59", - "quick-lru": "^6.1.1", - "ts-dedent": "^2.2.0", - "ts-pattern": "^5.0.5", - "unist-util-visit": "^4.1.2", - "zod": "^3.22.2" - } + "name": "obsidian-frontmatter-generator", + "version": "1.0.6", + "description": "A plugin for Obsidian that generates frontmatter for notes.", + "main": "main.js", + "scripts": { + "dev": "bun esbuild.config.mjs", + "build": "bun esbuild.config.mjs production", + "version": "bun version-bump.mjs && git add manifest.json versions.json", + "prepare": "husky install", + "release": "bash release.sh", + "typecheck": "tsc -noEmit -skipLibCheck", + "lint": "eslint . --ext .ts --fix" + }, + "keywords": [ + "obsidian", + "plugin", + "frontmatter", + "generator", + "yaml", + "dataview" + ], + "author": "Hananoshika Yomaru", + "license": "MIT", + "devDependencies": { + "@types/diff-match-patch": "^1.0.34", + "@types/js-yaml": "^4.0.6", + "@types/node": "^16.11.6", + "@typescript-eslint/eslint-plugin": "5.29.0", + "@typescript-eslint/parser": "5.29.0", + "builtin-modules": "3.3.0", + "bun-types": "^1.0.3", + "esbuild": "0.17.3", + "husky": "^8.0.3", + "obsidian": "latest", + "tslib": "2.4.0", + "typescript": "^5.0.5" + }, + "dependencies": { + "@total-typescript/ts-reset": "^0.5.1", + "diff-match-patch": "^1.0.5", + "js-yaml": "^4.1.0", + "mdast-util-from-markdown": "^1.2.0", + "mdast-util-gfm-footnote": "^1.0.1", + "mdast-util-gfm-task-list-item": "^1.0.1", + "mdast-util-math": "^2.0.1", + "micromark-extension-gfm-footnote": "^1.0.4", + "micromark-extension-gfm-task-list-item": "^1.0.3", + "micromark-extension-math": "^2.0.2", + "micromark-util-combine-extensions": "^1.0.0", + "obsidian-dataview": "^0.5.61", + "quick-lru": "^6.1.1", + "ts-dedent": "^2.2.0", + "ts-pattern": "^5.0.5", + "unist-util-visit": "^4.1.2", + "zod": "^3.22.2" + } } diff --git a/release.sh b/release.sh new file mode 100644 index 0000000..b1f6782 --- /dev/null +++ b/release.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# Set the default update type +UPDATE_TYPE="patch" + +# Parse command-line arguments +while [[ $# -gt 0 ]]; do + key="$1" + case $key in + -m | --minor) + UPDATE_TYPE="minor" + shift + ;; + -M | --major) + UPDATE_TYPE="major" + shift + ;; + *) + echo "Unknown option: $key" + exit 1 + ;; + esac +done + +# Get the version number from manifest.json +MANIFEST_VERSION=$(jq -r '.version' manifest.json) + +# Get the version number from package.json +PACKAGE_VERSION=$(node -p -e "require('./package.json').version") + +# Ensure the version from package.json matches the version in manifest.json +if [ "$PACKAGE_VERSION" != "$MANIFEST_VERSION" ]; then + echo "Version mismatch between package.json and manifest.json" + exit 1 +fi + +# Increment the version based on the specified update type +if [ "$UPDATE_TYPE" = "minor" ]; then + NEW_VERSION=$(semver $PACKAGE_VERSION -i minor) +elif [ "$UPDATE_TYPE" = "major" ]; then + NEW_VERSION=$(semver $PACKAGE_VERSION -i major) +else + NEW_VERSION=$(semver $PACKAGE_VERSION -i patch) +fi + +echo "Current version: $PACKAGE_VERSION" +echo "New version: $NEW_VERSION" + +# Update the version in package.json +jq --arg version "$NEW_VERSION" '.version = $version' package.json >tmp.json && mv tmp.json package.json +echo "Changed package.json version to $NEW_VERSION" + +# Print the updated version of manifest.json using 'bun' +bun run version +echo "Updated version of manifest using bun. The current version of manifest.json is $(jq -r '.version' manifest.json)" + +# Create a git commit and tag +git add . && git commit -m "release: $NEW_VERSION" +git tag -a "$NEW_VERSION" -m "release: $NEW_VERSION" +echo "Created tag $NEW_VERSION" + +# Push the commit and tag to the remote repository +git push origin "$NEW_VERSION" +echo "Pushed tag $NEW_VERSION to the origin branch $NEW_VERSION" +git push +echo "Pushed to the origin master branch" diff --git a/versions.json b/versions.json index 1d7eb49..22b4387 100644 --- a/versions.json +++ b/versions.json @@ -3,5 +3,6 @@ "1.0.1": "0.15.0", "1.0.2": "0.15.0", "1.0.3": "0.15.0", - "1.0.4": "0.15.0" + "1.0.4": "0.15.0", + "1.0.5": "0.15.0" } \ No newline at end of file