@miketromba/issy-app 0.1.5 → 0.1.6
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/dist/app.js +86 -86
- package/dist/server.js +42 -13
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -2,26 +2,57 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
3
|
|
|
4
4
|
// src/server.ts
|
|
5
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
6
6
|
import { createServer } from "node:http";
|
|
7
|
-
import { extname, join as join2, resolve } from "node:path";
|
|
7
|
+
import { extname, join as join2, resolve as resolve2 } from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
// ../core/src/lib/issues.ts
|
|
10
|
+
import { existsSync } from "node:fs";
|
|
10
11
|
import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
+
import { dirname, join, resolve } from "node:path";
|
|
12
13
|
var issuesDir = null;
|
|
13
14
|
function setIssuesDir(dir) {
|
|
14
15
|
issuesDir = dir;
|
|
15
16
|
}
|
|
16
17
|
function getIssuesDir() {
|
|
17
18
|
if (!issuesDir) {
|
|
18
|
-
throw new Error("Issues directory not initialized. Call setIssuesDir() first.");
|
|
19
|
+
throw new Error("Issues directory not initialized. Call setIssuesDir() or resolveIssuesDir() first.");
|
|
19
20
|
}
|
|
20
21
|
return issuesDir;
|
|
21
22
|
}
|
|
22
23
|
async function ensureIssuesDir() {
|
|
23
24
|
await mkdir(getIssuesDir(), { recursive: true });
|
|
24
25
|
}
|
|
26
|
+
function findIssuesDirUpward(fromPath) {
|
|
27
|
+
let current = resolve(fromPath);
|
|
28
|
+
for (let i = 0;i < 20; i++) {
|
|
29
|
+
const candidate = join(current, ".issues");
|
|
30
|
+
if (existsSync(candidate)) {
|
|
31
|
+
return candidate;
|
|
32
|
+
}
|
|
33
|
+
const parent = dirname(current);
|
|
34
|
+
if (parent === current)
|
|
35
|
+
break;
|
|
36
|
+
current = parent;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
function resolveIssuesDir() {
|
|
41
|
+
if (process.env.ISSUES_DIR) {
|
|
42
|
+
const dir = resolve(process.env.ISSUES_DIR);
|
|
43
|
+
setIssuesDir(dir);
|
|
44
|
+
return dir;
|
|
45
|
+
}
|
|
46
|
+
const startDir = process.env.ISSUES_ROOT || process.cwd();
|
|
47
|
+
const found = findIssuesDirUpward(startDir);
|
|
48
|
+
if (found) {
|
|
49
|
+
setIssuesDir(found);
|
|
50
|
+
return found;
|
|
51
|
+
}
|
|
52
|
+
const fallback = join(resolve(startDir), ".issues");
|
|
53
|
+
setIssuesDir(fallback);
|
|
54
|
+
return fallback;
|
|
55
|
+
}
|
|
25
56
|
function parseFrontmatter(content) {
|
|
26
57
|
const match = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
27
58
|
if (!match) {
|
|
@@ -1749,12 +1780,10 @@ function filterByQuery(issues, query) {
|
|
|
1749
1780
|
return result;
|
|
1750
1781
|
}
|
|
1751
1782
|
// src/server.ts
|
|
1752
|
-
|
|
1753
|
-
var ISSUES_DIR = process.env.ISSUES_DIR || resolve(DEFAULT_ROOT, ".issues");
|
|
1754
|
-
setIssuesDir(ISSUES_DIR);
|
|
1783
|
+
resolveIssuesDir();
|
|
1755
1784
|
var PORT = Number(process.env.ISSUES_PORT || process.env.PORT || 1554);
|
|
1756
|
-
var __dirname2 =
|
|
1757
|
-
var distDir = __dirname2.endsWith("dist") ? __dirname2 :
|
|
1785
|
+
var __dirname2 = resolve2(fileURLToPath(import.meta.url), "..");
|
|
1786
|
+
var distDir = __dirname2.endsWith("dist") ? __dirname2 : resolve2(__dirname2, "..", "dist");
|
|
1758
1787
|
var mimeTypes = {
|
|
1759
1788
|
".html": "text/html",
|
|
1760
1789
|
".js": "application/javascript",
|
|
@@ -1764,14 +1793,14 @@ var mimeTypes = {
|
|
|
1764
1793
|
".svg": "image/svg+xml"
|
|
1765
1794
|
};
|
|
1766
1795
|
async function parseBody(req) {
|
|
1767
|
-
return new Promise((
|
|
1796
|
+
return new Promise((resolve3, reject) => {
|
|
1768
1797
|
let body = "";
|
|
1769
1798
|
req.on("data", (chunk) => {
|
|
1770
1799
|
body += chunk;
|
|
1771
1800
|
});
|
|
1772
1801
|
req.on("end", () => {
|
|
1773
1802
|
try {
|
|
1774
|
-
|
|
1803
|
+
resolve3(body ? JSON.parse(body) : {});
|
|
1775
1804
|
} catch (e) {
|
|
1776
1805
|
reject(e);
|
|
1777
1806
|
}
|
|
@@ -1873,10 +1902,10 @@ var server = createServer(async (req, res) => {
|
|
|
1873
1902
|
return res.end("Forbidden");
|
|
1874
1903
|
}
|
|
1875
1904
|
let targetPath = fullPath;
|
|
1876
|
-
if (!
|
|
1905
|
+
if (!existsSync2(fullPath)) {
|
|
1877
1906
|
targetPath = join2(distDir, "index.html");
|
|
1878
1907
|
}
|
|
1879
|
-
if (
|
|
1908
|
+
if (existsSync2(targetPath)) {
|
|
1880
1909
|
const ext = extname(targetPath);
|
|
1881
1910
|
const contentType = mimeTypes[ext] || "application/octet-stream";
|
|
1882
1911
|
const content = readFileSync(targetPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miketromba/issy-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Local web UI and API server for issy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"node": ">=18.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@miketromba/issy-core": "^0.1.
|
|
38
|
+
"@miketromba/issy-core": "^0.1.6"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@tailwindcss/typography": "^0.5.16",
|