Skip to content

Commit f328606

Browse files
authored
add version bump script (#10)
1 parent 4f502e9 commit f328606

File tree

6 files changed

+24
-4
lines changed

6 files changed

+24
-4
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"root": true,
33
"parser": "@typescript-eslint/parser",
4+
"env": { "node": true },
45
"plugins": [
56
"@typescript-eslint"
67
],

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tag-version-prefix=""

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Quick starting guide for new plugin devs:
3636
- Upload the files `manifest.json`, `main.js`, `styles.css` as binary attachments. Note: The manifest.json file must be in two places, first the root path of your repository and also in the release.
3737
- Publish the release.
3838

39+
> You can simplify the version bump process by running `npm version patch`, `npm version minor` or `npm version major` after updating `minAppVersion` manually in `manifest.json`.
40+
> The command will bump version in `manifest.json` and `package.json`, and add the entry for the new version to `versions.json`
41+
3942
### Adding your plugin to the community plugin list
4043

4144
- Check https://github.com/obsidianmd/obsidian-releases/blob/master/plugin-review.md

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "obsidian-sample-plugin",
3-
"version": "0.12.0",
3+
"version": "1.0.1",
44
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {
77
"dev": "node esbuild.config.mjs",
8-
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production"
8+
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
9+
"version": "node version-bump.mjs && git add manifest.json versions.json"
910
},
1011
"keywords": [],
1112
"author": "",

version-bump.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { readFileSync, writeFileSync } from "fs";
2+
3+
const targetVersion = process.env.npm_package_version;
4+
5+
// read minAppVersion from manifest.json and bump version to target version
6+
let manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
7+
const { minAppVersion } = manifest;
8+
manifest.version = targetVersion;
9+
writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
10+
11+
// update versions.json with target version and minAppVersion from manifest.json
12+
let versions = JSON.parse(readFileSync("versions.json", "utf8"));
13+
versions[targetVersion] = minAppVersion;
14+
writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));

versions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"1.0.1": "0.9.12",
3-
"1.0.0": "0.9.7"
2+
"1.0.0": "0.9.7",
3+
"1.0.1": "0.12.0"
44
}

0 commit comments

Comments
 (0)