@mean-weasel/lineage 0.1.7 → 0.1.9
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/CHANGELOG.md +14 -0
- package/README.md +43 -4
- package/dist/cli/lineage-dev.js +429 -15
- package/dist/cli/lineage-dev.js.map +4 -4
- package/dist/cli/lineage.js +428 -14
- package/dist/cli/lineage.js.map +4 -4
- package/dist/server.js +79 -8
- package/dist/server.js.map +4 -4
- package/dist/web/assets/index-CEb6Sfqx.js +23 -0
- package/dist/web/assets/index-CKMlZT43.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +3 -1
- package/dist/web/assets/index-38XlcMya.css +0 -1
- package/dist/web/assets/index-CtsYIUyG.js +0 -23
package/dist/server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/server.ts
|
|
2
2
|
import express2 from "express";
|
|
3
3
|
import multer from "multer";
|
|
4
|
-
import { existsSync as
|
|
5
|
-
import { join as
|
|
4
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
5
|
+
import { join as join10 } from "node:path";
|
|
6
6
|
|
|
7
7
|
// src/server/assetCore.ts
|
|
8
8
|
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readdirSync as readdirSync2, readFileSync as readFileSync2, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -1134,8 +1134,8 @@ function isPackageRoot(path) {
|
|
|
1134
1134
|
const packageJson = join4(path, "package.json");
|
|
1135
1135
|
if (!existsSync3(packageJson)) return false;
|
|
1136
1136
|
try {
|
|
1137
|
-
const
|
|
1138
|
-
return
|
|
1137
|
+
const packageInfo2 = JSON.parse(readFileSync2(packageJson, "utf8"));
|
|
1138
|
+
return packageInfo2.name === "@mean-weasel/lineage";
|
|
1139
1139
|
} catch {
|
|
1140
1140
|
return false;
|
|
1141
1141
|
}
|
|
@@ -7188,6 +7188,74 @@ function registerLineageWorkspaceRoutes(app2, projectFrom2, asyncRoute2) {
|
|
|
7188
7188
|
}));
|
|
7189
7189
|
}
|
|
7190
7190
|
|
|
7191
|
+
// src/server/runtimeInfo.ts
|
|
7192
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
7193
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
7194
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5, statSync as statSync3 } from "node:fs";
|
|
7195
|
+
import { join as join9 } from "node:path";
|
|
7196
|
+
var require3 = createRequire2(import.meta.url);
|
|
7197
|
+
function packageInfo() {
|
|
7198
|
+
try {
|
|
7199
|
+
const info = JSON.parse(readFileSync5(join9(repoRoot, "package.json"), "utf8"));
|
|
7200
|
+
return { name: info.name || "@mean-weasel/lineage", version: info.version || "0.0.0" };
|
|
7201
|
+
} catch {
|
|
7202
|
+
return { name: "@mean-weasel/lineage", version: "0.0.0" };
|
|
7203
|
+
}
|
|
7204
|
+
}
|
|
7205
|
+
function normalizeRuntimeChannel(value) {
|
|
7206
|
+
if (value === "stable" || value === "preview" || value === "dev") return value;
|
|
7207
|
+
if (value === "production") return "stable";
|
|
7208
|
+
if (value === "next") return "preview";
|
|
7209
|
+
if (value === "development") return "dev";
|
|
7210
|
+
return process.env.NODE_ENV === "production" ? "stable" : "dev";
|
|
7211
|
+
}
|
|
7212
|
+
function gitSha() {
|
|
7213
|
+
const envSha = process.env.LINEAGE_GIT_SHA || process.env.GITHUB_SHA;
|
|
7214
|
+
if (envSha) return envSha.slice(0, 40);
|
|
7215
|
+
if (!existsSync6(join9(repoRoot, ".git"))) return void 0;
|
|
7216
|
+
const result = spawnSync2("git", ["rev-parse", "--short=12", "HEAD"], { cwd: repoRoot, encoding: "utf8" });
|
|
7217
|
+
return result.status === 0 ? result.stdout.trim() || void 0 : void 0;
|
|
7218
|
+
}
|
|
7219
|
+
function tableExists(database, table) {
|
|
7220
|
+
return Boolean(database.prepare("select name from sqlite_master where type = 'table' and name = ?").get(table));
|
|
7221
|
+
}
|
|
7222
|
+
function tableCount(database, table) {
|
|
7223
|
+
if (!tableExists(database, table)) return void 0;
|
|
7224
|
+
const row = database.prepare(`select count(*) count from ${table}`).get();
|
|
7225
|
+
return typeof row?.count === "number" ? row.count : void 0;
|
|
7226
|
+
}
|
|
7227
|
+
function getLineageRuntimeInfo(options = {}) {
|
|
7228
|
+
const info = packageInfo();
|
|
7229
|
+
const dbPath = options.dbPath || lineageDbPath();
|
|
7230
|
+
const databaseInfo = { exists: existsSync6(dbPath), path: dbPath };
|
|
7231
|
+
if (databaseInfo.exists) {
|
|
7232
|
+
try {
|
|
7233
|
+
const stat = statSync3(dbPath);
|
|
7234
|
+
databaseInfo.modified_at = stat.mtime.toISOString();
|
|
7235
|
+
databaseInfo.size_bytes = stat.size;
|
|
7236
|
+
const { DatabaseSync } = require3("node:sqlite");
|
|
7237
|
+
const database = new DatabaseSync(dbPath, { readOnly: true });
|
|
7238
|
+
try {
|
|
7239
|
+
databaseInfo.projects = tableCount(database, "projects");
|
|
7240
|
+
databaseInfo.workspaces = tableCount(database, "lineage_workspaces");
|
|
7241
|
+
} finally {
|
|
7242
|
+
database.close();
|
|
7243
|
+
}
|
|
7244
|
+
} catch (error) {
|
|
7245
|
+
databaseInfo.error = error instanceof Error ? error.message : String(error);
|
|
7246
|
+
}
|
|
7247
|
+
}
|
|
7248
|
+
return {
|
|
7249
|
+
channel: normalizeRuntimeChannel(options.channel || process.env.LINEAGE_CHANNEL || process.env.LINEAGE_RELEASE_CHANNEL),
|
|
7250
|
+
database: databaseInfo,
|
|
7251
|
+
fetchedAt: nowIso(),
|
|
7252
|
+
git_sha: gitSha(),
|
|
7253
|
+
node_env: process.env.NODE_ENV,
|
|
7254
|
+
package_name: info.name,
|
|
7255
|
+
version: info.version
|
|
7256
|
+
};
|
|
7257
|
+
}
|
|
7258
|
+
|
|
7191
7259
|
// src/server.ts
|
|
7192
7260
|
var app = express2();
|
|
7193
7261
|
var port = Number(process.env.PORT || 5173);
|
|
@@ -7208,6 +7276,9 @@ function asyncRoute(handler) {
|
|
|
7208
7276
|
app.get("/api/projects", asyncRoute((_req, res) => {
|
|
7209
7277
|
res.json({ projects: listProjects() });
|
|
7210
7278
|
}));
|
|
7279
|
+
app.get("/api/runtime", asyncRoute((_req, res) => {
|
|
7280
|
+
res.json({ ok: true, runtime: getLineageRuntimeInfo() });
|
|
7281
|
+
}));
|
|
7211
7282
|
app.get(
|
|
7212
7283
|
"/api/assets",
|
|
7213
7284
|
asyncRoute((req, res) => {
|
|
@@ -7528,16 +7599,16 @@ app.post(
|
|
|
7528
7599
|
})
|
|
7529
7600
|
);
|
|
7530
7601
|
if (isProduction) {
|
|
7531
|
-
const dist =
|
|
7532
|
-
if (
|
|
7602
|
+
const dist = join10(repoRoot, "dist", "web");
|
|
7603
|
+
if (existsSync7(dist)) {
|
|
7533
7604
|
app.use(express2.static(dist));
|
|
7534
|
-
app.get("*", (_req, res) => res.sendFile(
|
|
7605
|
+
app.get("*", (_req, res) => res.sendFile(join10(dist, "index.html")));
|
|
7535
7606
|
}
|
|
7536
7607
|
} else {
|
|
7537
7608
|
const { createServer: createViteServer } = await import("vite");
|
|
7538
7609
|
const e2ePort = process.env.LINEAGE_E2E_PORT ? Number(process.env.LINEAGE_E2E_PORT) : void 0;
|
|
7539
7610
|
const vite = await createViteServer({
|
|
7540
|
-
configFile:
|
|
7611
|
+
configFile: join10(repoRoot, "vite.config.ts"),
|
|
7541
7612
|
server: {
|
|
7542
7613
|
middlewareMode: true,
|
|
7543
7614
|
...e2ePort ? { ws: { port: e2ePort + 1e3 } } : {}
|