Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

sam-goodwin
Copy link
Owner

This PR implements the alchemy bootstrap command that automates Cloudflare DOStateStore setup, addressing the user friction described in issue #497.

Changes

  • 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

Usage

alchemy bootstrap                    # Interactive setup
alchemy bootstrap --force            # Force overwrite existing setup
alchemy bootstrap --yes              # Skip prompts

Closes #497

Generated with Claude Code

…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]>
return randomBytes(32).toString("base64url");
}

async function updateEnvFile(token: string): Promise<void> {
Copy link
Owner Author

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

Copy link
Contributor

@claude claude bot Jun 26, 2025

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 with displayTokenInstructions()
  • 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.

Copy link

pkg-pr-new bot commented Jun 26, 2025

Open in StackBlitz

npm i https://pkg.pr.new/sam-goodwin/alchemy@499

commit: 7d4a46c

… 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]>

const app = alchemy({
name: "my-app",
state: DOStateStore(),
Copy link
Owner Author

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)

Copy link
Contributor

@claude claude bot Jun 26, 2025

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.

Copy link

github-actions bot commented Jun 26, 2025

🚀 Website Preview Deployed

Your 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.

Comment on lines +90 to +92
// Your resources here...

export default app;`)}
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

alchemy login, profiles and alchemy bootstrap
1 participant