-
Notifications
You must be signed in to change notification settings - Fork 214
feat: auto-fill detected env variables for sites/functions #2851
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
Console (appwrite/console)Project ID: Tip Each function runs in its own isolated container with custom environment variables |
WalkthroughAdds a new EnvironmentVariables Svelte component that provides a full UI for managing environment variables and exports: variables, productLabel, docsLink, analyticsSource, analyticsCreateSource, and isLoading. Integrates this component into function and site creation flows, replacing prior inline environment-variable UI and modal state in site configuration. Introduces helpers: DetectedVariable type, normalizeDetectedVariables, and mergeVariables to normalize and merge detected runtime variables. Parametrizes existing variable modals with productLabel and variable editor with docsLink. Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@src/routes/`(console)/project-[region]-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte:
- Around line 52-89: Extract the duplicated DetectedVariable type and the
functions normalizeDetectedVariables and mergeVariables into a single shared
helper module (e.g., helpers/variables.ts), export them, and import them from
both pages to eliminate duplication; keep the exact function signatures and
behavior (using Partial<Models.Variable> and the same key/name/value/secret
handling), ensure to import type { Models } from '@appwrite.io/console' in the
helper, remove the inline definitions from each +page.svelte, and replace them
with imports of DetectedVariable, normalizeDetectedVariables, and
mergeVariables.
🧹 Nitpick comments (1)
src/lib/components/variables/environmentVariables.svelte (1)
186-207: Merge adjacent identical{#if!variable?.secret}blocks.Two consecutive blocks check the same condition. Combining them reduces template noise and makes it clearer these actions are grouped.
♻️ Proposed merge
- {`#if` !variable?.secret} - <ActionMenu.Item.Button - leadingIcon={IconPencil} - on:click={(e) => { - toggle(e); - currentVariable = variable; - showUpdate = true; - }}> - Update - </ActionMenu.Item.Button> - {/if} - {`#if` !variable?.secret} - <ActionMenu.Item.Button - leadingIcon={IconEyeOff} - on:click={(e) => { - toggle(e); - currentVariable = variable; - showSecretModal = true; - }}> - Secret - </ActionMenu.Item.Button> - {/if} + {`#if` !variable?.secret} + <ActionMenu.Item.Button + leadingIcon={IconPencil} + on:click={(e) => { + toggle(e); + currentVariable = variable; + showUpdate = true; + }}> + Update + </ActionMenu.Item.Button> + <ActionMenu.Item.Button + leadingIcon={IconEyeOff} + on:click={(e) => { + toggle(e); + currentVariable = variable; + showSecretModal = true; + }}> + Secret + </ActionMenu.Item.Button> + {/if}
...oject-[region]-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte
Outdated
Show resolved
Hide resolved
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.
- Svelte 5 format.
productLabelshould have proper union type,site | function | global.
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.
svelte 5
|
|
||
| export let variables: Partial<Models.Variable>[] = []; | ||
| export let productLabel = 'site'; | ||
| export let docsLink = |
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.
we should do this links building in the component based on productLabel just once.
| <Button | ||
| secondary | ||
| size="s" | ||
| on:mousedown={() => { |
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.
does this directive work on components too?? 👀
| columns={[ | ||
| { id: 'key', width: { min: 300 } }, | ||
| { id: 'value', width: { min: 280 } }, | ||
| { id: 'actions', width: 40 } | ||
| ]}> |
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.
used twice, extract to a const.
| key?: string; | ||
| name?: string; | ||
| value?: string; | ||
| secret?: boolean; |
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.
how come all are optional? I'd expect key and the name to be there. if not, I don't think it constitutes as a valid env format.
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.
in what cases does this happen?
| bind:buildCommand | ||
| bind:roles | ||
| bind:variables | ||
| isVariablesLoading={detectingRuntime} /> |
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.
naming sounds confusing to me. one variable oriented, another runtime.
| import { InputText } from '$lib/elements/forms'; | ||
| import { Accordion, Fieldset, Layout } from '@appwrite.io/pink-svelte'; | ||
| import type { Models } from '@appwrite.io/console'; | ||
| import EnvironmentVariables from '$lib/components/variables/environmentVariables.svelte'; |
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.
lets just make an index.ts [barrel file] and export all variables/* from there. better management and readability.

What does this PR do?
(Provide a description of what this PR does.)
Test Plan
example:

Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)
Summary by CodeRabbit
New Features
Chore