yamlite 0.44.1 → 0.45.0
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/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { B as
|
|
3
|
-
import { n as guide, r as envKeys, t as createWorkspace } from "./workspace-
|
|
2
|
+
import { B as loopbackHosts, L as createHandler, V as check, a as query, c as exportSite, i as formatTable, n as formatCsv, o as generateConfig, r as formatJson, s as init, t as open, z as isLoopback } from "./src-EgLryo0T.mjs";
|
|
3
|
+
import { n as guide, r as envKeys, t as createWorkspace } from "./workspace-Ba4Q66xr.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { relative, resolve } from "node:path";
|
|
6
6
|
import { homedir } from "node:os";
|
package/dist/core.d.mts
CHANGED
package/dist/core.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as createWorkspace } from "./workspace-
|
|
1
|
+
import { E as worthShowing, G as readsFile, H as CONFIG_NAMES, J as MAX_PAGE_FILE_BYTES, Q as normalizeFilePath, R as HttpError, T as fieldChanges, V as check, W as parseConfig, Z as fileGranted, a as query, c as exportSite, g as templatePath, i as formatTable, n as formatCsv, o as generateConfig, p as ReviewRefused, q as DENIED_FILES, r as formatJson, s as init, t as open, w as describeChange } from "./src-EgLryo0T.mjs";
|
|
2
|
+
import { t as createWorkspace } from "./workspace-Ba4Q66xr.mjs";
|
|
3
3
|
export { CONFIG_NAMES, DENIED_FILES, HttpError, MAX_PAGE_FILE_BYTES, ReviewRefused, check, createWorkspace, describeChange, exportSite, fieldChanges, fileGranted, formatCsv, formatJson, formatTable, generateConfig, init, normalizeFilePath, open, parseConfig, query, readsFile, templatePath, worthShowing };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { V as check, c as exportSite, n as formatCsv, r as formatJson, i as formatTable, o as generateConfig, s as init, t as open, a as query } from "./src-EgLryo0T.mjs";
|
|
@@ -5716,7 +5716,12 @@ async function findRepo(root) {
|
|
|
5716
5716
|
return null;
|
|
5717
5717
|
}
|
|
5718
5718
|
}
|
|
5719
|
-
|
|
5719
|
+
function toRoot(repo, topPath) {
|
|
5720
|
+
if (topPath.startsWith(repo.prefix)) return topPath.slice(repo.prefix.length);
|
|
5721
|
+
if (!repo.reaches) return null;
|
|
5722
|
+
const path = posix.relative(repo.prefix.replace(/\/$/, "") || ".", topPath);
|
|
5723
|
+
return repo.reaches(resolve(repo.root, path)) ? path : null;
|
|
5724
|
+
}
|
|
5720
5725
|
async function currentBranch(repo) {
|
|
5721
5726
|
try {
|
|
5722
5727
|
return (await runGit(repo.top, [
|
|
@@ -5861,8 +5866,10 @@ async function ghReady(env = process.env) {
|
|
|
5861
5866
|
function insideRoot$1(repo, path) {
|
|
5862
5867
|
const abs = resolve(repo.root, path);
|
|
5863
5868
|
const rel = relative(repo.root, abs);
|
|
5864
|
-
if (rel === "" ||
|
|
5865
|
-
|
|
5869
|
+
if (rel === "" || isAbsolute(rel)) return null;
|
|
5870
|
+
if (!(rel !== ".." && !rel.startsWith(`..${sep}`)) && !repo.reaches?.(abs)) return null;
|
|
5871
|
+
const top = posix.normalize(repo.prefix + rel.split(sep).join(posix.sep));
|
|
5872
|
+
return top === ".." || top.startsWith("../") ? null : top;
|
|
5866
5873
|
}
|
|
5867
5874
|
//#endregion
|
|
5868
5875
|
//#region src/git/pr.ts
|
|
@@ -6303,13 +6310,17 @@ var NoRepository = class extends Error {
|
|
|
6303
6310
|
super("the data folder is not in a git repository");
|
|
6304
6311
|
}
|
|
6305
6312
|
};
|
|
6306
|
-
async function localDriver(root, gh) {
|
|
6313
|
+
async function localDriver(root, gh, reaches) {
|
|
6307
6314
|
let found = null;
|
|
6308
6315
|
let base = null;
|
|
6309
6316
|
const lookup = async () => {
|
|
6310
6317
|
if (found) return found;
|
|
6311
|
-
const
|
|
6312
|
-
if (!
|
|
6318
|
+
const at = await findRepo(root);
|
|
6319
|
+
if (!at) return null;
|
|
6320
|
+
const repo = reaches ? {
|
|
6321
|
+
...at,
|
|
6322
|
+
reaches
|
|
6323
|
+
} : at;
|
|
6313
6324
|
found ??= {
|
|
6314
6325
|
repo,
|
|
6315
6326
|
steps: {
|
|
@@ -6402,7 +6413,7 @@ async function localDriver(root, gh) {
|
|
|
6402
6413
|
"-z",
|
|
6403
6414
|
`${await defaultRef(f.repo, name)}...HEAD`,
|
|
6404
6415
|
"--",
|
|
6405
|
-
f.repo.prefix || "."
|
|
6416
|
+
f.repo.reaches ? "." : f.repo.prefix || "."
|
|
6406
6417
|
])).split("\0");
|
|
6407
6418
|
const changes = [];
|
|
6408
6419
|
for (let i = 0; i + 1 < parts.length; i += 2) {
|
|
@@ -7111,9 +7122,7 @@ const gitRoutes = (router, ctx) => {
|
|
|
7111
7122
|
return ctx.proposals.exclusive(async () => {
|
|
7112
7123
|
const changed = new Set((await from.changes().catch(notFound)).map((c) => c.path));
|
|
7113
7124
|
const files = await Promise.all(paths.map(async (path) => {
|
|
7114
|
-
const file =
|
|
7115
|
-
const rel = relative(ctx.root, file);
|
|
7116
|
-
if (rel === "" || rel.startsWith("..") || isAbsolute(rel)) throw new HttpError(400, `${path} is outside the data folder`);
|
|
7125
|
+
const file = dataFile(ctx, path);
|
|
7117
7126
|
if (!changed.has(path)) throw new HttpError(400, `${path} is the same as on the default branch`);
|
|
7118
7127
|
const content = await from.file(path).catch(notFound);
|
|
7119
7128
|
if (content === null && existsSync(file) && lstatSync(file).isDirectory()) throw new HttpError(409, `${path} is a folder; remove it with git`);
|
|
@@ -7138,15 +7147,18 @@ const gitRoutes = (router, ctx) => {
|
|
|
7138
7147
|
const git = ctx.git;
|
|
7139
7148
|
if (!git) throw new HttpError(404, "the data folder is not in a git repository");
|
|
7140
7149
|
const path = query.get("path") ?? "";
|
|
7141
|
-
|
|
7142
|
-
if (rel === "" || rel.startsWith("..") || isAbsolute(rel)) throw new HttpError(400, `${path} is outside the data folder`);
|
|
7150
|
+
dataFile(ctx, path);
|
|
7143
7151
|
const found = await recordChanges(git, ctx.root, ctx.y.tables, path).catch(notFound);
|
|
7144
7152
|
if (!found?.records) throw new HttpError(404, `${path} holds no records to compare`);
|
|
7145
7153
|
return { records: found.records.map((r) => {
|
|
7146
7154
|
const keyField = ctx.y.tables.find((t) => t.name === found.table)?.key ?? "";
|
|
7147
7155
|
const before = r.before ? withoutKey(r.before, keyField) : {};
|
|
7148
7156
|
const after = r.after ? withoutKey(r.after, keyField) : {};
|
|
7149
|
-
const fields =
|
|
7157
|
+
const fields = r.kind === "modified" ? fieldChanges(before, after).map((c) => ({
|
|
7158
|
+
field: c.path,
|
|
7159
|
+
from: wireValue(c.from),
|
|
7160
|
+
to: wireValue(c.to)
|
|
7161
|
+
})) : [.../* @__PURE__ */ new Set([...Object.keys(after), ...Object.keys(before)])].map((field) => ({
|
|
7150
7162
|
field,
|
|
7151
7163
|
from: wireValue(own$1(before, field) ?? null),
|
|
7152
7164
|
to: wireValue(own$1(after, field) ?? null)
|
|
@@ -7245,9 +7257,7 @@ const gitRoutes = (router, ctx) => {
|
|
|
7245
7257
|
if (items.length === 0 && paths.length === 0) throw new HttpError(400, "choose at least one record or file", { field: "records" });
|
|
7246
7258
|
const changed = new Map(paths.length > 0 ? (await git.status()).changes.map((c) => [c.path, c.status]) : []);
|
|
7247
7259
|
const files = await Promise.all(paths.map(async (path) => {
|
|
7248
|
-
const file =
|
|
7249
|
-
const rel = relative(ctx.root, file);
|
|
7250
|
-
if (rel === "" || rel.startsWith("..") || isAbsolute(rel)) throw new HttpError(400, `${path} is outside the data folder`);
|
|
7260
|
+
const file = dataFile(ctx, path);
|
|
7251
7261
|
const status = changed.get(path);
|
|
7252
7262
|
if (status === void 0) throw new HttpError(400, `${path} has no changes`);
|
|
7253
7263
|
const content = await git.baseFile(path).catch(notFound);
|
|
@@ -7321,6 +7331,12 @@ function shownFile(file) {
|
|
|
7321
7331
|
if (!s.isFile()) return s.isSymbolicLink() ? "(a symbolic link)" : null;
|
|
7322
7332
|
return s.size > DRAFT_FILE_BYTES ? OMITTED : shownText(readFileSync(file, "utf8"));
|
|
7323
7333
|
}
|
|
7334
|
+
function dataFile(ctx, path) {
|
|
7335
|
+
const file = resolve(ctx.root, path);
|
|
7336
|
+
const rel = relative(ctx.root, file);
|
|
7337
|
+
if (!(rel !== "" && !rel.startsWith("..") && !isAbsolute(rel)) && ownerOf(ctx.y.tables, file) === null) throw new HttpError(400, `${path} is outside the data folder`);
|
|
7338
|
+
return file;
|
|
7339
|
+
}
|
|
7324
7340
|
function notFound(e) {
|
|
7325
7341
|
if (e instanceof NoRepository) throw new HttpError(404, e.message);
|
|
7326
7342
|
throw e;
|
|
@@ -8813,4 +8829,4 @@ async function open(options) {
|
|
|
8813
8829
|
};
|
|
8814
8830
|
}
|
|
8815
8831
|
//#endregion
|
|
8816
|
-
export {
|
|
8832
|
+
export { declaredViews as $, EventHub as A, loopbackHosts as B, which as C, PageSql as D, worthShowing as E, toWire as F, readsFile as G, CONFIG_NAMES as H, Router as I, MAX_PAGE_FILE_BYTES as J, resolveConfig as K, createHandler as L, ProposalStore as M, readRecord as N, isRead as O, assertSynced as P, normalizeFilePath as Q, HttpError as R, gitStatus as S, fieldChanges as T, configPath as U, check as V, parseConfig as W, entryCovers as X, deniedFile as Y, fileGranted as Z, DIFF_LIMIT as _, query as a, gitDiff as b, exportSite as c, validateNewTable as d, Store as et, ownerOf as f, templatePath as g, STEP_KINDS as h, formatTable as i, deniedFiles as j, statementCount as k, ROUTES as l, localDriver as m, formatCsv as n, generateConfig as o, ReviewRefused as p, DENIED_FILES as q, formatJson as r, init as s, open as t, COLUMN_TYPES as tt, createTable as u, ghReady as v, describeChange as w, gitLog as x, gitBranches as y, isLoopback as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as declaredViews, A as EventHub, C as which, D as PageSql, F as toWire, I as Router, K as resolveConfig, M as ProposalStore, N as readRecord, O as isRead, P as assertSynced, R as HttpError, S as gitStatus, U as configPath, V as check, X as entryCovers, Y as deniedFile, Z as fileGranted, _ as DIFF_LIMIT, b as gitDiff, d as validateNewTable, et as Store, f as ownerOf, h as STEP_KINDS, j as deniedFiles, k as statementCount, l as ROUTES, m as localDriver, t as open, tt as COLUMN_TYPES, u as createTable, v as ghReady, x as gitLog, y as gitBranches } from "./src-EgLryo0T.mjs";
|
|
2
2
|
import { dirname, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { randomBytes } from "node:crypto";
|
|
@@ -885,7 +885,7 @@ async function createWorkspace(o) {
|
|
|
885
885
|
dry = new Store(config.db);
|
|
886
886
|
let probed;
|
|
887
887
|
const gh = () => probed ??= o.gh !== void 0 ? Promise.resolve(o.gh) : ghReady().then((ok) => ok ? which("gh") : null);
|
|
888
|
-
const git = o.git === void 0 ? await localDriver(o.root, gh) : o.git;
|
|
888
|
+
const git = o.git === void 0 ? await localDriver(o.root, gh, (file) => ownerOf(y.tables, file) !== null) : o.git;
|
|
889
889
|
const proposals = new ProposalStore({
|
|
890
890
|
store,
|
|
891
891
|
dry,
|