@zerolith/cli 0.0.0-canary.20261102.g8292c77
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 +37 -0
- package/assets.d.ts +260 -0
- 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 +56 -0
- package/src/bin.ts +48 -0
- package/src/index.ts +70 -0
- package/zerolith.schema.json +97 -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
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @zerolith/cli
|
|
2
|
+
|
|
3
|
+
The `zerolith` command line from npm: `new`, `dev`, which serves a project with its packages resolved from `node_modules` and forwards its API to a backend, `serve`, `build`, which bundles and minifies an application with Rolldown compiled into the binary, `preview`, `skill`, which writes the zerolith skill for coding agents into a project, `importmap`, and `doctor`. 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
|
+
Install it once and start a project. `new` asks a few questions, each with a default, writes the starter, and installs its dependencies, this package among them:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install --global @zerolith/cli@alpha
|
|
9
|
+
zerolith new my-app
|
|
10
|
+
cd my-app
|
|
11
|
+
zerolith dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Without a global install, `npx @zerolith/cli@alpha new my-app` does the same, and inside the project `npx zerolith dev` and its npm scripts run the copy it lists.
|
|
15
|
+
|
|
16
|
+
Or add it to an existing project and call it through `npx`:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
npm install --save-dev @zerolith/cli@alpha
|
|
20
|
+
npx zerolith doctor .
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
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 --locked` 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.
|
|
24
|
+
|
|
25
|
+
The commands are documented in the [command line guide](https://zerolith.dev/guide/command-line/).
|
|
26
|
+
|
|
27
|
+
Status: alpha. The commands and their flags may change before 1.0.
|
|
28
|
+
|
|
29
|
+
## Documentation
|
|
30
|
+
|
|
31
|
+
- The [command line guide](https://zerolith.dev/guide/command-line/) covers every command and option, and `zerolith.json`.
|
|
32
|
+
- [Building and serving](https://zerolith.dev/guide/deploying/) covers what the build writes and how to serve it from a static host, a web server, or a backend.
|
|
33
|
+
- New to zerolith? The [tutorial](https://zerolith.dev/learn/) builds an app step by step, and the [playground](https://zerolith.dev/playground/) runs code in the browser.
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
Apache-2.0. See `LICENSE`.
|
package/assets.d.ts
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The types of the files `zerolith dev` and `zerolith build` turn into
|
|
3
|
+
* values when a module imports them, for a project's `env.d.ts` to
|
|
4
|
+
* reference with `/// <reference types="@zerolith/cli/assets" />`. An
|
|
5
|
+
* image, a font, media, or a document gives its URL, `?url` gives any
|
|
6
|
+
* file's URL, and `?raw` gives a file's text. A project on Vite takes the
|
|
7
|
+
* same types from `vite/client` instead, since both declare these modules.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** A file imported for its text, as in `import notes from "./notes.md?raw"`. */
|
|
11
|
+
declare module "*?raw"
|
|
12
|
+
{
|
|
13
|
+
const text: string;
|
|
14
|
+
export default text;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Any file imported for its URL, as in `import url from "./worker.js?url"`. */
|
|
18
|
+
declare module "*?url"
|
|
19
|
+
{
|
|
20
|
+
const url: string;
|
|
21
|
+
export default url;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A `.apng` file, imported for its URL. */
|
|
25
|
+
declare module "*.apng"
|
|
26
|
+
{
|
|
27
|
+
const url: string;
|
|
28
|
+
export default url;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A `.bmp` file, imported for its URL. */
|
|
32
|
+
declare module "*.bmp"
|
|
33
|
+
{
|
|
34
|
+
const url: string;
|
|
35
|
+
export default url;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A `.png` file, imported for its URL. */
|
|
39
|
+
declare module "*.png"
|
|
40
|
+
{
|
|
41
|
+
const url: string;
|
|
42
|
+
export default url;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A `.jpg` file, imported for its URL. */
|
|
46
|
+
declare module "*.jpg"
|
|
47
|
+
{
|
|
48
|
+
const url: string;
|
|
49
|
+
export default url;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A `.jpeg` file, imported for its URL. */
|
|
53
|
+
declare module "*.jpeg"
|
|
54
|
+
{
|
|
55
|
+
const url: string;
|
|
56
|
+
export default url;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A `.jfif` file, imported for its URL. */
|
|
60
|
+
declare module "*.jfif"
|
|
61
|
+
{
|
|
62
|
+
const url: string;
|
|
63
|
+
export default url;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A `.pjpeg` file, imported for its URL. */
|
|
67
|
+
declare module "*.pjpeg"
|
|
68
|
+
{
|
|
69
|
+
const url: string;
|
|
70
|
+
export default url;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A `.pjp` file, imported for its URL. */
|
|
74
|
+
declare module "*.pjp"
|
|
75
|
+
{
|
|
76
|
+
const url: string;
|
|
77
|
+
export default url;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** A `.gif` file, imported for its URL. */
|
|
81
|
+
declare module "*.gif"
|
|
82
|
+
{
|
|
83
|
+
const url: string;
|
|
84
|
+
export default url;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** A `.svg` file, imported for its URL. */
|
|
88
|
+
declare module "*.svg"
|
|
89
|
+
{
|
|
90
|
+
const url: string;
|
|
91
|
+
export default url;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** A `.ico` file, imported for its URL. */
|
|
95
|
+
declare module "*.ico"
|
|
96
|
+
{
|
|
97
|
+
const url: string;
|
|
98
|
+
export default url;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** A `.webp` file, imported for its URL. */
|
|
102
|
+
declare module "*.webp"
|
|
103
|
+
{
|
|
104
|
+
const url: string;
|
|
105
|
+
export default url;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** A `.avif` file, imported for its URL. */
|
|
109
|
+
declare module "*.avif"
|
|
110
|
+
{
|
|
111
|
+
const url: string;
|
|
112
|
+
export default url;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** A `.cur` file, imported for its URL. */
|
|
116
|
+
declare module "*.cur"
|
|
117
|
+
{
|
|
118
|
+
const url: string;
|
|
119
|
+
export default url;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** A `.jxl` file, imported for its URL. */
|
|
123
|
+
declare module "*.jxl"
|
|
124
|
+
{
|
|
125
|
+
const url: string;
|
|
126
|
+
export default url;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** A `.mp4` file, imported for its URL. */
|
|
130
|
+
declare module "*.mp4"
|
|
131
|
+
{
|
|
132
|
+
const url: string;
|
|
133
|
+
export default url;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** A `.webm` file, imported for its URL. */
|
|
137
|
+
declare module "*.webm"
|
|
138
|
+
{
|
|
139
|
+
const url: string;
|
|
140
|
+
export default url;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** A `.ogg` file, imported for its URL. */
|
|
144
|
+
declare module "*.ogg"
|
|
145
|
+
{
|
|
146
|
+
const url: string;
|
|
147
|
+
export default url;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** A `.mp3` file, imported for its URL. */
|
|
151
|
+
declare module "*.mp3"
|
|
152
|
+
{
|
|
153
|
+
const url: string;
|
|
154
|
+
export default url;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** A `.wav` file, imported for its URL. */
|
|
158
|
+
declare module "*.wav"
|
|
159
|
+
{
|
|
160
|
+
const url: string;
|
|
161
|
+
export default url;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** A `.flac` file, imported for its URL. */
|
|
165
|
+
declare module "*.flac"
|
|
166
|
+
{
|
|
167
|
+
const url: string;
|
|
168
|
+
export default url;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** A `.aac` file, imported for its URL. */
|
|
172
|
+
declare module "*.aac"
|
|
173
|
+
{
|
|
174
|
+
const url: string;
|
|
175
|
+
export default url;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** A `.opus` file, imported for its URL. */
|
|
179
|
+
declare module "*.opus"
|
|
180
|
+
{
|
|
181
|
+
const url: string;
|
|
182
|
+
export default url;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** A `.mov` file, imported for its URL. */
|
|
186
|
+
declare module "*.mov"
|
|
187
|
+
{
|
|
188
|
+
const url: string;
|
|
189
|
+
export default url;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** A `.m4a` file, imported for its URL. */
|
|
193
|
+
declare module "*.m4a"
|
|
194
|
+
{
|
|
195
|
+
const url: string;
|
|
196
|
+
export default url;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** A `.vtt` file, imported for its URL. */
|
|
200
|
+
declare module "*.vtt"
|
|
201
|
+
{
|
|
202
|
+
const url: string;
|
|
203
|
+
export default url;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** A `.woff` file, imported for its URL. */
|
|
207
|
+
declare module "*.woff"
|
|
208
|
+
{
|
|
209
|
+
const url: string;
|
|
210
|
+
export default url;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** A `.woff2` file, imported for its URL. */
|
|
214
|
+
declare module "*.woff2"
|
|
215
|
+
{
|
|
216
|
+
const url: string;
|
|
217
|
+
export default url;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** A `.eot` file, imported for its URL. */
|
|
221
|
+
declare module "*.eot"
|
|
222
|
+
{
|
|
223
|
+
const url: string;
|
|
224
|
+
export default url;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** A `.ttf` file, imported for its URL. */
|
|
228
|
+
declare module "*.ttf"
|
|
229
|
+
{
|
|
230
|
+
const url: string;
|
|
231
|
+
export default url;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** A `.otf` file, imported for its URL. */
|
|
235
|
+
declare module "*.otf"
|
|
236
|
+
{
|
|
237
|
+
const url: string;
|
|
238
|
+
export default url;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** A `.webmanifest` file, imported for its URL. */
|
|
242
|
+
declare module "*.webmanifest"
|
|
243
|
+
{
|
|
244
|
+
const url: string;
|
|
245
|
+
export default url;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** A `.pdf` file, imported for its URL. */
|
|
249
|
+
declare module "*.pdf"
|
|
250
|
+
{
|
|
251
|
+
const url: string;
|
|
252
|
+
export default url;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** A `.txt` file, imported for its URL. */
|
|
256
|
+
declare module "*.txt"
|
|
257
|
+
{
|
|
258
|
+
const url: string;
|
|
259
|
+
export default url;
|
|
260
|
+
}
|
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 --locked` 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,yHACmG,CAAC;AAE3H,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 --locked` 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. When npx ran this from a copy it cached before ${name} reached the registry, that copy lacks it: delete the _npx folder in npm's cache, which \`npm config get cache\` prints, and run the command again. ${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,sHAAsH,CAAC;AAe3H,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,6DAA6D,IAAI,uJAAuJ,UAAU,EAAE,CACjb,CAAC;IACN,CAAC;AACL,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zerolith/cli",
|
|
3
|
+
"version": "0.0.0-canary.20261102.g8292c77",
|
|
4
|
+
"description": "The zerolith command line from npm: a production build that bundles and minifies, a dev server that serves TypeScript and JSX without a build step, 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://zerolith.dev/",
|
|
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
|
+
"./assets": {
|
|
32
|
+
"types": "./assets.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json",
|
|
35
|
+
"./zerolith.schema.json": "./zerolith.schema.json"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"src",
|
|
40
|
+
"assets.d.ts",
|
|
41
|
+
"zerolith.schema.json",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"README.md"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc -p tsconfig.build.json"
|
|
47
|
+
},
|
|
48
|
+
"optionalDependencies": {
|
|
49
|
+
"@zerolith/cli-darwin-arm64": "0.0.0-canary.20261102.g8292c77",
|
|
50
|
+
"@zerolith/cli-darwin-x64": "0.0.0-canary.20261102.g8292c77",
|
|
51
|
+
"@zerolith/cli-linux-arm64": "0.0.0-canary.20261102.g8292c77",
|
|
52
|
+
"@zerolith/cli-linux-x64": "0.0.0-canary.20261102.g8292c77",
|
|
53
|
+
"@zerolith/cli-win32-arm64": "0.0.0-canary.20261102.g8292c77",
|
|
54
|
+
"@zerolith/cli-win32-x64": "0.0.0-canary.20261102.g8292c77"
|
|
55
|
+
}
|
|
56
|
+
}
|
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 --locked` 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. When npx ran this from a copy it cached before ${name} reached the registry, that copy lacks it: delete the _npx folder in npm's cache, which \`npm config get cache\` prints, and run the command again. ${CARGO_HINT}`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://zerolith.dev/zerolith.schema.json",
|
|
4
|
+
"title": "zerolith.json",
|
|
5
|
+
"description": "The settings zerolith dev, serve, build, and preview share. A flag given on the command line overrides the file.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The schema an editor validates this file against."
|
|
12
|
+
},
|
|
13
|
+
"base": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "The public path the application is served under, such as /app/, for dev, build, and preview alike. ./ makes every URL the build writes relative to the page.",
|
|
16
|
+
"examples": ["/", "/app/", "./"]
|
|
17
|
+
},
|
|
18
|
+
"allowedHosts": {
|
|
19
|
+
"type": "array",
|
|
20
|
+
"description": "Host names dev, serve, and preview answer besides localhost and IP addresses, such as a name in the hosts file or a tunnel's. A request for any other host gets 403, so another site cannot read the project by pointing its own name at the loopback address (DNS rebinding). An entry starting with a dot allows every name under it.",
|
|
21
|
+
"items": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
"examples": [["myapp.test"], [".example.dev"]]
|
|
25
|
+
},
|
|
26
|
+
"proxy": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"description": "Paths dev, serve, and preview forward to a backend, by the path prefix they start with, such as \"/api\": \"http://127.0.0.1:3000\".",
|
|
29
|
+
"propertyNames": {
|
|
30
|
+
"pattern": "^/"
|
|
31
|
+
},
|
|
32
|
+
"additionalProperties": {
|
|
33
|
+
"oneOf": [
|
|
34
|
+
{
|
|
35
|
+
"type": "string",
|
|
36
|
+
"pattern": "^http://",
|
|
37
|
+
"description": "The backend's address. The request's whole path is forwarded."
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"type": "object",
|
|
41
|
+
"additionalProperties": false,
|
|
42
|
+
"required": ["target"],
|
|
43
|
+
"properties": {
|
|
44
|
+
"target": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"pattern": "^http://",
|
|
47
|
+
"description": "The backend's address, with an optional path the forwarded path goes under."
|
|
48
|
+
},
|
|
49
|
+
"stripPrefix": {
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"default": false,
|
|
52
|
+
"description": "Remove the matched prefix before forwarding, so /api/notes reaches the backend as /notes."
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"dev": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"additionalProperties": false,
|
|
62
|
+
"properties": {
|
|
63
|
+
"port": {
|
|
64
|
+
"type": "integer",
|
|
65
|
+
"minimum": 0,
|
|
66
|
+
"maximum": 65535,
|
|
67
|
+
"default": 8080,
|
|
68
|
+
"description": "The port zerolith dev and serve listen on."
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"preview": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"additionalProperties": false,
|
|
75
|
+
"properties": {
|
|
76
|
+
"port": {
|
|
77
|
+
"type": "integer",
|
|
78
|
+
"minimum": 0,
|
|
79
|
+
"maximum": 65535,
|
|
80
|
+
"default": 4173,
|
|
81
|
+
"description": "The port zerolith preview listens on."
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"build": {
|
|
86
|
+
"type": "object",
|
|
87
|
+
"additionalProperties": false,
|
|
88
|
+
"properties": {
|
|
89
|
+
"out": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"default": "dist",
|
|
92
|
+
"description": "The output folder, relative to the project unless absolute, such as the static folder of a backend next to it."
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|