@geml/logseq-sync 2.0.4 → 2.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geml/logseq-sync",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -280,13 +280,13 @@ function resolveGraphOrExit() {
280
280
  if (detected?.candidates) {
281
281
  console.error(
282
282
  `Error: several graphs and none open in the app — ${detected.candidates.join(", ")}. ` +
283
- `Pick one with --graph <name>.`
283
+ `Pick one with --graph <name>. Run \`logseq-sync doctor\` for the full picture.`
284
284
  );
285
285
  process.exit(2);
286
286
  }
287
287
  console.error(
288
288
  `Error: no Logseq graphs found under ${join(logseqRootDir(probe), "graphs")}. ` +
289
- `Open a graph in Logseq first, or name one with --graph <name>.`
289
+ `Open a graph in Logseq first. Run \`logseq-sync doctor\` for the full picture.`
290
290
  );
291
291
  process.exit(2);
292
292
  }
@@ -295,7 +295,8 @@ function resolveVaultOrExit() {
295
295
  if (vaultRaw) return resolve(expandHome(vaultRaw));
296
296
  console.error(
297
297
  `Error: no vault directory. Set it in Logseq — Settings → Plugins → ${PLUGIN_TITLE} → ` +
298
- `"Vault folder" — or pass one: logseq-sync <vault-dir>.`
298
+ `"Vault folder" — or pass one: logseq-sync <vault-dir>. ` +
299
+ `Run \`logseq-sync doctor\` for the full picture.`
299
300
  );
300
301
  process.exit(2);
301
302
  }
@@ -407,13 +408,24 @@ if (!/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/.test(graphName)) {
407
408
 
408
409
  // `logseq graph export --graph <name>` does not fail on an unknown name — it
409
410
  // CREATES that graph and exports the empty result. A typo would then sync
410
- // emptiness over the vault and commit it. Refuse names we cannot see on disk.
411
- // An unreadable graphs directory yields an empty list; that is "I do not know",
412
- // not "it is missing", so the check only fires when we did find graphs.
413
- if (knownGraphs.length > 0 && !knownGraphs.includes(graphName)) {
411
+ // emptiness over the vault and commit it. Refuse names we cannot see,
412
+ // INCLUDING when we see none at all: a bare run calls zero graphs a hard
413
+ // error, and naming one does not make graphs exist treating the same state
414
+ // as "cannot verify, proceed" is how `--graph demo` once sailed past this
415
+ // check straight into the vault error, and reads as a contradiction. The
416
+ // escape hatches are real, not hypothetical: LOGSEQ_ROOT_DIR when the graphs
417
+ // live elsewhere, and the API-server route, which exports whatever graph the
418
+ // app has open and ignores local directories entirely.
419
+ if (!apiServerToken && !knownGraphs.includes(graphName)) {
414
420
  console.error(
415
- `Error: no graph named "${graphName}" — found ${knownGraphs.join(", ")}. ` +
416
- `(The app CLI would silently create "${graphName}" rather than fail.)`
421
+ knownGraphs.length > 0
422
+ ? `Error: no graph named "${graphName}" found ${knownGraphs.join(", ")}. ` +
423
+ `(The app CLI would silently create "${graphName}" rather than fail.) ` +
424
+ `Run \`logseq-sync doctor\` for the full picture.`
425
+ : `Error: no graph named "${graphName}" — no graphs found under ` +
426
+ `${join(logseqRootDir(probe), "graphs")} at all, and the app CLI would silently ` +
427
+ `create "${graphName}" and sync emptiness. If your graphs live elsewhere, set ` +
428
+ `LOGSEQ_ROOT_DIR. Run \`logseq-sync doctor\` for the full picture.`
417
429
  );
418
430
  process.exit(2);
419
431
  }