Skip to content

Make Lintel installable with npx - #3

Merged
Amsozzer1 merged 4 commits into
mainfrom
prep/npm-install
Oct 13, 2026
Merged

Amsozzer1 merged 4 commits into
mainfrom
prep/npm-install

Conversation

@Amsozzer1

@Amsozzer1 Amsozzer1 commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Goal: npx @amsozzer/lintel migrations check works on a machine with Docker and the Supabase CLI, with no clone or build step.

Changes

  • package.json
    • engines.node is now >=22.12. commander 15 requires >=22.12.0, so >=22 let Node 22.0–22.11 install and then break. lintel doctor checks the same floor.
    • prepack: pnpm build, so npm pack and npm publish always ship a fresh dist/.
    • publishConfig.access: public, required for a scoped package's first publish.
    • bin and the files allowlist were already correct and are unchanged.
  • First-run fix: base and head databases start in parallel, and each started its own image pull, so the "pulling…" line printed twice. They now share one in-flight pull.
  • README:
    • "Try it" leads with the npx command; the from-source steps follow the sample output.
    • The sample output is the real current output, including the P001 proof line.
    • The "about 25 ms" startup claim is replaced with the measured number. The same change is in docs/design.md.

Testing

  • npm pack --dry-run: 28 files, 27.2 kB (dist, schemas, README, LICENSE, package.json).
  • Installed the tarball into a fresh npm init project; the lintel bin resolves.
  • With the database image deleted, ran npx --package=<tarball> lintel migrations check in a throwaway repo built from demo/supabase, with RLS removed from messages in the working tree. The image pulled once, the run reported 3 new errors including P001 [proven] and exited 1, in 47 s. No containers were left behind.
  • --help: 38 ms median wall-clock for both the installed tarball and unmodified HEAD, against 24 ms for bare node -e 0 (Apple M4, Node 24.21). Packaging doesn't slow startup.
  • pnpm check:all and pnpm test:e2e pass.

Not included: npm publish, which will be run manually.

🤖 Generated with Claude Code

Summary by Sourcery

Make Lintel installable via npx with reliable packaging, compatible Node.js checks, and streamlined first-run database setup.

New Features:

  • Make Lintel installable and runnable through npx without requiring users to clone or build the repository.

Bug Fixes:

  • Prevent duplicate Supabase Postgres image pulls when starting base and head databases concurrently.
  • Align the doctor Node.js version check with the package's minimum supported version.

Enhancements:

  • Update the documented usage examples, sample output, and CLI startup-time measurements to reflect the installable package workflow.

Build:

  • Ensure package creation and publishing always build a fresh distribution and configure scoped-package publishing as public.

Documentation:

  • Lead the README with npx usage while retaining source-based setup instructions and update design documentation with current startup measurements.

Amsozzer1 and others added 3 commits October 13, 2026 13:46
…ther

Both throwaway databases start in parallel and each called ensureImage, so a
first run started two pulls and printed the progress line twice. Concurrent
callers now share one in-flight pull per image.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- engines: node >=22.12, the floor commander 15 requires (>=22 let 22.0-22.11
  install and break); lintel doctor checks the same version.
- prepack builds dist, so npm pack and npm publish always ship a fresh build.
- publishConfig.access public, needed for a scoped package's first publish.

Tested by installing the packed tarball in a fresh project and running
`npx --package=<tarball> lintel migrations check` against demo/supabase.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Try it starts with `npx @amsozzer/lintel migrations check`; from source
  moves below the sample output.
- The sample output is the real current output, including the P001 proof.
- Replace the unreproducible "about 25 ms" with the measured 38 ms
  wall-clock (24 ms of it Node startup) and the machine it was measured on.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This PR makes Lintel directly usable through npx by enforcing the required Node.js version, rebuilding dist during packaging, and configuring scoped publication, while also deduplicating concurrent Supabase image pulls and updating documentation and diagnostics to reflect the published workflow and measured behavior.

Sequence diagram for concurrent Supabase image setup

sequenceDiagram
    participant Base as Base database
    participant Head as Head database
    participant EnsureImage as ensureImage
    participant Pulls as pulls map
    participant Docker as Docker image

    par Start base database
        Base->>EnsureImage: ensureImage(image)
    and Start head database
        Head->>EnsureImage: ensureImage(image)
    end
    EnsureImage->>Pulls: pulls.get(image)
    alt image pull is not in flight
        EnsureImage->>Docker: pullImage(image)
        Docker-->>EnsureImage: pull complete
        EnsureImage->>Pulls: pulls.delete(image)
    else image pull is already in flight
        EnsureImage-->>EnsureImage: await shared pull
    end
    EnsureImage-->>Base: image ready
    EnsureImage-->>Head: image ready
