create-cloudflare 0.0.0-fa09f4a2 → 0.0.0-fa91ff54

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.
Files changed (39) hide show
  1. package/dist/cli.js +71470 -58676
  2. package/package.json +10 -7
  3. package/templates/angular/c3.ts +100 -0
  4. package/{dist → templates}/angular/templates/tools/copy-files.mjs +1 -1
  5. package/templates/astro/c3.ts +50 -0
  6. package/templates/chatgptPlugin/c3.ts +9 -0
  7. package/templates/common/c3.ts +14 -0
  8. package/templates/docusaurus/c3.ts +27 -0
  9. package/templates/gatsby/c3.ts +46 -0
  10. package/templates/hello-world/c3.ts +14 -0
  11. package/templates/hello-world-durable-object/c3.ts +14 -0
  12. package/templates/hono/c3.ts +25 -0
  13. package/templates/next/c3.ts +212 -0
  14. package/templates/next/templates.ts +281 -0
  15. package/templates/nuxt/c3.ts +59 -0
  16. package/templates/openapi/c3.ts +9 -0
  17. package/templates/openapi/ts/src/endpoints/taskList.ts +1 -1
  18. package/templates/openapi/ts/src/index.ts +2 -2
  19. package/templates/pre-existing/c3.ts +84 -0
  20. package/templates/pre-existing/js/.editorconfig +13 -0
  21. package/templates/pre-existing/js/.prettierrc +6 -0
  22. package/templates/pre-existing/js/__dot__gitignore +172 -0
  23. package/templates/pre-existing/js/package.json +13 -0
  24. package/templates/pre-existing/js/wrangler.toml +3 -0
  25. package/templates/queues/c3.ts +24 -0
  26. package/templates/qwik/c3.ts +36 -0
  27. package/templates/react/c3.ts +29 -0
  28. package/templates/remix/c3.ts +33 -0
  29. package/templates/scheduled/c3.ts +14 -0
  30. package/templates/solid/c3.ts +37 -0
  31. package/templates/solid/js/vite.config.js +12 -0
  32. package/templates/solid/ts/vite.config.ts +12 -0
  33. package/templates/svelte/c3.ts +75 -0
  34. package/templates/svelte/templates.ts +13 -0
  35. package/templates/vue/c3.ts +27 -0
  36. package/{dist → templates}/angular/templates/server.ts +0 -0
  37. package/{dist → templates}/angular/templates/src/_routes.json +0 -0
  38. package/{dist → templates}/angular/templates/tools/alter-polyfills.mjs +1 -1
  39. /package/{dist → templates}/angular/templates/tools/paths.mjs +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "0.0.0-fa09f4a2",
3
+ "version": "0.0.0-fa91ff54",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -34,11 +34,12 @@
34
34
  "@iarna/toml": "^3.0.0",
35
35
  "@types/command-exists": "^1.2.0",
36
36
  "@types/cross-spawn": "^6.0.2",
37
+ "@types/deepmerge": "^2.2.0",
38
+ "@types/degit": "^2.8.6",
37
39
  "@types/dns2": "^2.0.3",
38
40
  "@types/esprima": "^4.0.3",
39
41
  "@types/node": "^18.15.3",
40
42
  "@types/semver": "^7.5.1",
41
- "@types/shell-quote": "^1.7.2",
42
43
  "@types/which-pm-runs": "^1.0.0",
43
44
  "@types/yargs": "^17.0.22",
44
45
  "@typescript-eslint/eslint-plugin": "^5.55.0",
@@ -46,25 +47,27 @@
46
47
  "chalk": "^5.2.0",
47
48
  "command-exists": "^1.2.9",
48
49
  "cross-spawn": "^7.0.3",
50
+ "deepmerge": "^4.3.1",
51
+ "degit": "^2.8.4",
49
52
  "dns2": "^2.1.0",
50
53
  "esbuild": "^0.17.12",
51
54
  "execa": "^7.1.1",
52
55
  "glob": "^10.3.3",
53
56
  "haikunator": "^2.1.2",
57
+ "magic-string": "^0.30.5",
54
58
  "open": "^8.4.0",
55
59
  "pnpm": "^8.10.0",
56
60
  "recast": "^0.22.0",
57
61
  "semver": "^7.5.1",
58
- "shell-quote": "^1.8.1",
59
62
  "typescript": "^5.0.2",
