Use and ship package-lock.json
npm install has been generating package-lock.json [1] for long enough for us to start relying on it. Replace the unreliable and hacky `$NODE_MODULES_TEST` file with just comparing package.json against package-lock.json to decide when to run npm install. This will finally avoid unnecessary `npm install` runs, but start to run these when git switching branches that have a different package.json. Ship package-lock.json in release tarballs, so that node_modules/ can be reconstructed exactly as it was when making the release. [1] https://docs.npmjs.com/files/package-lock.json Closes #222
This commit is contained in:
parent
b4cb5fe5c9
commit
bfc4039b3e
1 changed files with 6 additions and 6 deletions
12
Makefile
12
Makefile
|
|
@ -6,8 +6,8 @@ TEST_OS = centos-7
|
|||
endif
|
||||
export TEST_OS
|
||||
VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS)
|
||||
# one example directory from `npm install` to check if that already ran
|
||||
NODE_MODULES_TEST=node_modules/po2json
|
||||
# stamp file to check if/when npm install ran
|
||||
NODE_MODULES_TEST=package-lock.json
|
||||
# one example file in dist/ from webpack to check if that already ran
|
||||
WEBPACK_TEST=dist/index.html
|
||||
|
||||
|
|
@ -85,18 +85,18 @@ devel-install: $(WEBPACK_TEST)
|
|||
ln -s `pwd`/dist ~/.local/share/cockpit/$(PACKAGE_NAME)
|
||||
|
||||
# when building a distribution tarball, call webpack with a 'production' environment
|
||||
# ship a stub node_modules/ so that `make` works without re-running `npm install`
|
||||
# we don't ship node_modules for license and compactness reasons; we ship a
|
||||
# pre-built dist/ (so it's not necessary) and ship packge-lock.json (so that
|
||||
# node_modules/ can be reconstructed if necessary)
|
||||
dist-gzip: NODE_ENV=production
|
||||
dist-gzip: all cockpit-$(PACKAGE_NAME).spec
|
||||
if type appstream-util >/dev/null 2>&1; then appstream-util validate-relax --nonet *.metainfo.xml; fi
|
||||
mv node_modules node_modules.release
|
||||
mkdir -p $(NODE_MODULES_TEST)
|
||||
touch -r package.json $(NODE_MODULES_TEST)
|
||||
touch dist/*
|
||||
tar czf cockpit-$(PACKAGE_NAME)-$(VERSION).tar.gz --transform 's,^,cockpit-$(PACKAGE_NAME)/,' \
|
||||
--exclude cockpit-$(PACKAGE_NAME).spec.in \
|
||||
$$(git ls-files) cockpit-$(PACKAGE_NAME).spec dist/ node_modules
|
||||
rm -rf node_modules
|
||||
$$(git ls-files) package-lock.json cockpit-$(PACKAGE_NAME).spec dist/
|
||||
mv node_modules.release node_modules
|
||||
|
||||
srpm: dist-gzip cockpit-$(PACKAGE_NAME).spec
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue