Skip to content

fix(create-blocks-app,hosting): print Hosting's own warning about an unsupported next when adding AWS Blocks to a project - #1508

Open
xyos wants to merge 14 commits into
aws:mainfrom
xyos:fix/create-blocks-app-next-range-warning
Open

xyos wants to merge 14 commits into
aws:mainfrom
xyos:fix/create-blocks-app-next-range-warning

Conversation

@xyos

@xyos xyos commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

npx @aws-blocks/create-blocks-app . --template nextjs --yes in an existing app on Next.js 14 adds AWS Blocks and says nothing about the version. The backend it adds defines a Hosting, which builds a server-rendered Next.js app with OpenNext; for a next outside the next peer range of that OpenNext, the Next.js adapter warns during the hosting build of the first deploy and goes on.

The first version of this PR made the scaffolder decide that itself: it copied Hosting's fallback range (>=15.5.28 <16 || >=16.4.1) and reimplemented the adapter's check. Every such copy describes the Hosting next to the CLI, not the Hosting release the project installs (the fallback moved from OpenNext 4.0.3 to 4.1.14 while @aws-blocks/hosting stayed at 0.5.0). The same holds for the other things a scaffolder would have to know: which packages count, whether Hosting builds the app with Next.js at all, and what to tell the user.

So the scaffolder now decides nothing. It asks the project's installed Hosting one question and prints the answer.

While doing this I found that Hosting's package lookup prints an ENOTDIR error with its stack trace whenever a project lacks the package it looks for. A Next.js build of an app without @opennextjs/aws printed it on every run, and the scaffolder would print it too.

Issue #, if available:

Changes

