Skip to content

Examples revamp#14266

Draft
nachocodoner wants to merge 24 commits intorelease-3.4.1from
examples-revamp
Draft

Examples revamp#14266
nachocodoner wants to merge 24 commits intorelease-3.4.1from
examples-revamp

Conversation

@nachocodoner
Copy link
Copy Markdown
Member

@nachocodoner nachocodoner commented Mar 25, 2026

Context: meteor/examples#42

This PR replaces the hardcoded EXAMPLE_REPOSITORIES with a dynamic system that fetches https://github.com/meteor/examples/blob/migrate-examples/examples.json from the https://github.com/meteor/examples repo. Contributors can now add examples there without PRs to the main Meteor repo.

  • meteor create --list shows rich example info (description, tech stack, demo URL, repo link, Meteor version)
  • meteor create --example <slug> supports both internal (monorepo subfolder) and external examples
  • New --from-dir and --from-branch options to extract a subdirectory from a specific branch of a repo
  • Always fetches fresh data from GitHub, with local cache (~/.meteor/examples-cache.json) as offline fallback
  • Removed EXAMPLE_REPOSITORIES, getExamplesJSON(), and setupExampleByURL()
  • E2E tests covering --list, --example, --from and --from --from-branch --from-dir
image

Summary by CodeRabbit

  • New Features

    • Enhanced meteor create --example with improved catalog display showing meteorVersion, stack, demo, and tutorial info
    • Added --from-branch and --from-dir options for cloning specific branches and subdirectories from Git repositories
    • Improved meteor create --list output with richer formatting and additional project details
  • Documentation

    • Updated CLI help text and user documentation with new examples and cloning options
  • Tests

    • Added comprehensive end-to-end tests for example and repository cloning workflows

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 25, 2026

Deploy Preview for v3-meteor-api-docs canceled.

Name Link
🔨 Latest commit 9f61ccb
🔍 Latest deploy log https://app.netlify.com/projects/v3-meteor-api-docs/deploys/69c55e002ba9a50008e303a8

@harryadel
Copy link
Copy Markdown
Contributor

Noooooooooooooo, we need your brain intact pls no use Claude, you'll be unable to do basic arithmetic in two week max!

@nachocodoner
Copy link
Copy Markdown
Member Author

We can't avoid it already! I will work with AI, but I won't accept anything blindly. That is why I keep making follow-up commits on his initial approaches. 🤣

@harryadel
Copy link
Copy Markdown
Contributor

@fredmaiaarantes Protect their brains please 😭 It's enough that contributors use LLMs. Core committers need to be 100% human 😢

@nachocodoner
Copy link
Copy Markdown
Member Author

image

@harryadel
Copy link
Copy Markdown
Contributor

@nachocodoner "Transcended his fragile biological form" Are you a fragile biological form currently Nacho?

@nachocodoner
Copy link
Copy Markdown
Member Author

image

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fb1e0056-c092-4e80-906e-ef92582855cc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch examples-revamp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tools/cli/commands.js (1)

935-980: ⚠️ Potential issue | 🟡 Minor

Skip skeleton selection for clone/example flows.

setup() runs before the options.example / options.from branches, so meteor create --example <slug> and meteor create --from <url> still prompt for a skeleton when no path is supplied, and any explicit skeleton flag is silently discarded afterward.

