superprint 1.0.57 → 1.0.58

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/cli.mjs +21 -6
  2. package/package.json +1 -1
package/cli.mjs CHANGED
@@ -6,7 +6,7 @@
6
6
  // Works identically on Windows, macOS and Linux.
7
7
  // ═══════════════════════════════════════════════════════════════
8
8
  import { spawn, spawnSync } from 'node:child_process';
9
- import { createWriteStream, existsSync, mkdirSync, readFileSync, statSync, writeFileSync, unlinkSync } from 'node:fs';
9
+ import { createWriteStream, existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync, unlinkSync } from 'node:fs';
10
10
  import { get as httpsGet } from 'node:https';
11
11
  import { pipeline } from 'node:stream/promises';
12
12
  import path from 'node:path';
@@ -142,6 +142,18 @@ function isInstalled() {
142
142
  function installedVersion() {
143
143
  try { return readFileSync(VERSION_FILE, 'utf8').trim(); } catch { return null; }
144
144
  }
145
+ function dependenciesReady() {
146
+ return [
147
+ path.join(APP_DIR, 'node_modules', 'vite', 'bin', 'vite.js'),
148
+ path.join(APP_DIR, 'node_modules', '@mlc-ai', 'web-llm', 'package.json'),
149
+ path.join(APP_DIR, 'node_modules', '@e965', 'xlsx', 'package.json')
150
+ ].every(existsSync);
151
+ }
152
+ function runNpmInstall() {
153
+ return spawnSync('npm', ['install', '--no-audit', '--no-fund'], {
154
+ stdio: 'inherit', cwd: APP_DIR, shell: true
155
+ });
156
+ }
145
157
 
146
158
  // ── Main ──────────────────────────────────────────────────────
147
159
  async function main() {
@@ -200,15 +212,18 @@ async function main() {
200
212
  }
201
213
 
202
214
  // ---- Step 4/4: npm install if needed ----
203
- if (!existsSync(path.join(APP_DIR, 'node_modules'))) {
215
+ if (!dependenciesReady()) {
204
216
  step(4, 'Installing dependencies (npm install)');
205
217
  info('First install: a few minutes. Subsequent launches will be instant.');
206
218
  // shell:true needed on Windows to launch npm (the .cmd wrappers
207
219
  // fail with EINVAL via spawnSync without shell).
208
- const r = spawnSync('npm', ['install', '--no-audit', '--no-fund'], {
209
- stdio: 'inherit', cwd: APP_DIR, shell: true
210
- });
211
- if (r.status !== 0) { fail('npm install failed.'); process.exit(1); }
220
+ let install = runNpmInstall();
221
+ if (install.status !== 0) {
222
+ warn('The dependency folder is incomplete. Cleaning it and retrying once.');
223
+ try { rmSync(path.join(APP_DIR, 'node_modules'), { recursive: true, force: true }); } catch (_) {}
224
+ install = runNpmInstall();
225
+ }
226
+ if (install.status !== 0 || !dependenciesReady()) { fail('npm install failed.'); process.exit(1); }
212
227
  // npm 12+ blocks install scripts (e.g. esbuild needs its postinstall
213
228
  // to place its native binary). We approve all: this is our own
214
229
  // trusted application.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superprint",
3
- "version": "1.0.57",
3
+ "version": "1.0.58",
4
4
  "description": "SuperPrint by 2.13 — free, local-first browser DTP and prepress editor with the SP213 AI layout studio.",
5
5
  "keywords": [
6
6
  "superprint",