Skip to content

Commit

Permalink
chore(mitm-socket): move connect to os-arch dir
Browse files Browse the repository at this point in the history
chore: update tar dependency
  • Loading branch information
blakebyrnes committed Sep 26, 2024
1 parent cd0b43d commit 3b536f3
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 27 deletions.
38 changes: 20 additions & 18 deletions agent/mitm-socket/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ const { createHash } = require('crypto');
const { gunzipSync } = require('zlib');
const packageJson = require('./package.json');

const outDir = `${__dirname}/dist`;
const arch = process.env.npm_config_cpu || os.arch();
const platform = process.env.npm_config_os || os.platform();

const outDir = `${__dirname}/dist/${platform}-${arch}`;

if (!fs.existsSync(outDir)) {
fs.mkdirSync(outDir);
fs.mkdirSync(outDir, { recursive: true });
}
const { version } = packageJson;
const releasesAssetsUrl = `https://github.com/ulixee/hero/releases/download/v${version}`;
Expand All @@ -19,24 +22,24 @@ const forceBuild = Boolean(JSON.parse(process.env.ULX_MITM_REBUILD_SOCKET || 'fa
(async function install() {
let programName = 'connect';
const filename = buildFilename();
if (os.platform() === 'win32') {
if (platform === 'win32') {
programName += '.exe';
}

try {
if (fs.existsSync(`${__dirname}/dist/artifacts.json`)) {
const artifacts = JSON.parse(fs.readFileSync(`${__dirname}/dist/artifacts.json`, 'utf8'));
let platform = os.platform();
if (os.platform() === 'win32') {
platform = 'windows';
let artPlatform = platform;
if (platform === 'win32') {
artPlatform = 'windows';
}
let arch = os.arch();
if (os.arch() === 'x86_64') {
arch = 'amd64';
let artArch = arch;
if (arch === 'x86_64') {
artArch = 'amd64';
}
const artifact = artifacts.find(x => x.goos === platform && x.goarch === arch);
const artifact = artifacts.find(x => x.goos === artPlatform && x.goarch === artArch);
if (artifact) {
fs.copyFileSync(artifact.path, `${__dirname}/dist/${artifact.name}`);
fs.copyFileSync(artifact.path, `${outDir}/${artifact.name}`);
saveVersion();
console.log('Successfully copied Agent connect library');
}
Expand Down Expand Up @@ -129,19 +132,18 @@ function saveVersion() {
}

function buildFilename() {
let platform = String(os.platform());
let arch = os.arch();
if (arch === 'x64') arch = 'x86_64';
if (arch === 'ia32') arch = 'i386';
let arch_name = arch;
let platform_name = String(platform);
if (arch === 'x64') arch_name = 'x86_64';

if (platform === 'win32') {
platform = 'win';
platform_name = 'win';
}
if (platform === 'darwin') {
platform = 'mac';
platform_name = 'mac';
}

return `connect_${version}_${platform}_${arch}.gz`;
return `connect_${version}_${platform_name}_${arch_name}.gz`;
}

function download(filepath) {
Expand Down
9 changes: 5 additions & 4 deletions agent/mitm-socket/lib/BaseIpcHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import * as Fs from 'fs';
import * as Path from 'path';

const ext = os.platform() === 'win32' ? '.exe' : '';
const libPath = Path.join(__dirname, '/../dist/', `connect${ext}`).replace(
'app.asar',
'app.asar.unpacked',
);
const libPath = Path.join(
__dirname,
`/../dist/${os.platform()}-${os.arch()}`,
`connect${ext}`,
).replace('app.asar', 'app.asar.unpacked');

const distExists = Fs.existsSync(libPath);

Expand Down
2 changes: 1 addition & 1 deletion double-agent/collect-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"p-queue": "^6.2.1",
"path-to-regexp": "^6.1.0",
"source-map-support": "^0.5.16",
"tar": "^6.2.1",
"tar": "^7.4.3",
"ws": "^8.18.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion double-agent/runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"commander": "^9.5.0",
"node-fetch": "^2.6.1",
"p-queue": "^6.6.2",
"tar": "^6.2.1"
"tar": "^7.4.3"
},
"devDependencies": {
"@types/unzipper": "^0.10.5"
Expand Down
2 changes: 1 addition & 1 deletion plugins/default-browser-emulator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@ulixee/unblocked-specification": "2.0.0-alpha.29",
"compare-versions": "^6.1.0",
"nanoid": "^3.3.6",
"tar": "^6.2.1",
"tar": "^7.4.3",
"tough-cookie": "^4.1.3",
"ua-parser-js": "^1.0.37"
},
Expand Down
53 changes: 51 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,13 @@
wrap-ansi "^8.1.0"
wrap-ansi-cjs "npm:wrap-ansi@^7.0.0"

"@isaacs/fs-minipass@^4.0.0":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz#2d59ae3ab4b38fb4270bfa23d30f8e2e86c7fe32"
integrity sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==
dependencies:
minipass "^7.0.4"

"@istanbuljs/load-nyc-config@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
Expand Down Expand Up @@ -2521,6 +2528,11 @@ chownr@^2.0.0:
resolved "https://registry.yarnpkg.com/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece"
integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==

chownr@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/chownr/-/chownr-3.0.0.tgz#9855e64ecd240a9cc4267ce8a4aa5d24a1da15e4"
integrity sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==

chrome-launcher@^0.13.4:
version "0.13.4"
resolved "https://registry.yarnpkg.com/chrome-launcher/-/chrome-launcher-0.13.4.tgz#4c7d81333c98282899c4e38256da23e00ed32f73"
Expand Down Expand Up @@ -4309,7 +4321,7 @@ glob-parent@^6.0.2:
dependencies:
is-glob "^4.0.3"

glob@^10.2.2, glob@^10.3.10:
glob@^10.2.2, glob@^10.3.10, glob@^10.3.7:
version "10.4.5"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956"
integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==
Expand Down Expand Up @@ -6175,7 +6187,7 @@ minipass@^5.0.0:
resolved "https://registry.yarnpkg.com/minipass/-/minipass-5.0.0.tgz#3e9788ffb90b694a5d0ec94479a45b5d8738133d"
integrity sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==

"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.0.2, minipass@^7.0.3, minipass@^7.1.2:
"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.0.2, minipass@^7.0.3, minipass@^7.0.4, minipass@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.2.tgz#93a9626ce5e5e66bd4db86849e7515e92340a707"
integrity sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==
Expand All @@ -6188,6 +6200,14 @@ minizlib@^2.1.1, minizlib@^2.1.2:
minipass "^3.0.0"
yallist "^4.0.0"

minizlib@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-3.0.1.tgz#46d5329d1eb3c83924eff1d3b858ca0a31581012"
integrity sha512-umcy022ILvb5/3Djuu8LWeqUa8D68JaBzlttKeMWen48SjabqS3iY5w/vzeMzMUNhLDifyhbOwKDSznB1vvrwg==
dependencies:
minipass "^7.0.4"
rimraf "^5.0.5"

mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3:
version "0.5.3"
resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113"
Expand All @@ -6205,6 +6225,11 @@ mkdirp@^1.0.3, mkdirp@^1.0.4:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

mkdirp@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-3.0.1.tgz#e44e4c5607fb279c168241713cc6e0fea9adcb50"
integrity sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==

moment@^2.29.0, moment@^2.29.4:
version "2.30.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae"
Expand Down Expand Up @@ -7339,6 +7364,13 @@ [email protected], rimraf@^3.0.0, rimraf@^3.0.2:
dependencies:
glob "^7.1.3"

rimraf@^5.0.5:
version "5.0.10"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-5.0.10.tgz#23b9843d3dc92db71f96e1a2ce92e39fd2a8221c"
integrity sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==
dependencies:
glob "^10.3.7"

rimraf@~2.5.2:
version "2.5.4"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04"
Expand Down Expand Up @@ -8023,6 +8055,18 @@ tar@^6.2.1:
mkdirp "^1.0.3"
yallist "^4.0.0"

tar@^7.4.3:
version "7.4.3"
resolved "https://registry.yarnpkg.com/tar/-/tar-7.4.3.tgz#88bbe9286a3fcd900e94592cda7a22b192e80571"
integrity sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==
dependencies:
"@isaacs/fs-minipass" "^4.0.0"
chownr "^3.0.0"
minipass "^7.1.2"
minizlib "^3.0.1"
mkdirp "^3.0.1"
yallist "^5.0.0"

temp-dir@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/temp-dir/-/temp-dir-3.0.0.tgz#7f147b42ee41234cc6ba3138cd8e8aa2302acffa"
Expand Down Expand Up @@ -8743,6 +8787,11 @@ yallist@^4.0.0:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==

yallist@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-5.0.0.tgz#00e2de443639ed0d78fd87de0d27469fbcffb533"
integrity sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==

[email protected]:
version "2.3.1"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.1.tgz#02fe0975d23cd441242aa7204e09fc28ac2ac33b"
Expand Down

0 comments on commit 3b536f3

Please sign in to comment.