Projekt-Grundgerüst: Build-System und Konfiguration
package.json mit better-sqlite3, tsconfig (strict, ES2022), esbuild mit native-module-resolver für better-sqlite3, manifest.json (Desktop-only), leere styles.css. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
4d31129090
7 changed files with 1228 additions and 0 deletions
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
node_modules/
|
||||
main.js
|
||||
*.js.map
|
||||
.DS_Store
|
||||
logfire.db
|
||||
logfire.db-wal
|
||||
logfire.db-shm
|
||||
67
esbuild.config.mjs
Normal file
67
esbuild.config.mjs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import esbuild from "esbuild";
|
||||
import process from "process";
|
||||
import builtins from "builtin-modules";
|
||||
|
||||
const prod = process.argv[2] === "production";
|
||||
|
||||
// Rewrite bare "better-sqlite3" require to resolve via Obsidian's vault path.
|
||||
// __dirname is Electron's internal asar path, not the plugin dir, so we use
|
||||
// the global `app` object to construct the absolute path at runtime.
|
||||
const nativeModulePlugin = {
|
||||
name: "native-module-resolver",
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /^better-sqlite3$/ }, () => ({
|
||||
path: "better-sqlite3",
|
||||
namespace: "native-module",
|
||||
}));
|
||||
build.onLoad({ filter: /.*/, namespace: "native-module" }, () => ({
|
||||
contents: `
|
||||
const path = require("path");
|
||||
const pluginDir = path.join(
|
||||
app.vault.adapter.basePath,
|
||||
app.vault.configDir,
|
||||
"plugins",
|
||||
"logfire"
|
||||
);
|
||||
module.exports = require(path.join(pluginDir, "node_modules", "better-sqlite3"));
|
||||
`,
|
||||
loader: "js",
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
const context = await esbuild.context({
|
||||
entryPoints: ["src/main.ts"],
|
||||
bundle: true,
|
||||
plugins: [nativeModulePlugin],
|
||||
external: [
|
||||
"obsidian",
|
||||
"electron",
|
||||
"@codemirror/autocomplete",
|
||||
"@codemirror/collab",
|
||||
"@codemirror/commands",
|
||||
"@codemirror/language",
|
||||
"@codemirror/lint",
|
||||
"@codemirror/search",
|
||||
"@codemirror/state",
|
||||
"@codemirror/view",
|
||||
"@lezer/common",
|
||||
"@lezer/highlight",
|
||||
"@lezer/lr",
|
||||
...builtins,
|
||||
],
|
||||
format: "cjs",
|
||||
target: "es2022",
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : "inline",
|
||||
treeShaking: true,
|
||||
outfile: "main.js",
|
||||
minify: prod,
|
||||
});
|
||||
|
||||
if (prod) {
|
||||
await context.rebuild();
|
||||
process.exit(0);
|
||||
} else {
|
||||
await context.watch();
|
||||
}
|
||||
9
manifest.json
Normal file
9
manifest.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"id": "logfire",
|
||||
"name": "Logfire",
|
||||
"version": "0.1.0",
|
||||
"minAppVersion": "1.5.0",
|
||||
"description": "Track all vault activity, query with SQL, visualize with charts and dashboards — all backed by SQLite.",
|
||||
"author": "Luca",
|
||||
"isDesktopOnly": true
|
||||
}
|
||||
1103
package-lock.json
generated
Normal file
1103
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
21
package.json
Normal file
21
package.json
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "logfire",
|
||||
"version": "0.1.0",
|
||||
"description": "Track all vault activity, query with SQL, visualize with charts and dashboards",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "node esbuild.config.mjs",
|
||||
"build": "node esbuild.config.mjs production"
|
||||
},
|
||||
"dependencies": {
|
||||
"better-sqlite3": "^12.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/better-sqlite3": "^7.6.0",
|
||||
"@types/node": "^22.0.0",
|
||||
"builtin-modules": "^4.0.0",
|
||||
"esbuild": "^0.24.0",
|
||||
"obsidian": "latest",
|
||||
"typescript": "^5.6.0"
|
||||
}
|
||||
}
|
||||
1
styles.css
Normal file
1
styles.css
Normal file
|
|
@ -0,0 +1 @@
|
|||
/* Logfire – Styles */
|
||||
20
tsconfig.json
Normal file
20
tsconfig.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"inlineSourceMap": true,
|
||||
"inlineSources": true,
|
||||
"module": "ESNext",
|
||||
"target": "ES2022",
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"importHelpers": true,
|
||||
"isolatedModules": true,
|
||||
"skipLibCheck": true,
|
||||
"lib": ["DOM", "ES2022"]
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
Loading…
Reference in a new issue