diff --git a/build/build-ci.js b/build/build-ci.js index a6a79df3..4bfa56de 100644 --- a/build/build-ci.js +++ b/build/build-ci.js @@ -13,10 +13,11 @@ cp("-R", "./build", kitPath()) cp("-R", "./src/types", kitPath()) cp("*.md", kitPath()) +cp(".npmrc", kitPath()) cp("package*.json", kitPath()) cp("LICENSE", kitPath()) -let { stdout: nodeVersion } = await exec("node --version") +let { stdout: nodeVersion } = await exec("pnpm node --version") console.log({ nodeVersion }) let { stdout: npmVersion } = await exec("pnpm --version") console.log({ npmVersion }) diff --git a/root/bin/kit b/root/bin/kit index 11faff37..034708ab 100755 --- a/root/bin/kit +++ b/root/bin/kit @@ -13,9 +13,9 @@ KIT=$(cd "$(dirname $(readlink -f ${BASH_SOURCE[0]}))/.." &>/dev/null && pwd) pwd )" -KIT_NODE="${KIT_NODE:=$KIT/../.kenv/bin/pnpm node}" +KIT_NODE="${KIT_NODE:=$(pnpm node -e 'console.log(process.execPath)')}" # Default to system node if KIT_NODE doesn't exist -[ ! -f $KIT_NODE ] && KIT_NODE=$(which node) +[ ! -f "$KIT_NODE" ] && KIT_NODE=$(which node) if [[ $KIT =~ ^/[a-zA-Z]/ ]]; then drive_letter=${KIT:1:1} diff --git a/root/bin/kit.bat b/root/bin/kit.bat index 98ab3b81..0cb36493 100644 --- a/root/bin/kit.bat +++ b/root/bin/kit.bat @@ -16,7 +16,9 @@ if %errorlevel%==0 ( REM Set the default KIT_NODE variable to the custom node binary if not defined KIT_NODE ( - set "KIT_NODE=%KIT%/../.kenv/bin/pnpm node" + for /f "tokens=* USEBACKQ" %%F in (`powershell -Command "pnpm node -e 'console.log(process.execPath)'"`) do ( + set "KIT_NODE=%%F" + ) ) REM Check if the custom node binary exists, if not, use the system's node binary diff --git a/scripts/test-pre.js b/scripts/test-pre.js index e6d7ebbd..50d4e73f 100644 --- a/scripts/test-pre.js +++ b/scripts/test-pre.js @@ -1,44 +1,43 @@ /** @type {import("/Users/johnlindquist/.kit")} */ -import { pathToFileURL } from 'node:url' -import { rimraf } from 'rimraf' +import { pathToFileURL } from "node:url" +import { rimraf } from "rimraf" async function importRelativePath(relativePath) { - const path = await import("node:path") - const { fileURLToPath, pathToFileURL } = await import("node:url") - const __filename = fileURLToPath(import.meta.url); - const __dirname = path.dirname(__filename); - const absolutePath = path.join(__dirname, relativePath); - const fileURL = pathToFileURL(absolutePath).href; - return import(fileURL); + const path = await import("node:path") + const { fileURLToPath, pathToFileURL } = await import("node:url") + const __filename = fileURLToPath(import.meta.url) + const __dirname = path.dirname(__filename) + const absolutePath = path.join(__dirname, relativePath) + const fileURL = pathToFileURL(absolutePath).href + return import(fileURL) } -await importRelativePath("../test-sdk/config.js"); +await importRelativePath("../test-sdk/config.js") console.log({ kenvTestPath }) -let escapePathPeriods = p => p.replace(/\./g, "\\.") +let escapePathPeriods = (p) => p.replace(/\./g, "\\.") let userKenv = (...parts) => { - return pathToFileURL(home(".kenv", ...parts.filter(Boolean))).href + return pathToFileURL(home(".kenv", ...parts.filter(Boolean))).href } let userBinPath = userKenv("bin") if (await isDir(userBinPath)) { - let staleMocks = userKenv("bin", "mock*") - console.log(`Removing stale mocks: ${staleMocks}`) - await rimraf(escapePathPeriods(staleMocks)) + let staleMocks = userKenv("bin", "mock*") + console.log(`Removing stale mocks: ${staleMocks}`) + await rimraf(escapePathPeriods(staleMocks)) } if (await isDir("-d", kitMockPath())) { - await rimraf(escapePathPeriods(kitMockPath())) + await rimraf(escapePathPeriods(kitMockPath())) } if (await isDir(kenvTestPath)) { - console.log(`Clearing ${kenvTestPath}`) - await rimraf(escapePathPeriods(kenvTestPath)) + console.log(`Clearing ${kenvTestPath}`) + await rimraf(escapePathPeriods(kenvTestPath)) } -let { stdout: branch, stderr } = - await exec("git branch --show-current") +let { stdout: branch, stderr } = await exec("git branch --show-current") if (stderr || !branch.match(/main|beta|alpha|next/)) exit(1) @@ -48,16 +47,20 @@ let repo = `johnlindquist/kenv#${branch}` console.log(`Cloning ${repo} to ${kenvTestPath}`) await degit(repo, { - force: true, + force: true }).clone(kenvTestPath) console.log(`Cloning ${repo} to ${kenvSetupPath}`) await degit(repo, { - force: true, + force: true }).clone(kenvSetupPath) +console.log({ kitPath: kitPath() }) + process.env.KENV = kenvTestPath + +console.log({ kitPath: kitPath() }) await rimraf(escapePathPeriods(kitPath("db", "scripts.json"))) await exec(`kit "${kitPath("setup", "setup.js")}" --no-edit`) // console.log(