@aws-blocks/hosting

  • New public subpath @aws-blocks/hosting/nextjs-compatibility (minor). The adapter makes this check before its OpenNext build; the subpath returns it as data:

    export interface NextjsCompatibilityOptions {
      /**
       * The `framework` the project's `Hosting` is given. Omit it when `Hosting` is given none:
       * the framework is then detected from the project's `package.json`, as `Hosting` detects it.
       */
      framework?: string;
    }
    
    export interface NextjsCompatibility {
      /** The `next` the project resolves. */
      nextVersion: string;
      /** The `@opennextjs/aws` that would build it: the one the project resolves, else Hosting's fallback. */
      openNextVersion: string;
      /** That OpenNext's `next` peer range. */
      nextRange: string;
      /** Where `openNextVersion` came from. */
      openNextSource: 'installed' | 'fallback';
      /** Whether `nextVersion` is inside `nextRange`. */
      supported: boolean;
      /** The warning the hosting build prints for this project. Set when `supported` is `false`. */
      warning?: string;
    }
    
    export function checkNextjsCompatibility(
      projectDir: string,
      options?: NextjsCompatibilityOptions,
    ): NextjsCompatibility | undefined;

    It returns undefined when Hosting would not build the project with its Next.js adapter (options.framework ?? detectFramework(projectDir) is not 'nextjs', the choice Hosting itself makes), when the project resolves no valid next, or when there is no valid range to check it against. It resolves packages the way the adapter does (the app's own copy first, then hoisted copies), uses includePrerelease: true, and reads installed versions only. It loads no aws-cdk-lib, no adapter and no build tooling (a test records every module the import resolves). Added to exports as types + default, like the other subpaths. It is not re-exported from @aws-blocks/blocks: the umbrella re-exports no Hosting subpath, and no export-parity rule covers Hosting.

  • One implementation, one wording. The adapter calls checkNextjsCompatibility(projectDir, { framework: 'nextjs' }) and prints warning after its ⚠️ prefix. The printed line is byte-for-byte the one on main (compared against main's source for a fixture project), the warning conditions and build arguments are unchanged, and the adapter's existing tests pass untouched. It looks up OpenNext itself only when there is no verdict, so it makes the same lookups as before.

  • Moved, not copied. OPENNEXT_FALLBACK_VERSION, OPENNEXT_FALLBACK_NEXT_PEER_RANGE, detectNextVersion and the installed-OpenNext lookup move to adapters/shared/opennext_version.ts; detectFramework and readProjectDeps move to adapters/shared/detect_framework.ts. adapters/nextjs.ts and adapters/index.ts re-export the names they exported before, so existing imports and tests are unchanged. None of them is exported from the new subpath.

  • Package lookup without a stack trace (patch). adapters/shared/package_info.ts resolved from <projectDir>/package.json. For a package that isn't installed, the resolver also tries <base>/_index.js, here package.json/_index.js, which fails with ENOTDIR instead of not-found, and local-pkg prints it with its stack. It now resolves from <projectDir>/: the app's own copy still wins over a hoisted one, and a missing package is a plain not-found.

  • README: a paragraph in "Next.js: the OpenNext version", with an example.

@aws-blocks/create-blocks-app

  • HOSTING_NEXT_RANGE, the semver and @types/semver dependencies (and their package-lock.json lines) and the test that compared the copy with the adapter's constant are gone.
  • After the install step, when the backend it copied defines a Hosting, the existing-project path resolves @aws-blocks/hosting/nextjs-compatibility the way that backend resolves Hosting: from aws-blocks/ to @aws-blocks/blocks, then the @aws-blocks/core that it imports Hosting from, then that core's @aws-blocks/hosting. That is never the CLI's own copy. It calls checkNextjsCompatibility(targetDir, { framework }), where framework is whatever the copied backend gives its Hosting (only the nextjs template gives one), and prints the warning it returns, followed by one line of its own: the warning is from the @aws-blocks/hosting the project installs, and your next was not changed.
  • The CLI holds no version range, no framework detection and no wording about OpenNext or the hosting build. It never names nextjs.
  • It loads that module with import() and stays silent, with no error or stack trace, when the module can't be resolved (--skip-install without Blocks, or a Hosting that predates the export), when loading or calling it throws, or when there is no warning. console.error and console.warn are muted while the check runs, because Hosting's package lookup logs an error and its stack for a broken installed package before it answers that it has no verdict. It never fails the command and never edits next.
  • packages/create-blocks-app/README.md is unchanged against main. The check is documented in the Hosting README.

The review comments on the first version

  • JSON.parse of a malformed node_modules/next/package.json rejected and exited 1: that lookup is gone. With such a file, Hosting's own lookup logs the parse error and gives no verdict; the CLI mutes console.error during the check, so its stderr stays empty and it exits 0 (checked by hand with this repository's Hosting, and covered by a fixture that logs an error and returns nothing).
  • No case for next only in devDependencies, or for a prerelease: both rules are Hosting's now. A prerelease case is in Hosting's tests (16.4.2-canary.1 against >=16.4.1; it fails without includePrerelease). Hosting's existing detectFramework tests cover next in dependencies and in devDependencies, and a compatibility test covers a peer-only next.
  • An installed but undeclared next, and an OpenNext hoisted to a parent node_modules: resolution is Hosting's (the app's own copy first, then hoisted). For the nextjs template the CLI passes framework: 'nextjs', so an undeclared next is checked, as the build checks it. For the other templates Hosting detects the framework from package.json, so a Vite app with some other app's next installed gets no warning; its hosting build doesn't use OpenNext.
  • The copied range goes stale when Hosting releases a new one: the CLI has no range.
  • amplify and observability add no Hosting either: the README paragraph is removed and the changeset no longer lists templates. The CLI reads the backend it copied.
  • "nothing was changed" reads as a claim about the whole run: the CLI's line now says "Your next was not changed."

