Skip to content

chore: only show the "Open in Stackblitz" button when there are no actual templates defined #349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/backend/server/utils/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ _commit: <a href="${checkRunUrl}"><code>${abbreviateCommitHash(workflowData.sha)

function generateTemplatesStr(templates: Record<string, string>) {
const entries = Object.entries(templates).filter(([k]) => k !== "default");
let str = templates.default
? `[Open in Stackblitz](${templates.default})`
: "";
let str =
entries.length === 0 && templates.default
? `[Open in StackBlitz](${templates.default})`
: "";

if (entries.length > 0 && entries.length <= 2) {
str = [str, ...entries.map(([k, v]) => `[${k}](${v})`)]
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ const main = defineCommand({

const noDefaultTemplate = args.template === false;

if (!noDefaultTemplate) {
if (!noDefaultTemplate && templates.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be an &&? why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be an && because we want the default template to be created only when both conditions are true?
if no templates were found and if the user hasn't explicitly disabled templates.
if you think about using ||, I think it might be incorrect because if noDefaultTemplate is true, we should not create the default template, even if no templates were found. or if the user uses, as an example, --template ./examples/* and templates are found, we should not create the default template. unless I'm missing something here...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes total sense.

const project = createDefaultTemplate(
Object.fromEntries(deps.entries()),
);
Expand Down