Loading

Flow diagram for npx package execution

flowchart LR
    User[Developer in Supabase project] --> Npx[npx @amsozzer/lintel migrations check]
    Npx --> Package[Published package]
    Package --> Bin[lintel bin]
    Bin --> Check[migrations check]
    Check --> Docker[Docker and Supabase database]
    Check --> Result[Migration findings and exit status]
Loading

File-Level Changes

Change Details Files
Package the CLI for direct npx installation with reproducible build output and compatible runtime metadata.
  • Raise the Node.js engine floor to 22.12 to match Commander 15.
  • Build fresh dist output automatically during packing.
  • Configure scoped-package publication as public while retaining the existing bin and file allowlist.
package.json
Make the first database startup avoid duplicate image pulls and progress messages when base and head databases initialize concurrently.
  • Track in-flight pulls by image and share the promise between concurrent startup paths.
  • Remove the shared pull entry after completion, including failure.
src/core/replay/docker.ts
Align runtime diagnostics with the supported Node.js version.
  • Have doctor validate Node 22.12 or newer, including newer major versions.
  • Display the updated version requirement and detected version.
src/cli/commands/setup.ts
Update documentation to present the published npx workflow and accurately describe current behavior and startup performance.
  • Lead the quick-start instructions with npx and retain source-based usage separately.
  • Refresh sample output to include proven P001 findings and current totals.
  • Replace outdated startup timing claims with measured wall-clock and Node startup figures.
README.md
docs/design.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="package.json" line_range="29" />
<code_context>
   },
   "scripts": {
     "build": "tsup",
+    "prepack": "pnpm build",
     "typecheck": "tsc --noEmit",
     "lint": "biome check .",
</code_context>
<issue_to_address>
**Packing requires pnpm**

When the package is packed or published with npm in an environment without pnpm on `PATH`, the `prepack` lifecycle command invokes `pnpm build`, so `npm pack` and `npm publish` fail with a command-not-found error when pnpm is not on `PATH`, even if npm and the build dependencies are available.

Use an npm-invocable build script such as `npm run build` for the `prepack` lifecycle hook.
</issue_to_address>

### Comment 2
<location path="src/core/replay/docker.ts" line_range="142-147" />
<code_context>
-  opts.onProgress?.("pulling the Supabase Postgres image (one time, about 800 MB)…");
-  await pullImage(image);
+  // Base and head start in parallel: share one pull (and one progress message) per image.
+  let pull = pulls.get(image);
+  if (!pull) {
+    opts.onProgress?.("pulling the Supabase Postgres image (one time, about 800 MB)…");
+    pull = pullImage(image).finally(() => pulls.delete(image));
+    pulls.set(image, pull);
+  }
+  await pull;
 }
</code_context>
<issue_to_address>
**Image pulls run twice**

When the second image inspection returns after the first pull resolves, `ensureImage` uses the stale inspection result after `pulls` has been cleared, so it starts another `pullImage` and prints the progress line again even though the image is present.

Recheck whether the image is present before starting another pull.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread package.json Resolved
Comment thread src/core/replay/docker.ts
Comment on lines +142 to +147
let pull = pulls.get(image);
if (!pull) {
opts.onProgress?.("pulling the Supabase Postgres image (one time, about 800 MB)…");
pull = pullImage(image).finally(() => pulls.delete(image));
pulls.set(image, pull);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Image pulls run twice

When the second image inspection returns after the first pull resolves, ensureImage uses the stale inspection result after pulls has been cleared, so it starts another pullImage and prints the progress line again even though the image is present.

Recheck whether the image is present before starting another pull.

Prompt for AI agents
In `src/core/replay/docker.ts` at lines 142-147:

**Image pulls run twice**

When the second image inspection returns after the first pull resolves, `ensureImage` uses the stale inspection result after `pulls` has been cleared, so it starts another `pullImage` and prints the progress line again even though the image is present.

Recheck whether the image is present before starting another pull.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Amsozzer1
Amsozzer1 merged commit 2876905 into main Oct 13, 2026
4 checks passed
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.

1 participant