Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
34.17k stars 1.92k forks source link

[FEATURE REQUEST] Ability to save and work on a collection/doc in local file system #1638

Open cyberhck opened 5 years ago

cyberhck commented 5 years ago

Details

Hello there, I did try to search through the issues, find anything, so hopefully this isn't duplicate.

I wanted to be able to save and open workspace from any location on our disk. The motivation behind this is that I want to commit this data on my source control and others can use it directly, I know about the teams and sharing, but there another issue, I want to be able to run those requests through CLI on CI system.

Actually saving to a directory on my repository, without a huge single json file would be better, it can use the same dir structure as the app, and each request could be separate file, that way version control would track much better.

Thanks

welcome[bot] commented 5 years ago

πŸ‘‹ Thanks for opening your first issue! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. If you're requesting a feature 🎁, please provide real use cases that would benefit. πŸ‘ͺ

To help make this a smooth process, please be sure you have first read the contributing guidelines.

muuvmuuv commented 5 years ago

Was about to open an issue for this. I have a different use case. We as a team store everything next to our project, so we would love to have the API JSON file there too. Paw supports storing it to a location, so we were able to save the file to our NextCloud and share it with the team. Maybe you could add this too with a lowered priced team sub.

gschier commented 5 years ago

The local DB files probably won't work very well with VCS but there currently exists an INSOMNIA_DATA_PATH environment variable that can be used to control where local app data is stored. https://github.com/getinsomnia/insomnia/pull/1230

There's also a plugin hook to export the current workspace. It should be possible to write a plugin that exports the current workspace every few seconds to a desired folder.

Saving to the FS with the same folder/request structure as Insomnia uses would require replacing the current local database (NeDB) with a new file-based one so that's likely not an option for now.

muuvmuuv commented 5 years ago

Sounds like what I wanted @gschier. Where do I add this env var, just in my e.g. .zshrc?

gschier commented 5 years ago

I'm not sure. You could try it there.

If you need it to be different for different projects than you'd likely be better off setting it when launching it from the command line.

INSOMNIA_DATA_PATH=/my/data/path /path/to/insomnia

I'm not familiar enough with Ubuntu to suggest the best method.

muuvmuuv commented 5 years ago

Great, thanks! I am on macOS so it is different, this works: INSOMNIA_DATA_PATH=~/Downloads/Data /Applications/Insomnia.app/Contents/MacOS/Insomnia.

Unfortunately this is as you have mentioned the hole Insomnia instance with all settings not only the workspace. Would be great to have something like this in the future. I'll use it like this for now and check out the plugin hooks method.

muuvmuuv commented 5 years ago

So I had a quick look into plugins but none of the hooks seems to work here. There is context.data.export which would work I guess but I can't find a hook that has access to it.

Do you have a reference/link that has more information? I just found https://support.insomnia.rest/article/26-plugins#context.data and https://github.com/getinsomnia/insomnia/blob/develop/packages/insomnia-app/app/plugins/index.js#L174-L219

gschier commented 4 years ago

Ah right, we might need a new plugin hook for that. It might be good to have an init hook that a plugin could use to do initial setup of things like repeating commands.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

cyberhck commented 4 years ago

actually I'd still like this to be opened

dingyaguang117 commented 4 years ago

So I had a quick look into plugins but none of the hooks seems to work here. There is context.data.export which would work I guess but I can't find a hook that has access to it.

Do you have a reference/link that has more information? I just found https://support.insomnia.rest/article/26-plugins#context.data and https://github.com/getinsomnia/insomnia/blob/develop/packages/insomnia-app/app/plugins/index.js#L174-L219

Insomnia Cancel the API for exporting data?

the context object didn't has a member called data

ericwooley commented 4 years ago

I was really hoping for this feature when I discovered insomnia. Postman won't do this because it goes against their business model.

Honestly it would be fine if the db was committed to the repo (though obviously not ideal), as long as there was decent ui for opening and closing a workspace.

Hell, even just a hotkey to "save" which could just be an export, and open from an exported folder would work.

It's bizarre to me that all the api tools seem to want to sync using teams instead of letting people control their data in vc.

cyberhck commented 4 years ago

Or have an extension, which is a simple json file or whatever db file insomnia uses, and allow us to double click on it, I really need it on VC because I want to have tests there and run it on ci

jj0b commented 4 years ago

+1 to this feature request. Being able to save a workspace in a project's repository would be very valuable.

MDornian commented 3 years ago

+1 to this feature request. It would be nice that each environment had its own save location as I work on different projects each with their own repo

develohpanda commented 3 years ago

Hey all, Insomnia Designer does support directly syncing your workspace with a git repository. Specifically for @cyberhck, Unit Tests in Designer also sync to your repository, and you can run them in CI using the companion CLI, Inso - inso run test TestSuite --env Staging.

Git Sync, and the ability to create and run Unit Tests, have not been included in Insomnia Core just yet, but it is entirely possible to migrate across to Designer to make use of these features in a seamless manner.

Please reach out if there is anything I can help to clarify. I know this isn't a direct answer to some of the queries in this issue, but some different workflows are available for keeping a workspace in the same location as a project repository. πŸ€—

fjfnaranjo-wavelt commented 3 years ago

It will be nice if we can tell the workspace exporter not to minimize the resulting JSON. This feature (the export/import) is ok for me as it is but having it not minimized will help with diffs. It will also allow to implement a VCS backed workspace even if you have to import/export it manually.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

VultureJD commented 1 year ago

+1 for this feature request. @filfreire any possibility of this happening in the near future?

Chicane90 commented 1 year ago

Im supporting this as well, my usecase is just simply to avoid accidentally wiping all your workspaces. I usually have all my developing stuff on a separate harddrive, so that way i am able to avoid losing all my data when my OS HDD dies. Also, all developing stuff is organized on a single hard drive.

So yes, reinstalled windows, and guess what happened, i didn't think of Insomnia storing all my stuff in AppData. So many Tools tend to force Users into their own specific save Folders, it starts becoming a Mess. And for many tools forcing Users to do this, it becomes easy to overlook one of them.

cyberhck commented 1 year ago

seriously? You're storing your code in a external hard drive? what if it's lost or damaged? Why aren't you using git and github?

VultureJD commented 1 year ago

Why do we have to be tied into using Inso’s git tool? It would be much better and easier to just allow for Inso spec files to be saved to a file location that is source controlled through another tool. Why re-invent the wheel?

cyberhck commented 1 year ago

Why re-invent the wheel?

I guess money?

Chicane90 commented 1 year ago

seriously? You're storing your code in a external hard drive? what if it's lost or damaged? Why aren't you using git and github?

No, not external Hard Drive, a separate HardDrive in my Computer, and there isnt only code on this drive, (local Servers, Tools, local maven repos etc.), basically all the stuff needed for developing. And ofc, the code itself also gets pushed to git.

andrei-dascalu commented 11 months ago

@cyberhck For example, I am storing files in a local filesystem that's committed to Git outside of Insomnia management. Since Insomnia can't work with file references from the apispec, I'm managing the spec separately then use a pipeline to merge into one so that insomnia can use them.

chaojian-zhang commented 9 months ago

This problem deserves more attention but I am not sure whether allowing external storage of existing data file solves the issue completely. For instance, currently Insomnia stores data in (on Windows) %AppData%/Insomnia as various JSON-like DB files, e.g. insomnia.Request.db. Such files are not friendly for version control.

Chicane90 commented 5 days ago

And once again, my workmachine died, and guess what, everything in Insomnia is gone again, because i am not able to "Save as..." and Version Control my Files ...