gm-plugkit 2.0.1992 → 2.0.1993

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/bootstrap.js CHANGED
@@ -7,7 +7,7 @@ const os = require('os');
7
7
  const crypto = require('crypto');
8
8
  const { spawn, spawnSync } = require('child_process');
9
9
  const { logEvent: _sharedLogEvent } = require('./gm-log');
10
- const { pidCommandLineForKillGuard: _sharedPidCommandLine } = require('./gm-process');
10
+ const { pidCommandLineForKillGuard: _sharedPidCommandLine, ensureDir, pidAlive, sha256OfFile, sha256OfFileSync } = require('./gm-process');
11
11
 
12
12
  function resolveWindowsExe(cmd) {
13
13
  if (process.platform !== 'win32') return cmd;
@@ -311,28 +311,6 @@ function readShaManifest() {
311
311
  return out;
312
312
  }
313
313
 
314
- function sha256OfFileSync(filePath) {
315
- const h = crypto.createHash('sha256');
316
- const fd = fs.openSync(filePath, 'r');
317
- try {
318
- const buf = Buffer.alloc(1024 * 1024);
319
- for (;;) {
320
- const n = fs.readSync(fd, buf, 0, buf.length, null);
321
- if (n <= 0) break;
322
- h.update(buf.subarray(0, n));
323
- }
324
- } finally { try { fs.closeSync(fd); } catch (_) {} }
325
- return h.digest('hex');
326
- }
327
-
328
- function ensureDir(dir) {
329
- fs.mkdirSync(dir, { recursive: true });
330
- }
331
-
332
- function pidAlive(pid) {
333
- try { process.kill(pid, 0); return true; } catch (e) { return e.code === 'EPERM'; }
334
- }
335
-
336
314
  function acquireLock(lockPath) {
337
315
  const start = Date.now();
338
316
  for (;;) {
@@ -364,16 +342,6 @@ function releaseLock(lockPath) {
364
342
  try { fs.unlinkSync(lockPath); } catch (_) {}
365
343
  }
366
344
 
367
- function sha256OfFile(filePath) {
368
- return new Promise((resolve, reject) => {
369
- const h = crypto.createHash('sha256');
370
- const s = fs.createReadStream(filePath);
371
- s.on('data', c => h.update(c));
372
- s.on('end', () => resolve(h.digest('hex')));
373
- s.on('error', reject);
374
- });
375
- }
376
-
377
345
  function resolveNpxJsCli() {
378
346
  if (process.platform !== 'win32') return null;
379
347
  const candidates = [];
package/gm-process.js CHANGED
@@ -1,7 +1,44 @@
1
1
  'use strict';
2
2
 
3
+ const fs = require('fs');
4
+ const crypto = require('crypto');
3
5
  const { spawnSync } = require('child_process');
4
6
 
7
+ // Pure-leaf helpers shared byte-for-byte between bin/bootstrap.js and
8
+ // gm-plugkit/bootstrap.js (they were identical inline copies in both). Only
9
+ // node builtins, no bootstrap-local state -- safe to centralize here.
10
+ function ensureDir(dir) {
11
+ fs.mkdirSync(dir, { recursive: true });
12
+ }
13
+
14
+ function pidAlive(pid) {
15
+ try { process.kill(pid, 0); return true; } catch (e) { return e.code === 'EPERM'; }
16
+ }
17
+
18
+ function sha256OfFile(filePath) {
19
+ return new Promise((resolve, reject) => {
20
+ const h = crypto.createHash('sha256');
21
+ const s = fs.createReadStream(filePath);
22
+ s.on('data', c => h.update(c));
23
+ s.on('end', () => resolve(h.digest('hex')));
24
+ s.on('error', reject);
25
+ });
26
+ }
27
+
28
+ function sha256OfFileSync(filePath) {
29
+ const h = crypto.createHash('sha256');
30
+ const fd = fs.openSync(filePath, 'r');
31
+ try {
32
+ const buf = Buffer.alloc(1024 * 1024);
33
+ for (;;) {
34
+ const n = fs.readSync(fd, buf, 0, buf.length, null);
35
+ if (n <= 0) break;
36
+ h.update(buf.subarray(0, n));
37
+ }
38
+ } finally { try { fs.closeSync(fd); } catch (_) {} }
39
+ return h.digest('hex');
40
+ }
41
+
5
42
  function pidCommandLineForKillGuard(pid) {
6
43
  try {
7
44
  if (process.platform === 'win32') {
@@ -31,4 +68,4 @@ function waitForPidDeath(pid, timeoutMs) {
31
68
  return !pidAliveSync(pid);
32
69
  }
33
70
 
34
- module.exports = { pidCommandLineForKillGuard, pidAliveSync, waitForPidDeath };
71
+ module.exports = { ensureDir, pidAlive, sha256OfFile, sha256OfFileSync, pidCommandLineForKillGuard, pidAliveSync, waitForPidDeath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-plugkit",
3
- "version": "2.0.1992",
3
+ "version": "2.0.1993",
4
4
  "description": "Bootstrap and daemon-spawn tool for gm plugkit binary. Downloads the correct platform binary, verifies SHA256, and starts the spool watcher daemon. Includes plugkit-wasm-wrapper for WASM-based spool watching.",
5
5
  "main": "index.js",
6
6
  "bin": {