nodebb-plugin-katex2 1.0.2 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-katex2",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "KaTeX math rendering plugin for NodeBB",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
package/plugin.json CHANGED
@@ -11,8 +11,7 @@
11
11
  }
12
12
  ],
13
13
  "scripts": ["static/js/render.js"],
14
- "stylesheets": ["static/css/katex.css"],
15
14
  "staticDirs": {
16
- "katex": "./static/katex"
15
+ "katex": "node_modules/katex/dist"
17
16
  }
18
17
  }
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
 
3
4
  const fs = require("fs");
@@ -25,25 +26,25 @@ function copyDir(src, dest) {
25
26
  function findKatexDist() {
26
27
  const pluginRoot = path.resolve(__dirname, "..");
27
28
 
28
- // Вариант 1: Локальный node_modules плагина
29
- const localPath = path.join(pluginRoot, "node_modules", "katex", "dist");
30
- if (fs.existsSync(localPath)) {
31
- console.log("[KaTeX] Found in local node_modules");
32
- return localPath;
33
- }
34
-
35
- // Вариант 2: Hoisted в корень NodeBB (../../node_modules/katex)
36
- const hoistedPath = path.join(
37
- pluginRoot,
38
- "..",
39
- "..",
40
- "node_modules",
41
- "katex",
42
- "dist",
43
- );
44
- if (fs.existsSync(hoistedPath)) {
45
- console.log("[KaTeX] Found in hoisted node_modules");
46
- return hoistedPath;
29
+ // Все возможные пути поиска
30
+ const searchPaths = [
31
+ // 1. Локальный node_modules плагина
32
+ path.join(pluginRoot, "node_modules", "katex", "dist"),
33
+ // 2. Hoisted в NodeBB (2 уровня вверх)
34
+ path.join(pluginRoot, "..", "..", "node_modules", "katex", "dist"),
35
+ // 3. Hoisted выше (3 уровня)
36
+ path.join(pluginRoot, "..", "..", "..", "node_modules", "katex", "dist"),
37
+ // 4. В соседней папке (параллельно плагину)
38
+ path.join(pluginRoot, "..", "katex", "dist"),
39
+ ];
40
+
41
+ console.log("[KaTeX] Searching for katex dist...");
42
+ for (const searchPath of searchPaths) {
43
+ console.log(" Checking:", searchPath);
44
+ if (fs.existsSync(searchPath)) {
45
+ console.log("[KaTeX] ✓ Found at:", searchPath);
46
+ return searchPath;
47
+ }
47
48
  }
48
49
 
49
50
  return null;
@@ -53,25 +54,37 @@ try {
53
54
  console.log("[KaTeX Plugin] Running postinstall...");
54
55
 
55
56
  const pluginRoot = path.resolve(__dirname, "..");
56
- const katexSource = findKatexDist();
57
57
  const katexDest = path.join(pluginRoot, "static", "katex");
58
58
 
59
+ // Ищем KaTeX
60
+ const katexSource = findKatexDist();
61
+
59
62
  if (!katexSource) {
60
- console.error("[KaTeX] ERROR: katex not found!");
61
- process.exit(1);
63
+ console.warn("[KaTeX] WARNING: katex not found!");
64
+ console.warn("[KaTeX] This is normal during initial npm install.");
65
+ console.warn(
66
+ "[KaTeX] Run 'npm rebuild nodebb-plugin-katex2' after installation completes.",
67
+ );
68
+ // Не блокируем установку
69
+ process.exit(0);
62
70
  }
63
71
 
72
+ // Удаляем старую директорию
64
73
  if (fs.existsSync(katexDest)) {
74
+ console.log("[KaTeX] Removing old directory...");
65
75
  fs.rmSync(katexDest, { recursive: true, force: true });
66
76
  }
67
77
 
68
- console.log("[KaTeX] Copying from:", katexSource);
69
- console.log("[KaTeX] Copying to:", katexDest);
78
+ // Копируем файлы
79
+ console.log("[KaTeX] Copying files...");
80
+ console.log("[KaTeX] From:", katexSource);
81
+ console.log("[KaTeX] To:", katexDest);
70
82
 
71
83
  copyDir(katexSource, katexDest);
72
84
 
73
- console.log("[KaTeX] Postinstall completed!");
85
+ console.log("[KaTeX] Postinstall completed!");
74
86
  } catch (err) {
75
- console.error("[KaTeX] Postinstall failed:", err);
76
- process.exit(1);
87
+ console.error("[KaTeX] Postinstall failed:", err.message);
88
+ // Не блокируем установку
89
+ process.exit(0);
77
90
  }
@@ -120,7 +120,7 @@
120
120
  // const basePath = "/plugins/nodebb-plugin-katex/node_modules/katex/dist/";
121
121
  // Находим правильный путь
122
122
  // Путь к файлам через modules
123
- const basePath = "/assets/plugins/nodebb-plugin-katex/katex/";
123
+ const basePath = "/assets/plugins/nodebb-plugin-katex2/katex/";
124
124
 
125
125
  // Параллельная загрузка всех файлов
126
126
  await Promise.all([