@larkup/cli 0.2.28 → 0.2.30

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.
@@ -3,7 +3,7 @@ import {
3
3
  getAnalyticsSummary,
4
4
  readUsageEvents,
5
5
  trackUsageEvent
6
- } from "./chunk-JZ3UCEGF.js";
6
+ } from "./chunk-T2XKBURE.js";
7
7
  import "./chunk-QGM4M3NI.js";
8
8
  export {
9
9
  estimateCost,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getToolById,
3
3
  invalidateRegistryCache
4
- } from "./chunk-5UWKP64Q.js";
4
+ } from "./chunk-YUC4VMEE.js";
5
5
  import {
6
6
  __require
7
7
  } from "./chunk-QGM4M3NI.js";
@@ -27,7 +27,8 @@ function serializePackageMutation(fn) {
27
27
  return run;
28
28
  }
29
29
  function getToolsDir() {
30
- return path.join(process.cwd(), ".larkup", "tools");
30
+ const dataDir = process.env.LARKUP_DATA_DIR?.trim();
31
+ return path.join(dataDir ? path.resolve(dataDir) : path.join(process.cwd(), ".larkup"), "tools");
31
32
  }
32
33
  function getManifestPath() {
33
34
  return path.join(getToolsDir(), "installed.json");
@@ -451,7 +452,7 @@ async function uninstallTool(toolId) {
451
452
  }
452
453
  }
453
454
  invalidateRegistryCache();
454
- const { unloadTool: unloadTool2 } = await import("./tool-loader-PEQZZWTB.js");
455
+ const { unloadTool: unloadTool2 } = await import("./tool-loader-2WHU3H77.js");
455
456
  unloadTool2(toolId);
