From 1695737fd09b7cd554fa51105c2efb38e3f1b40e Mon Sep 17 00:00:00 2001 From: quorafind <951011105@qq.com> Date: Sat, 9 Aug 2025 13:28:11 +0800 Subject: [PATCH] chore: bump release --- .release-it.cjs | 5 ++-- dist/manifest.json | 4 +-- esbuild.config.mjs | 70 +++++++++++++++++++++++++++++++++++++++++++--- manifest-beta.json | 18 ++++++------ manifest.json | 4 +-- package.json | 2 +- versions.json | 5 ++-- 7 files changed, 84 insertions(+), 24 deletions(-) diff --git a/.release-it.cjs b/.release-it.cjs index be29498b..6f2f0192 100644 --- a/.release-it.cjs +++ b/.release-it.cjs @@ -1,9 +1,8 @@ module.exports = { hooks: { - "before:init": ["pnpm run build"], + "before:init": ["node esbuild.config.mjs production"], "after:bump": [ - "pnpm run build", - "node -e \"const fs=require('fs'); if(!fs.existsSync('dist')) fs.mkdirSync('dist'); ['main.js','manifest.json','styles.css'].forEach(f=>fs.copyFileSync(f,'dist/'+f))\"", + "node esbuild.config.mjs production", "node ./scripts/zip.mjs", "git add .", ], diff --git a/dist/manifest.json b/dist/manifest.json index 0947acff..9000483a 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -1,10 +1,10 @@ { "id": "obsidian-task-progress-bar", "name": "Task Genius", - "version": "9.3.0", + "version": "9.2.2", "minAppVersion": "0.15.2", "description": "Comprehensive task management that includes progress bars, task status cycling, and advanced task tracking features.", "author": "Boninall", "authorUrl": "https://github.com/Quorafind", "isDesktopOnly": false -} \ No newline at end of file +} diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 1bd5e18d..67968f18 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -55,6 +55,68 @@ const renamePlugin = { }; const prod = process.argv[2] === "production"; +const outDir = prod ? "dist" : "."; + +// Ensure dist directory exists in production mode +if (prod && !fs.existsSync("dist")) { + fs.mkdirSync("dist", { recursive: true }); +} + +// Update plugins to handle output directory +const renamePluginWithDir = { + name: "rename-styles", + setup(build) { + build.onEnd(() => { + const { outfile } = build.initialOptions; + const outcss = outfile.replace(/\.js$/, ".css"); + const fixcss = outfile.replace(/main\.js$/, "styles.css"); + if (fs.existsSync(outcss)) { + console.log("Renaming", outcss, "to", fixcss); + fs.renameSync(outcss, fixcss); + } + }); + }, +}; + +// Update CSS settings plugin to handle output directory +const cssSettingsPluginWithDir = { + name: "css-settings-plugin", + setup(build) { + build.onEnd(async (result) => { + // Path to the output CSS file + const cssOutfile = path.join(outDir, "styles.css"); + + // The settings comment to prepend + const settingsComment = + fs.readFileSync("src/styles/index.css", "utf8").split("*/")[0] + + "*/\n\n"; + + if (fs.existsSync(cssOutfile)) { + // Read the current content + const cssContent = fs.readFileSync(cssOutfile, "utf8"); + + // Check if the settings comment is already there + if (!cssContent.includes("/* @settings")) { + // Prepend the settings comment + fs.writeFileSync(cssOutfile, settingsComment + cssContent); + } + } + }); + }, +}; + +// Copy manifest to output directory in production +const copyManifestPlugin = { + name: "copy-manifest", + setup(build) { + build.onEnd(() => { + if (prod) { + fs.copyFileSync("manifest.json", path.join(outDir, "manifest.json")); + console.log("Copied manifest.json to", outDir); + } + }); + }, +}; esbuild .build({ @@ -65,9 +127,9 @@ esbuild entryPoints: ["src/index.ts"], plugins: [ inlineWorkerPlugin({ workerName: "Task Genius Indexer" }), - - renamePlugin, - cssSettingsPlugin, + renamePluginWithDir, + cssSettingsPluginWithDir, + copyManifestPlugin, ], bundle: true, external: [ @@ -107,7 +169,7 @@ esbuild logLevel: "info", sourcemap: prod ? false : "inline", treeShaking: true, - outfile: "main.js", + outfile: path.join(outDir, "main.js"), pure: prod ? ["console.log"] : [], }) .catch(() => process.exit(1)); diff --git a/manifest-beta.json b/manifest-beta.json index 079ea8a1..9000483a 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,10 +1,10 @@ { - "id": "obsidian-task-progress-bar", - "name": "Task Genius", - "version": "9.3.0", - "minAppVersion": "0.15.2", - "description": "Comprehensive task management that includes progress bars, task status cycling, and advanced task tracking features.", - "author": "Boninall", - "authorUrl": "https://github.com/Quorafind", - "isDesktopOnly": false -} \ No newline at end of file + "id": "obsidian-task-progress-bar", + "name": "Task Genius", + "version": "9.2.2", + "minAppVersion": "0.15.2", + "description": "Comprehensive task management that includes progress bars, task status cycling, and advanced task tracking features.", + "author": "Boninall", + "authorUrl": "https://github.com/Quorafind", + "isDesktopOnly": false +} diff --git a/manifest.json b/manifest.json index 0947acff..9000483a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "id": "obsidian-task-progress-bar", "name": "Task Genius", - "version": "9.3.0", + "version": "9.2.2", "minAppVersion": "0.15.2", "description": "Comprehensive task management that includes progress bars, task status cycling, and advanced task tracking features.", "author": "Boninall", "authorUrl": "https://github.com/Quorafind", "isDesktopOnly": false -} \ No newline at end of file +} diff --git a/package.json b/package.json index 2544a8b6..13461b31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "task-genius", - "version": "9.3.0", + "version": "9.2.2", "description": "Comprehensive task management plugin for Obsidian with progress bars, task status cycling, and advanced task tracking features.", "main": "main.js", "scripts": { diff --git a/versions.json b/versions.json index 18bf7567..debb0f27 100644 --- a/versions.json +++ b/versions.json @@ -103,6 +103,5 @@ "9.1.5": "0.15.2", "9.2.0": "0.15.2", "9.2.1": "0.15.2", - "9.2.2": "0.15.2", - "9.3.0": "0.15.2" -} \ No newline at end of file + "9.2.2": "0.15.2" +}