Also applies to: 983-986

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/cli/commands.js` around lines 935 - 980, setup() is prompting for a
skeleton even for clone/example flows; update setup() to detect options.example
|| options.from before showing interactive prompts and immediately return {
appPathAsEntered, skeleton } so clone/from flows don't get the skeleton
prompt—use the already-computed skeletonExplicitOption or DEFAULT_SKELETON as
the returned skeleton (and preserve any explicit skeleton flag), and only run
the inquirer flow when neither options.example nor options.from apply (this
change also covers the related prompt logic referenced around the subsequent
skeleton handling).
🧹 Nitpick comments (1)
tools/e2e-tests/example.test.js (1)

66-92: Make the negative assertions specific.

rejects.toThrow() also passes on unrelated failures like GitHub outages or a missing git binary, so these tests can stay green while the intended validation regresses. Match the expected message/pattern for “directory not found” and “not a Meteor app”.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/e2e-tests/example.test.js` around lines 66 - 92, Update the two
negative assertions to verify specific error messages instead of a generic
rejects.toThrow(); for the first test (the one using tempApp('baddir')), change
the expectation on runMeteorCommand(...) to assert the rejection message/pattern
contains the “directory not found” text (or the exact error text your CLI/git
layer emits when --from-dir is missing) and for the second test
(tempApp('nonmeteor')) assert the rejection message/pattern contains the “not a
Meteor app” (or repo validation) text; locate the calls to runMeteorCommand in
these two it blocks and replace rejects.toThrow() with
rejects.toThrow(/expected-regex-or-string/) (or the test framework equivalent)
so failures like network/git outages won’t falsely satisfy the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tools/cli/examples.js`:
- Around line 7-9: EXAMPLES_BRANCH is pinned to a mutable feature branch causing
runtime breakage; change the reference so EXAMPLES_JSON_URL points to an
immutable ref (canonical branch like "main" or, better, a specific tag or commit
SHA). Replace the EXAMPLES_BRANCH value (and any usage in EXAMPLES_JSON_URL)
with the chosen stable identifier (e.g. a tag name or commit hash) so the CLI
fetches a permanent URL instead of the mutable "migrate-examples" branch.
- Around line 72-97: getExamples currently ignores the refresh flag and always
falls back to cache on network failure; update getExamples({ refresh = false })
so that when refresh is true it does not return cached.examples on fetch failure
but instead re-throws the fetch error (i.e., bypass the cached return path), and
ensure any consumer recovery hints (e.g., in tools/cli/commands.js) do not
reference a non-existent --refresh flag — either remove that hint or update it
to the correct command/flag. Locate symbols getExamples, fetchExamplesJson,
writeCache, readCache and EXAMPLES_BRANCH to make the change and adjust the
user-facing recovery hint accordingly.
- Around line 165-172: The code builds subdirPath with files.pathJoin(tempDir,
subdir) then blindly copies with files.cp_r, allowing `..` to escape the temp
clone; resolve the candidate path (e.g., use files.realpath or path.resolve on
the joined path and on tempDir) and verify the resolved subdirPath is contained
inside the resolved tempDir (use path.relative or string-prefix check with a
trailing separator) before proceeding; if the resolved path is outside tempDir
throw an error (replace or precede the existing files.exists check), and only
then call files.cp_r.
- Around line 104-121: The cloneRepo and cloneSubdirectory functions use exec()
with interpolated strings (url, branch, repoUrl, destPath) creating
command-injection risks and breaking paths with spaces; replace exec() calls
with child_process.spawn() or execFile() using argv arrays and shell: false,
pass the git command and its arguments as separate array elements (e.g.,
['clone','--progress', '--branch', branch, url, dest]) and supply { env:
process.env }/stdio handling and proper error/exit handling; ensure
process.env.GIT_TERMINAL_PROMPT is set the same and that you handle Windows
quoting by passing raw paths (converted with files.convertToOSPath) as separate
argv entries instead of embedding them in a shell string.

In `@tools/e2e-tests/example.test.js`:
- Around line 14-60: The tests in example.test.js (the "meteor create
--example", "--from", and "--from with --from-branch and --from-dir" cases)
depend on live GitHub repos and should be made deterministic: replace external
network calls by creating local fixture git repositories (using tempApp /
tempDir) or by mocking the code path that fetches remote examples used by
runMeteorCommand, then point the tests to those local repo URLs (or stubbed
responses) and remove reliance on real branches/repos; ensure cleanupTempDir is
still used to remove fixtures and keep the existing assertions
(fs.existsSync(path.join(tempDir, '.meteor'))) unchanged.

---

Outside diff comments:
In `@tools/cli/commands.js`:
- Around line 935-980: setup() is prompting for a skeleton even for
clone/example flows; update setup() to detect options.example || options.from
before showing interactive prompts and immediately return { appPathAsEntered,
skeleton } so clone/from flows don't get the skeleton prompt—use the
already-computed skeletonExplicitOption or DEFAULT_SKELETON as the returned
skeleton (and preserve any explicit skeleton flag), and only run the inquirer
flow when neither options.example nor options.from apply (this change also
covers the related prompt logic referenced around the subsequent skeleton
handling).

---

Nitpick comments:
In `@tools/e2e-tests/example.test.js`:
- Around line 66-92: Update the two negative assertions to verify specific error
messages instead of a generic rejects.toThrow(); for the first test (the one
using tempApp('baddir')), change the expectation on runMeteorCommand(...) to
assert the rejection message/pattern contains the “directory not found” text (or
the exact error text your CLI/git layer emits when --from-dir is missing) and
for the second test (tempApp('nonmeteor')) assert the rejection message/pattern
contains the “not a Meteor app” (or repo validation) text; locate the calls to
runMeteorCommand in these two it blocks and replace rejects.toThrow() with
rejects.toThrow(/expected-regex-or-string/) (or the test framework equivalent)
so failures like network/git outages won’t falsely satisfy the test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5f7f404c-f638-4621-b7f4-a889f55f2cd3

📥 Commits

Reviewing files that changed from the base of the PR and between db3a703 and 806e2b2.

📒 Files selected for processing (9)
  • tools/cli/commands.js
  • tools/cli/example-repositories.js
  • tools/cli/examples.js
  • tools/cli/help.txt
  • tools/console/console.js
  • tools/e2e-tests/example.test.js
  • tools/tests/create.js
  • tools/tests/help.js
  • v3-docs/docs/cli/index.md
💤 Files with no reviewable changes (1)
  • tools/cli/example-repositories.js

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants