javascript-solid-server 0.0.204 → 0.0.205

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.
@@ -11,7 +11,18 @@
11
11
  "Bash(gh pr create --title 'docs: Account Management page \\(change password, backup/export, delete\\) — closes #23' --body ' *)",
12
12
  "Bash(gh pr *)",
13
13
  "Bash(git checkout *)",
14
- "Bash(git pull *)"
14
+ "Bash(git pull *)",
15
+ "Bash(gh api *)",
16
+ "Bash(git fetch *)",
17
+ "Bash(grep *)",
18
+ "Bash(node --check src/cli/install.js)",
19
+ "Bash(git commit -q -m 'fix\\(install\\): drop spawnSync\\('\\\\''rm'\\\\''\\) shell-out for fs.rmSync — works on Windows *)",
20
+ "Bash(node --test --test-concurrency=1 test/turtle.test.js)",
21
+ "Bash(npm test *)",
22
+ "Bash(git commit -q -m 'fix\\(rdf\\): preserve blank-node SUBJECTS through Turtle ↔ JSON-LD \\(#536\\) *)",
23
+ "Bash(npm view *)",
24
+ "Bash(git branch *)",
25
+ "Bash(git commit -q -m 'bump version to 0.0.205 *)"
15
26
  ]
16
27
  }
17
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javascript-solid-server",
3
- "version": "0.0.204",
3
+ "version": "0.0.205",
4
4
  "description": "A minimal, fast Solid server",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -25,8 +25,9 @@
25
25
  */
26
26
 
27
27
  import { spawnSync } from 'child_process';
28
- import { existsSync, readFileSync } from 'fs';
28
+ import { existsSync, readFileSync, rmSync } from 'fs';
29
29
  import { join, isAbsolute } from 'path';
30
+ import { tmpdir } from 'os';
30
31
  import { nip98Token } from '../nostr/event.js';
31
32
 
32
33
  // ANSI helpers — keep zero-dep so this works in any embedded usage.
@@ -221,6 +222,18 @@ async function fetchToken({ pod, user, password }) {
221
222
  }
222
223
  }
223
224
 