For a maintainer to decide

  • The new public export and its shape (above): a new entry point of @aws-blocks/hosting. On naming: docs/design/API-DESIGN.md G14 says check* returns a boolean, and G3 prefers null for absence. Both are written for Building Block methods, and Hosting's own helpers return undefined, so I kept the name. warning puts a sentence in a data result; it is there so the adapter and a caller print the same words.
  • The scaffolder runs code from the project's node_modules, in its own process: the @aws-blocks/hosting the project installed, which the project already runs on every hosting build. It imports only that one subpath and calls only that one function. A throw is caught and logged errors are muted; a module that exited the process or hung would take the command with it. An earlier revision on this branch ran the check in a child process to contain that; it was dropped as more machinery than the case needs.
  • Silence when the project's Hosting has no export. With an installed Hosting from before this release, or none installed, the scaffolder says nothing, and the hosting build stays the first place the project hears about the version.
  • What the scaffolder still knows. The subpath, the function name and the warning field; the path @aws-blocks/blocks → @aws-blocks/core → @aws-blocks/hosting (a test with this repository's real packages fails if that path changes); and how its own templates spell new Hosting( and framework: '…' (the tests run the real templates).
  • Gone from the first version: the warning from a range declared in package.json when next isn't installed, and the note that a static export has no minimum version (a Hosting fact that its build warning does not carry).
  • The package-lookup fix changes Hosting's stderr for every adapter: the ENOTDIR traces for missing packages are gone. Resolution results are the same. Windows paths are not exercised by these tests.

Validation

  • New tests in packages/hosting/src/nextjs_compatibility.test.ts. checkNextjsCompatibility cases: an installed OpenNext's next peer range wins over the fallback (16.3.0 supported against 4.0.3's range, and no warning); without OpenNext it uses the fallback version and range with openNextSource: 'fallback', and the warning names the version, the OpenNext and the range; a project that declares no next has no verdict, and has one when given framework: 'nextjs'; a project that depends on next has no verdict when given framework: 'static'; a next and an OpenNext hoisted to a workspace root are found; the app's own next wins over a hoisted one; an installed next declared only as a peer dependency is checked; a prerelease inside the range is supported; no installed next gives undefined; an installed OpenNext without a next peer range, or with an invalid one, gives undefined. A child process records every module the subpath's import resolves: no aws-cdk-lib, constructs, adapters/index.js, adapters/nextjs.js, fast-glob or cross-spawn.
  • packages/hosting/src/adapters/shared/package_info.test.ts: for a missing package, getProjectPackageInfo returns undefined, projectHasPackage returns false, and nothing is written to stderr. sub_path_exports.test.ts resolves the new subpath.
  • The adapter's existing tests in nextjs.test.ts, adapters.test.ts and version_pins.test.ts pass without changes. I also compared the adapter's warning line with main's: main's two source lines, evaluated with the values of a fixture project, equal ⚠️ ${warning}\n from this branch (a one-off script, not kept).
  • New tests in packages/create-blocks-app/src/cli.test.ts run the built CLI (--skip-install) on an existing project in a temporary directory outside the repository, with a fixture @aws-blocks/blocks → @aws-blocks/core → @aws-blocks/hosting chain whose answer is its own. The fixture warning names the next in the directory it was given and the framework it was passed.
    • Prints the fixture's warning and the CLI's line: for the nextjs template (framework nextjs); when only the Hosting nested under Core has a warning; for the default template (framework undefined). That fixture also logs an error and a warning, which do not reach the output.
    • Prints nothing: when Hosting has no warning, predates the export or is not installed; when the module throws on load; when the check throws, or logs an error and returns nothing; for the backend template.
    • Every case asserts exit code 0, that the backend was added, an empty stderr, and that next in package.json and node_modules is unchanged.
    • One more test installs this repository's Blocks (symlinked) in three projects and requires the CLI to print exactly what this repository's Hosting answers for each, with at least one warning among them.
  • Each new test fails without the change it covers. I checked by editing the source temporarily, rebuilding, running the test and restoring:
    • Hosting: dropping includePrerelease; always using the fallback range; dropping the framework choice; ignoring options.framework (the adapter's own tests fail too); dropping the warning text (the adapter's own tests fail too); importing adapters/index.js or the adapter from the subpath; resolving from <projectDir>/package.json again; resolving from projectDir without the separator.
    • CLI: resolving Hosting from the CLI's own location; skipping the Blocks → Core chain; passing no framework; always passing nextjs; not checking for a Hosting in the backend; removing the catch; not muting console.error, or muting it without console.warn.
  • The contributor checklist on c380e4b18, run locally on Node.js 22.23.1 after npm ci, all exit 0:
    • npm run build, npm run lint, npm run lint:deps (655 files). The build failed twice before it passed, for a reason in my shell and not in the repository: with some environment variables of my local setup present, next build in packages/admin-ui stops with SecurityFatalError about an advisory for next@16.4.2. With those variables unset the same command exits 0 on the same commit, as it does in CI.
    • npm run check:api: the API reports are unchanged. Hosting has no API report.
    • npm run check:exports-consistency, npm run check:runtime-guard, npm run check:client-user-agent
    • node --test scripts/sink-guards/{regex,shell,workflows,codegen,html}.test.mjs: 35 tests. The import lines added to adapters/nextjs.ts move its allowlisted regex sink from line 1042 to 1048; the allowlist entry is updated in the commit that moves it.
    • npm test (every workspace): 13,278 tests, 0 failures, 10 skipped. @aws-blocks/hosting: 1,840 tests, 0 failures. @aws-blocks/create-blocks-app: 365 tests, 0 failures. The intermittent dist/secret-cli.test.js failure described in test(hosting,blocks): keep CLI and adapter output off the test runner's stdout #1330 did not occur in this run. One earlier full Hosting run, on work not yet committed, failed that file as a whole (1 of 1,833 tests); I did not capture the message, and the file alone then passed (32 tests).
    • npm run test:e2e:local: 557 tests, 0 failures, 6 skipped
  • By hand, with the built CLI and this repository's Hosting: a project on next@14.2.35 gets Hosting's warning and the CLI's line with an empty stderr; a project whose node_modules/next/package.json is not valid JSON gets no warning, exit code 0 and an empty stderr.
  • Not verified: a deployed app, or a hosting build against a real OpenNext; nothing was deployed. Nothing here ran on Windows, so the changed package lookup is untested there. No scaffold was run against a published Hosting release (none has the export yet).

