@crustjs/crust 0.0.21 → 0.0.23

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/README.md CHANGED
@@ -121,8 +121,7 @@ dist/npm/
121
121
  manifest.json
122
122
  root/
123
123
  package.json
124
- bin/my-cli
125
- bin/my-cli.cmd
124
+ bin/my-cli.js
126
125
  linux-x64/
127
126
  package.json
128
127
  bin/my-cli-bun-linux-x64-baseline
@@ -143,7 +142,7 @@ dist/npm/
143
142
  bin/my-cli-bun-windows-arm64.exe
144
143
  ```
145
144
 
146
- The generated root package contains shell and `.cmd` launchers plus `optionalDependencies` on the platform packages. Each platform package is tagged with npm `os` / `cpu` metadata and contains only its native binary.
145
+ The generated root package contains a JS resolver plus `optionalDependencies` on the platform packages. Each platform package is tagged with npm `os` / `cpu` metadata and contains only its native binary. npm generates the platform launchers from the root package `bin` entry during install, so Crust does not stage its own `.cmd` file for `--package`.
147
146
 
148
147
  `crust build --package` is the npm-packaging workflow. The staged interface is:
149
148
 
package/bin/crust.js ADDED
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env node
2
+ // Auto-generated by crust build --package -- do not edit
3
+ import { spawn } from "node:child_process";
4
+ import { chmodSync, existsSync } from "node:fs";
5
+ import { dirname, resolve } from "node:path";
6
+ import process from "node:process";
7
+ import { fileURLToPath } from "node:url";
8
+
9
+ const PLATFORMS = {
10
+ "linux-x64": {
11
+ "packagePathSegment": "crust-linux-x64",
12
+ "packageName": "@crustjs/crust-linux-x64",
13
+ "binaryFilename": "crust-bun-linux-x64-baseline"
14
+ },
15
+ "linux-arm64": {
16
+ "packagePathSegment": "crust-linux-arm64",
17
+ "packageName": "@crustjs/crust-linux-arm64",
18
+ "binaryFilename": "crust-bun-linux-arm64"
19
+ },
20
+ "darwin-x64": {
21
+ "packagePathSegment": "crust-darwin-x64",
22
+ "packageName": "@crustjs/crust-darwin-x64",
23
+ "binaryFilename": "crust-bun-darwin-x64"
24
+ },
25
+ "darwin-arm64": {
26
+ "packagePathSegment": "crust-darwin-arm64",
27
+ "packageName": "@crustjs/crust-darwin-arm64",
28
+ "binaryFilename": "crust-bun-darwin-arm64"
29
+ },
30
+ "win32-x64": {
31
+ "packagePathSegment": "crust-windows-x64",
32
+ "packageName": "@crustjs/crust-windows-x64",
33
+ "binaryFilename": "crust-bun-windows-x64-baseline.exe"
34
+ },
35
+ "win32-arm64": {
36
+ "packagePathSegment": "crust-windows-arm64",
37
+ "packageName": "@crustjs/crust-windows-arm64",
38
+ "binaryFilename": "crust-bun-windows-arm64.exe"
39
+ }
40
+ };
41
+ const dir = dirname(fileURLToPath(import.meta.url));
42
+ const platformKey = `${process.platform}-${process.arch}`;
43
+ const target = PLATFORMS[platformKey];
44
+
45
+ if (!target) {
46
+ console.error("[crust] Unsupported platform: " + platformKey);
47
+ console.error("[crust] Supported platforms: linux-x64, linux-arm64, darwin-x64, darwin-arm64, windows-x64, windows-arm64");
48
+ process.exit(1);
49
+ }
50
+
51
+ const candidateOne = resolve(
52
+ dir,
53
+ "..",
54
+ "..",
55
+ target.packagePathSegment,
56
+ "bin",
57
+ target.binaryFilename,
58
+ );
59
+ const candidateTwo = resolve(
60
+ dir,
61
+ "..",
62
+ "node_modules",
63
+ target.packageName,
64
+ "bin",
65
+ target.binaryFilename,
66
+ );
67
+
68
+ const binPath = existsSync(candidateOne)
69
+ ? candidateOne
70
+ : existsSync(candidateTwo)
71
+ ? candidateTwo
72
+ : null;
73
+
74
+ if (!binPath) {
75
+ console.error("[crust] Missing platform package for " + platformKey);
76
+ console.error("[crust] Tried:");
77
+ console.error(" " + candidateOne);
78
+ console.error(" " + candidateTwo);
79
+ console.error(
80
+ "[crust] Reinstall dependencies on this platform and ensure optional dependencies are enabled.",
81
+ );
82
+ process.exit(1);
83
+ }
84
+
85
+ if (process.platform !== "win32") {
86
+ try {
87
+ chmodSync(binPath, 0o755);
88
+ } catch {
89
+ // Ignore permission adjustment failures and let spawn surface real errors.
90
+ }
91
+ }
92
+
93
+ const child = spawn(binPath, process.argv.slice(2), {
94
+ stdio: "inherit",
95
+ });
96
+
97
+ child.on("error", (error) => {
98
+ console.error("[crust] Failed to launch binary: " + error.message);
99
+ process.exit(1);
100
+ });
101
+
102
+ child.on("exit", (code, signal) => {
103
+ if (signal) {
104
+ try {
105
+ process.kill(process.pid, signal);
106
+ } catch {
107
+ process.exit(1);
108
+ }
109
+ return;
110
+ }
111
+
112
+ process.exit(code ?? 0);
113
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crustjs/crust",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "CLI tooling for the Crust framework",
5
5
  "license": "MIT",
6
6
  "author": "chenxin-yan",
@@ -29,14 +29,14 @@
29
29
  "bin"
30
30
  ],
31
31
  "bin": {
32
- "crust": "bin/crust"
32
+ "crust": "bin/crust.js"
33
33
  },
34
34
  "optionalDependencies": {
35
- "@crustjs/crust-linux-x64": "0.0.21",
36
- "@crustjs/crust-linux-arm64": "0.0.21",
37
- "@crustjs/crust-darwin-x64": "0.0.21",
38
- "@crustjs/crust-darwin-arm64": "0.0.21",
39
- "@crustjs/crust-windows-x64": "0.0.21",
40
- "@crustjs/crust-windows-arm64": "0.0.21"
35
+ "@crustjs/crust-linux-x64": "0.0.23",
36
+ "@crustjs/crust-linux-arm64": "0.0.23",
37
+ "@crustjs/crust-darwin-x64": "0.0.23",
38
+ "@crustjs/crust-darwin-arm64": "0.0.23",
39
+ "@crustjs/crust-windows-x64": "0.0.23",
40
+ "@crustjs/crust-windows-arm64": "0.0.23"
41
41
  }
42
42
  }
package/bin/crust DELETED
@@ -1,65 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Auto-generated by crust build --package -- do not edit
3
- set -e
4
-
5
- source="$0"
6
- while [ -L "$source" ]; do
7
- link_dir="$(cd "$(dirname "$source")" && pwd)"
8
- source="$(readlink "$source")"
9
- case "$source" in
10
- /*) ;;
11
- *) source="$link_dir/$source" ;;
12
- esac
13
- done
14
-
15
- dir="$(cd "$(dirname "$source")" && pwd)"
16
- platform="$(uname -s)-$(uname -m)"
17
- platform_pkg=""
18
- fallback_pkg=""
19
- binary=""
20
-
21
- case "$platform" in
22
- Linux-x86_64)
23
- platform_pkg="crust-linux-x64"
24
- fallback_pkg="@crustjs/crust-linux-x64"
25
- binary="crust-bun-linux-x64-baseline"
26
- ;;
27
- Linux-aarch64)
28
- platform_pkg="crust-linux-arm64"
29
- fallback_pkg="@crustjs/crust-linux-arm64"
30
- binary="crust-bun-linux-arm64"
31
- ;;
32
- Darwin-x86_64)
33
- platform_pkg="crust-darwin-x64"
34
- fallback_pkg="@crustjs/crust-darwin-x64"
35
- binary="crust-bun-darwin-x64"
36
- ;;
37
- Darwin-arm64)
38
- platform_pkg="crust-darwin-arm64"
39
- fallback_pkg="@crustjs/crust-darwin-arm64"
40
- binary="crust-bun-darwin-arm64"
41
- ;;
42
- *)
43
- echo "[crust] Unsupported platform: $platform" >&2
44
- echo "[crust] Supported platforms: linux-x64, linux-arm64, darwin-x64, darwin-arm64" >&2
45
- exit 1
46
- ;;
47
- esac
48
-
49
- candidate_one="$dir/../../$platform_pkg/bin/$binary"
50
- candidate_two="$dir/../node_modules/$fallback_pkg/bin/$binary"
51
-
52
- if [ -f "$candidate_one" ]; then
53
- exec "$candidate_one" "$@"
54
- fi
55
-
56
- if [ -f "$candidate_two" ]; then
57
- exec "$candidate_two" "$@"
58
- fi
59
-
60
- echo "[crust] Missing platform package for $platform" >&2
61
- echo "[crust] Tried:" >&2
62
- echo " $candidate_one" >&2
63
- echo " $candidate_two" >&2
64
- echo "[crust] Reinstall dependencies on this platform and ensure optional dependencies are enabled." >&2
65
- exit 1
package/bin/crust.cmd DELETED
@@ -1,45 +0,0 @@
1
- @echo off
2
- rem Auto-generated by crust build --package -- do not edit
3
- setlocal
4
- set "dir=%~dp0"
5
- set "host_arch=%PROCESSOR_ARCHITECTURE%"
6
- set "pkg_segment="
7
- set "fallback_pkg="
8
- set "binary="
9
-
10
- if /I "%PROCESSOR_ARCHITEW6432%"=="ARM64" set "host_arch=ARM64"
11
-
12
- if /I "%host_arch%"=="AMD64" (
13
- set "pkg_segment=crust-windows-x64"
14
- set "fallback_pkg=@crustjs\crust-windows-x64"
15
- set "binary=crust-bun-windows-x64-baseline.exe"
16
- )
17
- if /I "%host_arch%"=="ARM64" (
18
- set "pkg_segment=crust-windows-arm64"
19
- set "fallback_pkg=@crustjs\crust-windows-arm64"
20
- set "binary=crust-bun-windows-arm64.exe"
21
- )
22
-
23
- if "%binary%"=="" (
24
- echo [crust] Unsupported Windows architecture: %host_arch% >&2
25
- exit /b 1
26
- )
27
-
28
- set "candidate_one=%dir%..\..\%pkg_segment%\bin\%binary%"
29
- set "candidate_two=%dir%..\node_modules\%fallback_pkg%\bin\%binary%"
30
-
31
- if exist "%candidate_one%" (
32
- "%candidate_one%" %*
33
- exit /b %ERRORLEVEL%
34
- )
35
-
36
- if exist "%candidate_two%" (
37
- "%candidate_two%" %*
38
- exit /b %ERRORLEVEL%
39
- )
40
-
41
- echo [crust] Missing platform package for Windows %host_arch% >&2
42
- echo [crust] Tried: %candidate_one% >&2
43
- echo [crust] Tried: %candidate_two% >&2
44
- echo [crust] Reinstall dependencies on this platform and ensure optional dependencies are enabled. >&2
45
- exit /b 1