diff --git a/api/db/generic-json-level.ts b/api/db/generic-json-level.ts index 80b37ce9..c8bb1bf6 100644 --- a/api/db/generic-json-level.ts +++ b/api/db/generic-json-level.ts @@ -5,7 +5,7 @@ import { AbstractValueIterator, } from "abstract-level" import { promises as fs } from "fs" -import path from "path" +import path from "path/posix" interface JSONLevelOptions {} diff --git a/api/db/get-db.ts b/api/db/get-db.ts index 3d9da27b..862aab86 100644 --- a/api/db/get-db.ts +++ b/api/db/get-db.ts @@ -1,5 +1,5 @@ import { mkdirSync } from "fs" -import * as Path from "path" +import * as Path from "path/posix" import { ZodLevelDatabase } from "./zod-level-db" let globalDb: ZodLevelDatabase | undefined diff --git a/bun.lockb b/bun.lockb index d9f15ea4..1308833f 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/cli/lib/cmd-fns/dev/check-if-initialized.ts b/cli/lib/cmd-fns/dev/check-if-initialized.ts index 5f2cea77..f72282da 100644 --- a/cli/lib/cmd-fns/dev/check-if-initialized.ts +++ b/cli/lib/cmd-fns/dev/check-if-initialized.ts @@ -1,6 +1,6 @@ import { AppContext } from "../../util/app-context" import kleur from "kleur" -import * as Path from "path" +import * as Path from "path/posix" import { existsSync, readFileSync } from "fs" export const checkIfInitialized = async (ctx: AppContext) => { diff --git a/cli/lib/cmd-fns/dev/index.ts b/cli/lib/cmd-fns/dev/index.ts index 3feb2e70..f8ffde48 100644 --- a/cli/lib/cmd-fns/dev/index.ts +++ b/cli/lib/cmd-fns/dev/index.ts @@ -4,7 +4,7 @@ import fs from "fs" import kleur from "kleur" import posthog from "cli/lib/posthog" import open from "open" -import * as Path from "path" +import * as Path from "path/posix" import prompts from "prompts" import { z } from "zod" import { AppContext } from "../../util/app-context" diff --git a/cli/lib/cmd-fns/dev/soupify-and-upload-example-file.ts b/cli/lib/cmd-fns/dev/soupify-and-upload-example-file.ts index 9dc555b7..c2c0d612 100644 --- a/cli/lib/cmd-fns/dev/soupify-and-upload-example-file.ts +++ b/cli/lib/cmd-fns/dev/soupify-and-upload-example-file.ts @@ -1,5 +1,5 @@ import kleur from "kleur" -import { join as joinPath } from "path" +import { join as joinPath } from "path/posix" import { AxiosInstance } from "axios" import { readdirSync, readFileSync } from "fs" import { soupify } from "cli/lib/soupify" diff --git a/cli/lib/cmd-fns/dev/start-edit-event-watcher.ts b/cli/lib/cmd-fns/dev/start-edit-event-watcher.ts index 0635bd13..e43b84b0 100644 --- a/cli/lib/cmd-fns/dev/start-edit-event-watcher.ts +++ b/cli/lib/cmd-fns/dev/start-edit-event-watcher.ts @@ -5,7 +5,7 @@ import { AppContext } from "cli/lib/util/app-context" import fg from "fast-glob" import fs from "fs" import { Project, ts } from "ts-morph" -import * as Path from "path" +import * as Path from "path/posix" import { deriveSelectorFromPcbComponentId } from "./derive-selector-from-pcb-component-id" import type { EditEvent } from "@tscircuit/manual-edit-events" import { diff --git a/cli/lib/cmd-fns/dev/upload-examples-from-directory.ts b/cli/lib/cmd-fns/dev/upload-examples-from-directory.ts index 3ff87f44..0be267d6 100644 --- a/cli/lib/cmd-fns/dev/upload-examples-from-directory.ts +++ b/cli/lib/cmd-fns/dev/upload-examples-from-directory.ts @@ -1,5 +1,5 @@ import kleur from "kleur" -import { join as joinPath } from "path" +import { join as joinPath } from "path/posix" import { AxiosInstance } from "axios" import { readdirSync, readFileSync } from "fs" import { soupify } from "cli/lib/soupify" diff --git a/cli/lib/cmd-fns/init/create-or-modify-npmrc.ts b/cli/lib/cmd-fns/init/create-or-modify-npmrc.ts index e5ad0f76..d461f7f1 100644 --- a/cli/lib/cmd-fns/init/create-or-modify-npmrc.ts +++ b/cli/lib/cmd-fns/init/create-or-modify-npmrc.ts @@ -1,6 +1,6 @@ import { existsSync, writeFileSync } from "fs" import kleur from "kleur" -import * as Path from "path" +import * as Path from "path/posix" import { getGeneratedNpmrc } from "./get-generated-npmrc" import { AppContext } from "cli/lib/util/app-context" diff --git a/cli/lib/cmd-fns/init/index.ts b/cli/lib/cmd-fns/init/index.ts index 57a158af..6fcb2c3e 100644 --- a/cli/lib/cmd-fns/init/index.ts +++ b/cli/lib/cmd-fns/init/index.ts @@ -8,7 +8,7 @@ import { writeFile, appendFileSync, } from "fs" -import * as Path from "node:path" +import * as Path from "node:path/posix" import $ from "dax-sh" import { getGeneratedReadme } from "./get-generated-readme" import { getGeneratedTsconfig } from "./get-generated-tsconfig" diff --git a/cli/lib/cmd-fns/open.ts b/cli/lib/cmd-fns/open.ts index 623b9c73..e9c379d0 100644 --- a/cli/lib/cmd-fns/open.ts +++ b/cli/lib/cmd-fns/open.ts @@ -1,7 +1,7 @@ import { existsSync, readFileSync } from "fs" import kleur from "kleur" import { AppContext } from "cli/lib/util/app-context" -import * as Path from "path" +import * as Path from "path/posix" import open from "open" export const openCmd = async (ctx: AppContext, args: any) => { diff --git a/cli/lib/cmd-fns/publish/index.ts b/cli/lib/cmd-fns/publish/index.ts index b4d2e8ed..bfb713d7 100644 --- a/cli/lib/cmd-fns/publish/index.ts +++ b/cli/lib/cmd-fns/publish/index.ts @@ -1,7 +1,7 @@ import kleur from "kleur" import { z } from "zod" import { AppContext } from "../../util/app-context" -import * as Path from "path" +import * as Path from "path/posix" import * as fs from "fs/promises" import { existsSync, readFileSync } from "fs" import { getAllPackageFiles } from "cli/lib/util/get-all-package-files" diff --git a/cli/lib/cmd-fns/render.ts b/cli/lib/cmd-fns/render.ts index de63ba6e..282afee9 100644 --- a/cli/lib/cmd-fns/render.ts +++ b/cli/lib/cmd-fns/render.ts @@ -1,7 +1,7 @@ import { soupify } from "cli/lib/soupify" import type { AppContext } from "cli/lib/util/app-context" import fs from "fs" -import path from "path" +import path from "path/posix" export const renderCmd = async ( ctx: AppContext, diff --git a/cli/lib/cmd-fns/soupify.ts b/cli/lib/cmd-fns/soupify.ts index eb0c8838..eff3e92e 100644 --- a/cli/lib/cmd-fns/soupify.ts +++ b/cli/lib/cmd-fns/soupify.ts @@ -1,6 +1,6 @@ import { AppContext } from "../util/app-context" import { z } from "zod" -import * as Path from "path" +import * as Path from "path/posix" import { unlink } from "node:fs/promises" import { soupify } from "cli/lib/soupify" import { writeFileSync } from "fs" diff --git a/cli/lib/export-fns/export-gerbers.ts b/cli/lib/export-fns/export-gerbers.ts index 6df2d5ef..8d5d576d 100644 --- a/cli/lib/export-fns/export-gerbers.ts +++ b/cli/lib/export-fns/export-gerbers.ts @@ -1,6 +1,6 @@ import { AppContext } from "../util/app-context" import { z } from "zod" -import * as Path from "path" +import * as Path from "path/posix" import { unlink } from "node:fs/promises" import { soupify } from "cli/lib/soupify" import * as fs from "fs" @@ -91,7 +91,6 @@ export const exportGerbersToZipBuffer = async ( ) => { const tempDir = Path.join(".tscircuit", "tmp-gerber-zip") fs.mkdirSync(tempDir, { recursive: true }) - await exportGerbersToFile( { example_file_path: params.example_file_path, diff --git a/cli/lib/export-fns/export-pnp-csv.ts b/cli/lib/export-fns/export-pnp-csv.ts index 512c2313..89800564 100644 --- a/cli/lib/export-fns/export-pnp-csv.ts +++ b/cli/lib/export-fns/export-pnp-csv.ts @@ -1,6 +1,6 @@ import { AppContext } from "../util/app-context" import { z } from "zod" -import * as Path from "path" +import * as Path from "path/posix" import { unlink } from "node:fs/promises" import { soupify } from "cli/lib/soupify" import { convertCircuitJsonToPickAndPlaceCsv } from "circuit-json-to-pnp-csv" diff --git a/cli/lib/soupify/get-tmp-entrpoint-filepath.ts b/cli/lib/soupify/get-tmp-entrpoint-filepath.ts index 4911c49d..6b008a89 100644 --- a/cli/lib/soupify/get-tmp-entrpoint-filepath.ts +++ b/cli/lib/soupify/get-tmp-entrpoint-filepath.ts @@ -1,4 +1,4 @@ -import Path from "node:path" +import Path from "node:path/posix" import fs from "fs/promises" export const getTmpEntrypointFilePath = async (filePath: string) => { diff --git a/cli/lib/soupify/run-entrypoint-file.ts b/cli/lib/soupify/run-entrypoint-file.ts index 4032e33b..434a609f 100644 --- a/cli/lib/soupify/run-entrypoint-file.ts +++ b/cli/lib/soupify/run-entrypoint-file.ts @@ -22,11 +22,11 @@ export const runEntrypointFile = async ( ctx.runtime === "node" ? $`npx tsx ${tmpEntrypointPath}` : $`bun ${tmpEntrypointPath}` - debug(`starting process....`) + const processResult = await processCmdPart1 - .stdout(debug.enabled ? "inheritPiped" : "piped") .stderr(debug.enabled ? "inheritPiped" : "piped") + .stdout(debug.enabled ? "inheritPiped" : "piped") .noThrow() const rawSoup = await readFile(tmpOutputPath, "utf-8") @@ -48,7 +48,6 @@ export const runEntrypointFile = async ( console.log(kleur.red(soup.COMPILE_ERROR)) throw new Error(soup.COMPILE_ERROR) } - return soup } catch (e: any) { // console.log(kleur.red(`Failed to parse result of soupify: ${e.toString()}`)) diff --git a/cli/lib/soupify/soupify-with-core.ts b/cli/lib/soupify/soupify-with-core.ts index e06e6f37..95555cb1 100644 --- a/cli/lib/soupify/soupify-with-core.ts +++ b/cli/lib/soupify/soupify-with-core.ts @@ -1,7 +1,7 @@ import { AppContext } from "../util/app-context" import { z } from "zod" import $ from "dax-sh" -import * as Path from "path" +import * as Path from "path/posix" import { unlink } from "node:fs/promises" import kleur from "kleur" import { writeFileSync } from "fs" diff --git a/cli/lib/util/create-context-and-run-program.ts b/cli/lib/util/create-context-and-run-program.ts index 731ec460..6db4a828 100644 --- a/cli/lib/util/create-context-and-run-program.ts +++ b/cli/lib/util/create-context-and-run-program.ts @@ -104,6 +104,10 @@ export const createContextAndRunProgram = async (process_args: any) => { }, ) + function isBunRuntime() { + return typeof process !== "undefined" && "isBun" in process + } + const ctx: AppContext = { cmd: args._, cwd: args.cwd ?? process.cwd(), @@ -112,7 +116,7 @@ export const createContextAndRunProgram = async (process_args: any) => { axios, global_config, profile_config, - runtime: global_config.get("runtime") ?? "node", + runtime: isBunRuntime() ? "bun" : (global_config.get("runtime") ?? "node"), args: { cmd: args._, yes: args.y ?? args.yes, diff --git a/cli/lib/util/lint-project.ts b/cli/lib/util/lint-project.ts index 3dadd117..73bbf40c 100644 --- a/cli/lib/util/lint-project.ts +++ b/cli/lib/util/lint-project.ts @@ -1,6 +1,6 @@ import * as ts from "typescript" import * as fs from "fs" -import * as path from "path" +import * as path from "path/posix" interface LintResult { filePath: string diff --git a/cli/tests/export-gerber-keyboard.test.ts b/cli/tests/export-gerber-keyboard.test.ts index 610f3754..a24a9076 100644 --- a/cli/tests/export-gerber-keyboard.test.ts +++ b/cli/tests/export-gerber-keyboard.test.ts @@ -1,7 +1,7 @@ import { test, expect, describe } from "bun:test" import { $ } from "bun" import { temporaryDirectory } from "tempy" -import { join } from "path" +import { join } from "path/posix" import { existsSync } from "fs" test("tsci export gerbers --input example-project/examples/macrokeypad.tsx", async () => { diff --git a/cli/tests/export-gerber.test.ts b/cli/tests/export-gerber.test.ts index 21709b8b..135844cf 100644 --- a/cli/tests/export-gerber.test.ts +++ b/cli/tests/export-gerber.test.ts @@ -1,7 +1,7 @@ import { test, expect, describe } from "bun:test" import { $ } from "bun" import { temporaryDirectory } from "tempy" -import { join } from "path" +import { join } from "path/posix" import { existsSync, readdirSync, readFileSync } from "fs" import extract from "extract-zip" import pcbStackup from "pcb-stackup" diff --git a/cli/tests/export-kicad-pcb.test.ts b/cli/tests/export-kicad-pcb.test.ts index 9ce7b342..b35ddce8 100644 --- a/cli/tests/export-kicad-pcb.test.ts +++ b/cli/tests/export-kicad-pcb.test.ts @@ -1,7 +1,7 @@ import { test, expect, describe } from "bun:test" import { $ } from "bun" import { temporaryDirectory } from "tempy" -import { join } from "path" +import { join } from "path/posix" import { existsSync, readFileSync } from "fs" test("tsci export kicad_pcb --input example-project/examples/macrokeypad.tsx", async () => { diff --git a/package.json b/package.json index 91d1fbc4..f4e1e8f0 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "tempy": "^3.1.0", "ts-morph": "^22.0.0", "tsup": "^8.0.2", - "winterspec": "0.0.86", + "winterspec": "0.0.89", "zod": "^3.22.4" }, "peerDependencies": {