Merge pull request #11461 from Budibase/fix/cli-build
Fix for CLI building correctly with esbuild
This commit is contained in:
commit
5601f1b9b5
|
@ -2,16 +2,16 @@
|
||||||
"name": "@budibase/cli",
|
"name": "@budibase/cli",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
||||||
"main": "dist/src/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"budi": "dist/src/index.js"
|
"budi": "dist/index.js"
|
||||||
},
|
},
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "rm -rf prebuilds 2> /dev/null && cp -r ../../node_modules/leveldown/prebuilds prebuilds",
|
"prebuild": "rm -rf prebuilds 2> /dev/null && cp -r ../../node_modules/leveldown/prebuilds prebuilds",
|
||||||
"rename": "renamer --find .node --replace .fake 'prebuilds/**'",
|
"rename": "renamer --find .node --replace .fake 'prebuilds/**'",
|
||||||
"tsc": "tsc -p tsconfig.build.json",
|
"tsc": "node ../../scripts/build.js",
|
||||||
"pkg": "pkg . --out-path build --no-bytecode --public --public-packages \"*\" -C GZip",
|
"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 prebuild && yarn rename && yarn tsc && yarn pkg && yarn postbuild",
|
||||||
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
|
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
|
||||||
|
@ -19,12 +19,11 @@
|
||||||
},
|
},
|
||||||
"pkg": {
|
"pkg": {
|
||||||
"targets": [
|
"targets": [
|
||||||
"node16-linux",
|
"node18-linux",
|
||||||
"node16-win",
|
"node18-win",
|
||||||
"node16-macos"
|
"node18-macos"
|
||||||
],
|
],
|
||||||
"assets": [
|
"assets": [
|
||||||
"node_modules/@budibase/backend-core/dist/**/*",
|
|
||||||
"prebuilds/**/*"
|
"prebuilds/**/*"
|
||||||
],
|
],
|
||||||
"outputPath": "build"
|
"outputPath": "build"
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { error } from "./utils"
|
||||||
|
|
||||||
const PREBUILDS = "prebuilds"
|
const PREBUILDS = "prebuilds"
|
||||||
const ARCH = `${os.platform()}-${os.arch()}`
|
const ARCH = `${os.platform()}-${os.arch()}`
|
||||||
const PREBUILD_DIR = join(process.execPath, "..", PREBUILDS, ARCH)
|
const PREBUILD_DIR = join(process.execPath, "..", "cli", PREBUILDS, ARCH)
|
||||||
|
|
||||||
// running as built CLI pkg bundle
|
// running as built CLI pkg bundle
|
||||||
if (!process.argv[0].includes("node")) {
|
if (!process.argv[0].includes("node")) {
|
||||||
|
@ -13,17 +13,19 @@ if (!process.argv[0].includes("node")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkForBinaries() {
|
function checkForBinaries() {
|
||||||
const readDir = join(__filename, "..", "..", "..", PREBUILDS, ARCH)
|
const readDir = join(__filename, "..", "..", "..", "cli", PREBUILDS, ARCH)
|
||||||
if (fs.existsSync(PREBUILD_DIR) || !fs.existsSync(readDir)) {
|
if (fs.existsSync(PREBUILD_DIR) || !fs.existsSync(readDir)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const natives = fs.readdirSync(readDir)
|
const natives = fs.readdirSync(readDir)
|
||||||
if (fs.existsSync(readDir)) {
|
if (fs.existsSync(readDir)) {
|
||||||
fs.mkdirSync(PREBUILD_DIR, { recursive: true })
|
const writePath = join(process.execPath, PREBUILDS, ARCH)
|
||||||
|
fs.mkdirSync(writePath, { recursive: true })
|
||||||
for (let native of natives) {
|
for (let native of natives) {
|
||||||
const filename = `${native.split(".fake")[0]}.node`
|
const filename = `${native.split(".fake")[0]}.node`
|
||||||
fs.cpSync(join(readDir, native), join(PREBUILD_DIR, filename))
|
fs.cpSync(join(readDir, native), join(writePath, filename))
|
||||||
}
|
}
|
||||||
|
console.log("copied something")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +41,9 @@ function cleanup(evt?: number) {
|
||||||
)
|
)
|
||||||
console.error(error(evt))
|
console.error(error(evt))
|
||||||
}
|
}
|
||||||
if (fs.existsSync(PREBUILD_DIR)) {
|
const path = join(process.execPath, PREBUILDS)
|
||||||
fs.rmSync(PREBUILD_DIR, { recursive: true })
|
if (fs.existsSync(path)) {
|
||||||
|
fs.rmSync(path, { recursive: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,12 @@
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"types": [ "node", "jest" ],
|
"types": [ "node", "jest" ],
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true,
|
||||||
|
"paths": {
|
||||||
|
"@budibase/types": ["../types/src"],
|
||||||
|
"@budibase/backend-core": ["../backend-core/src"],
|
||||||
|
"@budibase/backend-core/*": ["../backend-core/*"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*"
|
"src/**/*"
|
||||||
|
|
|
@ -5,12 +5,7 @@
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true
|
||||||
"paths": {
|
|
||||||
"@budibase/types": ["../types/src"],
|
|
||||||
"@budibase/backend-core": ["../backend-core/src"],
|
|
||||||
"@budibase/backend-core/*": ["../backend-core/*"]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"require": ["tsconfig-paths/register"],
|
"require": ["tsconfig-paths/register"],
|
||||||
|
|
Loading…
Reference in New Issue