create-cloudflare 0.0.0-b92e5ac0 → 0.0.0-b9b34ce0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "0.0.0-b92e5ac0",
3
+ "version": "0.0.0-b9b34ce0",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -66,8 +66,8 @@
66
66
  "yargs": "^17.7.1",
67
67
  "yarn": "^1.22.19",
68
68
  "@cloudflare/cli": "1.1.1",
69
- "@cloudflare/workers-tsconfig": "0.0.0",
70
- "wrangler": "3.25.0"
69
+ "wrangler": "3.28.2",
70
+ "@cloudflare/workers-tsconfig": "0.0.0"
71
71
  },
72
72
  "engines": {
73
73
  "node": ">=18.14.1"
@@ -4,11 +4,13 @@ export default {
4
4
  displayName: "Example router & proxy Worker",
5
5
  platform: "workers",
6
6
  copyFiles: {
7
- js: {
8
- path: "./js",
9
- },
10
- ts: {
11
- path: "./ts",
7
+ variants: {
8
+ js: {
9
+ path: "./js",
10
+ },
11
+ ts: {
12
+ path: "./ts",
13
+ },
12
14
  },
13
15
  },
14
16
  };
@@ -4,11 +4,13 @@ export default {
4
4
  displayName: '"Hello World" Worker',
5
5
  platform: "workers",
6
6
  copyFiles: {
7
- js: {
8
- path: "./js",
9
- },
10
- ts: {
11
- path: "./ts",
7
+ variants: {
8
+ js: {
9
+ path: "./js",
10
+ },
11
+ ts: {
12
+ path: "./ts",
13
+ },
12
14
  },
13
15
  },
14
16
  };
@@ -4,11 +4,13 @@ export default {
4
4
  displayName: '"Hello World" Durable Object',
5
5
  platform: "workers",
6
6
  copyFiles: {
7
- js: {
8
- path: "./js",
9
- },
10
- ts: {
11
- path: "./ts",
7
+ variants: {
8
+ js: {
9
+ path: "./js",
10
+ },
11
+ ts: {
12
+ path: "./ts",
13
+ },
12
14
  },
13
15
  },
14
16
  };
@@ -0,0 +1,57 @@
1
+ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`c3`](https://developers.cloudflare.com/pages/get-started/c3).
2
+
3
+ ## Getting Started
4
+
5
+ First, run the development server:
6
+
7
+ ```bash
8
+ npm run dev
9
+ # or
10
+ yarn dev
11
+ # or
12
+ pnpm dev
13
+ # or
14
+ bun dev
15
+ ```
16
+
17
+ Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18
+
19
+ ## Cloudflare integration
20
+
21
+ Besides the `dev` script mentioned above `c3` has added a few extra scripts that allow you to integrate the application with the [Cloudflare Pages](https://pages.cloudflare.com/) environment, these are:
22
+ - `pages:build` to build the application for Pages using the [`@cloudflare/next-on-pages`](https://github.com/cloudflare/next-on-pages) CLI
23
+ - `pages:preview` to locally preview your Pages application using the [Wrangler](https://developers.cloudflare.com/workers/wrangler/) CLI
24
+ - `pages:deploy` to deploy your Pages application using the [Wrangler](https://developers.cloudflare.com/workers/wrangler/) CLI
25
+
26
+ > __Note:__ while the `dev` script is optimal for local development you should preview your Pages application as well (periodically or before deployments) in order to make sure that it can properly work in the Pages environment (for more details see the [`@cloudflare/next-on-pages` recommended workflow](https://github.com/cloudflare/next-on-pages/blob/05b6256/internal-packages/next-dev/README.md#recommended-workflow))
27
+
28
+ ### Bindings
29
+
30
+ Cloudflare [Bindings](https://developers.cloudflare.com/pages/functions/bindings/) are what allows you to interact with resources available in the Cloudflare Platform.
31
+
32
+ You can use bindings during development, when previewing locally your application and of course in the deployed application:
33
+
34
+ - To use bindings in dev mode you need to define them in the `next.config.js` file under `setupDevBindings`, this mode uses the `next-dev` `@cloudflare/next-on-pages` submodule. For more details see its [documentation](https://github.com/cloudflare/next-on-pages/blob/05b6256/internal-packages/next-dev/README.md).
35
+
36
+ - To use bindings in the preview mode you need to add them to the `pages:preview` script accordingly to the `wrangler pages dev` command. For more details see its [documentation](https://developers.cloudflare.com/workers/wrangler/commands/#dev-1) or the [Pages Bindings documentation](https://developers.cloudflare.com/pages/functions/bindings/).
37
+
38
+ - To use bindings in the deployed application you will need to configure them in the Cloudflare [dashboard](https://dash.cloudflare.com/). For more details see the [Pages Bindings documentation](https://developers.cloudflare.com/pages/functions/bindings/).
39
+
40
+ #### KV Example
41
+
42
+ `c3` has added for you an example showing how you can use a KV binding, in order to enable the example, search for lines containing the following comment:
43
+ ```ts
44
+ // KV Example:
45
+ ```
46
+
47
+ and uncomment the commented lines below it.
48
+
49
+ After doing this you can run the `dev` script and visit the `/api/hello` route to see the example in action.
50
+
51
+ To then enable such example also in preview mode add a `kv` in the `pages:preview` script like so:
52
+ ```diff
53
+ - "pages:preview": "npm run pages:build && wrangler pages dev .vercel/output/static --compatibility-date=2023-12-18 --compatibility-flag=nodejs_compat",
54
+ + "pages:preview": "npm run pages:build && wrangler pages dev .vercel/output/static --compatibility-date=2023-12-18 --compatibility-flag=nodejs_compat --kv MY_KV",
55
+ ```
56
+
57
+ Finally, if you also want to see the example work in the deployed application make sure to add a `MY_KV` 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.
@@ -0,0 +1,19 @@
1
+ export const runtime = 'edge'
2
+
3
+ export async function GET(request) {
4
+ let responseText = 'Hello World'
5
+
6
+ // In the edge runtime you can use Bindings that are available in your application
7
+ // (for more details see:
8
+ // - https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-bindings-in-your-nextjs-application
9
+ // - https://developers.cloudflare.com/pages/functions/bindings/
10
+ // )
11
+ //
12
+ // KV Example:
13
+ // const myKv = process.env.MY_KV
14
+ // await myKv.put('suffix', ' from a KV store!')
15
+ // const suffix = await myKv.get('suffix')
16
+ // responseText += suffix
17
+
18
+ return new Response(responseText)
19
+ }
@@ -0,0 +1,58 @@
1
+ export const runtime = "edge";
2
+
3
+ export default function NotFound() {
4
+ return (
5
+ <>
6
+ <title>404: This page could not be found.</title>
7
+ <div style={styles.error}>
8
+ <div>
9
+ <style
10
+ dangerouslySetInnerHTML={{
11
+ __html: `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`,
12
+ }}
13
+ />
14
+ <h1 className="next-error-h1" style={styles.h1}>
15
+ 404
16
+ </h1>
17
+ <div style={styles.desc}>
18
+ <h2 style={styles.h2}>This page could not be found.</h2>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </>
23
+ );
24
+ }
25
+
26
+ const styles = {
27
+ error: {
28
+ fontFamily:
29
+ 'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',
30
+ height: "100vh",
31
+ textAlign: "center",
32
+ display: "flex",
33
+ flexDirection: "column",
34
+ alignItems: "center",
35
+ justifyContent: "center",
36
+ },
37
+
38
+ desc: {
39
+ display: "inline-block",
40
+ },
41
+
42
+ h1: {
43
+ display: "inline-block",
44
+ margin: "0 20px 0 0",
45
+ padding: "0 23px 0 0",
46
+ fontSize: 24,
47
+ fontWeight: 500,
48
+ verticalAlign: "top",
49
+ lineHeight: "49px",
50
+ },
51
+
52
+ h2: {
53
+ fontSize: 14,
54
+ fontWeight: 400,
55
+ lineHeight: "49px",
56
+ margin: 0,
57
+ },
58
+ };
@@ -0,0 +1,21 @@
1
+ import type { NextRequest } from 'next/server'
2
+
3
+ export const runtime = 'edge'
4
+
5
+ export async function GET(request: NextRequest) {
6
+ let responseText = 'Hello World'
7
+
8
+ // In the edge runtime you can use Bindings that are available in your application
9
+ // (for more details see:
10
+ // - https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-bindings-in-your-nextjs-application
11
+ // - https://developers.cloudflare.com/pages/functions/bindings/
12
+ // )
13
+ //
14
+ // KV Example:
15
+ // const myKv = process.env.MY_KV
16
+ // await myKv.put('suffix', ' from a KV store!')
17
+ // const suffix = await myKv.get('suffix')
18
+ // responseText += suffix
19
+
20
+ return new Response(responseText)
21
+ }
@@ -0,0 +1,58 @@
1
+ export const runtime = "edge";
2
+
3
+ export default function NotFound() {
4
+ return (
5
+ <>
6
+ <title>404: This page could not be found.</title>
7
+ <div style={styles.error}>
8
+ <div>
9
+ <style
10
+ dangerouslySetInnerHTML={{
11
+ __html: `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`,
12
+ }}
13
+ />
14
+ <h1 className="next-error-h1" style={styles.h1}>
15
+ 404
16
+ </h1>
17
+ <div style={styles.desc}>
18
+ <h2 style={styles.h2}>This page could not be found.</h2>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </>
23
+ );
24
+ }
25
+
26
+ const styles = {
27
+ error: {
28
+ fontFamily:
29
+ 'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',
30
+ height: "100vh",
31
+ textAlign: "center",
32
+ display: "flex",
33
+ flexDirection: "column",
34
+ alignItems: "center",
35
+ justifyContent: "center",
36
+ },
37
+
38
+ desc: {
39
+ display: "inline-block",
40
+ },
41
+
42
+ h1: {
43
+ display: "inline-block",
44
+ margin: "0 20px 0 0",
45
+ padding: "0 23px 0 0",
46
+ fontSize: 24,
47
+ fontWeight: 500,
48
+ verticalAlign: "top",
49
+ lineHeight: "49px",
50
+ },
51
+
52
+ h2: {
53
+ fontSize: 14,
54
+ fontWeight: 400,
55
+ lineHeight: "49px",
56
+ margin: 0,
57
+ },
58
+ } as const;
@@ -1,29 +1,19 @@
1
- import { existsSync, mkdirSync } from "fs";
1
+ import { join } from "path";
2
2
  import { crash, updateStatus, warn } from "@cloudflare/cli";
3
3
  import { processArgument } from "@cloudflare/cli/args";
4
4
  import { brandColor, dim } from "@cloudflare/cli/colors";
5
5
  import { installPackages, runFrameworkGenerator } from "helpers/command";
6
6
  import {
7
7
  compatDateFlag,
8
+ copyFile,
8
9
  probePaths,
9
10
  readJSON,
10
11
  usesEslint,
11
12
  usesTypescript,
12
- writeFile,
13
13
  writeJSON,
14
14
  } from "helpers/files";
15
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";
16
+ import { getTemplatePath } from "../../src/templates";
27
17
  import type { TemplateConfig } from "../../src/templates";
28
18
  import type { C3Args, C3Context } from "types";
29
19
 
@@ -35,27 +25,6 @@ const generate = async (ctx: C3Context) => {
35
25
  await runFrameworkGenerator(ctx, [projectName]);
36
26
  };
37
27
 
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
28
  const configure = async (ctx: C3Context) => {
60
29
  const projectPath = ctx.project.path;
61
30
 
@@ -73,36 +42,13 @@ const configure = async (ctx: C3Context) => {
73
42
  crash("Could not find the `/api` or `/app` directory");
74
43
  }
75
44
 
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
45
  const usesTs = usesTypescript(ctx);
80
46
 
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
47
  if (usesTs) {
105
- writeFile(`${projectPath}/env.d.ts`, envDts);
48
+ copyFile(
49
+ join(getTemplatePath(ctx), "env.d.ts"),
50
+ join(projectPath, "env.d.ts")
51
+ );
106
52
  updateStatus("Created an env.d.ts file");
107
53
  }
108
54
 
@@ -112,10 +58,16 @@ const configure = async (ctx: C3Context) => {
112
58
  await writeEslintrc(ctx);
113
59
  }
114
60
 
115
- writeFile(`${projectPath}/next.config.js`, nextConfig);
116
- updateStatus("Updated the next.config.js file");
61
+ copyFile(
62
+ join(getTemplatePath(ctx), "next.config.mjs"),
63
+ join(projectPath, "next.config.mjs")
64
+ );
65
+ updateStatus("Updated the next.config.mjs file");
117
66
 
118
- writeFile(`${projectPath}/README.md`, readme);
67
+ copyFile(
68
+ join(getTemplatePath(ctx), "README.md"),
69
+ join(projectPath, "README.md")
70
+ );
119
71
  updateStatus("Updated the README file");
120
72
 
121
73
  await addDevDependencies(installEslintPlugin);
@@ -181,6 +133,37 @@ export default {
181
133
  previewScript: "pages:preview",
182
134
  generate,
183
135
  configure,
136
+ copyFiles: {
137
+ async selectVariant(ctx) {
138
+ const isApp = probePaths([
139
+ `${ctx.project.path}/src/app`,
140
+ `${ctx.project.path}/app`,
141
+ ]);
142
+
143
+ const isTypescript = usesTypescript(ctx);
144
+
145
+ const dir = isApp ? "app" : "pages";
146
+ return `${dir}/${isTypescript ? "ts" : "js"}`;
147
+ },
148
+ destinationDir(ctx) {
149
+ const srcPath = probePaths([`${ctx.project.path}/src`]);
150
+ return srcPath ? "./src" : "./";
151
+ },
152
+ variants: {
153
+ "app/ts": {
154
+ path: "./app/ts",
155
+ },
156
+ "app/js": {
157
+ path: "./app/js",
158
+ },
159
+ "pages/ts": {
160
+ path: "./pages/ts",
161
+ },
162
+ "pages/js": {
163
+ path: "./pages/js",
164
+ },
165
+ },
166
+ },
184
167
  transformPackageJson: async () => {
185
168
  const isNpm = npm === "npm";
186
169
  const isBun = npm === "bun";
@@ -0,0 +1,13 @@
1
+ declare global {
2
+ namespace NodeJS {
3
+ interface ProcessEnv {
4
+ // Add here the Cloudflare Bindings you want to have available in your application
5
+ // (for more details on Bindings see: https://developers.cloudflare.com/pages/functions/bindings/)
6
+ //
7
+ // KV Example:
8
+ // MY_KV: KVNamespace
9
+ }
10
+ }
11
+ }
12
+
13
+ export {}
@@ -0,0 +1,24 @@
1
+ import { setupDevBindings } from '@cloudflare/next-on-pages/next-dev';
2
+
3
+ /** @type {import('next').NextConfig} */
4
+ const nextConfig = {};
5
+
6
+ // Here we use the @cloudflare/next-on-pages next-dev module to allow us to use bindings during local development
7
+ // (when running the application with \`next dev\`), for more information see:
8
+ // https://github.com/cloudflare/next-on-pages/blob/8e93067/internal-packages/next-dev/README.md
9
+ if (process.env.NODE_ENV === 'development') {
10
+ await setupDevBindings({
11
+ bindings: {
12
+ // Add here the Cloudflare Bindings you want to have available during local development,
13
+ // for more details on Bindings see: https://developers.cloudflare.com/pages/functions/bindings/)
14
+ //
15
+ // KV Example:
16
+ // MY_KV: {
17
+ // type: 'kv',
18
+ // id: 'xxx',
19
+ // }
20
+ }
21
+ });
22
+ }
23
+
24
+ export default nextConfig;
@@ -0,0 +1,21 @@
1
+ export const config = {
2
+ runtime: 'edge',
3
+ }
4
+
5
+ export default async function handler(req) {
6
+ let responseText = 'Hello World'
7
+
8
+ // In the edge runtime you can use Bindings that are available in your application
9
+ // (for more details see:
10
+ // - https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-bindings-in-your-nextjs-application
11
+ // - https://developers.cloudflare.com/pages/functions/bindings/
12
+ // )
13
+ //
14
+ // KV Example:
15
+ // const myKv = process.env.MY_KV
16
+ // await myKv.put('suffix', ' from a KV store!')
17
+ // const suffix = await myKv.get('suffix')
18
+ // responseText += suffix
19
+
20
+ return new Response(responseText)
21
+ }
@@ -0,0 +1,23 @@
1
+ import type { NextRequest } from 'next/server'
2
+
3
+ export const config = {
4
+ runtime: 'edge',
5
+ }
6
+
7
+ export default async function handler(req: NextRequest) {
8
+ let responseText = 'Hello World'
9
+
10
+ // In the edge runtime you can use Bindings that are available in your application
11
+ // (for more details see:
12
+ // - https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-bindings-in-your-nextjs-application
13
+ // - https://developers.cloudflare.com/pages/functions/bindings/
14
+ // )
15
+ //
16
+ // KV Example:
17
+ // const myKv = process.env.MY_KV
18
+ // await myKv.put('suffix', ' from a KV store!')
19
+ // const suffix = await myKv.get('suffix')
20
+ // responseText += suffix
21
+
22
+ return new Response(responseText)
23
+ }
@@ -1,11 +1,11 @@
1
- import { readFileSync } from "node:fs";
2
- import { resolve } from "node:path";
3
1
  import { logRaw } from "@cloudflare/cli";
4
2
  import { brandColor, dim } from "@cloudflare/cli/colors";
5
3
  import { spinner } from "@cloudflare/cli/interactive";
6
- import { runFrameworkGenerator } from "helpers/command";
7
- import { compatDateFlag, writeFile } from "helpers/files";
4
+ import { transformFile } from "helpers/codemod";
5
+ import { installPackages, runFrameworkGenerator } from "helpers/command";
6
+ import { writeFile } from "helpers/files";
8
7
  import { detectPackageManager } from "helpers/packages";
8
+ import * as recast from "recast";
9
9
  import type { TemplateConfig } from "../../src/templates";
10
10
  import type { C3Context } from "types";
11
11
 
@@ -28,31 +28,71 @@ const generate = async (ctx: C3Context) => {
28
28
  };
29
29
 
30
30
  const configure = async () => {
31
- const configFileName = "nuxt.config.ts";
32
- const configFilePath = resolve(configFileName);
31
+ await installPackages(["nitro-cloudflare-dev"], {
32
+ dev: true,
33
+ startText: "Installing nitro module `nitro-cloudflare-dev`",
34
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
35
+ });
36
+ updateNuxtConfig();
37
+ };
38
+
39
+ const updateNuxtConfig = () => {
33
40
  const s = spinner();
34
- s.start(`Updating \`${configFileName}\``);
35
- // Add the cloudflare preset into the configuration file.
36
- const originalConfigFile = readFileSync(configFilePath, "utf8");
37
- const updatedConfigFile = originalConfigFile.replace(
38
- "defineNuxtConfig({",
39
- "defineNuxtConfig({\n nitro: {\n preset: 'cloudflare-pages'\n },"
41
+
42
+ const configFile = "nuxt.config.ts";
43
+ s.start(`Updating \`${configFile}\``);
44
+
45
+ const b = recast.types.builders;
46
+
47
+ const presetDef = b.objectProperty(
48
+ b.identifier("nitro"),
49
+ b.objectExpression([
50
+ b.objectProperty(
51
+ b.identifier("preset"),
52
+ b.stringLiteral("cloudflare-pages")
53
+ ),
54
+ ])
55
+ );
56
+
57
+ const moduleDef = b.objectProperty(
58
+ b.identifier("modules"),
59
+ b.arrayExpression([b.stringLiteral("nitro-cloudflare-dev")])
40
60
  );
41
- writeFile(configFilePath, updatedConfigFile);
42
- s.stop(`${brandColor(`updated`)} ${dim(`\`${configFileName}\``)}`);
61
+
62
+ transformFile(configFile, {
63
+ visitCallExpression: function (n) {
64
+ const callee = n.node.callee as recast.types.namedTypes.Identifier;
65
+ if (callee.name === "defineNuxtConfig") {
66
+ const obj = n.node
67
+ .arguments[0] as recast.types.namedTypes.ObjectExpression;
68
+
69
+ obj.properties.push(presetDef);
70
+ obj.properties.push(moduleDef);
71
+ }
72
+
73
+ return this.traverse(n);
74
+ },
75
+ });
76
+
77
+ s.stop(`${brandColor(`updated`)} ${dim(`\`${configFile}\``)}`);
43
78
  };
44
79
 
45
80
  const config: TemplateConfig = {
46
81
  configVersion: 1,
47
82
  id: "nuxt",
48
83
  platform: "pages",
84
+ copyFiles: {
85
+ path: "./templates",
86
+ },
49
87
  displayName: "Nuxt",
88
+ devScript: "dev",
89
+ deployScript: "deploy",
50
90
  generate,
51
91
  configure,
52
92
  transformPackageJson: async () => ({
53
93
  scripts: {
54
- "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 3000 -- ${npm} run dev`,
55
- "pages:deploy": `${npm} run build && wrangler pages deploy ./dist`,
94
+ deploy: `${npm} run build && wrangler pages deploy ./dist`,
95
+ preview: `${npm} run build && wrangler pages dev ./dist`,
56
96
  },
57
97
  }),
58
98
  };