diff --git a/.gitignore b/.gitignore index 6b3f1b1..254cda8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ node_modules # VSCode .vscode +# Other TODO.md \ No newline at end of file diff --git a/esbuild.config.mjs b/esbuild.config.mjs index afc74df..71fe536 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -1,9 +1,10 @@ import esbuild from "esbuild"; import process from "process"; -import { readFileSync } from "fs"; +import { readFileSync, writeFileSync } from "fs"; const pkg = JSON.parse(readFileSync("./package.json", "utf8")); const banner = `/*! ${pkg.name} v${pkg.version} | (c) ${pkg.author.name} | ${pkg.author.url} */`; +const outdir = "dist"; /** * @type {import('esbuild').Plugin} @@ -27,6 +28,26 @@ const esbuildProblemMatcherPlugin = { }, }; +/** + * Copy `manifest.json` to outdir, updating its version to match what's in `package.json`. + * @type {import('esbuild').Plugin} + */ +const updateManifestPlugin = { + name: "update-manifest", + + setup(build) { + build.onEnd(() => { + const manifest = JSON.parse(readFileSync("manifest.json", "utf8")); + manifest.version = pkg.version; + writeFileSync( + outdir + "/manifest.json", + JSON.stringify(manifest, null, 2) + ); + console.log("✅ manifest.json updated"); + }); + }, +}; + const production = process.argv.includes("--production"); const watch = process.argv.includes("--watch"); @@ -43,9 +64,10 @@ const ctx = await esbuild.context({ bundle: true, sourcemap: production ? false : "inline", treeShaking: true, - outdir: "dist", + outdir: outdir, minify: production, plugins: [ + updateManifestPlugin, /* add to the end of plugins array */ esbuildProblemMatcherPlugin, ], diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..6265cea --- /dev/null +++ b/manifest.json @@ -0,0 +1,10 @@ +{ + "id": "manuscripten", + "name": "Manuscripten", + "version": "x.x.x", + "minAppVersion": "1.5.7", + "description": "Obsidian plugin to create .docx files that contain story and novel manuscripts for submission to magazines or agents.", + "author": "Stephen Granade", + "authorUrl": "https://github.com/sgranade", + "isDesktopOnly": true +}