diff --git a/AGENTS.md b/AGENTS.md index a7894f2a2..6385560ab 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 1777865644 +# bump 1777865732 +# bump 1777867214 +# bump 1777910427 +# bump 1777953613 +# bump 1777996815 +# bump 1778040019 +# bump 1778083222 +# bump 1778126419 diff --git a/lib/shared/push-snippet.ts b/lib/shared/push-snippet.ts index 75bc61dea..48a785c73 100644 --- a/lib/shared/push-snippet.ts +++ b/lib/shared/push-snippet.ts @@ -5,6 +5,7 @@ import * as path from "node:path" import semver from "semver" import Debug from "debug" import kleur from "kleur" +import { globbySync } from "globby" import { getEntrypoint } from "./get-entrypoint" import prompts from "lib/utils/prompts" import { getUnscopedPackageName } from "lib/utils/get-unscoped-package-name" @@ -14,6 +15,7 @@ import { getPackageFilePaths } from "lib/dev/get-package-file-paths" import { checkOrgAccess } from "lib/utils/check-org-access" import { isBinaryFile } from "./is-binary-file" import { hasBinaryContent } from "./has-binary-content" +import { DEFAULT_IGNORED_PATTERNS } from "./should-ignore-path" import JSZip from "jszip" type PushOptions = { @@ -75,12 +77,33 @@ export const pushSnippet = async ({ } // Detect the entrypoint file - const snippetFilePath = await getEntrypoint({ + let snippetFilePath = await getEntrypoint({ filePath, onSuccess: () => {}, onError, }) + // Fallback: if no entrypoint found, look for any .tsx/.ts/.circuit.json file + // This mirrors `tsci dev` behavior which also finds alternative files + if (!snippetFilePath) { + const fallbackFiles = globbySync( + ["**/*.tsx", "**/*.ts", "**/*.circuit.json"], + { + cwd: process.cwd(), + ignore: DEFAULT_IGNORED_PATTERNS, + }, + ) + if (fallbackFiles.length > 0) { + const fallbackPath = path.resolve(process.cwd(), fallbackFiles[0]) + console.log( + kleur.gray( + `No standard entrypoint found. Using fallback file: '${path.relative(process.cwd(), fallbackPath)}'`, + ), + ) + snippetFilePath = fallbackPath + } + } + if (!snippetFilePath) { return onExit(1) }