@crustjs/crust 0.2.0 → 0.3.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.
package/README.md CHANGED
@@ -5,7 +5,7 @@ CLI tooling for the Crust framework
5
5
  ## Install
6
6
 
7
7
  ```sh
8
- bun add -d @crustjs/crust
8
+ npm install -D @crustjs/crust
9
9
  ```
10
10
 
11
11
  ## Documentation
package/bin/crust.js CHANGED
@@ -1,83 +1,99 @@
1
1
  #!/usr/bin/env node
2
- // Auto-generated by crust build --package -- do not edit
2
+ // Auto-generated by crust build -- do not edit
3
3
  import { spawn } from "node:child_process";
4
4
  import { chmodSync, existsSync } from "node:fs";
5
5
  import { dirname, resolve } from "node:path";
6
6
  import process from "node:process";
7
7
  import { fileURLToPath } from "node:url";
8
8
 
9
+ const NAME = "crust";
9
10
  const PLATFORMS = {
10
11
  "linux-x64": {
11
12
  "packagePathSegment": "crust-linux-x64",
12
13
  "packageName": "@crustjs/crust-linux-x64",
13
- "binaryFilename": "crust-bun-linux-x64-baseline"
14
+ "targetAlias": "linux-x64",
15
+ "binaryFilename": "crust-bun-linux-x64"
14
16
  },
15
17
  "linux-arm64": {
16
18
  "packagePathSegment": "crust-linux-arm64",
17
19
  "packageName": "@crustjs/crust-linux-arm64",
20
+ "targetAlias": "linux-arm64",
18
21
  "binaryFilename": "crust-bun-linux-arm64"
19
22
  },
23
+ "linux-x64-musl": {
24
+ "packagePathSegment": "crust-linux-x64-musl",
25
+ "packageName": "@crustjs/crust-linux-x64-musl",
26
+ "targetAlias": "linux-x64-musl",
27
+ "binaryFilename": "crust-bun-linux-x64-musl"
28
+ },
29
+ "linux-arm64-musl": {
30
+ "packagePathSegment": "crust-linux-arm64-musl",
31
+ "packageName": "@crustjs/crust-linux-arm64-musl",
32
+ "targetAlias": "linux-arm64-musl",
33
+ "binaryFilename": "crust-bun-linux-arm64-musl"
34
+ },
20
35
  "darwin-x64": {
21
36
  "packagePathSegment": "crust-darwin-x64",
22
37
  "packageName": "@crustjs/crust-darwin-x64",
38
+ "targetAlias": "darwin-x64",
23
39
  "binaryFilename": "crust-bun-darwin-x64"
24
40
  },
25
41
  "darwin-arm64": {
26
42
  "packagePathSegment": "crust-darwin-arm64",
27
43
  "packageName": "@crustjs/crust-darwin-arm64",
44
+ "targetAlias": "darwin-arm64",
28
45
  "binaryFilename": "crust-bun-darwin-arm64"
29
46
  },
30
47
  "win32-x64": {
31
48
  "packagePathSegment": "crust-windows-x64",
32
49
  "packageName": "@crustjs/crust-windows-x64",
33
- "binaryFilename": "crust-bun-windows-x64-baseline.exe"
50
+ "targetAlias": "windows-x64",
51
+ "binaryFilename": "crust-bun-windows-x64.exe"
34
52
  },
35
53
  "win32-arm64": {
36
54
  "packagePathSegment": "crust-windows-arm64",
37
55
  "packageName": "@crustjs/crust-windows-arm64",
56
+ "targetAlias": "windows-arm64",
38
57
  "binaryFilename": "crust-bun-windows-arm64.exe"
39
58
  }
40
59
  };
41
60
  const dir = dirname(fileURLToPath(import.meta.url));
42
- const platformKey = `${process.platform}-${process.arch}`;
61
+
62
+ // Same check as Bun's own npm installer: glibc reports its version, musl does not.
63
+ function isMusl() {
64
+ try {
65
+ const report = process.report?.getReport();
66
+ if (report?.header) return report.header.glibcVersionRuntime === undefined;
67
+ } catch {}
68
+ return existsSync("/etc/alpine-release");
69
+ }
70
+
71
+ const platformKey =
72
+ `${process.platform}-${process.arch}` + (process.platform === "linux" && isMusl() ? "-musl" : "");
43
73
  const target = PLATFORMS[platformKey];
44
74
 
45
75
  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");
76
+ console.error("[" + NAME + "] Unsupported platform: " + platformKey);
77
+ console.error("[" + NAME + "] Supported platforms: linux-x64, linux-arm64, linux-x64-musl, linux-arm64-musl, darwin-x64, darwin-arm64, windows-x64, windows-arm64");
48
78
  process.exit(1);
49
79
  }
