# Test a consumer with local packages

Use built tarballs when testing an application against an unreleased library
change. This exercises the package exports and declarations without importing
implementation source or publishing a release.

In the library checkout, install with `bun install --frozen-lockfile`, supply the
matching mock WebAssembly artifact, then build a uniquely named local candidate:

```sh
bun scripts/build-packages.ts --version 0.5.0-local.1
```

Set `aster_ui_checkout` to that checkout, `aster_consumer_checkout` to the app,
and `aster_candidate_version` to the version used in the build.
The following installs its first-party dependencies from the built tarballs,
including transitive overrides. It restores the committed manifests and lockfile
after installation; `node_modules` deliberately retains the local packages for
the check.

```sh
python3 - "$aster_ui_checkout" "$aster_consumer_checkout" "$aster_candidate_version" <<'PY'
import json, pathlib, subprocess, sys
packages = pathlib.Path(sys.argv[1]).resolve() / 'dist-release'
app = pathlib.Path(sys.argv[2]).resolve()
manifest, lock = app / 'package.json', app / 'bun.lock'
original, original_lock = manifest.read_bytes(), lock.read_bytes()
try:
    package = json.loads(original)
    package.setdefault('overrides', {})
    for name in package['dependencies']:
        if name.startswith('@getaster/'):
            archive = packages / f"getaster-{name.split('/')[1]}-{sys.argv[3]}.tgz"
            if not archive.is_file():
                raise RuntimeError(f'Missing local tarball {archive}')
            package['dependencies'][name] = package['overrides'][name] = 'file:' + str(archive)
    manifest.write_text(json.dumps(package, indent=2) + '\n')
    subprocess.run(['bun', 'install'], cwd=app, check=True)
finally:
    manifest.write_bytes(original)
    lock.write_bytes(original_lock)
PY
```

Run the application's documented build, typecheck, tests and browser checks.
Record the library revision, candidate version and results. Run
`bun install --frozen-lockfile` in the app to restore its published dependencies
when finished. A branch using new APIs still needs the matching local candidate
until the approved library version is available and its exact pins are updated.