60
- "undici": "5.20.0",
63
+ "undici": "5.28.2",
61
64
  "vite-tsconfig-paths": "^4.0.8",
62
65
  "which-pm-runs": "^1.1.0",
63
66
  "yargs": "^17.7.1",
64
67
  "yarn": "^1.22.19",
65
- "wrangler": "3.23.0",
66
- "@cloudflare/cli": "1.1.0",
67
- "@cloudflare/workers-tsconfig": "0.0.0"
68
+ "wrangler": "3.24.0",
69
+ "@cloudflare/workers-tsconfig": "0.0.0",
70
+ "@cloudflare/cli": "1.1.1"
68
71
  },
69
72
  "engines": {
70
73
  "node": ">=18.14.1"
@@ -0,0 +1,100 @@
1
+ import { cp } from "node:fs/promises";
2
+ import { resolve } from "node:path";
3
+ import { logRaw } from "@cloudflare/cli";
4
+ import { brandColor, dim } from "@cloudflare/cli/colors";
5
+ import { spinner } from "@cloudflare/cli/interactive";
6
+ import { installPackages, runFrameworkGenerator } from "helpers/command";
7
+ import { compatDateFlag, readFile, readJSON, writeFile } from "helpers/files";
8
+ import { detectPackageManager } from "helpers/packages";
9
+ import type { TemplateConfig } from "../../src/templates";
10
+ import type { C3Context } from "types";
11
+
12
+ const { npm } = detectPackageManager();
13
+
14
+ const generate = async (ctx: C3Context) => {
15
+ await runFrameworkGenerator(ctx, [ctx.project.name, "--ssr"]);
16
+ logRaw("");
17
+ };
18
+
19
+ const configure = async (ctx: C3Context) => {
20
+ updateAngularJson(ctx);
21
+ await updateAppCode();
22
+ await installCFWorker(ctx);
23
+ };
24
+
25
+ async function installCFWorker(ctx: C3Context) {
26
+ await installPackages(
27
+ ["@cloudflare/workers-types", "@miniflare/tre@next", "wrangler@beta"],
28
+ {
29
+ dev: true,
30
+ startText: "Installing adapter dependencies",
31
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
32
+ }
33
+ );
34
+ }
35
+ async function updateAppCode() {
36
+ const s = spinner();
37
+ s.start(`Updating application code`);
38
+
39
+ // Update an app config file to:
40
+ // - add the `provideHttpClient(withFetch())` call to enable `fetch` usage in `HttpClient`
41
+ const appConfigPath = "src/app/app.config.ts";
42
+ const appConfig = readFile(resolve(appConfigPath));
43
+ const newAppConfig =
44
+ "import { provideHttpClient, withFetch } from '@angular/common/http';\n" +
45
+ appConfig.replace(
46
+ "providers: [",
47
+ "providers: [provideHttpClient(withFetch()), "
48
+ );
49
+ writeFile(resolve(appConfigPath), newAppConfig);
50
+ s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
51
+
52
+ // Remove unwanted dependencies
53
+ s.start(`Updating package.json`);
54
+ const packageJsonPath = resolve("package.json");
55
+ const packageManifest = readJSON(packageJsonPath);
56
+
57
+ delete packageManifest["dependencies"]["@angular/ssr"];
58
+ delete packageManifest["dependencies"]["express"];
59
+
60
+ writeFile(packageJsonPath, JSON.stringify(packageManifest, null, 2));
61
+ s.stop(`${brandColor(`updated`)} ${dim(`\`package.json\``)}`);
62
+ }
63
+
64
+ function updateAngularJson(ctx: C3Context) {
65
+ const s = spinner();
66
+ s.start(`Updating angular.json config`);
67
+ const angularJson = readJSON(resolve("angular.json"));
68
+ // Update builder
69
+ const architectSection = angularJson.projects[ctx.project.name].architect;
70
+ architectSection.build.options.outputPath = "dist";
71
+ architectSection.build.options.assets.push("src/_routes.json");
72
+
73
+ writeFile(resolve("angular.json"), JSON.stringify(angularJson, null, 2));
74
+ s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
75
+ }
76
+
77
+ const config: TemplateConfig = {
78
+ configVersion: 1,
79
+ id: "angular",
80
+ displayName: "Angular",
81
+ platform: "pages",
82
+ copyFiles: {
83
+ path: "./templates",
84
+ },
85
+ generate,
86
+ configure,
87
+ transformPackageJson: async () => ({
88
+ scripts: {
89
+ start: `${npm} run pages:build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
90
+ process:
91
+ "node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
92
+ "pages:build": `ng build && ${npm} run process`,
93
+ deploy: `${npm} run pages:build && wrangler pages deploy dist/cloudflare`,
94
+ },
95
+ }),
96
+ deployScript: "deploy",
97
+ devScript: "start",
98
+ testFlags: ["--style", "sass"],
99
+ };
100
+ export default config;
@@ -1,7 +1,7 @@
1
1
  // Copy the files over so that they can be uploaded by the pages publish command.
