create-mailslot 0.1.1 → 0.2.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/lib/run.js +6 -1
- package/lib/scaffold.js +5 -2
- package/package.json +1 -1
package/lib/run.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
2
3
|
import { writeFile } from "node:fs/promises";
|
|
3
4
|
import { join, resolve } from "node:path";
|
|
4
5
|
import * as p from "@clack/prompts";
|
|
@@ -7,6 +8,10 @@ import { mxRecords, isCloudflareMx, isCloudflareNs, findZone, waitForCloudflareM
|
|
|
7
8
|
import { templates, writeScaffold } from "./scaffold.js";
|
|
8
9
|
import { zoneId, routingStatus, enableRouting, setCatchAllToWorker } from "./cf-api.js";
|
|
9
10
|
|
|
11
|
+
// Wizard and core ship in lockstep (same repo version), so the inbox we
|
|
12
|
+
// scaffold should depend on the core that matches THIS wizard's version.
|
|
13
|
+
const selfVersion = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
14
|
+
|
|
10
15
|
export function parseArgs(argv) {
|
|
11
16
|
const flags = {};
|
|
12
17
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -133,7 +138,7 @@ export async function run(argv) {
|
|
|
133
138
|
const routingReady = isCloudflareMx(domainMx);
|
|
134
139
|
|
|
135
140
|
// ---- scaffold ----
|
|
136
|
-
const coreSpec = flags["core-spec"] ??
|
|
141
|
+
const coreSpec = flags["core-spec"] ?? `^${selfVersion}`;
|
|
137
142
|
const files = templates({ workerName, coreSpec });
|
|
138
143
|
await writeScaffold(dir, files);
|
|
139
144
|
p.log.success(`Scaffolded ${dir}`);
|
package/lib/scaffold.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { mkdir, readdir, writeFile } from "node:fs/promises";
|
|
2
2
|
import { join, dirname } from "node:path";
|
|
3
3
|
|
|
4
|
-
/** Render the files of a scaffolded Mailslot project.
|
|
5
|
-
|
|
4
|
+
/** Render the files of a scaffolded Mailslot project.
|
|
5
|
+
* coreSpec (e.g. "^0.2.0") is required — run.js derives it from the wizard's
|
|
6
|
+
* own version so the scaffold can't drift from the core it shipped with. */
|
|
7
|
+
export function templates({ workerName, coreSpec }) {
|
|
8
|
+
if (!coreSpec) throw new Error("templates: coreSpec is required");
|
|
6
9
|
const pkg = {
|
|
7
10
|
name: workerName,
|
|
8
11
|
private: true,
|