50
80
 
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;
81
+ const candidates = [
82
+ // Hoisted install: the platform package beside this one in node_modules.
83
+ resolve(dir, "..", "..", target.packagePathSegment, "bin", target.binaryFilename),
84
+ // Nested install: the platform package under this package's node_modules.
85
+ resolve(dir, "..", "node_modules", target.packageName, "bin", target.binaryFilename),
86
+ // In place: the .crust/ tree crust build staged, before any install.
87
+ resolve(dir, "..", "..", target.targetAlias, "bin", target.binaryFilename),
88
+ ];
89
+ const binPath = candidates.find((candidate) => existsSync(candidate));
73
90
 
74
91
  if (!binPath) {
75
- console.error("[crust] Missing platform package for " + platformKey);
76
- console.error("[crust] Tried:");
77
- console.error(" " + candidateOne);
78
- console.error(" " + candidateTwo);
92
+ console.error("[" + NAME + "] Missing platform package for " + platformKey);
93
+ console.error("[" + NAME + "] Tried:");
94
+ for (const candidate of candidates) console.error(" " + candidate);
79
95
  console.error(
80
- "[crust] Reinstall dependencies on this platform and ensure optional dependencies are enabled.",
96
+ "[" + NAME + "] Reinstall dependencies on this platform and ensure optional dependencies are enabled.",
81
97
  );
82
98
  process.exit(1);
83
99
  }
@@ -95,7 +111,7 @@ const child = spawn(binPath, process.argv.slice(2), {
95
111
  });
96
112
 
97
113
  child.on("error", (error) => {
98
- console.error("[crust] Failed to launch binary: " + error.message);
114
+ console.error("[" + NAME + "] Failed to launch binary: " + error.message);
99
115
  process.exit(1);
100
116
  });
101
117
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crustjs/crust",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "CLI tooling for the Crust framework",
5
5
  "license": "MIT",
6
6
  "author": "chenxin-yan",
@@ -25,21 +25,24 @@
25
25
  "access": "public"
26
26
  },
27
27
  "engines": {
28
- "bun": ">=1.3.14"
28
+ "bun": ">=1.4.0"
29
29
  },
30
30
  "type": "module",
31
31
  "files": [
32
- "bin"
32
+ "bin",
33
+ "schema"
33
34
  ],
34
35
  "bin": {
35
36
  "crust": "bin/crust.js"
36
37
  },
37
38
  "optionalDependencies": {
38
- "@crustjs/crust-linux-x64": "0.2.0",
39
- "@crustjs/crust-linux-arm64": "0.2.0",
40
- "@crustjs/crust-darwin-x64": "0.2.0",
41
- "@crustjs/crust-darwin-arm64": "0.2.0",
42
- "@crustjs/crust-windows-x64": "0.2.0",
43
- "@crustjs/crust-windows-arm64": "0.2.0"
39
+ "@crustjs/crust-linux-x64": "0.3.0",
40
+ "@crustjs/crust-linux-arm64": "0.3.0",
41
+ "@crustjs/crust-linux-x64-musl": "0.3.0",
42
+ "@crustjs/crust-linux-arm64-musl": "0.3.0",
43
+ "@crustjs/crust-darwin-x64": "0.3.0",
44
+ "@crustjs/crust-darwin-arm64": "0.3.0",
45
+ "@crustjs/crust-windows-x64": "0.3.0",
46
+ "@crustjs/crust-windows-arm64": "0.3.0"
44
47
  }
45
48
  }
@@ -0,0 +1,43 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "package.json with a Crust build configuration",
4
+ "description": "package.json schema for CLIs built with Crust. Point \"$schema\" at ./node_modules/@crustjs/crust/schema/package.json to get completion for the \"crust\" block alongside the standard package.json fields.",
5
+ "type": "object",
6
+ "allOf": [
7
+ {
8
+ "$ref": "https://json.schemastore.org/package.json"
9
+ }
10
+ ],
11
+ "properties": {
12
+ "crust": {
13
+ "description": "Build configuration read by `crust build`. Every key is optional; unknown keys fail the build. Command names and their source entries come from the standard `bin` field.",
14
+ "type": "object",
15
+ "additionalProperties": false,
16
+ "properties": {
17
+ "runtime": {
18
+ "description": "Runtime the CLI is built for. Without it: deno.json/deno.jsonc selects deno; @types/node without @types/bun selects node; otherwise bun.",
19
+ "type": "string",
20
+ "enum": [
21
+ "bun",
22
+ "deno",
23
+ "node"
24
+ ]
25
+ },
26
+ "bunPlugins": {
27
+ "description": "Bun bundler plugin modules applied to Bun and Node builds, in order: bare names resolve from node_modules, paths from the project root; each must default-export the plugin. Rejected for Deno.",
28
+ "type": "array",
29
+ "items": {
30
+ "type": "string"
31
+ }
32
+ },
33
+ "include": {
34
+ "description": "Directories relative to the project root that `crust build` copies into .crust/root/ and into each platform package's bin/.",
35
+ "type": "array",
36
+ "items": {
37
+ "type": "string"
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }