@we8/cloudflare 0.1.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 +57 -0
- package/dist/cli-args.d.ts +22 -0
- package/dist/cli-args.d.ts.map +1 -0
- package/dist/cli-args.js +76 -0
- package/dist/cli-args.js.map +1 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +122 -0
- package/dist/cli.js.map +1 -0
- package/dist/doctor.d.ts +87 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +236 -0
- package/dist/doctor.js.map +1 -0
- package/dist/email.d.ts +80 -0
- package/dist/email.d.ts.map +1 -0
- package/dist/email.js +104 -0
- package/dist/email.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonc.d.ts +15 -0
- package/dist/jsonc.d.ts.map +1 -0
- package/dist/jsonc.js +60 -0
- package/dist/jsonc.js.map +1 -0
- package/dist/project.d.ts +26 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +112 -0
- package/dist/project.js.map +1 -0
- package/dist/wrangler-config.d.ts +65 -0
- package/dist/wrangler-config.d.ts.map +1 -0
- package/dist/wrangler-config.js +179 -0
- package/dist/wrangler-config.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAiE3E,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAA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,CAAC;IACzE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;IAEzE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CACR,MAAM,CAAC,EAAE;QACP,CAAC,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,YAAY;QAChF,CAAC,CAAC,cAAc,MAAM,CAAC,QAAQ,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CACvF,CAAC;IAEF,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
|
package/dist/email.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The real sender: Cloudflare Email Service, behind the CMS email seam.
|
|
3
|
+
*
|
|
4
|
+
* The seam's types are restated here rather than imported from `@we8/cms`.
|
|
5
|
+
* The pack declares the CMS as a peer, not a dependency, so that the two
|
|
6
|
+
* typecheck and build in any order and neither has to be built before the
|
|
7
|
+
* other; `EmailSender` is structural, so a class shaped like this one
|
|
8
|
+
* satisfies the interface wherever a composed worker registers it. The
|
|
9
|
+
* generated project's own typecheck is what proves the two still line up.
|
|
10
|
+
*/
|
|
11
|
+
/** One message, as the CMS hands it over. */
|
|
12
|
+
export interface EmailMessage {
|
|
13
|
+
to: string[];
|
|
14
|
+
subject: string;
|
|
15
|
+
html: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
/** The seam. Mirrors `EmailSender` in `@we8/cms`. */
|
|
19
|
+
export interface EmailSender {
|
|
20
|
+
send(message: EmailMessage): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
/** What Cloudflare Email Service returns from a successful send. */
|
|
23
|
+
export interface EmailSendResult {
|
|
24
|
+
messageId: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The `send_email` binding, narrowed to the fields this pack uses. Cloudflare
|
|
28
|
+
* accepts far more (cc, bcc, replyTo, attachments, headers); a form
|
|
29
|
+
* notification and a password reset need none of it.
|
|
30
|
+
*/
|
|
31
|
+
export interface SendEmailBinding {
|
|
32
|
+
send(message: {
|
|
33
|
+
to: string | string[];
|
|
34
|
+
from: string;
|
|
35
|
+
subject: string;
|
|
36
|
+
html?: string;
|
|
37
|
+
text?: string;
|
|
38
|
+
}): Promise<EmailSendResult>;
|
|
39
|
+
}
|
|
40
|
+
/** The slice of a worker environment this sender reads. */
|
|
41
|
+
export interface CloudflareEmailEnv {
|
|
42
|
+
EMAIL?: SendEmailBinding | undefined;
|
|
43
|
+
EMAIL_MODE?: string | undefined;
|
|
44
|
+
EMAIL_FROM?: string | undefined;
|
|
45
|
+
}
|
|
46
|
+
/** The `EMAIL_MODE` value that turns this sender on. */
|
|
47
|
+
export declare const CLOUDFLARE_EMAIL_MODE = "cloudflare";
|
|
48
|
+
/** Cloudflare caps a single send at 50 addresses across to, cc, and bcc. */
|
|
49
|
+
export declare const MAX_RECIPIENTS = 50;
|
|
50
|
+
/**
|
|
51
|
+
* Sends over a `send_email` binding and never throws. Mail from a CMS is
|
|
52
|
+
* always a side effect of something that already succeeded: a submission was
|
|
53
|
+
* stored, an account was created. A transport failure is logged and the caller
|
|
54
|
+
* carries on, because turning a captured lead into a 500 is the worse outcome.
|
|
55
|
+
*/
|
|
56
|
+
export declare class CloudflareEmailSender implements EmailSender {
|
|
57
|
+
#private;
|
|
58
|
+
constructor(binding: SendEmailBinding, from: string);
|
|
59
|
+
send(message: EmailMessage): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Decides whether this environment wants the Cloudflare sender, and says why
|
|
63
|
+
* it does not when it does not. Split out from the factory so the doctor can
|
|
64
|
+
* report the same verdict without constructing anything.
|
|
65
|
+
*/
|
|
66
|
+
export declare function inspectEmailConfig(env: CloudflareEmailEnv): {
|
|
67
|
+
enabled: boolean;
|
|
68
|
+
reason: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The factory a composed worker registers with the CMS. Off unless the site
|
|
72
|
+
* asked for it: anything short of `EMAIL_MODE=cloudflare` plus a bound `EMAIL`
|
|
73
|
+
* plus a valid `EMAIL_FROM` returns null and the CMS falls back to its own
|
|
74
|
+
* resolution, so installing the pack never changes how a site behaves.
|
|
75
|
+
*
|
|
76
|
+
* A half-configured site is the one case worth a log line, because silence
|
|
77
|
+
* there looks exactly like mail that was sent.
|
|
78
|
+
*/
|
|
79
|
+
export declare function cloudflareEmailSender(env: unknown): EmailSender | null;
|
|
80
|
+
//# sourceMappingURL=email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../src/email.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,6CAA6C;AAC7C,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,OAAO,EAAE;QACZ,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC9B;AAED,2DAA2D;AAC3D,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,wDAAwD;AACxD,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD,4EAA4E;AAC5E,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,WAAW;;gBAI3C,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM;IAK7C,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CA8BjD;AAOD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,kBAAkB,GAAG;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAiBA;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CActE"}
|
package/dist/email.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The real sender: Cloudflare Email Service, behind the CMS email seam.
|
|
3
|
+
*
|
|
4
|
+
* The seam's types are restated here rather than imported from `@we8/cms`.
|
|
5
|
+
* The pack declares the CMS as a peer, not a dependency, so that the two
|
|
6
|
+
* typecheck and build in any order and neither has to be built before the
|
|
7
|
+
* other; `EmailSender` is structural, so a class shaped like this one
|
|
8
|
+
* satisfies the interface wherever a composed worker registers it. The
|
|
9
|
+
* generated project's own typecheck is what proves the two still line up.
|
|
10
|
+
*/
|
|
11
|
+
/** The `EMAIL_MODE` value that turns this sender on. */
|
|
12
|
+
export const CLOUDFLARE_EMAIL_MODE = 'cloudflare';
|
|
13
|
+
/** Cloudflare caps a single send at 50 addresses across to, cc, and bcc. */
|
|
14
|
+
export const MAX_RECIPIENTS = 50;
|
|
15
|
+
/**
|
|
16
|
+
* Sends over a `send_email` binding and never throws. Mail from a CMS is
|
|
17
|
+
* always a side effect of something that already succeeded: a submission was
|
|
18
|
+
* stored, an account was created. A transport failure is logged and the caller
|
|
19
|
+
* carries on, because turning a captured lead into a 500 is the worse outcome.
|
|
20
|
+
*/
|
|
21
|
+
export class CloudflareEmailSender {
|
|
22
|
+
#binding;
|
|
23
|
+
#from;
|
|
24
|
+
constructor(binding, from) {
|
|
25
|
+
this.#binding = binding;
|
|
26
|
+
this.#from = from;
|
|
27
|
+
}
|
|
28
|
+
async send(message) {
|
|
29
|
+
const to = message.to.filter((address) => address.trim().length > 0);
|
|
30
|
+
if (to.length === 0)
|
|
31
|
+
return;
|
|
32
|
+
if (to.length > MAX_RECIPIENTS) {
|
|
33
|
+
console.warn(`[email] ${String(to.length)} recipients exceeds the ${String(MAX_RECIPIENTS)} Cloudflare allows; sending to the first ${String(MAX_RECIPIENTS)}`);
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const result = await this.#binding.send({
|
|
37
|
+
to: to.slice(0, MAX_RECIPIENTS),
|
|
38
|
+
from: this.#from,
|
|
39
|
+
subject: message.subject,
|
|
40
|
+
html: message.html,
|
|
41
|
+
text: message.text,
|
|
42
|
+
});
|
|
43
|
+
console.log(`[email] sent messageId=${result.messageId} recipients=${String(to.length)}`);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
// A `code` property is how Email Service reports why it refused.
|
|
47
|
+
const code = typeof error === 'object' && error !== null && 'code' in error
|
|
48
|
+
? ` code=${String(error.code)}`
|
|
49
|
+
: '';
|
|
50
|
+
console.error(`[email] cloudflare send failed${code}: ${error instanceof Error ? error.message : String(error)}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** True when the value looks like a single addr-spec. Deliberately loose. */
|
|
55
|
+
function isEmailAddress(value) {
|
|
56
|
+
return /^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/.test(value);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Decides whether this environment wants the Cloudflare sender, and says why
|
|
60
|
+
* it does not when it does not. Split out from the factory so the doctor can
|
|
61
|
+
* report the same verdict without constructing anything.
|
|
62
|
+
*/
|
|
63
|
+
export function inspectEmailConfig(env) {
|
|
64
|
+
if (env.EMAIL_MODE !== CLOUDFLARE_EMAIL_MODE) {
|
|
65
|
+
return {
|
|
66
|
+
enabled: false,
|
|
67
|
+
reason: `EMAIL_MODE is ${env.EMAIL_MODE ? `"${env.EMAIL_MODE}"` : 'unset'}, not "${CLOUDFLARE_EMAIL_MODE}"`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (!env.EMAIL || typeof env.EMAIL.send !== 'function') {
|
|
71
|
+
return { enabled: false, reason: 'the send_email binding named EMAIL is missing' };
|
|
72
|
+
}
|
|
73
|
+
if (!env.EMAIL_FROM) {
|
|
74
|
+
return { enabled: false, reason: 'EMAIL_FROM is not set' };
|
|
75
|
+
}
|
|
76
|
+
if (!isEmailAddress(env.EMAIL_FROM)) {
|
|
77
|
+
return { enabled: false, reason: `EMAIL_FROM is not an email address: "${env.EMAIL_FROM}"` };
|
|
78
|
+
}
|
|
79
|
+
return { enabled: true, reason: `sending as ${env.EMAIL_FROM}` };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The factory a composed worker registers with the CMS. Off unless the site
|
|
83
|
+
* asked for it: anything short of `EMAIL_MODE=cloudflare` plus a bound `EMAIL`
|
|
84
|
+
* plus a valid `EMAIL_FROM` returns null and the CMS falls back to its own
|
|
85
|
+
* resolution, so installing the pack never changes how a site behaves.
|
|
86
|
+
*
|
|
87
|
+
* A half-configured site is the one case worth a log line, because silence
|
|
88
|
+
* there looks exactly like mail that was sent.
|
|
89
|
+
*/
|
|
90
|
+
export function cloudflareEmailSender(env) {
|
|
91
|
+
if (typeof env !== 'object' || env === null)
|
|
92
|
+
return null;
|
|
93
|
+
const emailEnv = env;
|
|
94
|
+
const verdict = inspectEmailConfig(emailEnv);
|
|
95
|
+
if (!verdict.enabled) {
|
|
96
|
+
if (emailEnv.EMAIL_MODE === CLOUDFLARE_EMAIL_MODE) {
|
|
97
|
+
console.warn(`[email] EMAIL_MODE is "${CLOUDFLARE_EMAIL_MODE}" but ${verdict.reason}; mail is off`);
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
// Both fields are proven present by inspectEmailConfig above.
|
|
102
|
+
return new CloudflareEmailSender(emailEnv.EMAIL, emailEnv.EMAIL_FROM);
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../src/email.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA0CH,wDAAwD;AACxD,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAElD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IACvB,QAAQ,CAAmB;IAC3B,KAAK,CAAS;IAEvB,YAAY,OAAyB,EAAE,IAAY;QACjD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAqB;QAC9B,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACrE,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAE5B,IA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C;YAClD,OAAO,CAAC,IAAI,CAAC,0BAA0B,qBAAqB,SAAS,OAAO,CAAC,MAAM,eAAe,CAAC,CAAC;QACtG,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8DAA8D;IAC9D,OAAO,IAAI,qBAAqB,CAAC,QAAQ,CAAC,KAAyB,EAAE,QAAQ,CAAC,UAAoB,CAAC,CAAC;AACtG,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@we8/cloudflare`: the Cloudflare pack. Three things, and only three.
|
|
3
|
+
*
|
|
4
|
+
* 1. A real `EmailSender` over Cloudflare Email Service, registered through
|
|
5
|
+
* the CMS seam and off until a site configures it.
|
|
6
|
+
* 2. The wrangler config generator, which is what `create-we8` writes a
|
|
7
|
+
* project's `wrangler.jsonc` with.
|
|
8
|
+
* 3. First-boot help: the doctor's checks and the facts they read, behind the
|
|
9
|
+
* `we8-cloudflare` CLI.
|
|
10
|
+
*
|
|
11
|
+
* The package has no runtime dependencies. It declares `@we8/cms` as a peer
|
|
12
|
+
* rather than importing it, so the two build in either order.
|
|
13
|
+
*/
|
|
14
|
+
export { CLOUDFLARE_EMAIL_MODE, CloudflareEmailSender, MAX_RECIPIENTS, cloudflareEmailSender, inspectEmailConfig, type CloudflareEmailEnv, type EmailMessage, type EmailSendResult, type EmailSender, type SendEmailBinding, } from './email.js';
|
|
15
|
+
export { COMPATIBILITY_DATE, D1_ID_PLACEHOLDER, DEFAULT_MIGRATIONS_DIR, RETENTION_CRON, generateWranglerConfig, isRealDatabaseId, isValidResourceName, type EmailMode, type WranglerConfigAnswers, } from './wrangler-config.js';
|
|
16
|
+
export { checkMigrationSequence, findD1Binding, findR2Binding, formatDoctorReport, readMigrationsDir, runDoctorChecks, seedTargetsRemote, type CheckStatus, type DoctorCheck, type DoctorFacts, type DoctorReport, type DoctorTarget, } from './doctor.js';
|
|
17
|
+
export { CONFIG_FILENAMES, SEED_RELATIVE_PATH, findConfigPath, findSeedFile, gatherFacts, parseDevVarNames, } from './project.js';
|
|
18
|
+
export { parseJsonc, stripJsonComments } from './jsonc.js';
|
|
19
|
+
export { USAGE, parseCliArgs, type CommandName, type ParsedCommand } from './cli-args.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,SAAS,EACd,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,WAAW,EACX,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@we8/cloudflare`: the Cloudflare pack. Three things, and only three.
|
|
3
|
+
*
|
|
4
|
+
* 1. A real `EmailSender` over Cloudflare Email Service, registered through
|
|
5
|
+
* the CMS seam and off until a site configures it.
|
|
6
|
+
* 2. The wrangler config generator, which is what `create-we8` writes a
|
|
7
|
+
* project's `wrangler.jsonc` with.
|
|
8
|
+
* 3. First-boot help: the doctor's checks and the facts they read, behind the
|
|
9
|
+
* `we8-cloudflare` CLI.
|
|
10
|
+
*
|
|
11
|
+
* The package has no runtime dependencies. It declares `@we8/cms` as a peer
|
|
12
|
+
* rather than importing it, so the two build in either order.
|
|
13
|
+
*/
|
|
14
|
+
export { CLOUDFLARE_EMAIL_MODE, CloudflareEmailSender, MAX_RECIPIENTS, cloudflareEmailSender, inspectEmailConfig, } from './email.js';
|
|
15
|
+
export { COMPATIBILITY_DATE, D1_ID_PLACEHOLDER, DEFAULT_MIGRATIONS_DIR, RETENTION_CRON, generateWranglerConfig, isRealDatabaseId, isValidResourceName, } from './wrangler-config.js';
|
|
16
|
+
export { checkMigrationSequence, findD1Binding, findR2Binding, formatDoctorReport, readMigrationsDir, runDoctorChecks, seedTargetsRemote, } from './doctor.js';
|
|
17
|
+
export { CONFIG_FILENAMES, SEED_RELATIVE_PATH, findConfigPath, findSeedFile, gatherFacts, parseDevVarNames, } from './project.js';
|
|
18
|
+
export { parseJsonc, stripJsonComments } from './jsonc.js';
|
|
19
|
+
export { USAGE, parseCliArgs } from './cli-args.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,GAMnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,GAGpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,GAMlB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,WAAW,EACX,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAE,YAAY,EAAwC,MAAM,eAAe,CAAC"}
|
package/dist/jsonc.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small JSONC reader, so the doctor can read the same `wrangler.jsonc` a
|
|
3
|
+
* human edits. Wrangler's own config format is JSON with comments and trailing
|
|
4
|
+
* commas; `JSON.parse` refuses both. Pulling in a parser dependency for this
|
|
5
|
+
* would be the larger cost, since the pack otherwise has none.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Strips `//` and slash-star comments and trailing commas, leaving valid JSON.
|
|
9
|
+
* String literals and their escapes are respected, so a `//` inside a URL
|
|
10
|
+
* survives.
|
|
11
|
+
*/
|
|
12
|
+
export declare function stripJsonComments(text: string): string;
|
|
13
|
+
/** Parses JSONC. Throws the same way `JSON.parse` does when the result is not JSON. */
|
|
14
|
+
export declare function parseJsonc(text: string): unknown;
|
|
15
|
+
//# sourceMappingURL=jsonc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonc.d.ts","sourceRoot":"","sources":["../src/jsonc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA8CtD;AAED,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD"}
|
package/dist/jsonc.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small JSONC reader, so the doctor can read the same `wrangler.jsonc` a
|
|
3
|
+
* human edits. Wrangler's own config format is JSON with comments and trailing
|
|
4
|
+
* commas; `JSON.parse` refuses both. Pulling in a parser dependency for this
|
|
5
|
+
* would be the larger cost, since the pack otherwise has none.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Strips `//` and slash-star comments and trailing commas, leaving valid JSON.
|
|
9
|
+
* String literals and their escapes are respected, so a `//` inside a URL
|
|
10
|
+
* survives.
|
|
11
|
+
*/
|
|
12
|
+
export function stripJsonComments(text) {
|
|
13
|
+
let out = '';
|
|
14
|
+
let index = 0;
|
|
15
|
+
while (index < text.length) {
|
|
16
|
+
const char = text[index];
|
|
17
|
+
if (char === '"') {
|
|
18
|
+
// Copy the whole string literal verbatim, escapes included.
|
|
19
|
+
out += char;
|
|
20
|
+
index += 1;
|
|
21
|
+
while (index < text.length) {
|
|
22
|
+
const inner = text[index];
|
|
23
|
+
out += inner;
|
|
24
|
+
index += 1;
|
|
25
|
+
if (inner === '\\') {
|
|
26
|
+
if (index < text.length) {
|
|
27
|
+
out += text[index];
|
|
28
|
+
index += 1;
|
|
29
|
+
}
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (inner === '"')
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (char === '/' && text[index + 1] === '/') {
|
|
38
|
+
while (index < text.length && text[index] !== '\n')
|
|
39
|
+
index += 1;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (char === '/' && text[index + 1] === '*') {
|
|
43
|
+
index += 2;
|
|
44
|
+
while (index < text.length && !(text[index] === '*' && text[index + 1] === '/'))
|
|
45
|
+
index += 1;
|
|
46
|
+
index += 2;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
out += char;
|
|
50
|
+
index += 1;
|
|
51
|
+
}
|
|
52
|
+
// Trailing commas, now that comments can no longer hide between the comma
|
|
53
|
+
// and the closing brace.
|
|
54
|
+
return out.replace(/,(\s*[}\]])/g, '$1');
|
|
55
|
+
}
|
|
56
|
+
/** Parses JSONC. Throws the same way `JSON.parse` does when the result is not JSON. */
|
|
57
|
+
export function parseJsonc(text) {
|
|
58
|
+
return JSON.parse(stripJsonComments(text));
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=jsonc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonc.js","sourceRoot":"","sources":["../src/jsonc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAW,CAAC;QAEnC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACjB,4DAA4D;YAC5D,GAAG,IAAI,IAAI,CAAC;YACZ,KAAK,IAAI,CAAC,CAAC;YACX,OAAO,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAW,CAAC;gBACpC,GAAG,IAAI,KAAK,CAAC;gBACb,KAAK,IAAI,CAAC,CAAC;gBACX,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;oBACnB,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;wBACxB,GAAG,IAAI,IAAI,CAAC,KAAK,CAAW,CAAC;wBAC7B,KAAK,IAAI,CAAC,CAAC;oBACb,CAAC;oBACD,SAAS;gBACX,CAAC;gBACD,IAAI,KAAK,KAAK,GAAG;oBAAE,MAAM;YAC3B,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC5C,OAAO,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI;gBAAE,KAAK,IAAI,CAAC,CAAC;YAC/D,SAAS;QACX,CAAC;QAED,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC5C,KAAK,IAAI,CAAC,CAAC;YACX,OAAO,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;gBAAE,KAAK,IAAI,CAAC,CAAC;YAC5F,KAAK,IAAI,CAAC,CAAC;YACX,SAAS;QACX,CAAC;QAED,GAAG,IAAI,IAAI,CAAC;QACZ,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,0EAA0E;IAC1E,yBAAyB;IACzB,OAAO,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a project from disk: the config, the local variables, the
|
|
3
|
+
* migrations, and the seed. Everything here touches the filesystem and nothing
|
|
4
|
+
* here decides anything, so that `doctor.ts` stays a pure function of facts.
|
|
5
|
+
*/
|
|
6
|
+
import { type DoctorFacts, type DoctorTarget } from './doctor.js';
|
|
7
|
+
/** The config filenames wrangler itself accepts, in the order it looks for them. */
|
|
8
|
+
export declare const CONFIG_FILENAMES: readonly ["wrangler.jsonc", "wrangler.json", "wrangler.toml"];
|
|
9
|
+
/** Where the seed lives inside an installed project. */
|
|
10
|
+
export declare const SEED_RELATIVE_PATH = "node_modules/@we8/cms/seed/local.sql";
|
|
11
|
+
/**
|
|
12
|
+
* Parses `.dev.vars` for the names it sets. Only names: a doctor that printed
|
|
13
|
+
* the value of a secret to prove it exists would be the bug it is looking for.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseDevVarNames(contents: string): string[];
|
|
16
|
+
/** The project's wrangler config path, or null when there is none. */
|
|
17
|
+
export declare function findConfigPath(projectDir: string): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Gathers everything the doctor reasons over. `remoteSecrets` is passed in
|
|
20
|
+
* because reading it needs the network and an account, which this function
|
|
21
|
+
* deliberately never touches.
|
|
22
|
+
*/
|
|
23
|
+
export declare function gatherFacts(projectDir: string, target: DoctorTarget, remoteSecrets?: string[] | null): DoctorFacts;
|
|
24
|
+
/** The seed file inside the project's installed `@we8/cms`, or null when absent. */
|
|
25
|
+
export declare function findSeedFile(projectDir: string): string | null;
|
|
26
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAErF,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,+DAAgE,CAAC;AAE9F,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AAEzE;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAa3D;AAED,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMhE;AAoBD;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,YAAY,EACpB,aAAa,GAAE,MAAM,EAAE,GAAG,IAAW,GACpC,WAAW,CAuCb;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG9D"}
|
package/dist/project.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a project from disk: the config, the local variables, the
|
|
3
|
+
* migrations, and the seed. Everything here touches the filesystem and nothing
|
|
4
|
+
* here decides anything, so that `doctor.ts` stays a pure function of facts.
|
|
5
|
+
*/
|
|
6
|
+
import { readdirSync, readFileSync, existsSync } from 'node:fs';
|
|
7
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
8
|
+
import { parseJsonc } from './jsonc.js';
|
|
9
|
+
import { readMigrationsDir } from './doctor.js';
|
|
10
|
+
/** The config filenames wrangler itself accepts, in the order it looks for them. */
|
|
11
|
+
export const CONFIG_FILENAMES = ['wrangler.jsonc', 'wrangler.json', 'wrangler.toml'];
|
|
12
|
+
/** Where the seed lives inside an installed project. */
|
|
13
|
+
export const SEED_RELATIVE_PATH = 'node_modules/@we8/cms/seed/local.sql';
|
|
14
|
+
/**
|
|
15
|
+
* Parses `.dev.vars` for the names it sets. Only names: a doctor that printed
|
|
16
|
+
* the value of a secret to prove it exists would be the bug it is looking for.
|
|
17
|
+
*/
|
|
18
|
+
export function parseDevVarNames(contents) {
|
|
19
|
+
const names = [];
|
|
20
|
+
for (const rawLine of contents.split('\n')) {
|
|
21
|
+
const line = rawLine.trim();
|
|
22
|
+
if (line.length === 0 || line.startsWith('#'))
|
|
23
|
+
continue;
|
|
24
|
+
const eq = line.indexOf('=');
|
|
25
|
+
if (eq <= 0)
|
|
26
|
+
continue;
|
|
27
|
+
const name = line.slice(0, eq).trim();
|
|
28
|
+
const value = line.slice(eq + 1).trim();
|
|
29
|
+
// A declared-but-empty variable is not a set variable.
|
|
30
|
+
if (name.length > 0 && value.length > 0)
|
|
31
|
+
names.push(name);
|
|
32
|
+
}
|
|
33
|
+
return names;
|
|
34
|
+
}
|
|
35
|
+
/** The project's wrangler config path, or null when there is none. */
|
|
36
|
+
export function findConfigPath(projectDir) {
|
|
37
|
+
for (const name of CONFIG_FILENAMES) {
|
|
38
|
+
const candidate = join(projectDir, name);
|
|
39
|
+
if (existsSync(candidate))
|
|
40
|
+
return candidate;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
function readScripts(projectDir) {
|
|
45
|
+
const manifest = join(projectDir, 'package.json');
|
|
46
|
+
if (!existsSync(manifest))
|
|
47
|
+
return {};
|
|
48
|
+
try {
|
|
49
|
+
const parsed = JSON.parse(readFileSync(manifest, 'utf8'));
|
|
50
|
+
const scripts = typeof parsed === 'object' && parsed !== null ? parsed.scripts : null;
|
|
51
|
+
if (typeof scripts !== 'object' || scripts === null)
|
|
52
|
+
return {};
|
|
53
|
+
const out = {};
|
|
54
|
+
for (const [key, value] of Object.entries(scripts)) {
|
|
55
|
+
if (typeof value === 'string')
|
|
56
|
+
out[key] = value;
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gathers everything the doctor reasons over. `remoteSecrets` is passed in
|
|
66
|
+
* because reading it needs the network and an account, which this function
|
|
67
|
+
* deliberately never touches.
|
|
68
|
+
*/
|
|
69
|
+
export function gatherFacts(projectDir, target, remoteSecrets = null) {
|
|
70
|
+
const configPath = findConfigPath(projectDir);
|
|
71
|
+
let config = null;
|
|
72
|
+
let configError;
|
|
73
|
+
if (!configPath) {
|
|
74
|
+
configError = 'no wrangler.jsonc, wrangler.json, or wrangler.toml here';
|
|
75
|
+
}
|
|
76
|
+
else if (configPath.endsWith('.toml')) {
|
|
77
|
+
configError = `${configPath} is TOML; this pack generates and reads wrangler.jsonc`;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
try {
|
|
81
|
+
config = parseJsonc(readFileSync(configPath, 'utf8'));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
configError = `${configPath} could not be parsed: ${error instanceof Error ? error.message : String(error)}`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const devVarsPath = join(projectDir, '.dev.vars');
|
|
88
|
+
const devVars = existsSync(devVarsPath) ? parseDevVarNames(readFileSync(devVarsPath, 'utf8')) : null;
|
|
89
|
+
let migrations = null;
|
|
90
|
+
const migrationsDir = config ? readMigrationsDir(config) : '';
|
|
91
|
+
if (migrationsDir) {
|
|
92
|
+
const absolute = isAbsolute(migrationsDir) ? migrationsDir : resolve(projectDir, migrationsDir);
|
|
93
|
+
if (existsSync(absolute)) {
|
|
94
|
+
migrations = readdirSync(absolute).filter((name) => name.endsWith('.sql'));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
target,
|
|
99
|
+
config,
|
|
100
|
+
configError,
|
|
101
|
+
devVars,
|
|
102
|
+
remoteSecrets,
|
|
103
|
+
migrations,
|
|
104
|
+
packageScripts: readScripts(projectDir),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** The seed file inside the project's installed `@we8/cms`, or null when absent. */
|
|
108
|
+
export function findSeedFile(projectDir) {
|
|
109
|
+
const candidate = resolve(projectDir, SEED_RELATIVE_PATH);
|
|
110
|
+
return existsSync(candidate) ? candidate : null;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,Y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,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM;QACN,MAAM;QACN,WAAW;QACX,OAAO;QACP,aAAa;QACb,UAAU;QACV,cAAc,EAAE,WAAW,CAAC,UAAU,CAAC;KACxC,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC7C,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;IAC1D,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wrangler config generator. One function turns a scaffolder's answers
|
|
3
|
+
* into the `wrangler.jsonc` a project deploys with, shaped after the CMS
|
|
4
|
+
* package's own config so the two never drift apart in compatibility date,
|
|
5
|
+
* flags, cron, or binding names.
|
|
6
|
+
*
|
|
7
|
+
* It writes JSONC on purpose. The file a stranger opens first should explain
|
|
8
|
+
* itself, and half of what it has to explain (which value is a placeholder,
|
|
9
|
+
* why the secret is not here) has nowhere to live in plain JSON.
|
|
10
|
+
*/
|
|
11
|
+
/** The placeholder id a project carries until its D1 database exists. */
|
|
12
|
+
export declare const D1_ID_PLACEHOLDER = "REPLACE_WITH_YOUR_D1_DATABASE_ID";
|
|
13
|
+
/**
|
|
14
|
+
* The compatibility date the CMS is written against. Pinned here rather than
|
|
15
|
+
* set to today's date at scaffold time: a date the code has never run under is
|
|
16
|
+
* a guess, and a guess in a compatibility date is a runtime surprise.
|
|
17
|
+
*/
|
|
18
|
+
export declare const COMPATIBILITY_DATE = "2026-07-05";
|
|
19
|
+
/** Where the migrations live in an installed project. */
|
|
20
|
+
export declare const DEFAULT_MIGRATIONS_DIR = "node_modules/@we8/cms/migrations";
|
|
21
|
+
/** The daily retention sweep, matching the CMS package config. */
|
|
22
|
+
export declare const RETENTION_CRON = "0 3 * * *";
|
|
23
|
+
/** How a project sends mail. `off` is the default and drops every message. */
|
|
24
|
+
export type EmailMode = 'off' | 'console' | 'cloudflare';
|
|
25
|
+
/** Everything the generator needs. Everything else it decides. */
|
|
26
|
+
export interface WranglerConfigAnswers {
|
|
27
|
+
/** The Worker name, which is also its workers.dev subdomain. */
|
|
28
|
+
workerName: string;
|
|
29
|
+
/** The D1 database name, as passed to `wrangler d1 create`. */
|
|
30
|
+
databaseName: string;
|
|
31
|
+
/**
|
|
32
|
+
* The D1 database id from `wrangler d1 create`. Left as the placeholder when
|
|
33
|
+
* the database does not exist yet, so the file is still valid JSON and the
|
|
34
|
+
* doctor has something concrete to complain about.
|
|
35
|
+
*/
|
|
36
|
+
databaseId?: string | undefined;
|
|
37
|
+
/** The R2 bucket name, as passed to `wrangler r2 bucket create`. */
|
|
38
|
+
bucketName: string;
|
|
39
|
+
/** The site's public origin. */
|
|
40
|
+
siteUrl: string;
|
|
41
|
+
/** Reported by `/v1/health`. */
|
|
42
|
+
cmsVersion: string;
|
|
43
|
+
/** Defaults to `off`. */
|
|
44
|
+
emailMode?: EmailMode | undefined;
|
|
45
|
+
/** The from-address, required when emailMode is `cloudflare`. */
|
|
46
|
+
emailFrom?: string | undefined;
|
|
47
|
+
/** Defaults to node_modules/@we8/cms/migrations. */
|
|
48
|
+
migrationsDir?: string | undefined;
|
|
49
|
+
/** Defaults to the pinned COMPATIBILITY_DATE. */
|
|
50
|
+
compatibilityDate?: string | undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The rules a Worker, database, and bucket name all share on Cloudflare:
|
|
54
|
+
* lowercase, digits, and hyphens, starting with a letter or a digit.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isValidResourceName(name: string): boolean;
|
|
57
|
+
/** True for a real D1 id. The placeholder is deliberately not one. */
|
|
58
|
+
export declare function isRealDatabaseId(id: string | undefined): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Renders the project's `wrangler.jsonc`. Throws on an answer that would
|
|
61
|
+
* produce a config Cloudflare rejects, because failing here is a sentence and
|
|
62
|
+
* failing at deploy time is a support thread.
|
|
63
|
+
*/
|
|
64
|
+
export declare function generateWranglerConfig(answers: WranglerConfigAnswers): string;
|
|
65
|
+
//# sourceMappingURL=wrangler-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler-config.d.ts","sourceRoot":"","sources":["../src/wrangler-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,qCAAqC,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,eAAe,CAAC;AAE/C,yDAAyD;AACzD,eAAO,MAAM,sBAAsB,qCAAqC,CAAC;AAEzE,kEAAkE;AAClE,eAAO,MAAM,cAAc,cAAc,CAAC;AAE1C,8EAA8E;AAC9E,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,SAAS,GAAG,YAAY,CAAC;AAEzD,kEAAkE;AAClE,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAClC,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,oDAAoD;IACpD,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,iDAAiD;IACjD,iBAAiB,CAAC,EAAE,MAAM,GAAG,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