-
Notifications
You must be signed in to change notification settings - Fork 88
chore(docs): clarify local vs stage scope properties and some usage examples
#1148
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
base: main
Are you sure you want to change the base?
Conversation
Add comprehensive documentation explaining the difference between `local` and `stage` properties in Alchemy scopes. **Key additions:** - Clarify that `local` and `stage` are independent properties - Show CLI usage examples for different combinations - Explain state isolation per stage - Provide common conditional pattern for resource configuration - Add warning against using environment variables to mimic stages This resolves confusion around running local environments with different stages (e.g., `bun alchemy dev --stage e2e` for E2E testing vs `bun alchemy dev` for regular development). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
So the generated docs here are kind of wrong, and the whole I want to acknowledge that we are probably missing something in our docs here. Can you I guess clarify what your understand is. I feel like something is getting lost in translation by having claude make a change here. |
|
@Mkassabov The main trouble I had was creating different resources for different use cases but using env variables instead of stages. This led Alchemy to create/update/delete resources unexpectedly, and while Alchemy was doing the right thing, it wasn't immediately clear to me why. Here's an example that shows the issue with the env pattern: import alchemy from "alchemy"
import { FileSystemStateStore } from "alchemy/state"
import { Exec } from "alchemy/os"
const app = await alchemy("test", {
stateStore: scope => new FileSystemStateStore(scope),
})
// Using environment variable to switch between E2E and dev
if (app.local && process.env.E2E === "e2e") {
await Exec("e2e-resource", { command: "echo 'E2E mode'" })
} else if (app.local) {
await Exec("dev-resource", { command: "echo 'Dev mode'" })
}
await app.finalize()If you run this: # First run - creates dev-resource
$ bun alchemy.run.ts --dev --stage dev
[creating] dev-resource Creating Resource...
[created] dev-resource Created Resource
# Second run - deletes dev-resource!
$ E2E=e2e bun alchemy.run.ts --dev --stage dev
[creating] e2e-resource Creating Resource...
[created] e2e-resource Created Resource
[deleting] dev-resource Deleting Resource...
[deleted] dev-resource Deleted ResourceBoth runs use The "better" pattern imo is using // Using stage parameter
if (app.local && app.stage === "e2e") {
await Exec("e2e-resource", { command: "echo 'E2E mode'" })
} else if (app.local) {
await Exec("dev-resource", { command: "echo 'Dev mode'" })
}Now it works correctly: $ bun alchemy.run.ts --dev --stage dev
[creating] dev-resource Creating Resource...
[created] dev-resource Created Resource
$ bun alchemy.run.ts --dev --stage e2e
[creating] e2e-resource Creating Resource...
[created] e2e-resource Created Resource
# No deletions - both coexist in separate state directoriesEach stage gets its own state directory ( |
@agcty reading your response the above quote stands out to me as the key issue. I'll talk to the team today to get consensus. I'm currently leaning towards making all the guides explicitly telling you to run with a specific stage rather than assuming a "default" stage that way users are exposed to it and we have a good direction to point them to from our guides. As well as rewriting the stage docs to provide more advanced examples Do you think that would've been a good enough solution to prevent you from running into this? I'm trying to trace your journey with alchemy to figure out where you missed stages so we can expose it to users following in your footsteps. |
|
@Mkassabov Yes, that would make a lot of sense. My journey roughly was: "Oh wow this is really easy setting up resources, so much simpler and more flexible than other frameworks", What made it slightly confusing is that I was doing all of this inside a large monorepo, reading both the monorepo docs and the stage docs simultaneously, while also opening PRs to improve resources, so I was juggling too much at once. If the docs were more explicit about stages and monorepos, with a couple of best-practice patterns, I think the experience would have been smoother. But I do want to mention that overall it was a very sane experience but best practices would definitely help. |
Add documentation explaining the difference between
localandstageproperties in Alchemy scopes.Key additions:
localandstageare independent propertiesThis resolves confusion around running local environments with different stages (e.g.,
bun alchemy dev --stage e2efor E2E testing vsbun alchemy devfor regular development).🤖 Generated with Claude Code