225
+ // Best-effort recursive cleanup of the scratch clone dir. fs.rmSync
226
+ // with `force: true` silently ignores ENOENT (so no existsSync guard
227
+ // is needed), and the try/catch absorbs the rare EBUSY / EACCES that
228
+ // can fire on Windows when an editor or antivirus still holds a
229
+ // handle inside the tree. Mirrors the original `spawnSync('rm',
230
+ // '-rf', ..., { stdio: 'ignore' })` contract: an install must not
231
+ // fail after a successful clone/push just because tmp cleanup didn't
232
+ // go through. Portable: no shell-out, no /tmp assumptions.
233
+ function cleanupTmp(tmp) {
234
+ try { rmSync(tmp, { recursive: true, force: true }); } catch { /* best-effort */ }
235
+ }
236
+
224
237
  /**
225
238
  * Install one app spec to one pod. Returns a status object the caller
226
239
  * uses for per-app output + exit-code aggregation.
@@ -228,10 +241,13 @@ async function fetchToken({ pod, user, password }) {
228
241
  async function installOne({ spec, pod, token, nostrPrivkey }) {
229
242
  const { source, name, ref } = spec;
230
243
  const dest = `${pod}/public/apps/${name}`;
231
- const tmp = join('/tmp', `jss-install-${name}-${process.pid}`);
244
+ // Respect the platform's tmp dir — '/tmp' is hardcoded out on
245
+ // Termux (Android), where the writable tmp is at $PREFIX/tmp.
246
+ // os.tmpdir() respects $TMPDIR and falls back sensibly everywhere.
247
+ const tmp = join(tmpdir(), `jss-install-${name}-${process.pid}`);
232
248
 
233
249
  // Clean any stale tmp from a prior failed run.
234
- if (existsSync(tmp)) spawnSync('rm', ['-rf', tmp], { stdio: 'ignore' });
250
+ cleanupTmp(tmp);
235
251
 
236
252
  // Clone (no --depth: shallow pushes are rejected by JSS git-receive).
237
253
  // --branch picks a tag or branch when pinned (e.g. `foo/bar#v2`).
@@ -285,7 +301,7 @@ async function installOne({ spec, pod, token, nostrPrivkey }) {
285
301
  // Auto-init refuses on a non-empty target dir → 404 / "not found".
286
302
  // Distinguish "path already in use" from real errors.
287
303
  if (pushMain.status !== 0 && (errMain.includes('not found') || errMain.includes('404'))) {
288
- spawnSync('rm', ['-rf', tmp], { stdio: 'ignore' });
304
+ cleanupTmp(tmp);
289
305
  return { name, status: 'skipped', reason: 'path already in use' };
290
306
  }
291
307
 
@@ -293,11 +309,11 @@ async function installOne({ spec, pod, token, nostrPrivkey }) {
293
309
 
294
310
  if (pushMain.status !== 0 && pushPages.status !== 0) {
295
311
  const err = (errMain + '\n' + (pushPages.stderr?.toString?.() || '')).trim();
296
- spawnSync('rm', ['-rf', tmp], { stdio: 'ignore' });
312
+ cleanupTmp(tmp);
297
313
  return { name, status: 'failed', reason: `push failed: ${err.slice(0, 400)}` };
298
314
  }
299
315
 
300
- spawnSync('rm', ['-rf', tmp], { stdio: 'ignore' });
316
+ cleanupTmp(tmp);
301
317
  return { name, status: 'installed', dest: `${dest}/` };
302
318
  }
303
319
 
package/src/rdf/turtle.js CHANGED
Binary file
@@ -12,7 +12,7 @@
12
12
 
13
13
  import { describe, it } from 'node:test';
14
14
  import assert from 'node:assert';
15
- import { fromJsonLd } from '../src/rdf/conneg.js';
15
+ import { fromJsonLd, toJsonLd } from '../src/rdf/conneg.js';
16
16
 
17
17
  describe('turtle converter — unit (#320 follow-ups)', () => {
18
18
  it('expandUri does not recurse forever on a cyclic context (a → b → a)', async () => {
@@ -258,4 +258,45 @@ describe('turtle converter — unit (#320 follow-ups)', () => {
258
258
  assert.ok(content.includes('https://example.test/a'), 'node a should appear');
259
259
  assert.ok(content.includes('https://example.test/b'), 'node b should appear');
260
260
  });
261
+
262
+ describe('blank-node subject roundtrip (#536)', () => {
263
+ const baseUri = 'https://example.test/u/c/bn.ttl';
264
+ const input = '@prefix ex: <http://example.org/> .\n<#s> ex:p [ ex:a 1 ; ex:b 2 ] .\n';
265
+
266
+ it('Turtle → JSON-LD emits blank-node SUBJECTS with the "_:" prefix', async () => {
267
+ // Previously the subject side dropped "_:", producing a bare label
268
+ // ("n3-0") that resolved as a relative IRI on read; the object side
269
+ // (termToJsonLd) already kept "_:". Result: severed graph.
270
+ const doc = await toJsonLd(input, 'text/turtle', baseUri, true);
271
+ const nodes = Array.isArray(doc) ? doc : [doc];
272
+ // The blank-node subject is the one carrying ex:a / ex:b.
273
+ const bn = nodes.find(n => 'ex:a' in n);
274
+ assert.ok(bn, 'expected a node carrying ex:a');
275
+ assert.ok(typeof bn['@id'] === 'string' && bn['@id'].startsWith('_:'),
276
+ `blank-node subject @id should start with "_:", got ${JSON.stringify(bn['@id'])}`);
277
+ });
278
+
279
+ it('Turtle → JSON-LD → Turtle preserves the blank-node connection', async () => {
280
+ // End-to-end: parse output Turtle and verify the blank node carrying
281
+ // ex:a / ex:b is the SAME node that <#s> ex:p points at — i.e. the
282
+ // graph is not severed.
283
+ const doc = await toJsonLd(input, 'text/turtle', baseUri, true);
284
+ const { content: outTurtle } = await fromJsonLd(doc, 'text/turtle', baseUri, true);
285
+
286
+ const { Parser } = await import('n3');
287
+ const quads = new Parser({ baseIRI: baseUri }).parse(outTurtle);
288
+
289
+ const pQuad = quads.find(q => q.predicate.value === 'http://example.org/p');
290
+ assert.ok(pQuad, 'ex:p triple should be present');
291
+ assert.strictEqual(pQuad.object.termType, 'BlankNode',
292
+ 'ex:p object must remain a blank node, not be promoted to a named IRI');
293
+
294
+ const aQuad = quads.find(q => q.predicate.value === 'http://example.org/a');
295
+ assert.ok(aQuad, 'ex:a triple should be present');
296
+ assert.strictEqual(aQuad.subject.termType, 'BlankNode',
297
+ 'ex:a subject must remain a blank node');
298
+ assert.strictEqual(aQuad.subject.value, pQuad.object.value,
299
+ 'the blank node carrying ex:a must be the same one ex:p references');
300
+ });
301
+ });
261
302
  });