fix: lazy-load scheduler AWS SDK in core and repair frigg init scaffolding - #639
Open
seanspeaks wants to merge 2 commits into
Open
fix: lazy-load scheduler AWS SDK in core and repair frigg init scaffolding#639seanspeaks wants to merge 2 commits into
frigg init scaffolding#639seanspeaks wants to merge 2 commits into
Conversation
Loading @friggframework/core pulled in @aws-sdk/client-scheduler because
eventbridge-scheduler-adapter.js required it at module top level and
scheduler/index.js eagerly requires that adapter. Core never declared the
package, so a clean install (or any consumer on the mock provider / no AWS)
threw MODULE_NOT_FOUND merely on `require('@friggframework/core')`.
- Require @aws-sdk/client-scheduler lazily via a cached loadSchedulerSdk()
helper, invoked from the EventBridge adapter's constructor and methods
rather than at module load. Requiring the scheduler module (and thus core)
no longer touches aws-sdk; only instantiating the EventBridge adapter does.
A missing package now yields a clear, actionable error instead of a raw
MODULE_NOT_FOUND.
- Declare @aws-sdk/client-scheduler in optionalDependencies so AWS
deployments still install it by default while non-AWS/local consumers are
not forced to. The factory already only instantiates the EventBridge
adapter for the eventbridge provider; the mock path never touches aws-sdk.
- Add a regression test asserting the module loads without the SDK, the mock
provider works, the dev/test/local default is mock, and instantiating the
EventBridge adapter reaches for the SDK.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JDh45c1vm91ySYtvVv9Z65
…oute)
`frigg init <name>` failed two ways in 2.0-next:
(a) Backend template not shipped. The init handler copies from
frigg-cli/templates/backend, but that directory did not exist in the
source tree (and so was absent from the published tarball), producing
"Backend template not found." Add a working backend template
(index.js exporting `Definition`, infrastructure.js, README.md) and
list frigg-cli/templates/ explicitly in package `files`. The template's
app definition validates against the current app-definition schema and
carries the exact markers the handler's updateAppDefinition() rewrites
when integrations are selected.
(b) The default routed every init into the dead legacy branch. The CLI
registered `--template` with a default of 'backend-only', but the
handler only runs the backend-first path when `!options.template`, so
the truthy default always fell through to "Legacy template system is no
longer supported" and exit 1. Remove the default; `--template` is now an
explicit (unsupported) legacy opt-in. Make the positional the project
name (`init [projectName]`), register the flags the handler actually
reads (`--mode`, `--no-frontend`, `--force`, `--verbose`), drop the
unused `--directory`, and remove the dangling `options.legacyFrontend`
reference so the handler and commander definitions are consistent.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JDh45c1vm91ySYtvVv9Z65
There was a problem hiding this comment.
Claude Code Review
Claude Code Review is paused for this repository. To reconnect it, an admin of this repository's GitHub organization (or the account owner, for personal repositories) who can also manage your Claude organization's Code Review settings needs to re-link GitHub in Code Review settings. This is a one-time step.
Tip: disable this comment in your organization's Code Review settings.
✅ Deploy Preview for friggframework-org canceled.
|
|
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
Two independent packaging bugs on
next, both of which make a clean install unusable before any real work starts.Fix 1 —
@friggframework/coreshould not require@aws-sdk/client-schedulerunless EventBridge is actually usedinfrastructure/scheduler/eventbridge-scheduler-adapter.jsdid a top-levelrequire('@aws-sdk/client-scheduler'), andscheduler/index.jseagerly requires that adapter (which core loads viaapplication → scheduler-commands). Core never declared the package, so on a clean install merely runningrequire('@friggframework/core')threwMODULE_NOT_FOUND— even on the mock provider or with no AWS at all. This also broke the devtools CLI, which loads core (verified:frigg init --helpcrashed on the unfixed registry core).Approach (dep made lazy, not just added):
@aws-sdk/client-scheduleris now required lazily through a cachedloadSchedulerSdk()helper, called from the EventBridge adapter's constructor and methods — never at module load. Requiring the scheduler module (and thus core) no longer pulls aws-sdk; only instantiating the EventBridge adapter does. A missing package yields a clear, actionable error instead of a rawMODULE_NOT_FOUND.optionalDependenciesso AWS deployments still install it by default, while non-AWS/local consumers aren't forced to. The factory already only instantiates the EventBridge adapter for theeventbridgeprovider; the mock path never touches aws-sdk.eventbridge-scheduler-adapter.test.js).Proof (clean temp install,
--omit=optionalso client-scheduler is absent):@aws-sdk/client-schedulerand instantiatingEventBridgeSchedulerAdapterstill constructs a realSchedulerClient.Fix 2 —
frigg initis broken in the 2.0-next devtoolsfrigg init <name>failed two ways:(a) Backend template not shipped. The handler copies from
frigg-cli/templates/backend, but that directory did not exist in the source tree (confirmed absent from the published2.0.0-next.107tarball) → "Backend template not found." Added a working backend template (index.jsexportingDefinition,infrastructure.js,README.md) and listedfrigg-cli/templates/in packagefiles. The template's app definition validates against the current app-definition schema, and carries the exact markersupdateAppDefinition()rewrites when integrations are selected.(b) The
--templatedefault routed every init into the dead legacy branch. The CLI registered--templatewith a default of'backend-only', but the handler only runs the backend-first path when!options.template, so the truthy default always fell through to "Legacy template system is no longer supported" and exited 1. Removed the default (--templateis now an explicit, unsupported legacy opt-in), made the positional the project name (init [projectName]), registered the flags the handler actually reads (--mode,--no-frontend,--force,--verbose), dropped the unused--directory, and removed the danglingoptions.legacyFrontendreference.Proof (built devtools tarball installed into a scratch dir):
frigg init --helplists the new options.my-frigg-appproducesindex.js/infrastructure.js/package.json/README.md— no "template not found", no "legacy not supported". Generatedindex.jsexports a validDefinition;infrastructure.jsresolvescreateFriggInfrastructurefrom devtools.--templatestill shows the legacy message (escape hatch preserved).Files changed
packages/core/infrastructure/scheduler/eventbridge-scheduler-adapter.js— lazy SDK loadpackages/core/infrastructure/scheduler/eventbridge-scheduler-adapter.test.js— new regression testpackages/core/package.json—optionalDependencies: @aws-sdk/client-schedulerpackages/devtools/frigg-cli/templates/backend/{index.js,infrastructure.js,README.md}— new backend templatepackages/devtools/package.json— shipfrigg-cli/templates/packages/devtools/frigg-cli/index.js—initcommand definitionpackages/devtools/frigg-cli/init-command/index.js— default routing + project-name handlingTest plan
requiresucceeds (threw before)frigg init <name>scaffolds a backend app from the built devtools tarball🤖 Generated with Claude Code
Generated by Claude Code