Unify build config in one place

This commit is contained in:
Gregory Schier committed 2019-09-17 17:02:42 -07:00
1 parent cc489c9d22
commit 945ff0e631
22 files changed
+222 -110

No files matched your search

+4 -4
View File
@@ -1,5 +1,5 @@
{
"appId": "com.insomnia.app",
"appId": "__APP_ID__",
"publish": false,
"extraResources": [
{
@@ -40,11 +40,11 @@
]
},
"squirrelWindows":{
"iconUrl": "https://github.com/getinsomnia/insomnia/blob/master/packages/insomnia-app/app/icons/icon.ico?raw=true"
"iconUrl": "__ICON_URL__"
},
"linux": {
"executableName": "insomnia",
"synopsis": "A simple, beautiful, and free REST API client",
"executableName": "__EXECUTABLE_NAME__",
"synopsis": "__SYNOPSIS__",
"category": "Development",
"target": [
"AppImage",
+2 -1
View File
@@ -1,4 +1,5 @@
// @flow
import * as packageJson from '../../package.json';
import type { BaseModel } from './index';
import * as db from '../common/database';
import { UPDATE_CHANNEL_STABLE } from '../common/constants';
@@ -71,7 +72,7 @@ export function init(): BaseSettings {
validateSSL: true,
forceVerticalLayout: false,
autoHideMenuBar: false,
theme: 'default',
theme: packageJson.app.theme,
pluginPath: '',
nunjucksPowerUserMode: false,
deviceId: null,
@@ -102,7 +102,7 @@ describe('actuallySend()', () => {
'Accept: */*',
'Accept-Encoding:',
],
NOPROGRESS: false,
NOPROGRESS: true,
USERNAME: 'user',
PASSWORD: 'pass',
POSTFIELDS: 'foo=bar',
@@ -163,7 +163,7 @@ describe('actuallySend()', () => {
'Accept: */*',
'Accept-Encoding:',
],
NOPROGRESS: false,
NOPROGRESS: true,
POSTFIELDS: 'foo=bar&bar=&=value',
PROXY: '',
TIMEOUT_MS: 0,
@@ -252,7 +252,7 @@ describe('actuallySend()', () => {
'Accept: */*',
'Accept-Encoding:',
],
NOPROGRESS: false,
NOPROGRESS: true,
USERNAME: 'user',
PASSWORD: 'pass',
POSTFIELDS: 'foo=bar',
@@ -310,7 +310,7 @@ describe('actuallySend()', () => {
'Accept: */*',
'Accept-Encoding:',
],
NOPROGRESS: false,
NOPROGRESS: true,
INFILESIZE_LARGE: 26,
PROXY: '',
READDATA: fs.readFileSync(fileName, 'utf8'),
@@ -377,7 +377,7 @@ describe('actuallySend()', () => {
'Accept-Encoding:',
],
INFILESIZE_LARGE: 244,
NOPROGRESS: false,
NOPROGRESS: true,
READDATA: [
`--${DEFAULT_BOUNDARY}`,
'Content-Disposition: form-data; name="foo"; filename="testfile.txt"',
@@ -434,7 +434,7 @@ describe('actuallySend()', () => {
COOKIEFILE: '',
FOLLOWLOCATION: true,
HTTPHEADER: ['Accept: */*', 'Accept-Encoding:', 'content-type:'],
NOPROGRESS: false,
NOPROGRESS: true,
PROXY: '',
TIMEOUT_MS: 0,
URL: 'http://my/path',
@@ -478,7 +478,7 @@ describe('actuallySend()', () => {
COOKIEFILE: '',
FOLLOWLOCATION: true,
HTTPHEADER: ['Accept: */*', 'Accept-Encoding:', 'content-type:'],
NOPROGRESS: false,
NOPROGRESS: true,
PROXY: '',
TIMEOUT_MS: 0,
URL: 'http://localhost:3000/foo/bar',
@@ -521,7 +521,7 @@ describe('actuallySend()', () => {
COOKIEFILE: '',
FOLLOWLOCATION: true,
HTTPHEADER: ['Accept: */*', 'Accept-Encoding:', 'content-type:'],
NOPROGRESS: false,
NOPROGRESS: true,
PROXY: '',
TIMEOUT_MS: 0,
URL: 'http://unix:3000/my/path',
@@ -565,7 +565,7 @@ describe('actuallySend()', () => {
COOKIEFILE: '',
FOLLOWLOCATION: true,
HTTPHEADER: ['Accept: */*', 'Accept-Encoding:', 'content-type:'],
NOPROGRESS: false,
NOPROGRESS: true,
PROXY: '',
TIMEOUT_MS: 0,
NETRC: 2,
+4 -23
View File
@@ -215,7 +215,7 @@ export async function _actuallySend(
// Set all the basic options
setOpt(Curl.option.FOLLOWLOCATION, settings.followRedirects);
setOpt(Curl.option.VERBOSE, true); // True so debug function works
setOpt(Curl.option.NOPROGRESS, false); // False so progress function works
setOpt(Curl.option.NOPROGRESS, true); // True so curl doesn't print progress
setOpt(Curl.option.ACCEPT_ENCODING, ''); // Auto decode everything
enable(Curl.feature.NO_HEADER_PARSING);
enable(Curl.feature.NO_DATA_PARSING);
@@ -286,26 +286,6 @@ export async function _actuallySend(
// Set the headers (to be modified as we go)
const headers = clone(renderedRequest.headers);
let lastPercent = 0;
// NOTE: This option was added in 7.32.0 so make it optional
setOpt(
Curl.option.XFERINFOFUNCTION,
(dltotal, dlnow, ultotal, ulnow) => {
if (dltotal === 0) {
return 0;
}
const percent = Math.round((dlnow / dltotal) * 100);
if (percent !== lastPercent) {
// console.log(`[network] Request downloaded ${percent}%`);
lastPercent = percent;
}
return 0;
},
true,
);
// Set the URL, including the query parameters
const qs = buildQueryStringFromParams(renderedRequest.parameters);
const url = joinUrlAndQueryString(renderedRequest.url, qs);
@@ -711,7 +691,7 @@ export async function _actuallySend(
// Update cookie jar if we need to and if we found any cookies
if (renderedRequest.settingStoreCookies && setCookieStrings.length) {
const cookies = await cookiesFromJar(jar);
models.cookieJar.update(renderedRequest.cookieJar, { cookies });
await models.cookieJar.update(renderedRequest.cookieJar, { cookies });
}
// Print informational message
@@ -743,7 +723,8 @@ export async function _actuallySend(
// Make sure the response body has been fully written first
await waitForStreamToFinish(responseBodyWriteStream);
respond(responsePatch, responseBodyPath);
// Send response
await respond(responsePatch, responseBodyPath);
});
curl.on('error', function(err, code) {
+2 -15
View File
@@ -1,5 +1,6 @@
// @flow
import mkdirp from 'mkdirp';
import * as packageJson from '../../package.json';
import * as models from '../models';
import fs from 'fs';
import path from 'path';
@@ -52,20 +53,6 @@ export type Theme = {
theme: PluginTheme,
};
const CORE_PLUGINS = [
'insomnia-plugin-base64',
'insomnia-plugin-hash',
'insomnia-plugin-file',
'insomnia-plugin-now',
'insomnia-plugin-uuid',
'insomnia-plugin-prompt',
'insomnia-plugin-request',
'insomnia-plugin-response',
'insomnia-plugin-jsonpath',
'insomnia-plugin-cookie-jar',
'insomnia-plugin-core-themes',
];
let plugins: ?Array<Plugin> = null;
export async function init(): Promise<void> {
@@ -157,7 +144,7 @@ export async function getPlugins(force: boolean = false): Promise<Array<Plugin>>
// "name": "module"
};
for (const p of CORE_PLUGINS) {
for (const p of packageJson.app.plugins) {
const pluginJson = global.require(`${p}/package.json`);
const pluginModule = global.require(p);
pluginMap[pluginJson.name] = _initPlugin(pluginJson, pluginModule);
-1
View File
@@ -2,7 +2,6 @@
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>Insomnia</title>
<meta
http-equiv="Content-Security-Policy"
content="default-src * insomnia://*; img-src blob: data: * insomnia://*; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src blob: data: mediastream: * insomnia://*;"
+2
View File
@@ -1,4 +1,5 @@
import * as React from 'react';
import * as packageJson from '../../package.json';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import App from './containers/app';
@@ -16,6 +17,7 @@ import DNDBackend from './dnd-backend';
// Handy little helper
document.body.setAttribute('data-platform', process.platform);
document.title = packageJson.app.longName;
(async function() {
await db.initClient();
+1 -1
View File
@@ -2,6 +2,6 @@
declare module 'mkdirp' {
declare module.exports: {
sync: (path: string) => void,
sync: (path: string) => string | null,
};
}
+19 -1
View File
@@ -4,10 +4,28 @@
"name": "insomnia-app",
"app": {
"name": "insomnia",
"executableName": "insomnia",
"appId": "com.insomnia.app",
"productName": "Insomnia",
"longName": "Insomnia REST Client",
"synopsis": "A simple, beautiful, and free REST API client",
"icon": "https://github.com/getinsomnia/insomnia/blob/master/packages/insomnia-app/app/icons/icon.ico?raw=true",
"theme": "default",
"version": "6.6.2",
"main": "main.min.js"
"main": "main.min.js",
"plugins": [
"insomnia-plugin-base64",
"insomnia-plugin-hash",
"insomnia-plugin-file",
"insomnia-plugin-now",
"insomnia-plugin-uuid",
"insomnia-plugin-prompt",
"insomnia-plugin-request",
"insomnia-plugin-response",
"insomnia-plugin-jsonpath",
"insomnia-plugin-cookie-jar",
"insomnia-plugin-core-themes"
]
},
"licence": "MIT",
"homepage": "https://insomnia.rest/",
+30 -3
View File
@@ -1,3 +1,4 @@
const packageJson = require('../package.json');
const childProcess = require('child_process');
const webpack = require('webpack');
const rimraf = require('rimraf');
@@ -48,11 +49,13 @@ module.exports.start = async function() {
async function buildWebpack(config) {
return new Promise((resolve, reject) => {
webpack(config, (err, stats) => {
const compiler = webpack(config);
compiler.run((err, stats) => {
if (err) {
reject(err);
} else if (stats.hasErrors()) {
reject(new Error('Failed to build webpack'));
console.log(stats.toJson().errors);
} else {
resolve();
}
@@ -90,9 +93,33 @@ async function copyFiles(relSource, relDest) {
}
async function install(relDir) {
return new Promise((resolve, reject) => {
return new Promise(resolve => {
const prefix = path.resolve(__dirname, relDir);
// Link all plugins
const plugins = path.resolve(__dirname, `../../../plugins`);
for (const dir of fs.readdirSync(plugins)) {
console.log(`[build] Linking plugin ${dir}`);
const p = path.join(plugins, dir);
childProcess.spawnSync('npm', ['link', p], {
cwd: prefix,
shell: true,
});
}
// Link all packages
const packages = path.resolve(__dirname, `../../../packages`);
for (const dir of fs.readdirSync(packages)) {
// Don't like ourselves
if (dir === packageJson.name) {
continue;
}
console.log(`[build] Linking local package ${dir}`);
const p = path.join(packages, dir);
childProcess.spawnSync('npm', ['link', p], { cwd: prefix, shell: true });
}
const p = childProcess.spawn('npm', ['install', '--production', '--no-optional'], {
cwd: prefix,
shell: true,
@@ -121,7 +148,7 @@ function generatePackageJson(relBasePkg, relOutPkg) {
const basePkg = JSON.parse(fs.readFileSync(basePath));
const appPkg = {
name: 'insomnia',
name: packageJson.app.name,
version: basePkg.app.version,
productName: basePkg.app.productName,
longName: basePkg.app.longName,
+13 -1
View File
@@ -1,3 +1,4 @@
const packageJson = require('../package.json');
const electronBuilder = require('electron-builder');
const path = require('path');
const rimraf = require('rimraf');
@@ -38,7 +39,18 @@ module.exports.start = async function() {
async function pkg(relConfigPath) {
const configPath = path.resolve(__dirname, relConfigPath);
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
// Replace some things
const rawConfig = fs
.readFileSync(configPath, 'utf8')
.replace('__APP_ID__', packageJson.app.appId)
.replace('__ICON_URL__', packageJson.app.icon)
.replace('__EXECUTABLE_NAME__', packageJson.app.executableName)
.replace('__SYNOPSIS__', packageJson.app.synopsis);
console.log(`[package] Using electron-builder config\n${rawConfig}`);
const config = JSON.parse(rawConfig);
const targetPlatform = PLATFORM_MAP[process.platform];
const target = process.env.BUILD_TARGETS
+3 -3
View File
@@ -1,5 +1,5 @@
{
"name": "insomnia-prettify",
"version": "0.1.1",
"lockfileVersion": 1
"name": "insomnia-prettify",
"version": "0.1.11",
"lockfileVersion": 1
}
+3 -3
View File
@@ -1,5 +1,5 @@
{
"name": "insomnia-url",
"version": "0.1.1",
"lockfileVersion": 1
"name": "insomnia-url",
"version": "0.1.10",
"lockfileVersion": 1
}
+27
View File
@@ -4,6 +4,33 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"insomnia-cookies": {
"version": "0.0.17",
"resolved": "https://registry.npmjs.org/insomnia-cookies/-/insomnia-cookies-0.0.17.tgz",
"integrity": "sha512-L+5HrvkHRciCImArY5u4Ua0Nl+/YNLNzaADlsAsoB/Pb2desKIQMU37J6onxka9h7umvhuBchxROK2lKjy+oYQ==",
"requires": {
"tough-cookie": "^2.3.3"
}
},
"psl": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz",
"integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw=="
},
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"tough-cookie": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
"integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==",
"requires": {
"psl": "^1.1.28",
"punycode": "^2.1.1"
}
},
"xmldom": {
"version": "0.1.27",
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz",
+3 -3
View File
@@ -1,5 +1,5 @@
{
"name": "insomnia-plugin-base64",
"version": "1.0.2",
"lockfileVersion": 1
"name": "insomnia-plugin-base64",
"version": "1.0.10",
"lockfileVersion": 1
}
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "insomnia-plugin-core-themes",
"version": "1.0.8",
"version": "1.0.9",
"lockfileVersion": 1
}
+3 -3
View File
@@ -1,5 +1,5 @@
{
"name": "insomnia-plugin-default-headers",
"version": "1.0.3",
"lockfileVersion": 1
"name": "insomnia-plugin-default-headers",
"version": "1.1.11",
"lockfileVersion": 1
}
+3 -3
View File
@@ -1,5 +1,5 @@
{
"name": "insomnia-plugin-file",
"version": "1.0.2",
"lockfileVersion": 1
"name": "insomnia-plugin-file",
"version": "1.0.11",
"lockfileVersion": 1
}
+3 -3
View File
@@ -1,5 +1,5 @@
{
"name": "insomnia-plugin-hash",
"version": "1.0.2",
"lockfileVersion": 1
"name": "insomnia-plugin-hash",
"version": "1.0.11",
"lockfileVersion": 1
}
+5
View File
@@ -0,0 +1,5 @@
{
"name": "insomnia-plugin-prompt",
"version": "1.1.15",
"lockfileVersion": 1
}
+38 -32
View File
@@ -1,34 +1,40 @@
{
"name": "insomnia-plugin-request",
"version": "1.0.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"insomnia-cookies": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/insomnia-cookies/-/insomnia-cookies-0.0.3.tgz",
"integrity": "sha512-w15mXZd9aoYVxhtKgeZEfLREzn26Ggq1Y5CSazjcib/FQyyovd7O473/YVz9eQaQwgsUgOfmUAg2ofQTVIQ58A==",
"requires": {
"tough-cookie": "2.3.3"
}
},
"insomnia-url": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/insomnia-url/-/insomnia-url-0.1.1.tgz",
"integrity": "sha512-wkrtC4M/9m0Rwi04eDv/DxJvo8dPwbfdTxucfahK/bNGUza9h7JdVHWgJNviEiQ6u4y08ne13tT+SnqSbe7pDA=="
},
"punycode": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
},
"tough-cookie": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz",
"integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=",
"requires": {
"punycode": "1.4.1"
}
}
}
"name": "insomnia-plugin-request",
"version": "1.0.24",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"insomnia-cookies": {
"version": "0.0.17",
"resolved": "https://registry.npmjs.org/insomnia-cookies/-/insomnia-cookies-0.0.17.tgz",
"integrity": "sha512-L+5HrvkHRciCImArY5u4Ua0Nl+/YNLNzaADlsAsoB/Pb2desKIQMU37J6onxka9h7umvhuBchxROK2lKjy+oYQ==",
"requires": {
"tough-cookie": "^2.3.3"
}
},
"insomnia-url": {
"version": "0.1.10",
"resolved": "https://registry.npmjs.org/insomnia-url/-/insomnia-url-0.1.10.tgz",
"integrity": "sha512-fSN3/gNryiDi07Ut9M9GjGMM5bg1v6RwfG5FyQGkCettzgqJNc1pDO5QQSargR6vdSYo9rqBU9gZVGVdWWR2kg=="
},
"psl": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz",
"integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw=="
},
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"tough-cookie": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
"integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==",
"requires": {
"psl": "^1.1.28",
"punycode": "^2.1.1"
}
}
}
}
+47
View File
@@ -53,6 +53,24 @@
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
"integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ=="
},
"insomnia-cookies": {
"version": "0.0.17",
"resolved": "https://registry.npmjs.org/insomnia-cookies/-/insomnia-cookies-0.0.17.tgz",
"integrity": "sha512-L+5HrvkHRciCImArY5u4Ua0Nl+/YNLNzaADlsAsoB/Pb2desKIQMU37J6onxka9h7umvhuBchxROK2lKjy+oYQ==",
"requires": {
"tough-cookie": "^2.3.3"
}
},
"insomnia-xpath": {
"version": "1.0.14",
"resolved": "https://registry.npmjs.org/insomnia-xpath/-/insomnia-xpath-1.0.14.tgz",
"integrity": "sha512-GedSmR+P9SPhKfJRX4bNM9uoPBdTPPmhxaapODSjrdHtOE2jj0Ggl/K/7YbqpvbAIU5GgUDWiRqCgrYNW+2QfQ==",
"requires": {
"insomnia-cookies": "^0.0.17",
"xmldom": "^0.1.27",
"xpath": "0.0.27"
}
},
"jsonpath": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.0.2.tgz",
@@ -90,6 +108,16 @@
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ="
},
"psl": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz",
"integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw=="
},
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
@@ -104,6 +132,15 @@
"escodegen": "^1.8.1"
}
},
"tough-cookie": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
"integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==",
"requires": {
"psl": "^1.1.28",
"punycode": "^2.1.1"
}
},
"type-check": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
@@ -121,6 +158,16 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus="
},
"xmldom": {
"version": "0.1.27",
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz",
"integrity": "sha1-1QH5ezvbQDr4757MIFcxh6rawOk="
},
"xpath": {
"version": "0.0.27",
"resolved": "https://registry.npmjs.org/xpath/-/xpath-0.0.27.tgz",
"integrity": "sha512-fg03WRxtkCV6ohClePNAECYsmpKKTv5L8y/X3Dn1hQrec3POx2jHZ/0P2qQ6HvsrU1BmeqXcof3NGGueG6LxwQ=="
}
}
}