clidesk 0.1.2 → 0.1.3

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/bin/clidesk.js CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  const fs = require('fs');
10
10
  const path = require('path');
11
- const { spawn } = require('child_process');
11
+ const { execFileSync, spawn } = require('child_process');
12
12
 
13
13
  const args = process.argv.slice(2);
14
14
  const debug = args.includes('--debug-launch');
@@ -32,6 +32,8 @@ const vendorLauncher = path.join(vendorDir, 'clidesk-launcher.exe');
32
32
 
33
33
  const runtimeApp = path.join(runtimeDir, 'clidesk.exe');
34
34
  const runtimeLauncher = path.join(runtimeDir, 'clidesk-launcher.exe');
35
+ const latestVersion = readLatestVersion();
36
+ const updateAvailable = latestVersion ? isVersionNewer(latestVersion, version) : false;
35
37
 
36
38
  function ensureFileExists(filePath, label) {
37
39
  if (!fs.existsSync(filePath)) {
@@ -69,6 +71,55 @@ function printDebugInfo() {
69
71
  console.log('[CliDesk] runtimeDir:', runtimeDir);
70
72
  console.log('[CliDesk] launcherPath:', runtimeLauncher);
71
73
  console.log('[CliDesk] appPath:', runtimeApp);
74
+ console.log('[CliDesk] version:', version);
75
+ console.log('[CliDesk] latestVersion:', latestVersion || '(unknown)');
76
+ console.log('[CliDesk] updateAvailable:', updateAvailable ? 'true' : 'false');
77
+ }
78
+
79
+ function readLatestVersion() {
80
+ const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
81
+ try {
82
+ const output = execFileSync(npmCommand, ['view', 'clidesk', 'version', '--silent'], {
83
+ encoding: 'utf8',
84
+ timeout: 5000,
85
+ windowsHide: true,
86
+ stdio: ['ignore', 'pipe', 'ignore'],
87
+ });
88
+ const latest = output.trim();
89
+ return latest || null;
90
+ } catch (_) {
91
+ return null;
92
+ }
93
+ }
94
+
95
+ function isVersionNewer(latest, current) {
96
+ const latestParts = parseVersion(latest);
97
+ const currentParts = parseVersion(current);
98
+ for (let index = 0; index < 3; index += 1) {
99
+ if (latestParts[index] > currentParts[index]) {
100
+ return true;
101
+ }
102
+ if (latestParts[index] < currentParts[index]) {
103
+ return false;
104
+ }
105
+ }
106
+ return false;
107
+ }
108
+
109
+ function parseVersion(value) {
110
+ const parts = String(value)
111
+ .split(/[.+-]/)
112
+ .slice(0, 3)
113
+ .map((part) => {
114
+ const parsed = Number.parseInt(part, 10);
115
+ return Number.isFinite(parsed) ? parsed : 0;
116
+ });
117
+
118
+ while (parts.length < 3) {
119
+ parts.push(0);
120
+ }
121
+
122
+ return parts;
72
123
  }
73
124
 
74
125
  function main() {
@@ -81,6 +132,13 @@ function main() {
81
132
 
82
133
  const child = spawn(runtimeLauncher, args, {
83
134
  cwd: runtimeDir,
135
+ env: {
136
+ ...process.env,
137
+ CLIDESK_VERSION: version,
138
+ CLIDESK_LATEST_VERSION: latestVersion || '',
139
+ CLIDESK_UPDATE_AVAILABLE: updateAvailable ? '1' : '0',
140
+ CLIDESK_UPDATE_COMMAND: 'npm i -g clidesk',
141
+ },
84
142
  stdio: 'inherit',
85
143
  windowsHide: false,
86
144
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clidesk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "CliDesk desktop app launcher — install with npm i -g clidesk",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
Binary file
Binary file