|
1 | | -<!-- markdownlint-disable heading-style first-line-h1 --> |
2 | | -<!-- markdownlint-disable no-inline-html --> |
3 | | -<div align="center"> |
4 | | - <br /> |
5 | | - <br /> |
6 | | - <img src="https://raw.githubusercontent.com/Kong/insomnia/develop/packages/insomnia-inso/assets/logo.svg" alt=""/> |
7 | | - <h1> |
8 | | - Inso CLI |
9 | | - <br /> |
10 | | - <br /> |
11 | | - </h1> |
12 | | - <h3>A CLI for <a href="https://insomnia.rest">Insomnia</a></h3> |
13 | | - <pre>npm install --global <a href="https://www.npmjs.com/package/insomnia-inso">insomnia-inso</a></pre> |
14 | | - <img src="https://raw.githubusercontent.com/Kong/insomnia/develop/packages/insomnia-inso/assets/demo.gif" alt=""/> |
15 | | - <br /> |
16 | | -</div> |
17 | | -<br /> |
18 | | -<!-- markdownlint-enable no-inline-html --> |
19 | | - |
20 | | -## Documentation |
21 | | - |
22 | | -See the [open-source Inso CLI documentation](https://docs.insomnia.rest/inso-cli/introduction). |
| 1 | +# Documentation |
| 2 | + |
| 3 | +How to use [Inso CLI](https://docs.insomnia.rest/inso-cli/introduction). |
| 4 | + |
| 5 | +## Testing |
| 6 | + |
| 7 | +```shell |
| 8 | +# unit tests |
| 9 | +npm run test:unit |
| 10 | + |
| 11 | +# start smoke test api (required for e2e tests) |
| 12 | +npm run serve -w insomnia-smoke-test |
| 13 | + |
| 14 | +# e2e tests for dev bundle |
| 15 | +npm run test:bundle |
| 16 | + |
| 17 | +# e2e tests for binary |
| 18 | +npm run test:binary |
| 19 | +``` |
| 20 | + |
| 21 | +## Development |
| 22 | + |
| 23 | +### Getting started |
| 24 | + |
| 25 | +```shell |
| 26 | +npm run inso-start |
| 27 | +npm run test -w insomnia-inso |
| 28 | +# will default to insomnia app database |
| 29 | +$PWD/packages/insomnia-inso/bin/inso run test |
| 30 | +# will use config, useful for testing with fewer args |
| 31 | +$PWD/packages/insomnia-inso/bin/inso -w packages/insomnia-inso/src/db/fixtures/git-repo script runTest |
| 32 | +``` |
| 33 | + |
| 34 | +### node-libcurl |
| 35 | + |
| 36 | +`Error: The module '.../insomnia/node_modules/@getinsomnia/node-libcurl/lib/binding/node_libcurl.node' |
| 37 | +was compiled against a different Node.js version using` |
| 38 | + |
| 39 | +node-libcurl builds for 3 operating systems and two versions of nodejs. insomnia-inso uses the nodejs build and insomnia app uses the electron build. you can switch between them using the following two commands |
| 40 | + |
| 41 | +```shell |
| 42 | +# install node version |
| 43 | +node_modules/.bin/node-pre-gyp install --update-binary --directory node_modules/@getinsomnia/node-libcurl |
| 44 | +# install electron version |
| 45 | +node_modules/.bin/node-pre-gyp install --update-binary --directory node_modules/@getinsomnia/node-libcurl --runtime=electron --target=30.0.0 |
| 46 | +``` |
| 47 | + |
| 48 | +## Run CLI Smoke Tests |
| 49 | + |
| 50 | +```shell |
| 51 | +# Run CLI tests |
| 52 | +npm run test:bundle -w insomnia-inso |
| 53 | +# Package the Inso CLI binaries |
| 54 | +npm run inso-package |
| 55 | +npm run test:binary -w insomnia-inso |
| 56 | +``` |
| 57 | + |
| 58 | +## Debugging CLI tests using watcher |
| 59 | + |
| 60 | +This is helpful for debugging failing api tests |
| 61 | + |
| 62 | +From project root, in separate terminals: |
| 63 | + |
| 64 | +```sh |
| 65 | +# start smoke test api |
| 66 | +npm run serve -w insomnia-smoke-test |
| 67 | + |
| 68 | +# watch inso |
| 69 | +npm run start -w insomnia-inso |
| 70 | + |
| 71 | +# run api test with dev bundle |
| 72 | +$PWD/packages/insomnia-inso/bin/inso run test "Echo Test Suite" --src $PWD/packages/insomnia-smoke-test/fixtures/inso-nedb --env Dev --verbose |
| 73 | +``` |
| 74 | + |
| 75 | +## How to debug pkg |
| 76 | + |
| 77 | +```sh |
| 78 | +# run modify package command and then a unit test |
| 79 | +npm run package -w insomnia-inso && \ |
| 80 | +$PWD/packages/insomnia-inso/binaries/inso run test "Echo Test Suite" --src $PWD/packages/insomnia-smoke-test/fixtures/inso-nedb --env Dev --verbose |
| 81 | + |
| 82 | +``` |
| 83 | + |
| 84 | +## How to update the `inso-nedb` fixtures |
| 85 | + |
| 86 | +Run Insomnia with `INSOMNIA_DATA_PATH` environment variable set to `fixtures/inso-nedb`, e.g.: |
| 87 | + |
| 88 | +```bash |
| 89 | +INSOMNIA_DATA_PATH=packages/insomnia-smoke-test/fixtures/inso-nedb /Applications/Insomnia.app/Contents/MacOS/Insomnia |
| 90 | +``` |
| 91 | + |
| 92 | +Relaunch the app one more time, so that Insomnia compacts the database. |
| 93 | + |
| 94 | +The `.gitignore` file will explicitly ignore certain database files, to keep the directory size down and avoid prevent sensitive data leaks. |
| 95 | + |
| 96 | +## How to run inso with the `inso-nedb` fixture locally? |
| 97 | + |
| 98 | +Set the `--src` argument pointed to `packages/insomnia-smoke-test/fixtures/inso-nedb`: |
| 99 | + |
| 100 | +```bash |
| 101 | +# if installed globally |
| 102 | +inso --src <INSO_NEDB_PATH> |
| 103 | + |
| 104 | +# using the package bin |
| 105 | +./packages/insomnia-inso/bin/inso --src <INSO_NEDB_PATH> |
| 106 | + |
| 107 | +# using a binary |
| 108 | +./packages/insomnia-inso/binaries/insomnia-inso --src <INSO_NEDB_PATH> |
| 109 | +``` |
0 commit comments