2
2
  import fs from "node:fs";
3
3
  import { join } from "node:path";
4
- import { client, cloudflare, worker, ssr } from "./paths.mjs";
4
+ import { client, cloudflare, ssr, worker } from "./paths.mjs";
5
5
 
6
6
  fs.cpSync(client, cloudflare, { recursive: true });
7
7
  fs.cpSync(ssr, worker, { recursive: true });
@@ -0,0 +1,50 @@
1
+ import { logRaw } from "@cloudflare/cli";
2
+ import { brandColor, dim } from "@cloudflare/cli/colors";
3
+ import { runCommand, runFrameworkGenerator } from "helpers/command";
4
+ import { compatDateFlag } from "helpers/files";
5
+ import { detectPackageManager } from "helpers/packages";
6
+ import type { TemplateConfig } from "../../src/templates";
7
+ import type { C3Context } from "types";
8
+
9
+ const { npx } = detectPackageManager();
10
+
11
+ const generate = async (ctx: C3Context) => {
12
+ await runFrameworkGenerator(ctx, [ctx.project.name, "--no-install"]);
13
+
14
+ logRaw(""); // newline
15
+ };
16
+
17
+ const configure = async (ctx: C3Context) => {
18
+ await runCommand([npx, "astro", "add", "cloudflare", "-y"], {
19
+ silent: true,
20
+ startText: "Installing adapter",
21
+ doneText: `${brandColor("installed")} ${dim(
22
+ `via \`${npx} astro add cloudflare\``
23
+ )}`,
24
+ });
25
+ };
26
+
27
+ const config: TemplateConfig = {
28
+ configVersion: 1,
29
+ id: "astro",
30
+ platform: "pages",
31
+ displayName: "Astro",
32
+ generate,
33
+ configure,
34
+ transformPackageJson: async () => ({
35
+ scripts: {
36
+ "pages:dev": `wrangler pages dev ${await compatDateFlag()} -- astro dev`,
37
+ "pages:deploy": `astro build && wrangler pages deploy ./dist`,
38
+ },
39
+ }),
40
+ testFlags: [
41
+ "--skip-houston",
42
+ "--no-install",
43
+ "--no-git",
44
+ "--template",
45
+ "blog",
46
+ "--typescript",
47
+ "strict",
48
+ ],
49
+ };
50
+ export default config;
@@ -0,0 +1,9 @@
1
+ export default {
2
+ configVersion: 1,
3
+ id: "chatgptPlugin",
4
+ displayName: "ChatGPT plugin",
5
+ platform: "workers",
6
+ copyFiles: {
7
+ path: "./ts",
8
+ },
9
+ };
@@ -0,0 +1,14 @@
1
+ export default {
2
+ configVersion: 1,
3
+ id: "common",
4
+ displayName: "Example router & proxy Worker",
5
+ platform: "workers",
6
+ copyFiles: {
7
+ js: {
8
+ path: "./js",
9
+ },
10
+ ts: {
11
+ path: "./ts",
12
+ },
13
+ },
14
+ };
@@ -0,0 +1,27 @@
1
+ import { runFrameworkGenerator } from "helpers/command";
2
+ import { compatDateFlag } from "helpers/files";
3
+ import { detectPackageManager } from "helpers/packages";
4
+ import type { TemplateConfig } from "../../src/templates";
5
+ import type { C3Context } from "types";
6
+
7
+ const { npm } = detectPackageManager();
8
+
9
+ const generate = async (ctx: C3Context) => {
10
+ await runFrameworkGenerator(ctx, [ctx.project.name, "classic"]);
11
+ };
12
+
13
+ const config: TemplateConfig = {
14
+ configVersion: 1,
15
+ id: "docusaurus",
16
+ platform: "pages",
17
+ displayName: "Docusaurus",
18
+ generate,
19
+ transformPackageJson: async () => ({
20
+ scripts: {
21
+ "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 3000 -- ${npm} run start`,
22
+ "pages:deploy": `${npm} run build && wrangler pages deploy ./build`,
23
+ },
24
+ }),
25
+ testFlags: [`--package-manager`, npm],
26
+ };
27
+ export default config;
@@ -0,0 +1,46 @@
1
+ import { inputPrompt } from "@cloudflare/cli/interactive";
2
+ import { runFrameworkGenerator } from "helpers/command";
3
+ import { compatDateFlag } from "helpers/files";
4
+ import { detectPackageManager } from "helpers/packages";
5
+ import type { TemplateConfig } from "../../src/templates";
6
+ import type { C3Context } from "types";
7
+
8
+ const { npm } = detectPackageManager();
9
+
10
+ const generate = async (ctx: C3Context) => {
11
+ const defaultTemplate = "https://github.com/gatsbyjs/gatsby-starter-blog";
12
+
13
+ const useTemplate = await inputPrompt({
14
+ type: "confirm",
15
+ question: "Would you like to use a template?",
16
+ label: "template",
17
+ defaultValue: true,
18
+ });
19
+
20
+ let templateUrl = "";
21
+ if (useTemplate) {
22
+ templateUrl = await inputPrompt({
23
+ type: "text",
24
+ question: `Please specify the url of the template you'd like to use`,
25
+ label: "template",
26
+ defaultValue: defaultTemplate,
27
+ });
28
+ }
29
+
30
+ await runFrameworkGenerator(ctx, ["new", ctx.project.name, templateUrl]);
31
+ };
32
+
33
+ const config: TemplateConfig = {
34
+ configVersion: 1,
35
+ id: "gatsby",
36
+ platform: "pages",
37
+ displayName: "Gatsby",
38
+ generate,
39
+ transformPackageJson: async () => ({
40
+ scripts: {
41
+ "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 8000 -- ${npm} run develop`,
42
+ "pages:deploy": `${npm} run build && wrangler pages deploy ./public`,
43
+ },
44
+ }),
45
+ };
46
+ export default config;
@@ -0,0 +1,14 @@
1
+ export default {
2
+ configVersion: 1,
3
+ id: "hello-world",
4
+ displayName: '"Hello World" Worker',
5
+ platform: "workers",
6
+ copyFiles: {
7
+ js: {
8
+ path: "./js",
9
+ },
10
+ ts: {
11
+ path: "./ts",
12
+ },
13
+ },
14
+ };
@@ -0,0 +1,14 @@
1
+ export default {
2
+ configVersion: 1,
3
+ id: "hello-world-durable-object",
4
+ displayName: '"Hello World" Durable Object',
5
+ platform: "workers",
6
+ copyFiles: {
7
+ js: {
8
+ path: "./js",
9
+ },
10
+ ts: {
11
+ path: "./ts",
12
+ },
13
+ },
14
+ };
@@ -0,0 +1,25 @@
1
+ import { logRaw } from "@cloudflare/cli";
2
+ import { runFrameworkGenerator } from "helpers/command";
3
+ import type { TemplateConfig } from "../../src/templates";
4
+ import type { C3Context } from "types";
5
+
6
+ const generate = async (ctx: C3Context) => {
7
+ await runFrameworkGenerator(ctx, [
8
+ ctx.project.name,
9
+ "--template",
10
+ "cloudflare-workers",
11
+ ]);
12
+
13
+ logRaw(""); // newline
14
+ };
15
+
16
+ const config: TemplateConfig = {
17
+ configVersion: 1,
18
+ id: "hono",
19
+ displayName: "Hono",
20
+ platform: "workers",
21
+ generate,
22
+ devScript: "dev",
23
+ deployScript: "deploy",
24
+ };
25
+ export default config;
@@ -0,0 +1,212 @@
1
+ import { existsSync, mkdirSync } from "fs";
2
+ import { crash, updateStatus, warn } from "@cloudflare/cli";
3
+ import { processArgument } from "@cloudflare/cli/args";
4
+ import { brandColor, dim } from "@cloudflare/cli/colors";
5
+ import { installPackages, runFrameworkGenerator } from "helpers/command";
6
+ import {
7
+ compatDateFlag,
8
+ probePaths,
9
+ readJSON,
10
+ usesEslint,
11
+ usesTypescript,
12
+ writeFile,
13
+ writeJSON,
14
+ } from "helpers/files";
15
+ import { detectPackageManager } from "helpers/packages";
16
+ import {
17
+ apiAppDirHelloJs,
18
+ apiAppDirHelloTs,
19
+ apiPagesDirHelloJs,
20
+ apiPagesDirHelloTs,
21
+ appDirNotFoundJs,
22
+ appDirNotFoundTs,
23
+ envDts,
24
+ nextConfig,
25
+ readme,
26
+ } from "./templates";
27
+ import type { TemplateConfig } from "../../src/templates";
28
+ import type { C3Args, C3Context } from "types";
29
+
30
+ const { npm, npx } = detectPackageManager();
31
+
32
+ const generate = async (ctx: C3Context) => {
33
+ const projectName = ctx.project.name;
34
+
35
+ await runFrameworkGenerator(ctx, [projectName]);
36
+ };
37
+
38
+ const getApiTemplate = (
39
+ apiPath: string,
40
+ isTypescript: boolean
41
+ ): [string, string] => {
42
+ const isAppDir = /\/app\/api$/.test(apiPath);
43
+
44
+ if (isAppDir) {
45
+ // App directory uses route handlers that are defined in a subdirectory (`/api/hello/route.ts`).
46
+ const routeHandlerPath = `${apiPath}/hello`;
47
+ mkdirSync(routeHandlerPath, { recursive: true });
48
+
49
+ return isTypescript
50
+ ? [`${routeHandlerPath}/route.ts`, apiAppDirHelloTs]
51
+ : [`${routeHandlerPath}/route.js`, apiAppDirHelloJs];
52
+ }
53
+
54
+ return isTypescript
55
+ ? [`${apiPath}/hello.ts`, apiPagesDirHelloTs]
56
+ : [`${apiPath}/hello.js`, apiPagesDirHelloJs];
57
+ };
58
+
59
+ const configure = async (ctx: C3Context) => {
60
+ const projectPath = ctx.project.path;
61
+
62
+ // Add a compatible function handler example
63
+ const path = probePaths([
64
+ `${projectPath}/pages/api`,
65
+ `${projectPath}/src/pages/api`,
66
+ `${projectPath}/src/app/api`,
67
+ `${projectPath}/app/api`,
68
+ `${projectPath}/src/app`,
69
+ `${projectPath}/app`,
70
+ ]);
71
+
72
+ if (!path) {
73
+ crash("Could not find the `/api` or `/app` directory");
74
+ }
75
+
76
+ // App directory template may not generate an API route handler, so we update the path to add an `api` directory.
77
+ const apiPath = path.replace(/\/app$/, "/app/api");
78
+
79
+ const usesTs = usesTypescript(ctx);
80
+
81
+ const appDirPath = probePaths([
82
+ `${projectPath}/src/app`,
83
+ `${projectPath}/app`,
84
+ ]);
85
+
86
+ if (appDirPath) {
87
+ // Add a custom app not-found edge route as recommended in next-on-pages
88
+ // (see: https://github.com/cloudflare/next-on-pages/blob/2b5c8f25/packages/next-on-pages/docs/gotchas.md#not-found)
89
+ const notFoundPath = `${appDirPath}/not-found.${usesTs ? "tsx" : "js"}`;
90
+ if (!existsSync(notFoundPath)) {
91
+ const notFoundContent = usesTs ? appDirNotFoundTs : appDirNotFoundJs;
92
+ writeFile(notFoundPath, notFoundContent);
93
+ updateStatus("Created a custom edge not-found route");
94
+ }
95
+ }
96
+
97
+ const [handlerPath, handlerFile] = getApiTemplate(
98
+ apiPath,
99
+ usesTypescript(ctx)
100
+ );
101
+ writeFile(handlerPath, handlerFile);
102
+ updateStatus("Created an example API route handler");
103
+
104
+ if (usesTs) {
105
+ writeFile(`${projectPath}/env.d.ts`, envDts);
106
+ updateStatus("Created an env.d.ts file");
107
+ }
108
+
109
+ const installEslintPlugin = await shouldInstallNextOnPagesEslintPlugin(ctx);
110
+
111
+ if (installEslintPlugin) {
112
+ await writeEslintrc(ctx);
113
+ }
114
+
115
+ writeFile(`${projectPath}/next.config.js`, nextConfig);
116
+ updateStatus("Updated the next.config.js file");
117
+
118
+ writeFile(`${projectPath}/README.md`, readme);
119
+ updateStatus("Updated the README file");
120
+
121
+ await addDevDependencies(installEslintPlugin);
122
+ };
123
+
124
+ export const shouldInstallNextOnPagesEslintPlugin = async (
125
+ ctx: C3Context
126
+ ): Promise<boolean> => {
127
+ const eslintUsage = usesEslint(ctx);
128
+
129
+ if (!eslintUsage.used) return false;
130
+
131
+ if (eslintUsage.configType !== ".eslintrc.json") {
132
+ warn(
133
+ `Expected .eslintrc.json from Next.js scaffolding but found ${eslintUsage.configType} instead`
134
+ );
135
+ return false;
136
+ }
137
+
138
+ return await processArgument(ctx.args, "eslint-plugin" as keyof C3Args, {
139
+ type: "confirm",
140
+ question: "Do you want to use the next-on-pages eslint-plugin?",
141
+ label: "eslint-plugin",
142
+ defaultValue: true,
143
+ });
144
+ };
145
+
146
+ export const writeEslintrc = async (ctx: C3Context): Promise<void> => {
147
+ const eslintConfig = readJSON(`${ctx.project.path}/.eslintrc.json`);
148
+
149
+ eslintConfig.plugins ??= [];
150
+ eslintConfig.plugins.push("eslint-plugin-next-on-pages");
151
+
152
+ if (typeof eslintConfig.extends === "string") {
153
+ eslintConfig.extends = [eslintConfig.extends];
154
+ }
155
+ eslintConfig.extends ??= [];
156
+ eslintConfig.extends.push("plugin:eslint-plugin-next-on-pages/recommended");
157
+
158
+ writeJSON(`${ctx.project.path}/.eslintrc.json`, eslintConfig);
159
+ };
160
+
161
+ const addDevDependencies = async (installEslintPlugin: boolean) => {
162
+ const packages = [
163
+ "@cloudflare/next-on-pages@1",
164
+ "@cloudflare/workers-types",
165
+ "vercel",
166
+ ...(installEslintPlugin ? ["eslint-plugin-next-on-pages"] : []),
167
+ ];
168
+ await installPackages(packages, {
169
+ dev: true,
170
+ startText: "Adding the Cloudflare Pages adapter",
171
+ doneText: `${brandColor(`installed`)} ${dim(packages.join(", "))}`,
172
+ });
173
+ };
174
+
175
+ export default {
176
+ configVersion: 1,
177
+ id: "next",
178
+ platform: "pages",
179
+ displayName: "Next",
180
+ devScript: "dev",
181
+ generate,
182
+ configure,
183
+ transformPackageJson: async () => {
184
+ const isNpm = npm === "npm";
185
+ const isBun = npm === "bun";
186
+ const isNpmOrBun = isNpm || isBun;
187
+ const nextOnPagesScope = isNpmOrBun ? "@cloudflare/" : "";
188
+ const nextOnPagesCommand = `${nextOnPagesScope}next-on-pages`;
189
+ const pmCommand = isNpmOrBun ? npx : npm;
190
+ const pagesBuildRunCommand = `${
191
+ isNpm ? "npm run" : isBun ? "bun" : pmCommand
192
+ } pages:build`;
193
+ return {
194
+ scripts: {
195
+ "pages:build": `${pmCommand} ${nextOnPagesCommand}`,
196
+ "pages:preview": `${pagesBuildRunCommand} && wrangler pages dev .vercel/output/static ${await compatDateFlag()} --compatibility-flag=nodejs_compat`,
197
+ "pages:deploy": `${pagesBuildRunCommand} && wrangler pages deploy .vercel/output/static`,
198
+ },
199
+ };
200
+ },
201
+ testFlags: [
202
+ "--typescript",
203
+ "--no-install",
204
+ "--eslint",
205
+ "--tailwind",
206
+ "--src-dir",
207
+ "--app",
208
+ "--import-alias",
209
+ "@/*",
210
+ ],
211
+ compatibilityFlags: ["nodejs_compat"],
212
+ } as TemplateConfig;