plusui-native 0.2.17 → 0.2.19

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plusui-native",
3
- "version": "0.2.17",
3
+ "version": "0.2.19",
4
4
  "description": "PlusUI CLI - Build C++ desktop apps modern UI ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -27,11 +27,11 @@
27
27
  "semver": "^7.6.0",
28
28
  "which": "^4.0.0",
29
29
  "execa": "^8.0.1",
30
- "plusui-native-builder": "^0.1.16",
31
- "plusui-native-bindgen": "^0.1.16"
30
+ "plusui-native-builder": "^0.1.18",
31
+ "plusui-native-bindgen": "^0.1.18"
32
32
  },
33
33
  "peerDependencies": {
34
- "plusui-native-bindgen": "^0.1.16"
34
+ "plusui-native-bindgen": "^0.1.18"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
package/src/index.js CHANGED
@@ -232,6 +232,29 @@ function getInstalledPackageVersion(packageName) {
232
232
  return null;
233
233
  }
234
234
 
235
+ function getLatestPackageVersion(packageName) {
236
+ try {
237
+ const result = execSync(`npm view ${packageName} version`, {
238
+ encoding: 'utf8',
239
+ stdio: ['pipe', 'pipe', 'ignore']
240
+ });
241
+ return result.trim();
242
+ } catch {
243
+ return null;
244
+ }
245
+ }
246
+
247
+ function compareVersions(v1, v2) {
248
+ const parts1 = v1.split('.').map(Number);
249
+ const parts2 = v2.split('.').map(Number);
250
+
251
+ for (let i = 0; i < 3; i++) {
252
+ if (parts1[i] > parts2[i]) return 1;
253
+ if (parts1[i] < parts2[i]) return -1;
254
+ }
255
+ return 0;
256
+ }
257
+
235
258
  function showVersionInfo() {
236
259
  const packages = [
237
260
  cliPackageJson.name,
@@ -270,38 +293,87 @@ async function updatePlusUIPackages() {
270
293
  'plusui-native-bindgen'
271
294
  ];
272
295
 
273
- log('Checking for updates...', 'blue');
296
+ log('Checking for updates...\n', 'blue');
274
297
 
275
298
  // Check if packages are installed locally or globally
276
299
  const isInProject = existsSync(join(process.cwd(), 'package.json'));
277
300
 
278
301
  if (isInProject) {
279
- log('Detected project environment - updating local packages...', 'cyan');
302
+ let updatedCount = 0;
303
+ let upToDateCount = 0;
304
+
280
305
  for (const pkg of packages) {
281
- const localVersion = getInstalledPackageVersion(pkg);
282
- if (localVersion) {
306
+ const currentVersion = getInstalledPackageVersion(pkg);
307
+
308
+ if (!currentVersion) {
309
+ log(`${COLORS.dim}${pkg}: not installed${COLORS.reset}`);
310
+ continue;
311
+ }
312
+
313
+ // Get latest version from npm
314
+ const latestVersion = getLatestPackageVersion(pkg);
315
+
316
+ if (!latestVersion) {
317
+ log(`${COLORS.yellow}${pkg}: couldn't check for updates${COLORS.reset}`);
318
+ continue;
319
+ }
320
+
321
+ const comparison = compareVersions(latestVersion, currentVersion);
322
+
323
+ if (comparison > 0) {
324
+ // Newer version available
283
325
  try {
284
- log(`Updating ${pkg}...`, 'dim');
285
- execSync(`npm install ${pkg}@latest`, { stdio: 'inherit' });
326
+ log(`${COLORS.blue}${pkg}: ${currentVersion} → ${latestVersion}${COLORS.reset}`);
327
+ execSync(`npm install ${pkg}@${latestVersion}`, {
328
+ stdio: ['ignore', 'ignore', 'pipe'],
329
+ encoding: 'utf8'
330
+ });
331
+ log(`${COLORS.green}✓ ${pkg} updated${COLORS.reset}`);
332
+ updatedCount++;
286
333
  } catch (e) {
287
- log(`Failed to update ${pkg}`, 'yellow');
334
+ log(`${COLORS.red}✗ ${pkg} update failed${COLORS.reset}`);
288
335
  }
336
+ } else {
337
+ // Already up to date
338
+ log(`${COLORS.green}✓ ${pkg} v${currentVersion} (up to date)${COLORS.reset}`);
339
+ upToDateCount++;
289
340
  }
290
341
  }
342
+
343
+ console.log('');
344
+ if (updatedCount > 0) {
345
+ log(`Updated ${updatedCount} package${updatedCount !== 1 ? 's' : ''}`, 'green');
346
+ }
347
+ if (upToDateCount > 0) {
348
+ log(`${upToDateCount} package${upToDateCount !== 1 ? 's' : ''} already up to date`, 'dim');
349
+ }
291
350
  } else {
292
- log('Updating global packages...', 'cyan');
293
- // Update the CLI globally
294
- try {
295
- log(`Updating ${cliPackageJson.name} globally...`, 'dim');
296
- execSync(`npm install -g ${cliPackageJson.name}@latest`, { stdio: 'inherit' });
297
- log(`✓ ${cliPackageJson.name} updated successfully`, 'green');
298
- } catch (e) {
299
- log(`Failed to update ${cliPackageJson.name}`, 'yellow');
351
+ log('Updating global CLI package...', 'cyan');
352
+
353
+ const currentVersion = cliPackageJson.version;
354
+ const latestVersion = getLatestPackageVersion(cliPackageJson.name);
355
+
356
+ if (!latestVersion) {
357
+ log('Couldn\'t check for updates', 'yellow');
358
+ return;
359
+ }
360
+
361
+ const comparison = compareVersions(latestVersion, currentVersion);
362
+
363
+ if (comparison > 0) {
364
+ try {
365
+ log(`${COLORS.blue}${cliPackageJson.name}: ${currentVersion} → ${latestVersion}${COLORS.reset}`);
366
+ execSync(`npm install -g ${cliPackageJson.name}@${latestVersion}`, { stdio: 'inherit' });
367
+ log(`✓ ${cliPackageJson.name} updated successfully`, 'green');
368
+ } catch (e) {
369
+ log(`Failed to update ${cliPackageJson.name}`, 'red');
370
+ }
371
+ } else {
372
+ log(`✓ ${cliPackageJson.name} v${currentVersion} (already up to date)`, 'green');
300
373
  }
301
374
  }
302
375
 
303
- log('\\n✓ Update complete!', 'green');
304
- log('Run "plusui -v" to see installed versions\\n', 'dim');
376
+ console.log('');
305
377
  }
306
378
 
307
379
  function getAppBindgenPaths() {
@@ -3,6 +3,8 @@
3
3
  #include <iostream>
4
4
  #include "generated/assets.h"
5
5
 
6
+ using namespace plusui;
7
+
6
8
  // ============================================================================
7
9
  // {{PROJECT_NAME}} - Configuration
8
10
  // ============================================================================
@@ -104,7 +106,7 @@ struct WebGPUConfig {
104
106
  // ============================================================================
105
107
  int main() {
106
108
  // Use your app name as the variable name
107
- auto {{PROJECT_NAME_LOWER}} = plusui::createApp()
109
+ auto {{PROJECT_NAME_LOWER}} = createApp()
108
110
  .title(appConfig.name)
109
111
  .width(windowConfig.width)
110
112
  .height(windowConfig.height)
@@ -172,24 +174,24 @@ int main() {
172
174
  // FILE DROP EVENTS (Drag & Drop)
173
175
  // ========================================
174
176
  // Listen for files dropped into the window
175
- plusui::event::on("fileDrop.filesDropped", [](const std::string& data) {
177
+ event::on("fileDrop.filesDropped", [](const std::string& data) {
176
178
  std::cout << "Files dropped: " << data << std::endl;
177
179
  // Parse the JSON data to get file info
178
180
  // You can process files here in C++
179
181
  });
180
182
 
181
- plusui::event::on("fileDrop.dragEnter", [](const std::string&) {
183
+ event::on("fileDrop.dragEnter", [](const std::string&) {
182
184
  std::cout << "Drag entered window" << std::endl;
183
185
  });
184
186
 
185
- plusui::event::on("fileDrop.dragLeave", [](const std::string&) {
187
+ event::on("fileDrop.dragLeave", [](const std::string&) {
186
188
  std::cout << "Drag left window" << std::endl;
187
189
  });
188
190
 
189
191
  // ========================================
190
192
  // RUN APPLICATION
191
193
  // ========================================
192
- plusui::App runtime;
194
+ App runtime;
193
195
  runtime.run();
194
196
 
195
197
  return 0;
@@ -3,6 +3,8 @@
3
3
  #include <iostream>
4
4
  #include "generated/assets.h"
5
5
 
6
+ using namespace plusui;
7
+
6
8
  // ============================================================================
7
9
  // {{PROJECT_NAME}} - Configuration
8
10
  // ============================================================================
@@ -104,7 +106,7 @@ struct WebGPUConfig {
104
106
  // ============================================================================
105
107
  int main() {
106
108
  // Use your app name as the variable name
107
- auto {{PROJECT_NAME_LOWER}} = plusui::createApp()
109
+ auto {{PROJECT_NAME_LOWER}} = createApp()
108
110
  .title(appConfig.name)
109
111
  .width(windowConfig.width)
110
112
  .height(windowConfig.height)
@@ -167,24 +169,24 @@ int main() {
167
169
  // FILE DROP EVENTS (Drag & Drop)
168
170
  // ========================================
169
171
  // Listen for files dropped into the window
170
- plusui::event::on("fileDrop.filesDropped", [](const std::string& data) {
172
+ event::on("fileDrop.filesDropped", [](const std::string& data) {
171
173
  std::cout << "Files dropped: " << data << std::endl;
172
174
  // Parse the JSON data to get file info
173
175
  // You can process files here in C++
174
176
  });
175
177
 
176
- plusui::event::on("fileDrop.dragEnter", [](const std::string&) {
178
+ event::on("fileDrop.dragEnter", [](const std::string&) {
177
179
  std::cout << "Drag entered window" << std::endl;
178
180
  });
179
181
 
180
- plusui::event::on("fileDrop.dragLeave", [](const std::string&) {
182
+ event::on("fileDrop.dragLeave", [](const std::string&) {
181
183
  std::cout << "Drag left window" << std::endl;
182
184
  });
183
185
 
184
186
  // ========================================
185
187
  // RUN APPLICATION
186
188
  // ========================================
187
- plusui::App runtime;
189
+ App runtime;
188
190
  runtime.run();
189
191
 
190
192
  return 0;