chore: code cleanup + cli updates

This commit is contained in:
Anoop M D 2024-08-19 11:36:24 +05:30
parent 1bf3a15784
commit d187a8efab
9 changed files with 413 additions and 2936 deletions

View File

@ -26,12 +26,6 @@ jobs:
npm run build --workspace=packages/bruno-common
npm run build --workspace=packages/bruno-query
# rebuild isolated-vm for bruno-js
- name: Rebuild bruno-js isolated-vm
run: |
cd packages/bruno-js/node_modules/isolated-vm
npm run rebuild || true
# tests
- name: Test Package bruno-js
run: npm run test --workspace=packages/bruno-js
@ -70,12 +64,6 @@ jobs:
npm run build --workspace=packages/bruno-query
npm run build --workspace=packages/bruno-common
# rebuild isolated-vm for bruno-js
- name: Rebuild bruno-js isolated-vm
run: |
cd packages/bruno-js/node_modules/isolated-vm
npm run rebuild || true
- name: Run tests
run: |
cd packages/bruno-tests/collection

2807
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -51,10 +51,7 @@
"rollup": "3.2.5"
},
"dependencies": {
"isolated-vm": "^5.0.0",
"json-bigint": "^1.0.0",
"lossless-json": "^4.0.1",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0"
"lossless-json": "^4.0.1"
}
}

View File

@ -18,7 +18,7 @@ import CollectionSettings from 'components/CollectionSettings';
import { DocExplorer } from '@usebruno/graphql-docs';
import StyledWrapper from './StyledWrapper';
import SecuritySettings from 'components/SecuritySettings/index';
import SecuritySettings from 'components/SecuritySettings';
import FolderSettings from 'components/FolderSettings';
const MIN_LEFT_PANE_WIDTH = 300;

View File

@ -190,6 +190,10 @@ const getFolderRoot = (dir) => {
return collectionBruToJson(content);
};
const getJsSandboxRuntime = (sandbox) => {
return sandbox === 'safe' ? 'quickjs' : 'vm2';
};
const builder = async (yargs) => {
yargs
.option('r', {
@ -215,6 +219,11 @@ const builder = async (yargs) => {
describe: 'Overwrite a single environment variable, multiple usages possible',
type: 'string'
})
.option('sandbox', {
describe: 'Javscript sandbox to use; available sandboxes are "developer" (default) or "safe"',
default: 'developer',
type: 'string'
})
.option('output', {
alias: 'o',
describe: 'Path to write file results to',
@ -282,6 +291,7 @@ const handler = async function (argv) {
r: recursive,
output: outputPath,
format,
sandbox,
testsOnly,
bail
} = argv;
@ -451,6 +461,7 @@ const handler = async function (argv) {
}
}
const runtime = getJsSandboxRuntime(sandbox);
let currentRequestIndex = 0;
let nJumps = 0; // count the number of jumps to avoid infinite loops
while (currentRequestIndex < bruJsons.length) {
@ -466,7 +477,8 @@ const handler = async function (argv) {
envVars,
processEnvVars,
brunoConfig,
collectionRoot
collectionRoot,
runtime
);
results.push({

View File

@ -29,7 +29,8 @@ const runSingleRequest = async function (
envVariables,
processEnvVars,
brunoConfig,
collectionRoot
collectionRoot,
runtime
) {
try {
let request;
@ -38,11 +39,7 @@ const runSingleRequest = async function (
request = prepareRequest(bruJson.request, collectionRoot);
const scriptingConfig = get(brunoConfig, 'scripts', {});
// todo: allow to override from cli args
// we will default to vm2 (developer-mode) for 1.x version for backward compatibility
// 2.x will default to isolated-vm (safe mode)
scriptingConfig.runtime = 'quickjs';
scriptingConfig.runtime = runtime;
// make axios work in node using form data
// reference: https://github.com/axios/axios/issues/1006#issuecomment-320165427

View File

@ -8,7 +8,7 @@
"author": "Anoop M D <anoop.md1421@gmail.com> (https://helloanoop.com/)",
"scripts": {
"clean": "rimraf dist",
"dev": "electron --no-node-snapshot .",
"dev": "electron .",
"dist:mac": "electron-builder --mac --config electron-builder-config.js",
"dist:win": "electron-builder --win --config electron-builder-config.js",
"dist:linux": "electron-builder --linux AppImage --config electron-builder-config.js",
@ -64,8 +64,7 @@
"dmg-license": "^1.0.11"
},
"devDependencies": {
"electron": "23.3.3",
"electron-builder": "23.0.2",
"electron-icon-maker": "^0.0.5"
"electron": "31.2.1",
"electron-builder": "23.0.2"
}
}

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@ const addLibraryShimsToContext = require('./shims/lib');
const { newQuickJSWASMModule, memoizePromiseFactory } = require('quickjs-emscripten');
// execute `npm run sandbox:bundle-libraries` if the below file doesn't exist
const getBundledCode = require('../../bundle-browser-rollup');
const getBundledCode = require('../bundle-browser-rollup');
const addSleepShimToContext = require('./shims/sleep');
let QuickJSSyncContext;