From b8a3aa0954ffaea0516a9ce6b1215cafc9ee8ace Mon Sep 17 00:00:00 2001 From: jackkav Date: Sat, 13 Jul 2024 00:57:32 +0200 Subject: [PATCH 01/11] add --- package-lock.json | 7 +++++++ packages/insomnia/package.json | 1 + .../ui/components/modals/request-render-error-modal.tsx | 2 +- .../src/ui/components/templating/local-template-tags.ts | 9 ++++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 026f22c5b38..f544886943d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6572,6 +6572,12 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "node_modules/@types/jsonpath-plus": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@types/jsonpath-plus/-/jsonpath-plus-5.0.5.tgz", + "integrity": "sha512-aaqqDf5LcGOtAfEntO5qKZS6ixT0MpNhUXNwbVPdLf7ET9hKsufJq+buZr7eXSnWoLRyGzVj2Yz2hbjVSK3wsA==", + "dev": true + }, "node_modules/@types/keygrip": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/keygrip/-/keygrip-1.0.6.tgz", @@ -23503,6 +23509,7 @@ "@types/hosted-git-info": "3.0.5", "@types/js-yaml": "^4.0.9", "@types/jshint": "^2.12.4", + "@types/jsonpath-plus": "^5.0.5", "@types/license-checker": "^25.0.6", "@types/marked": "^5.0.2", "@types/mime-types": "^2.1.4", diff --git a/packages/insomnia/package.json b/packages/insomnia/package.json index 57524525bee..7d4d4265dad 100644 --- a/packages/insomnia/package.json +++ b/packages/insomnia/package.json @@ -112,6 +112,7 @@ "@types/hosted-git-info": "3.0.5", "@types/js-yaml": "^4.0.9", "@types/jshint": "^2.12.4", + "@types/jsonpath-plus": "^5.0.5", "@types/license-checker": "^25.0.6", "@types/marked": "^5.0.2", "@types/mime-types": "^2.1.4", diff --git a/packages/insomnia/src/ui/components/modals/request-render-error-modal.tsx b/packages/insomnia/src/ui/components/modals/request-render-error-modal.tsx index 024b4846201..7d2e9789841 100644 --- a/packages/insomnia/src/ui/components/modals/request-render-error-modal.tsx +++ b/packages/insomnia/src/ui/components/modals/request-render-error-modal.tsx @@ -39,7 +39,7 @@ export const RequestRenderErrorModal = forwardRef Date: Sat, 13 Jul 2024 01:06:03 +0200 Subject: [PATCH 02/11] use es2020 --- packages/insomnia-inso/tsconfig.json | 7 +++++-- packages/insomnia-testing/tsconfig.jest.json | 4 ++-- packages/insomnia/tsconfig.build.json | 8 ++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/insomnia-inso/tsconfig.json b/packages/insomnia-inso/tsconfig.json index d1afaae7ac3..e194b7fc688 100644 --- a/packages/insomnia-inso/tsconfig.json +++ b/packages/insomnia-inso/tsconfig.json @@ -8,7 +8,10 @@ "declaration": true, "declarationMap": true, "esModuleInterop": true, - "lib": ["DOM", "ES2019"], + "lib": [ + "DOM", + "ES2020" + ], "module": "CommonJS", "moduleResolution": "node", "noImplicitReturns": true, @@ -18,7 +21,7 @@ "resolveJsonModule": true, "sourceMap": true, "strict": true, - "target": "ES2019", + "target": "ES2020", "types": ["node"], "useUnknownInCatchVariables": false }, diff --git a/packages/insomnia-testing/tsconfig.jest.json b/packages/insomnia-testing/tsconfig.jest.json index 167210bce90..8438ce3b7ac 100644 --- a/packages/insomnia-testing/tsconfig.jest.json +++ b/packages/insomnia-testing/tsconfig.jest.json @@ -10,7 +10,7 @@ "esModuleInterop": true, "lib": [ "DOM", - "ES2019" + "ES2020" ], "module": "CommonJS", "moduleResolution": "node", @@ -21,7 +21,7 @@ "resolveJsonModule": true, "sourceMap": true, "strict": true, - "target": "ES2019", + "target": "ES2020", "types": [ "node" ], diff --git a/packages/insomnia/tsconfig.build.json b/packages/insomnia/tsconfig.build.json index 7e9e3cde353..b31bffb5871 100644 --- a/packages/insomnia/tsconfig.build.json +++ b/packages/insomnia/tsconfig.build.json @@ -16,10 +16,14 @@ "resolveJsonModule": true, "sourceMap": true, "strict": true, - "target": "ES2019", + "target": "ES2020", "useUnknownInCatchVariables": false, - "lib": ["DOM.Iterable", "DOM"], + "lib": [ + "ES2020", + "DOM.Iterable", + "DOM" + ], "isolatedModules": true, "jsx": "react", "outDir": "./build", From faace6a7762e91c13abec113d472191e911436b1 Mon Sep 17 00:00:00 2001 From: jackkav Date: Sat, 13 Jul 2024 19:45:28 +0200 Subject: [PATCH 03/11] improve verify --- packages/insomnia-inso/src/scripts/verify-pkg.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/insomnia-inso/src/scripts/verify-pkg.js b/packages/insomnia-inso/src/scripts/verify-pkg.js index 2f848310f51..d77ae5c49a2 100644 --- a/packages/insomnia-inso/src/scripts/verify-pkg.js +++ b/packages/insomnia-inso/src/scripts/verify-pkg.js @@ -1,5 +1,3 @@ -// import { spawn } from 'child_process'; -// import { resolve } from 'path'; const spawn = require('child_process').spawn; const resolve = require('path').resolve; const basePath = resolve('binaries/inso'); @@ -7,6 +5,9 @@ const childProcess = spawn(basePath, ['--help']); childProcess.stdout.on('data', data => { console.log(`stdout: ${data}`); }); +childProcess.stderr.on('data', data => { + console.log(`stderr: ${data}`); +}); childProcess.on('error', err => { console.error(`Error: ${err.message}`); }); From 722c50a641b0be3bd7085fc79c6c7242c65a4efb Mon Sep 17 00:00:00 2001 From: jackkav Date: Sat, 13 Jul 2024 20:05:47 +0200 Subject: [PATCH 04/11] minify jest conf --- packages/insomnia-testing/tsconfig.jest.json | 25 -------------------- packages/insomnia/tsconfig.build.json | 3 ++- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/packages/insomnia-testing/tsconfig.jest.json b/packages/insomnia-testing/tsconfig.jest.json index 8438ce3b7ac..b6955c086e7 100644 --- a/packages/insomnia-testing/tsconfig.jest.json +++ b/packages/insomnia-testing/tsconfig.jest.json @@ -1,30 +1,5 @@ { "compilerOptions": { - "allowJs": true, - "allowSyntheticDefaultImports": true, - "allowUnreachableCode": true, - "allowUnusedLabels": false, - "checkJs": true, - "declaration": true, - "declarationMap": true, "esModuleInterop": true, - "lib": [ - "DOM", - "ES2020" - ], - "module": "CommonJS", - "moduleResolution": "node", - "noImplicitReturns": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "pretty": true, - "resolveJsonModule": true, - "sourceMap": true, - "strict": true, - "target": "ES2020", - "types": [ - "node" - ], - "useUnknownInCatchVariables": false } } diff --git a/packages/insomnia/tsconfig.build.json b/packages/insomnia/tsconfig.build.json index b31bffb5871..97b4bd78440 100644 --- a/packages/insomnia/tsconfig.build.json +++ b/packages/insomnia/tsconfig.build.json @@ -8,10 +8,10 @@ "declaration": true, "declarationMap": true, "esModuleInterop": true, - "moduleResolution": "node", "noImplicitReturns": true, "noUnusedLocals": true, "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, "pretty": true, "resolveJsonModule": true, "sourceMap": true, @@ -29,6 +29,7 @@ "outDir": "./build", "rootDir": ".", "module": "ESNext", + "moduleResolution": "node", "skipLibCheck": true, "strictNullChecks": true, "types": ["node", "vite/client"], From f532ecb4762093a84310ce1c4c1bebee72d47b08 Mon Sep 17 00:00:00 2001 From: jackkav Date: Sat, 13 Jul 2024 20:50:14 +0200 Subject: [PATCH 05/11] organise tsconfig --- packages/insomnia/tsconfig.build.json | 42 ++++++++++++--------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/packages/insomnia/tsconfig.build.json b/packages/insomnia/tsconfig.build.json index 97b4bd78440..19fd94876f1 100644 --- a/packages/insomnia/tsconfig.build.json +++ b/packages/insomnia/tsconfig.build.json @@ -1,38 +1,32 @@ { "compilerOptions": { - "allowJs": true, - "allowSyntheticDefaultImports": true, - "allowUnreachableCode": true, - "allowUnusedLabels": false, - "checkJs": true, - "declaration": true, - "declarationMap": true, + /* Basic */ "esModuleInterop": true, - "noImplicitReturns": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "pretty": true, + "skipLibCheck": true, + "target": "es2022", + "allowJs": true, "resolveJsonModule": true, + "moduleResolution": "node", + "isolatedModules": true, + /* Transpiling Options */ + "module": "ESNext", + "outDir": "./build", + "rootDir": ".", "sourceMap": true, - "strict": true, - "target": "ES2020", - "useUnknownInCatchVariables": false, - + /* Runs in the DOM */ "lib": [ "ES2020", "DOM.Iterable", "DOM" ], - "isolatedModules": true, "jsx": "react", - "outDir": "./build", - "rootDir": ".", - "module": "ESNext", - "moduleResolution": "node", - "skipLibCheck": true, - "strictNullChecks": true, - "types": ["node", "vite/client"], + /* Strictness */ + "strict": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "useUnknownInCatchVariables": false, }, "include": [ "**/*.d.ts", From 21a8d729129c08ac9f025e46bd2e4011c4e1a885 Mon Sep 17 00:00:00 2001 From: jackkav Date: Sat, 13 Jul 2024 21:01:06 +0200 Subject: [PATCH 06/11] tweaks --- packages/insomnia-inso/tsconfig.json | 35 ++++++++++++------------ packages/insomnia/tsconfig.build.json | 18 ++++++------ packages/insomnia/tsconfig.build.sr.json | 3 ++ 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/packages/insomnia-inso/tsconfig.json b/packages/insomnia-inso/tsconfig.json index e194b7fc688..b562bc72887 100644 --- a/packages/insomnia-inso/tsconfig.json +++ b/packages/insomnia-inso/tsconfig.json @@ -1,29 +1,30 @@ { "compilerOptions": { + /* Basic */ + "esModuleInterop": true, + "skipLibCheck": true, + "target": "es2022", "allowJs": true, - "allowSyntheticDefaultImports": true, - "allowUnreachableCode": true, - "allowUnusedLabels": false, "checkJs": true, - "declaration": true, - "declarationMap": true, - "esModuleInterop": true, + "resolveJsonModule": true, + "moduleResolution": "node", + "isolatedModules": true, + /* Transpiling Options */ + "module": "CommonJS", + "sourceMap": true, + /* Runs in the DOM NOTE: this is inconsistent with reality */ "lib": [ - "DOM", - "ES2020" + "ES2020", + "DOM.Iterable", + "DOM" ], - "module": "CommonJS", - "moduleResolution": "node", + /* Strictness */ + "strict": true, "noImplicitReturns": true, "noUnusedLocals": true, "noUnusedParameters": true, - "pretty": true, - "resolveJsonModule": true, - "sourceMap": true, - "strict": true, - "target": "ES2020", - "types": ["node"], - "useUnknownInCatchVariables": false + "noFallthroughCasesInSwitch": true, + "useUnknownInCatchVariables": false, }, "include": [ ".eslintrc.js", diff --git a/packages/insomnia/tsconfig.build.json b/packages/insomnia/tsconfig.build.json index 19fd94876f1..6a39256897d 100644 --- a/packages/insomnia/tsconfig.build.json +++ b/packages/insomnia/tsconfig.build.json @@ -1,6 +1,6 @@ { "compilerOptions": { - /* Basic */ + /* Basic */ "esModuleInterop": true, "skipLibCheck": true, "target": "es2022", @@ -10,8 +10,6 @@ "isolatedModules": true, /* Transpiling Options */ "module": "ESNext", - "outDir": "./build", - "rootDir": ".", "sourceMap": true, /* Runs in the DOM */ "lib": [ @@ -20,13 +18,13 @@ "DOM" ], "jsx": "react", - /* Strictness */ - "strict": true, - "noImplicitReturns": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "useUnknownInCatchVariables": false, + /* Strictness */ + "strict": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "useUnknownInCatchVariables": false, }, "include": [ "**/*.d.ts", diff --git a/packages/insomnia/tsconfig.build.sr.json b/packages/insomnia/tsconfig.build.sr.json index 00bd07348a5..0c10ef09c06 100644 --- a/packages/insomnia/tsconfig.build.sr.json +++ b/packages/insomnia/tsconfig.build.sr.json @@ -1,8 +1,11 @@ { "extends": "./tsconfig.build.json", "compilerOptions": { + "declaration": true, + "declarationMap": true, "emitDeclarationOnly": true, "outDir": "../insomnia-send-request/dist", + "rootDir": ".", }, "include": [ "**/*.d.ts", From 32eef679ed9bbe257394c191aed271d9b0f9f6cf Mon Sep 17 00:00:00 2001 From: jackkav Date: Sat, 13 Jul 2024 21:09:14 +0200 Subject: [PATCH 07/11] remove tsconfig.build.json --- packages/insomnia/package.json | 2 +- packages/insomnia/tsconfig.build.json | 53 ------------------------ packages/insomnia/tsconfig.build.sr.json | 28 ++++++++++++- packages/insomnia/tsconfig.json | 48 ++++++++++++++++++++- 4 files changed, 73 insertions(+), 58 deletions(-) delete mode 100644 packages/insomnia/tsconfig.build.json diff --git a/packages/insomnia/package.json b/packages/insomnia/package.json index 7d4d4265dad..826ac70a718 100644 --- a/packages/insomnia/package.json +++ b/packages/insomnia/package.json @@ -29,7 +29,7 @@ "test": "jest", "electron:dev-build": "electron ./build/main.min.js", "test:watch": "jest --watch", - "type-check": "tsc --noEmit --project tsconfig.build.json", + "type-check": "tsc --noEmit --project tsconfig.json", "type-check:watch": "npm run type-check -- --watch", "convert-svg": "npm_config_yes=true npx @svgr/cli@6.4.0 --no-index --config-file svgr.config.js --out-dir src/ui/components/assets/svgr src/ui/components/assets/" }, diff --git a/packages/insomnia/tsconfig.build.json b/packages/insomnia/tsconfig.build.json deleted file mode 100644 index 6a39256897d..00000000000 --- a/packages/insomnia/tsconfig.build.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "compilerOptions": { - /* Basic */ - "esModuleInterop": true, - "skipLibCheck": true, - "target": "es2022", - "allowJs": true, - "resolveJsonModule": true, - "moduleResolution": "node", - "isolatedModules": true, - /* Transpiling Options */ - "module": "ESNext", - "sourceMap": true, - /* Runs in the DOM */ - "lib": [ - "ES2020", - "DOM.Iterable", - "DOM" - ], - "jsx": "react", - /* Strictness */ - "strict": true, - "noImplicitReturns": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "useUnknownInCatchVariables": false, - }, - "include": [ - "**/*.d.ts", - "package.json", - "src", - ], - "exclude": [ - "**/*.test.ts", - "**/*.test.tsx", - "**/__jest__", - "**/__mocks__", - "**/__snapshots__", - "**/__tests__", - "**/main.min.js", - "__jest__", - "assets", - "bin", - "config", - "jest.config.js", - "node_modules", - "src/coverage", - "src/main.min.js", - "src/preload.js", - "src/hidden-window-preload.js", - ], -} diff --git a/packages/insomnia/tsconfig.build.sr.json b/packages/insomnia/tsconfig.build.sr.json index 0c10ef09c06..990c9763621 100644 --- a/packages/insomnia/tsconfig.build.sr.json +++ b/packages/insomnia/tsconfig.build.sr.json @@ -1,11 +1,35 @@ { - "extends": "./tsconfig.build.json", - "compilerOptions": { +"compilerOptions": { + /* Basic */ + "esModuleInterop": true, + "skipLibCheck": true, + "target": "es2022", + "allowJs": true, + "resolveJsonModule": true, + "moduleResolution": "node", + "isolatedModules": true, + /* Transpiling Options */ + "module": "ESNext", + "sourceMap": true, "declaration": true, "declarationMap": true, "emitDeclarationOnly": true, "outDir": "../insomnia-send-request/dist", "rootDir": ".", + /* Runs in the DOM */ + "lib": [ + "ES2020", + "DOM.Iterable", + "DOM" + ], + "jsx": "react", + /* Strictness */ + "strict": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "useUnknownInCatchVariables": false, }, "include": [ "**/*.d.ts", diff --git a/packages/insomnia/tsconfig.json b/packages/insomnia/tsconfig.json index 1e832f69242..9e869a9663d 100644 --- a/packages/insomnia/tsconfig.json +++ b/packages/insomnia/tsconfig.json @@ -1,5 +1,31 @@ { - "extends": "./tsconfig.build.json", + "compilerOptions": { + /* Basic */ + "esModuleInterop": true, + "skipLibCheck": true, + "target": "es2022", + "allowJs": true, + "resolveJsonModule": true, + "moduleResolution": "node", + "isolatedModules": true, + /* Transpiling Options */ + "module": "ESNext", + "sourceMap": true, + /* Runs in the DOM */ + "lib": [ + "ES2020", + "DOM.Iterable", + "DOM" + ], + "jsx": "react", + /* Strictness */ + "strict": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "useUnknownInCatchVariables": false, + }, "include": [ ".eslintrc.js", "config", @@ -14,7 +40,8 @@ "tailwind.config.js", "postcss.config.js", "vite.config.ts", - "vite-plugin-electron-node-require" + "vite-plugin-electron-node-require", + "**/*.d.ts", ], "exclude": [ "bin", @@ -25,5 +52,22 @@ "src/main.min.js", "src/preload.js", "svgr.config.js", + "**/*.test.ts", + "**/*.test.tsx", + "**/__jest__", + "**/__mocks__", + "**/__snapshots__", + "**/__tests__", + "**/main.min.js", + "__jest__", + "assets", + "bin", + "config", + "jest.config.js", + "node_modules", + "src/coverage", + "src/main.min.js", + "src/preload.js", + "src/hidden-window-preload.js", ], } From fb8c3c6aa50b5d62870c093053f4d196af09df73 Mon Sep 17 00:00:00 2001 From: jackkav Date: Sat, 13 Jul 2024 21:21:39 +0200 Subject: [PATCH 08/11] add inso structure notes --- DEVELOPMENT.md | 13 +++++++++++-- packages/insomnia-testing/package.json | 4 +--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 3d8a8cfe942..7b4ea7da686 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -23,6 +23,14 @@ Insomnia uses [`npm workspaces`](https://docs.npmjs.com/cli/v9/using-npm/workspa - `/packages` contains related packages that are consumed by `insomnia` or externally. +Insomnia Inso CLI is built using a series of steps + +1. `packages/insomnia-send-request/dist/index.js` is transpiled from `packages/insomnia` using both esbuild and tsc to gather some of insomnia renderer networking functionality +1. `insomnia-inso` uses project references to import `insomnia-send-request` and `insomnia-testing` to gather functionality for creating test code and running requests. +1. `packages/insomnia-inso/dist/index.js` is transpiled with esbuild +1. `packages/insomnia-inso/bin/inso` is shell script which points at `packages/insomnia-inso/dist/index.js` and is used for local development +1. `packages/insomnia-inso/binaries/inso` is an executable made with `pkg` + ## The `insomnia` Main Package `/packages/insomnia` is the entry point for the app. All other packages are imported from this one. @@ -81,9 +89,9 @@ This is just a brief summary of Insomnia's current technical debt. - [x] styling vision (react-aria + tailwind) - [ ] de-polymorph database - [ ] codemirror is unmaintained -- [ ] nedb is unmaintained +- [x] nedb is unmaintained - [ ] grpc state state should be in main rather than renderer -- [ ] drag and drop is flakey +- [x] drag and drop is flakey - [ ] sync code is spaghetti - [ ] template rendering is spaghetti and has poor discoverability - [ ] inso abstraction limits networking improvements @@ -101,3 +109,4 @@ bump the following node and electron versions - `packages/insomnia/package.json` electron and node-libcurl - `packages/insomnia-send-request/package.json` node-libcurl - `shell.nix` + diff --git a/packages/insomnia-testing/package.json b/packages/insomnia-testing/package.json index 3550845d460..a6a68674fc9 100644 --- a/packages/insomnia-testing/package.json +++ b/packages/insomnia-testing/package.json @@ -16,9 +16,7 @@ "types": "src/index.ts", "scripts": { "lint": "eslint . --ext .js,.ts,.tsx --cache", - "test": "jest", - "build": "tsc --build tsconfig.build.json", - "watch": "npm run build -- --watch" + "test": "jest" }, "homepage": "https://github.com/Kong/insomnia#readme", "description": "" From 5ab7e206ff1363de606178205b8be7d8bde4f669 Mon Sep 17 00:00:00 2001 From: jackkav Date: Sun, 14 Jul 2024 10:48:40 +0200 Subject: [PATCH 09/11] fix lint --- DEVELOPMENT.md | 1 - 1 file changed, 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 7b4ea7da686..2bc091cd0db 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -109,4 +109,3 @@ bump the following node and electron versions - `packages/insomnia/package.json` electron and node-libcurl - `packages/insomnia-send-request/package.json` node-libcurl - `shell.nix` - From 2fc1e63b99e61c0bdab24da48a6035921487cf06 Mon Sep 17 00:00:00 2001 From: jackkav Date: Sun, 14 Jul 2024 10:55:47 +0200 Subject: [PATCH 10/11] remove tsc step --- DEVELOPMENT.md | 11 ++++++----- packages/insomnia/package.json | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 2bc091cd0db..a07c04c7edb 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -25,11 +25,12 @@ Insomnia uses [`npm workspaces`](https://docs.npmjs.com/cli/v9/using-npm/workspa Insomnia Inso CLI is built using a series of steps -1. `packages/insomnia-send-request/dist/index.js` is transpiled from `packages/insomnia` using both esbuild and tsc to gather some of insomnia renderer networking functionality -1. `insomnia-inso` uses project references to import `insomnia-send-request` and `insomnia-testing` to gather functionality for creating test code and running requests. -1. `packages/insomnia-inso/dist/index.js` is transpiled with esbuild -1. `packages/insomnia-inso/bin/inso` is shell script which points at `packages/insomnia-inso/dist/index.js` and is used for local development -1. `packages/insomnia-inso/binaries/inso` is an executable made with `pkg` +1. `packages/insomnia-send-request/dist/index.js` is transpiled from `packages/insomnia` using esbuild to expose `getSendRequestCallbackMemDb` in order to send a request without writing to database +2. `insomnia-testing` is connected to both `packages/insomnia` `packages/insomnia-inso` using "project references" to expose `generate`, `runTests` and `runTestsCli` +3. `insomnia-inso` uses"project references" to import `insomnia-send-request` and `insomnia-testing`. +4. `packages/insomnia-inso/dist/index.js` is transpiled with esbuild +5. `packages/insomnia-inso/bin/inso` is shell script which points at `packages/insomnia-inso/dist/index.js` and is used for local development +6. `packages/insomnia-inso/binaries/inso` is an executable made with `pkg` ## The `insomnia` Main Package diff --git a/packages/insomnia/package.json b/packages/insomnia/package.json index 826ac70a718..36d47cc5d14 100644 --- a/packages/insomnia/package.json +++ b/packages/insomnia/package.json @@ -20,7 +20,7 @@ "build": "npm run build:sr && npm run build:app", "build:app": "esr --cache ./scripts/build.ts --noErrorTruncation", "build:main.min.js": "cross-env NODE_ENV=development esr esbuild.main.ts", - "build:sr": "esr esbuild.sr.ts && tsc --build tsconfig.build.sr.json", + "build:sr": "esr esbuild.sr.ts", "lint": "eslint . --ext .js,.ts,.tsx --cache", "package": "npm run build:app && cross-env USE_HARD_LINKS=false electron-builder build --config electron-builder.config.js", "start": "concurrently -n browser,main --kill-others \"npm run start:dev-server\" \"npm run start:electron\"", From d2c67e0a530c9b11a30a69f296511e7a46c5e6a3 Mon Sep 17 00:00:00 2001 From: jackkav Date: Sun, 14 Jul 2024 11:15:23 +0200 Subject: [PATCH 11/11] add notes --- DEVELOPMENT.md | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index a07c04c7edb..53fc40a16d7 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -26,11 +26,31 @@ Insomnia uses [`npm workspaces`](https://docs.npmjs.com/cli/v9/using-npm/workspa Insomnia Inso CLI is built using a series of steps 1. `packages/insomnia-send-request/dist/index.js` is transpiled from `packages/insomnia` using esbuild to expose `getSendRequestCallbackMemDb` in order to send a request without writing to database -2. `insomnia-testing` is connected to both `packages/insomnia` `packages/insomnia-inso` using "project references" to expose `generate`, `runTests` and `runTestsCli` -3. `insomnia-inso` uses"project references" to import `insomnia-send-request` and `insomnia-testing`. -4. `packages/insomnia-inso/dist/index.js` is transpiled with esbuild -5. `packages/insomnia-inso/bin/inso` is shell script which points at `packages/insomnia-inso/dist/index.js` and is used for local development -6. `packages/insomnia-inso/binaries/inso` is an executable made with `pkg` +1. `insomnia-testing` is connected to both `packages/insomnia` `packages/insomnia-inso` using "project references" to expose `generate`, `runTests` and `runTestsCli` +1. `insomnia-inso` uses"project references" to import `insomnia-send-request` and `insomnia-testing`. +1. `packages/insomnia-inso/dist/index.js` is transpiled with esbuild +1. `packages/insomnia-inso/bin/inso` is shell script which points at `packages/insomnia-inso/dist/index.js` and is used for local development +1. `packages/insomnia-inso/binaries/inso` is an executable made with `pkg` + +What `insomnia-send-request` is an abstraction which trades-off CLI build complexity against refactoring the insomnia app into modules which both could share. It exposes some behaviour from the insomnia renderer. + +- database: to fetch needed models +- nunjucks templates: to interpolate the fields containing tags +- node-libcurl: to send the request +- fs: to persist responses +- plugins: potentially needed by the community, unclear if the implementation works + +Problems + +- send-request bundles almost the entire renderer, react components included, meaning that although we are intending to use this code in node we are bundling it using rules intended for browsers. +- node-libcurl present bundling issues because it needs to re-download a different version from npm each time you want to work on either insomnia or inso. +- nunjucks codepaths haven't been touched in a long time, they need some love in order to be able to understand how to make them composable. + +Unexplored ideas in this area. + +- create a database package with nunjucks templating and have both insomnia and inso use it with project references, use node-libcurl directly, eliminating `insomnia-send-request`. +- use an adapter pattern in inso to replace node-libcurl with fetch in order to avoid the bundling issues NaN modules present. +- remove plugin support from inso and reimplement later with a fixed and supported API. ## The `insomnia` Main Package