Skip to content

feat(npm): ship schema.json inside the fallow package (#275)#279

Merged
BartWaardenburg merged 2 commits intofallow-rs:mainfrom
ChrisJr404:feat/ship-schema-json-in-npm-275
May 5, 2026
Merged

feat(npm): ship schema.json inside the fallow package (#275)#279
BartWaardenburg merged 2 commits intofallow-rs:mainfrom
ChrisJr404:feat/ship-schema-json-in-npm-275

Conversation

@ChrisJr404
Copy link
Copy Markdown
Contributor

Closes #275.

Two-line fix to bundle the JSON schema into the published `fallow` npm package so consumers can reference `./node_modules/fallow/schema.json` instead of the `raw.githubusercontent.com` URL. That fixes the three downsides @OmerGronich called out:

  • Drift — `./node_modules/fallow/schema.json` is always version-aligned with the installed CLI; the URL tracks `main` and can disagree with a pinned install.
  • Network on every IDE open — the URL needs to be fetched and cached, and corporate proxies sometimes block `raw.githubusercontent.com`.
  • Offline / airgapped — local schema lookup, no generator step, no refresh policy on upgrade.

What changed

  • `npm/fallow/package.json`: `schema.json` added to the `files` array.
  • `.github/workflows/release.yml`: new `Bundle schema.json into fallow package` step right before `Publish fallow` that copies `schema.json` from the repo root into `npm/fallow/schema.json`. Doing it at workflow level rather than via a `prepublishOnly` hook because the existing publish call uses `--ignore-scripts`.

After this, the issue's recommended consumer config works:

```jsonc
// .fallowrc.json
{
"$schema": "./node_modules/fallow/schema.json",
...
}
```

The existing remote URL (`raw.githubusercontent.com/fallow-rs/fallow/main/schema.json`) keeps working as a fallback for users without a local install — nothing about this change breaks the remote-URL path.

What's not in this PR

The optional `fallow init` template polish (emit `./node_modules/fallow/schema.json` by default) lives in the Rust CLI and is a separate change that's only meaningful once this artifact has actually been published. Happy to do that as a follow-up after the next release if you'd like.

Test plan

  • `package.json` valid JSON, `files` array includes `schema.json`
  • `release.yml` valid YAML, copy step ordered before `npm publish ./npm/fallow`
  • `schema.json` already lives at the repo root (56 KB, the canonical artifact `fallow config-schema` would emit), so the `cp` source path is correct
  • (For maintainer) — next `v*..` tag should produce a published `fallow` package containing `schema.json` at the package root; `npm pack ./npm/fallow` locally on a tagged build would confirm without a real publish

Today the published `fallow` npm package omits `schema.json`, so the
only stable way to point `$schema` at a matching schema is the
`raw.githubusercontent.com/.../main/schema.json` URL — which:

  - drifts from the installed CLI version (URL tracks main, install
    is pinned to a tag),
  - requires network on every fresh editor open and trips up
    corporate proxies that block raw.githubusercontent.com,
  - has no clean offline / airgapped story.

Two-line fix:

  - Add `schema.json` to `npm/fallow/package.json`'s files array.
  - In the release workflow, copy `schema.json` from the repo root
    to `npm/fallow/schema.json` immediately before the `npm publish
    ./npm/fallow` step. We can't rely on a prepublishOnly hook here
    because the existing publish call uses `--ignore-scripts`.

After this, consumers can write:

  {
    "$schema": "./node_modules/fallow/schema.json",
    ...
  }

…and get version-aligned validation with zero network calls. The
remote URL keeps working as a fallback for users without a local
install.

The optional `fallow init` template change suggested in the issue
isn't included here — that lives in the Rust CLI and is best done as
a follow-up once this artifact is actually published.
@BartWaardenburg BartWaardenburg merged commit 547ac02 into fallow-rs:main May 5, 2026
1 check passed
@BartWaardenburg
Copy link
Copy Markdown
Collaborator

Merged in 547ac02. Thanks for the clean two-line fix, @ChrisJr404. The next v* tag will publish fallow with schema.json bundled, so users can point $schema at ./node_modules/fallow/schema.json for version-aligned validation without the network round-trip. Added a CI assertion alongside so the package never silently loses the file again.

@BartWaardenburg
Copy link
Copy Markdown
Collaborator

Released in v2.65.0. Thanks @ChrisJr404.

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.

Ship schema.json inside the npm package so $schema can resolve from node_modules

2 participants