clidesk 0.1.2 → 0.1.4

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,67 @@ 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
+ try {
81
+ const command = process.platform === 'win32' ? (process.env.ComSpec || 'cmd.exe') : 'npm';
82
+ const commandArgs = process.platform === 'win32'
83
+ ? ['/d', '/s', '/c', 'npm view clidesk version --silent']
84
+ : ['view', 'clidesk', 'version', '--silent'];
85
+ const output = execFileSync(command, commandArgs, {
86
+ encoding: 'utf8',
87
+ timeout: 5000,
88
+ windowsHide: true,
89
+ env: {
90
+ ...process.env,
91
+ npm_config_audit: 'false',
92
+ npm_config_fund: 'false',
93
+ npm_config_loglevel: 'silent',
94
+ npm_config_logs_max: '0',
95
+ npm_config_update_notifier: 'false',
96
+ NO_UPDATE_NOTIFIER: '1',
97
+ },
98
+ stdio: ['ignore', 'pipe', 'ignore'],
99
+ });
100
+ const latest = output.trim();
101
+ return latest || null;
102
+ } catch (_) {
103
+ return null;
104
+ }
105
+ }
106
+
107
+ function isVersionNewer(latest, current) {
108
+ const latestParts = parseVersion(latest);
109
+ const currentParts = parseVersion(current);
110
+ for (let index = 0; index < 3; index += 1) {
111
+ if (latestParts[index] > currentParts[index]) {
112
+ return true;
113
+ }
114
+ if (latestParts[index] < currentParts[index]) {
115
+ return false;
116
+ }
117
+ }
118
+ return false;
119
+ }
120
+
121
+ function parseVersion(value) {
122
+ const parts = String(value)
123
+ .split(/[.+-]/)
124
+ .slice(0, 3)
125
+ .map((part) => {
126
+ const parsed = Number.parseInt(part, 10);
127
+ return Number.isFinite(parsed) ? parsed : 0;
128
+ });
129
+
130
+ while (parts.length < 3) {
131
+ parts.push(0);
132
+ }
133
+
134
+ return parts;
72
135
  }
73
136
 
74
137
  function main() {
@@ -81,6 +144,13 @@ function main() {
81
144
 
82
145
  const child = spawn(runtimeLauncher, args, {
83
146
  cwd: runtimeDir,
147
+ env: {
148
+ ...process.env,
149
+ CLIDESK_VERSION: version,
150
+ CLIDESK_LATEST_VERSION: latestVersion || '',
151
+ CLIDESK_UPDATE_AVAILABLE: updateAvailable ? '1' : '0',
152
+ CLIDESK_UPDATE_COMMAND: 'npm i -g clidesk',
153
+ },
84
154
  stdio: 'inherit',
85
155
  windowsHide: false,
86
156
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clidesk",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
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