@lexho111/plainblog 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Blog.js CHANGED
@@ -6,16 +6,16 @@ import process from "node:process";
6
6
  import path from "path";
7
7
  import { fileURLToPath } from "url";
8
8
  import pkg from "./package.json" with { type: "json" };
9
- import { debuglog as createDebug } from "node:util";
10
9
  import Article from "./Article.js";
11
10
  import DatabaseModel from "./model/DatabaseModel.js";
12
11
  import { fetchData, postData } from "./model/APIModel.js";
13
- import { formatHTML, header, formatMarkdown, validate } from "./Formatter.js"; // import pkg from "./package.json" with { type: "json" };
12
+ import { formatHTML, header, formatMarkdown, validate } from "./Formatter.js";
14
13
  import { compileStyles, mergeStyles } from "./build-styles.js";
15
14
  import { compileScripts } from "./build-scripts.js";
16
15
  import FileAdapter from "./model/FileAdapter.js";
17
16
  import DataModel from "./model/DataModel.js";
18
17
  import { BinarySearchTreeHashMap } from "./model/datastructures/BinarySearchTreeHashMap.js";
18
+ import createDebug from "./debug-loader.js";
19
19
 
20
20
  // Initialize the debugger with a specific namespace
21
21
  const debug = createDebug("plainblog:Blog");
Binary file
package/blog_test_load.db CHANGED
Binary file
@@ -0,0 +1,26 @@
1
+ import { debuglog } from "node:util";
2
+ import { createRequire } from "node:module";
3
+
4
+ const require = createRequire(import.meta.url);
5
+
6
+ /**
7
+ * Tries to load the 'debug' package synchronously, falling back to node:util.debuglog if not found.
8
+ * @param {string} namespace - The debug namespace (e.g., 'app:module').
9
+ * @returns {Function} - The debug function.
10
+ */
11
+ export default function createDebug(namespace) {
12
+ try {
13
+ // Attempt to load the external package synchronously
14
+ const debugFactory = require("debug");
15
+ return debugFactory(namespace);
16
+ } catch (err) {
17
+ if (
18
+ err.code === "ERR_MODULE_NOT_FOUND" ||
19
+ err.code === "MODULE_NOT_FOUND"
20
+ ) {
21
+ // Fallback to built-in node:util
22
+ return debuglog(namespace);
23
+ }
24
+ throw err; // Re-throw if it's a different error
25
+ }
26
+ }
package/index.js CHANGED
@@ -1,32 +1,5 @@
1
1
  import Blog from "./Blog.js";
2
2
  import Article from "./Article.js";
3
- import FileAdapter from "./model/FileAdapter.js";
4
- import SqliteAdapter from "./model/SqliteAdapter.js";
5
- import PostgresAdapter from "./model/PostgresAdapter.js";
6
- import DataModel from "./model/DataModel.js";
7
- import ArrayList from "./model/datastructures/ArrayList.js";
8
- import FileList from "./model/datastructures/FileList.js";
9
- import { BinarySearchTree } from "./model/datastructures/BinarySearchTree.js";
10
- import {
11
- generateTitle,
12
- generateContent,
13
- generateDateList,
14
- } from "./utilities.js";
15
- import { appendArticle } from "./model/FileModel.js";
16
3
 
17
- export {
18
- Blog,
19
- Article,
20
- FileAdapter,
21
- SqliteAdapter,
22
- PostgresAdapter,
23
- DataModel,
24
- ArrayList,
25
- FileList,
26
- BinarySearchTree,
27
- generateTitle,
28
- generateContent,
29
- generateDateList,
30
- appendArticle,
31
- };
4
+ export { Blog, Article };
32
5
  export default Blog;
@@ -1,4 +1,4 @@
1
- import { debuglog as createDebug } from "node:util";
1
+ import createDebug from "../debug-loader.js";
2
2
  import Article from "../Article.js";
3
3
 
4
4
  const debug = createDebug("plainblog:DataModel");
@@ -1,4 +1,4 @@
1
- import { debuglog as createDebug } from "node:util";
1
+ import createDebug from "../debug-loader.js";
2
2
 
3
3
  const debug = createDebug("plainblog:DatabaseModel");
4
4
 
@@ -6,7 +6,7 @@ import {
6
6
  initFiles,
7
7
  saveArticles,
8
8
  } from "./FileModel.js";
9
- import { debuglog as createDebug } from "node:util";
9
+ import createDebug from "../debug-loader.js";
10
10
 
11
11
  const debug = createDebug("plainblog:FileAdapter");
12
12
 
@@ -1,6 +1,6 @@
1
1
  import { promises as promise } from "fs";
2
- import { appendFile, appendFileSync, readFile, readFileSync } from "node:fs";
3
- import { debuglog as createDebug } from "node:util";
2
+ import { appendFileSync, readFileSync } from "node:fs";
3
+ import createDebug from "../debug-loader.js";
4
4
  import Article from "../Article.js";
5
5
 
6
6
  const debug = createDebug("plainblog:FileModel");
@@ -1,5 +1,5 @@
1
- import { debuglog as createDebug } from "node:util";
2
1
  import Article from "../../Article.js";
2
+ import createDebug from "../../debug-loader.js";
3
3
 
4
4
  const debug = createDebug("plainblog:BinarySearchTree");
5
5
 
@@ -1,4 +1,4 @@
1
- import { debuglog as createDebug } from "node:util";
1
+ import createDebug from "../../debug-loader.js";
2
2
  import { BinarySearchTree } from "./BinarySearchTree.js";
3
3
 
4
4
  // Initialize the debugger with a specific namespace
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexho111/plainblog",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "A tool for creating and serving a minimalist, single-page blog.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,6 +26,7 @@
26
26
  "@types/node": "^25.0.3",
27
27
  "autoprefixer": "^10.4.23",
28
28
  "cssnano": "^7.1.2",
29
+ "debug": "^4.4.3",
29
30
  "eslint": "^9.39.2",
30
31
  "eslint-plugin-jest": "^28.6.0",
31
32
  "globals": "^17.0.0",
@@ -38,6 +39,5 @@
38
39
  "typescript": "^5.9.3",
39
40
  "uglify-js": "^3.19.3",
40
41
  "w3c-css-validator": "^1.4.1"
41
- },
42
- "dependencies": {}
42
+ }
43
43
  }