Skip to content

Commit

Permalink
fix(wip): pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlindquist committed Sep 1, 2024
1 parent 340ac62 commit eb161b0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 26 deletions.
3 changes: 2 additions & 1 deletion build/build-ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
4 changes: 2 additions & 2 deletions root/bin/kit
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 3 additions & 1 deletion root/bin/kit.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 25 additions & 22 deletions scripts/test-pre.js
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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(
Expand Down

0 comments on commit eb161b0

Please sign in to comment.