Checklist

  • PR description included
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…de the range Hosting builds server-rendered

Adding AWS Blocks to an existing app on Next.js 14 said nothing about the
version. Hosting builds a server-rendered Next.js app with OpenNext, whose
`next` peer range is `>=15.5.28 <16 || >=16.4.1` for the version Hosting
falls back to, and its adapter warns about a version outside that range only
during the hosting build of the first deploy.

The existing-project path now prints a warning that names the version found
(the installed one from node_modules/next, else the range in package.json),
the supported range, and that upgrading is the user's step. It checks against
the same range as the adapter: the `next` peer range of an installed
@opennextjs/aws, else a copy of the fallback range, which a test compares with
the adapter's constant. It is printed only when the added backend defines a
Hosting, never fails the command and edits nothing. A static export served
with `framework: 'static'` has no minimum version, and the warning says so.

create-blocks-app gains `semver` as a dependency to evaluate the ranges.

Validation: npm run build; npm run lint; npm run lint:deps;
npm test -w @aws-blocks/create-blocks-app (354 pass). Full unit suite and
local e2e suite not run locally.
@changeset-bot

changeset-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c380e4b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@aws-blocks/create-blocks-app Patch
@aws-blocks/hosting Minor
@aws-blocks/blocks Patch
@aws-blocks/pipeline Patch
@aws-blocks/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@xyos
xyos marked this pull request as ready for review November 16, 2026 11:37
@xyos
xyos requested a review from a team as a code owner November 16, 2026 11:37
xyos added 5 commits November 16, 2026 12:12
The adapters resolve a project's packages from `<projectDir>/package.json`
so the app's own copy wins over one hoisted to a workspace root. For a
package that isn't installed, the resolver also tries `<base>/_index.js`,
which under that base is `package.json/_index.js`; that fails with ENOTDIR
instead of not-found, and local-pkg prints the error and its stack trace.
A Next.js build of an app without @opennextjs/aws printed it on every run.

Resolve from `<projectDir>/` instead: the lookup still starts in the app's
directory, and a missing package is a plain not-found.
…g/nextjs-compatibility

A tool that adds AWS Blocks to a project (create-blocks-app) wants to tell
the project, before its first deploy, that its `next` is outside the range
the OpenNext Hosting builds with supports. Copying Hosting's fallback range
into such a tool goes stale against the Hosting release the project
installs, and a second lookup misses hoisted installs.

