-
Notifications
You must be signed in to change notification settings - Fork 203
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
[FIX]:285 - Type proccess.env based off the available secrets in a no… #333
[FIX]:285 - Type proccess.env based off the available secrets in a no… #333
Conversation
fixes #285 @nichochar @benjreinhart I'd like to know your feedback on this approach and whether we can go ahead with this or not. Type error on hover: Suggestions: |
packages/api/srcbook/index.mts
Outdated
if (!Object.entries(sessionSecrets).length) return; | ||
const envTypeDeclarationFileContent = generateEnvTypesFile(sessionSecrets); | ||
const srcbookDir = pathToSrcbook(sessionId); | ||
const envDtsPath = Path.join(srcbookDir, 'src', 'env.d.ts'); |
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.
Nit but i would put this in the repo root. I think that's where I've typically seen these global envs.
@@ -0,0 +1,16 @@ | |||
// vite.config.ts |
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.
This file doesn't look like it should be checked in. Can we remove.
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.
Sure
* Add support for deleting and renaming files * Fix lint
* inital homepage rework, sections, card style, srcbook to notebook * fix lil linter error * move user facing Srcbook (in ref to notebook) to Notebook * style up to match figma
…tdout from vite to get port (srcbookdev#349) * feat: add logic to represent booting state within preview panel and parse stdout from vite to get port * fix: run npm run format
* Add folder delete and rename behavior * Remove unused files state * Fix lint warnings
Neat, thanks @BeRecursive22 ! |
…tebook
Dynamic Environment Type Declarations for Srcbooks
Approach
Initial Creation:
When creating a new srcbook, an empty environment type declaration file (env.d.ts) is generated under /src.
This file initially assumes all environment secrets are disabled.
Dynamic Updates:
Upon user actions (Add/Enable/Disable/Delete secrets), the system:
a. Retrieves the updated secrets available for the srcbook.
b. Dynamically generates a new env.d.ts file.
c. Writes the updated file to disk under the /src directory.
Type Safety:
All available environment secrets for a srcbook are typed in the ProcessEnv interface.
This enables TSServer to throw type errors when a user attempts to access non-existent environment secrets.
Limitations
This feature is not retroactively applicable to srcbooks created prior to this feature release.
Some assumptions: