Skip to content

Add prepublishOnly guard to prevent accidental local npm publish #20

@MelbourneDeveloper

Description

@MelbourneDeveloper

Problem

Neither `packages/core/package.json` nor `packages/too-many-cooks/package.json` has a `prepublishOnly` script. If anyone runs `npm publish` from a laptop (typo, muscle memory, accidental autocomplete) it will publish whatever happens to be on disk — at whatever version is on disk, possibly with uncommitted changes, possibly without going through CI provenance.

The CI workflow itself is fine; the concern is human-driven mishaps bypassing it.

Fix

Add to both packages:

```json
"scripts": {
"prepublishOnly": "node -e "if(!process.env.CI)throw new Error('publish only from CI')""
}
```

This blocks `npm publish` unless `CI=1` (true on GitHub Actions, false locally). A typo on a laptop fails fast with a clear error.

Related

Found while reviewing release workflow after fixing the missing `files` field in `too-many-cooks/package.json`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions