Skip to content

fix: create should generate from the bundled template #1625

Description

@marcossevilla

Description

very_good create does not generate projects from the template bundled in the CLI. Instead it fetches the
brick from the hosted registry (brickhub.dev) using a caret constraint, falling back to the bundle only
when offline.

In create_subcommand.dart, _getGeneratorForTemplate():

  final brick = Brick.version(
    name: template.bundle.name,
    version: '^${template.bundle.version}', // e.g. ^1.3.3
  );
  return await _generatorFromBrick(brick);  // hosted fetch
  // bundle is only used if the fetch throws

Because the constraint is a caret, ^1.3.3 resolves to the latest compatible published version. The CLI
currently bundles very_good_core 1.3.3 but generates 1.4.0.

Impact

  • The version we ship and test is not the version users get.
  • create output is non-deterministic — a template publish changes results with no CLI release.
  • Our e2e tests (online) validate the latest published brick, not the committed bundle.
  • An upstream template release can change/break create silently.

Proposed fix

Always generate from the embedded MasonBundle and remove the hosted brick fetch:

  Future<MasonGenerator> _getGeneratorForTemplate() async {
    return _generatorFromBundle(template.bundle);
  }

This makes create deterministic, offline-first, and faster, and makes the CLI the single source of truth
for template output. Template updates are then delivered via a CLI release (regenerate bundles with
tool/generate_bundles.sh).

Steps To Reproduce

You can see this affecting issues like #1624

Expected Behavior

  • create generates solely from template.bundle; no registry fetch at runtime.
  • Remove the now-unused generatorFromBrick / MasonGeneratorFromBrick plumbing (or keep it clearly
    unused/tested).
  • e2e tests assert the generated project matches the bundled template version.
  • Tests/coverage updated to reflect the bundle-only path (100% coverage).

Notes / alternatives considered

  • Exact-pin the brick constraint (version: template.bundle.version) keeps the hosted-fetch architecture
    but in lockstep with the bundle. Rejected here in favor of the simpler, fully deterministic bundle-only
    approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working as expected

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions