@longtable/cli 0.1.7 → 0.1.8

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.
Files changed (2) hide show
  1. package/dist/cli.js +30 -3
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { existsSync, readFileSync, statSync } from "node:fs";
3
+ import { mkdtemp, rm } from "node:fs/promises";
3
4
  import { emitKeypressEvents } from "node:readline";
4
5
  import { createInterface } from "node:readline/promises";
5
6
  import { stdin as input, stdout as output, cwd, exit } from "node:process";
6
- import { resolve } from "node:path";
7
+ import { dirname, resolve } from "node:path";
7
8
  import { homedir } from "node:os";
8
9
  import { buildProviderChoices, buildQuickSetupFlow, createPersistedSetupOutput, installRuntimeConfigFromStoredSetup, loadSetupOutput, renderInstallSummary, renderSetupSummary, resolveDefaultRuntimeConfigPath, resolveDefaultSetupPath, saveSetupAndRuntimeConfig, serializeSetupOutput } from "@diverga/setup";
9
10
  import { buildCodexThinWrappedPrompt, runCodexThinWrapper } from "@diverga/provider-codex";
@@ -242,6 +243,29 @@ function resolveInteractiveProjectPath(parentOrPath, projectName) {
242
243
  }
243
244
  return resolve(normalized);
244
245
  }
246
+ async function verifyWritableWorkspaceParent(projectPath) {
247
+ const parentDir = dirname(resolve(projectPath));
248
+ const probePrefix = resolve(parentDir, ".longtable-permission-check-");
249
+ try {
250
+ const created = await mkdtemp(probePrefix);
251
+ await rm(created, { recursive: true, force: true });
252
+ }
253
+ catch (error) {
254
+ const message = error instanceof Error ? error.message : String(error);
255
+ throw new Error([
256
+ `Long Table could not create a project workspace under: ${parentDir}`,
257
+ "Reason: your current shell process cannot write to that parent directory.",
258
+ "",
259
+ "What to try next:",
260
+ `- test it directly: mkdir -p "${resolve(parentDir, "_longtable_write_test")}"`,
261
+ "- if that fails too, this is an OS/disk permission problem rather than a Long Table command problem",
262
+ "- try a known-writable path such as ~/Research",
263
+ "- or choose a different existing parent directory when Long Table asks where the project should live",
264
+ "",
265
+ `Original error: ${message}`
266
+ ].join("\n"));
267
+ }
268
+ }
245
269
  async function promptChoiceByNumber(rl, prompt, choices) {
246
270
  while (true) {
247
271
  const answer = await rl.question(`${prompt}\n${renderChoices(choices)}\nSelect one number: `);
@@ -930,6 +954,7 @@ async function runStart(args) {
930
954
  throw new Error("Long Table global setup is missing. Run `longtable init --flow interview` first.");
931
955
  }
932
956
  const interview = await collectProjectInterview(existingSetup, args);
957
+ await verifyWritableWorkspaceParent(interview.projectPath);
933
958
  const context = await createOrUpdateProjectWorkspace({
934
959
  projectName: interview.projectName,
935
960
  projectPath: interview.projectPath,
@@ -1101,7 +1126,9 @@ main().catch((error) => {
1101
1126
  if (message === "Setup cancelled.") {
1102
1127
  exit(1);
1103
1128
  }
1104
- console.error("");
1105
- console.error(usage());
1129
+ if (message.startsWith("Unknown command:") || message.startsWith("Invalid ")) {
1130
+ console.error("");
1131
+ console.error(usage());
1132
+ }
1106
1133
  exit(1);
1107
1134
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longtable/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "private": false,
5
5
  "description": "Researcher-facing Long Table CLI on top of the legacy Diverga package surface",
6
6
  "type": "module",