diff --git a/scripts/setup.js b/scripts/setup.js index 47d25d657..cf1e9a70e 100644 --- a/scripts/setup.js +++ b/scripts/setup.js @@ -47,7 +47,7 @@ const glob = function (startPath, pattern) { } results = results.concat(glob(filename, pattern)); } - + // If file matches pattern, add to results if (file === pattern) { results.push(filename); @@ -57,6 +57,25 @@ const glob = function (startPath, pattern) { return results; }; +function forceInstallPlatformDeps() { + // Note: make sure to hard pin deps and only add deps that have been checked + // for sec vuln already since the following will be force installed. + const deps = { + darwin: ['@lydell/node-pty-darwin-arm64@1.1.0', '@lydell/node-pty-darwin-x64@1.1.0'], + win32: ['@lydell/node-pty-win32-arm64@1.1.0', '@lydell/node-pty-win32-x64@1.1.0'], + linux: ['@lydell/node-pty-linux-arm64@1.1.0', '@lydell/node-pty-linux-x64@1.1.0'] + }; + + // Ignore if no deps need to be installed + if (!deps[process.platform] || (Array.isArray(deps[process.platform]) && deps[process.platform].length === 0)) return; + + const toInstall = deps[process.platform]; + execCommand( + `npm i --legacy-peer-deps --no-save --force ${toInstall.join(' ')}`, + 'Installing platform specific dependencies' + ); +} + async function setup() { try { // Clean up node_modules (if exists) @@ -69,6 +88,7 @@ async function setup() { // Install dependencies execCommand('npm i --legacy-peer-deps', 'Installing dependencies'); + forceInstallPlatformDeps(); // Build packages execCommand('npm run build:graphql-docs', 'Building graphql-docs'); @@ -78,12 +98,9 @@ async function setup() { execCommand('npm run build:bruno-requests', 'Building bruno-requests'); execCommand('npm run build:schema-types', 'Building schema-types'); execCommand('npm run build:bruno-filestore', 'Building bruno-filestore'); - + // Bundle JS sandbox libraries - execCommand( - 'npm run sandbox:bundle-libraries --workspace=packages/bruno-js', - 'Bundling 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) { @@ -93,7 +110,7 @@ async function setup() { } } -setup().catch(error => { +setup().catch((error) => { console.error(error); process.exit(1); });