Skip to content

Commit

Permalink
Actually actually (TM) include lockfile in npm artifacts
Browse files Browse the repository at this point in the history
Previous attempt failed by design of `npm pack` / `npm publish`,
as documented at https://docs.npmjs.com/cli/v6/configuring-npm/package-lock-json :

> One key detail about package-lock.json is that it cannot be published,
> and it will be ignored if found in any place other than the toplevel
> package. It shares a format with npm-shrinkwrap.json, which is
> essentially the same file, but allows publication.
>
> This is not recommended unless deploying a CLI tool or otherwise using
> the publication process for producing production packages.

, and we are a CLI tool. Switching to shrinkwrap.
  • Loading branch information
ronjouch committed Sep 25, 2021
1 parent 8fdceee commit 561beda
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 225 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ built-tests
!app/lib/.placeholder

dist
package-lock.json
app/package-lock.json

# Logs
logs
Expand Down
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
!lib/
!icon-scripts
!package-lock.json
!npm-shrinkwrap.json
.DS_Store
src/
*eslintrc.js
Expand All @@ -19,5 +19,5 @@ app/*
!app/inject/
!app/nativefier.json
!app/package.json
!app/package-lock.json
!app/npm-shrinkwrap.json
.vscode/
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
9 changes: 7 additions & 2 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ The best time to do package upgrades is now / progressively, because:

So: do upgrade CLI & App deps regularly! Our release script will remind you about it.

### Deps lockfile
### Deps lockfile / shrinkwrap

We do use lockfiles (`package-lock.json` & `app/package-lock.json`), for:
We do use lockfiles (`npm-shrinkwrap.json` & `app/npm-shrinkwrap.json`), for:

1. Security (avoiding supply chain attacks)
2. Reproducibility
Expand All @@ -162,6 +162,11 @@ We do use lockfiles (`package-lock.json` & `app/package-lock.json`), for:
It means you might have to update these lockfiles when adding a dependency.
`npm run relock` will help you with that.

Note: we do use `npm-shrinkwrap.json` rather than `package-lock.json` because
the latter is tailored to libraries, and is not publishable.
As [documented](https://docs.npmjs.com/cli/v6/configuring-npm/shrinkwrap-json),
CLI tools like Nativefier should use shrinkwrap.

### Release

While on `master`, with no uncommitted changes, run:
Expand Down
44 changes: 22 additions & 22 deletions app/package-lock.json → app/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 561beda

Please sign in to comment.