@appaloft/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/bin/appaloft.js +65 -0
  2. package/package.json +29 -0
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+ import { existsSync } from "node:fs";
4
+ import { createRequire } from "node:module";
5
+ import { dirname, join } from "node:path";
6
+
7
+ const require = createRequire(import.meta.url);
8
+
9
+ function detectLinuxLibc() {
10
+ if (process.platform !== "linux") {
11
+ return undefined;
12
+ }
13
+
14
+ if (process.report?.getReport().header.glibcVersionRuntime) {
15
+ return "gnu";
16
+ }
17
+
18
+ return "musl";
19
+ }
20
+
21
+ function packageName() {
22
+ const arch = process.arch;
23
+
24
+ if (process.platform === "darwin" && (arch === "arm64" || arch === "x64")) {
25
+ return `@appaloft/cli-darwin-${arch}`;
26
+ }
27
+
28
+ if (process.platform === "linux" && (arch === "arm64" || arch === "x64")) {
29
+ return `@appaloft/cli-linux-${arch}-${detectLinuxLibc()}`;
30
+ }
31
+
32
+ if (process.platform === "win32" && (arch === "arm64" || arch === "x64")) {
33
+ return `@appaloft/cli-win32-${arch}`;
34
+ }
35
+
36
+ return undefined;
37
+ }
38
+
39
+ function resolveBinary() {
40
+ const selectedPackage = packageName();
41
+ if (!selectedPackage) {
42
+ throw new Error(`Unsupported Appaloft platform: ${process.platform}/${process.arch}`);
43
+ }
44
+
45
+ const packageJsonPath = require.resolve(`${selectedPackage}/package.json`);
46
+ const binaryName = process.platform === "win32" ? "appaloft.exe" : "appaloft";
47
+ const binaryPath = join(dirname(packageJsonPath), "bin", binaryName);
48
+
49
+ if (!existsSync(binaryPath)) {
50
+ throw new Error(`Installed Appaloft package ${selectedPackage} is missing ${binaryName}`);
51
+ }
52
+
53
+ return binaryPath;
54
+ }
55
+
56
+ const binaryPath = resolveBinary();
57
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
58
+ stdio: "inherit",
59
+ });
60
+
61
+ if (result.error) {
62
+ throw result.error;
63
+ }
64
+
65
+ process.exit(result.status ?? 1);
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@appaloft/cli",
3
+ "version": "0.1.0",
4
+ "description": "Appaloft CLI and local server launcher.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "appaloft": "bin/appaloft.js"
9
+ },
10
+ "files": [
11
+ "bin"
12
+ ],
13
+ "optionalDependencies": {
14
+ "@appaloft/cli-darwin-arm64": "0.1.0",
15
+ "@appaloft/cli-darwin-x64": "0.1.0",
16
+ "@appaloft/cli-linux-arm64-gnu": "0.1.0",
17
+ "@appaloft/cli-linux-x64-gnu": "0.1.0",
18
+ "@appaloft/cli-linux-arm64-musl": "0.1.0",
19
+ "@appaloft/cli-linux-x64-musl": "0.1.0",
20
+ "@appaloft/cli-win32-arm64": "0.1.0",
21
+ "@appaloft/cli-win32-x64": "0.1.0"
22
+ },
23
+ "engines": {
24
+ "node": ">=18"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ }
29
+ }