Skip to content
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

Util that can create and read files from a hidden folder in the user's project #80

Open
jdtjenkins opened this issue Mar 13, 2024 · 2 comments
Labels
enhancement New feature or request feat: utility help wanted Extra attention is needed

Comments

@jdtjenkins
Copy link
Collaborator

jdtjenkins commented Mar 13, 2024

This is more of an RFC I guess, but what do we think about a utility that lets the author create and read files inside a hidden folder just for that integration inside a user's project?

So it'd be something like this:

({ createHiddenFile, readHiddenFile }) => {
  createHiddenFile({
    name: 'foo.ts',
    content: `export default {}`
  })

  const myHiddenFile = await readHiddenFile('foo.ts')
}

These would then save at ${ root }/.[integration.name]/foo.ts So right next to the hidden .astro folder. And it can't read/write outside that folder.

For context, the usecase is:

For my themes, I'm planning on shipping encrypted versions of my component files so that then they can be decrypted on the user's machine if they have the correct permissions with their env variables. So they'll set an env key, it'll check the api for their "level" and then decrypt the components for that level.

But I don't want it to have to make an api call each time they run or build their project. So once it's done one call and gotten the decryption keys I want to store them on the user's machine. Then they can still develop and reinstall and everything without the api.

I realise I could do this relatively easily without a utility. But I'm going to implement this either way, so just wondered if other people thought there'd be any interest in making it an AIK util.

@florian-lefebvre
Copy link
Owner

Isn't it a good usecase for node_modules caching? Like storing at .node_modules/.your-folder. This way it's even cached by hosts like vercel. That being said, I think it's a great idea. This way we can add the folder name to .gitignore as needed

@jdtjenkins
Copy link
Collaborator Author

Yeah actually that's a good idea, to cache it in the node modules. I'm not really sure what would be best. But yeah whether it's stored in node_modules or a level up, just a little util that can just handle it for you

@florian-lefebvre florian-lefebvre added enhancement New feature or request help wanted Extra attention is needed feat: utility labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat: utility help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants