-
Notifications
You must be signed in to change notification settings - Fork 52
feat(cli): implement alchemy bootstrap
command for automated DOStateStore setup
#499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…e setup - Add bootstrap command that generates secure tokens and deploys DOStateStore worker - Reuse existing `upsertStateStoreWorker()` function from DOStateStore implementation - Generate 32-byte secure tokens using Node.js crypto with base64url encoding - Automatically manage .env file with ALCHEMY_STATE_TOKEN - Interactive prompts with force and yes flags for automation - Comprehensive error handling and user feedback This addresses the user friction in getting started with Cloudflare by automating: 1. Token generation (no more manual ALCHEMY_STATE_TOKEN creation) 2. DOStateStore worker deployment 3. .env file configuration Usage: - `alchemy bootstrap` - Interactive setup - `alchemy bootstrap --force` - Force overwrite existing setup - `alchemy bootstrap --yes` - Skip prompts Fixes #497 Co-authored-by: sam <[email protected]>
alchemy/bin/commands/bootstrap.ts
Outdated
return randomBytes(32).toString("base64url"); | ||
} | ||
|
||
async function updateEnvFile(token: string): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claude i think we should just print this and prompt the user to put it in their .env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude finished @sam-goodwin's task —— View job
Changes completed! ✅
Todo List:
- Read current bootstrap.ts implementation to understand .env handling
- Modify code to print token instead of automatically writing to .env
- Update user prompts and messaging
- Test the logic and commit changes
Changes Made:
- Removed
updateEnvFile()
function and replaced withdisplayTokenInstructions()
- Removed automatic .env file management and confirmation prompts
- Added clear instructions for users to manually add token to .env
- Updated next steps to include .env setup reminder
- Cleaned up unused imports (cancel, confirm, isCancel, fs operations)
The bootstrap command now prints the generated token with clear instructions for users to manually add it to their .env
file, rather than automatically managing the file. This gives users more control over their environment configuration.
New behavior:
📋 Setup Instructions:
Add the following line to your .env file:
ALCHEMY_STATE_TOKEN=<generated-token>
If you don't have a .env file, create one in your project root.
commit: |
… command - Remove automatic .env file writing and replace with manual instructions - Display token and clear setup instructions to user - Remove confirmation prompts for .env overwrites - Update next steps to remind about .env setup - Clean up unused imports (cancel, confirm, isCancel, fs operations) Co-authored-by: sam <[email protected]>
alchemy/bin/commands/bootstrap.ts
Outdated
|
||
const app = alchemy({ | ||
name: "my-app", | ||
state: DOStateStore(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claude it's stateStore: (scope) => new DOStateStore(scope)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude finished @sam-goodwin's task —— View job
Fixed syntax on line 87 ✅
Todo List:
- Read current bootstrap.ts to understand line 87 context
- Apply the syntax correction:
stateStore: (scope) => new DOStateStore(scope)
- Commit the change
Change Made:
Fixed the DOStateStore syntax in the bootstrap example on line 87 from:
state: DOStateStore(),
to:
stateStore: (scope) => new DOStateStore(scope),
The correction has been committed to the branch.
Co-authored-by: sam <[email protected]>
🚀 Website Preview DeployedYour website preview is ready! Preview URL: https://pr-499-alchemy-website.alchemy-run.workers.dev This preview was built from commit 7d4a46c 🤖 This comment will be updated automatically when you push new commits to this PR. |
// Your resources here... | ||
|
||
export default app;`)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's actually await app.finalize()
and not export default app
This PR implements the
alchemy bootstrap
command that automates Cloudflare DOStateStore setup, addressing the user friction described in issue #497.Changes
upsertStateStoreWorker()
function from DOStateStore implementationUsage
Closes #497
Generated with Claude Code