1
0
Fork 0
mirror of synced 2024-10-02 18:16:29 +13:00

Merge pull request #12686 from Budibase/fix/cli-build-remove-pkg

Remove CLI PKG build
This commit is contained in:
Michael Drury 2024-01-03 10:01:03 +00:00 committed by GitHub
commit 28e810255c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 1326 deletions

View file

@ -5,7 +5,6 @@ build/
docker-error.log
envoy.yaml
*.tar.gz
prebuilds/
dist/
budibase-automation/
budibase-component/

View file

@ -9,26 +9,11 @@
"author": "Budibase",
"license": "GPL-3.0",
"scripts": {
"prebuild": "rm -rf prebuilds 2> /dev/null && cp -r ../../node_modules/leveldown/prebuilds prebuilds",
"rename": "renamer --find .node --replace .fake 'prebuilds/**'",
"tsc": "node ../../scripts/build.js",
"pkg": "pkg . --out-path build --no-bytecode --public --public-packages \"*\" -C GZip",
"build": "yarn prebuild && yarn rename && yarn tsc && yarn pkg && yarn postbuild",
"build": "yarn tsc",
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
"postbuild": "rm -rf prebuilds 2> /dev/null",
"start": "ts-node ./src/index.ts"
},
"pkg": {
"targets": [
"node18-linux",
"node18-win",
"node18-macos"
],
"assets": [
"prebuilds/**/*"
],
"outputPath": "build"
},
"dependencies": {
"@budibase/backend-core": "0.0.0",
"@budibase/string-templates": "0.0.0",
@ -43,7 +28,6 @@
"inquirer": "8.0.0",
"lookpath": "1.1.0",
"node-fetch": "2.6.7",
"pkg": "5.8.0",
"posthog-node": "1.3.0",
"pouchdb": "7.3.0",
"pouchdb-replication-stream": "1.2.9",
@ -55,7 +39,6 @@
"@types/jest": "29.5.5",
"@types/node-fetch": "2.6.4",
"@types/pouchdb": "^6.4.0",
"renamer": "^4.0.0",
"ts-node": "10.8.1",
"typescript": "5.2.2"
}

View file

@ -1,10 +1,9 @@
#!/usr/bin/env node
process.env.DISABLE_PINO_LOGGER = "1"
import "./prebuilds"
import "./environment"
import { getCommands } from "./options"
import { Command } from "commander"
import { getHelpDescription } from "./utils"
import { getHelpDescription, error } from "./utils"
import { version } from "../package.json"
// add hosting config
@ -21,6 +20,23 @@ async function init() {
await program.parseAsync(process.argv)
}
const events = ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "uncaughtException"]
events.forEach(event => {
process.on(event, (evt?: number) => {
if (evt && !isNaN(evt)) {
return
}
if (evt) {
console.error(
error(
"Failed to run CLI command - please report with the following message:"
)
)
console.error(error(evt))
}
})
})
init().catch(err => {
console.error(`Unexpected error - `, err)
})

View file

@ -1,57 +0,0 @@
import os from "os"
import { join } from "path"
import fs from "fs"
import { error } from "./utils"
const PREBUILDS = "prebuilds"
const ARCH = `${os.platform()}-${os.arch()}`
const PREBUILD_DIR = join(process.execPath, "..", "cli", PREBUILDS, ARCH)
// running as built CLI pkg bundle
if (!process.argv[0].includes("node")) {
checkForBinaries()
}
function localPrebuildPath() {
return join(process.execPath, "..", PREBUILDS)
}
function checkForBinaries() {
const readDir = join(__filename, "..", "..", "..", "cli", PREBUILDS, ARCH)
if (fs.existsSync(PREBUILD_DIR) || !fs.existsSync(readDir)) {
return
}
const natives = fs.readdirSync(readDir)
if (fs.existsSync(readDir)) {
const writePath = join(localPrebuildPath(), ARCH)
fs.mkdirSync(writePath, { recursive: true })
for (let native of natives) {
const filename = `${native.split(".fake")[0]}.node`
fs.cpSync(join(readDir, native), join(writePath, filename))
}
}
}
function cleanup(evt?: number) {
// cleanup prebuilds first
const path = localPrebuildPath()
if (fs.existsSync(path)) {
fs.rmSync(path, { recursive: true })
}
if (evt && !isNaN(evt)) {
return
}
if (evt) {
console.error(
error(
"Failed to run CLI command - please report with the following message:"
)
)
console.error(error(evt))
}
}
const events = ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "uncaughtException"]
events.forEach(event => {
process.on(event, cleanup)
})

1306
yarn.lock

File diff suppressed because it is too large Load diff