fix: create-mcp-server bundle resolution + daily CLI checks#50
Merged
fix: create-mcp-server bundle resolution + daily CLI checks#50
Conversation
The CLI read its own version with createRequire(import.meta.url) +
require("../../package.json"). The path was correct from the source
file (src/init/nuget-versions.ts), but after tsup bundles everything
into dist/index.js, import.meta.url points at dist/, so the same
relative path no longer finds package.json — npx-installed CLIs
crashed with "Cannot find module '../../package.json'" at module load.
Switched to `import pkg from "../package.json" with { type: "json" }`
so the version is inlined by the bundler at build time.
Also adds a --version / -v flag to the CLI so the bundled entry point
can be smoke-tested without going through the interactive scaffold
prompts.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`discover` auto-creates the API user by logging in as admin first. Previously it hardcoded admin@test.com / SecurePass1234 (the PSW unattended-install defaults), so running discover against an existing Umbraco with different admin credentials failed with an error that misleadingly pointed at the Umbraco 17.3 OAuth-client first-boot regression. - UMBRACO_ADMIN_EMAIL / UMBRACO_ADMIN_PASSWORD env vars override the defaults, so users with an existing Umbraco can auto-create the API user without editing source. - Distinguish admin-login failures from bearer-token failures via a discriminated AutoCreateFailure type. Only the bearer-token case surfaces the "restart Umbraco" advice; admin-login failures now say what actually went wrong and point at the env vars. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The existing CLI E2E imports source (src/...) and never executes
the bundled dist/index.js, so bundle-time regressions (like the
recent require("../../package.json") bug) don't surface until
after publish. Two additions close that gap:
- PR suite: a new "CLI bundle smoke test" step after the CLI
build runs `node dist/index.js --version`. Takes seconds and
fails immediately on module-load errors in the bundled output.
- Scheduled daily workflow (scheduled-daily.yml, 06:00 UTC):
- published-cli-smoke: runs `npx @umbraco-cms/create-umbraco-mcp-server@latest`
(and @beta) against a clean runner, scaffolds, installs, and
typechecks. Catches regressions in the currently-published
artifact (bundle bugs, missing files entries, broken deps).
- cli-e2e: the full 19-step deterministic E2E, identical to the
PR job but scheduled so tooling drift surfaces without waiting
for a PR.
- notify-on-failure: opens a GitHub issue @-mentioning the repo
owner on failure, so notifications go out via GitHub's email
system without needing SMTP secrets.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drops the explicit notify-on-failure job. GitHub already emails the user who last modified a scheduled workflow file when a run fails (provided Actions notifications are enabled), so the separate issue job was redundant. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hifi-phil
added a commit
that referenced
this pull request
Apr 21, 2026
Fixes
-----
- `@umbraco-cms/create-umbraco-mcp-server`: resolve bundled package.json
via an inlined JSON import. The CLI read its own version with
`require("../../package.json")`, which resolved correctly from source
but not from the bundled `dist/index.js` — npx-installed CLIs crashed
with "Cannot find module '../../package.json'" at module load. Bug
shipped undetected through beta.9, beta.10, and beta.11 because every
existing E2E imports source (`../../src/...`) and never executes the
bundled output. (#50)
Features
--------
- `UMBRACO_ADMIN_EMAIL` / `UMBRACO_ADMIN_PASSWORD` env var overrides for
`discover`, so the API user can be auto-created against an existing
Umbraco whose admin credentials differ from PSW's unattended-install
defaults. (#50)
- `--version` / `-v` flag on the CLI. (#50)
- `check-api-user.ts` now distinguishes admin-login failures from
bearer-token failures via a discriminated `AutoCreateFailure` type.
Only the bearer-token case surfaces the "restart Umbraco (17.3
regression)" advice; admin-login failures point at the env vars. (#50)
CI hardening
------------
- PR bundle smoke test: `node dist/index.js --version` runs after the CLI
build. Catches module-load regressions in the bundled output in
seconds. Would have failed on the PR that introduced the package.json
bug. (#50)
- Scheduled daily workflow (scheduled-daily.yml, 06:00 UTC): a
`published-cli-smoke` job that scaffolds and compiles against the
currently-published @latest (and @beta) npm artifact, plus a full
`cli-e2e` job so tooling drift (Umbraco updates, PSW updates, .NET SDK
changes) surfaces without waiting for a PR. Failure notifications rely
on GitHub's built-in scheduled-workflow emails. (#50)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
require("../../package.json")resolved correctly from source but not from the bundleddist/index.js, so installs vianpx @umbraco-cms/create-umbraco-mcp-servercrashed on boot in beta.9/10/11. Switched to a JSON import so tsup inlines the version at build time.discoverhardcodedadmin@test.com/SecurePass1234and misattributed login failures to the Umbraco 17.3 OAuth first-boot regression. Now acceptsUMBRACO_ADMIN_EMAIL/UMBRACO_ADMIN_PASSWORD, and a discriminatedAutoCreateFailuretype routes each failure mode to the right guidance.--versionflag plus a PR-time bundle smoke step (node dist/index.js --version) that would have caught the bug immediately, and a daily scheduled workflow that exercises the full E2E + the currently-published npm artifact. On failure it opens a GitHub issue @-mentioning the repo owner for email delivery via GitHub's notification system.Why now
The bundle bug shipped through three releases (beta.9, beta.10, beta.11) because every existing E2E imports
src/...and never runs the bundled output. The smoke step + scheduled run close that gap.Test plan
npm test -w packages/create-mcp-server(121 passed)npm run compile -w packages/create-mcp-servernpm run test:e2e -w packages/create-mcp-serverlocally (19/19 passed after rebuild)node packages/create-mcp-server/dist/index.js --versionprints17.0.0-beta.11scheduled-daily.ymlviaworkflow_dispatchonce merged to verify the scheduled job worksFollow-up
@hifi-philinscheduled-daily.ymlis inferred from commit trailers — correct if wrong.🤖 Generated with Claude Code