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
@@ -0,0 +1,36 @@
1
+ import { endSection } from "@cloudflare/cli";
2
+ import { runCommand, runFrameworkGenerator } from "helpers/command";
3
+ import { compatDateFlag } from "helpers/files";
4
+ import { detectPackageManager } from "helpers/packages";
5
+ import { quoteShellArgs } from "../../src/common";
6
+ import type { TemplateConfig } from "../../src/templates";
7
+ import type { C3Context } from "types";
8
+
9
+ const { npm, npx } = detectPackageManager();
10
+
11
+ const generate = async (ctx: C3Context) => {
12
+ await runFrameworkGenerator(ctx, ["basic", ctx.project.name]);
13
+ };
14
+
15
+ const configure = async (ctx: C3Context) => {
16
+ // Add the pages integration
17
+ const cmd = [npx, "qwik", "add", "cloudflare-pages"];
18
+ endSection(`Running ${quoteShellArgs(cmd)}`);
19
+ await runCommand(cmd);
20
+ };
21
+
22
+ const config: TemplateConfig = {
23
+ configVersion: 1,
24
+ id: "qwik",
25
+ displayName: "Qwik",
26
+ platform: "pages",
27
+ generate,
28
+ configure,
29
+ transformPackageJson: async () => ({
30
+ scripts: {
31
+ "pages:dev": `wrangler pages dev ${await compatDateFlag()} -- ${npm} run dev`,
32
+ "pages:deploy": `${npm} run build && wrangler pages deploy ./dist`,
33
+ },
34
+ }),
35
+ };
36
+ export default config;
@@ -0,0 +1,29 @@
1
+ import { logRaw } from "@cloudflare/cli";
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
+ await runFrameworkGenerator(ctx, [ctx.project.name]);
12
+
13
+ logRaw("");
14
+ };
15
+
16
+ const config: TemplateConfig = {
17
+ configVersion: 1,
18
+ id: "react",
19
+ displayName: "React",
20
+ platform: "pages",
21
+ generate,
22
+ transformPackageJson: async () => ({
23
+ scripts: {
24
+ "pages:dev": `wrangler pages dev ${await compatDateFlag()} --port 3000 -- ${npm} start`,
25
+ "pages:deploy": `${npm} run build && wrangler pages deploy ./build`,
26
+ },
27
+ }),
28
+ };
29
+ export default config;
@@ -0,0 +1,33 @@
1
+ import { logRaw } from "@cloudflare/cli";
2
+ import { runFrameworkGenerator } from "helpers/command.js";
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, [
11
+ ctx.project.name,
12
+ "--template",
13
+ "https://github.com/remix-run/remix/tree/main/templates/cloudflare-pages",
14
+ ]);
15
+
16
+ logRaw(""); // newline
17
+ };
18
+
19
+ const config: TemplateConfig = {
20
+ configVersion: 1,
21
+ id: "remix",
22
+ displayName: "Remix",
23
+ platform: "pages",
24
+ generate,
25
+ transformPackageJson: async () => ({
26
+ scripts: {
27
+ "pages:deploy": `${npm} run build && wrangler pages deploy ./public`,
28
+ },
29
+ }),
30
+ devScript: "dev",
31
+ testFlags: ["--typescript", "--no-install", "--no-git-init"],
32
+ };
33
+ export default config;
@@ -0,0 +1,14 @@
1
+ export default {
2
+ configVersion: 1,
3
+ id: "scheduled",
4
+ displayName: "Scheduled Worker (Cron Trigger)",
5
+ platform: "workers",
6
+ copyFiles: {
7
+ js: {
8
+ path: "./js",
9
+ },
10
+ ts: {
11
+ path: "./ts",
12
+ },
13
+ },
14
+ };
@@ -0,0 +1,37 @@
1
+ import { logRaw, updateStatus } from "@cloudflare/cli";
2
+ import { blue, brandColor, dim } from "@cloudflare/cli/colors";
3
+ import { installPackages, 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 { npm } = detectPackageManager();
10
+
11
+ const generate = async (ctx: C3Context) => {
12
+ // Run the create-solid command
13
+ await runFrameworkGenerator(ctx, [ctx.project.name]);
14
+
15
+ logRaw("");
16
+ };
17
+
18
+ const config: TemplateConfig = {
19
+ configVersion: 1,
20
+ id: "solid",
21
+ displayName: "Solid",
22
+ platform: "pages",
23
+ copyFiles: {
24
+ js: { path: "./js" },
25
+ ts: { path: "./ts" },
26
+ },
27
+ generate,
28
+ transformPackageJson: async () => ({
29
+ scripts: {
30
+ "pages:preview": `${npm} run build && npx wrangler pages dev dist ${await compatDateFlag()} --compatibility-flag nodejs_compat`,
31
+ "pages:deploy": `${npm} run build && wrangler pages deploy ./dist`,
32
+ },
33
+ }),
34
+ devScript: "dev",
35
+ compatibilityFlags: ["nodejs_compat"],
36
+ };
37
+ export default config;
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "@solidjs/start/config";
2
+
3
+ export default defineConfig({
4
+ start: {
5
+ server: {
6
+ preset: "cloudflare-pages",
7
+ rollupConfig: {
8
+ external: ["node:async_hooks"]
9
+ },
10
+ }
11
+ }
12
+ });
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "@solidjs/start/config";
2
+
3
+ export default defineConfig({
4
+ start: {
5
+ server: {
6
+ preset: "cloudflare-pages",
7
+ rollupConfig: {
8
+ external: ["node:async_hooks"]
9
+ },
10
+ }
11
+ }
12
+ });
@@ -0,0 +1,75 @@
1
+ import { logRaw, updateStatus } from "@cloudflare/cli";
2
+ import { blue, brandColor, dim } from "@cloudflare/cli/colors";
3
+ import { parseTs, transformFile } from "helpers/codemod";
4
+ import { installPackages, runFrameworkGenerator } from "helpers/command";
5
+ import { compatDateFlag, usesTypescript } from "helpers/files";
6
+ import { detectPackageManager } from "helpers/packages";
7
+ import { platformInterface } from "./templates";
8
+ import type { TemplateConfig } from "../../src/templates";
9
+ import type * as recast from "recast";
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]);
16
+
17
+ logRaw("");
18
+ };
19
+
20
+ const configure = async (ctx: C3Context) => {
21
+ // Install the adapter
22
+ const pkg = `@sveltejs/adapter-cloudflare`;
23
+ await installPackages([pkg], {
24
+ dev: true,
25
+ startText: "Adding the Cloudflare Pages adapter",
26
+ doneText: `${brandColor(`installed`)} ${dim(pkg)}`,
27
+ });
28
+
29
+ // Change the import statement in svelte.config.js
30
+ transformFile("svelte.config.js", {
31
+ visitImportDeclaration: function (n) {
32
+ // importSource is the `x` in `import y from "x"`
33
+ const importSource = n.value.source;
34
+ if (importSource.value === "@sveltejs/adapter-auto") {
35
+ importSource.value = "@sveltejs/adapter-cloudflare";
36
+ }
37
+
38
+ // stop traversing this node
39
+ return false;
40
+ },
41
+ });
42
+ updateStatus(`Changing adapter in ${blue("svelte.config.js")}`);
43
+
44
+ // If using typescript, add the platform interface to the `App` interface
45
+ if (usesTypescript(ctx)) {
46
+ transformFile("src/app.d.ts", {
47
+ visitTSModuleDeclaration(n) {
48
+ if (n.value.id.name === "App") {
49
+ const patchAst = parseTs(platformInterface);
50
+ const body = n.node.body as recast.types.namedTypes.TSModuleBlock;
51
+ body.body.push(patchAst.program.body[0]);
52
+ }
53
+
54
+ this.traverse(n);
55
+ },
56
+ });
57
+ updateStatus(`Updating global type definitions in ${blue("app.d.ts")}`);
58
+ }
59
+ };
60
+
61
+ const config: TemplateConfig = {
62
+ configVersion: 1,
63
+ id: "svelte",
64
+ displayName: "Svelte",
65
+ platform: "pages",
66
+ generate,
67
+ configure,
68
+ transformPackageJson: async () => ({
69
+ scripts: {
70
+ "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 5173 -- ${npm} run dev`,
71
+ "pages:deploy": `${npm} run build && wrangler pages deploy .svelte-kit/cloudflare`,
72
+ },
73
+ }),
74
+ };
75
+ export default config;
@@ -0,0 +1,13 @@
1
+ export const platformInterface = `
2
+ interface Platform {
3
+ env: {
4
+ COUNTER: DurableObjectNamespace;
5
+ };
6
+ context: {
7
+ waitUntil(promise: Promise<any>): void;
8
+ };
9
+ caches: CacheStorage & { default: Cache }
10
+ }
11
+ `;
12
+
13
+ // interface["Platform"] #context #waitUntil:nth(2)
@@ -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]);
11
+ };
12
+
13
+ const config: TemplateConfig = {
14
+ configVersion: 1,
15
+ id: "vue",
16
+ displayName: "Vue",
17
+ platform: "pages",
18
+ generate,
19
+ transformPackageJson: async () => ({
20
+ scripts: {
21
+ "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 5173 -- ${npm} run dev`,
22
+ "pages:deploy": `${npm} run build && wrangler pages deploy ./dist`,
23
+ },
24
+ }),
25
+ testFlags: ["--ts"],
26
+ };
27
+ export default config;
File without changes
@@ -1,5 +1,5 @@
1
- import { EOL } from "node:os";
2
1
  import fs from "node:fs";
2
+ import { EOL } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { worker } from "./paths.mjs";
5
5