Skip to content

Commit

Permalink
Switch to npm binary for license headers
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm committed May 31, 2024
1 parent fc0b591 commit 93a01cc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
24 changes: 2 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ SHELL := bash
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-print-directory
BIN := .tmp/bin
COPYRIGHT_YEARS := 2024
LICENSE_IGNORE := -e dist\/
BUF_VERSION ?= 1.32.2

UNAME_S := $(shell uname -s)
Expand Down Expand Up @@ -50,20 +47,8 @@ endif
$(SED_I) "s/version: [0-9]+\.[0-9]+\.[0-9]+/version: $(BUF_VERSION)/g" examples/*.yaml

.PHONY: generate
generate: $(BIN)/license-header ## Regenerate licenses
@# We want to operate on a list of modified and new files, excluding
@# deleted and ignored files. git-ls-files can't do this alone. comm -23 takes
@# two files and prints the union, dropping lines common to both (-3) and
@# those only in the second file (-2). We make one git-ls-files call for
@# the modified, cached, and new (--others) files, and a second for the
@# deleted files.
comm -23 \
<(git ls-files --cached --modified --others --no-empty-directory --exclude-standard | sort -u | grep -v $(LICENSE_IGNORE) ) \
<(git ls-files --deleted | sort -u) | \
xargs $(BIN)/license-header \
--license-type apache \
--copyright-holder "Buf Technologies, Inc." \
--year-range "$(COPYRIGHT_YEARS)"
generate: node_modules ## Regenerate licenses
npm run generate

.PHONY: checkgenerate
checkgenerate:
Expand All @@ -72,8 +57,3 @@ checkgenerate:

node_modules: package-lock.json
npm ci

$(BIN)/license-header: Makefile
@mkdir -p $(@D)
GOBIN=$(abspath $(@D)) go install \
github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v$(BUF_VERSION)
19 changes: 16 additions & 3 deletions package-lock.json

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

9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"format": "prettier --write 'src/*.{json,js,jsx,ts,tsx,css}' --log-level error",
"lint": "eslint --max-warnings 0 src",
"lint:fix": "eslint --max-warnings 0 --fix src",
"build": "ncc build -o dist src/main.ts"
"build": "ncc build -o dist src/main.ts",
"generate": "license-header src --ignore 'dist/**'"
},
"keywords": [
"actions",
Expand All @@ -18,7 +19,13 @@
],
"author": "Buf Technologies, Inc.",
"license": "Apache-2.0",
"licenseHeader": {
"licenseType": "apache",
"yearRange": "2024",
"copyrightHolder": "Buf Technologies, Inc."
},
"devDependencies": {
"@bufbuild/license-header": "^0.0.4",
"@eslint/js": "^9.2.0",
"@types/node": "^20.12.7",
"@vercel/ncc": "^0.38.1",
Expand Down

0 comments on commit 93a01cc

Please sign in to comment.