create-cloudflare 0.0.0-6d7d00a8 → 0.0.0-6dda3626

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-6d7d00a8",
3
+ "version": "0.0.0-6dda3626",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -40,7 +40,6 @@
40
40
  "@types/esprima": "^4.0.3",
41
41
  "@types/node": "^18.15.3",
42
42
  "@types/semver": "^7.5.1",
43
- "@types/shell-quote": "^1.7.2",
44
43
  "@types/which-pm-runs": "^1.0.0",
45
44
  "@types/yargs": "^17.0.22",
46
45
  "@typescript-eslint/eslint-plugin": "^5.55.0",
@@ -60,7 +59,6 @@
60
59
  "pnpm": "^8.10.0",
61
60
  "recast": "^0.22.0",
62
61
  "semver": "^7.5.1",
63
- "shell-quote": "^1.8.1",
64
62
  "typescript": "^5.0.2",
65
63
  "undici": "5.28.2",
66
64
  "vite-tsconfig-paths": "^4.0.8",
@@ -69,7 +67,7 @@
69
67
  "yarn": "^1.22.19",
70
68
  "@cloudflare/cli": "1.1.1",
71
69
  "@cloudflare/workers-tsconfig": "0.0.0",
72
- "wrangler": "3.24.0"
70
+ "wrangler": "3.26.0"
73
71
  },