456
457
  } finally {
457
458
  uninstallingTools.delete(toolId);
@@ -575,7 +576,7 @@ function unloadTool(toolId) {
575
576
  moduleCache.delete(toolId);
576
577
  }
577
578
  async function hasCapability(capability) {
578
- const { getToolsWithCapability } = await import("./tool-registry-VJYLRXKJ.js");
579
+ const { getToolsWithCapability } = await import("./tool-registry-JS5NUNN6.js");
579
580
  const tools = await getToolsWithCapability(capability);
580
581
  for (const t of tools) {
581
582
  const installed = await getInstalledTool(t.id);
@@ -55,12 +55,17 @@ var DEFAULT_CONFIG = {
55
55
  };
56
56
 
57
57
  // ../../packages/core/src/project-store.ts
58
- var LARKUP_ROOT = path.join(process.cwd(), ".larkup");
59
- var PROJECTS_DIR = path.join(LARKUP_ROOT, "projects");
60
58
  var BASE_PORT = 8080;
61
59
  var EMPTY_WORKSPACE = { activeProjectId: null, projects: [] };
62
60
  var projectScope = new AsyncLocalStorage();
63
61
  var writeChain = Promise.resolve();
62
+ function getLarkupDataDir() {
63
+ const configured = process.env.LARKUP_DATA_DIR?.trim();
64
+ return configured ? path.resolve(configured) : path.join(process.cwd(), ".larkup");
65
+ }
66
+ function projectsDir() {
67
+ return path.join(getLarkupDataDir(), "projects");
68
+ }
64
69
  function serialize(operation) {
65
70
  const run = writeChain.then(operation, operation);
66
71
  writeChain = run.catch(() => void 0);
@@ -68,12 +73,12 @@ function serialize(operation) {
68
73
  }
69
74
  async function readWorkspaceFile() {
70
75
  try {
71
- const entries = await fs.readdir(PROJECTS_DIR, { withFileTypes: true });
76
+ const entries = await fs.readdir(projectsDir(), { withFileTypes: true });
72
77
  const projects = await Promise.all(
73
78
  entries.filter((entry) => entry.isDirectory()).map(async (entry) => {
74
79
  try {
75
80
  return JSON.parse(
76
- await fs.readFile(path.join(PROJECTS_DIR, entry.name, "project.json"), "utf8")
81
+ await fs.readFile(path.join(projectsDir(), entry.name, "project.json"), "utf8")
77
82
  );
78
83
  } catch {
79
84
  return null;
@@ -91,7 +96,7 @@ async function readWorkspaceFile() {
91
96
  }
92
97
  }
93
98
  async function writeWorkspaceFile(workspace) {
94
- await fs.mkdir(PROJECTS_DIR, { recursive: true });
99
+ await fs.mkdir(projectsDir(), { recursive: true });
95
100
  await Promise.all(
96
101
  workspace.projects.map(async (project) => {
97
102
  const persisted = { ...project, active: project.id === workspace.activeProjectId };
@@ -122,13 +127,14 @@ function slugify(name) {
122
127
  return name.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "my-larkup";
123
128
  }
124
129
  function initialConfig(project) {
130
+ const configuredDataRoot = process.env.LARKUP_DATA_DIR?.trim();
125
131
  return {
126
132
  ...DEFAULT_CONFIG,
127
133
  projectName: slugify(project.name),
128
134
  storeConfig: {
129
135
  ...DEFAULT_CONFIG.storeConfig,
130
136
  mode: "local",
131
- dbPath: `./.larkup/projects/${project.id}/index`
137
+ dbPath: configuredDataRoot ? path.join(getLarkupDataDir(), "projects", project.id, "index") : `./.larkup/projects/${project.id}/index`
132
138
  },
133
139
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
134
140
  };
@@ -137,7 +143,7 @@ function runWithProject(projectId, operation) {
137
143
  return projectScope.run({ projectId }, operation);
138
144
  }
139
145
  function projectDir(projectId) {
140
- return path.join(PROJECTS_DIR, projectId);
146
+ return path.join(projectsDir(), projectId);
141
147
  }
142
148
  async function getProjectWorkspace() {
143
149
  return readWorkspaceFile();
@@ -177,21 +183,35 @@ function createProject(name) {
177
183
  const dir = projectDir(project.id);
178
184
  await fs.mkdir(path.join(dir, "releases"), { recursive: true });
179
185
  await Promise.all([
180
- fs.writeFile(path.join(dir, "project.json"), JSON.stringify({ ...project, active: true }, null, 2), "utf8"),
186
+ fs.writeFile(
187
+ path.join(dir, "project.json"),
188
+ JSON.stringify({ ...project, active: true }, null, 2),
189
+ "utf8"
190
+ ),
181
191
  fs.writeFile(
182
192
  path.join(dir, "config.json"),
183
193
  JSON.stringify(initialConfig(project), null, 2),
184
194
  "utf8"
185
195
  ),
186
- fs.writeFile(path.join(dir, "groups.json"), JSON.stringify([{
187
- id: "default",
188
- name: "Default",
189
- description: "Sources added without a specific group.",
190
- icon: "\u{1F4DA}",
191
- assistantEnabled: true,
192
- createdAt: now,
193
- updatedAt: now
194
- }], null, 2), "utf8"),
196
+ fs.writeFile(
197
+ path.join(dir, "groups.json"),
198
+ JSON.stringify(
199
+ [
200
+ {
201
+ id: "default",
202
+ name: "Default",
203
+ description: "Sources added without a specific group.",
204
+ icon: "\u{1F4DA}",
205
+ assistantEnabled: true,
206
+ createdAt: now,
207
+ updatedAt: now
208
+ }
209
+ ],
210
+ null,
211
+ 2
212
+ ),
213
+ "utf8"
214
+ ),
195
215
  fs.writeFile(path.join(dir, "documents.json"), "[]\n", "utf8"),
196
216
  fs.writeFile(path.join(dir, "deployments.json"), "[]\n", "utf8"),
197
217
  fs.writeFile(path.join(dir, "automations.json"), "[]\n", "utf8"),
@@ -214,11 +234,12 @@ function setActiveProject(projectId) {
214
234
  });
215
235
  }
216
236
  async function resetLocalProjects(confirmedPath) {
217
- if (confirmedPath !== PROJECTS_DIR) {
218
- throw new Error(`Confirmation must exactly match ${PROJECTS_DIR}.`);
237
+ const target = projectsDir();
238
+ if (confirmedPath !== target) {
239
+ throw new Error(`Confirmation must exactly match ${target}.`);
219
240
  }
220
241
  await serialize(async () => {
221
- await fs.rm(PROJECTS_DIR, { recursive: true, force: true });
242
+ await fs.rm(target, { recursive: true, force: true });
222
243
  });
223
244
  }
224
245
 
@@ -7010,6 +7031,7 @@ async function getAnalyticsSummary(days, runtime = "all") {
7010
7031
 
7011
7032
  export {
7012
7033
  DEFAULT_CONFIG,
7034
+ getLarkupDataDir,
7013
7035
  runWithProject,
7014
7036
  getProjectWorkspace,
7015
7037
  getActiveProject,