Skip to content

Commit

Permalink
feat: add experimental gatsby workers + assets template
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Sep 12, 2024
1 parent 66d8ab7 commit 3df7947
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/create-cloudflare/src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import angularTemplateExperimental from "templates-experimental/angular/c3";
import astroTemplateExperimental from "templates-experimental/astro/c3";
import docusaurusTemplateExperimental from "templates-experimental/docusaurus/c3";
import gatsbyTemplateExperimental from "templates-experimental/gatsby/c3";
import helloWorldWithAssetsTemplateExperimental from "templates-experimental/hello-world-with-assets/c3";
import nuxtTemplateExperimental from "templates-experimental/nuxt/c3";
import qwikTemplateExperimental from "templates-experimental/qwik/c3";
Expand Down Expand Up @@ -161,6 +162,7 @@ export function getFrameworkMap({ experimental = false }): TemplateMap {
angular: angularTemplateExperimental,
astro: astroTemplateExperimental,
docusaurus: docusaurusTemplateExperimental,
gatsby: gatsbyTemplateExperimental,
nuxt: nuxtTemplateExperimental,
qwik: qwikTemplateExperimental,
remix: remixTemplateExperimental,
Expand Down
53 changes: 53 additions & 0 deletions packages/create-cloudflare/templates-experimental/gatsby/c3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { inputPrompt } from "@cloudflare/cli/interactive";
import { runFrameworkGenerator } from "frameworks/index";
import { detectPackageManager } from "helpers/packageManagers";
import type { TemplateConfig } from "../../src/templates";
import type { C3Context } from "types";

const { npm } = detectPackageManager();

const generate = async (ctx: C3Context) => {
const defaultTemplate = "https://github.com/gatsbyjs/gatsby-starter-blog";

const useTemplate = await inputPrompt({
type: "confirm",
question: "Would you like to use a template?",
label: "template",
defaultValue: true,
});

let templateUrl = "";
if (useTemplate) {
templateUrl = await inputPrompt({
type: "text",
question: `Please specify the url of the template you'd like to use`,
label: "template",
defaultValue: defaultTemplate,
});
}

await runFrameworkGenerator(ctx, ["new", ctx.project.name, templateUrl]);
};

const config: TemplateConfig = {
configVersion: 1,
id: "gatsby",
frameworkCli: "gatsby",
platform: "workers",
displayName: "Gatsby",
copyFiles: {
path: "./templates",
},
path: "templates-experimental/gatsby",
generate,
transformPackageJson: async () => ({
scripts: {
deploy: `${npm} run build && wrangler deploy`,
preview: `${npm} run build && wrangler dev`,
},
}),
devScript: "develop",
deployScript: "deploy",
previewScript: "preview",
};
export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#:schema node_modules/wrangler/config-schema.json
name = "<TBD>"
compatibility_date = "<TBD>"
experimental_assets = { directory = "./public" }

0 comments on commit 3df7947

Please sign in to comment.