nanoshell 1.0.7 → 1.0.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.
Files changed (2) hide show
  1. package/cli/index.js +73 -1
  2. package/package.json +1 -1
package/cli/index.js CHANGED
@@ -1,9 +1,81 @@
1
1
  #!/usr/bin/env node
2
2
  const { spawnSync } = require('child_process');
3
3
  const path = require('path');
4
+ const fs = require('fs');
5
+
6
+ const pkgDir = path.join(__dirname, '..');
7
+ let exePath = path.join(pkgDir, 'zig-out', 'bin', 'nanoshell.exe');
8
+ if (!fs.existsSync(exePath)) {
9
+ exePath = path.join(pkgDir, 'bin', 'nanoshell.exe');
10
+ }
4
11
 
5
- const exePath = path.join(__dirname, '..', 'zig-out', 'bin', 'nanoshell.exe');
6
12
  const args = process.argv.slice(2);
7
13
 
14
+ // Run the Zig CLI binary
8
15
  const result = spawnSync(exePath, args, { stdio: 'inherit', shell: true });
16
+
17
+ // If a new app directory was scaffolded (e.g. npx nanoshell my-app), copy runtime binaries from the npm package directory
18
+ if (args.length > 0 && !args[0].startsWith('-') && args[0] !== 'package' && args[0] !== 'build' && args[0] !== 'start') {
19
+ const targetDirName = args[0];
20
+ const targetDir = path.resolve(process.cwd(), targetDirName);
21
+ const targetBinDir = path.join(targetDir, 'bin');
22
+ const targetResourcesDir = path.join(targetBinDir, 'resources');
23
+
24
+ if (fs.existsSync(targetDir)) {
25
+ if (!fs.existsSync(targetBinDir)) fs.mkdirSync(targetBinDir, { recursive: true });
26
+ if (!fs.existsSync(targetResourcesDir)) fs.mkdirSync(targetResourcesDir, { recursive: true });
27
+
28
+ // Search locations for runtime binaries
29
+ const binDirs = [
30
+ path.join(pkgDir, 'zig-out', 'bin'),
31
+ path.join(pkgDir, 'vendor', 'bin'),
32
+ path.join(pkgDir, 'bin')
33
+ ];
34
+
35
+ let foundExe = null;
36
+ for (const dir of binDirs) {
37
+ const p = path.join(dir, 'example_app.exe');
38
+ if (fs.existsSync(p)) {
39
+ foundExe = p;
40
+ break;
41
+ }
42
+ }
43
+
44
+ if (foundExe) {
45
+ fs.copyFileSync(foundExe, path.join(targetBinDir, `${targetDirName}.exe`));
46
+ }
47
+
48
+ // Copy DLLs
49
+ const dlls = ['AppCore.dll', 'Ultralight.dll', 'UltralightCore.dll', 'WebCore.dll'];
50
+ for (const dll of dlls) {
51
+ for (const dir of binDirs) {
52
+ const src = path.join(dir, dll);
53
+ if (fs.existsSync(src)) {
54
+ fs.copyFileSync(src, path.join(targetBinDir, dll));
55
+ break;
56
+ }
57
+ }
58
+ }
59
+
60
+ // Copy ICU dat & cacert.pem into bin and bin/resources
61
+ const resDirs = [
62
+ path.join(pkgDir, 'vendor', 'resources'),
63
+ path.join(pkgDir, 'zig-out', 'bin', 'resources'),
64
+ path.join(pkgDir, 'resources')
65
+ ];
66
+
67
+ const resFiles = ['icudt67l.dat', 'cacert.pem'];
68
+ for (const file of resFiles) {
69
+ for (const dir of resDirs) {
70
+ const src = path.join(dir, file);
71
+ if (fs.existsSync(src)) {
72
+ fs.copyFileSync(src, path.join(targetBinDir, file));
73
+ fs.copyFileSync(src, path.join(targetResourcesDir, file));
74
+ break;
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+
9
81
  process.exit(result.status || 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nanoshell",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Hyper-lightweight 17MB RAM, 120 FPS native desktop application framework & runtime engine created by Suman Biswas",
5
5
  "main": "zig-out/bin/example_app.exe",
6
6
  "bin": {