adds markdown linting (#3931)

This commit is contained in:
Dimitri Mitropoulos
2021-08-26 23:44:01 -04:00
committed by GitHub
parent 7135114768
commit 422d5a809c
28 changed files with 478 additions and 292 deletions

View File

@@ -30,6 +30,8 @@ jobs:
run: npm run bootstrap
- name: Lint
run: npm run lint
- name: Lint Markdown
run: npm run lint:markdown
- name: Run tests
run: npm test
- name: Build for smoke tests

3
.gitignore vendored
View File

@@ -23,7 +23,6 @@ node_modules/
.idea
.DS_Store
*test-plugins
.vscode
graphql.config.json
.cache
.graphqlconfig
@@ -31,4 +30,4 @@ schema.graphql
packages/insomnia-smoke-test/screenshots
*.tsbuildinfo
dist
.history
.history

27
.markdownlint.yaml Normal file
View File

@@ -0,0 +1,27 @@
# see https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md for docs
# Default state for all rules
default: true
# Path to configuration file to extend
extends: null
# MD004 - Unordered list style
# We want to use dashes consistently everywhere
MD004:
style: dash
# MD013 - Line length
# We do not want to artificially limit line lengh in a language like markdown because of the nature of the language's handling of whitespace. Line wrapping is just a fact of life in markdown and trying to impose the conventions of other languages on markdown is an impedance mismatch that leads to people thinking that whitespace in markdown is more representative of the rendered HTML than it really is.
MD013: false
# MD033 - Inline HTML
MD033:
allowed_elements:
- details # there is no markdown equivalent for accordions
- summary # there is no markdown equivalent for accordions
# MD029 - Ordered list item prefix
# Plain and simple, markdown parsers do not respect the numbering you use for ordered lists. It only leads to confusion and misconception to allow otherwise.
MD029:
style: one

15
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,15 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"yzhang.markdown-all-in-one",
"DavidAnson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [
]
}

View File

