@zerolith/cli 0.0.0-stage → 0.1.0-alpha.2
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/LICENSE +201 -0
- package/README.md +12 -2
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +41 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -5
- package/src/bin.ts +48 -0
- package/src/index.ts +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zerolith/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `zerolith` command line from npm. The binary is written in Rust; this package carries none itself and depends optionally on one package per platform, so npm installs only the binary that matches the machine.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install --save-dev @zerolith/cli@alpha
|
|
7
|
+
npx zerolith new my-app
|
|
8
|
+
npx zerolith dev .
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Prebuilt binaries exist for Linux (glibc), macOS, and Windows on x64 and arm64. On any other system, or on Alpine and other musl distributions, install the crate with `cargo install zerolith` and point `ZEROLITH_BINARY_PATH` at the binary; the shim runs that instead. Installing with `--omit=optional` leaves the binary out, and the shim says which platform package to install.
|
|
12
|
+
|
|
13
|
+
The commands are documented in the [command line guide](https://molexxxx.github.io/zerolith/guide/command-line/).
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `zerolith`: runs the native command line from the platform package that
|
|
4
|
+
* matches this machine, passing the arguments and the exit status through.
|
|
5
|
+
*/
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import process from "node:process";
|
|
9
|
+
import { locate } from "./index.js";
|
|
10
|
+
function musl() {
|
|
11
|
+
if (process.platform !== "linux") {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const report = process.report?.getReport();
|
|
15
|
+
return report?.header?.glibcVersionRuntime === undefined;
|
|
16
|
+
}
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
let binary;
|
|
19
|
+
try {
|
|
20
|
+
binary = locate({
|
|
21
|
+
platform: process.platform,
|
|
22
|
+
arch: process.arch,
|
|
23
|
+
musl: musl(),
|
|
24
|
+
override: process.env["ZEROLITH_BINARY_PATH"],
|
|
25
|
+
resolve: (specifier) => require.resolve(specifier),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit", windowsHide: true });
|
|
33
|
+
if (result.error) {
|
|
34
|
+
process.stderr.write(`zerolith could not start ${binary}: ${result.error.message}\n`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
if (result.signal) {
|
|
38
|
+
process.kill(process.pid, result.signal);
|
|
39
|
+
}
|
|
40
|
+
process.exit(result.status ?? 1);
|
|
41
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,SAAS,IAAI;IAET,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAChC,CAAC;QACG,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,SAAS,EAA+D,CAAC;IACxG,OAAO,MAAM,EAAE,MAAM,EAAE,mBAAmB,KAAK,SAAS,CAAC;AAC7D,CAAC;AAED,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,IAAI,MAAc,CAAC;AACnB,IACA,CAAC;IACG,MAAM,GAAG,MAAM,CAAC;QACZ,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,IAAI,EAAE;QACZ,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;QAC7C,OAAO,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;KACrD,CAAC,CAAC;AACP,CAAC;AACD,OAAO,KAAK,EACZ,CAAC;IACG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AACD,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;AACjG,IAAI,MAAM,CAAC,KAAK,EAChB,CAAC;IACG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,MAAM,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;IACtF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AACD,IAAI,MAAM,CAAC,MAAM,EACjB,CAAC;IACG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;AACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the native `zerolith` binary for the running platform. `@zerolith/cli`
|
|
3
|
+
* carries no binary itself: one optional dependency per platform does, and
|
|
4
|
+
* npm installs only the one whose `os` and `cpu` match, so this module
|
|
5
|
+
* resolves that package or says what is missing and how to get a binary.
|
|
6
|
+
*/
|
|
7
|
+
/** The platform packages, keyed by `${platform}-${arch}` as Node reports them. */
|
|
8
|
+
export declare const PLATFORMS: Readonly<Record<string, string>>;
|
|
9
|
+
/** The route around a missing binary, appended to every error. */
|
|
10
|
+
export declare const CARGO_HINT = "Alternatively install the crate with `cargo install zerolith` and point ZEROLITH_BINARY_PATH at the binary.";
|
|
11
|
+
/** What locating needs from the host. */
|
|
12
|
+
export interface Host {
|
|
13
|
+
readonly platform: string;
|
|
14
|
+
readonly arch: string;
|
|
15
|
+
/** True on a Linux without glibc (Alpine and other musl systems), where the prebuilt binaries do not run. */
|
|
16
|
+
readonly musl?: boolean;
|
|
17
|
+
/** `ZEROLITH_BINARY_PATH`: a binary the user built or installed elsewhere, used as is. */
|
|
18
|
+
readonly override?: string | undefined;
|
|
19
|
+
/** `require.resolve` from the shim's location. */
|
|
20
|
+
readonly resolve: (specifier: string) => string;
|
|
21
|
+
}
|
|
22
|
+
/** The binary's file name on a platform. */
|
|
23
|
+
export declare function binaryName(platform: string): string;
|
|
24
|
+
/** The platform package for a platform and architecture, if one is built. */
|
|
25
|
+
export declare function platformPackage(platform: string, arch: string): string | undefined;
|
|
26
|
+
/** The path of the binary to run, or an error whose message says how to get one. */
|
|
27
|
+
export declare function locate(host: Host): string;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kFAAkF;AAClF,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOtD,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,UAAU,gHAC0F,CAAC;AAElH,yCAAyC;AACzC,MAAM,WAAW,IAAI;IAEjB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6GAA6G;IAC7G,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,0FAA0F;IAC1F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,kDAAkD;IAClD,QAAQ,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CACnD;AAED,4CAA4C;AAC5C,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGlF;AAED,oFAAoF;AACpF,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAsBzC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the native `zerolith` binary for the running platform. `@zerolith/cli`
|
|
3
|
+
* carries no binary itself: one optional dependency per platform does, and
|
|
4
|
+
* npm installs only the one whose `os` and `cpu` match, so this module
|
|
5
|
+
* resolves that package or says what is missing and how to get a binary.
|
|
6
|
+
*/
|
|
7
|
+
/** The platform packages, keyed by `${platform}-${arch}` as Node reports them. */
|
|
8
|
+
export const PLATFORMS = {
|
|
9
|
+
"darwin-arm64": "@zerolith/cli-darwin-arm64",
|
|
10
|
+
"darwin-x64": "@zerolith/cli-darwin-x64",
|
|
11
|
+
"linux-arm64": "@zerolith/cli-linux-arm64",
|
|
12
|
+
"linux-x64": "@zerolith/cli-linux-x64",
|
|
13
|
+
"win32-arm64": "@zerolith/cli-win32-arm64",
|
|
14
|
+
"win32-x64": "@zerolith/cli-win32-x64",
|
|
15
|
+
};
|
|
16
|
+
/** The route around a missing binary, appended to every error. */
|
|
17
|
+
export const CARGO_HINT = "Alternatively install the crate with `cargo install zerolith` and point ZEROLITH_BINARY_PATH at the binary.";
|
|
18
|
+
/** The binary's file name on a platform. */
|
|
19
|
+
export function binaryName(platform) {
|
|
20
|
+
return platform === "win32" ? "zerolith.exe" : "zerolith";
|
|
21
|
+
}
|
|
22
|
+
/** The platform package for a platform and architecture, if one is built. */
|
|
23
|
+
export function platformPackage(platform, arch) {
|
|
24
|
+
return PLATFORMS[`${platform}-${arch}`];
|
|
25
|
+
}
|
|
26
|
+
/** The path of the binary to run, or an error whose message says how to get one. */
|
|
27
|
+
export function locate(host) {
|
|
28
|
+
if (host.override) {
|
|
29
|
+
return host.override;
|
|
30
|
+
}
|
|
31
|
+
const name = platformPackage(host.platform, host.arch);
|
|
32
|
+
if (name === undefined || host.musl) {
|
|
33
|
+
const key = `${host.platform}-${host.arch}${host.musl ? " (musl)" : ""}`;
|
|
34
|
+
throw new Error(`zerolith has no prebuilt binary for ${key}. ${CARGO_HINT}`);
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
return host.resolve(`${name}/${binaryName(host.platform)}`);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
throw new Error(`${name}, the package that carries the zerolith binary for this platform, is not installed. Install @zerolith/cli without --omit=optional (its optional dependencies hold the binaries), or install ${name} directly. ${CARGO_HINT}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kFAAkF;AAClF,MAAM,CAAC,MAAM,SAAS,GAAqC;IACvD,cAAc,EAAE,4BAA4B;IAC5C,YAAY,EAAE,0BAA0B;IACxC,aAAa,EAAE,2BAA2B;IAC1C,WAAW,EAAE,yBAAyB;IACtC,aAAa,EAAE,2BAA2B;IAC1C,WAAW,EAAE,yBAAyB;CACzC,CAAC;AAEF,kEAAkE;AAClE,MAAM,CAAC,MAAM,UAAU,GACnB,6GAA6G,CAAC;AAelH,4CAA4C;AAC5C,MAAM,UAAU,UAAU,CAAC,QAAgB;IAEvC,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC;AAC9D,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,IAAY;IAE1D,OAAO,SAAS,CAAC,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,MAAM,CAAC,IAAU;IAE7B,IAAI,IAAI,CAAC,QAAQ,EACjB,CAAC;QACG,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IACD,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,EACnC,CAAC;QACG,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,KAAK,UAAU,EAAE,CAAC,CAAC;IACjF,CAAC;IACD,IACA,CAAC;QACG,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,MACA,CAAC;QACG,MAAM,IAAI,KAAK,CACX,GAAG,IAAI,+LAA+L,IAAI,cAAc,UAAU,EAAE,CACvO,CAAC;IACN,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@zerolith/cli",
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
|
+
"description": "The zerolith command line from npm: a dev server that serves TypeScript and JSX without a build step, a static build, import maps with integrity hashes, project checks, and the scaffold, as a prebuilt native binary for the platform npm installs on",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "molexxxx",
|
|
7
|
+
"homepage": "https://github.com/molexxxx/zerolith#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/molexxxx/zerolith.git",
|
|
11
|
+
"directory": "packages/cli"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/molexxxx/zerolith/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"zerolith",
|
|
18
|
+
"cli",
|
|
19
|
+
"dev-server",
|
|
20
|
+
"import-map",
|
|
21
|
+
"scaffold"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=24.0.0"
|
|
26
|
+
},
|
|
27
|
+
"bin": {
|
|
28
|
+
"zerolith": "dist/bin.js"
|
|
29
|
+
},
|
|
30
|
+
"exports": {
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"src",
|
|
36
|
+
"LICENSE",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc -p tsconfig.build.json"
|
|
41
|
+
},
|
|
42
|
+
"optionalDependencies": {
|
|
43
|
+
"@zerolith/cli-darwin-arm64": "0.1.0-alpha.2",
|
|
44
|
+
"@zerolith/cli-darwin-x64": "0.1.0-alpha.2",
|
|
45
|
+
"@zerolith/cli-linux-arm64": "0.1.0-alpha.2",
|
|
46
|
+
"@zerolith/cli-linux-x64": "0.1.0-alpha.2",
|
|
47
|
+
"@zerolith/cli-win32-arm64": "0.1.0-alpha.2",
|
|
48
|
+
"@zerolith/cli-win32-x64": "0.1.0-alpha.2"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/bin.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `zerolith`: runs the native command line from the platform package that
|
|
4
|
+
* matches this machine, passing the arguments and the exit status through.
|
|
5
|
+
*/
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import process from "node:process";
|
|
9
|
+
import { locate } from "./index.js";
|
|
10
|
+
|
|
11
|
+
function musl(): boolean
|
|
12
|
+
{
|
|
13
|
+
if (process.platform !== "linux")
|
|
14
|
+
{
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const report = process.report?.getReport() as { header?: { glibcVersionRuntime?: string } } | undefined;
|
|
18
|
+
return report?.header?.glibcVersionRuntime === undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
22
|
+
let binary: string;
|
|
23
|
+
try
|
|
24
|
+
{
|
|
25
|
+
binary = locate({
|
|
26
|
+
platform: process.platform,
|
|
27
|
+
arch: process.arch,
|
|
28
|
+
musl: musl(),
|
|
29
|
+
override: process.env["ZEROLITH_BINARY_PATH"],
|
|
30
|
+
resolve: (specifier) => require.resolve(specifier),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch (error)
|
|
34
|
+
{
|
|
35
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit", windowsHide: true });
|
|
39
|
+
if (result.error)
|
|
40
|
+
{
|
|
41
|
+
process.stderr.write(`zerolith could not start ${binary}: ${result.error.message}\n`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
if (result.signal)
|
|
45
|
+
{
|
|
46
|
+
process.kill(process.pid, result.signal);
|
|
47
|
+
}
|
|
48
|
+
process.exit(result.status ?? 1);
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the native `zerolith` binary for the running platform. `@zerolith/cli`
|
|
3
|
+
* carries no binary itself: one optional dependency per platform does, and
|
|
4
|
+
* npm installs only the one whose `os` and `cpu` match, so this module
|
|
5
|
+
* resolves that package or says what is missing and how to get a binary.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** The platform packages, keyed by `${platform}-${arch}` as Node reports them. */
|
|
9
|
+
export const PLATFORMS: Readonly<Record<string, string>> = {
|
|
10
|
+
"darwin-arm64": "@zerolith/cli-darwin-arm64",
|
|
11
|
+
"darwin-x64": "@zerolith/cli-darwin-x64",
|
|
12
|
+
"linux-arm64": "@zerolith/cli-linux-arm64",
|
|
13
|
+
"linux-x64": "@zerolith/cli-linux-x64",
|
|
14
|
+
"win32-arm64": "@zerolith/cli-win32-arm64",
|
|
15
|
+
"win32-x64": "@zerolith/cli-win32-x64",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** The route around a missing binary, appended to every error. */
|
|
19
|
+
export const CARGO_HINT =
|
|
20
|
+
"Alternatively install the crate with `cargo install zerolith` and point ZEROLITH_BINARY_PATH at the binary.";
|
|
21
|
+
|
|
22
|
+
/** What locating needs from the host. */
|
|
23
|
+
export interface Host
|
|
24
|
+
{
|
|
25
|
+
readonly platform: string;
|
|
26
|
+
readonly arch: string;
|
|
27
|
+
/** True on a Linux without glibc (Alpine and other musl systems), where the prebuilt binaries do not run. */
|
|
28
|
+
readonly musl?: boolean;
|
|
29
|
+
/** `ZEROLITH_BINARY_PATH`: a binary the user built or installed elsewhere, used as is. */
|
|
30
|
+
readonly override?: string | undefined;
|
|
31
|
+
/** `require.resolve` from the shim's location. */
|
|
32
|
+
readonly resolve: (specifier: string) => string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The binary's file name on a platform. */
|
|
36
|
+
export function binaryName(platform: string): string
|
|
37
|
+
{
|
|
38
|
+
return platform === "win32" ? "zerolith.exe" : "zerolith";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The platform package for a platform and architecture, if one is built. */
|
|
42
|
+
export function platformPackage(platform: string, arch: string): string | undefined
|
|
43
|
+
{
|
|
44
|
+
return PLATFORMS[`${platform}-${arch}`];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The path of the binary to run, or an error whose message says how to get one. */
|
|
48
|
+
export function locate(host: Host): string
|
|
49
|
+
{
|
|
50
|
+
if (host.override)
|
|
51
|
+
{
|
|
52
|
+
return host.override;
|
|
53
|
+
}
|
|
54
|
+
const name = platformPackage(host.platform, host.arch);
|
|
55
|
+
if (name === undefined || host.musl)
|
|
56
|
+
{
|
|
57
|
+
const key = `${host.platform}-${host.arch}${host.musl ? " (musl)" : ""}`;
|
|
58
|
+
throw new Error(`zerolith has no prebuilt binary for ${key}. ${CARGO_HINT}`);
|
|
59
|
+
}
|
|
60
|
+
try
|
|
61
|
+
{
|
|
62
|
+
return host.resolve(`${name}/${binaryName(host.platform)}`);
|
|
63
|
+
}
|
|
64
|
+
catch
|
|
65
|
+
{
|
|
66
|
+
throw new Error(
|
|
67
|
+
`${name}, the package that carries the zerolith binary for this platform, is not installed. Install @zerolith/cli without --omit=optional (its optional dependencies hold the binaries), or install ${name} directly. ${CARGO_HINT}`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|