create-cloudflare 0.0.0-a5231dec → 0.0.0-a676f55a
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/dist/cli.js +200 -103
- package/package.json +3 -3
- package/templates/angular/c3.ts +5 -6
- package/templates/astro/c3.ts +0 -9
- package/templates/common/js/.editorconfig +0 -1
- package/templates/common/ts/.editorconfig +0 -1
- package/templates/docusaurus/c3.ts +3 -4
- package/templates/gatsby/c3.ts +5 -3
- package/templates/hello-world/js/.editorconfig +0 -1
- package/templates/hello-world/js/package.json +3 -1
- package/templates/hello-world/js/test/index.spec.js +20 -0
- package/templates/hello-world/js/vitest.config.js +11 -0
- package/templates/hello-world/js/wrangler.toml +1 -0
- package/templates/hello-world/ts/.editorconfig +0 -1
- package/templates/hello-world/ts/package.json +5 -2
- package/templates/hello-world/ts/test/index.spec.ts +25 -0
- package/templates/hello-world/ts/test/tsconfig.json +11 -0
- package/templates/hello-world/ts/tsconfig.json +3 -2
- package/templates/hello-world/ts/vitest.config.ts +11 -0
- package/templates/hello-world/ts/wrangler.toml +1 -0
- package/templates/hello-world-durable-object/js/.editorconfig +0 -1
- package/templates/hello-world-durable-object/ts/.editorconfig +0 -1
- package/templates/next/c3.ts +3 -13
- package/templates/nuxt/c3.ts +39 -6
- package/templates/nuxt/templates/env.d.ts +14 -0
- package/templates/nuxt/templates/worker-configuration.d.ts +3 -0
- package/templates/pre-existing/js/.editorconfig +0 -1
- package/templates/queues/js/.editorconfig +0 -1
- package/templates/queues/ts/.editorconfig +0 -1
- package/templates/qwik/c3.ts +3 -2
- package/templates/react/c3.ts +5 -3
- package/templates/remix/c3.ts +0 -1
- package/templates/scheduled/js/.editorconfig +0 -1
- package/templates/scheduled/ts/.editorconfig +0 -1
- package/templates/solid/c3.ts +3 -2
- package/templates/vue/c3.ts +5 -4
package/dist/cli.js
CHANGED
|
@@ -1595,12 +1595,22 @@ var init_colors = __esm({
|
|
|
1595
1595
|
}
|
|
1596
1596
|
});
|
|
1597
1597
|
|
|
1598
|
+
// ../cli/streams.ts
|
|
1599
|
+
var stdout, stderr;
|
|
1600
|
+
var init_streams = __esm({
|
|
1601
|
+
"../cli/streams.ts"() {
|
|
1602
|
+
stdout = process.stdout;
|
|
1603
|
+
stderr = process.stderr;
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
|
|
1598
1607
|
// ../cli/index.ts
|
|
1599
1608
|
var import_process, shapes, status, space, logRaw, log, newline, updateStatus, startSection, endSection, cancel, warn, stripAnsi, crash, error;
|
|
1600
1609
|
var init_cli = __esm({
|
|
1601
1610
|
"../cli/index.ts"() {
|
|
1602
1611
|
import_process = require("process");
|
|
1603
1612
|
init_colors();
|
|
1613
|
+
init_streams();
|
|
1604
1614
|
shapes = {
|
|
1605
1615
|
diamond: "\u25C7",
|
|
1606
1616
|
dash: "\u2500",
|
|
@@ -1630,7 +1640,7 @@ var init_cli = __esm({
|
|
|
1630
1640
|
return hidden("\u200A".repeat(n2));
|
|
1631
1641
|
};
|
|
1632
1642
|
logRaw = (msg) => {
|
|
1633
|
-
|
|
1643
|
+
stdout.write(`${msg}
|
|
1634
1644
|
`);
|
|
1635
1645
|
};
|
|
1636
1646
|
log = (msg) => {
|
|
@@ -1683,10 +1693,10 @@ var init_cli = __esm({
|
|
|
1683
1693
|
error(msg, extra);
|
|
1684
1694
|
(0, import_process.exit)(1);
|
|
1685
1695
|
};
|
|
1686
|
-
error = (msg, extra) => {
|
|
1696
|
+
error = (msg, extra, corner = shapes.corners.bl) => {
|
|
1687
1697
|
if (msg) {
|
|
1688
|
-
|
|
1689
|
-
`${gray(
|
|
1698
|
+
stderr.write(
|
|
1699
|
+
`${gray(corner)} ${status.error} ${dim(msg)}
|
|
1690
1700
|
${extra ? space() + extra + "\n" : ""}`
|
|
1691
1701
|
);
|
|
1692
1702
|
}
|
|
@@ -3404,6 +3414,15 @@ var init_select_list = __esm({
|
|
|
3404
3414
|
});
|
|
3405
3415
|
|
|
3406
3416
|
// ../cli/interactive.ts
|
|
3417
|
+
function acceptDefault(promptConfig, renderers, initialValue) {
|
|
3418
|
+
const error2 = promptConfig.validate?.(initialValue);
|
|
3419
|
+
if (error2) {
|
|
3420
|
+
crash(error2);
|
|
3421
|
+
}
|
|
3422
|
+
const lines = renderers.submit({ value: initialValue });
|
|
3423
|
+
logRaw(lines.join("\n"));
|
|
3424
|
+
return initialValue;
|
|
3425
|
+
}
|
|
3407
3426
|
var logUpdate2, grayBar, blCorner, leftT, inputPrompt, renderSubmit, handleCancel, getRenderers, getTextRenderers, getSelectRenderers, getSelectListRenderers, getConfirmRenderers, spinnerFrames, ellipsisFrames, spinner, isInteractive;
|
|
3408
3427
|
var init_interactive = __esm({
|
|
3409
3428
|
"../cli/interactive.ts"() {
|
|
@@ -3411,31 +3430,43 @@ var init_interactive = __esm({
|
|
|
3411
3430
|
init_log_update();
|
|
3412
3431
|
init_colors();
|
|
3413
3432
|
init_select_list();
|
|
3433
|
+
init_streams();
|
|
3414
3434
|
init_cli();
|
|
3415
|
-
logUpdate2 = createLogUpdate(
|
|
3435
|
+
logUpdate2 = createLogUpdate(stdout);
|
|
3416
3436
|
grayBar = gray(shapes.bar);
|
|
3417
3437
|
blCorner = gray(shapes.corners.bl);
|
|
3418
3438
|
leftT = gray(shapes.leftT);
|
|
3419
3439
|
inputPrompt = async (promptConfig) => {
|
|
3420
|
-
const renderers =
|
|
3440
|
+
const renderers = {
|
|
3441
|
+
...getRenderers(promptConfig),
|
|
3442
|
+
...promptConfig.renderers
|
|
3443
|
+
};
|
|
3421
3444
|
let prompt;
|
|
3422
3445
|
const dispatchRender = (props, p2) => {
|
|
3423
3446
|
const renderedLines = renderers[props.state](props, p2);
|
|
3424
3447
|
return renderedLines.join("\n");
|
|
3425
3448
|
};
|
|
3426
3449
|
if (promptConfig.type === "select") {
|
|
3450
|
+
const initialValue = String(promptConfig.defaultValue);
|
|
3451
|
+
if (promptConfig.acceptDefault) {
|
|
3452
|
+
return acceptDefault(promptConfig, renderers, initialValue);
|
|
3453
|
+
}
|
|
3427
3454
|
prompt = new ED({
|
|
3428
3455
|
...promptConfig,
|
|
3429
3456
|
options: promptConfig.options.filter((o) => !o.hidden),
|
|
3430
|
-
initialValue
|
|
3457
|
+
initialValue,
|
|
3431
3458
|
render() {
|
|
3432
3459
|
return dispatchRender(this, prompt);
|
|
3433
3460
|
}
|
|
3434
3461
|
});
|
|
3435
3462
|
} else if (promptConfig.type === "confirm") {
|
|
3463
|
+
const initialValue = Boolean(promptConfig.defaultValue);
|
|
3464
|
+
if (promptConfig.acceptDefault) {
|
|
3465
|
+
return acceptDefault(promptConfig, renderers, initialValue);
|
|
3466
|
+
}
|
|
3436
3467
|
prompt = new sD({
|
|
3437
3468
|
...promptConfig,
|
|
3438
|
-
initialValue
|
|
3469
|
+
initialValue,
|
|
3439
3470
|
active: promptConfig.activeText || "",
|
|
3440
3471
|
inactive: promptConfig.inactiveText || "",
|
|
3441
3472
|
render() {
|
|
@@ -3449,6 +3480,9 @@ var init_interactive = __esm({
|
|
|
3449
3480
|
} else if (promptConfig.defaultValue !== void 0) {
|
|
3450
3481
|
initialValues = [String(promptConfig.defaultValue)];
|
|
3451
3482
|
}
|
|
3483
|
+
if (promptConfig.acceptDefault) {
|
|
3484
|
+
return acceptDefault(promptConfig, renderers, initialValues);
|
|
3485
|
+
}
|
|
3452
3486
|
prompt = new iD({
|
|
3453
3487
|
...promptConfig,
|
|
3454
3488
|
options: promptConfig.options,
|
|
@@ -3458,19 +3492,27 @@ var init_interactive = __esm({
|
|
|
3458
3492
|
}
|
|
3459
3493
|
});
|
|
3460
3494
|
} else if (promptConfig.type === "list") {
|
|
3495
|
+
const initialValue = String(promptConfig.defaultValue);
|
|
3496
|
+
if (promptConfig.acceptDefault) {
|
|
3497
|
+
return acceptDefault(promptConfig, renderers, initialValue);
|
|
3498
|
+
}
|
|
3461
3499
|
prompt = new SelectRefreshablePrompt({
|
|
3462
3500
|
...promptConfig,
|
|
3463
3501
|
onRefresh: promptConfig.onRefresh ?? (() => Promise.resolve(promptConfig.options)),
|
|
3464
|
-
initialValue
|
|
3502
|
+
initialValue,
|
|
3465
3503
|
render() {
|
|
3466
3504
|
return dispatchRender(this, prompt);
|
|
3467
3505
|
}
|
|
3468
3506
|
});
|
|
3469
3507
|
} else {
|
|
3508
|
+
const initialValue = promptConfig.initialValue ?? String(promptConfig.defaultValue ?? "");
|
|
3509
|
+
if (promptConfig.acceptDefault) {
|
|
3510
|
+
return acceptDefault(promptConfig, renderers, initialValue);
|
|
3511
|
+
}
|
|
3470
3512
|
prompt = new oD({
|
|
3471
3513
|
...promptConfig,
|
|
3472
3514
|
initialValue: promptConfig.initialValue,
|
|
3473
|
-
defaultValue: String(promptConfig.defaultValue),
|
|
3515
|
+
defaultValue: String(promptConfig.defaultValue ?? ""),
|
|
3474
3516
|
render() {
|
|
3475
3517
|
return dispatchRender(this, prompt);
|
|
3476
3518
|
}
|
|
@@ -3510,14 +3552,10 @@ var init_interactive = __esm({
|
|
|
3510
3552
|
}
|
|
3511
3553
|
};
|
|
3512
3554
|
getTextRenderers = (config13) => {
|
|
3513
|
-
const {
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
format: _format
|
|
3518
|
-
} = config13;
|
|
3519
|
-
const helpText = _helpText ?? "";
|
|
3520
|
-
const format4 = _format ?? ((val) => String(val));
|
|
3555
|
+
const { question } = config13;
|
|
3556
|
+
const helpText = config13.helpText ?? "";
|
|
3557
|
+
const format4 = config13.format ?? ((val) => String(val));
|
|
3558
|
+
const defaultValue = config13.defaultValue?.toString() ?? "";
|
|
3521
3559
|
return {
|
|
3522
3560
|
initial: () => [
|
|
3523
3561
|
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
@@ -3527,9 +3565,7 @@ var init_interactive = __esm({
|
|
|
3527
3565
|
],
|
|
3528
3566
|
active: ({ value }) => [
|
|
3529
3567
|
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
3530
|
-
`${space(2)}${format4(
|
|
3531
|
-
value || dim(typeof defaultValue === "string" ? defaultValue : ``)
|
|
3532
|
-
)}`,
|
|
3568
|
+
`${space(2)}${format4(value || dim(defaultValue))}`,
|
|
3533
3569
|
``
|
|
3534
3570
|
// extra line for readability
|
|
3535
3571
|
],
|
|
@@ -3541,7 +3577,7 @@ var init_interactive = __esm({
|
|
|
3541
3577
|
``
|
|
3542
3578
|
// extra line for readability
|
|
3543
3579
|
],
|
|
3544
|
-
submit: ({ value }) => renderSubmit(config13, format4(value)),
|
|
3580
|
+
submit: ({ value }) => renderSubmit(config13, format4(value ?? "")),
|
|
3545
3581
|
cancel: handleCancel
|
|
3546
3582
|
};
|
|
3547
3583
|
};
|
|
@@ -3555,10 +3591,11 @@ var init_interactive = __esm({
|
|
|
3555
3591
|
const { label: optionLabel, value: optionValue } = opt;
|
|
3556
3592
|
const active = i === cursor;
|
|
3557
3593
|
const isInListOfValues = Array.isArray(value) && value.includes(optionValue);
|
|
3558
|
-
const color = isInListOfValues || active ? blue :
|
|
3594
|
+
const color = isInListOfValues || active ? blue : white;
|
|
3559
3595
|
const text = active ? color.underline(optionLabel) : color(optionLabel);
|
|
3596
|
+
const sublabel = opt.sublabel ? color.grey(opt.sublabel) : "";
|
|
3560
3597
|
const indicator = isInListOfValues || active && !Array.isArray(value) ? color(shapes.radioActive) : color(shapes.radioInactive);
|
|
3561
|
-
return `${space(2)}${indicator} ${text}`;
|
|
3598
|
+
return `${space(2)}${indicator} ${text} ${sublabel}`;
|
|
3562
3599
|
};
|
|
3563
3600
|
const renderOptionCondition = (_2, i) => {
|
|
3564
3601
|
if (options.length <= maxItemsPerPage) {
|
|
@@ -3610,7 +3647,7 @@ ${space(2)}${dim("...")}` : ""}`,
|
|
|
3610
3647
|
const { question, helpText: _helpText } = config13;
|
|
3611
3648
|
let options = config13.options;
|
|
3612
3649
|
const helpText = _helpText ?? "";
|
|
3613
|
-
const { rows } =
|
|
3650
|
+
const { rows } = stdout;
|
|
3614
3651
|
const defaultRenderer = ({ cursor, value }, prompt) => {
|
|
3615
3652
|
if (prompt instanceof SelectRefreshablePrompt) {
|
|
3616
3653
|
options = prompt.options;
|
|
@@ -3814,7 +3851,7 @@ var init_args = __esm({
|
|
|
3814
3851
|
var version, devDependencies;
|
|
3815
3852
|
var init_package = __esm({
|
|
3816
3853
|
"package.json"() {
|
|
3817
|
-
version = "0.0.0-
|
|
3854
|
+
version = "0.0.0-a676f55a";
|
|
3818
3855
|
devDependencies = {
|
|
3819
3856
|
"@babel/parser": "^7.21.3",
|
|
3820
3857
|
"@babel/types": "^7.21.4",
|
|
@@ -24217,14 +24254,14 @@ var init_package2 = __esm({
|
|
|
24217
24254
|
],
|
|
24218
24255
|
dependencies: {
|
|
24219
24256
|
"create-astro": "4.7.3",
|
|
24220
|
-
"@angular/create": "17.2.
|
|
24257
|
+
"@angular/create": "17.2.3",
|
|
24221
24258
|
"create-docusaurus": "3.1.1",
|
|
24222
24259
|
"create-hono": "0.5.0",
|
|
24223
24260
|
"create-next-app": "14.1.0",
|
|
24224
24261
|
"create-qwik": "1.4.5",
|
|
24225
24262
|
"create-react-app": "5.0.1",
|
|
24226
24263
|
"create-remix": "2.8.0",
|
|
24227
|
-
"create-solid": "0.
|
|
24264
|
+
"create-solid": "0.5.3",
|
|
24228
24265
|
"create-svelte": "6.0.9",
|
|
24229
24266
|
"create-vue": "3.9.2",
|
|
24230
24267
|
gatsby: "5.13.3",
|
|
@@ -24297,7 +24334,8 @@ var init_packages = __esm({
|
|
|
24297
24334
|
import_which_pm_runs = __toESM(require_which_pm_runs());
|
|
24298
24335
|
init_package();
|
|
24299
24336
|
detectPackageManager = () => {
|
|
24300
|
-
|
|
24337
|
+
const pmInfo = (0, import_which_pm_runs.default)();
|
|
24338
|
+
let { name: name2, version: version3 } = pmInfo ?? { name: "npm", version: "0.0.0" };
|
|
24301
24339
|
if (process.env.TEST_PM) {
|
|
24302
24340
|
switch (process.env.TEST_PM) {
|
|
24303
24341
|
case "pnpm":
|
|
@@ -25811,7 +25849,7 @@ var init_poll = __esm({
|
|
|
25811
25849
|
var version2;
|
|
25812
25850
|
var init_package3 = __esm({
|
|
25813
25851
|
"../wrangler/package.json"() {
|
|
25814
|
-
version2 = "3.
|
|
25852
|
+
version2 = "3.34.2";
|
|
25815
25853
|
}
|
|
25816
25854
|
});
|
|
25817
25855
|
|
|
@@ -27872,7 +27910,7 @@ var require_toml = __commonJS({
|
|
|
27872
27910
|
});
|
|
27873
27911
|
|
|
27874
27912
|
// src/helpers/files.ts
|
|
27875
|
-
var import_fs5, import_path5, import_toml, copyFile, writeFile2, readFile, readJSON, writeJSON, probePaths, usesTypescript, eslintRcExts, usesEslint, compatDateFlag;
|
|
27913
|
+
var import_fs5, import_path5, import_toml, copyFile, writeFile2, appendFile, readFile, directoryExists, readJSON, writeJSON, probePaths, usesTypescript, eslintRcExts, usesEslint, compatDateFlag;
|
|
27876
27914
|
var init_files = __esm({
|
|
27877
27915
|
"src/helpers/files.ts"() {
|
|
27878
27916
|
import_fs5 = __toESM(require("fs"));
|
|
@@ -27894,6 +27932,13 @@ var init_files = __esm({
|
|
|
27894
27932
|
crash(error2);
|
|
27895
27933
|
}
|
|
27896
27934
|
};
|
|
27935
|
+
appendFile = (path3, content) => {
|
|
27936
|
+
try {
|
|
27937
|
+
import_fs5.default.appendFileSync(path3, content);
|
|
27938
|
+
} catch (error2) {
|
|
27939
|
+
crash(error2);
|
|
27940
|
+
}
|
|
27941
|
+
};
|
|
27897
27942
|
readFile = (path3) => {
|
|
27898
27943
|
try {
|
|
27899
27944
|
return import_fs5.default.readFileSync(path3, "utf-8");
|
|
@@ -27901,6 +27946,17 @@ var init_files = __esm({
|
|
|
27901
27946
|
return crash(error2);
|
|
27902
27947
|
}
|
|
27903
27948
|
};
|
|
27949
|
+
directoryExists = (path3) => {
|
|
27950
|
+
try {
|
|
27951
|
+
const stat = (0, import_fs5.statSync)(path3);
|
|
27952
|
+
return stat.isDirectory();
|
|
27953
|
+
} catch (error2) {
|
|
27954
|
+
if (error2.code === "ENOENT") {
|
|
27955
|
+
return false;
|
|
27956
|
+
}
|
|
27957
|
+
return crash(error2);
|
|
27958
|
+
}
|
|
27959
|
+
};
|
|
27904
27960
|
readJSON = (path3) => {
|
|
27905
27961
|
const contents = readFile(path3);
|
|
27906
27962
|
return contents ? JSON.parse(contents) : contents;
|
|
@@ -31115,10 +31171,6 @@ var init_command = __esm({
|
|
|
31115
31171
|
)}`
|
|
31116
31172
|
);
|
|
31117
31173
|
logRaw("");
|
|
31118
|
-
if (process.env.VITEST) {
|
|
31119
|
-
const flags = ctx.template.testFlags ?? [];
|
|
31120
|
-
cmd.push(...flags);
|
|
31121
|
-
}
|
|
31122
31174
|
await runCommand(cmd, { env: env2 });
|
|
31123
31175
|
};
|
|
31124
31176
|
installPackages = async (packages, config13) => {
|
|
@@ -37987,8 +38039,8 @@ var require_index_688c5d50 = __commonJS({
|
|
|
37987
38039
|
}
|
|
37988
38040
|
var fs$appendFile = fs3.appendFile;
|
|
37989
38041
|
if (fs$appendFile)
|
|
37990
|
-
fs3.appendFile =
|
|
37991
|
-
function
|
|
38042
|
+
fs3.appendFile = appendFile2;
|
|
38043
|
+
function appendFile2(path4, data, options, cb) {
|
|
37992
38044
|
if (typeof options === "function")
|
|
37993
38045
|
cb = options, options = null;
|
|
37994
38046
|
return go$appendFile(path4, data, options, cb);
|
|
@@ -41823,12 +41875,12 @@ var require_index_688c5d50 = __commonJS({
|
|
|
41823
41875
|
}
|
|
41824
41876
|
function exec2(command2) {
|
|
41825
41877
|
return new Promise((fulfil, reject) => {
|
|
41826
|
-
child_process__default["default"].exec(command2, (err,
|
|
41878
|
+
child_process__default["default"].exec(command2, (err, stdout2, stderr2) => {
|
|
41827
41879
|
if (err) {
|
|
41828
41880
|
reject(err);
|
|
41829
41881
|
return;
|
|
41830
41882
|
}
|
|
41831
|
-
fulfil({ stdout, stderr });
|
|
41883
|
+
fulfil({ stdout: stdout2, stderr: stderr2 });
|
|
41832
41884
|
});
|
|
41833
41885
|
});
|
|
41834
41886
|
}
|
|
@@ -42198,8 +42250,8 @@ var require_index_688c5d50 = __commonJS({
|
|
|
42198
42250
|
}
|
|
42199
42251
|
async function fetchRefs(repo) {
|
|
42200
42252
|
try {
|
|
42201
|
-
const { stdout } = await exec2(`git ls-remote ${repo.url}`);
|
|
42202
|
-
return
|
|
42253
|
+
const { stdout: stdout2 } = await exec2(`git ls-remote ${repo.url}`);
|
|
42254
|
+
return stdout2.split("\n").filter(Boolean).map((row) => {
|
|
42203
42255
|
const [hash, ref] = row.split(" ");
|
|
42204
42256
|
if (ref === "HEAD") {
|
|
42205
42257
|
return {
|
|
@@ -42377,19 +42429,18 @@ var init_c3 = __esm({
|
|
|
42377
42429
|
copyFiles: {
|
|
42378
42430
|
path: "./templates"
|
|
42379
42431
|
},
|
|
42432
|
+
devScript: "start",
|
|
42433
|
+
deployScript: "deploy",
|
|
42380
42434
|
generate,
|
|
42381
42435
|
configure,
|
|
42382
42436
|
transformPackageJson: async () => ({
|
|
42383
42437
|
scripts: {
|
|
42384
|
-
start: `${npm3} run
|
|
42438
|
+
start: `${npm3} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
|
|
42439
|
+
build: `ng build && ${npm3} run process`,
|
|
42385
42440
|
process: "node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
|
|
42386
|
-
|
|
42387
|
-
deploy: `${npm3} run pages:build && wrangler pages deploy dist/cloudflare`
|
|
42441
|
+
deploy: `${npm3} run build && wrangler pages deploy dist/cloudflare`
|
|
42388
42442
|
}
|
|
42389
|
-
})
|
|
42390
|
-
deployScript: "deploy",
|
|
42391
|
-
devScript: "start",
|
|
42392
|
-
testFlags: ["--style", "sass"]
|
|
42443
|
+
})
|
|
42393
42444
|
};
|
|
42394
42445
|
c3_default = config;
|
|
42395
42446
|
}
|
|
@@ -73597,16 +73648,7 @@ var init_c32 = __esm({
|
|
|
73597
73648
|
preview: `astro build && wrangler pages dev ./dist`,
|
|
73598
73649
|
...usesTypescript(ctx) && { "build-cf-types": `wrangler types` }
|
|
73599
73650
|
}
|
|
73600
|
-
})
|
|
73601
|
-
testFlags: [
|
|
73602
|
-
"--skip-houston",
|
|
73603
|
-
"--no-install",
|
|
73604
|
-
"--no-git",
|
|
73605
|
-
"--template",
|
|
73606
|
-
"blog",
|
|
73607
|
-
"--typescript",
|
|
73608
|
-
"strict"
|
|
73609
|
-
]
|
|
73651
|
+
})
|
|
73610
73652
|
};
|
|
73611
73653
|
c3_default2 = config2;
|
|
73612
73654
|
}
|
|
@@ -73621,7 +73663,6 @@ var npm4, generate3, config3, c3_default3;
|
|
|
73621
73663
|
var init_c33 = __esm({
|
|
73622
73664
|
"templates/docusaurus/c3.ts"() {
|
|
73623
73665
|
init_command();
|
|
73624
|
-
init_files();
|
|
73625
73666
|
init_packages();
|
|
73626
73667
|
({ npm: npm4 } = detectPackageManager());
|
|
73627
73668
|
generate3 = async (ctx) => {
|
|
@@ -73635,11 +73676,11 @@ var init_c33 = __esm({
|
|
|
73635
73676
|
generate: generate3,
|
|
73636
73677
|
transformPackageJson: async () => ({
|
|
73637
73678
|
scripts: {
|
|
73638
|
-
|
|
73639
|
-
"pages:deploy": `${npm4} run build && wrangler pages deploy ./build`
|
|
73679
|
+
deploy: `${npm4} run build && wrangler pages deploy ./build`
|
|
73640
73680
|
}
|
|
73641
73681
|
}),
|
|
73642
|
-
|
|
73682
|
+
devScript: "start",
|
|
73683
|
+
deployScript: "deploy"
|
|
73643
73684
|
};
|
|
73644
73685
|
c3_default3 = config3;
|
|
73645
73686
|
}
|
|
@@ -73655,7 +73696,6 @@ var init_c34 = __esm({
|
|
|
73655
73696
|
"templates/gatsby/c3.ts"() {
|
|
73656
73697
|
init_interactive();
|
|
73657
73698
|
init_command();
|
|
73658
|
-
init_files();
|
|
73659
73699
|
init_packages();
|
|
73660
73700
|
({ npm: npm5 } = detectPackageManager());
|
|
73661
73701
|
generate4 = async (ctx) => {
|
|
@@ -73685,10 +73725,13 @@ var init_c34 = __esm({
|
|
|
73685
73725
|
generate: generate4,
|
|
73686
73726
|
transformPackageJson: async () => ({
|
|
73687
73727
|
scripts: {
|
|
73688
|
-
|
|
73689
|
-
|
|
73728
|
+
deploy: `${npm5} run build && wrangler pages deploy ./public`,
|
|
73729
|
+
preview: `${npm5} run build && wrangler pages dev ./public`
|
|
73690
73730
|
}
|
|
73691
|
-
})
|
|
73731
|
+
}),
|
|
73732
|
+
devScript: "develop",
|
|
73733
|
+
deployScript: "deploy",
|
|
73734
|
+
previewScript: "preview"
|
|
73692
73735
|
};
|
|
73693
73736
|
c3_default4 = config4;
|
|
73694
73737
|
}
|
|
@@ -73851,9 +73894,6 @@ var init_c36 = __esm({
|
|
|
73851
73894
|
id: "next",
|
|
73852
73895
|
platform: "pages",
|
|
73853
73896
|
displayName: "Next",
|
|
73854
|
-
devScript: "dev",
|
|
73855
|
-
previewScript: "preview",
|
|
73856
|
-
deployScript: "deploy",
|
|
73857
73897
|
generate: generate6,
|
|
73858
73898
|
configure: configure3,
|
|
73859
73899
|
copyFiles: {
|
|
@@ -73901,16 +73941,9 @@ var init_c36 = __esm({
|
|
|
73901
73941
|
}
|
|
73902
73942
|
};
|
|
73903
73943
|
},
|
|
73904
|
-
|
|
73905
|
-
|
|
73906
|
-
|
|
73907
|
-
"--eslint",
|
|
73908
|
-
"--tailwind",
|
|
73909
|
-
"--src-dir",
|
|
73910
|
-
"--app",
|
|
73911
|
-
"--import-alias",
|
|
73912
|
-
"@/*"
|
|
73913
|
-
],
|
|
73944
|
+
devScript: "dev",
|
|
73945
|
+
previewScript: "preview",
|
|
73946
|
+
deployScript: "deploy",
|
|
73914
73947
|
compatibilityFlags: ["nodejs_compat"]
|
|
73915
73948
|
};
|
|
73916
73949
|
}
|
|
@@ -73921,7 +73954,7 @@ var c3_exports7 = {};
|
|
|
73921
73954
|
__export(c3_exports7, {
|
|
73922
73955
|
default: () => c3_default7
|
|
73923
73956
|
});
|
|
73924
|
-
var recast3, npm7, generate7, configure4, updateNuxtConfig, config6, c3_default7;
|
|
73957
|
+
var recast3, npm7, pm, generate7, configure4, updateEnvTypes, updateNuxtConfig, config6, c3_default7;
|
|
73925
73958
|
var init_c37 = __esm({
|
|
73926
73959
|
"templates/nuxt/c3.ts"() {
|
|
73927
73960
|
init_cli();
|
|
@@ -73932,7 +73965,8 @@ var init_c37 = __esm({
|
|
|
73932
73965
|
init_files();
|
|
73933
73966
|
init_packages();
|
|
73934
73967
|
recast3 = __toESM(require_main3());
|
|
73935
|
-
(
|
|
73968
|
+
init_workers();
|
|
73969
|
+
({ npm: npm7, name: pm } = detectPackageManager());
|
|
73936
73970
|
generate7 = async (ctx) => {
|
|
73937
73971
|
const gitFlag = ctx.args.git ? `--gitInit` : `--no-gitInit`;
|
|
73938
73972
|
await runFrameworkGenerator(ctx, [
|
|
@@ -73945,13 +73979,32 @@ var init_c37 = __esm({
|
|
|
73945
73979
|
writeFile2("./.node-version", "17");
|
|
73946
73980
|
logRaw("");
|
|
73947
73981
|
};
|
|
73948
|
-
configure4 = async () => {
|
|
73949
|
-
|
|
73982
|
+
configure4 = async (ctx) => {
|
|
73983
|
+
const packages = ["nitro-cloudflare-dev"];
|
|
73984
|
+
if (pm === "pnpm") {
|
|
73985
|
+
packages.push("h3");
|
|
73986
|
+
}
|
|
73987
|
+
await installPackages(packages, {
|
|
73950
73988
|
dev: true,
|
|
73951
73989
|
startText: "Installing nitro module `nitro-cloudflare-dev`",
|
|
73952
73990
|
doneText: `${brandColor("installed")} ${dim(`via \`${npm7} install\``)}`
|
|
73953
73991
|
});
|
|
73954
73992
|
updateNuxtConfig();
|
|
73993
|
+
updateEnvTypes(ctx);
|
|
73994
|
+
};
|
|
73995
|
+
updateEnvTypes = (ctx) => {
|
|
73996
|
+
const filepath = "env.d.ts";
|
|
73997
|
+
const s = spinner();
|
|
73998
|
+
s.start(`Updating ${filepath}`);
|
|
73999
|
+
let file = readFile(filepath);
|
|
74000
|
+
let typesEntrypoint = `@cloudflare/workers-types/`;
|
|
74001
|
+
const latestEntrypoint = getLatestTypesEntrypoint(ctx);
|
|
74002
|
+
if (latestEntrypoint) {
|
|
74003
|
+
typesEntrypoint += `/${latestEntrypoint}`;
|
|
74004
|
+
}
|
|
74005
|
+
file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
|
|
74006
|
+
writeFile2("env.d.ts", file);
|
|
74007
|
+
s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
|
|
73955
74008
|
};
|
|
73956
74009
|
updateNuxtConfig = () => {
|
|
73957
74010
|
const s = spinner();
|
|
@@ -73992,8 +74045,6 @@ var init_c37 = __esm({
|
|
|
73992
74045
|
copyFiles: {
|
|
73993
74046
|
path: "./templates"
|
|
73994
74047
|
},
|
|
73995
|
-
devScript: "dev",
|
|
73996
|
-
deployScript: "deploy",
|
|
73997
74048
|
generate: generate7,
|
|
73998
74049
|
configure: configure4,
|
|
73999
74050
|
transformPackageJson: async () => ({
|
|
@@ -74002,7 +74053,10 @@ var init_c37 = __esm({
|
|
|
74002
74053
|
preview: `${npm7} run build && wrangler pages dev ./dist`,
|
|
74003
74054
|
"build-cf-types": `wrangler types`
|
|
74004
74055
|
}
|
|
74005
|
-
})
|
|
74056
|
+
}),
|
|
74057
|
+
devScript: "dev",
|
|
74058
|
+
deployScript: "deploy",
|
|
74059
|
+
previewScript: "preview"
|
|
74006
74060
|
};
|
|
74007
74061
|
c3_default7 = config6;
|
|
74008
74062
|
}
|
|
@@ -74114,8 +74168,6 @@ var init_c38 = __esm({
|
|
|
74114
74168
|
copyFiles: {
|
|
74115
74169
|
path: "./templates"
|
|
74116
74170
|
},
|
|
74117
|
-
devScript: "dev",
|
|
74118
|
-
deployScript: "deploy",
|
|
74119
74171
|
generate: generate8,
|
|
74120
74172
|
configure: configure5,
|
|
74121
74173
|
transformPackageJson: async () => ({
|
|
@@ -74124,7 +74176,10 @@ var init_c38 = __esm({
|
|
|
74124
74176
|
preview: `${npm8} run build && wrangler pages dev ./dist`,
|
|
74125
74177
|
"build-cf-types": `wrangler types`
|
|
74126
74178
|
}
|
|
74127
|
-
})
|
|
74179
|
+
}),
|
|
74180
|
+
devScript: "dev",
|
|
74181
|
+
deployScript: "deploy",
|
|
74182
|
+
previewScript: "preview"
|
|
74128
74183
|
};
|
|
74129
74184
|
c3_default8 = config7;
|
|
74130
74185
|
}
|
|
@@ -74140,7 +74195,6 @@ var init_c39 = __esm({
|
|
|
74140
74195
|
"templates/react/c3.ts"() {
|
|
74141
74196
|
init_cli();
|
|
74142
74197
|
init_command();
|
|
74143
|
-
init_files();
|
|
74144
74198
|
init_packages();
|
|
74145
74199
|
({ npm: npm9 } = detectPackageManager());
|
|
74146
74200
|
generate9 = async (ctx) => {
|
|
@@ -74155,10 +74209,13 @@ var init_c39 = __esm({
|
|
|
74155
74209
|
generate: generate9,
|
|
74156
74210
|
transformPackageJson: async () => ({
|
|
74157
74211
|
scripts: {
|
|
74158
|
-
|
|
74159
|
-
|
|
74212
|
+
deploy: `${npm9} run build && wrangler pages deploy ./build`,
|
|
74213
|
+
preview: `${npm9} run build && wrangler pages dev ./build`
|
|
74160
74214
|
}
|
|
74161
|
-
})
|
|
74215
|
+
}),
|
|
74216
|
+
devScript: "dev",
|
|
74217
|
+
deployScript: "deploy",
|
|
74218
|
+
previewScript: "preview"
|
|
74162
74219
|
};
|
|
74163
74220
|
c3_default9 = config8;
|
|
74164
74221
|
}
|
|
@@ -74221,8 +74278,7 @@ var init_c310 = __esm({
|
|
|
74221
74278
|
}),
|
|
74222
74279
|
devScript: "dev",
|
|
74223
74280
|
deployScript: "deploy",
|
|
74224
|
-
previewScript: "preview"
|
|
74225
|
-
testFlags: ["--typescript", "--no-install", "--no-git-init"]
|
|
74281
|
+
previewScript: "preview"
|
|
74226
74282
|
};
|
|
74227
74283
|
c3_default10 = config9;
|
|
74228
74284
|
}
|
|
@@ -74245,7 +74301,7 @@ var init_c311 = __esm({
|
|
|
74245
74301
|
recast5 = __toESM(require_main3());
|
|
74246
74302
|
({ npm: npm11 } = detectPackageManager());
|
|
74247
74303
|
generate11 = async (ctx) => {
|
|
74248
|
-
await runFrameworkGenerator(ctx, [ctx.project.name]);
|
|
74304
|
+
await runFrameworkGenerator(ctx, ["-p", ctx.project.name, "-s"]);
|
|
74249
74305
|
logRaw("");
|
|
74250
74306
|
};
|
|
74251
74307
|
configure7 = async (ctx) => {
|
|
@@ -74298,10 +74354,10 @@ var init_c311 = __esm({
|
|
|
74298
74354
|
deploy: `${npm11} run build && wrangler pages deploy ./dist`
|
|
74299
74355
|
}
|
|
74300
74356
|
}),
|
|
74357
|
+
compatibilityFlags: ["nodejs_compat"],
|
|
74301
74358
|
devScript: "dev",
|
|
74302
74359
|
deployScript: "deploy",
|
|
74303
|
-
previewScript: "preview"
|
|
74304
|
-
compatibilityFlags: ["nodejs_compat"]
|
|
74360
|
+
previewScript: "preview"
|
|
74305
74361
|
};
|
|
74306
74362
|
c3_default11 = config10;
|
|
74307
74363
|
}
|
|
@@ -74431,7 +74487,6 @@ var npm13, generate13, config12, c3_default13;
|
|
|
74431
74487
|
var init_c313 = __esm({
|
|
74432
74488
|
"templates/vue/c3.ts"() {
|
|
74433
74489
|
init_command();
|
|
74434
|
-
init_files();
|
|
74435
74490
|
init_packages();
|
|
74436
74491
|
({ npm: npm13 } = detectPackageManager());
|
|
74437
74492
|
generate13 = async (ctx) => {
|
|
@@ -74445,11 +74500,13 @@ var init_c313 = __esm({
|
|
|
74445
74500
|
generate: generate13,
|
|
74446
74501
|
transformPackageJson: async () => ({
|
|
74447
74502
|
scripts: {
|
|
74448
|
-
|
|
74449
|
-
|
|
74503
|
+
deploy: `${npm13} run build && wrangler pages deploy ./dist`,
|
|
74504
|
+
preview: `${npm13} run build && wrangler pages dev ./dist`
|
|
74450
74505
|
}
|
|
74451
74506
|
}),
|
|
74452
|
-
|
|
74507
|
+
devScript: "dev",
|
|
74508
|
+
deployScript: "deploy",
|
|
74509
|
+
previewScript: "preview"
|
|
74453
74510
|
};
|
|
74454
74511
|
c3_default13 = config12;
|
|
74455
74512
|
}
|
|
@@ -74727,7 +74784,7 @@ async function copyTemplateFiles(ctx) {
|
|
|
74727
74784
|
}
|
|
74728
74785
|
s.stop(`${brandColor("files")} ${dim("copied to project directory")}`);
|
|
74729
74786
|
}
|
|
74730
|
-
var import_fs10, import_promises2, import_os2, import_path12, import_deepmerge, import_degit, defaultSelectVariant, getFrameworkMap, getTemplateMap, selectTemplate, selectFramework, shouldUseTs, processRemoteTemplate, validateTemplate, validateTemplateSrcDirectory, inferTemplateConfig, inferCopyFilesDefinition, downloadRemoteTemplate, updatePackageName, updatePackageScripts, getTemplatePath, isVariantInfo, getCopyFilesDestinationDir;
|
|
74787
|
+
var import_fs10, import_promises2, import_os2, import_path12, import_deepmerge, import_degit, defaultSelectVariant, getFrameworkMap, getTemplateMap, selectTemplate, selectFramework, shouldUseTs, processRemoteTemplate, validateTemplate, validateTemplateSrcDirectory, inferTemplateConfig, inferCopyFilesDefinition, downloadRemoteTemplate, updatePackageName, updatePackageScripts, getTemplatePath, isVariantInfo, getCopyFilesDestinationDir, addWranglerToGitIgnore;
|
|
74731
74788
|
var init_templates = __esm({
|
|
74732
74789
|
"src/templates.ts"() {
|
|
74733
74790
|
import_fs10 = require("fs");
|
|
@@ -74985,6 +75042,45 @@ var init_templates = __esm({
|
|
|
74985
75042
|
}
|
|
74986
75043
|
return copyFiles.destinationDir(ctx);
|
|
74987
75044
|
};
|
|
75045
|
+
addWranglerToGitIgnore = (ctx) => {
|
|
75046
|
+
const gitIgnorePath = `${ctx.project.path}/.gitignore`;
|
|
75047
|
+
const gitIgnorePreExisted = (0, import_fs10.existsSync)(gitIgnorePath);
|
|
75048
|
+
const gitDirExists = directoryExists(`${ctx.project.path}/.git`);
|
|
75049
|
+
if (!gitIgnorePreExisted && !gitDirExists) {
|
|
75050
|
+
return;
|
|
75051
|
+
}
|
|
75052
|
+
if (!gitIgnorePreExisted) {
|
|
75053
|
+
writeFile2(gitIgnorePath, "");
|
|
75054
|
+
}
|
|
75055
|
+
const existingGitIgnoreContent = readFile(gitIgnorePath);
|
|
75056
|
+
const wranglerGitIgnoreFiles = [".wrangler", ".dev.vars"];
|
|
75057
|
+
const wranglerGitIgnoreFilesToAdd = wranglerGitIgnoreFiles.filter(
|
|
75058
|
+
(file) => !existingGitIgnoreContent.match(
|
|
75059
|
+
new RegExp(`
|
|
75060
|
+
${file}${file === ".wrangler" ? "/?" : ""}\\s+(#'*)?`)
|
|
75061
|
+
)
|
|
75062
|
+
);
|
|
75063
|
+
if (wranglerGitIgnoreFilesToAdd.length === 0) {
|
|
75064
|
+
return;
|
|
75065
|
+
}
|
|
75066
|
+
const s = spinner();
|
|
75067
|
+
s.start("Adding Wrangler files to the .gitignore file");
|
|
75068
|
+
const linesToAppend = [
|
|
75069
|
+
"",
|
|
75070
|
+
...!existingGitIgnoreContent.match(/\n\s*$/) ? [""] : []
|
|
75071
|
+
];
|
|
75072
|
+
if (wranglerGitIgnoreFilesToAdd.length === wranglerGitIgnoreFiles.length) {
|
|
75073
|
+
linesToAppend.push("# wrangler files");
|
|
75074
|
+
}
|
|
75075
|
+
wranglerGitIgnoreFilesToAdd.forEach((line) => linesToAppend.push(line));
|
|
75076
|
+
linesToAppend.push("");
|
|
75077
|
+
appendFile(gitIgnorePath, linesToAppend.join("\n"));
|
|
75078
|
+
s.stop(
|
|
75079
|
+
`${brandColor(gitIgnorePreExisted ? "updated" : "created")} ${dim(
|
|
75080
|
+
".gitignore file"
|
|
75081
|
+
)}`
|
|
75082
|
+
);
|
|
75083
|
+
};
|
|
74988
75084
|
}
|
|
74989
75085
|
});
|
|
74990
75086
|
|
|
@@ -80121,6 +80217,7 @@ var configure9 = async (ctx) => {
|
|
|
80121
80217
|
if (template.configure) {
|
|
80122
80218
|
await template.configure({ ...ctx });
|
|
80123
80219
|
}
|
|
80220
|
+
addWranglerToGitIgnore(ctx);
|
|
80124
80221
|
await updatePackageScripts(ctx);
|
|
80125
80222
|
await offerGit(ctx);
|
|
80126
80223
|
await gitCommit(ctx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cloudflare",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-a676f55a",
|
|
4
4
|
"description": "A CLI for creating and deploying new applications to Cloudflare.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"which-pm-runs": "^1.1.0",
|
|
67
67
|
"yargs": "^17.7.1",
|
|
68
68
|
"yarn": "^1.22.19",
|
|
69
|
-
"@cloudflare/cli": "1.1.1",
|
|
70
69
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
71
|
-
"wrangler": "3.
|
|
70
|
+
"wrangler": "3.34.2",
|
|
71
|
+
"@cloudflare/cli": "1.1.1"
|
|
72
72
|
},
|
|
73
73
|
"engines": {
|
|
74
74
|
"node": ">=18.14.1"
|
package/templates/angular/c3.ts
CHANGED
|
@@ -81,19 +81,18 @@ const config: TemplateConfig = {
|
|
|
81
81
|
copyFiles: {
|
|
82
82
|
path: "./templates",
|
|
83
83
|
},
|
|
84
|
+
devScript: "start",
|
|
85
|
+
deployScript: "deploy",
|
|
84
86
|
generate,
|
|
85
87
|
configure,
|
|
86
88
|
transformPackageJson: async () => ({
|
|
87
89
|
scripts: {
|
|
88
|
-
start: `${npm} run
|
|
90
|
+
start: `${npm} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
|
|
91
|
+
build: `ng build && ${npm} run process`,
|
|
89
92
|
process:
|
|
90
93
|
"node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
|
|
91
|
-
|
|
92
|
-
deploy: `${npm} run pages:build && wrangler pages deploy dist/cloudflare`,
|
|
94
|
+
deploy: `${npm} run build && wrangler pages deploy dist/cloudflare`,
|
|
93
95
|
},
|
|
94
96
|
}),
|
|
95
|
-
deployScript: "deploy",
|
|
96
|
-
devScript: "start",
|
|
97
|
-
testFlags: ["--style", "sass"],
|
|
98
97
|
};
|
|
99
98
|
export default config;
|
package/templates/astro/c3.ts
CHANGED
|
@@ -107,14 +107,5 @@ const config: TemplateConfig = {
|
|
|
107
107
|
...(usesTypescript(ctx) && { "build-cf-types": `wrangler types` }),
|
|
108
108
|
},
|
|
109
109
|
}),
|
|
110
|
-
testFlags: [
|
|
111
|
-
"--skip-houston",
|
|
112
|
-
"--no-install",
|
|
113
|
-
"--no-git",
|
|
114
|
-
"--template",
|
|
115
|
-
"blog",
|
|
116
|
-
"--typescript",
|
|
117
|
-
"strict",
|
|
118
|
-
],
|
|
119
110
|
};
|
|
120
111
|
export default config;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { runFrameworkGenerator } from "helpers/command";
|
|
2
|
-
import { compatDateFlag } from "helpers/files";
|
|
3
2
|
import { detectPackageManager } from "helpers/packages";
|
|
4
3
|
import type { TemplateConfig } from "../../src/templates";
|
|
5
4
|
import type { C3Context } from "types";
|
|
@@ -18,10 +17,10 @@ const config: TemplateConfig = {
|
|
|
18
17
|
generate,
|
|
19
18
|
transformPackageJson: async () => ({
|
|
20
19
|
scripts: {
|
|
21
|
-
|
|
22
|
-
"pages:deploy": `${npm} run build && wrangler pages deploy ./build`,
|
|
20
|
+
deploy: `${npm} run build && wrangler pages deploy ./build`,
|
|
23
21
|
},
|
|
24
22
|
}),
|
|
25
|
-
|
|
23
|
+
devScript: "start",
|
|
24
|
+
deployScript: "deploy",
|
|
26
25
|
};
|
|
27
26
|
export default config;
|
package/templates/gatsby/c3.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { inputPrompt } from "@cloudflare/cli/interactive";
|
|
2
2
|
import { runFrameworkGenerator } from "helpers/command";
|
|
3
|
-
import { compatDateFlag } from "helpers/files";
|
|
4
3
|
import { detectPackageManager } from "helpers/packages";
|
|
5
4
|
import type { TemplateConfig } from "../../src/templates";
|
|
6
5
|
import type { C3Context } from "types";
|
|
@@ -38,9 +37,12 @@ const config: TemplateConfig = {
|
|
|
38
37
|
generate,
|
|
39
38
|
transformPackageJson: async () => ({
|
|
40
39
|
scripts: {
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
deploy: `${npm} run build && wrangler pages deploy ./public`,
|
|
41
|
+
preview: `${npm} run build && wrangler pages dev ./public`,
|
|
43
42
|
},
|
|
44
43
|
}),
|
|
44
|
+
devScript: "develop",
|
|
45
|
+
deployScript: "deploy",
|
|
46
|
+
previewScript: "preview",
|
|
45
47
|
};
|
|
46
48
|
export default config;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { env, createExecutionContext, waitOnExecutionContext, SELF } from "cloudflare:test";
|
|
2
|
+
import { describe, it, expect } from "vitest";
|
|
3
|
+
import worker from "../src";
|
|
4
|
+
|
|
5
|
+
describe("Hello World worker", () => {
|
|
6
|
+
it("responds with Hello World! (unit style)", async () => {
|
|
7
|
+
const request = new Request("http://example.com");
|
|
8
|
+
// Create an empty context to pass to `worker.fetch()`.
|
|
9
|
+
const ctx = createExecutionContext();
|
|
10
|
+
const response = await worker.fetch(request, env, ctx);
|
|
11
|
+
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
|
|
12
|
+
await waitOnExecutionContext(ctx);
|
|
13
|
+
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("responds with Hello World! (integration style)", async () => {
|
|
17
|
+
const response = await SELF.fetch(request, env, ctx);
|
|
18
|
+
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
"scripts": {
|
|
6
6
|
"deploy": "wrangler deploy",
|
|
7
7
|
"dev": "wrangler dev",
|
|
8
|
-
"start": "wrangler dev"
|
|
8
|
+
"start": "wrangler dev",
|
|
9
|
+
"test": "vitest"
|
|
9
10
|
},
|
|
10
11
|
"devDependencies": {
|
|
11
12
|
"typescript": "^5.0.4",
|
|
12
|
-
"wrangler": "^3.0.0"
|
|
13
|
+
"wrangler": "^3.0.0",
|
|
14
|
+
"vitest": "1.3.0",
|
|
15
|
+
"@cloudflare/vitest-pool-workers": "^0.1.0"
|
|
13
16
|
}
|
|
14
17
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// test/index.spec.ts
|
|
2
|
+
import { env, createExecutionContext, waitOnExecutionContext, SELF } from "cloudflare:test";
|
|
3
|
+
import { describe, it, expect } from "vitest";
|
|
4
|
+
import worker from "../src/index";
|
|
5
|
+
|
|
6
|
+
// For now, you'll need to do something like this to get a correctly-typed
|
|
7
|
+
// `Request` to pass to `worker.fetch()`.
|
|
8
|
+
const IncomingRequest = Request<unknown, IncomingRequestCfProperties>;
|
|
9
|
+
|
|
10
|
+
describe("Hello World worker", () => {
|
|
11
|
+
it("responds with Hello World! (unit style)", async () => {
|
|
12
|
+
const request = new IncomingRequest("http://example.com");
|
|
13
|
+
// Create an empty context to pass to `worker.fetch()`.
|
|
14
|
+
const ctx = createExecutionContext();
|
|
15
|
+
const response = await worker.fetch(request, env, ctx);
|
|
16
|
+
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
|
|
17
|
+
await waitOnExecutionContext(ctx);
|
|
18
|
+
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("responds with Hello World! (integration style)", async () => {
|
|
22
|
+
const response = await SELF.fetch("https://example.com");
|
|
23
|
+
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
/* Modules */
|
|
27
27
|
"module": "es2022" /* Specify what module code is generated. */,
|
|
28
28
|
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
29
|
-
"moduleResolution": "
|
|
29
|
+
"moduleResolution": "Bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
|
30
30
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
31
31
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
32
32
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
@@ -97,5 +97,6 @@
|
|
|
97
97
|
/* Completeness */
|
|
98
98
|
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
99
99
|
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
100
|
-
}
|
|
100
|
+
},
|
|
101
|
+
"exclude": ["test"]
|
|
101
102
|
}
|
package/templates/next/c3.ts
CHANGED
|
@@ -158,9 +158,6 @@ export default {
|
|
|
158
158
|
id: "next",
|
|
159
159
|
platform: "pages",
|
|
160
160
|
displayName: "Next",
|
|
161
|
-
devScript: "dev",
|
|
162
|
-
previewScript: "preview",
|
|
163
|
-
deployScript: "deploy",
|
|
164
161
|
generate,
|
|
165
162
|
configure,
|
|
166
163
|
copyFiles: {
|
|
@@ -212,15 +209,8 @@ export default {
|
|
|
212
209
|
},
|
|
213
210
|
};
|
|
214
211
|
},
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
"--eslint",
|
|
219
|
-
"--tailwind",
|
|
220
|
-
"--src-dir",
|
|
221
|
-
"--app",
|
|
222
|
-
"--import-alias",
|
|
223
|
-
"@/*",
|
|
224
|
-
],
|
|
212
|
+
devScript: "dev",
|
|
213
|
+
previewScript: "preview",
|
|
214
|
+
deployScript: "deploy",
|
|
225
215
|
compatibilityFlags: ["nodejs_compat"],
|
|
226
216
|
} as TemplateConfig;
|
package/templates/nuxt/c3.ts
CHANGED
|
@@ -3,13 +3,14 @@ import { brandColor, dim } from "@cloudflare/cli/colors";
|
|
|
3
3
|
import { spinner } from "@cloudflare/cli/interactive";
|
|
4
4
|
import { transformFile } from "helpers/codemod";
|
|
5
5
|
import { installPackages, runFrameworkGenerator } from "helpers/command";
|
|
6
|
-
import { writeFile } from "helpers/files";
|
|
6
|
+
import { readFile, writeFile } from "helpers/files";
|
|
7
7
|
import { detectPackageManager } from "helpers/packages";
|
|
8
8
|
import * as recast from "recast";
|
|
9
|
+
import { getLatestTypesEntrypoint } from "../../src/workers";
|
|
9
10
|
import type { TemplateConfig } from "../../src/templates";
|
|
10
11
|
import type { C3Context } from "types";
|
|
11
12
|
|
|
12
|
-
const { npm } = detectPackageManager();
|
|
13
|
+
const { npm, name: pm } = detectPackageManager();
|
|
13
14
|
|
|
14
15
|
const generate = async (ctx: C3Context) => {
|
|
15
16
|
const gitFlag = ctx.args.git ? `--gitInit` : `--no-gitInit`;
|
|
@@ -27,13 +28,44 @@ const generate = async (ctx: C3Context) => {
|
|
|
27
28
|
logRaw(""); // newline
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
const configure = async () => {
|
|
31
|
-
|
|
31
|
+
const configure = async (ctx: C3Context) => {
|
|
32
|
+
const packages = ["nitro-cloudflare-dev"];
|
|
33
|
+
|
|
34
|
+
// When using pnpm, explicitly add h3 package so the H3Event type declaration can be updated.
|
|
35
|
+
// Package managers other than pnpm will hoist the dependency, as will pnpm with `--shamefully-hoist`
|
|
36
|
+
if (pm === "pnpm") {
|
|
37
|
+
packages.push("h3");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
await installPackages(packages, {
|
|
32
41
|
dev: true,
|
|
33
42
|
startText: "Installing nitro module `nitro-cloudflare-dev`",
|
|
34
43
|
doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
|
|
35
44
|
});
|
|
36
45
|
updateNuxtConfig();
|
|
46
|
+
|
|
47
|
+
updateEnvTypes(ctx);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const updateEnvTypes = (ctx: C3Context) => {
|
|
51
|
+
const filepath = "env.d.ts";
|
|
52
|
+
|
|
53
|
+
const s = spinner();
|
|
54
|
+
s.start(`Updating ${filepath}`);
|
|
55
|
+
|
|
56
|
+
let file = readFile(filepath);
|
|
57
|
+
|
|
58
|
+
let typesEntrypoint = `@cloudflare/workers-types/`;
|
|
59
|
+
const latestEntrypoint = getLatestTypesEntrypoint(ctx);
|
|
60
|
+
if (latestEntrypoint) {
|
|
61
|
+
typesEntrypoint += `/${latestEntrypoint}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Replace placeholder with actual types entrypoint
|
|
65
|
+
file = file.replace("WORKERS_TYPES_ENTRYPOINT", typesEntrypoint);
|
|
66
|
+
writeFile("env.d.ts", file);
|
|
67
|
+
|
|
68
|
+
s.stop(`${brandColor(`updated`)} ${dim(`\`${filepath}\``)}`);
|
|
37
69
|
};
|
|
38
70
|
|
|
39
71
|
const updateNuxtConfig = () => {
|
|
@@ -85,8 +117,6 @@ const config: TemplateConfig = {
|
|
|
85
117
|
copyFiles: {
|
|
86
118
|
path: "./templates",
|
|
87
119
|
},
|
|
88
|
-
devScript: "dev",
|
|
89
|
-
deployScript: "deploy",
|
|
90
120
|
generate,
|
|
91
121
|
configure,
|
|
92
122
|
transformPackageJson: async () => ({
|
|
@@ -96,5 +126,8 @@ const config: TemplateConfig = {
|
|
|
96
126
|
"build-cf-types": `wrangler types`,
|
|
97
127
|
},
|
|
98
128
|
}),
|
|
129
|
+
devScript: "dev",
|
|
130
|
+
deployScript: "deploy",
|
|
131
|
+
previewScript: "preview",
|
|
99
132
|
};
|
|
100
133
|
export default config;
|
package/templates/qwik/c3.ts
CHANGED
|
@@ -130,8 +130,6 @@ const config: TemplateConfig = {
|
|
|
130
130
|
copyFiles: {
|
|
131
131
|
path: "./templates",
|
|
132
132
|
},
|
|
133
|
-
devScript: "dev",
|
|
134
|
-
deployScript: "deploy",
|
|
135
133
|
generate,
|
|
136
134
|
configure,
|
|
137
135
|
transformPackageJson: async () => ({
|
|
@@ -141,5 +139,8 @@ const config: TemplateConfig = {
|
|
|
141
139
|
"build-cf-types": `wrangler types`,
|
|
142
140
|
},
|
|
143
141
|
}),
|
|
142
|
+
devScript: "dev",
|
|
143
|
+
deployScript: "deploy",
|
|
144
|
+
previewScript: "preview",
|
|
144
145
|
};
|
|
145
146
|
export default config;
|
package/templates/react/c3.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { logRaw } from "@cloudflare/cli";
|
|
2
2
|
import { runFrameworkGenerator } from "helpers/command";
|
|
3
|
-
import { compatDateFlag } from "helpers/files";
|
|
4
3
|
import { detectPackageManager } from "helpers/packages";
|
|
5
4
|
import type { TemplateConfig } from "../../src/templates";
|
|
6
5
|
import type { C3Context } from "types";
|
|
@@ -21,9 +20,12 @@ const config: TemplateConfig = {
|
|
|
21
20
|
generate,
|
|
22
21
|
transformPackageJson: async () => ({
|
|
23
22
|
scripts: {
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
deploy: `${npm} run build && wrangler pages deploy ./build`,
|
|
24
|
+
preview: `${npm} run build && wrangler pages dev ./build`,
|
|
26
25
|
},
|
|
27
26
|
}),
|
|
27
|
+
devScript: "dev",
|
|
28
|
+
deployScript: "deploy",
|
|
29
|
+
previewScript: "preview",
|
|
28
30
|
};
|
|
29
31
|
export default config;
|
package/templates/remix/c3.ts
CHANGED
package/templates/solid/c3.ts
CHANGED
|
@@ -12,7 +12,8 @@ const { npm } = detectPackageManager();
|
|
|
12
12
|
|
|
13
13
|
const generate = async (ctx: C3Context) => {
|
|
14
14
|
// Run the create-solid command
|
|
15
|
-
|
|
15
|
+
// -s flag forces solid-start
|
|
16
|
+
await runFrameworkGenerator(ctx, ["-p", ctx.project.name, "-s"]);
|
|
16
17
|
|
|
17
18
|
logRaw("");
|
|
18
19
|
};
|
|
@@ -72,9 +73,9 @@ const config: TemplateConfig = {
|
|
|
72
73
|
deploy: `${npm} run build && wrangler pages deploy ./dist`,
|
|
73
74
|
},
|
|
74
75
|
}),
|
|
76
|
+
compatibilityFlags: ["nodejs_compat"],
|
|
75
77
|
devScript: "dev",
|
|
76
78
|
deployScript: "deploy",
|
|
77
79
|
previewScript: "preview",
|
|
78
|
-
compatibilityFlags: ["nodejs_compat"],
|
|
79
80
|
};
|
|
80
81
|
export default config;
|
package/templates/vue/c3.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { runFrameworkGenerator } from "helpers/command";
|
|
2
|
-
import { compatDateFlag } from "helpers/files";
|
|
3
2
|
import { detectPackageManager } from "helpers/packages";
|
|
4
3
|
import type { TemplateConfig } from "../../src/templates";
|
|
5
4
|
import type { C3Context } from "types";
|
|
@@ -18,10 +17,12 @@ const config: TemplateConfig = {
|
|
|
18
17
|
generate,
|
|
19
18
|
transformPackageJson: async () => ({
|
|
20
19
|
scripts: {
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
deploy: `${npm} run build && wrangler pages deploy ./dist`,
|
|
21
|
+
preview: `${npm} run build && wrangler pages dev ./dist`,
|
|
23
22
|
},
|
|
24
23
|
}),
|
|
25
|
-
|
|
24
|
+
devScript: "dev",
|
|
25
|
+
deployScript: "deploy",
|
|
26
|
+
previewScript: "preview",
|
|
26
27
|
};
|
|
27
28
|
export default config;
|