@@ -1,47 +1,18 @@
# Code of Conduct
Like the technical community as a whole, the Insomnia community is made up of a mixture
of professionals and volunteers from all over the world, working on every aspect of the
mission including mentorship, teaching, and connecting people.
Like the technical community as a whole, the Insomnia community is made up of a mixture of professionals and volunteers from all over the world, working on every aspect of the mission including mentorship, teaching, and connecting people.
Diversity is a huge priority, but it can also lead to communication issues and
unhappiness. To that end, we have a few ground rules that we ask people to adhere to. This
code applies equally to founders, mentors and those seeking help and guidance.
Diversity is a huge priority, but it can also lead to communication issues and unhappiness. To that end, we have a few ground rules that we ask people to adhere to. This code applies equally to founders, mentors and those seeking help and guidance. This isnt an exhaustive list of things that you cant do. Rather, take it in the spirit in which its intended - a guide to make it easier to enrich all of us and the technical communities in which we participate.
This isnt an exhaustive list of things that you cant do. Rather, take it in the spirit
in which its intended - a guide to make it easier to enrich all of us and the technical
communities in which we participate.
This code of conduct applies to all spaces managed by the Insomnia project, including Slack, the issue tracker, and any other forums created for the project which the community uses for communication. In addition, violations of this code outside these spaces may affect a person's ability to participate within them.
This code of conduct applies to all spaces managed by the Insomnia project, including Slack,
the issue tracker, and any other forums created for the project which the community uses
for communication. In addition, violations of this code outside these spaces may affect
a person's ability to participate within them.
If you believe someone is violating the code of conduct, we ask that you report it by
emailing [support@insomnia.rest](mailto:support@insomnia.rest). For more details
please see our Reporting Guidelines
If you believe someone is violating the code of conduct, we ask that you report it by emailing [support@insomnia.rest](mailto:support@insomnia.rest). For more details please see our Reporting Guidelines
- **Be friendly and patient.**
- **Be welcoming.** We strive to be a community that welcomes and supports people of all
backgrounds and identities. This includes, but is not limited to members of any race,
ethnicity, culture, national origin, colour, immigration status, social and economic
class, educational level, sex, sexual orientation, gender identity and expression, age,
size, family status, political belief, religion, and mental and physical ability.
- **Be considerate.** Your work will be used by other people, and you in turn will
depend on the work of others. Any decision you take will affect users and colleagues,
and you should take those consequences into account when making decisions. Remember
that we're a world-wide community, so you might not be communicating in someone
else's primary language.
- **Be respectful.** Not all of us will agree all the time, but disagreement is no
excuse for poor behavior and poor manners. We might all experience some frustration
now and then, but we cannot allow that frustration to turn into a personal attack.
Its important to remember that a community where people feel uncomfortable or
threatened is not a productive one. Members of the Insomnia community should be respectful
when dealing with other members as well as with people outside the Insomnia community.
- **Be careful in the words that you choose.** We are a community of professionals,
and we conduct ourselves professionally. Be kind to others. Do not insult or put
down other participants. Harassment and other exclusionary behavior isn't acceptable.
This includes, but is not limited to:
- **Be welcoming.** We strive to be a community that welcomes and supports people of all backgrounds and identities. This includes, but is not limited to members of any race, ethnicity, culture, national origin, colour, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability.
- **Be considerate.** Your work will be used by other people, and you in turn will depend on the work of others. Any decision you take will affect users and colleagues, and you should take those consequences into account when making decisions. Remember that we're a world-wide community, so you might not be communicating in someone else's primary language.
- **Be respectful.** Not all of us will agree all the time, but disagreement is no excuse for poor behavior and poor manners. We might all experience some frustration now and then, but we cannot allow that frustration to turn into a personal attack. Its important to remember that a community where people feel uncomfortable or threatened is not a productive one. Members of the Insomnia community should be respectful when dealing with other members as well as with people outside the Insomnia community.
- **Be careful in the words that you choose.** We are a community of professionals, and we conduct ourselves professionally. Be kind to others. Do not insult or put down other participants. Harassment and other exclusionary behavior isn't acceptable. This includes, but is not limited to:
- Violent threats or language directed against another person.
- Discriminatory jokes and language.
- Posting sexually explicit or violent material.
@@ -50,17 +21,9 @@ please see our Reporting Guidelines
- Unwelcome sexual attention.
- Advocating for, or encouraging, any of the above behavior.
- Repeated harassment of others. In general, if someone asks you to stop, then stop.
- **When we disagree, try to understand why.** Disagreements, both social and technical,
happen all the time and Insomnia is no exception. It is important that we resolve
disagreements and differing views constructively. Remember that were different. The
strength of Insomnia comes from its varied community, people from a wide range of backgrounds.
Different people have different perspectives on issues. Being unable to understand why
someone holds a viewpoint doesnt mean that theyre wrong. Dont forget that it is human
to err and blaming each other doesnt get us anywhere. Instead, focus on helping to resolve
issues and learning from mistakes.
- **When we disagree, try to understand why.** Disagreements, both social and technical, happen all the time and Insomnia is no exception. It is important that we resolve disagreements and differing views constructively. Remember that were different. The strength of Insomnia comes from its varied community, people from a wide range of backgrounds. Different people have different perspectives on issues. Being unable to understand why someone holds a viewpoint doesnt mean that theyre wrong. Dont forget that it is human to err and blaming each other doesnt get us anywhere. Instead, focus on helping to resolve issues and learning from mistakes.
Original text courtesy of the
[Speak Up! project](http://web.archive.org/web/20141109123859/http://speakup.io/coc.html).
Original text courtesy of the [Speak Up! project](http://web.archive.org/web/20141109123859/http://speakup.io/coc.html).
## Questions?

View File

@@ -1,63 +1,41 @@
# Contributing to this project
Please take a moment to review this document in order to make the contribution
process easy and effective for everyone involved.
Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.
## Using the issue tracker
[GitHub Issues](https://github.com/kong/insomnia/issues) is the preferred channel
for [bug reports](#bug-reports), [features requests](#feature-requests)
and [submitting pull requests](#pull-requests).
[GitHub Issues](https://github.com/kong/insomnia/issues) is the preferred channel for [bug reports](#bug-reports), [features requests](#feature-requests) and [submitting pull requests](#pull-requests).
Please respect the following restrictions:
- Please **do not** use the issue tracker for personal support requests (email
[support@insomnia.rest](mailto:support@insomnia.rest)).
- Please **do not** use the issue tracker for personal support requests (email [support@insomnia.rest](mailto:support@insomnia.rest)).
- Please **do not** derail or troll issues. Keep the discussion on topic and
respect the opinions of others.
- Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others.
## Bug Reports
A bug is a _demonstrable problem_ that is caused by the code in the repository.
Good bug reports are extremely helpful - thank you!
A bug is a _demonstrable problem_ that is caused by the code in the repository. Good bug reports are extremely helpful - thank you!
Guidelines for bug reports:
1. **Use the GitHub issue search** — check if the issue has already been
reported.
1. **Use the GitHub issue search** — check if the issue has already been reported.
1. **Check if the issue has been fixed** — try to reproduce it using the latest `master` or development branch in the repository.
1. **Demonstrate the problem** — provide clear steps that can be reproduced.
2. **Check if the issue has been fixed** — try to reproduce it using the
latest `master` or development branch in the repository.
3. **Demonstrate the problem** — provide clear steps that can be reproduced.
A good bug report should not leave others needing to chase you up for more
information. Please try to be as detailed as possible in your report. What is
your environment? What steps will reproduce the issue? What OS experienced the
problem? What would you expect to be the outcome? All these details will help
to fix any potential bugs.
A good bug report should not leave others needing to chase you up for more information. Please try to be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What OS experienced the problem? What would you expect to be the outcome? All these details will help to fix any potential bugs.
## Feature Requests
Feature requests are welcome. But take a moment to find out whether your idea
fits with the scope and aims of the project. It's up to _you_ to make a strong
case to convince the project's developers of the merits of this feature. Please
provide as much detail and context as possible.
Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to _you_ to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.
## Pull Requests
Good pull requests (patches, improvements, new features) are a fantastic
help. They should remain focused in scope and avoid containing unrelated
commits.
Good pull requests (patches, improvements, new features) are a fantastic help. They should remain focused in scope and avoid containing unrelated commits.
**Please ask first** before embarking on any significant pull request (e.g.
implementing features, refactoring code, porting to a different language),
otherwise, you risk spending a lot of time working on something that might
not get accepted into the project.
**Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code, porting to a different language), otherwise, you risk spending a lot of time working on something that might not get accepted into the project.
**IMPORTANT**: By submitting a patch, you agree to allow the project owner to
license your work under the same license as that used by the project.
**IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by the project.
## Contributor T-shirt
If your pull request to [Kong/insomnia](https://github.com/Kong/insomnia) was accepted, and it fixes a bug, adds functionality, or makes it significantly easier to use or understand Insomnia, congratulations! You are eligible to receive the very special contributor t-shirt! Go ahead and fill out the [contributor submission form](https://goo.gl/forms/5w6mxLaE4tz2YM0L2).

View File

@@ -11,32 +11,26 @@ to provide access to operating system features.
There are a few more technologies and tools worth mentioning:
- [`React`](https://reactjs.org/) is the library used for all UI components.
- [`styled-components`](https://styled-components.com/) and [`Less`](http://lesscss.org/) are used
for styling UI components.
- [`Electron Builder`](https://github.com/electron-userland/electron-builder) is used to help build,
sign, and package Insomnia for distribution.
- [`Flow`](https://flow.org/) is used for adding types to the codebase. Not everything is Flow but
all new code should be typed with Flow.
- [`styled-components`](https://styled-components.com/) and [`Less`](http://lesscss.org/) are used for styling UI components.
- [`Electron Builder`](https://github.com/electron-userland/electron-builder) is used to help build, sign, and package Insomnia for distribution.
- [`Flow`](https://flow.org/) is used for adding types to the codebase. Not everything is Flow but all new code should be typed with Flow.
- [`Webpack`](https://webpack.js.org/) is the bundler used to compile the JS/Less/babel/etc
- [`libcurl`](https://curl.se/libcurl/) is the library that Insomnia uses to make requests. Libcurl is the HTTP client of choice because it allows the deepest amount of debuggability and control of HTTP requests.
- [`nedb`](https://github.com/louischatriot/nedb) a local in-memory database.
- [`node-libcurl`](https://github.com/JCMais/node-libcurl) is a Node.js wrapper around the native libcurl library.
- [`Codemirror`](https://codemirror.net/) is a web-based, extendable, code editor used for
highlighting and linting of data formats like JSON, GraphQL, and XML.
- [`Codemirror`](https://codemirror.net/) is a web-based, extendable, code editor used for highlighting and linting of data formats like JSON, GraphQL, and XML.
- [`Commander.js`](https://github.com/tj/commander.js) is used for building the inso CLI.
## Project Structure
Insomnia uses [`lerna`](https://lerna.js.org/) to manage multiple npm packages within a single
repository. There are currently two package locations:
Insomnia uses [`lerna`](https://lerna.js.org/) to manage multiple npm packages within a single repository. There are currently two package locations:
- `/packages` contains related packages that are consumed by `insomnia-app` or externally.
- `/plugins` contains plugin packages that are included by default with the application.
## The `insomnia-app` Main Package
`/packages/insomnia-app` is the entry point for the app. All other packages are imported from this
one.
`/packages/insomnia-app` is the entry point for the app. All other packages are imported from this one.
There are a few notable directories inside of it:
@@ -58,8 +52,7 @@ Insomnia stores data in a few places:
- A local Redux store contains an in-memory copy of all database entities.
- Multiple React Context stores, defined in `/app/ui/context`.
*Eventually, Redux could/should be removed, which would both reduce memory overhead and simplify
the codebase. NeDB should essentially replace it*
> Note: Eventually, Redux could/should be removed, which would both reduce memory overhead and simplify the codebase. NeDB should essentially replace it
## Automated testing
@@ -67,6 +60,7 @@ We use [Jest](https://jestjs.io/) and [react-testing-library](https://testing-li
to write our unit tests, and [Spectron](https://www.electronjs.org/spectron) for integration tests.
Unit tests exist alongside the file under test. For example:
- `/app/common/database.js` contains the database business logic
- `/app/common/__tests__/database.test.js` contains the database tests
@@ -79,11 +73,7 @@ The structure for smoke tests is explained in the smoke testing package: [`packa
This is just a brief summary of Insomnia's current technical debt.
- Loading large responses (~20MB) can crash the app on weaker hardware.
- An in-memory duplicate of the local DB is stored in Redux, unnecessarily doubling memory usage. Moving
forward, Redux shouldn't need to be considered much and may be able to be removed eventually.
- Bundling `libcurl` (native module) has caused many weeks of headaches trying to get builds working
across Windows, Mac, and Linux. More expertise here is definitely needed.
- All input fields that support templating/autocomplete/etc are actually Codemirror instances. This
isn't really debt but may affect things going forward.
- Use of `libcurl` means Insomnia can't run in a web browser and can't support bidirectional socket
communication.
- An in-memory duplicate of the local DB is stored in Redux, unnecessarily doubling memory usage. Moving forward, Redux shouldn't need to be considered much and may be able to be removed eventually.
- Bundling `libcurl` (native module) has caused many weeks of headaches trying to get builds working across Windows, Mac, and Linux. More expertise here is definitely needed.
- All input fields that support templating/autocomplete/etc are actually Codemirror instances. This isn't really debt but may affect things going forward.
- Use of `libcurl` means Insomnia can't run in a web browser and can't support bidirectional socket communication.

View File

@@ -25,23 +25,18 @@ For more generic product questions and feedback, join the [Slack Team](https://c
## Contributing
Please read through our [contributing guidelines](CONTRIBUTING.md) and [code of conduct](CODE_OF_CONDUCT.md). Included are directions
for opening issues, coding standards, and notes on development.
Please read through our [contributing guidelines](CONTRIBUTING.md) and [code of conduct](CODE_OF_CONDUCT.md). Included are directions for opening issues, coding standards, and notes on development.
## Developing
Development on Insomnia can be done on Mac, Windows, or Linux as long as you have
[Node.js](https://nodejs.org) and [Git](https://git-scm.com/). See the `.nvmrc` file located in the project for the correct Node version.
Development on Insomnia can be done on Mac, Windows, or Linux as long as you have [Node.js](https://nodejs.org) and [Git](https://git-scm.com/). See the `.nvmrc` file located in the project for the correct Node version.
<details>
<summary>Initial Dev Setup</summary>
This repository is structured as a monorepo and contains many Node.JS packages. Each package has
its own set of commands, but the most common commands are available from the
root [`package.json`](package.json) and can be accessed using the `npm run ...` command. Here
are the only three commands you should need to start developing on the app.
This repository is structured as a monorepo and contains many Node.JS packages. Each package has its own set of commands, but the most common commands are available from the root [`package.json`](package.json) and can be accessed using the `npm run ...` command. Here are the only three commands you should need to start developing on the app.
```bash
```shell
# Install and Link Dependencies
npm run bootstrap
@@ -52,9 +47,9 @@ npm test
npm run app-start
```
If you are on Linux, you may need to install the following supporting packages
If you are on Linux, you may need to install the following supporting packages
```bash
```shell
# Update library
sudo apt-get update
@@ -67,7 +62,8 @@ sudo apt-get install build-essential
```
Also on Linux, if Electron is failing during the bootstrap process, run the following
```bash
```shell
# Clear Electron install conflicts
rm -rf ~/.cache/electron
```
@@ -79,8 +75,7 @@ If you are on Windows and have problems, you may need to install [Windows Build
<details>
<summary>Editor Requirements</summary>
You can use any editor you'd like, but make sure to have support/plugins for
the following tools:
You can use any editor you'd like, but make sure to have support/plugins for the following tools:
- [ESLint](http://eslint.org/) For catching syntax problems and common errors
- [JSX Syntax](https://facebook.github.io/react/docs/jsx-in-depth.html) For React components

204
package-lock.json generated
View File

@@ -12992,6 +12992,15 @@
"integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=",
"dev": true
},
"linkify-it": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.2.tgz",
"integrity": "sha512-gDBO4aHNZS6coiZCKVhSNh43F9ioIL4JwRjLZPkoLIY4yZFwg264Y5lu2x6rb1Js42Gh6Yqm2f6L2AJcnkzinQ==",
"dev": true,
"requires": {
"uc.micro": "^1.0.1"
}
},
"load-json-file": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz",
@@ -13261,6 +13270,189 @@
"object-visit": "^1.0.0"
}
},
"markdown-it": {
"version": "12.0.4",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.0.4.tgz",
"integrity": "sha512-34RwOXZT8kyuOJy25oJNJoulO8L0bTHYWXcdZBYZqFnjIy3NgjeoM3FmPXIOFQ26/lSHYMr8oc62B6adxXcb3Q==",
"dev": true,
"requires": {
"argparse": "^2.0.1",
"entities": "~2.1.0",
"linkify-it": "^3.0.1",
"mdurl": "^1.0.1",
"uc.micro": "^1.0.5"
},
"dependencies": {
"argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true
},
"entities": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz",
"integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==",
"dev": true
}
}
},
"markdownlint": {
"version": "0.23.1",
"resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.23.1.tgz",
"integrity": "sha512-iOEwhDfNmq2IJlaA8mzEkHYUi/Hwoa6Ss+HO5jkwUR6wQ4quFr0WzSx+Z9rsWZKUaPbyirIdL1zGmJRkWawr4Q==",
"dev": true,
"requires": {
"markdown-it": "12.0.4"
}
},
"markdownlint-cli2": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/markdownlint-cli2/-/markdownlint-cli2-0.2.0.tgz",
"integrity": "sha512-/MIaG2MOlm39SBApQbeHK847/bgX6FfUPZMpCzA2UMYXR8NTwzTdjQAXjjLBK6+zG52GWKyhdmBKobkhLnq8wQ==",
"dev": true,
"requires": {
"globby": "~11.0.4",
"markdownlint": "~0.23.1",
"markdownlint-cli2-formatter-default": "^0.0.2",
"markdownlint-rule-helpers": "~0.14.0",
"micromatch": "~4.0.4",
"strip-json-comments": "~3.1.1",
"yaml": "~1.10.2"
},
"dependencies": {
"@nodelib/fs.stat": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz",
"integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==",
"dev": true
},
"array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"dev": true
},
"braces": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true,
"requires": {
"fill-range": "^7.0.1"
}
},
"dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
"dev": true,
"requires": {
"path-type": "^4.0.0"
}
},
"fast-glob": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.7.tgz",
"integrity": "sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==",
"dev": true,
"requires": {
"@nodelib/fs.stat": "^2.0.2",
"@nodelib/fs.walk": "^1.2.3",
"glob-parent": "^5.1.2",
"merge2": "^1.3.0",
"micromatch": "^4.0.4"
}
},
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dev": true,
"requires": {
"to-regex-range": "^5.0.1"
}
},
"glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dev": true,
"requires": {
"is-glob": "^4.0.1"
}
},
"globby": {
"version": "11.0.4",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz",
"integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==",
"dev": true,
"requires": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.1.1",
"ignore": "^5.1.4",
"merge2": "^1.3.0",
"slash": "^3.0.0"
}
},
"ignore": {
"version": "5.1.8",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz",
"integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==",
"dev": true
},
"is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true
},
"micromatch": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz",
"integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==",
"dev": true,
"requires": {
"braces": "^3.0.1",
"picomatch": "^2.2.3"
}
},
"picomatch": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz",
"integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==",
"dev": true
},
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"requires": {
"is-number": "^7.0.0"
}
}
}
},
"markdownlint-cli2-formatter-default": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/markdownlint-cli2-formatter-default/-/markdownlint-cli2-formatter-default-0.0.2.tgz",
"integrity": "sha512-jIz1X3SIC8sX4NDFqQFUXL+JEtfnDoN4i+xocEu+etcxGX455pHb6sx86f/yVk4mKJ2o7aNe2ydSx9an22BfBg==",
"dev": true
},
"markdownlint-rule-helpers": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.14.0.tgz",
"integrity": "sha512-vRTPqSU4JK8vVXmjICHSBhwXUvbfh/VJo+j7hvxqe15tLJyomv3FLgFdFgb8kpj0Fe8SsJa/TZUAXv7/sN+N7A==",
"dev": true
},
"mdurl": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
"integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=",
"dev": true
},
"meow": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/meow/-/meow-7.0.1.tgz",
@@ -16850,6 +17042,12 @@
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==",
"dev": true
},
"uc.micro": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz",
"integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==",
"dev": true
},
"uglify-js": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.10.0.tgz",
@@ -17511,6 +17709,12 @@
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
"dev": true
},
"yaml": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz",
"integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==",
"dev": true
},
"yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",

View File

@@ -13,6 +13,7 @@
"scripts": {
"build": "lerna run build --parallel",
"lint": "lerna run lint --stream --no-bail",
"lint:markdown": "markdownlint-cli2 \"**/*.md\" \"#**/node_modules\"",
"lint:fix": "lerna run lint:fix --stream --no-bail",
"bootstrap": "npm install && lerna bootstrap && lerna run --stream bootstrap",
"version": "lerna version --exact --preid beta --force-publish",
@@ -70,6 +71,7 @@
"eslint-plugin-standard": "^5.0.0",
"jest": "^26.6.3",
"lerna": "^3.22.0",
"markdownlint-cli2": "^0.2.0",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.6",
"type-fest": "^1.0.2",

View File

@@ -2,13 +2,14 @@
`insomnia-components` is a React component library of UI elements needed to build [Insomnia](https://insomnia.rest). Explore the components via [Storybook](https://storybook.insomnia.rest)!
#### SVGs
## SVGs
We use [SVGR](https://react-svgr.com) on the source SVGs to minify and convert them to React components. This conversion happens during `npm run bootstrap`.
The generated icons can automatically be bound to the theme library built into Insomnia, by following a few rules. In the source SVG:
1. All background colors should be black (#000)
2. All foreground colors should be white (#FFF)
1. All foreground colors should be white (#FFF)
SVGR converts these colors to `fill=''` and `fill='currentColor'` respectively. These icons are exposed via `svg-icon.js`, which sets the css `fill` and `color` of the SVG according to the required theme.

View File

@@ -2,4 +2,4 @@
[![Npm Version](https://img.shields.io/npm/v/insomnia-cookies.svg)](https://www.npmjs.com/package/insomnia-cookies)
Various utility functions for interacting with cookies and cookie jars.
Various utility functions for interacting with cookies and cookie jars.

View File

@@ -2,27 +2,30 @@
[![Npm Version](https://img.shields.io/npm/v/insomnia-importers.svg)](https://www.npmjs.com/package/insomnia-importers)
This repository contains converters to translate popular HTTP data formats to
Insomnia v3 format.
This repository contains converters to translate popular HTTP data formats to the latest Insomnia format.
- Insomnia v1 and v2
Supported import types include:
- Insomnia v1, v2, v3, v4
- Postman v2.0
- cURL
- Postman Environment
- HTTP Archive Format 1.2 (HAR)
- cURL
- Swagger 2.0
- OpenAPI 3.0
- WSDL
## Installation
For usage on **command line**, install globally
```bash
```shell
npm install -g insomnia-importers
```
For programmatic usage, install in project
```bash
```shell
npm install insomnia-importers
```
@@ -34,8 +37,8 @@ insomnia-import /path/to/har-export.json > insomnia-export.json
## Programmatic Usage
```javascript
const importers = require('insomnia-importers');
```ts
import { importers } from 'insomnia-importers';
(async function () {
// Convert a Curl command

View File

@@ -1,4 +1,5 @@
<!-- markdownlint-disable heading-style first-line-h1 -->
<!-- markdownlint-disable no-inline-html -->
<div align="center">
<br />
<br />
@@ -13,39 +14,43 @@
<img src="https://raw.githubusercontent.com/Kong/insomnia/develop/packages/insomnia-inso/assets/demo.gif" alt=""/>
<br />
</div>
<br />
<!-- markdownlint-enable no-inline-html -->
Table of Contents
=================
<!-- omit in toc -->
## Table of Contents
* [Data source](#data-source)
* [The `[identifier]` argument](#the-identifier-argument)
* [Global options](#global-options)
* [Commands](#commands)
+ [ `inso generate config` ](#-inso-generate-config-identifier)
+ [ `inso lint spec` ](#-inso-lint-spec-identifier)
+ [ `inso run test` ](#-inso-run-test-identifier)
+ [ `inso export spec` ](#-inso-export-spec-identifier)
+ [ `inso script` ](#-inso-script-name)
* [Configuration](#configuration)
* [Git Bash](#git-bash)
* [Continuous Integration](#continuous-integration)
* [Development](#development)
- [Data source](#data-source)
- [The `[identifier]` argument](#the-identifier-argument)
- [Global options](#global-options)
- [Commands](#commands)
- [`$ inso generate config [identifier]`](#-inso-generate-config-identifier)
- [`$ inso lint spec [identifier]`](#-inso-lint-spec-identifier)
- [`$ inso run test [identifier]`](#-inso-run-test-identifier)
- [`$ inso export spec [identifier]`](#-inso-export-spec-identifier)
- [`$ inso script <name>`](#-inso-script-name)
- [Configuration](#configuration)
- [Options](#options)
- [Scripts](#scripts)
- [Git Bash](#git-bash)
- [Continuous Integration](#continuous-integration)
- [Development](#development)
# Data source
## Data source
`inso` will first try to find a `.insomnia` directory in it's working directory. This directory is generated in a git repository when using git sync in Insomnia. When `inso` is used in a CI environment, it will always run against the `.insomnia` directory.
If `inso` cannot find the `.insomnia` directory, it will try to run against the Insomnia app data directory (if found). You can override both the working directory, and the app data directory, using the `--workingDir` and `--appDataDir` global options.
# The `[identifier]` argument
## The `[identifier]` argument
Typically, Insomnia database id's are quite long, for example: `wrk_012d4860c7da418a85ffea7406e1292a` . When specifying an identifier for `inso` , similar to Git hashes, you may choose to concatenate and use the first x characters (for example, `wrk_012d486` ), which is very likely to be unique. If in the rare chance the short id is _not_ unique against the data, `inso` will inform as such.
Additionally, if the `[identifier]` argument is omitted from the command, `inso` will search in the database for the information it needs, and prompt the user. Prompts can be disabled with the `--ci` global option.
![](https://raw.githubusercontent.com/Kong/insomnia/develop/packages/insomnia-inso/assets/ci-demo.gif)
![ci-demo](https://raw.githubusercontent.com/Kong/insomnia/develop/packages/insomnia-inso/assets/ci-demo.gif)
# Global options
## Global options
`$ inso [global options] [command]`
|Global option|Alias|Description|
@@ -59,9 +64,9 @@ Additionally, if the `[identifier]` argument is omitted from the command, `inso`
| `--version` | `-v` |output the version number|
| `--help` | `-h` |display help for a command|
# Commands
## Commands
## `$ inso generate config [identifier]`
### `$ inso generate config [identifier]`
Similar to the Kong [Kubernetes](https://insomnia.rest/plugins/insomnia-plugin-kong-kubernetes-config) and [Declarative](https://insomnia.rest/plugins/insomnia-plugin-kong-declarative-config) config plugins for Insomnia, this command can generate configuration from an API specification, using [openapi-2-kong](https://www.npmjs.com/package/openapi-2-kong).
@@ -73,70 +78,73 @@ Similar to the Kong [Kubernetes](https://insomnia.rest/plugins/insomnia-plugin-k
| `--output <path>` | `-o` |save the generated config to a file in the working directory|
| `--tags <tags>` | |comma separated list of tags to apply to each entity|
### Examples
<!-- omit in toc -->
#### Generate Config Examples
When running in the <a href="https://github.com/Kong/insomnia/tree/develop/packages/insomnia-inso/src/db/fixtures/git-repo">git-repo</a> directory
When running in the [git-repo](https://github.com/Kong/insomnia/tree/develop/packages/insomnia-inso/src/db/fixtures/git-repo) directory
Not specifying any arguments will prompt
``` sh
```shell
inso generate config
```
Scope by the document name or id
``` sh
```shell
inso generate config spc_46c5a4 --type declarative
inso generate config "Sample Specification" --type kubernetes
```
Scope by a file on the filesystem
``` sh
```shell
inso generate config spec.yaml
inso generate config spec.yaml --workingDir another/dir
```
Add tags
```sh
```shell
inso generate config spec.yaml --tags first
inso generate config spec.yaml --tags "first,second"
```
Output to file
``` sh
```shell
inso generate config spc_46c5a4 --output output.yaml
inso generate config spc_46c5a4 > output.yaml
```
</details>
## `$ inso lint spec [identifier]`
### `$ inso lint spec [identifier]`
Insomnia has the ability to lint and validate your OpenAPI specification as you write it. This command adds the same functionality to `inso` , in order to run linting during CI workflows. Lint results will be printed to the console, and `inso` will exit with an appropriate exit code.
**`[identifier]`**: this can be a **document name, or id**.
### Examples
<!-- omit in toc -->
#### Lint Spec Examples
When running in the <a href="https://github.com/Kong/insomnia/tree/develop/packages/insomnia-inso/src/db/fixtures/git-repo">git-repo</a> directory
When running in the [git-repo](https://github.com/Kong/insomnia/tree/develop/packages/insomnia-inso/src/db/fixtures/git-repo) directory
Not specifying any arguments will prompt
``` sh
```shell
inso lint spec
```
Scope by the document name or id
``` sh
```shell
inso lint spec spc_46c5a4
inso lint spec "Sample Specification"
```
## `$ inso run test [identifier]`
### `$ inso run test [identifier]`
API unit tests can be written and run within Insomnia, and this command adds the functionality to execute those unit tests via the command line, very useful for a CI environment. `inso` will report on test results, and exit with an appropriate exit code.
@@ -153,47 +161,48 @@ The test runner is built on top of Mocha, thus many of the options behave as the
| `--keepFile` | | do not delete the generated test file (useful for debugging)|
| `--disableCertValidation` | | disable certificate validation for requests with SSL|
### Examples
<!-- omit in toc -->
#### Run Test Examples
When running in the <a href="https://github.com/Kong/insomnia/tree/develop/packages/insomnia-inso/src/db/fixtures/git-repo">git-repo</a> directory
When running in the [git-repo](https://github.com/Kong/insomnia/tree/develop/packages/insomnia-inso/src/db/fixtures/git-repo) directory
Not specifying any arguments will prompt
``` sh
```shell
inso run test
```
Scope by the document name or id
``` sh
```shell
inso run test "Sample Specification" --env "OpenAPI env"
inso run test spc_46c5a4 --env env_env_ca046a
```
Don't validate SSL certificates
``` sh
```shell
inso run test "Sample Specification" --env "OpenAPI env" --disableSSL
inso run test spc_46c5a4 --env env_env_ca046a --disableSSL
```
Scope by the a test suite name or id
``` sh
```shell
inso run test "Math Suite" --env "OpenAPI env"
inso run test uts-7f0f85 --env env_env_ca046a
```
Scope by test name regex, and control test running and reporting
``` sh
```shell
inso run test "Sample Specification" --testNamePattern Math --env env_env_ca046a
inso run test spc_46c5a4 --reporter progress --bail --keepFile
```
More examples: [#2338](https://github.com/Kong/insomnia/pull/2338).
## `$ inso export spec [identifier]`
### `$ inso export spec [identifier]`
This command will extract and export the raw OpenAPI specification from the data store. If the `--output` option is not specified, the spec will print to console.
@@ -203,39 +212,41 @@ This command will extract and export the raw OpenAPI specification from the data
|- |- |- |
| `--output <path>` | `-o` |save the generated config to a file in the working directory|
### Examples
<!-- omit in toc -->
#### Export Spec Examples
When running in the <a href="https://github.com/Kong/insomnia/tree/develop/packages/insomnia-inso/src/db/fixtures/git-repo">git-repo</a> directory
When running in the [git-repo](https://github.com/Kong/insomnia/tree/develop/packages/insomnia-inso/src/db/fixtures/git-repo) directory
Not specifying any arguments will prompt
``` sh
```shell
inso export spec
```
Scope by the document name or id
``` sh
```shell
inso export spec spc_46c5a4
inso export spec "Sample Specification"
```
Output to file
``` sh
```shell
inso export spec spc_46c5a4 --output output.yaml
inso export spec spc_46c5a4 > output.yaml
```
## `$ inso script <name>`
### `$ inso script <name>`
The `inso` [config file](#configuration) supports scripts, akin to NPM scripts defined in a `package.json` file. These scripts can be executed by `inso` by running `inso script <name>` , or simply `inso <name>` as this is the default command. Any options passed to this command, will be forwarded to the script being executed.
### Examples
<!-- omit in toc -->
#### Script Examples
When running in the <a href="https://github.com/Kong/insomnia/tree/develop/packages/insomnia-inso/src/db/fixtures/git-repo">git-repo</a> directory, with the following inso config file.
When running in the [git-repo](https://github.com/Kong/insomnia/tree/develop/packages/insomnia-inso/src/db/fixtures/git-repo) directory, with the following inso config file.
``` yaml
```yaml
# .insorc.yaml
scripts:
lint: lint spec "Sample Specification"
@@ -246,56 +257,61 @@ scripts:
Run commands with or without the `script` prefix
``` bash
```shell
inso script gen-conf
inso gen-conf
```
If a conflict exists with another command (eg. `lint` ), you must prefix with `script`
``` bash
```shell
inso script lint
inso lint # will not work
```
Any options passed during script invocation will be forwarded to the script
``` bash
```shell
inso gen-conf # generates declarative config (default)
inso gen-conf:k8s # generates kubernetes config
inso gen-conf:k8s -t declarative # generates declarative config
inso gen-conf:k8s -o output.yaml # generates kubernetes config to output.yaml
```
# Configuration
## Configuration
Inso CLI can be configured with a configuration file, allowing you to specify options and scripts. For example, when running in a CI environment, you may choose to specify the steps as scripts in a config file, so that the same commands can be run both locally and in CI.
Inso CLI uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for config file management, meaning any of the following items found in the working tree are automatically used:
+ `inso` property in `package.json`
+ `.insorc` file in JSON or YAML format
+ `.insorc.json` file
+ `.insorc.yaml` , `.insorc.yml` , or `.insorc.js` file
+ `inso.config.js` file exporting a JS object
- `inso` property in `package.json`
- `.insorc` file in JSON or YAML format
- `.insorc.json` file
- `.insorc.yaml` , `.insorc.yml` , or `.insorc.js` file
- `inso.config.js` file exporting a JS object
Alternatively, you can use the `--config <file>` global option to specify an exact file to use, if it exists outside the directory tree.
**Options**
### Options
Options from the config file are combined with option defaults and any explicit overrides specified in script or command invocations. This combination is in priority order: command options > config file options > default options.
Options from the config file are combined with option defaults and any explicit overrides specified in script or command invocations. This combination is in priority order:
1. command options
1. config file options
1. default options
Any options specified in this file will apply to all scripts and manual commands. You can override these options by specifying them explicitly, when invoking a script or command.
Only [global options](#global-options) can be set in the config file.
**Scripts**
### Scripts
Scripts can have any name, and can be nested. Scripts must be prefixed with `inso` (see example below). Each command behaves the same way, as described in the sections above.
### Example
<!-- omit in toc -->
#### Script Example
``` yaml
```yaml
# .insorc.yaml
options:
@@ -314,19 +330,19 @@ scripts:
gen-conf:k8s: inso gen-conf --type kubernetes
```
# Git Bash
## Git Bash
Git Bash on Windows is not interactive and therefore prompts from `inso` will not work as expected. You may choose to specify the identifiers for each command explicitly, or run `inso` using `winpty` :
```
```shell
winpty inso.cmd generate config
```
# Continuous Integration
## Continuous Integration
`inso` has been designed to run in a CI environment, disabling prompts and providing exit codes to pass or fail the CI workflow accordingly. An example workflow run in Github Actions is as follows. This example will checkout > install Node.js > install Inso CLI > run linting > run unit tests > generate configuration. If any of these steps fail, the GH workflow will as well.
``` yaml
```yaml
# .github/workflows/test.yml
name: Test
@@ -350,8 +366,8 @@ jobs:
run: inso generate config "Insomnia Demo" --type declarative --ci
```
# Development
## Development
* Bootstrap: `npm run bootstrap`
* Start the compiler in watch mode: `npm run start`
* Run: `./bin/inso -v`
- Bootstrap: `npm run bootstrap`
- Start the compiler in watch mode: `npm run start`
- Run: `./bin/inso -v`

View File

@@ -6,13 +6,13 @@ Tests for the Electron app are written using [Spectron](https://github.com/elect
## Structure
|Folder|Purpose|
|-|-|
| `/cli` |tests for inso|
| `/core` |tests for Insomnia |
| `/server` |Express server used by the tests|
| `/fixtures` |data used by tests and the server|
| `/modules` |logical grouping of functionality (eg. `modals` , `tabs` , `settings` , `home` )|
| Folder | Purpose |
| - | - |
| `/cli` | tests for inso |
| `/core` | tests for Insomnia |
| `/server` | Express server used by the tests |
| `/fixtures` | data used by tests and the server |
| `/modules` | logical grouping of functionality (eg. `modals` , `tabs` , `settings` , `home` ) |
## How to run
@@ -20,21 +20,21 @@ There are several ways to run a test but the first step is to bootstrap and buil
From the root of this repository:
``` sh
```shell
npm run bootstrap # Install packages and compile inso
npm run app-build:smoke # Compile Insomnia
```
You can then run the smoke tests, again from the root:
``` sh
```shell
npm run test:smoke:cli # Run CLI tests
npm run test:smoke:build # Run Insomnia tests
```
Sometimes, you might need to run tests against a _packaged_ application. A packaged application is the final artifact which bundles all of the various resources together, and is created for distribution in the form of a `.dmg` or `.exe`, etc. Packaging takes longer to do and is only required for edge cases (such as a <!-- TODO(TSCONVERSION) update this link -->[plugin installation](https://github.com/Kong/insomnia/blob/357b8f05f89fd5c07a75d8418670abe37b2882dc/packages/insomnia-smoke-test/designer/app.test.js#L36)), so we typically run tests against a build. To run packaged tests, from the root:
``` sh
```shell
npm run app-package:smoke # Package Insomnia
npm run test:smoke:package # Run Insomnia tests
```
@@ -46,7 +46,8 @@ Each of the above commands will automatically run the Express server, so you do
When writing tests, it is recommended to use the scripts in this project directly (instead of from the root, as per the section above). After building and/or packaging your application under test, it will be available under `packages/insomnia-app/{build|dist}` and you can begin writing your test.
In order to run tests for development, open two terminal tabs in `packages/insomnia-smoke-test`:
```sh
```shell
# In the first tab, serve the Express API
npm run serve
@@ -64,12 +65,15 @@ You may also need to run a test multiple times. You can focus a particular test
## General guidelines
### Data
Individual tests will automatically run against a clean Insomnia data directory to keep data isolated.
### Dependencies
A test should not depend on any external services unless absolutely necessary. If a particular endpoint is required (eg. for authentication or a specific content type), implement a new endpoint in `/server`.
### Element selection
Spectron is built heavily on top of WebdriverIO, and WebdriverIO's `browser` object is available under `app.client` ([docs](https://github.com/electron-userland/spectron#client)). This is the primary API you will need for user interactions, see examples with existing tests.
Through WebdriverIO you can use a host of CSS or React selectors. There is no clear guideline about which selector to use, but whichever approach is used it must favour stability and be understandable.
@@ -77,6 +81,7 @@ Through WebdriverIO you can use a host of CSS or React selectors. There is no cl
There are trade-offs with each selector approach but it's important to know how generic or specific a particular component or CSS class is, in order to ensure that the correct element is always selected as the application evolves.
#### Select by component and props
Sometimes selecting by a React component and props, directly from `app.client` is the cleanest approach, as the following two examples show:
```ts
@@ -101,6 +106,7 @@ export const clickFolderByName = async (app, name) => {
You can find a list of component names in `modules/component-names.ts`.
#### Scoping
It is important to scope an element to an appropriate ancestor. In a way the selector becomes self-documenting, but also ensures stability as the UI evolves.
In the following example, it is possible for multiple buttons which match the `button#enabled` selector to exist on the page. By chaining a React and CSS selector, we can ensure the test runner will always click the expected button within the `BasicAuth` component.
@@ -127,11 +133,13 @@ export const expect200 = async (app: Application) => {
```
### Interactions
As is common with all smoke testing frameworks, before interacting with an element (click, hover, etc) it is generally good to check whether you _can_ interact with it. For instance, clicking a button will fail if the button is not yet clickable.
Sometimes you will need to add explicit pauses to allow for UI to refresh or database writes to occur (`await app.client.pause(500)`). Try to keep these to a minimum, though, exploring all other avenues first, such as WebdriverIO's `waitFor*` functions. Avoiding explicit waits ensures each test runs in the short amount of time.
When typing in the url bar for HTTP requests, we first wait for it to exist on the page before clicking on it and typing, because request activation can take some time.
```ts
export const typeInUrlBar = async (app: Application, url: string) => {
const urlEditor = await app.client.react$('RequestUrlBar');
@@ -142,6 +150,7 @@ export const typeInUrlBar = async (app: Application, url: string) => {
```
In addition, sometimes we want to wait for an element to hide instead of show. To achieve this, we can use the `reverse` option available through WebdriverIO, as shown in the following example.
```ts
// Wait for spinner to show
const spinner = await app.client.react$('ResponseTimer');
@@ -152,6 +161,7 @@ await spinner.waitForDisplayed({ reverse: true });
```
### Readability
It is important for a smoke test to be _readable_ so the flow can be understood, and the (often complicated) implementation details hidden, like in the example below.
```ts
@@ -192,6 +202,7 @@ it('sends request with basic authentication', async () => {
In most cases, it will be beneficial to create helper functions under `/modules`, regardless of how reusable they are. Some modules (such as `dropdown`, `tabs` and `settings`) are reusable, while some are specific to certain pages (eg `debug`, `home`, `onboarding`). These can be broken down into more granular modules as the test suite grows.
### Extend tests
Unlike unit tests, the application startup time for a smoke test can sometimes be longer than the test itself. As such, in cases where it is appropriate, **extend** a smoke test with additional steps instead of creating a **new** test.
## Contributing a smoke test?
@@ -199,6 +210,7 @@ Unlike unit tests, the application startup time for a smoke test can sometimes b
Smoke tests can potentially be flaky, and one attempt to avoid flaky tests in the default branch is to run the final implementation of a test at least 20 times locally to prove its stability. If a test is unable to achieve this, it is very unlikely to be accepted into the test suite.
You can repeat a test quickly by wrapping it with the following block:
```ts
describe.only.each(new Array(20).fill(1))('iteration %#', _ => {
it('your test name', () => {
@@ -206,4 +218,5 @@ describe.only.each(new Array(20).fill(1))('iteration %#', _ => {
});
});
```
When raising a PR, paste a screenshot of the test results showing at least 20 successful iterations.

View File

@@ -20,11 +20,11 @@ This module generates Kong Declarative Config and Kong for Kubernetes config, fr
- [`$.metadata.annotations`](#metadataannotations)
- [The `KongPlugin` and `KongIngress` resources](#the-kongplugin-and-kongingress-resources)
- [Example](#example)
- [Defaults](#defaults)
- [Plugins](#plugins)
- [Security Plugins](#security-plugins)
- [Generic Plugins](#generic-plugins)
- [Request Validator Plugin](#request-validator-plugin)
- [Defaults](#defaults)
- [Plugins](#plugins)
- [Security Plugins](#security-plugins)
- [Generic Plugins](#generic-plugins)
- [Request Validator Plugin](#request-validator-plugin)
## Library Usage
@@ -143,8 +143,7 @@ services:
tags: [] # <documented later>
```
Or, if variables are used, their default values will be substituted. The following example will
produce the same result
Or, if variables are used, their default values will be substituted. The following example will produce the same result
```yaml
servers:
@@ -165,7 +164,7 @@ The service name is set to the following
### `$.upstreams`
Upstreams and targets are generated from the `servers` root property (note that `servers` defined on `operation` or `path` objects are ignored).
Upstreams and targets are generated from the `servers` root property (note that `servers` defined on `operation` or `path` objects are ignored).
One OpenAPI spec will result in one `service` and one `upstream`, and each individual `server` in the root `servers` property will become a `target` in the `upstream`.
@@ -186,8 +185,7 @@ upstreams:
### `$.services[*].routes`
Service routes are generated from the root `paths` property. One service route per path/method
combination will be generated.
Service routes are generated from the root `paths` property. One service route per path/method combination will be generated.
```yaml
paths:
@@ -226,24 +224,19 @@ Each generated entity will get the tags as specified as well as the following ta
- `OAS3_import`
- `OAS3file_<filename>`
Tags can also be passed to this tool, which will be appended to the existing tags of
all created resources.
Tags can also be passed to this tool, which will be appended to the existing tags of all created resources.
## Kong for Kubernetes
### Output structure
The Kong for Kubernetes config will contain at least one `Ingress` document per server. Depending on where
Kong plugins (`x-kong-plugin-<plugin-name>`) exist in the specification, several `Ingress` documents may be created, in addition to
`KongPlugin` and `KongIngress` documents.
The Kong for Kubernetes config will contain at least one `Ingress` document per server. Depending on where Kong plugins (`x-kong-plugin-<plugin-name>`) exist in the specification, several `Ingress` documents may be created, in addition to `KongPlugin` and `KongIngress` documents.
`KongPlugin` and `KongIngress` resource documents can be reused, and are applied to the specs in an `Ingress` document
via metadata annotations.
`KongPlugin` and `KongIngress` resource documents can be reused, and are applied to the specs in an `Ingress` document via metadata annotations.
### The `Ingress` document
**At least** one `Ingress` document will be generated for each server. How many are required for each server, will be
determined by the presence of `KongPlugin` and `KongIngress` resources that need to be applied to specific paths.
**At least** one `Ingress` document will be generated for each server. How many are required for each server, will be determined by the presence of `KongPlugin` and `KongIngress` resources that need to be applied to specific paths.
<details>
<summary>Example</summary>
@@ -300,8 +293,7 @@ spec:
#### `$.metadata.name`
The `Ingress` document `metadata.name` is derived from sections in the source specification. If several are present, then the highest priority is selected. If none are present, then the fallback name is `openapi`.
The name is also converted to a lowercase slug.
The `Ingress` document `metadata.name` is derived from sections in the source specification. If several are present, then the highest priority is selected. If none are present, then the fallback name is `openapi`. The name is also converted to a lowercase slug.
Each of the following specifications generate an `Ingress` document with the following name:
@@ -347,17 +339,15 @@ In priority order, these sections are:
Annotations can be used to configure an Ingress document. This configuration applies to that entire Ingress document.
1. Any annotations that exist under `$.info.x-kubernetes-ingress-metadata.annotations` in the source specification are added automatically
2. `KongPlugin` and `KongIngress` resources may be generated. These are added to the Ingress document as:
1. `KongPlugin` and `KongIngress` resources may be generated. These are added to the Ingress document as:
- `konghq.com/plugins` references multiple `KongPlugin` resources via a comma separated string containing resource names
- `konghq.com/override` references single `KongIngress` resource via the resource name
### The `KongPlugin` and `KongIngress` resources
If plugins are found in the OpenAPI spec (see [Plugins](#plugins)), then they are converted to `KongPlugin` resources
by the Kong for Kubernetes config generator, before being applied to the `Ingress` document via [metadata annotations](#metadataannotations).
If plugins are found in the OpenAPI spec (see [Plugins](#plugins)), then they are converted to `KongPlugin` resources by the Kong for Kubernetes config generator, before being applied to the `Ingress` document via [metadata annotations](#metadataannotations).
If a plugin is found on an `operation` object in a path in the OpenAPI spec, then an additional `KongIngress` resource is generated,
that refers to the operation (`GET`, `POST`, etc).
If a plugin is found on an `operation` object in a path in the OpenAPI spec, then an additional `KongIngress` resource is generated, that refers to the operation (`GET`, `POST`, etc).
### Example
@@ -530,10 +520,9 @@ spec:
</details>
# Defaults
## Defaults
While properties for the generated entities will have properties derived from the OpenAPI spec, you may
choose to specify defaults for certain properties. You can specify these defaults using the following keys:
While properties for the generated entities will have properties derived from the OpenAPI spec, you may choose to specify defaults for certain properties. You can specify these defaults using the following keys:
- `x-kong-service-defaults` applied to the `root` object
- `x-kong-upstream-defaults` applied to the `root` object
@@ -541,20 +530,15 @@ choose to specify defaults for certain properties. You can specify these default
These defaults are only supported by the Declarative Config generator currently.
# Plugins
## Plugins
## Security Plugins
### Security Plugins
The `security` property can be defined on the top-level `openapi` object as well
as on `operation` objects. The information contained cannot be directly mapped
onto Kong, due to the logical and/or nature of how the specs have been set up.
The `security` property can be defined on the top-level `openapi` object as well as on `operation` objects. The information contained cannot be directly mapped onto Kong, due to the logical and/or nature of how the specs have been set up.
To overcome this Kong will only accept a single `securityScheme` from the `security`
property.
To overcome this Kong will only accept a single `securityScheme` from the `security` property.
The additional properties that Kong supports on its plugins can be configured
by using custom extensions. The custom extensions are
`x-kong-security-<plugin-name>`.
The additional properties that Kong supports on its plugins can be configured by using custom extensions. The custom extensions are `x-kong-security-<plugin-name>`.
Supported types are:
@@ -584,12 +568,9 @@ Supported types are:
- none
- requires to add credentials to Kong, which is not supported through OpenAPI specs.
## Generic Plugins
### Generic Plugins
Generic plugins can be added on various objects in the OpenAPI spec. The custom extension to
use is `x-kong-plugin-<plugin-name>`. The `name` property is not required
(since it's already in the extension name). Optional properties not specified
will get Kong defaults.
Generic plugins can be added on various objects in the OpenAPI spec. The custom extension to use is `x-kong-plugin-<plugin-name>`. The `name` property is not required (since it's already in the extension name). Optional properties not specified will get Kong defaults.
Currently, plugins are supported on the following OpenAPI objects by each generator:
@@ -605,8 +586,7 @@ If the _same_ plugin exists in several sections, then the more specific section
1. `server`
1. `OpenAPI` object (least specific)
This extension needs to hold an object that contains the entire plugin
config.
This extension needs to hold an object that contains the entire plugin config.
```yaml
x-kong-plugin-key-auth:
@@ -618,15 +598,14 @@ x-kong-plugin-key-auth:
hide_credentials: true
```
References are also supported, so this is valid as well (provided the
reference exists):
References are also supported, so this is valid as well (provided the reference exists):
```yaml
x-kong-plugin-key-auth:
$ref: '#/components/kong/plugins/key_auth_config'
```
## Request Validator Plugin
### Request Validator Plugin
To enable validation the `request-validator` plugin can be added to the `root`, `path` or `operation` object of the Spec and whichever is more specific will be used. You can either specify the full configuration, or have the missing properties be auto-generated based on the OpenAPI spec.

View File

@@ -2,4 +2,4 @@
[![Npm Version](https://img.shields.io/npm/v/insomnia-plugin-base64.svg)](https://www.npmjs.com/package/insomnia-plugin-base64)
This is a core Insomnia plugin.
This is a core Insomnia plugin.

View File

@@ -2,4 +2,4 @@
[![Npm Version](https://img.shields.io/npm/v/insomnia-plugin-cookie-jar.svg)](https://www.npmjs.com/package/insomnia-plugin-cookie-jar)
This is a core Insomnia plugin.
This is a core Insomnia plugin.

View File

@@ -15,13 +15,14 @@ Headers can be added by setting a `DEFAULT_HEADERS` environment variable.
```json
{
"DEFAULT_HEADERS": {
"Content-Type": "application/json",
"Connection": "close"
}
"DEFAULT_HEADERS": {
"Content-Type": "application/json",
"Connection": "close"
}
}
```
Default header can be removed by setting value to null. For example, use folder environment variables to remove authorization header from anonymous calls
```json
{
"DEFAULT_HEADERS": {

View File

@@ -2,4 +2,4 @@
[![Npm Version](https://img.shields.io/npm/v/insomnia-plugin-file.svg)](https://www.npmjs.com/package/insomnia-plugin-file)
This is a core Insomnia plugin.
This is a core Insomnia plugin.

View File

@@ -2,4 +2,4 @@
[![Npm Version](https://img.shields.io/npm/v/insomnia-plugin-hash.svg)](https://www.npmjs.com/package/insomnia-plugin-hash)
This is a core Insomnia plugin.
This is a core Insomnia plugin.

View File

@@ -8,7 +8,7 @@ This is a plugin for [Insomnia](https://insomnia.rest) to add the ability to gen
Install the `insomnia-plugin-kong-declarative-config` plugin from Preferences > Plugins.
![](./assets/plugins.png)
![plugins](./assets/plugins.png)
## Usage
@@ -16,11 +16,10 @@ Once this plugin is installed, open a document with an OpenAPI specification and
If installed correctly, a button titled `Generate Config` will appear in the header (you may need to reopen the document).
![](./assets/generateConfig.png)
![generate config](./assets/generateConfig.png)
Click on this button to open a modal, showing all of the config generator plugins installed and their output.
From here, you can copy the config to your clipboard and execute on your platform.
Click on this button to open a modal, showing all of the config generator plugins installed and their output. From here, you can copy the config to your clipboard and execute on your platform.
![](./assets/modal.png)
![modal](./assets/modal.png)
This config will regenerate each time you click on the button, so that changes in your specification are included.

View File

@@ -8,7 +8,7 @@ This is a plugin for [Insomnia](https://insomnia.rest) to add the ability to gen
Install the `insomnia-plugin-kong-kubernetes-config` plugin from Preferences > Plugins.
![](./assets/plugins.png)
![plugins](./assets/plugins.png)
## Usage
@@ -16,9 +16,8 @@ Once this plugin is installed, open a document with an OpenAPI specification and
If installed correctly, a button titled `Generate Config` will appear in the header (you may need to reopen the document).
![](./assets/generateConfig.png)
![generate config](./assets/generateConfig.png)
Click on this button to open a modal, showing all of the config generator plugins installed and their output.
From here, you can copy the config to your clipboard and execute on your platform. This config will regenerate each time you click on the button, so that changes in your specification are included.
Click on this button to open a modal, showing all of the config generator plugins installed and their output. From here, you can copy the config to your clipboard and execute on your platform. This config will regenerate each time you click on the button, so that changes in your specification are included.
![](./assets/modal.png)
![modal](./assets/modal.png)

View File

@@ -8,7 +8,7 @@ This is a plugin for [Insomnia](https://insomnia.rest) to add the ability to dep
Install the `insomnia-plugin-kong-portal` plugin from Preferences > Plugins.
![](./assets/plugins.png)
![plugins](./assets/plugins.png)
## Usage
@@ -16,8 +16,8 @@ Once this plugin is installed, navigate to the homepage and click `...` to open
If installed correctly, an option titled `Deploy to Portal` will appear.
![](./assets/dropdown.png)
![dropdown](./assets/dropdown.png)
Click on this button and enter your URL, workspace name and RBAC token in order to connect to Kong.
![](assets/connect.png)
![connect](assets/connect.png)

View File

@@ -2,4 +2,4 @@
[![Npm Version](https://img.shields.io/npm/v/insomnia-plugin-now.svg)](https://www.npmjs.com/package/insomnia-plugin-now)
This is a core Insomnia plugin.
This is a core Insomnia plugin.

View File

@@ -2,4 +2,4 @@
[![Npm Version](https://img.shields.io/npm/v/insomnia-plugin-request.svg)](https://www.npmjs.com/package/insomnia-plugin-request)
This is a core Insomnia plugin.
This is a core Insomnia plugin.

View File

@@ -2,4 +2,4 @@
[![Npm Version](https://img.shields.io/npm/v/insomnia-plugin-response.svg)](https://www.npmjs.com/package/insomnia-plugin-response)
This is a core Insomnia plugin.
This is a core Insomnia plugin.

View File

@@ -2,4 +2,4 @@
[![Npm Version](https://img.shields.io/npm/v/insomnia-plugin-uuid.svg)](https://www.npmjs.com/package/insomnia-plugin-uuid)
This is a core Insomnia plugin.
This is a core Insomnia plugin.