mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Add OS plugin
This commit is contained in:
parent
b764d0714d
commit
ec1072a802
24
plugins/insomnia-plugin-os/README.md
Normal file
24
plugins/insomnia-plugin-os/README.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Insomnia Default Headers
|
||||||
|
|
||||||
|
[![Npm Version](https://img.shields.io/npm/v/insomnia-plugin-default-headers.svg)](https://www.npmjs.com/package/insomnia-plugin-default-headers)
|
||||||
|
|
||||||
|
This is a plugin for [Insomnia](https://insomnia.rest) that allows users to set default
|
||||||
|
headers for requests.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Install the `insomnia-plugin-default-headers` plugin from Preferences > Plugins.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Headers can be added by setting a `DEFAULT_HEADERS` environment variable.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"DEFAULT_HEADERS": {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Connection": "close"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
47
plugins/insomnia-plugin-os/index.js
Normal file
47
plugins/insomnia-plugin-os/index.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
const os = require('os');
|
||||||
|
const jsonPath = require('jsonpath');
|
||||||
|
|
||||||
|
const FILTERABLE = [
|
||||||
|
'userInfo',
|
||||||
|
'cpus'
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports.templateTags = [{
|
||||||
|
displayName: 'OS',
|
||||||
|
name: 'os',
|
||||||
|
description: 'get OS info',
|
||||||
|
args: [{
|
||||||
|
displayName: 'Function',
|
||||||
|
type: 'enum',
|
||||||
|
options: [
|
||||||
|
{displayName: 'arch', value: 'arch'},
|
||||||
|
{displayName: 'cpus', value: 'cpus'},
|
||||||
|
{displayName: 'freemem', value: 'freemem'},
|
||||||
|
{displayName: 'hostname', value: 'hostname'},
|
||||||
|
{displayName: 'platform', value: 'platform'},
|
||||||
|
{displayName: 'release', value: 'release'},
|
||||||
|
{displayName: 'userInfo', value: 'userInfo'}
|
||||||
|
]
|
||||||
|
}, {
|
||||||
|
displayName: 'JSONPath Filter',
|
||||||
|
help: 'Some OS functions return objects. Use JSONPath queries to extract desired values.',
|
||||||
|
hide: args => !FILTERABLE.includes(args[0].value),
|
||||||
|
type: 'string',
|
||||||
|
}],
|
||||||
|
run (context, fnName, filter) {
|
||||||
|
let value = os[fnName]();
|
||||||
|
|
||||||
|
if (jsonPath && FILTERABLE.includes(fnName)) {
|
||||||
|
try {
|
||||||
|
value = jsonPath.query(value, filter)[0];
|
||||||
|
} catch (err) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value !== 'string') {
|
||||||
|
return JSON.stringify(value);
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
220
plugins/insomnia-plugin-os/package-lock.json
generated
Normal file
220
plugins/insomnia-plugin-os/package-lock.json
generated
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
{
|
||||||
|
"requires": true,
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"dependencies": {
|
||||||
|
"JSONSelect": {
|
||||||
|
"version": "0.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/JSONSelect/-/JSONSelect-0.4.0.tgz",
|
||||||
|
"integrity": "sha1-oI7cxn6z/L6Z7WMIVTRKDPKCu40="
|
||||||
|
},
|
||||||
|
"cjson": {
|
||||||
|
"version": "0.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/cjson/-/cjson-0.2.1.tgz",
|
||||||
|
"integrity": "sha1-c82KrWXZ4VBfmvF0TTt5wVJ2gqU="
|
||||||
|
},
|
||||||
|
"colors": {
|
||||||
|
"version": "0.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/colors/-/colors-0.5.1.tgz",
|
||||||
|
"integrity": "sha1-fQAj6usVTo7p/Oddy5I9DtFmd3Q="
|
||||||
|
},
|
||||||
|
"deep-is": {
|
||||||
|
"version": "0.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
|
||||||
|
"integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ="
|
||||||
|
},
|
||||||
|
"ebnf-parser": {
|
||||||
|
"version": "0.1.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/ebnf-parser/-/ebnf-parser-0.1.10.tgz",
|
||||||
|
"integrity": "sha1-zR9rpHfFY4xAyX7ZtXLbW6tdgzE="
|
||||||
|
},
|
||||||
|
"escodegen": {
|
||||||
|
"version": "0.0.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-0.0.21.tgz",
|
||||||
|
"integrity": "sha1-U9ZSz6EDA4gnlFilJmxf/HCcY8M=",
|
||||||
|
"requires": {
|
||||||
|
"esprima": "1.0.4",
|
||||||
|
"estraverse": "0.0.4",
|
||||||
|
"source-map": "0.6.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"esprima": {
|
||||||
|
"version": "1.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz",
|
||||||
|
"integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"esprima": {
|
||||||
|
"version": "1.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz",
|
||||||
|
"integrity": "sha1-dqD9Zvz+FU/SkmZ9wmQBl1CxZXs="
|
||||||
|
},
|
||||||
|
"estraverse": {
|
||||||
|
"version": "0.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-0.0.4.tgz",
|
||||||
|
"integrity": "sha1-AaCTLf7ldGhKWYr1pnw7+bZCjbI="
|
||||||
|
},
|
||||||
|
"esutils": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
|
||||||
|
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs="
|
||||||
|
},
|
||||||
|
"fast-levenshtein": {
|
||||||
|
"version": "2.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
|
||||||
|
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc="
|
||||||
|
},
|
||||||
|
"jison": {
|
||||||
|
"version": "0.4.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/jison/-/jison-0.4.13.tgz",
|
||||||
|
"integrity": "sha1-kEFwfWIkE2f1iDRTK58ZwsNvrHg=",
|
||||||
|
"requires": {
|
||||||
|
"JSONSelect": "0.4.0",
|
||||||
|
"cjson": "0.2.1",
|
||||||
|
"ebnf-parser": "0.1.10",
|
||||||
|
"escodegen": "0.0.21",
|
||||||
|
"esprima": "1.0.4",
|
||||||
|
"jison-lex": "0.2.1",
|
||||||
|
"lex-parser": "0.1.4",
|
||||||
|
"nomnom": "1.5.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"esprima": {
|
||||||
|
"version": "1.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz",
|
||||||
|
"integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jison-lex": {
|
||||||
|
"version": "0.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/jison-lex/-/jison-lex-0.2.1.tgz",
|
||||||
|
"integrity": "sha1-rEuBXozOUTLrErXfz+jXB7iETf4=",
|
||||||
|
"requires": {
|
||||||
|
"lex-parser": "0.1.4",
|
||||||
|
"nomnom": "1.5.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jsonpath": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-Rc2dTE0NaCXZC9fkD4PxGCsT3Qc=",
|
||||||
|
"requires": {
|
||||||
|
"esprima": "1.2.2",
|
||||||
|
"jison": "0.4.13",
|
||||||
|
"static-eval": "2.0.0",
|
||||||
|
"underscore": "1.7.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"levn": {
|
||||||
|
"version": "0.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
|
||||||
|
"integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=",
|
||||||
|
"requires": {
|
||||||
|
"prelude-ls": "1.1.2",
|
||||||
|
"type-check": "0.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lex-parser": {
|
||||||
|
"version": "0.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/lex-parser/-/lex-parser-0.1.4.tgz",
|
||||||
|
"integrity": "sha1-ZMTwJfF/1Tv7RXY/rrFvAVp0dVA="
|
||||||
|
},
|
||||||
|
"nomnom": {
|
||||||
|
"version": "1.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.5.2.tgz",
|
||||||
|
"integrity": "sha1-9DRUSKhTz71cDSYyDyR3qwUm/i8=",
|
||||||
|
"requires": {
|
||||||
|
"colors": "0.5.1",
|
||||||
|
"underscore": "1.1.7"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"underscore": {
|
||||||
|
"version": "1.1.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.1.7.tgz",
|
||||||
|
"integrity": "sha1-QLq4S60Z0jAJbo1u9ii/8FXYPbA="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"optionator": {
|
||||||
|
"version": "0.8.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz",
|
||||||
|
"integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=",
|
||||||
|
"requires": {
|
||||||
|
"deep-is": "0.1.3",
|
||||||
|
"fast-levenshtein": "2.0.6",
|
||||||
|
"levn": "0.3.0",
|
||||||
|
"prelude-ls": "1.1.2",
|
||||||
|
"type-check": "0.3.2",
|
||||||
|
"wordwrap": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"prelude-ls": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
|
||||||
|
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ="
|
||||||
|
},
|
||||||
|
"source-map": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"static-eval": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-6flshd3F1Gwm+Ksxq463LtFd1liC77N/PX1FVVc3OzL3hAmo2fwHFbuArkcfi7s9rTNsLEhcRmXGFZhlgy40uw==",
|
||||||
|
"requires": {
|
||||||
|
"escodegen": "1.9.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"escodegen": {
|
||||||
|
"version": "1.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.9.0.tgz",
|
||||||
|
"integrity": "sha512-v0MYvNQ32bzwoG2OSFzWAkuahDQHK92JBN0pTAALJ4RIxEZe766QJPDR8Hqy7XNUy5K3fnVL76OqYAdc4TZEIw==",
|
||||||
|
"requires": {
|
||||||
|
"esprima": "3.1.3",
|
||||||
|
"estraverse": "4.2.0",
|
||||||
|
"esutils": "2.0.2",
|
||||||
|
"optionator": "0.8.2",
|
||||||
|
"source-map": "0.5.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"esprima": {
|
||||||
|
"version": "3.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz",
|
||||||
|
"integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM="
|
||||||
|
},
|
||||||
|
"estraverse": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz",
|
||||||
|
"integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM="
|
||||||
|
},
|
||||||
|
"source-map": {
|
||||||
|
"version": "0.5.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
|
||||||
|
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type-check": {
|
||||||
|
"version": "0.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
|
||||||
|
"integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=",
|
||||||
|
"requires": {
|
||||||
|
"prelude-ls": "1.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"underscore": {
|
||||||
|
"version": "1.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz",
|
||||||
|
"integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk="
|
||||||
|
},
|
||||||
|
"wordwrap": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
plugins/insomnia-plugin-os/package.json
Normal file
19
plugins/insomnia-plugin-os/package.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "insomnia-plugin-os",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"author": "Gregory Schier <gschier1990@gmail.com>",
|
||||||
|
"description": "Template tag to get information about the OS",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "https://github.com/getinsomnia/insomnia/tree/master/plugins/insomnia-plugin-os",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/getinsomnia/insomnia"
|
||||||
|
},
|
||||||
|
"main": "index.js",
|
||||||
|
"insomnia": {
|
||||||
|
"name": "os-info",
|
||||||
|
"description": "Get information about the OS"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"jsonpath": "^1.0.0"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user