-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add experimental gatsby workers + assets template
- Loading branch information
1 parent
ce46e04
commit 7ac13a6
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/create-cloudflare/templates-experimental/gatsby/c3.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
4 changes: 4 additions & 0 deletions
4
packages/create-cloudflare/templates-experimental/gatsby/templates/wrangler.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } |