Skip to content

fix: add fallback to find any .tsx/.ts/.circuit.json when no standard entrypoint found#2913

Open
64johnlee wants to merge 1 commit intotscircuit:mainfrom
64johnlee:fix/tsci-push-fallback-to-any-circuit-file
Open

fix: add fallback to find any .tsx/.ts/.circuit.json when no standard entrypoint found#2913
64johnlee wants to merge 1 commit intotscircuit:mainfrom
64johnlee:fix/tsci-push-fallback-to-any-circuit-file

Conversation

@64johnlee
Copy link
Copy Markdown

Summary

tsci push fails when no index.circuit.tsx (or other standard entrypoint) exists AND no mainEntrypoint is configured in tscircuit.config.json. However, tsci dev finds alternative files — so push should do the same.

Root Cause

push-snippet.ts calls getEntrypoint() and immediately exits if it returns null. Meanwhile, resolve-dev-target.ts has a fallback that uses findSelectableFiles() to locate any .tsx/.ts/.circuit.json file when getEntrypoint() fails.

Fix

Added the same fallback logic to pushSnippet():

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: ...`))
    snippetFilePath = fallbackPath
  }
}

This keeps the priority: explicit filePath argument > mainEntrypoint config > standard entrypoint names > fallback to any circuit file.

Testing

  • Existing tests pass
  • Logic mirrors tsci dev fallback behavior

Related

… entrypoint found

tsci push currently fails when no index.circuit.tsx or mainEntrypoint is
configured, even though tsci dev finds alternative files. This mirrors the
fallback behavior already present in resolve-dev-target.ts where it looks
for any .tsx/.ts/.circuit.json file if getEntrypoint() returns null.

The fallback is gated behind getEntrypoint() returning null, so if the user
provided a specific filePath or configured mainEntrypoint, those still take
precedence. Only when no entrypoint can be detected does the fallback kick in.

Fixes tscircuit#2797
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsci push fails when no index.circuit.tsx file and no mainEntrypoint

1 participant