mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-03 04:29:09 +01:00
Merge branch 'usebruno:main' into main
This commit is contained in:
commit
fec99f0780
@ -30,6 +30,7 @@
|
|||||||
"ts-jest": "^29.0.5"
|
"ts-jest": "^29.0.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"setup": "node ./scripts/setup.js",
|
||||||
"dev": "concurrently --kill-others \"npm run dev:web\" \"npm run dev:electron\"",
|
"dev": "concurrently --kill-others \"npm run dev:web\" \"npm run dev:electron\"",
|
||||||
"dev:web": "npm run dev --workspace=packages/bruno-app",
|
"dev:web": "npm run dev --workspace=packages/bruno-app",
|
||||||
"build:web": "npm run build --workspace=packages/bruno-app",
|
"build:web": "npm run build --workspace=packages/bruno-app",
|
||||||
@ -51,6 +52,6 @@
|
|||||||
"prepare": "husky install"
|
"prepare": "husky install"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"rollup":"3.29.5"
|
"rollup": "3.29.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ export const globalEnvironmentsUpdateEvent = ({ globalEnvironmentVariables }) =>
|
|||||||
// update existing values
|
// update existing values
|
||||||
variables = variables?.map?.(variable => ({
|
variables = variables?.map?.(variable => ({
|
||||||
...variable,
|
...variable,
|
||||||
value: stringifyIfNot(globalEnvironmentVariables?.[variable?.name])
|
value: globalEnvironmentVariables?.[variable?.name]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// add new env values
|
// add new env values
|
||||||
@ -201,7 +201,7 @@ export const globalEnvironmentsUpdateEvent = ({ globalEnvironmentVariables }) =>
|
|||||||
variables.push({
|
variables.push({
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
name: key,
|
name: key,
|
||||||
value: stringifyIfNot(value),
|
value,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
secret: false,
|
secret: false,
|
||||||
enabled: true
|
enabled: true
|
||||||
|
@ -797,7 +797,7 @@ export const getGlobalEnvironmentVariables = ({ globalEnvironments, activeGlobal
|
|||||||
const environment = globalEnvironments?.find(env => env?.uid === activeGlobalEnvironmentUid);
|
const environment = globalEnvironments?.find(env => env?.uid === activeGlobalEnvironmentUid);
|
||||||
if (environment) {
|
if (environment) {
|
||||||
each(environment.variables, (variable) => {
|
each(environment.variables, (variable) => {
|
||||||
if (variable.name && variable.value && variable.enabled) {
|
if (variable.name && variable.enabled) {
|
||||||
variables[variable.name] = variable.value;
|
variables[variable.name] = variable.value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -80,9 +80,9 @@ export const transformItemsInCollection = (collection) => {
|
|||||||
// from 5 feb 2024, multipartFormData needs to have a type
|
// from 5 feb 2024, multipartFormData needs to have a type
|
||||||
// this was introduced when we added support for file uploads
|
// this was introduced when we added support for file uploads
|
||||||
// below logic is to make older collection exports backward compatible
|
// below logic is to make older collection exports backward compatible
|
||||||
let multipartFormData = _.get(item, 'request.body.multipartForm');
|
let multipartFormData = get(item, 'request.body.multipartForm');
|
||||||
if (multipartFormData) {
|
if (multipartFormData) {
|
||||||
_.each(multipartFormData, (form) => {
|
each(multipartFormData, (form) => {
|
||||||
if (!form.type) {
|
if (!form.type) {
|
||||||
form.type = 'text';
|
form.type = 'text';
|
||||||
}
|
}
|
||||||
|
@ -349,10 +349,10 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
|||||||
// rename item
|
// rename item
|
||||||
ipcMain.handle('renderer:rename-item', async (event, oldPath, newPath, newName) => {
|
ipcMain.handle('renderer:rename-item', async (event, oldPath, newPath, newName) => {
|
||||||
const tempDir = path.join(os.tmpdir(), `temp-folder-${Date.now()}`);
|
const tempDir = path.join(os.tmpdir(), `temp-folder-${Date.now()}`);
|
||||||
const parentDir = path.dirname(oldPath);
|
// const parentDir = path.dirname(oldPath);
|
||||||
const isWindowsOSAndNotWSLAndItemHasSubDirectories = isDirectory(oldPath) && isWindowsOS() && !isWSLPath(oldPath) && hasSubDirectories(oldPath);
|
const isWindowsOSAndNotWSLAndItemHasSubDirectories = isDirectory(oldPath) && isWindowsOS() && !isWSLPath(oldPath) && hasSubDirectories(oldPath);
|
||||||
let parentDirUnwatched = false;
|
// let parentDirUnwatched = false;
|
||||||
let parentDirRewatched = false;
|
// let parentDirRewatched = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Normalize paths if they are WSL paths
|
// Normalize paths if they are WSL paths
|
||||||
@ -376,8 +376,8 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
|||||||
moveRequestUid(bruFile, newBruFilePath);
|
moveRequestUid(bruFile, newBruFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
watcher.unlinkItemPathInWatcher(parentDir);
|
// watcher.unlinkItemPathInWatcher(parentDir);
|
||||||
parentDirUnwatched = true;
|
// parentDirUnwatched = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If it is windows OS
|
* If it is windows OS
|
||||||
@ -396,8 +396,8 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
|||||||
} else {
|
} else {
|
||||||
await fs.renameSync(oldPath, newPath);
|
await fs.renameSync(oldPath, newPath);
|
||||||
}
|
}
|
||||||
watcher.addItemPathInWatcher(parentDir);
|
// watcher.addItemPathInWatcher(parentDir);
|
||||||
parentDirRewatched = true;
|
// parentDirRewatched = true;
|
||||||
|
|
||||||
return newPath;
|
return newPath;
|
||||||
}
|
}
|
||||||
@ -424,9 +424,9 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
// in case an error occurs during the rename file operations after unlinking the parent dir
|
// in case an error occurs during the rename file operations after unlinking the parent dir
|
||||||
// and the rewatch fails, we need to add it back to watcher
|
// and the rewatch fails, we need to add it back to watcher
|
||||||
if (parentDirUnwatched && !parentDirRewatched) {
|
// if (parentDirUnwatched && !parentDirRewatched) {
|
||||||
watcher.addItemPathInWatcher(parentDir);
|
// watcher.addItemPathInWatcher(parentDir);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// in case the rename file operations fails, and we see that the temp dir exists
|
// in case the rename file operations fails, and we see that the temp dir exists
|
||||||
// and the old path does not exist, we need to restore the data from the temp dir to the old path
|
// and the old path does not exist, we need to restore the data from the temp dir to the old path
|
||||||
|
95
scripts/setup.js
Normal file
95
scripts/setup.js
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
const { execSync } = require('child_process');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const icons = {
|
||||||
|
clean: '🧹',
|
||||||
|
delete: '🗑️',
|
||||||
|
install: '📦',
|
||||||
|
build: '🔨',
|
||||||
|
success: '✅',
|
||||||
|
error: '❌',
|
||||||
|
working: '⚡'
|
||||||
|
};
|
||||||
|
|
||||||
|
const execCommand = (command, description) => {
|
||||||
|
try {
|
||||||
|
console.log(`\n${icons.working} ${description}...`);
|
||||||
|
execSync(command, { stdio: 'inherit' });
|
||||||
|
console.log(`${icons.success} ${description} completed`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`${icons.error} ${description} failed`);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const glob = function (startPath, pattern) {
|
||||||
|
let results = [];
|
||||||
|
|
||||||
|
// Ensure start path exists
|
||||||
|
if (!fs.existsSync(startPath)) {
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = fs.readdirSync(startPath);
|
||||||
|
for (const file of files) {
|
||||||
|
const filename = path.join(startPath, file);
|
||||||
|
const stat = fs.lstatSync(filename);
|
||||||
|
|
||||||
|
// If directory, recurse into it
|
||||||
|
if (stat.isDirectory()) {
|
||||||
|
// Skip node_modules recursion to avoid unnecessary deep scanning
|
||||||
|
if (file === 'node_modules') {
|
||||||
|
if (file === pattern) {
|
||||||
|
results.push(filename);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
results = results.concat(glob(filename, pattern));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If file matches pattern, add to results
|
||||||
|
if (file === pattern) {
|
||||||
|
results.push(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
async function setup() {
|
||||||
|
try {
|
||||||
|
// Clean up node_modules (if exists)
|
||||||
|
console.log(`\n${icons.clean} Cleaning up node_modules directories...`);
|
||||||
|
const nodeModulesPaths = glob('.', 'node_modules');
|
||||||
|
for (const dir of nodeModulesPaths) {
|
||||||
|
console.log(`${icons.delete} Removing ${dir}`);
|
||||||
|
fs.rmSync(dir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Install dependencies
|
||||||
|
execCommand('npm i --legacy-peer-deps', 'Installing dependencies');
|
||||||
|
|
||||||
|
// Build packages
|
||||||
|
execCommand('npm run build:graphql-docs', 'Building graphql-docs');
|
||||||
|
execCommand('npm run build:bruno-query', 'Building bruno-query');
|
||||||
|
execCommand('npm run build:bruno-common', 'Building bruno-common');
|
||||||
|
|
||||||
|
// Bundle JS sandbox libraries
|
||||||
|
execCommand(
|
||||||
|
'npm run sandbox:bundle-libraries --workspace=packages/bruno-js',
|
||||||
|
'Bundling JS sandbox libraries'
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`\n${icons.success} Setup completed successfully!\n`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`\n${icons.error} Setup failed:`);
|
||||||
|
console.error(error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setup().catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user