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

Ability to create a file on host #129

Open
mikesir87 opened this issue Apr 12, 2022 · 1 comment
Open

Ability to create a file on host #129

mikesir87 opened this issue Apr 12, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@mikesir87
Copy link
Member

Elevator Pitch

To support various use cases (such as a tutorial or helping bootstrap projects), I'd like to be able to create a file on the host with a specified filename and contents. I don't currently have the need to specify additional constraints like file permissions, but I could anticipate that might be needed at some point.

Current Limitations

Currently, I am working around this ability by adding an endpoint to my backend that my frontend invokes to drop the file into a directory that's bind mounted with the host. This works, but limits the location of files to that which the extension is mounting (which isn't configurable at runtime). Preferably, I'd like to use the new file picker to let the user choose a directory and then drop files there. If the SDK provided a supported mechanism to create files, I could do so without needing to create a proxy endpoint and volume configuration.

Proposal

As an idea of what I'd like to see, here are some rough typings (totally feel free to adjust these).

I'll admit I'm on the fence on whether the workingDirectory can/should be an option or if it should be expected that the invoker provides a full file path as the first argument. I'd probably leverage the new file picker functionality to pick a directory and simply pass that along. Might be nice to have the ability to set a default working directory, but that can be another discussion.

ddClient.extension.host.createFile(
    filename: String, 
    fileContents: String | Blob, 
    options? : CreateFileOptions) => Promise<CreateFileResult>;

interface CreateFileOptions {
  workingDirectory? : string;
  filePermissions? : "not-sure-of-type-here"
  ....
}

interface CreateFileResult {
  success: boolean;
  filename: String;
  fullPath: String;
}
@benja-M-1
Copy link
Member

Similar to #124
We rely on process.exec and process.spawn which take an options object containing cwd and env. We could expose those two options.

@benja-M-1 benja-M-1 added the enhancement New feature or request label Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants