mirror of
https://github.com/mossy1022/Smart-Connections-Visualizer.git
synced 2026-07-22 05:14:43 +00:00
fix: create dist directory before writing files
- Ensure dist directory exists before writing manifest.json - Make OBSIDIAN_PLUGINS_PATH optional to support fresh checkouts - Prevents ENOENT errors on first build
This commit is contained in:
parent
e474a3ccca
commit
9a2222ca32
1 changed files with 20 additions and 13 deletions
|
|
@ -19,6 +19,10 @@ const package_json = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'packag
|
||||||
const manifest_json = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'manifest.json')));
|
const manifest_json = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'manifest.json')));
|
||||||
manifest_json.version = package_json.version;
|
manifest_json.version = package_json.version;
|
||||||
fs.writeFileSync(path.join(process.cwd(), 'manifest.json'), JSON.stringify(manifest_json, null, 2));
|
fs.writeFileSync(path.join(process.cwd(), 'manifest.json'), JSON.stringify(manifest_json, null, 2));
|
||||||
|
// Ensure dist directory exists
|
||||||
|
if (!fs.existsSync(path.join(process.cwd(), 'dist'))) {
|
||||||
|
fs.mkdirSync(path.join(process.cwd(), 'dist'));
|
||||||
|
}
|
||||||
fs.writeFileSync(path.join(process.cwd(), './dist/manifest.json'), JSON.stringify(manifest_json, null, 2));
|
fs.writeFileSync(path.join(process.cwd(), './dist/manifest.json'), JSON.stringify(manifest_json, null, 2));
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -26,25 +30,28 @@ const copy_to_plugins = {
|
||||||
name: 'copy_to_plugins',
|
name: 'copy_to_plugins',
|
||||||
setup(build) {
|
setup(build) {
|
||||||
build.onEnd(() => {
|
build.onEnd(() => {
|
||||||
const plugin_path = path.join(process.env.OBSIDIAN_PLUGINS_PATH, "smart-connections-visualizer");
|
|
||||||
|
|
||||||
if (!fs.existsSync(plugin_path)) {
|
|
||||||
fs.mkdirSync(plugin_path);
|
|
||||||
}
|
|
||||||
// copy manifest and styles to dist folder
|
// copy manifest and styles to dist folder
|
||||||
fs.copyFileSync("./manifest.json", "./dist/manifest.json");
|
fs.copyFileSync("./manifest.json", "./dist/manifest.json");
|
||||||
fs.copyFileSync("./styles.css", "./dist/styles.css");
|
fs.copyFileSync("./styles.css", "./dist/styles.css");
|
||||||
|
|
||||||
|
|
||||||
|
// Only copy to plugins folder if OBSIDIAN_PLUGINS_PATH is set
|
||||||
|
if (process.env.OBSIDIAN_PLUGINS_PATH) {
|
||||||
|
const plugin_path = path.join(process.env.OBSIDIAN_PLUGINS_PATH, "smart-connections-visualizer");
|
||||||
|
|
||||||
fs.copyFileSync("./dist/main.js", path.join(plugin_path, "main.js"));
|
if (!fs.existsSync(plugin_path)) {
|
||||||
fs.copyFileSync("./dist/manifest.json", path.join(plugin_path, "manifest.json"));
|
fs.mkdirSync(plugin_path);
|
||||||
fs.copyFileSync("./dist/styles.css", path.join(plugin_path, "styles.css"));
|
}
|
||||||
// add empty .hotreload file
|
|
||||||
fs.writeFileSync(path.join(plugin_path, ".hotreload"), "");
|
|
||||||
|
|
||||||
|
|
||||||
console.log("Plugin built and copied to obsidian plugins folder");
|
fs.copyFileSync("./dist/main.js", path.join(plugin_path, "main.js"));
|
||||||
|
fs.copyFileSync("./dist/manifest.json", path.join(plugin_path, "manifest.json"));
|
||||||
|
fs.copyFileSync("./dist/styles.css", path.join(plugin_path, "styles.css"));
|
||||||
|
// add empty .hotreload file
|
||||||
|
fs.writeFileSync(path.join(plugin_path, ".hotreload"), "");
|
||||||
|
|
||||||
|
console.log("Plugin built and copied to obsidian plugins folder");
|
||||||
|
} else {
|
||||||
|
console.log("Plugin built (OBSIDIAN_PLUGINS_PATH not set, skipping auto-copy)");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue