From d35cd2631ccdb66d9bdf700795f83d40b3569dd8 Mon Sep 17 00:00:00 2001 From: Austin Golding Date: Thu, 28 Sep 2023 14:17:57 -0700 Subject: [PATCH] Release 0.9.4 --- Dockerfile | 3 +- package.json | 17 +++++++--- scripts/create-release.mjs | 63 ++++++++++++++++++++++++++++++-------- yarn.lock | 32 ++++++++----------- 4 files changed, 77 insertions(+), 38 deletions(-) diff --git a/Dockerfile b/Dockerfile index f5d93188..b8c65b1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,7 @@ FROM node:18-bullseye as redeye-builder WORKDIR /app COPY ./ ./ ENV CYPRESS_INSTALL_BINARY=0 -RUN npm install -g pkg -RUN yarn add rimraf +RUN npm install -g pkg rimraf RUN yarn install --immutable --inline-builds RUN yarn moon run server:build client:build RUN yarn node scripts/create-release.mjs diff --git a/package.json b/package.json index 92f2c68a..fbf7cb3e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "redeye", "productName": "RedEye", - "version": "0.9.3", + "version": "0.9.4", "private": true, "workspaces": [ "applications/**", @@ -35,10 +35,10 @@ "cy:open": "yarn moon run @redeye/e2e:open-cy", "cy:open-blue": "yarn moon run @redeye/e2e:open-cy-blue", "start:blue": "SERVER_BLUE_TEAM=true yarn run start:dev", - "release:all": "yarn moon run server:release-all && yarn moon run cobalt-strike-parser:release-all && yarn moon run brute-ratel-parser:release-all", - "release:mac": "yarn moon run server:release-mac && yarn moon run cobalt-strike-parser:release-mac && yarn moon run brute-ratel-parser:release-mac", - "release:linux": "yarn moon run server:release-linux && yarn moon run cobalt-strike-parser:release-linux && yarn moon run brute-ratel-parser:release-linux", - "release:windows": "yarn moon run server:release-windows && yarn moon run cobalt-strike-parser:release-windows && yarn moon run brute-ratel-parser:release-windows" + "release:all": "yarn node ./scripts/create-release.mjs", + "release:mac": "yarn node ./scripts/create-release.mjs --os mac", + "release:linux": "yarn node ./scripts/create-release.mjs --os linux", + "release:windows": "yarn node ./scripts/create-release.mjs --os windows" }, "dependencies": { "@apollo/server": "^4.7.0", @@ -55,6 +55,7 @@ "@openfonts/ibm-plex-sans_all": "^1.44.2", "@tanstack/react-query": "^4.1.3", "astro": "^2.5.6", + "better-sqlite3": "^8.6.0", "blueprint-styler": "^5.0.1", "chokidar": "^3.4.1", "class-validator": "^0.14.0", @@ -212,7 +213,13 @@ "vite-plugin-dts": "^2.3.0", "vite-tsconfig-paths": "^4.2.0" }, + "overrides": { + "pkg": { + "pkg-fetch": "^3.5.2" + } + }, "resolutions": { + "pkg-fetch": "^3.5.2", "@moonrepo/core-linux-arm64-gnu": "1.9.2", "@moonrepo/core-linux-arm64-musl": "1.9.2", "@moonrepo/core-linux-x64-gnu": "1.9.2", diff --git a/scripts/create-release.mjs b/scripts/create-release.mjs index d7bb2b7c..c80fbe58 100644 --- a/scripts/create-release.mjs +++ b/scripts/create-release.mjs @@ -1,12 +1,34 @@ -import { resolve, join } from 'node:path'; +import { resolve } from 'node:path'; import { readdir } from 'node:fs/promises'; -import childProc from 'node:child_process'; import { fileURLToPath } from 'node:url'; -import { promisify } from 'node:util'; +import { parseArgs } from 'node:util'; +import {exec as pkgExec} from 'pkg' -const exec = promisify(childProc.exec); +const { + values: { + /** @type {string} */ + nodeVersion, + /** @type {['all'] | ('mac' | 'linux' | 'windows' | 'mac-arm')[]} */ + os + }, +} = parseArgs({ + options: { + nodeVersion: { + type: "string", + short: "n", + default: "18.15.0", + }, + os: { + type: "string", + multiple: true, + default: ["all"], + short: "o", + }, + }, +}); -const NODE_VER = 'node18'; + +const NODE_VER = nodeVersion; const __dirname = fileURLToPath(new URL('.', import.meta.url)); const rootDir = resolve(__dirname, '..'); @@ -14,10 +36,22 @@ const releaseDir = resolve(rootDir, 'release'); const OS_ARCH = { - mac: 'macos-x64', - linux: 'linux-x64', - windows: 'win-x64', - 'mac-arm': 'macos-arm64', + mac: { + platform: 'macos', + arch: 'x64', + }, + linux: { + platform: 'linux', + arch: 'x64', + }, + windows: { + platform: 'windows', + arch: 'x64', + }, + 'mac-arm': { + platform: 'macos', + arch: 'arm64', + }, }; const PARSERS = []; @@ -30,11 +64,16 @@ const PROJECTS = [ { path: 'applications/server/package.json', out: 'RedEye' }, ...PARSERS.map((parser) => ({ path: `parsers/${parser}`, out: `parsers/${parser}` })), ]; - +const isAllOS = os.includes('all'); for (const [OS, PKG_KEY] of Object.entries(OS_ARCH)) { + if (!isAllOS && !os.includes(OS)) { + continue; + } + console.log('Building for: ', OS) for (const project of PROJECTS) { - await exec( - `yarn pkg ${project.path} -t ${NODE_VER}-${PKG_KEY} -o ${resolve(releaseDir, `RedEye-${OS}`, project.out)}` + console.log('\tBuilding: ', project.path) + await pkgExec( + [project.path, '-t', `node${NODE_VER}-${PKG_KEY.platform}-${PKG_KEY.arch}`, '-o', resolve(releaseDir, `RedEye-${OS}`, project.out)] ); } } diff --git a/yarn.lock b/yarn.lock index a9608e51..4bb2bc1f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5350,6 +5350,17 @@ __metadata: languageName: node linkType: hard +"better-sqlite3@npm:^8.6.0": + version: 8.6.0 + resolution: "better-sqlite3@npm:8.6.0" + dependencies: + bindings: ^1.5.0 + node-gyp: latest + prebuild-install: ^7.1.1 + checksum: 9ebdfd675352347cda1ba30d620a3c512d9db827a1eba66460fd48203a7ad8138b0195893bbf47d40f704bcdd598710041271d4ed69779979b6f784c0d3579a1 + languageName: node + linkType: hard + "big-integer@npm:^1.6.44": version: 1.6.51 resolution: "big-integer@npm:1.6.51" @@ -13965,24 +13976,6 @@ __metadata: languageName: node linkType: hard -"pkg-fetch@npm:3.4.2": - version: 3.4.2 - resolution: "pkg-fetch@npm:3.4.2" - dependencies: - chalk: ^4.1.2 - fs-extra: ^9.1.0 - https-proxy-agent: ^5.0.0 - node-fetch: ^2.6.6 - progress: ^2.0.3 - semver: ^7.3.5 - tar-fs: ^2.1.1 - yargs: ^16.2.0 - bin: - pkg-fetch: lib-es5/bin.js - checksum: e0f73cedf6cb8882e4d998700031443e6542d213f9817d66deb03fb89c122ca7f7505f11401f85a760a2d3951f9b793d0f78782be220c46c56ccf70f9915812a - languageName: node - linkType: hard - "pkg-fetch@npm:^3.5.2": version: 3.5.2 resolution: "pkg-fetch@npm:3.5.2" @@ -14074,7 +14067,7 @@ __metadata: languageName: node linkType: hard -"prebuild-install@npm:7.1.1, prebuild-install@npm:^7.1.0": +"prebuild-install@npm:7.1.1, prebuild-install@npm:^7.1.0, prebuild-install@npm:^7.1.1": version: 7.1.1 resolution: "prebuild-install@npm:7.1.1" dependencies: @@ -14840,6 +14833,7 @@ __metadata: "@xstate/cli": ^0.5.0 astro: ^2.5.6 barrelsby: ^2.8.0 + better-sqlite3: ^8.6.0 blueprint-styler: ^5.0.1 builder-util: ^23.0.2 chokidar: ^3.4.1