-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update templates, tweak prompts, add some magical actions ✨ (#20)
* Update templates: Include fiberplane studio, use db:seed command * Port over CLI changes * Update cli package.json * Revert template links back to create-honc-app instead of brettimus * Remove verbose D1 setup instructions * Ignore package-lock files * Tweak setup instructions for d1 and supa * Use inferSelect and seed each database with more clever names * Format * Tweak cancellation message * Tweak intro * Start parsing a hatch flag * Remove commented out code * Add small dev instructions for cli and clean up database preamble * Add cleaning scripts * Add dev script to test hatching * Update template deps and wrangler toml name fields * Organize postinstall instructions * Add better hello messages * Format and then give a better example for POSTing a user * Remind to run npm run fiberplane after seeding * Update the template github links for giget to point to main * Add back sample api * Update fiberplane studio dep to latest not canary
- Loading branch information
Showing
48 changed files
with
1,038 additions
and
292 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
node_modules | ||
|
||
# Ignore package-lock.json files in templates | ||
templates/**/package-lock.json | ||
|
||
# Ignore test apps | ||
cli/test-apps/** | ||
!cli/test-apps/.gitkeep | ||
|
||
# Ignore macOS DS_Store files | ||
.DS_Store |
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,7 @@ | ||
# Development Guide | ||
|
||
To test the CLI, run `pnpm dev` in the `cli` directory. | ||
|
||
It's recommendeded to add test apps to the `test-apps` directory, since they will be ignored by git. | ||
|
||
To test the hatching feature, run `pnpm dev:hatch`. |
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
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,62 @@ | ||
import { writeFileSync } from "node:fs"; | ||
import path from "node:path"; | ||
import type { Context } from "@/context"; | ||
import { getScaffoldedFiles, shouldSkipCodeGen } from "@/integrations/code-gen"; | ||
import { CodeGenError } from "@/types"; | ||
import { spinner } from "@clack/prompts"; | ||
|
||
/** | ||
* Start the code generation request in the background. | ||
* We save it as a promise so we can await the result later, in `actionCodeGenFinish`. | ||
* | ||
* @param ctx - The context object. | ||
*/ | ||
export async function actionCodeGenStart(ctx: Context) { | ||
if (shouldSkipCodeGen(ctx)) { | ||
return; | ||
} | ||
|
||
ctx.codeGenPromise = getScaffoldedFiles(ctx); | ||
} | ||
|
||
export async function actionCodeGenFinish(ctx: Context) { | ||
if (shouldSkipCodeGen(ctx)) { | ||
return; | ||
} | ||
|
||
const s = spinner(); | ||
s.start("Generating code from project description..."); | ||
|
||
try { | ||
const scaffoldedFiles = await ctx.codeGenPromise; | ||
|
||
if (scaffoldedFiles) { | ||
const currentPath = ctx.path ?? "."; | ||
if (scaffoldedFiles.indexFile) { | ||
writeFileSync( | ||
path.join(currentPath, "src", "index.ts"), | ||
scaffoldedFiles.indexFile, | ||
); | ||
} | ||
if (scaffoldedFiles.schemaFile) { | ||
writeFileSync( | ||
path.join(currentPath, "src", "db", "schema.ts"), | ||
scaffoldedFiles.schemaFile, | ||
); | ||
} | ||
if (scaffoldedFiles.seedFile) { | ||
writeFileSync( | ||
path.join(currentPath, "seed.ts"), | ||
scaffoldedFiles.seedFile, | ||
); | ||
} | ||
} | ||
s.stop(); | ||
return; | ||
} catch (error) { | ||
s.stop(); | ||
return new CodeGenError( | ||
error instanceof Error ? error.message : "Unknown error", | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,17 +1,5 @@ | ||
import { log } from "@clack/prompts"; | ||
|
||
export function showD1SetupInstructions() { | ||
log.step("Setting up :"); | ||
log.step("local development: Wrangler can spin up a D1 database locally"); | ||
|
||
log.step(`production: Create a Cloudflare account and D1 instance, retrieve the database key and your account id from the dashboard and addionally create an API token with D1 edit rights, and add it to your .prod.vars file. | ||
CLOUDFLARE_D1_TOKEN="" | ||
CLOUDFLARE_ACCOUNT_ID="" | ||
CLOUDFLARE_DATABASE_ID="" | ||
`); | ||
log.step("visit https://developers.cloudflare.com/d1/ for more information"); | ||
|
||
|
||
log.step("Setting up D1: Look in the file D1-explained.md"); | ||
} |
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
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
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
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
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,24 @@ | ||
import type { Context } from "@/context"; | ||
import { text } from "@clack/prompts"; | ||
|
||
export async function promptDescription(ctx: Context) { | ||
try { | ||
const placeholder = 'E.g., "A social network for geese"'; | ||
const result = await text({ | ||
message: "Briefly describe what you want to build.", | ||
placeholder, | ||
defaultValue: "", | ||
}); | ||
|
||
// NOTE - Do not give a default description | ||
if (typeof result === "string") { | ||
if (result !== "") { | ||
ctx.description = result; | ||
} | ||
} | ||
|
||
return result; | ||
} catch (error) { | ||
return error; | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.