diff --git a/AGENTS.md b/AGENTS.md index a7894f2a2..e679b996c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -80,3 +80,12 @@ Test fixture provides: ## Runtime The CLI entrypoint (`cli/entrypoint.js`) selects between Bun and tsx as the TypeScript runner, preferring Bun when available. This allows hot-reload during development while maintaining Node.js compatibility. +# bump 1777865639 +# bump 1777865726 +# bump 1777867209 +# bump 1777910411 +# bump 1777953607 +# bump 1777996807 +# bump 1778040013 +# bump 1778083216 +# bump 1778126413 diff --git a/lib/shared/export-snippet.ts b/lib/shared/export-snippet.ts index d7459d0df..4e5e0d04d 100644 --- a/lib/shared/export-snippet.ts +++ b/lib/shared/export-snippet.ts @@ -55,6 +55,7 @@ export const ALLOWED_EXPORT_FORMATS = [ "srj", "step", "assembly-svg", + "pnp-csv", ] as const export type ExportFormat = (typeof ALLOWED_EXPORT_FORMATS)[number] @@ -76,6 +77,7 @@ const OUTPUT_EXTENSIONS: Record = { "kicad-library": "", srj: ".simple-route.json", step: ".step", + "pnp-csv": "-pnp.csv", } const isRecord = (value: unknown): value is Record => @@ -345,6 +347,9 @@ export const exportSnippet = async ({ case "assembly-svg": outputContent = convertCircuitJsonToAssemblySvg(circuitJson) break + case "pnp-csv": + outputContent = await convertCircuitJsonToPickAndPlaceCsv(circuitJson) + break default: outputContent = JSON.stringify(circuitJson, null, 2) } diff --git a/lib/shared/push-snippet.ts b/lib/shared/push-snippet.ts index 75bc61dea..21b1173e3 100644 --- a/lib/shared/push-snippet.ts +++ b/lib/shared/push-snippet.ts @@ -6,6 +6,7 @@ import semver from "semver" import Debug from "debug" import kleur from "kleur" import { getEntrypoint } from "./get-entrypoint" +import { globbySync } from "globby" import prompts from "lib/utils/prompts" import { getUnscopedPackageName } from "lib/utils/get-unscoped-package-name" import { getPackageAuthor } from "lib/utils/get-package-author" @@ -75,12 +76,31 @@ export const pushSnippet = async ({ } // Detect the entrypoint file - const snippetFilePath = await getEntrypoint({ + let snippetFilePath = await getEntrypoint({ filePath, onSuccess: () => {}, onError, }) + // If no entrypoint found, try to find any valid circuit file (like tsci dev does) + if (!snippetFilePath) { + const projectDir = process.cwd() + const validFiles = globbySync( + ["**/*.tsx", "**/*.ts", "**/*.circuit.json"], + { + cwd: projectDir, + ignore: ["node_modules/**", "**/.*"], + }, + ).filter((relativePath) => + fs.existsSync(path.join(projectDir, relativePath)), + ) + + if (validFiles.length > 0) { + snippetFilePath = path.resolve(projectDir, validFiles[0]) + onSuccess(`Using fallback file: '${validFiles[0]}'`) + } + } + if (!snippetFilePath) { return onExit(1) }