diff --git a/.gitignore b/.gitignore index 35083ffed..ea5d89d80 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ packages/insomnia-smoke-test/screenshots *.tsbuildinfo dist .history +packages/insomnia-app/app/network/ca_certs.ts +packages/insomnia-app/app/main.min.js.map diff --git a/.vscode/launch.json b/.vscode/launch.json index 88ba58fba..51a892afd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -16,9 +16,6 @@ "runtimeExecutable": "${workspaceFolder}/packages/insomnia-app/node_modules/.bin/electron", "runtimeArgs": ["--remote-debugging-port=9222", "."], "outputCapture": "std", - "sourceMapPathOverrides": { - "webpack:///./*": "${workspaceFolder}/packages/insomnia-app/app/*" - }, "windows": { "type": "node", "request": "launch", @@ -26,7 +23,6 @@ "runtimeExecutable": "${workspaceFolder}/packages/insomnia-app/node_modules/.bin/electron.cmd" }, "env": { - "TS_NODE_PROJECT": "tsconfig.webpack.json", "NODE_ENV": "development", "ELECTRON_IS_DEV": "1" } @@ -41,9 +37,6 @@ "order": 2 }, "port": 9222, - "sourceMapPathOverrides": { - "webpack:///./*": "${workspaceFolder}/packages/insomnia-app/app/*" - }, "webRoot": "${workspaceFolder}/packages/insomnia-app/app", "timeout": 60000 }, @@ -59,9 +52,6 @@ "autoAttachChildProcesses": true, "trace": true, "preLaunchTask": "Inso: Compile (Watch)", - "sourceMapPathOverrides": { - "webpack://insomniacli/./*": "${workspaceFolder}/packages/insomnia-inso/*" - }, "args": ["${input:insoCommand}", "${input:insoCommandArgs}"], "console": "integratedTerminal" } @@ -106,6 +96,7 @@ "group": "Insomnia", "order": 0 }, + "stopAll": true, "preLaunchTask": "Insomnia: Compile (Watch)", "configurations": [ "Electron: main", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a2593d619..0c3cdfbfa 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,32 +5,31 @@ "tasks": [ { "label": "Insomnia: Compile Main", - "detail": "webpack --config webpack/webpack.config.electron.ts", + "detail": "esbuild.main.ts", "type": "shell", "promptOnClose": false, "options": { "cwd": "${workspaceFolder}/packages/insomnia-app", "env": { "NODE_ENV": "development", - "TS_NODE_PROJECT": "tsconfig.webpack.json" } }, - "command": "${workspaceRoot}/packages/insomnia-app/node_modules/.bin/webpack --config webpack/webpack.config.electron.ts" + "command": "${workspaceRoot}/packages/insomnia-app/node_modules/.bin/esr esbuild.main.ts" }, { "label": "Insomnia: Compile Renderer (Watch)", - "detail": "webpack-dev-server --config webpack/webpack.config.development.ts", + "detail": "vite dev", "type": "shell", "promptOnClose": false, "options": { "cwd": "${workspaceFolder}/packages/insomnia-app", "env": { - "TS_NODE_PROJECT": "tsconfig.webpack.json" + "NODE_ENV": "development", } }, "isBackground": true, "problemMatcher": { - "owner": "webpack", + "owner": "vite", "severity": "error", "fileLocation": "absolute", "pattern": [ @@ -47,13 +46,13 @@ ], "background": { "activeOnStart": true, - "beginsPattern": "Compiling\\.\\.\\.", + "beginsPattern": "vite", "endsPattern": { - "regexp": "Compiled" + "regexp": "ready in" } } }, - "command": "${workspaceRoot}/packages/insomnia-app/node_modules/.bin/webpack-dev-server --config webpack/webpack.config.development.ts" + "command": "${workspaceRoot}/packages/insomnia-app/node_modules/.bin/vite dev" }, { "label": "Insomnia: Compile (Watch)", diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 30dfce998..ea31cbe13 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -13,8 +13,6 @@ 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. -- [`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. diff --git a/package.json b/package.json index 6bc568ba8..3dadfe979 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "test:smoke:cli": "npm run test:cli --prefix packages/insomnia-smoke-test", "hard-reset": "npm run clean && npm run bootstrap && npm run app-start", "type-check": "lerna run type-check", - "changelog-image": "ts-node ./scripts/changelog-image/changelog-image.ts" + "changelog-image": "ts-node ./scripts/changelog-image/changelog-image.ts", + "dev": "npm start --prefix packages/insomnia-app" }, "devDependencies": { "@babel/cli": "^7.10.5", diff --git a/packages/insomnia-app/.eslintignore b/packages/insomnia-app/.eslintignore index 1a729db3b..87e12286c 100644 --- a/packages/insomnia-app/.eslintignore +++ b/packages/insomnia-app/.eslintignore @@ -2,6 +2,3 @@ build bin send-request **/main.min.js -webpack.config.*.js -webpack.config.*.js.map -webpack.config.*.d.ts \ No newline at end of file diff --git a/packages/insomnia-app/app/__jest__/setup.ts b/packages/insomnia-app/app/__jest__/setup.ts index a97fac010..d183d22bc 100644 --- a/packages/insomnia-app/app/__jest__/setup.ts +++ b/packages/insomnia-app/app/__jest__/setup.ts @@ -37,6 +37,7 @@ global.requestAnimationFrame = (callback: FrameRequestCallback) => { }; global.require = require; + // Don't console log real logs that start with a tag (eg. [db] ...). It's annoying const log = console.log; diff --git a/packages/insomnia-app/app/__tests__/package.test.ts b/packages/insomnia-app/app/__tests__/package.test.ts deleted file mode 100644 index 4b8b7a098..000000000 --- a/packages/insomnia-app/app/__tests__/package.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import * as globalPackage from '../../package.json'; -import { globalBeforeEach } from '../__jest__/before-each'; - -describe('package.json', () => { - beforeEach(globalBeforeEach); - - it('all packed dependencies should exist', () => { - for (const name of globalPackage.packedDependencies) { - const version = globalPackage.dependencies[name]; - expect(version).toBeDefined(); - } - }); - - it('packages must be included in webpack build or else errors happen', () => { - // If this is built by Webpack it fails on multipart/form-data - expect(globalPackage.packedDependencies.includes('httpsnippet')).toBe(false); - }); - - it('packages must NOT be included in webpack build or else errors happen', () => { - // PDFJS breaks if not part of Webpack build - expect(globalPackage.packedDependencies.includes('pdfjs-dist')).toBe(true); - }); -}); diff --git a/packages/insomnia-app/app/common/constants.ts b/packages/insomnia-app/app/common/constants.ts index d76c9de5b..abf9aa433 100644 --- a/packages/insomnia-app/app/common/constants.ts +++ b/packages/insomnia-app/app/common/constants.ts @@ -5,6 +5,8 @@ import { unreachableCase } from 'ts-assert-unreachable'; import appConfig from '../../config/config.json'; import { getDataDirectory, getPortableExecutableDir } from './electron-helpers'; +const env = process['env']; + // App Stuff export const getAppVersion = () => appConfig.version; export const getAppLongName = () => appConfig.longName; @@ -20,7 +22,7 @@ export const isLinux = () => getAppPlatform() === 'linux'; export const isWindows = () => getAppPlatform() === 'win32'; export const getAppEnvironment = () => process.env.INSOMNIA_ENV || 'production'; export const isDevelopment = () => getAppEnvironment() === 'development'; -export const getSegmentWriteKey = () => appConfig.segmentWriteKeys[(isDevelopment() || process.env.PLAYWRIGHT) ? 'development' : 'production']; +export const getSegmentWriteKey = () => appConfig.segmentWriteKeys[(isDevelopment() || env.PLAYWRIGHT) ? 'development' : 'production']; export const getAppBuildDate = () => new Date(process.env.BUILD_DATE ?? '').toLocaleDateString(); export const getBrowserUserAgent = () => encodeURIComponent( @@ -126,13 +128,13 @@ export enum UpdateURL { } // API -export const getApiBaseURL = () => process.env.INSOMNIA_API_URL || 'https://api.insomnia.rest'; +export const getApiBaseURL = () => env.INSOMNIA_API_URL || 'https://api.insomnia.rest'; // App website -export const getAppWebsiteBaseURL = () => process.env.INSOMNIA_APP_WEBSITE_URL || 'https://app.insomnia.rest'; +export const getAppWebsiteBaseURL = () => env.INSOMNIA_APP_WEBSITE_URL || 'https://app.insomnia.rest'; // GitHub API -export const getGitHubGraphQLApiURL = () => process.env.INSOMNIA_GITHUB_API_URL || 'https://api.github.com/graphql'; +export const getGitHubGraphQLApiURL = () => env.INSOMNIA_GITHUB_API_URL || 'https://api.github.com/graphql'; // SYNC export const DEFAULT_BRANCH_NAME = 'master'; diff --git a/packages/insomnia-app/app/common/electron-helpers.ts b/packages/insomnia-app/app/common/electron-helpers.ts index bb0d9ae84..543c7f829 100644 --- a/packages/insomnia-app/app/common/electron-helpers.ts +++ b/packages/insomnia-app/app/common/electron-helpers.ts @@ -16,11 +16,11 @@ export function clickLink(href: string) { * This environment variable is added by electron-builder. * see: https://www.electron.build/configuration/nsis.html#portable\ */ -export const getPortableExecutableDir = () => process.env.PORTABLE_EXECUTABLE_DIR; +export const getPortableExecutableDir = () => process.env['PORTABLE_EXECUTABLE_DIR']; export function getDataDirectory() { const { app } = process.type === 'renderer' ? window : electron; - return process.env.INSOMNIA_DATA_PATH || app.getPath('userData'); + return process.env['INSOMNIA_DATA_PATH'] || app.getPath('userData'); } export function getTempDir() { diff --git a/packages/insomnia-app/app/common/misc.ts b/packages/insomnia-app/app/common/misc.ts index 42400bb05..6cf62854b 100644 --- a/packages/insomnia-app/app/common/misc.ts +++ b/packages/insomnia-app/app/common/misc.ts @@ -224,7 +224,7 @@ export function decompressObject(input: string | null): any { export function resolveHomePath(p: string) { if (p.indexOf('~/') === 0) { - return pathJoin(process.env.HOME || '/', p.slice(1)); + return pathJoin(process.env['HOME'] || '/', p.slice(1)); } else { return p; } diff --git a/packages/insomnia-app/app/renderer.html b/packages/insomnia-app/app/index.html similarity index 62% rename from packages/insomnia-app/app/renderer.html rename to packages/insomnia-app/app/index.html index 6ac4ca1cf..7279221a2 100644 --- a/packages/insomnia-app/app/renderer.html +++ b/packages/insomnia-app/app/index.html @@ -4,7 +4,7 @@
@@ -21,6 +21,6 @@ " > - +