superprint 1.0.58 → 1.0.59
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/cli.mjs +13 -2
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -19,6 +19,7 @@ const isWin = process.platform === 'win32';
|
|
|
19
19
|
// ── URLs & chemins ────────────────────────────────────────────
|
|
20
20
|
const APP_VERSION_URL = 'https://superprint.cc/version.txt';
|
|
21
21
|
const APP_ZIP_URL = 'https://app.zigmoon.com/sp213-local.zip';
|
|
22
|
+
const MIN_APP_VERSION = '1.7.318';
|
|
22
23
|
const APP_DIR = path.join(os.homedir(), '.superprint', 'app');
|
|
23
24
|
const ZIP_PATH = path.join(os.homedir(), '.superprint', 'sp213-local.zip');
|
|
24
25
|
const VERSION_FILE = path.join(APP_DIR, 'version.txt');
|
|
@@ -142,6 +143,16 @@ function isInstalled() {
|
|
|
142
143
|
function installedVersion() {
|
|
143
144
|
try { return readFileSync(VERSION_FILE, 'utf8').trim(); } catch { return null; }
|
|
144
145
|
}
|
|
146
|
+
function newestVersion(first, second) {
|
|
147
|
+
const parts = version => String(version || '').split('.').map(value => parseInt(value, 10) || 0);
|
|
148
|
+
const a = parts(first);
|
|
149
|
+
const b = parts(second);
|
|
150
|
+
for (let index = 0; index < Math.max(a.length, b.length); index++) {
|
|
151
|
+
if ((a[index] || 0) > (b[index] || 0)) return first;
|
|
152
|
+
if ((a[index] || 0) < (b[index] || 0)) return second;
|
|
153
|
+
}
|
|
154
|
+
return first || second;
|
|
155
|
+
}
|
|
145
156
|
function dependenciesReady() {
|
|
146
157
|
return [
|
|
147
158
|
path.join(APP_DIR, 'node_modules', 'vite', 'bin', 'vite.js'),
|
|
@@ -164,8 +175,8 @@ async function main() {
|
|
|
164
175
|
|
|
165
176
|
// ---- Step 1/4: check online version ----
|
|
166
177
|
step(1, 'Checking online version');
|
|
167
|
-
let onlineVersion =
|
|
168
|
-
try { onlineVersion = await httpsGetText(APP_VERSION_URL); } catch (e) {}
|
|
178
|
+
let onlineVersion = MIN_APP_VERSION;
|
|
179
|
+
try { onlineVersion = newestVersion(await httpsGetText(APP_VERSION_URL), MIN_APP_VERSION); } catch (e) {}
|
|
169
180
|
const localVer = installedVersion();
|
|
170
181
|
|
|
171
182
|
if (isInstalled()) {
|