@lightshell/cli 0.1.0

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/install.js +52 -0
  2. package/package.json +35 -0
package/install.js ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Postinstall script: copy the platform-specific binary to bin/
4
+ const { platform, arch } = process;
5
+ const path = require("path");
6
+ const fs = require("fs");
7
+
8
+ const platformMap = {
9
+ darwin: "darwin",
10
+ linux: "linux",
11
+ };
12
+
13
+ const archMap = {
14
+ arm64: "arm64",
15
+ x64: "x64",
16
+ x86_64: "x64",
17
+ };
18
+
19
+ const os = platformMap[platform];
20
+ const cpu = archMap[arch];
21
+
22
+ if (!os || !cpu) {
23
+ console.error(
24
+ `lightshell: unsupported platform ${platform}-${arch}. Only macOS and Linux (arm64, x64) are supported.`
25
+ );
26
+ process.exit(1);
27
+ }
28
+
29
+ const pkgName = `@lightshell/${os}-${cpu}`;
30
+
31
+ let binaryPath;
32
+ try {
33
+ binaryPath = require.resolve(`${pkgName}/lightshell`);
34
+ } catch {
35
+ console.error(
36
+ `lightshell: could not find ${pkgName}. Make sure optional dependencies are installed.\n` +
37
+ `Try: npm install --include=optional`
38
+ );
39
+ process.exit(1);
40
+ }
41
+
42
+ const binDir = path.join(__dirname, "bin");
43
+ const dest = path.join(binDir, "lightshell");
44
+
45
+ try {
46
+ fs.mkdirSync(binDir, { recursive: true });
47
+ fs.copyFileSync(binaryPath, dest);
48
+ fs.chmodSync(dest, 0o755);
49
+ } catch (err) {
50
+ console.error(`lightshell: failed to install binary: ${err.message}`);
51
+ process.exit(1);
52
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@lightshell/cli",
3
+ "version": "0.1.0",
4
+ "description": "Build desktop apps with JavaScript. Ship them under 5MB.",
5
+ "keywords": [
6
+ "desktop",
7
+ "app",
8
+ "framework",
9
+ "webview",
10
+ "native",
11
+ "macos",
12
+ "linux"
13
+ ],
14
+ "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/meherpanguluri/lightshell"
18
+ },
19
+ "homepage": "https://lightshell.sh",
20
+ "bin": {
21
+ "lightshell": "bin/lightshell"
22
+ },
23
+ "scripts": {
24
+ "postinstall": "node install.js"
25
+ },
26
+ "optionalDependencies": {
27
+ "@lightshell/darwin-arm64": "0.1.0",
28
+ "@lightshell/darwin-x64": "0.1.0",
29
+ "@lightshell/linux-arm64": "0.1.0",
30
+ "@lightshell/linux-x64": "0.1.0"
31
+ },
32
+ "engines": {
33
+ "node": ">=16"
34
+ }
35
+ }