@mean-weasel/lineage 0.1.10 → 0.1.11

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.
@@ -289,7 +289,7 @@ function isPackageRoot(path) {
289
289
  return false;
290
290
  }
291
291
  }
292
- function resolveRepoRoot() {
292
+ function resolvePackageRoot() {
293
293
  const moduleDir = dirname2(fileURLToPath(import.meta.url));
294
294
  const candidates = [
295
295
  process.env.LINEAGE_REPO_ROOT,
@@ -301,7 +301,12 @@ function resolveRepoRoot() {
301
301
  if (!root) throw new Error("Unable to locate Lineage package root");
302
302
  return root;
303
303
  }
304
- var repoRoot = resolveRepoRoot();
304
+ var packageRoot = resolvePackageRoot();
305
+ var repoRoot = resolve2(process.env.LINEAGE_ASSET_ROOT || packageRoot);
306
+ function setLineageAssetRoot(path) {
307
+ repoRoot = resolve2(path || packageRoot);
308
+ return repoRoot;
309
+ }
305
310
  var defaultProject = "demo-project";
306
311
  var defaultProduct = process.env.LINEAGE_DEFAULT_PRODUCT || defaultProject;
307
312
  var publicFallbackBucket = "lineage-demo-assets";
@@ -326,7 +331,7 @@ function catalogPath(project = defaultProject) {
326
331
  return join3(repoRoot, cleanProject(project), "assets", "catalog.json");
327
332
  }
328
333
  function fixtureCatalogPath(project = defaultProject) {
329
- return join3(repoRoot, "fixtures", cleanProject(project), "assets", "catalog.json");
334
+ return join3(packageRoot, "fixtures", cleanProject(project), "assets", "catalog.json");
330
335
  }
331
336
  function resolvedCatalogPath(project = defaultProject) {
332
337
  const path = catalogPath(project);
@@ -588,7 +593,7 @@ function nowIso() {
588
593
  return (/* @__PURE__ */ new Date()).toISOString();
589
594
  }
590
595
  function lineageDbPath() {
591
- return process.env.LINEAGE_DB || join4(repoRoot, ".lineage", "asset-lineage.sqlite");
596
+ return process.env.LINEAGE_DB || join4(packageRoot, ".lineage", "asset-lineage.sqlite");
592
597
  }
593
598
  function lineageDb() {
594
599
  mkdirSync3(join4(lineageDbPath(), ".."), { recursive: true });
@@ -3601,7 +3606,7 @@ import { join as join6 } from "node:path";
3601
3606
  var require3 = createRequire2(import.meta.url);
3602
3607
  function packageInfo() {
3603
3608
  try {
3604
- const info = JSON.parse(readFileSync3(join6(repoRoot, "package.json"), "utf8"));
3609
+ const info = JSON.parse(readFileSync3(join6(packageRoot, "package.json"), "utf8"));
3605
3610
  return { name: info.name || "@mean-weasel/lineage", version: info.version || "0.0.0" };
3606
3611
  } catch {
3607
3612
  return { name: "@mean-weasel/lineage", version: "0.0.0" };
@@ -3617,8 +3622,8 @@ function normalizeRuntimeChannel(value) {
3617
3622
  function gitSha() {
3618
3623
  const envSha = process.env.LINEAGE_GIT_SHA || process.env.GITHUB_SHA;
3619
3624
  if (envSha) return envSha.slice(0, 40);
3620
- if (!existsSync6(join6(repoRoot, ".git"))) return void 0;
3621
- const result = spawnSync2("git", ["rev-parse", "--short=12", "HEAD"], { cwd: repoRoot, encoding: "utf8" });
3625
+ if (!existsSync6(join6(packageRoot, ".git"))) return void 0;
3626
+ const result = spawnSync2("git", ["rev-parse", "--short=12", "HEAD"], { cwd: packageRoot, encoding: "utf8" });
3622
3627
  return result.status === 0 ? result.stdout.trim() || void 0 : void 0;
3623
3628
  }
3624
3629
  function tableExists(database, table) {
@@ -3651,6 +3656,7 @@ function getLineageRuntimeInfo(options = {}) {
3651
3656
  }
3652
3657
  }
3653
3658
  return {
3659
+ asset_root: repoRoot,
3654
3660
  channel: normalizeRuntimeChannel(options.channel || process.env.LINEAGE_CHANNEL || process.env.LINEAGE_RELEASE_CHANNEL),
3655
3661
  database: databaseInfo,
3656
3662
  fetchedAt: nowIso(),
@@ -3666,12 +3672,12 @@ var signalExitCodes = {
3666
3672
  SIGINT: 130,
3667
3673
  SIGTERM: 143
3668
3674
  };
3669
- function packageRoot() {
3675
+ function packageRoot2() {
3670
3676
  return resolve5(dirname3(fileURLToPath2(import.meta.url)), "..", "..");
3671
3677
  }
3672
3678
  function packageVersion() {
3673
3679
  try {
3674
- const packageInfo2 = JSON.parse(readFileSync4(join7(packageRoot(), "package.json"), "utf8"));
3680
+ const packageInfo2 = JSON.parse(readFileSync4(join7(packageRoot2(), "package.json"), "utf8"));
3675
3681
  return packageInfo2.version || "0.0.0";
3676
3682
  } catch {
3677
3683
  return "0.0.0";
@@ -3711,6 +3717,7 @@ function resolveStartOptions(config, args) {
3711
3717
  throw new Error(`Invalid port: ${rawPort}`);
3712
3718
  }
3713
3719
  return {
3720
+ assetRoot: resolveCliAssetRoot(args),
3714
3721
  dbPath: resolveCliDbPath(config, args),
3715
3722
  host: readOption(args, "--host") || process.env.HOST || config.defaultHost,
3716
3723
  json: args.includes("--json"),
@@ -3718,6 +3725,14 @@ function resolveStartOptions(config, args) {
3718
3725
  port
3719
3726
  };
3720
3727
  }
3728
+ function resolveCliAssetRoot(args) {
3729
+ return resolve5(readOption(args, "--asset-root") || process.env.LINEAGE_ASSET_ROOT || packageRoot);
3730
+ }
3731
+ function configureCliAssetRoot(args) {
3732
+ const assetRoot = resolveCliAssetRoot(args);
3733
+ process.env.LINEAGE_ASSET_ROOT = assetRoot;
3734
+ return setLineageAssetRoot(assetRoot);
3735
+ }
3721
3736
  function resolveCliDbPath(config, args) {
3722
3737
  return readOption(args, "--db") || process.env.LINEAGE_DB || join7(dataRoot(config.displayName), `${config.binName}.sqlite`);
3723
3738
  }
@@ -3725,7 +3740,7 @@ function formatLineageHelp(config) {
3725
3740
  return `${config.binName} ${packageVersion()}
3726
3741
 
3727
3742
  Usage:
3728
- ${config.binName} start [--port <port>] [--host <host>] [--db <path>] [--open] [--json]
3743
+ ${config.binName} start [--port <port>] [--host <host>] [--db <path>] [--asset-root <path>] [--open] [--json]
3729
3744
  ${config.binName} next [--project <project>] [--root <asset-id>] [--db <path>] [--json]
3730
3745
  ${config.binName} brief [--project <project>] [--root <asset-id>] [--db <path>] [--json]
3731
3746
  ${config.binName} inspect --asset-id <asset-id> [--project <project>] [--db <path>] [--json]
@@ -3758,6 +3773,9 @@ Usage:
3758
3773
 
3759
3774
  ${config.displayName} runs the bundled Lineage server for the ${config.channel} channel.
3760
3775
 
3776
+ Asset catalogs and local media default to the installed package root. Pass
3777
+ --asset-root <path> or LINEAGE_ASSET_ROOT to use an external project root.
3778
+
3761
3779
  Variation vs re-roll:
3762
3780
  link-child creates a new visible child variation edge.
3763
3781
  reroll mark -> reroll plan -> reroll import updates the same node with a new attempt.`;
@@ -3784,6 +3802,7 @@ function positionalArgs(args) {
3784
3802
  return values;
3785
3803
  }
3786
3804
  function resolveDataCommandOptions(args) {
3805
+ configureCliAssetRoot(args);
3787
3806
  const positions = positionalArgs(args);
3788
3807
  const options = {
3789
3808
  assetId: readOption(args, "--asset-id") || positions[0],
@@ -4030,6 +4049,7 @@ function printDataResult(command, result, json) {
4030
4049
  console.log(String(result));
4031
4050
  }
4032
4051
  function runLineageDbCommand(config, command, args) {
4052
+ configureCliAssetRoot(args);
4033
4053
  const dbPath = resolveCliDbPath(config, args);
4034
4054
  process.env.LINEAGE_DB = dbPath;
4035
4055
  if (command === "info") return getLineageRuntimeInfo({ channel: config.channel, dbPath });
@@ -4046,6 +4066,7 @@ function printDbResult(command, result, json) {
4046
4066
  console.log(`Version: ${runtime.version}`);
4047
4067
  if (runtime.git_sha) console.log(`Git: ${runtime.git_sha}`);
4048
4068
  if (runtime.node_env) console.log(`Node env: ${runtime.node_env}`);
4069
+ console.log(`Assets: ${runtime.asset_root}`);
4049
4070
  console.log(`SQLite: ${runtime.database.path}`);
4050
4071
  console.log(`Exists: ${runtime.database.exists ? "yes" : "no"}`);
4051
4072
  if (runtime.database.size_bytes !== void 0) console.log(`Size: ${runtime.database.size_bytes} bytes`);
@@ -4058,6 +4079,7 @@ function printDbResult(command, result, json) {
4058
4079
  console.log(String(result));
4059
4080
  }
4060
4081
  function runLineageAgentCommand(command, args) {
4082
+ configureCliAssetRoot(args);
4061
4083
  const dbPath = readOption(args, "--db");
4062
4084
  if (dbPath) process.env.LINEAGE_DB = dbPath;
4063
4085
  const project = readOption(args, "--project") || process.env.LINEAGE_DEFAULT_PRODUCT || defaultProduct;
@@ -4183,7 +4205,7 @@ function start(config, args) {
4183
4205
  else console.error(`${config.binName}: ${message}`);
4184
4206
  process.exit(1);
4185
4207
  }
4186
- const serverPath = join7(packageRoot(), "dist", "server.js");
4208
+ const serverPath = join7(packageRoot2(), "dist", "server.js");
4187
4209
  if (!existsSync7(serverPath)) {
4188
4210
  const message = `Missing bundled server at ${serverPath}. Run npm run build before using ${config.binName} start from a source checkout.`;
4189
4211
  if (options.json) console.error(JSON.stringify({ ok: false, error: message }, null, 2));
@@ -4193,16 +4215,18 @@ function start(config, args) {
4193
4215
  mkdirSync4(dirname3(options.dbPath), { recursive: true });
4194
4216
  const url = `http://${options.host}:${options.port}`;
4195
4217
  if (options.json) {
4196
- console.log(JSON.stringify({ channel: config.channel, dbPath: options.dbPath, host: options.host, port: options.port, status: "starting", url }, null, 2));
4218
+ console.log(JSON.stringify({ assetRoot: options.assetRoot, channel: config.channel, dbPath: options.dbPath, host: options.host, port: options.port, status: "starting", url }, null, 2));
4197
4219
  } else {
4198
4220
  console.log(`${config.displayName} starting at ${url}`);
4199
4221
  console.log(`SQLite: ${options.dbPath}`);
4222
+ console.log(`Assets: ${options.assetRoot}`);
4200
4223
  }
4201
4224
  if (options.open) openBrowser(url);
4202
4225
  const child = spawn(process.execPath, [serverPath], {
4203
4226
  env: {
4204
4227
  ...process.env,
4205
4228
  HOST: options.host,
4229
+ LINEAGE_ASSET_ROOT: options.assetRoot,
4206
4230
  LINEAGE_CHANNEL: config.channel,
4207
4231
  LINEAGE_DB: options.dbPath,
4208
4232
  NODE_ENV: "production",