`checkNextjsCompatibility(projectDir)` returns the check the Next.js adapter
makes before its OpenNext build as data: the installed `next`, the OpenNext
that would build it (installed, else the fallback) with its `next` peer
range, where it came from, and whether the version is inside it. The
adapter now takes its warning from it, and looks OpenNext up itself only
when there is no verdict, so it prints the same warnings as before.

The fallback constants and the installed-version lookups move to
`adapters/shared/opennext_version.ts` so the subpath loads none of the
adapter's build tooling; `adapters/nextjs.ts` re-exports them. The import
lines this adds move an allowlisted regex sink in `nextjs.ts` from line
1042 to 1048, updated in the sink-guard allowlist.
…ject's Hosting

The warning for an existing project's `next` checked a copy of Hosting's
fallback range, which describes the sibling Hosting build, not the Hosting
release the project installs, and its own lookup missed hoisted installs
and a `next` declared only as a peer dependency.

After the install, the CLI now resolves `@aws-blocks/hosting/nextjs-compatibility`
the way the backend resolves `Hosting` (from `aws-blocks/` through
@aws-blocks/blocks and @aws-blocks/core), calls `checkNextjsCompatibility`
and warns when it says the version is unsupported, naming the OpenNext the
range is from. It stays silent when that Hosting is missing, predates the
export, throws or gives no verdict. Without an installed `next` there is no
verdict, so the warning from the range package.json declares is gone.

The copied range, the test pinning it, and the `semver` and `@types/semver`
dependencies are removed.
…ith Next.js

The check ran for every backend that defines a Hosting, and the Hosting
verdict reads any `next` the project resolves, including one hoisted from
another app of a monorepo. Only the `nextjs` template sets
`framework: 'nextjs'`; the other templates let Hosting detect the
framework from package.json, so a Vite app that declares no `next` is
built with another adapter, yet got an upgrade warning that said its
hosting build would use OpenNext.