74
72
  "engines": {
75
73
  "node": ">=18.14.1"
@@ -1,4 +1,3 @@
1
- import { cp } from "node:fs/promises";
2
1
  import { resolve } from "node:path";
3
2
  import { logRaw } from "@cloudflare/cli";
4
3
  import { brandColor, dim } from "@cloudflare/cli/colors";
@@ -19,10 +18,10 @@ const generate = async (ctx: C3Context) => {
19
18
  const configure = async (ctx: C3Context) => {
20
19
  updateAngularJson(ctx);
21
20
  await updateAppCode();
22
- await installCFWorker(ctx);
21
+ await installCFWorker();
23
22
  };
24
23
 
25
- async function installCFWorker(ctx: C3Context) {
24
+ async function installCFWorker() {
26
25
  await installPackages(
27
26
  ["@cloudflare/workers-types", "@miniflare/tre@next", "wrangler@beta"],
28
27
  {
@@ -93,8 +92,8 @@ const config: TemplateConfig = {
93
92
  deploy: `${npm} run pages:build && wrangler pages deploy dist/cloudflare`,
94
93
  },
95
94
  }),
96
- deployCommand: ["deploy"],
97
- devCommand: ["start"],
95
+ deployScript: "deploy",
96
+ devScript: "start",
98
97
  testFlags: ["--style", "sass"],
99
98
  };
100
99
  export default config;
@@ -14,7 +14,7 @@ const generate = async (ctx: C3Context) => {
14
14
  logRaw(""); // newline
15
15
  };
16
16
 
17
- const configure = async (ctx: C3Context) => {
17
+ const configure = async () => {
18
18
  await runCommand([npx, "astro", "add", "cloudflare", "-y"], {
19
19
  silent: true,
20
20
  startText: "Installing adapter",
@@ -3,7 +3,6 @@ export default {
3
3
  id: "common",
4
4
  displayName: "Example router & proxy Worker",
5
5
  platform: "workers",
6
- languages: ["js", "ts"],
7
6
  copyFiles: {
8
7
  js: {
9
8
  path: "./js",
@@ -3,7 +3,6 @@ export default {
3
3
  id: "hello-world",
4
4
  displayName: '"Hello World" Worker',
5
5
  platform: "workers",
6
- languages: ["js", "ts"],
7
6
  copyFiles: {
8
7
  js: {
9
8
  path: "./js",
@@ -3,7 +3,6 @@ export default {
3
3
  id: "hello-world-durable-object",
4
4
  displayName: '"Hello World" Durable Object',
5
5
  platform: "workers",
6
- languages: ["js", "ts"],
7
6
  copyFiles: {
8
7
  js: {
9
8
  path: "./js",
@@ -19,7 +19,7 @@ const config: TemplateConfig = {
19
19
  displayName: "Hono",
20
20
  platform: "workers",
21
21
  generate,
22
- devCommand: ["dev"],
23
- deployCommand: ["deploy"],
22
+ devScript: "dev",
23
+ deployScript: "deploy",
24
24
  };
25
25
  export default config;
@@ -112,7 +112,7 @@ const configure = async (ctx: C3Context) => {
112
112
  await writeEslintrc(ctx);
113
113
  }
114
114
 
115
- writeFile(`${projectPath}/next.config.js`, nextConfig);
115
+ writeFile(`${projectPath}/next.config.mjs`, nextConfig);
116
116
  updateStatus("Updated the next.config.js file");
117
117
 
118
118
  writeFile(`${projectPath}/README.md`, readme);
@@ -177,6 +177,8 @@ export default {
177
177
  id: "next",
178
178
  platform: "pages",
179
179
  displayName: "Next",
180
+ devScript: "dev",
181
+ previewScript: "pages:preview",
180
182
  generate,
181
183
  configure,
182
184
  transformPackageJson: async () => {
@@ -180,30 +180,30 @@ const styles = {
180
180
  } as const;
181
181
  `;
182
182
 
183
- export const nextConfig = `/** @type {import('next').NextConfig} */
184
- const nextConfig = {}
183
+ export const nextConfig = `import { setupDevBindings } from '@cloudflare/next-on-pages/next-dev';
185
184
 
186
- module.exports = nextConfig
185
+ /** @type {import('next').NextConfig} */
186
+ const nextConfig = {};
187
187
 
188
188
  // Here we use the @cloudflare/next-on-pages next-dev module to allow us to use bindings during local development
189
189
  // (when running the application with \`next dev\`), for more information see:
190
- // https://github.com/dario-piotrowicz/next-on-pages/blob/8e93067/internal-packages/next-dev/README.md
190
+ // https://github.com/cloudflare/next-on-pages/blob/8e93067/internal-packages/next-dev/README.md
191
191
  if (process.env.NODE_ENV === 'development') {
192
- import('@cloudflare/next-on-pages/next-dev').then(({ setupDevBindings }) => {
193
- setupDevBindings({
194
- bindings: {
195
- // Add here the Cloudflare Bindings you want to have available during local development,
196
- // for more details on Bindings see: https://developers.cloudflare.com/pages/functions/bindings/)
197
- //
198
- // KV Example:
199
- // MY_KV: {
200
- // type: 'kv',
201
- // id: 'xxx',
202
- // }
203
- }
204
- })
205
- })
192
+ await setupDevBindings({
193
+ bindings: {
194
+ // Add here the Cloudflare Bindings you want to have available during local development,
195
+ // for more details on Bindings see: https://developers.cloudflare.com/pages/functions/bindings/)
196
+ //
197
+ // KV Example:
198
+ // MY_KV: {
199
+ // type: 'kv',
200
+ // id: 'xxx',
201
+ // }
202
+ }
203
+ });
206
204
  }
205
+
206
+ export default nextConfig;
207
207
  `;
208
208
 
209
209
  export const envDts = `declare global {
@@ -27,7 +27,7 @@ const generate = async (ctx: C3Context) => {
27
27
  logRaw(""); // newline
28
28
  };
29
29
 
30
- const configure = async (ctx: C3Context) => {
30
+ const configure = async () => {
31
31
  const configFileName = "nuxt.config.ts";
32
32
  const configFilePath = resolve(configFileName);
33
33
  const s = spinner();
@@ -3,7 +3,6 @@ export default {
3
3
  id: "openapi",
4
4
  displayName: "API starter (OpenAPI compliant)",
5
5
  platform: "workers",
6
- languages: ["ts"],
7
6
  copyFiles: {
8
7
  path: "./ts",
9
8
  },
@@ -1,7 +1,6 @@
1
- import { cp, mkdtemp, readdir, rm } from "fs/promises";
1
+ import { cp, mkdtemp } from "fs/promises";
2
2
  import { tmpdir } from "os";
3
3
  import { join } from "path";
4
- import { crash } from "@cloudflare/cli";
5
4
  import { processArgument } from "@cloudflare/cli/args";
6
5
  import { brandColor, dim } from "@cloudflare/cli/colors";
7
6
  import { runCommand } from "helpers/command";
@@ -10,7 +9,7 @@ import { chooseAccount } from "../../src/common";
10
9
  import type { C3Context } from "types";
11
10
 
12
11
  export async function copyExistingWorkerFiles(ctx: C3Context) {
13
- const { dlx, npm } = detectPackageManager();
12
+ const { dlx } = detectPackageManager();
14
13
 
15
14
  await chooseAccount(ctx);
16
15
 
@@ -72,7 +71,6 @@ export default {
72
71
  displayName: "Pre-existing Worker (from Dashboard)",
73
72
  platform: "workers",
74
73
  hidden: true,
75
- languages: ["js"],
76
74
  copyFiles: {
77
75
  path: "./js",
78
76
  },
@@ -3,7 +3,6 @@ export default {
3
3
  id: "queues",
4
4
  displayName: "Queue consumer & producer Worker",
5
5
  platform: "workers",
6
- languages: ["js", "ts"],
7
6
  copyFiles: {
8
7
  js: {
9
8
  path: "./js",
@@ -12,7 +12,7 @@ const generate = async (ctx: C3Context) => {
12
12
  await runFrameworkGenerator(ctx, ["basic", ctx.project.name]);
13
13
  };
14
14
 
15
- const configure = async (ctx: C3Context) => {
15
+ const configure = async () => {
16
16
  // Add the pages integration
17
17
  const cmd = [npx, "qwik", "add", "cloudflare-pages"];
18
18
  endSection(`Running ${quoteShellArgs(cmd)}`);
@@ -27,7 +27,7 @@ const config: TemplateConfig = {
27
27
  "pages:deploy": `${npm} run build && wrangler pages deploy ./public`,
28
28
  },
29
29
  }),
30
- devCommand: ["dev"],
30
+ devScript: "dev",
31
31
  testFlags: ["--typescript", "--no-install", "--no-git-init"],
32
32
  };
33
33
  export default config;
@@ -3,7 +3,6 @@ export default {
3
3
  id: "scheduled",
4
4
  displayName: "Scheduled Worker (Cron Trigger)",
5
5
  platform: "workers",
6
- languages: ["js", "ts"],
7
6
  copyFiles: {
8
7
  js: {
9
8
  path: "./js",
@@ -1,6 +1,5 @@
1
- import { logRaw, updateStatus } from "@cloudflare/cli";
2
- import { blue, brandColor, dim } from "@cloudflare/cli/colors";
3
- import { installPackages, runFrameworkGenerator } from "helpers/command";
1
+ import { logRaw } from "@cloudflare/cli";
2
+ import { runFrameworkGenerator } from "helpers/command";
4
3
  import { compatDateFlag } from "helpers/files";
5
4
  import { detectPackageManager } from "helpers/packages";
6
5
  import type { TemplateConfig } from "../../src/templates";
@@ -15,18 +14,6 @@ const generate = async (ctx: C3Context) => {
15
14
  logRaw("");
16
15
  };
17
16
 
18
- const configure = async (ctx: C3Context) => {
19
- // Install the pages adapter
20
- const pkg = "solid-start-cloudflare-pages";
21
- await installPackages([pkg], {
22
- dev: true,
23
- startText: "Adding the Cloudflare Pages adapter",
24
- doneText: `${brandColor(`installed`)} ${dim(pkg)}`,
25
- });
26
-
27
- updateStatus(`Adding the Cloudflare Pages adapter to vite config`);
28
- };
29
-
30
17
  const config: TemplateConfig = {
31
18
  configVersion: 1,
32
19
  id: "solid",
@@ -37,12 +24,14 @@ const config: TemplateConfig = {
37
24
  ts: { path: "./ts" },
38
25
  },
39
26
  generate,
40
- configure,
41
27
  transformPackageJson: async () => ({
42
28
  scripts: {
43
- "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 3000 -- ${npm} run dev`,
44
- "pages:deploy": `${npm} run build && wrangler pages deploy ./dist/public`,
29
+ "pages:preview": `${npm} run build && npx wrangler pages dev dist ${await compatDateFlag()} --compatibility-flag nodejs_compat`,
30
+ "pages:deploy": `${npm} run build && wrangler pages deploy ./dist`,
45
31
  },
46
32
  }),
33
+ devScript: "dev",
34
+ previewScript: "pages:preview",
35
+ compatibilityFlags: ["nodejs_compat"],
47
36
  };
48
37
  export default config;
@@ -1,7 +1,12 @@
1
- import cloudflare from "solid-start-cloudflare-pages";
2
- import solid from "solid-start/vite";
3
- import { defineConfig } from "vite";
1
+ import { defineConfig } from "@solidjs/start/config";
4
2
 
5
3
  export default defineConfig({
6
- plugins: [solid({ adapter: cloudflare({}) })],
4
+ start: {
5
+ server: {
6
+ preset: "cloudflare-pages",
7
+ rollupConfig: {
8
+ external: ["node:async_hooks"]
9
+ },
10
+ }
11
+ }
7
12
  });
@@ -1,7 +1,12 @@
1
- import cloudflare from "solid-start-cloudflare-pages";
2
- import solid from "solid-start/vite";
3
- import { defineConfig } from "vite";
1
+ import { defineConfig } from "@solidjs/start/config";
4
2
 
5
3
  export default defineConfig({
6
- plugins: [solid({ adapter: cloudflare({}) })],
4
+ start: {
5
+ server: {
6
+ preset: "cloudflare-pages",
7
+ rollupConfig: {
8
+ external: ["node:async_hooks"]
9
+ },
10
+ }
11
+ }
7
12
  });
@@ -67,9 +67,11 @@ const config: TemplateConfig = {
67
67
  configure,
68
68
  transformPackageJson: async () => ({
69
69
  scripts: {
70
- "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 5173 -- ${npm} run dev`,
70
+ "pages:preview": `${npm} run build && wrangler pages dev ${await compatDateFlag()} .svelte-kit/cloudflare`,
71
71
  "pages:deploy": `${npm} run build && wrangler pages deploy .svelte-kit/cloudflare`,
72
72
  },
73
73
  }),
74
+ devScript: "dev",
75
+ previewScript: "pages:preview",
74
76
  };
75
77
  export default config;
@@ -1,10 +0,0 @@
1
- export default {
2
- configVersion: 1,
3
- id: "chatgptPlugin",
4
- displayName: "ChatGPT plugin",
5
- platform: "workers",
6
- languages: ["ts"],
7
- copyFiles: {
8
- path: "./ts",
9
- },
10
- };
@@ -1,25 +0,0 @@
1
- # Example ChatGPT Plugin for Cloudflare Workers
2
-
3
- This is an example plugin showing how to build [ChatGPT plugins](https://platform.openai.com/docs/plugins/introduction) using [Cloudflare Workers](https://workers.dev). Using this example, you can deploy a plugin to Cloudflare Workers in just a few minutes.
4
-
5
- The sample plugin allows ChatGPT users to search for repositories using GitHub's search API. The plugin is implemented in TypeScript and uses the [OpenAPI](https://www.openapis.org/) specification to define the plugin's API.
6
-
7
- ![Example conversation in ChatGPT showing the plugin in use](./.assets/example.png)
8
-
9
- ## Get started
10
-
11
- 0. Sign up for [Cloudflare Workers](https://workers.dev). The free tier is more than enough for most use cases.
12
- 1. Install [wrangler](https://developers.cloudflare.com/workers/cli-wrangler/install-update), the Cloudflare Workers CLI
13
- 2. Clone this project and install dependencies with `npm install`
14
- 3. Run `wrangler login` to login to your Cloudflare account in wrangler
15
- 4. Run `wrangler deploy` to publish the plugin to Cloudflare Workers
16
-
17
- ## Usage
18
-
19
- 1. You can configure the `.well-known/ai-plugin.json` route in `index.ts`.
20
- 2. You can set up any new routes and the associated OpenAPI schema by defining new routes. See `search.ts` for an example.
21
- 3. For more information read the [itty-router-openapi official documentation](https://cloudflare.github.io/itty-router-openapi/).
22
-
23
- ## Deploying to OpenAI's API
24
-
25
- Follow the instructions [in the ChatGPT documentation](https://platform.openai.com/docs/plugins/introduction/plugin-flow) to deploy your plugin and begin using it in ChatGPT.
@@ -1,171 +0,0 @@
1
- # Logs
2
-
3
- logs
4
- _.log
5
- npm-debug.log_
6
- yarn-debug.log*
7
- yarn-error.log*
8
- lerna-debug.log*
9
- .pnpm-debug.log*
10
-
11
- # Diagnostic reports (https://nodejs.org/api/report.html)
12
-
13
- report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
14
-
15
- # Runtime data
16
-
17
- pids
18
- _.pid
19
- _.seed
20
- \*.pid.lock
21
-
22
- # Directory for instrumented libs generated by jscoverage/JSCover
23
-
24
- lib-cov
25
-
26
- # Coverage directory used by tools like istanbul
27
-
28
- coverage
29
- \*.lcov
30
-
31
- # nyc test coverage
32
-
33
- .nyc_output
34
-
35
- # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
36
-
37
- .grunt
38
-
39
- # Bower dependency directory (https://bower.io/)
40
-
41
- bower_components
42
-
43
- # node-waf configuration
44
-
45
- .lock-wscript
46
-
47
- # Compiled binary addons (https://nodejs.org/api/addons.html)
48
-
49
- build/Release
50
-
51
- # Dependency directories
52
-
53
- node_modules/
54
- jspm_packages/
55
-
56
- # Snowpack dependency directory (https://snowpack.dev/)
57
-
58
- web_modules/
59
-
60
- # TypeScript cache
61
-
62
- \*.tsbuildinfo
63
-
64
- # Optional npm cache directory
65
-
66
- .npm
67
-
68
- # Optional eslint cache
69
-
70
- .eslintcache
71
-
72
- # Optional stylelint cache
73
-
74
- .stylelintcache
75
-
76
- # Microbundle cache
77
-
78
- .rpt2_cache/
79
- .rts2_cache_cjs/
80
- .rts2_cache_es/
81
- .rts2_cache_umd/
82
-
83
- # Optional REPL history
84
-
85
- .node_repl_history
86
-
87
- # Output of 'npm pack'
88
-
89
- \*.tgz
90
-
91
- # Yarn Integrity file
92
-
93
- .yarn-integrity
94
-
95
- # dotenv environment variable files
96
-
97
- .env
98
- .env.development.local
99
- .env.test.local
100
- .env.production.local
101
- .env.local
102
-
103
- # parcel-bundler cache (https://parceljs.org/)
104
-
105
- .cache
106
- .parcel-cache
107
-
108
- # Next.js build output
109
-
110
- .next
111
- out
112
-
113
- # Nuxt.js build / generate output
114
-
115
- .nuxt
116
- dist
117
-
118
- # Gatsby files
119
-
120
- .cache/
121
-
122
- # Comment in the public line in if your project uses Gatsby and not Next.js
123
-
124
- # https://nextjs.org/blog/next-9-1#public-directory-support
125
-
126
- # public
127
-
128
- # vuepress build output
129
-
130
- .vuepress/dist
131
-
132
- # vuepress v2.x temp and cache directory
133
-
134
- .temp
135
- .cache
136
-
137
- # Docusaurus cache and generated files
138
-
139
- .docusaurus
140
-
141
- # Serverless directories
142
-
143
- .serverless/
144
-
145
- # FuseBox cache
146
-
147
- .fusebox/
148
-
149
- # DynamoDB Local files
150
-
151
- .dynamodb/
152
-
153
- # TernJS port file
154
-
155
- .tern-port
156
-
157
- # Stores VSCode versions used for testing VSCode extensions
158
-
159
- .vscode-test
160
-
161
- # yarn v2
162
-
163
- .yarn/cache
164
- .yarn/unplugged
165
- .yarn/build-state.yml
166
- .yarn/install-state.gz
167
- .pnp.\*
168
-
169
- # wrangler project
170
-
171
- .dev.vars
@@ -1,16 +0,0 @@
1
- {
2
- "name": "cloudflare-workers-chatgpt-plugin-example",
3
- "version": "0.0.1",
4
- "private": true,
5
- "scripts": {
6
- "deploy": "wrangler deploy",
7
- "dev": "wrangler dev",
8
- "start": "wrangler dev"
9
- },
10
- "dependencies": {
11
- "@cloudflare/itty-router-openapi": "^1.0.1"
12
- },
13
- "devDependencies": {
14
- "wrangler": "^3.0.0"
15
- }
16
- }
@@ -1,33 +0,0 @@
1
- import { OpenAPIRouter } from "@cloudflare/itty-router-openapi";
2
- import { GetSearch } from "./search";
3
-
4
- export const router = OpenAPIRouter({
5
- schema: {
6
- info: {
7
- title: "GitHub Repositories Search API",
8
- description:
9
- "A plugin that allows the user to search for GitHub repositories using ChatGPT",
10
- version: "v0.0.1",
11
- },
12
- },
13
- docs_url: "/",
14
- aiPlugin: {
15
- name_for_human: "GitHub Repositories Search",
16
- name_for_model: "github_repositories_search",
17
- description_for_human: "GitHub Repositories Search plugin for ChatGPT.",
18
- description_for_model:
19
- "GitHub Repositories Search plugin for ChatGPT. You can search for GitHub repositories using this plugin.",
20
- contact_email: "support@example.com",
21
- legal_info_url: "http://www.example.com/legal",
22
- logo_url: "https://workers.cloudflare.com/resources/logo/logo.svg",
23
- },
24
- });
25
-
26
- router.get("/search", GetSearch);
27
-
28
- // 404 for everything else
29
- router.all("*", () => new Response("Not Found.", { status: 404 }));
30
-
31
- export default {
32
- fetch: router.handle,
33
- };