webnek 0.1.4 → 0.1.5
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/bin/cli.mjs +20 -0
- package/package.json +1 -1
- package/template/.cargo/config.toml +4 -0
- package/template/.vercelignore +3 -0
- package/template/README.md +4 -0
package/bin/cli.mjs
CHANGED
|
@@ -117,6 +117,25 @@ function copyTemplate(from, to, vars) {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
// Vercel's Rust builder (@vercel/rust) parses .cargo/config.toml whenever it
|
|
121
|
+
// exists and reads `build.target` without checking that a [build] table is
|
|
122
|
+
// present. An alias-only config kills every deploy with
|
|
123
|
+
// "Cannot read properties of undefined (reading 'target')".
|
|
124
|
+
// Guarantee scaffolded apps never ship that footgun.
|
|
125
|
+
function healCargoConfig(appDir) {
|
|
126
|
+
const p = join(appDir, ".cargo", "config.toml");
|
|
127
|
+
if (!existsSync(p)) return;
|
|
128
|
+
const text = readFileSync(p, "utf8");
|
|
129
|
+
const hasBuild = text
|
|
130
|
+
.split("\n")
|
|
131
|
+
.some((l) => /^\s*(\[build[\].]|build\.)/.test(l));
|
|
132
|
+
if (hasBuild) return;
|
|
133
|
+
writeFileSync(
|
|
134
|
+
p,
|
|
135
|
+
`${text.endsWith("\n") ? text : `${text}\n`}\n# Vercel's Rust builder requires a [build] table to exist when this file does.\n[build]\n`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
120
139
|
function stripNodeManifests(appDir) {
|
|
121
140
|
for (const leftover of [
|
|
122
141
|
"package.json",
|
|
@@ -186,6 +205,7 @@ function scaffold(targetArg) {
|
|
|
186
205
|
PROJECT_NAME: pkgName,
|
|
187
206
|
});
|
|
188
207
|
stripNodeManifests(appDir);
|
|
208
|
+
healCargoConfig(appDir);
|
|
189
209
|
|
|
190
210
|
const rel = relative(process.cwd(), appDir) || ".";
|
|
191
211
|
const built = cargoBuild(appDir);
|
package/package.json
CHANGED
package/template/.vercelignore
CHANGED
package/template/README.md
CHANGED
|
@@ -13,3 +13,7 @@ cargo dev
|
|
|
13
13
|
```bash
|
|
14
14
|
vercel
|
|
15
15
|
```
|
|
16
|
+
|
|
17
|
+
Vercel compiles `api/index.rs` into a Rust function; everything else rewrites to it (`vercel.json`).
|
|
18
|
+
|
|
19
|
+
Note: `.cargo/config.toml` must keep a `[build]` table (even empty) — Vercel's Rust builder crashes on configs without one. `.vercelignore` also keeps `.cargo` out of deploys.
|