Check only when the backend sets `framework: 'nextjs'` or package.json
declares `next` in `dependencies`, `devDependencies` or
`peerDependencies`, the maps Hosting's detection reads.
Comment thread packages/create-blocks-app/src/index.ts Outdated
// What the project's own node_modules holds of each package: its package.json, or `undefined`.
const [openNext, next] = await Promise.all(
['@opennextjs/aws', 'next'].map((name) =>
readFile(join(targetDir, 'node_modules', name, 'package.json'), 'utf-8').then((text) => JSON.parse(text), () => undefined),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

() => undefined handles only a failed readFile. When node_modules/next/package.json exists but is not valid JSON, JSON.parse throws, the promise rejects, and the command exits 1 after aws-blocks/ and package.json have been written.

Suggestion: .then(JSON.parse).catch(() => undefined)

// `installed` is the version in node_modules/next, read before the range package.json declares.
// `openNextPeer` is the `next` peer range of an @opennextjs/aws the project installs, which Hosting
// then builds with and checks against, instead of the OpenNext it falls back to (HOSTING_NEXT_RANGE).
type Project = { declared?: string; installed?: string; openNextPeer?: string; template?: string; warns?: string };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Every case puts next in dependencies, and none installs a prerelease. Removing ?? pkg.devDependencies?.next from warnIfNextOutsideHostingRange, or removing { includePrerelease: true } from the semver.satisfies call, leaves all 13 cases green.

Suggestion: add a case with next only in devDependencies that warns, and a case with an installed 16.5.0-canary.1 that does not.

Comment thread packages/create-blocks-app/src/index.ts Outdated
async function warnIfNextOutsideHostingRange(targetDir: string, pkg: PackageDeps): Promise<void> {
const declared = pkg.dependencies?.next ?? pkg.devDependencies?.next;
if (typeof declared !== 'string') return;
// What the project's own node_modules holds of each package: its package.json, or `undefined`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This returns when next is not in dependencies or devDependencies. A project with node_modules/next@14.2.35 and no next entry in package.json gets no warning. The adapter's detectNextVersion (packages/hosting/src/adapters/nextjs.ts:1771) reads the installed next through getProjectPackageInfo and does not read package.json, so the deploy warns.

The lookup at :1136 reads only <targetDir>/node_modules. With next@16.2.0 in the project's node_modules and @opennextjs/aws (peer >=16.0.0) in the parent directory's node_modules, this prints a warning against >=15.5.28 <16 || >=16.4.1. The adapter resolves @opennextjs/aws from <projectDir>/package.json with local-pkg (shared/package_info.ts:16-25) and uses that peer range.

Comment thread packages/create-blocks-app/src/index.ts Outdated
* in `@aws-blocks/hosting` (`src/adapters/nextjs.ts`), which create-blocks-app does
* not depend on at runtime; `cli.test.ts` checks that the two are equal.
*/
export const HOSTING_NEXT_RANGE = '>=15.5.28 <16 || >=16.4.1';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cli.test.ts:962 compares this string to OPENNEXT_FALLBACK_NEXT_PEER_RANGE from the packages/hosting build in the same checkout. @aws-blocks/hosting is a devDependency here (package.json:38, ^0.5.0) and the changeset bumps only @aws-blocks/create-blocks-app, so a hosting release that changes OPENNEXT_FALLBACK_NEXT_PEER_RANGE leaves the published CLI printing the previous range until the CLI is republished.

Comment thread packages/create-blocks-app/README.md Outdated

This writes `aws-blocks/tsconfig.json`, a TypeScript project that checks the backend with Node types, and never edits your own `tsconfig`. To keep Node types out of your frontend, reference that project from the `tsconfig` that compiles the code importing `aws-blocks`, and typecheck with `tsc -b --force`: the CLI prints the steps, and [Keep Node types out of the frontend](https://github.com/aws-devtools-labs/aws-blocks/blob/main/docs/guides/upgrading-older-apps.md#keep-node-types-out-of-the-frontend) has them in full. In a Next.js project, it writes no `aws-blocks/tsconfig.json`: `next build` ignores project references, so the app's `tsconfig.json` keeps checking `aws-blocks/`.

In a Next.js project whose backend gets a `Hosting` (every template except the backend-only ones), the CLI also checks the project's `next` against the versions `Hosting` builds as a server-rendered app: `>=15.5.28 <16 || >=16.4.1`, the `next` peer range of the OpenNext version `Hosting` builds with (or the `next` peer range of the `@opennextjs/aws` the project has installed). It reads the installed version from `node_modules/next`, or else the range in `package.json`. Outside that range it prints a warning that names the version it found, and changes nothing. The hosting build prints a warning for that version too and goes on with a combination OpenNext was not released for, so upgrading `next` is up to you. The check does not apply to a static export (`output: 'export'`) that `Hosting` serves as a static site (`framework: 'static'`): it is not built with OpenNext and has no minimum version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

amplify and observability have no new Hosting( in their index.cdk.ts either, and line 162 defines the backend-only templates as api-only, backend, cron, sql. Six of the thirteen templates print no warning.

Suggestion: name the templates that add a Hosting: agent, auth, bare, default, demo, nextjs, react.

Comment thread packages/create-blocks-app/src/index.ts Outdated
if (inside) return;
console.log(`⚠️ Next.js: this project has next@${version ?? declared}. \`Hosting\` builds a server-rendered Next.js app with OpenNext,`);
console.log(` which supports next ${range}. Outside that range the hosting build warns and goes on`);
console.log(' with a combination OpenNext was not released for. Upgrading `next` is up to you: nothing was changed.');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The command has just written aws-blocks/ and edited package.json, so "nothing was changed" reads as a statement about the whole run.

Suggestion: "your next was not changed".

@xyos xyos changed the title fix(create-blocks-app): warn when an existing project's next is outside the range Hosting builds server-rendered fix(create-blocks-app,hosting): warn about an unsupported next from the project's own Hosting, and export that check Nov 16, 2026
xyos added 7 commits November 16, 2026 14:15
…he templates it covers

The warning ended with "nothing was changed" right after the command wrote
aws-blocks/ and edited package.json, which reads as a claim about the
whole run; it now says the project's `next` was not changed. The README
and changeset said every template except the backend-only ones adds a
Hosting, but observability and amplify add none either; they now name the
templates. A case with `next` only in devDependencies covers the third
dependency map Hosting's detection reads.
…check

The paragraph restated, in a second place, how Hosting checks `next`, how
it detects the framework and which templates add a Hosting. The check is
documented where it lives, in the Hosting README, and the CLI's own
warning says what it found.
…rd the warning

A caller of the check had to decide for itself whether Hosting builds the
project with Next.js, and to phrase the mismatch itself. Both are Hosting
facts: the framework is `props.framework ?? detectFramework(root)`, and
the adapter already has a warning for the mismatch. A tool that copies
either goes stale against the Hosting release a project installs, the
same way a copied version range does.

`checkNextjsCompatibility(projectDir, { framework })` now makes that
choice itself (`framework`, else detection from package.json) and returns
`undefined` for a project Hosting would not build with its Next.js
adapter. An unsupported verdict carries `warning`, the text the adapter
prints; the adapter prints that field, so the words exist once. The
adapter passes `framework: 'nextjs'`, so its behavior is unchanged.

`detectFramework` and `readProjectDeps` move to
`adapters/shared/detect_framework.ts`, re-exported from
`adapters/index.ts`, so the subpath still loads no adapter.
…f deciding and wording it

Without a version range, the CLI still held two copies of Hosting's rules:
when Hosting builds an app with Next.js (`next` in the dependency maps, or
`framework: 'nextjs'`), and what a mismatch means (OpenNext, the fallback,
what the hosting build does, static exports). Its changeset also listed
which templates add a Hosting.

The CLI now passes the `framework` its copied backend gives `Hosting`, if
any, to the project's `checkNextjsCompatibility` and prints the `warning`
it returns, adding only that `next` was not changed. It has no framework
detection and no wording about Hosting left, and the changeset no longer
restates Hosting's rules or the template list.
The import is used only as a type. The lint check runs on changed files,
and moving the framework detection out of this file put it in that set.
… own

The CLI loaded the project's Hosting module into its own process and
guarded the call with try/catch. That stops a throw, but not what the
module prints: with a malformed node_modules/next/package.json, Hosting's
package lookup logs the error and its stack and returns no verdict, and
the trace appeared in the CLI's output. A module that exits or hangs
would end or stall the command.

The CLI now runs the question in a child process with the error output
dropped and a timeout, and reads the warning from the last line of its
output. Whatever that module does, the command prints either its warning
or nothing, and still exits 0.

The CLI's own line no longer says what the hosting build does; it says
where the warning is from and that `next` was not changed. The changeset
describes only what the CLI does. The tests take their expectations for
the repository's Hosting from that Hosting's own answer instead of
stating which versions it accepts.
…meout that cannot be ignored

The child process that asks the project's Hosting wrote its answer as the
last line of stdout, where the module prints too: a module that printed
JSON and exited was read as the answer, and one that printed after
answering hid it. The answer now goes to a pipe of its own (file
descriptor 3), and stdout is dropped with stderr.

The timeout sent the default SIGTERM, which a process can handle without
exiting; the synchronous call then waits for it forever. It now sends
SIGKILL, after ten seconds. The script exits once it has answered, so a
timer or socket the module leaves open does not hold it until the timeout.
@xyos xyos changed the title fix(create-blocks-app,hosting): warn about an unsupported next from the project's own Hosting, and export that check fix(create-blocks-app,hosting): print Hosting's own warning about an unsupported next when adding AWS Blocks to a project Nov 16, 2026
…running it in a child process

The child process kept everything a project's Hosting module could do
(print, exit, hang) away from the command, at the cost of a script kept
in a string, a process per scaffold and an extra pipe. The one case seen
in practice is narrower: for a broken installed package, Hosting's
package lookup logs the error and its stack trace and then answers that
it has no verdict.

Import the module again and mute console.error and console.warn while
the check runs. A throw is still caught. A module that exits or hangs is
no longer contained; it is the project's own @aws-blocks/hosting, which
the project runs on every hosting build.

This branch has not been deployed

No deployments
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.

2 participants