create-cloudflare 0.0.0-62f1fce8 → 0.0.0-63216f1e
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 +101 -43
- package/package.json +4 -4
- package/templates/astro/c3.ts +2 -2
- package/templates/astro/snippets/runtimeDeclaration.ts +2 -1
- package/templates/next/README.md +1 -1
- package/templates/next/app/js/app/api/hello/route.js +1 -1
- package/templates/next/app/ts/app/api/hello/route.ts +1 -1
- package/templates/next/c3.ts +19 -3
- package/templates/next/pages/js/pages/api/hello.js +1 -1
- package/templates/next/pages/ts/pages/api/hello.ts +1 -1
- package/templates/next/wrangler.toml +0 -4
- package/templates/remix/c3.ts +1 -1
package/dist/cli.js
CHANGED
|
@@ -1605,7 +1605,7 @@ var init_streams = __esm({
|
|
|
1605
1605
|
});
|
|
1606
1606
|
|
|
1607
1607
|
// ../cli/index.ts
|
|
1608
|
-
var import_process, shapes, status, space, logRaw, log, newline, updateStatus, startSection, endSection, cancel, warn, stripAnsi, crash, error;
|
|
1608
|
+
var import_process, shapes, status, space, logRaw, log, newline, format, updateStatus, startSection, endSection, cancel, warn, stripAnsi, crash, error;
|
|
1609
1609
|
var init_cli = __esm({
|
|
1610
1610
|
"../cli/index.ts"() {
|
|
1611
1611
|
import_process = require("process");
|
|
@@ -1634,7 +1634,8 @@ var init_cli = __esm({
|
|
|
1634
1634
|
error: bgRed(` ERROR `),
|
|
1635
1635
|
warning: bgYellow(` WARNING `),
|
|
1636
1636
|
info: bgBlue(` INFO `),
|
|
1637
|
-
success: bgGreen(` SUCCESS `)
|
|
1637
|
+
success: bgGreen(` SUCCESS `),
|
|
1638
|
+
cancel: white.bgRed(` X `)
|
|
1638
1639
|
};
|
|
1639
1640
|
space = (n2 = 1) => {
|
|
1640
1641
|
return hidden("\u200A".repeat(n2));
|
|
@@ -1650,15 +1651,32 @@ var init_cli = __esm({
|
|
|
1650
1651
|
newline = () => {
|
|
1651
1652
|
log("");
|
|
1652
1653
|
};
|
|
1654
|
+
format = (msg, {
|
|
1655
|
+
linePrefix = gray(shapes.bar),
|
|
1656
|
+
firstLinePrefix = linePrefix,
|
|
1657
|
+
newlineBefore = false,
|
|
1658
|
+
newlineAfter = false,
|
|
1659
|
+
formatLine = (line) => white(line),
|
|
1660
|
+
multiline = true
|
|
1661
|
+
} = {}) => {
|
|
1662
|
+
const lines = multiline ? msg.split("\n") : [msg];
|
|
1663
|
+
const formattedLines = lines.map(
|
|
1664
|
+
(line, i) => (i === 0 ? firstLinePrefix : linePrefix) + space() + formatLine(line)
|
|
1665
|
+
);
|
|
1666
|
+
if (newlineBefore)
|
|
1667
|
+
formattedLines.unshift(linePrefix);
|
|
1668
|
+
if (newlineAfter)
|
|
1669
|
+
formattedLines.push(linePrefix);
|
|
1670
|
+
return formattedLines.join("\n");
|
|
1671
|
+
};
|
|
1653
1672
|
updateStatus = (msg, printNewLine = true) => {
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
newline();
|
|
1673
|
+
logRaw(
|
|
1674
|
+
format(msg, {
|
|
1675
|
+
firstLinePrefix: gray(shapes.leftT),
|
|
1676
|
+
linePrefix: gray(shapes.bar),
|
|
1677
|
+
newlineAfter: printNewLine
|
|
1678
|
+
})
|
|
1679
|
+
);
|
|
1662
1680
|
};
|
|
1663
1681
|
startSection = (heading, subheading, printNewLine = true) => {
|
|
1664
1682
|
logRaw(
|
|
@@ -1673,13 +1691,39 @@ var init_cli = __esm({
|
|
|
1673
1691
|
`
|
|
1674
1692
|
);
|
|
1675
1693
|
};
|
|
1676
|
-
cancel = (msg
|
|
1677
|
-
|
|
1678
|
-
|
|
1694
|
+
cancel = (msg, {
|
|
1695
|
+
// current default is backcompat and makes sense going forward too
|
|
1696
|
+
shape = shapes.corners.bl,
|
|
1697
|
+
// current default for backcompat -- TODO: change default to true once all callees have been updated
|
|
1698
|
+
multiline = false
|
|
1699
|
+
} = {}) => {
|
|
1700
|
+
logRaw(
|
|
1701
|
+
format(msg, {
|
|
1702
|
+
firstLinePrefix: `${gray(shape)} ${status.cancel}`,
|
|
1703
|
+
linePrefix: gray(shapes.bar),
|
|
1704
|
+
newlineBefore: true,
|
|
1705
|
+
formatLine: (line) => dim(line),
|
|
1706
|
+
// for backcompat but it's not ideal for this to be "dim"
|
|
1707
|
+
multiline
|
|
1708
|
+
})
|
|
1709
|
+
);
|
|
1679
1710
|
};
|
|
1680
|
-
warn = (msg
|
|
1681
|
-
|
|
1682
|
-
|
|
1711
|
+
warn = (msg, {
|
|
1712
|
+
// current default for backcompat -- TODO: change default to shapes.bar once all callees have been updated
|
|
1713
|
+
shape = shapes.corners.bl,
|
|
1714
|
+
// current default for backcompat -- TODO: change default to true once all callees have been updated
|
|
1715
|
+
multiline = false
|
|
1716
|
+
} = {}) => {
|
|
1717
|
+
logRaw(
|
|
1718
|
+
format(msg, {
|
|
1719
|
+
firstLinePrefix: gray(shape) + space() + status.warning,
|
|
1720
|
+
linePrefix: gray(shapes.bar),
|
|
1721
|
+
newlineBefore: true,
|
|
1722
|
+
formatLine: (line) => dim(line),
|
|
1723
|
+
// for backcompat but it's not ideal for this to be "dim"
|
|
1724
|
+
multiline
|
|
1725
|
+
})
|
|
1726
|
+
);
|
|
1683
1727
|
};
|
|
1684
1728
|
stripAnsi = (str) => {
|
|
1685
1729
|
const pattern = [
|
|
@@ -3554,18 +3598,18 @@ var init_interactive = __esm({
|
|
|
3554
3598
|
getTextRenderers = (config13) => {
|
|
3555
3599
|
const { question } = config13;
|
|
3556
3600
|
const helpText = config13.helpText ?? "";
|
|
3557
|
-
const
|
|
3601
|
+
const format5 = config13.format ?? ((val) => String(val));
|
|
3558
3602
|
const defaultValue = config13.defaultValue?.toString() ?? "";
|
|
3559
3603
|
return {
|
|
3560
3604
|
initial: () => [
|
|
3561
3605
|
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
3562
|
-
`${space(2)}${gray(
|
|
3606
|
+
`${space(2)}${gray(format5(defaultValue))}`,
|
|
3563
3607
|
``
|
|
3564
3608
|
// extra line for readability
|
|
3565
3609
|
],
|
|
3566
3610
|
active: ({ value }) => [
|
|
3567
3611
|
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
3568
|
-
`${space(2)}${
|
|
3612
|
+
`${space(2)}${format5(value || dim(defaultValue))}`,
|
|
3569
3613
|
``
|
|
3570
3614
|
// extra line for readability
|
|
3571
3615
|
],
|
|
@@ -3573,11 +3617,11 @@ var init_interactive = __esm({
|
|
|
3573
3617
|
`${leftT} ${status.error} ${dim(error2)}`,
|
|
3574
3618
|
`${grayBar}`,
|
|
3575
3619
|
`${blCorner} ${question} ${dim(helpText)}`,
|
|
3576
|
-
`${space(2)}${
|
|
3620
|
+
`${space(2)}${format5(value)}`,
|
|
3577
3621
|
``
|
|
3578
3622
|
// extra line for readability
|
|
3579
3623
|
],
|
|
3580
|
-
submit: ({ value }) => renderSubmit(config13,
|
|
3624
|
+
submit: ({ value }) => renderSubmit(config13, format5(value ?? "")),
|
|
3581
3625
|
cancel: handleCancel
|
|
3582
3626
|
};
|
|
3583
3627
|
};
|
|
@@ -3810,8 +3854,10 @@ ${grayBar} ${msg}`);
|
|
|
3810
3854
|
}
|
|
3811
3855
|
clearLoop();
|
|
3812
3856
|
} else {
|
|
3813
|
-
|
|
3857
|
+
if (msg !== void 0) {
|
|
3858
|
+
logUpdate2(`
|
|
3814
3859
|
${grayBar} ${msg}`);
|
|
3860
|
+
}
|
|
3815
3861
|
newline();
|
|
3816
3862
|
}
|
|
3817
3863
|
}
|
|
@@ -3851,7 +3897,7 @@ var init_args = __esm({
|
|
|
3851
3897
|
var version, devDependencies;
|
|
3852
3898
|
var init_package = __esm({
|
|
3853
3899
|
"package.json"() {
|
|
3854
|
-
version = "0.0.0-
|
|
3900
|
+
version = "0.0.0-63216f1e";
|
|
3855
3901
|
devDependencies = {
|
|
3856
3902
|
"@babel/parser": "^7.21.3",
|
|
3857
3903
|
"@babel/types": "^7.21.4",
|
|
@@ -3859,7 +3905,7 @@ var init_package = __esm({
|
|
|
3859
3905
|
"@cloudflare/cli": "workspace:*",
|
|
3860
3906
|
"@cloudflare/eslint-config-worker": "*",
|
|
3861
3907
|
"@cloudflare/workers-tsconfig": "workspace:*",
|
|
3862
|
-
"@cloudflare/workers-types": "^4.
|
|
3908
|
+
"@cloudflare/workers-types": "^4.20240320.1",
|
|
3863
3909
|
"@iarna/toml": "^3.0.0",
|
|
3864
3910
|
"@types/command-exists": "^1.2.0",
|
|
3865
3911
|
"@types/cross-spawn": "^6.0.2",
|
|
@@ -24556,19 +24602,19 @@ var init_package2 = __esm({
|
|
|
24556
24602
|
"additionally it also contains a map that maps frameworks to their respective clis"
|
|
24557
24603
|
],
|
|
24558
24604
|
dependencies: {
|
|
24559
|
-
"create-astro": "4.7.
|
|
24605
|
+
"create-astro": "4.7.4",
|
|
24560
24606
|
"@angular/create": "17.2.3",
|
|
24561
24607
|
"create-docusaurus": "3.1.1",
|
|
24562
24608
|
"create-hono": "0.5.0",
|
|
24563
24609
|
"create-next-app": "14.1.0",
|
|
24564
24610
|
"create-qwik": "1.4.5",
|
|
24565
24611
|
"create-react-app": "5.0.1",
|
|
24566
|
-
"create-remix": "2.8.
|
|
24567
|
-
"create-solid": "0.5.
|
|
24568
|
-
"create-svelte": "6.0.
|
|
24612
|
+
"create-remix": "2.8.1",
|
|
24613
|
+
"create-solid": "0.5.5",
|
|
24614
|
+
"create-svelte": "6.0.10",
|
|
24569
24615
|
"create-vue": "3.9.2",
|
|
24570
24616
|
gatsby: "5.13.3",
|
|
24571
|
-
nuxi: "3.
|
|
24617
|
+
nuxi: "3.11.1"
|
|
24572
24618
|
},
|
|
24573
24619
|
frameworkCliMap: {
|
|
24574
24620
|
angular: "@angular/create",
|
|
@@ -37936,12 +37982,12 @@ var require_index_688c5d50 = __commonJS({
|
|
|
37936
37982
|
args.unshift("%O");
|
|
37937
37983
|
}
|
|
37938
37984
|
let index = 0;
|
|
37939
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match2,
|
|
37985
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match2, format5) => {
|
|
37940
37986
|
if (match2 === "%%") {
|
|
37941
37987
|
return "%";
|
|
37942
37988
|
}
|
|
37943
37989
|
index++;
|
|
37944
|
-
const formatter = createDebug.formatters[
|
|
37990
|
+
const formatter = createDebug.formatters[format5];
|
|
37945
37991
|
if (typeof formatter === "function") {
|
|
37946
37992
|
const val = args[index];
|
|
37947
37993
|
match2 = formatter.call(self2, val);
|
|
@@ -70613,9 +70659,9 @@ var init_c32 = __esm({
|
|
|
70613
70659
|
n2.node.arguments = [
|
|
70614
70660
|
b2.objectExpression([
|
|
70615
70661
|
b2.objectProperty(
|
|
70616
|
-
b2.identifier("
|
|
70662
|
+
b2.identifier("platformProxy"),
|
|
70617
70663
|
b2.objectExpression([
|
|
70618
|
-
b2.objectProperty(b2.identifier("
|
|
70664
|
+
b2.objectProperty(b2.identifier("enabled"), b2.booleanLiteral(true))
|
|
70619
70665
|
])
|
|
70620
70666
|
)
|
|
70621
70667
|
])
|
|
@@ -70807,10 +70853,16 @@ var init_c36 = __esm({
|
|
|
70807
70853
|
generate6 = async (ctx) => {
|
|
70808
70854
|
const projectName = ctx.project.name;
|
|
70809
70855
|
await runFrameworkGenerator(ctx, [projectName]);
|
|
70810
|
-
|
|
70811
|
-
|
|
70812
|
-
|
|
70856
|
+
const wranglerToml = readFile((0, import_path13.join)(getTemplatePath(ctx), "wrangler.toml"));
|
|
70857
|
+
const newTomlContent = wranglerToml.replace(
|
|
70858
|
+
/#\s+\[\[kv_namespaces\]\]\n#\s+binding\s+=\s+"MY_KV_NAMESPACE"\n#\s+id\s+=\s+"[a-zA-Z0-9]+?"/,
|
|
70859
|
+
($1) => `# KV Example:
|
|
70860
|
+
${$1}`
|
|
70813
70861
|
);
|
|
70862
|
+
if (!/# KV Example/.test(newTomlContent)) {
|
|
70863
|
+
crash("Failed to properly generate the wrangler.toml file");
|
|
70864
|
+
}
|
|
70865
|
+
writeFile2((0, import_path13.join)(ctx.project.path, "wrangler.toml"), newTomlContent);
|
|
70814
70866
|
updateStatus("Created wrangler.toml file");
|
|
70815
70867
|
};
|
|
70816
70868
|
updateNextConfig = () => {
|
|
@@ -71260,7 +71312,7 @@ var init_c310 = __esm({
|
|
|
71260
71312
|
await runFrameworkGenerator(ctx, [
|
|
71261
71313
|
ctx.project.name,
|
|
71262
71314
|
"--template",
|
|
71263
|
-
"https://github.com/remix-run/remix/tree/main/templates/
|
|
71315
|
+
"https://github.com/remix-run/remix/tree/main/templates/cloudflare"
|
|
71264
71316
|
]);
|
|
71265
71317
|
logRaw("");
|
|
71266
71318
|
};
|
|
@@ -71846,7 +71898,7 @@ var init_templates = __esm({
|
|
|
71846
71898
|
"hello-world": (await Promise.resolve().then(() => (init_c314(), c3_exports14))).default,
|
|
71847
71899
|
"hello-world-durable-object": (await Promise.resolve().then(() => (init_c315(), c3_exports15))).default,
|
|
71848
71900
|
// Dummy record -- actual template config resolved in `selectFramework`
|
|
71849
|
-
|
|
71901
|
+
"web-framework": { displayName: "Website or web app" },
|
|
71850
71902
|
common: (await Promise.resolve().then(() => (init_c316(), c3_exports16))).default,
|
|
71851
71903
|
scheduled: (await Promise.resolve().then(() => (init_c317(), c3_exports17))).default,
|
|
71852
71904
|
queues: (await Promise.resolve().then(() => (init_c318(), c3_exports18))).default,
|
|
@@ -71861,13 +71913,19 @@ var init_templates = __esm({
|
|
|
71861
71913
|
selectTemplate = async (args) => {
|
|
71862
71914
|
if (!args.type) {
|
|
71863
71915
|
if (args.framework) {
|
|
71864
|
-
args.type = "
|
|
71916
|
+
args.type = "web-framework";
|
|
71865
71917
|
} else if (args.existingScript) {
|
|
71866
71918
|
args.type = "pre-existing";
|
|
71867
71919
|
} else if (args.template) {
|
|
71868
71920
|
args.type = "remote-template";
|
|
71869
71921
|
}
|
|
71870
71922
|
}
|
|
71923
|
+
if (args.type && args.type === "webFramework") {
|
|
71924
|
+
warn(
|
|
71925
|
+
"The `webFramework` type is deprecated and will be removed in a future version. Please use `web-framework` instead."
|
|
71926
|
+
);
|
|
71927
|
+
args.type = "web-framework";
|
|
71928
|
+
}
|
|
71871
71929
|
const templateMap = await getTemplateMap();
|
|
71872
71930
|
const templateOptions = Object.entries(templateMap).map(
|
|
71873
71931
|
([value, { displayName, hidden: hidden2 }]) => ({
|
|
@@ -71889,7 +71947,7 @@ var init_templates = __esm({
|
|
|
71889
71947
|
if (!Object.keys(templateMap).includes(type)) {
|
|
71890
71948
|
return crash(`Unknown application type provided: ${type}.`);
|
|
71891
71949
|
}
|
|
71892
|
-
if (type === "
|
|
71950
|
+
if (type === "web-framework") {
|
|
71893
71951
|
return selectFramework(args);
|
|
71894
71952
|
}
|
|
71895
71953
|
if (type === "remote-template") {
|
|
@@ -77095,7 +77153,7 @@ init_command();
|
|
|
77095
77153
|
init_packageManagers();
|
|
77096
77154
|
|
|
77097
77155
|
// ../wrangler/package.json
|
|
77098
|
-
var version2 = "3.
|
|
77156
|
+
var version2 = "3.41.0";
|
|
77099
77157
|
|
|
77100
77158
|
// src/git.ts
|
|
77101
77159
|
init_package();
|
|
@@ -79165,7 +79223,7 @@ var CharacterCodes;
|
|
|
79165
79223
|
})(CharacterCodes || (CharacterCodes = {}));
|
|
79166
79224
|
|
|
79167
79225
|
// ../../node_modules/.pnpm/jsonc-parser@3.2.0/node_modules/jsonc-parser/lib/esm/impl/format.js
|
|
79168
|
-
function
|
|
79226
|
+
function format4(documentText, range, options) {
|
|
79169
79227
|
let initialIndentLevel;
|
|
79170
79228
|
let formatText;
|
|
79171
79229
|
let formatTextStart;
|
|
@@ -79966,7 +80024,7 @@ function withFormatting(text, edit, options) {
|
|
|
79966
80024
|
end++;
|
|
79967
80025
|
}
|
|
79968
80026
|
}
|
|
79969
|
-
const edits =
|
|
80027
|
+
const edits = format4(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
|
|
79970
80028
|
for (let i = edits.length - 1; i >= 0; i--) {
|
|
79971
80029
|
const edit2 = edits[i];
|
|
79972
80030
|
newText = applyEdit(newText, edit2);
|
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-63216f1e",
|
|
4
4
|
"description": "A CLI for creating and deploying new applications to Cloudflare.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@babel/types": "^7.21.4",
|
|
31
31
|
"@clack/prompts": "^0.6.3",
|
|
32
32
|
"@cloudflare/eslint-config-worker": "*",
|
|
33
|
-
"@cloudflare/workers-types": "^4.
|
|
33
|
+
"@cloudflare/workers-types": "^4.20240320.1",
|
|
34
34
|
"@iarna/toml": "^3.0.0",
|
|
35
35
|
"@types/command-exists": "^1.2.0",
|
|
36
36
|
"@types/cross-spawn": "^6.0.2",
|
|
@@ -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",
|
|
69
70
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
70
|
-
"wrangler": "3.
|
|
71
|
-
"@cloudflare/cli": "1.1.1"
|
|
71
|
+
"wrangler": "3.41.0"
|
|
72
72
|
},
|
|
73
73
|
"engines": {
|
|
74
74
|
"node": ">=18.14.1"
|
package/templates/astro/c3.ts
CHANGED
|
@@ -46,9 +46,9 @@ const updateAstroConfig = () => {
|
|
|
46
46
|
n.node.arguments = [
|
|
47
47
|
b.objectExpression([
|
|
48
48
|
b.objectProperty(
|
|
49
|
-
b.identifier("
|
|
49
|
+
b.identifier("platformProxy"),
|
|
50
50
|
b.objectExpression([
|
|
51
|
-
b.objectProperty(b.identifier("
|
|
51
|
+
b.objectProperty(b.identifier("enabled"), b.booleanLiteral(true)),
|
|
52
52
|
])
|
|
53
53
|
),
|
|
54
54
|
]),
|
package/templates/next/README.md
CHANGED
|
@@ -65,4 +65,4 @@ In order to enable the example:
|
|
|
65
65
|
|
|
66
66
|
After doing this you can run the `dev` or `preview` script and visit the `/api/hello` route to see the example in action.
|
|
67
67
|
|
|
68
|
-
Finally, if you also want to see the example work in the deployed application make sure to add a `
|
|
68
|
+
Finally, if you also want to see the example work in the deployed application make sure to add a `MY_KV_NAMESPACE` binding to your Pages application in its [dashboard kv bindings settings section](https://dash.cloudflare.com/?to=/:account/pages/view/:pages-project/settings/functions#kv_namespace_bindings_section). After having configured it make sure to re-deploy your application.
|
|
@@ -12,7 +12,7 @@ export async function GET(request) {
|
|
|
12
12
|
// )
|
|
13
13
|
//
|
|
14
14
|
// KV Example:
|
|
15
|
-
// const myKv = getRequestContext().env.
|
|
15
|
+
// const myKv = getRequestContext().env.MY_KV_NAMESPACE
|
|
16
16
|
// await myKv.put('suffix', ' from a KV store!')
|
|
17
17
|
// const suffix = await myKv.get('suffix')
|
|
18
18
|
// responseText += suffix
|
|
@@ -13,7 +13,7 @@ export async function GET(request: NextRequest) {
|
|
|
13
13
|
// )
|
|
14
14
|
//
|
|
15
15
|
// KV Example:
|
|
16
|
-
// const myKv = getRequestContext().env.
|
|
16
|
+
// const myKv = getRequestContext().env.MY_KV_NAMESPACE
|
|
17
17
|
// await myKv.put('suffix', ' from a KV store!')
|
|
18
18
|
// const suffix = await myKv.get('suffix')
|
|
19
19
|
// responseText += suffix
|
package/templates/next/c3.ts
CHANGED
|
@@ -27,10 +27,26 @@ const generate = async (ctx: C3Context) => {
|
|
|
27
27
|
|
|
28
28
|
await runFrameworkGenerator(ctx, [projectName]);
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const wranglerToml = readFile(join(getTemplatePath(ctx), "wrangler.toml"));
|
|
31
|
+
|
|
32
|
+
// Note: here we add `# KV Example:` to the toml file for the KV example, we don't actually
|
|
33
|
+
// include the comment in the template wrangler.toml file just so to keep it identical
|
|
34
|
+
// and consistent with that of all the other frameworks
|
|
35
|
+
// (instead of making it a special case which needs extra care)
|
|
36
|
+
const newTomlContent = wranglerToml.replace(
|
|
37
|
+
/#\s+\[\[kv_namespaces\]\]\n#\s+binding\s+=\s+"MY_KV_NAMESPACE"\n#\s+id\s+=\s+"[a-zA-Z0-9]+?"/,
|
|
38
|
+
($1) => `# KV Example:\n${$1}`
|
|
33
39
|
);
|
|
40
|
+
|
|
41
|
+
if (!/# KV Example/.test(newTomlContent)) {
|
|
42
|
+
// This should never happen to users, it is a check mostly so that
|
|
43
|
+
// if the toml file is changed in a way that breaks the "KV Example" addition
|
|
44
|
+
// the C3 Next.js e2e runs will fail with this
|
|
45
|
+
crash("Failed to properly generate the wrangler.toml file");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
writeFile(join(ctx.project.path, "wrangler.toml"), newTomlContent);
|
|
49
|
+
|
|
34
50
|
updateStatus("Created wrangler.toml file");
|
|
35
51
|
};
|
|
36
52
|
|
|
@@ -14,7 +14,7 @@ export default async function handler(req) {
|
|
|
14
14
|
// )
|
|
15
15
|
//
|
|
16
16
|
// KV Example:
|
|
17
|
-
// const myKv = getRequestContext().env.
|
|
17
|
+
// const myKv = getRequestContext().env.MY_KV_NAMESPACE
|
|
18
18
|
// await myKv.put('suffix', ' from a KV store!')
|
|
19
19
|
// const suffix = await myKv.get('suffix')
|
|
20
20
|
// responseText += suffix
|
|
@@ -15,7 +15,7 @@ export default async function handler(req: NextRequest) {
|
|
|
15
15
|
// )
|
|
16
16
|
//
|
|
17
17
|
// KV Example:
|
|
18
|
-
// const myKv = getRequestContext().env.
|
|
18
|
+
// const myKv = getRequestContext().env.MY_KV_NAMESPACE
|
|
19
19
|
// await myKv.put('suffix', ' from a KV store!')
|
|
20
20
|
// const suffix = await myKv.get('suffix')
|
|
21
21
|
// responseText += suffix
|
package/templates/remix/c3.ts
CHANGED
|
@@ -13,7 +13,7 @@ const generate = async (ctx: C3Context) => {
|
|
|
13
13
|
await runFrameworkGenerator(ctx, [
|
|
14
14
|
ctx.project.name,
|
|
15
15
|
"--template",
|
|
16
|
-
"https://github.com/remix-run/remix/tree/main/templates/
|
|
16
|
+
"https://github.com/remix-run/remix/tree/main/templates/cloudflare",
|
|
17
17
|
]);
|
|
18
18
|
|
|
19
19
|
logRaw(""); // newline
|