From dde01882d5f4e655ffcf3dcc5bef8e6218b8fef2 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 5 Nov 2019 15:38:01 -0800 Subject: [PATCH] add 'make cutarelease' to publish new versions; use "files" for smaller published package (#95) Also drop some unnecessary Makefile goop. The 'make cutarelease' task was copied from node-manta/Makefile with tweaks to make it work with /bin/sh that isn't ksh or bash. --- .gitignore | 3 +- CHANGES.md | 6 ++- Makefile | 63 ++++++++++++++++++-------------- package.json | 3 ++ tools/mk/Makefile.node_deps.defs | 35 ------------------ tools/mk/Makefile.node_deps.targ | 16 -------- 6 files changed, 43 insertions(+), 83 deletions(-) delete mode 100644 tools/mk/Makefile.node_deps.defs delete mode 100644 tools/mk/Makefile.node_deps.targ diff --git a/.gitignore b/.gitignore index 3351ce2..07e6e47 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -*.log -node_modules +/node_modules diff --git a/CHANGES.md b/CHANGES.md index 10d9947..005f88c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ # node-http-signature changelog -## Not Yet Released +## not yet released + +(nothing yet) ## 1.3.1 @@ -46,7 +48,7 @@ - First semver release. - #36: Ensure verifySignature does not leak useful timing information -- #42: Bring the library up to the latest version of the spec (including the +- #42: Bring the library up to the latest version of the spec (including the request-target changes) - Support for ECDSA keys and signatures. - Now uses `sshpk` for key parsing, validation and conversion. diff --git a/Makefile b/Makefile index 9a56760..5b7cc2c 100644 --- a/Makefile +++ b/Makefile @@ -1,51 +1,58 @@ # -# Copyright (c) 2012, Joyent, Inc. All rights reserved. +# Copyright 2019 Joyent, Inc. # -# Makefile: basic Makefile for template API service -# -# This Makefile is a template for new repos. It contains only repo-specific -# logic and uses included makefiles to supply common targets (javascriptlint, -# jsstyle, restdown, etc.), which are used by other repos as well. You may well -# need to rewrite most of this file, but you shouldn't need to touch the -# included makefiles. -# -# If you find yourself adding support for new targets that could be useful for -# other projects too, you should add these to the original versions of the -# included Makefiles (in eng.git) so that other teams can use them too. -# - -# -# Tools -# -NPM_EXEC := npm -TAP := ./node_modules/.bin/tap -# -# Files -# JS_FILES := $(shell find lib -name '*.js') JSL_CONF_NODE = tools/jsl.node.conf JSL_FILES_NODE = $(JS_FILES) JSSTYLE_FILES = $(JS_FILES) JSSTYLE_FLAGS = -f tools/jsstyle.conf - +# This, and the includes below, provide: 'make check' and 'make clean'. include ./tools/mk/Makefile.defs -include ./tools/mk/Makefile.node_deps.defs + # # Repo-specific targets # .PHONY: all all: $(REPO_DEPS) - $(NPM_EXEC) install + npm install -CLEAN_FILES += $(TAP) ./node_modules/tap +CLEAN_FILES += ./node_modules .PHONY: test test: all - TAP=1 $(TAP) test/*.test.js + TAP=1 ./node_modules/.bin/tap test/*.test.js + +# Ensure CHANGES.md and package.json have the same version. +.PHONY: check-version +check-version: + @echo version is: $(shell cat package.json | json version) + [ "`cat package.json | json version`" = "`grep '^## ' CHANGES.md | head -2 | tail -1 | awk '{print $$2}'`" ] + +check: check-version + +.PHONY: cutarelease +cutarelease: $(COMPLETION_FILE) check-version + [ -z "`git status --short`" ] # If this fails, the working dir is dirty. + @which json 2>/dev/null 1>/dev/null && \ + ver=$(shell json -f package.json version) && \ + name=$(shell json -f package.json name) && \ + publishedVer=$(shell npm view -j $(shell json -f package.json name)@$(shell json -f package.json version) version 2>/dev/null) && \ + if [ -n "$$publishedVer" ]; then \ + echo "error: $$name@$$ver is already published to npm"; \ + exit 1; \ + fi && \ + echo "** Are you sure you want to tag and publish $$name@$$ver to npm?" && \ + echo "** Enter to continue, Ctrl+C to abort." && \ + read + ver=$(shell cat package.json | json version) && \ + date=$(shell date -u "+%Y-%m-%d") && \ + git tag -a "v$$ver" -m "version $$ver ($$date)" && \ + git push --tags origin && \ + npm publish + include ./tools/mk/Makefile.deps -include ./tools/mk/Makefile.node_deps.targ include ./tools/mk/Makefile.targ diff --git a/package.json b/package.json index 14e5bfb..b72f688 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,9 @@ "node": ">=0.10" }, "main": "lib/index.js", + "files": [ + "lib" + ], "scripts": { "test": "tap test/*.js" }, diff --git a/tools/mk/Makefile.node_deps.defs b/tools/mk/Makefile.node_deps.defs deleted file mode 100644 index e9999b4..0000000 --- a/tools/mk/Makefile.node_deps.defs +++ /dev/null @@ -1,35 +0,0 @@ -# -*- mode: makefile -*- -# -# Copyright (c) 2012, Joyent, Inc. All rights reserved. -# -# Makefile.node_deps.defs: Makefile for including npm modules whose sources -# reside inside the repo. This should NOT be used for modules in the npm -# public repo or modules that could be specified with git SHAs. -# -# NOTE: This makefile comes from the "eng" repo. It's designed to be dropped -# into other repos as-is without requiring any modifications. If you find -# yourself changing this file, you should instead update the original copy in -# eng.git and then update your repo to use the new version. -# - -# -# This Makefile takes as input the following make variable: -# -# REPO_MODULES List of relative paths to node modules (i.e., npm -# packages) inside this repo. For example: -# src/node-canative, where there's a binary npm package -# in src/node-canative. -# -# Based on the above, this Makefile defines the following new variables: -# -# REPO_DEPS List of relative paths to the installed modules. For -# example: "node_modules/canative". -# -# The accompanying Makefile.node_deps.targ defines a target that will install -# each of REPO_MODULES into REPO_DEPS and remove REPO_DEPS with "make clean". -# The top-level Makefile is responsible for depending on REPO_DEPS where -# appropriate (usually the "deps" or "all" target). -# - -REPO_DEPS := $(REPO_MODULES:src/node-%=node_modules/%) -CLEAN_FILES += $(REPO_DEPS) diff --git a/tools/mk/Makefile.node_deps.targ b/tools/mk/Makefile.node_deps.targ deleted file mode 100644 index 603c87c..0000000 --- a/tools/mk/Makefile.node_deps.targ +++ /dev/null @@ -1,16 +0,0 @@ -# -*- mode: makefile -*- -# -# Copyright (c) 2012, Joyent, Inc. All rights reserved. -# -# Makefile.node_deps.targ: targets for Makefile.node_deps.defs. -# -# NOTE: This makefile comes from the "eng" repo. It's designed to be dropped -# into other repos as-is without requiring any modifications. If you find -# yourself changing this file, you should instead update the original copy in -# eng.git and then update your repo to use the new version. -# - -NPM_EXEC ?= $(error NPM_EXEC must be defined for Makefile.node_deps.targ) - -node_modules/%: src/node-% | $(NPM_EXEC) - $(NPM) install $<