react-doctor-cli-dev 1.0.6 → 1.0.7
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/backend/dist/db.js +14 -7
- package/backend/dist/routes/reports.js +35 -3
- package/backend/src/db.ts +15 -7
- package/backend/src/routes/reports.ts +2 -3
- package/package.json +1 -1
package/backend/dist/db.js
CHANGED
|
@@ -3,24 +3,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.screenshotsDir = void 0;
|
|
6
7
|
const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
10
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
11
|
+
dotenv_1.default.config({ path: path_1.default.join(__dirname, "..", ".env") });
|
|
12
|
+
const PACKAGE_ROOT = path_1.default.resolve(__dirname, "..", "..");
|
|
13
|
+
const DEFAULT_DB = path_1.default.join(PACKAGE_ROOT, "backend", "data", "reports.db");
|
|
14
|
+
const dbPath = process.env.DB_PATH || DEFAULT_DB;
|
|
13
15
|
fs_1.default.mkdirSync(path_1.default.dirname(dbPath), { recursive: true });
|
|
16
|
+
fs_1.default.mkdirSync(path_1.default.join(path_1.default.dirname(dbPath), "screenshots"), { recursive: true });
|
|
14
17
|
const db = new better_sqlite3_1.default(dbPath);
|
|
18
|
+
// ✅ NEW SCHEMA WITH SPLIT COLUMNS
|
|
15
19
|
db.exec(`
|
|
16
|
-
CREATE TABLE IF NOT EXISTS reports (
|
|
20
|
+
CREATE TABLE IF NOT EXISTS reports (
|
|
17
21
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18
22
|
project TEXT NOT NULL,
|
|
19
23
|
score INTEGER NOT NULL,
|
|
20
24
|
grade TEXT NOT NULL,
|
|
21
25
|
analyzed_at TEXT NOT NULL,
|
|
22
26
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
static_json TEXT NOT NULL,
|
|
28
|
+
runtime_json TEXT NOT NULL,
|
|
29
|
+
suggestions TEXT NOT NULL
|
|
30
|
+
);
|
|
25
31
|
`);
|
|
32
|
+
exports.screenshotsDir = path_1.default.join(path_1.default.dirname(dbPath), "screenshots");
|
|
26
33
|
exports.default = db;
|
|
@@ -31,6 +31,39 @@
|
|
|
31
31
|
// /screenshots/<filename>
|
|
32
32
|
// so the dashboard can load them as normal <img> tags.
|
|
33
33
|
// ─────────────────────────────────────────────────────────────
|
|
34
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
35
|
+
if (k2 === undefined) k2 = k;
|
|
36
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
37
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
38
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
39
|
+
}
|
|
40
|
+
Object.defineProperty(o, k2, desc);
|
|
41
|
+
}) : (function(o, m, k, k2) {
|
|
42
|
+
if (k2 === undefined) k2 = k;
|
|
43
|
+
o[k2] = m[k];
|
|
44
|
+
}));
|
|
45
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
46
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
47
|
+
}) : function(o, v) {
|
|
48
|
+
o["default"] = v;
|
|
49
|
+
});
|
|
50
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
51
|
+
var ownKeys = function(o) {
|
|
52
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
53
|
+
var ar = [];
|
|
54
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
55
|
+
return ar;
|
|
56
|
+
};
|
|
57
|
+
return ownKeys(o);
|
|
58
|
+
};
|
|
59
|
+
return function (mod) {
|
|
60
|
+
if (mod && mod.__esModule) return mod;
|
|
61
|
+
var result = {};
|
|
62
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
63
|
+
__setModuleDefault(result, mod);
|
|
64
|
+
return result;
|
|
65
|
+
};
|
|
66
|
+
})();
|
|
34
67
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
68
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
69
|
};
|
|
@@ -38,9 +71,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
71
|
const express_1 = require("express");
|
|
39
72
|
const path_1 = __importDefault(require("path"));
|
|
40
73
|
const fs_1 = __importDefault(require("fs"));
|
|
41
|
-
const db_1 =
|
|
74
|
+
const db_1 = __importStar(require("../db"));
|
|
42
75
|
const auth_1 = require("../middleware/auth");
|
|
43
|
-
const screenshotsDir = "data/screenshots";
|
|
44
76
|
const router = (0, express_1.Router)();
|
|
45
77
|
// ── GET /api/reports ─────────────────────────────────────────
|
|
46
78
|
// Summary list — no blobs, just the columns the history page needs.
|
|
@@ -209,7 +241,7 @@ function saveScreenshots(reportId, pending) {
|
|
|
209
241
|
const safeRoute = shot.routeKey.replace(/[/:]/g, "-").replace(/^-+/, "");
|
|
210
242
|
const safeLabel = shot.label.replace(/[^a-z0-9]/gi, "-");
|
|
211
243
|
const filename = `${reportId}-${safeRoute}-${safeLabel}.png`;
|
|
212
|
-
const fullPath = path_1.default.join(screenshotsDir, filename);
|
|
244
|
+
const fullPath = path_1.default.join(db_1.screenshotsDir, filename);
|
|
213
245
|
try {
|
|
214
246
|
fs_1.default.writeFileSync(fullPath, shot.buffer);
|
|
215
247
|
saved.push({
|
package/backend/src/db.ts
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import Database from "better-sqlite3";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fs from "fs";
|
|
4
|
-
import
|
|
4
|
+
import dotenv from "dotenv";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
6
|
+
dotenv.config({ path: path.join(__dirname, "..", ".env") });
|
|
7
|
+
|
|
8
|
+
const PACKAGE_ROOT = path.resolve(__dirname, "..", "..");
|
|
9
|
+
const DEFAULT_DB = path.join(PACKAGE_ROOT, "backend", "data", "reports.db");
|
|
10
|
+
const dbPath = process.env.DB_PATH || DEFAULT_DB;
|
|
9
11
|
|
|
10
12
|
fs.mkdirSync(path.dirname(dbPath), { recursive: true });
|
|
13
|
+
fs.mkdirSync(path.join(path.dirname(dbPath), "screenshots"), { recursive: true });
|
|
11
14
|
|
|
12
15
|
const db = new Database(dbPath);
|
|
16
|
+
|
|
17
|
+
// ✅ NEW SCHEMA WITH SPLIT COLUMNS
|
|
13
18
|
db.exec(`
|
|
14
|
-
CREATE TABLE IF NOT EXISTS reports (
|
|
19
|
+
CREATE TABLE IF NOT EXISTS reports (
|
|
15
20
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
16
21
|
project TEXT NOT NULL,
|
|
17
22
|
score INTEGER NOT NULL,
|
|
18
23
|
grade TEXT NOT NULL,
|
|
19
24
|
analyzed_at TEXT NOT NULL,
|
|
20
25
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
static_json TEXT NOT NULL,
|
|
27
|
+
runtime_json TEXT NOT NULL,
|
|
28
|
+
suggestions TEXT NOT NULL
|
|
29
|
+
);
|
|
23
30
|
`);
|
|
24
31
|
|
|
32
|
+
export const screenshotsDir = path.join(path.dirname(dbPath), "screenshots");
|
|
25
33
|
export default db;
|
|
@@ -34,10 +34,9 @@
|
|
|
34
34
|
import { Router, Request, Response, RequestHandler } from "express";
|
|
35
35
|
import path from "path";
|
|
36
36
|
import fs from "fs";
|
|
37
|
-
import db from "../db";
|
|
38
|
-
import { requireApiKey } from "../middleware/auth";
|
|
37
|
+
import db, { screenshotsDir } from "../db";
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
import { requireApiKey } from "../middleware/auth";
|
|
41
40
|
|
|
42
41
|
const router = Router();
|
|
43
42
|
|
package/package.json
CHANGED