qtex 1.1.5 ā 1.1.8
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 +1 -1
- package/src/updater.js +35 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qtex",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "Ultra-fast cloud LaTeX compiler. Compile .tex documents in milliseconds without installing TeXLive or MikTeX. Zero config, sub-second builds, live watch mode.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
package/src/updater.js
CHANGED
|
@@ -26,6 +26,20 @@ async function saveState(state) {
|
|
|
26
26
|
} catch { }
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Simple semver comparison (v1.2.3 format)
|
|
31
|
+
* Returns true if latest > current
|
|
32
|
+
*/
|
|
33
|
+
function isNewer(latest, current) {
|
|
34
|
+
const l = latest.split('.').map(Number);
|
|
35
|
+
const c = current.split('.').map(Number);
|
|
36
|
+
for (let i = 0; i < 3; i++) {
|
|
37
|
+
if (l[i] > c[i]) return true;
|
|
38
|
+
if (l[i] < c[i]) return false;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
/**
|
|
30
44
|
* Checks for updates in the background and launches a detached
|
|
31
45
|
* background process to update the binary if a new version is found.
|
|
@@ -47,13 +61,20 @@ export async function autoUpdate(currentVersion) {
|
|
|
47
61
|
|
|
48
62
|
await saveState({ ...state, lastCheck: now });
|
|
49
63
|
|
|
50
|
-
if (latestVersion
|
|
64
|
+
if (isNewer(latestVersion, currentVersion)) {
|
|
51
65
|
console.log(`${colors.dim}\nš New version detected (${data.tag_name}). Updating silently in background...${colors.reset}`);
|
|
52
66
|
|
|
53
|
-
//
|
|
54
|
-
|
|
67
|
+
// Platform-aware install command
|
|
68
|
+
let installCmd, shell;
|
|
69
|
+
if (process.platform === 'win32') {
|
|
70
|
+
installCmd = 'irm https://raw.githubusercontent.com/' + REPO + '/main/install.ps1 | iex';
|
|
71
|
+
shell = 'powershell';
|
|
72
|
+
} else {
|
|
73
|
+
installCmd = 'curl -fsSL https://raw.githubusercontent.com/' + REPO + '/main/install.sh | bash';
|
|
74
|
+
shell = 'bash';
|
|
75
|
+
}
|
|
55
76
|
|
|
56
|
-
spawn(
|
|
77
|
+
spawn(shell, ['-c', installCmd], {
|
|
57
78
|
detached: true,
|
|
58
79
|
stdio: 'ignore'
|
|
59
80
|
}).unref();
|
|
@@ -72,14 +93,21 @@ export async function selfUpdate(currentVersion) {
|
|
|
72
93
|
const data = await res.json();
|
|
73
94
|
const latestVersion = data.tag_name.replace('v', '');
|
|
74
95
|
|
|
75
|
-
if (latestVersion
|
|
96
|
+
if (!isNewer(latestVersion, currentVersion)) {
|
|
76
97
|
ui.success(`qtex is already up to date (${colors.bold}v${currentVersion}${colors.reset}).`);
|
|
77
98
|
return;
|
|
78
99
|
}
|
|
79
100
|
|
|
80
101
|
ui.info(`New version found: ${colors.bold}v${latestVersion}${colors.reset}. Updating...`);
|
|
81
|
-
|
|
82
|
-
|
|
102
|
+
|
|
103
|
+
if (process.platform === 'win32') {
|
|
104
|
+
const installCmd = `powershell -Command "irm https://raw.githubusercontent.com/${REPO}/main/install.ps1 | iex"`;
|
|
105
|
+
execSync(installCmd, { stdio: 'inherit' });
|
|
106
|
+
} else {
|
|
107
|
+
const installScriptCmd = `curl -fsSL https://raw.githubusercontent.com/${REPO}/main/install.sh | bash`;
|
|
108
|
+
execSync(installScriptCmd, { stdio: 'inherit' });
|
|
109
|
+
}
|
|
110
|
+
|
|
83
111
|
ui.success('qtex has been updated successfully!');
|
|
84
112
|
} catch (error) {
|
|
85
113
|
ui.error(`Update failed: ${error.message}`);
|