-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Split npm package by os and cpu (#281)
Splitting allows us to give up with post install scripts which is considered as a best practice * feature: Split npm package by OS and CPU Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com> * docs: Update the docs Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com> * chore: Automate publishing Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com> * fix: Make lefthook NPM package work Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com> * feature: Add new NPM package binary to hook template Signed-off-by: Valentin Kiselev <mrexox@evilmartians.com>
- Loading branch information
Showing
12 changed files
with
209 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# NPM package version to release | ||
VERSION := 1.0.0 | ||
|
||
DIST_DIR := ../../dist | ||
|
||
LINUX_AMD64_BIN=$(DIST_DIR)/lefthook_linux_amd64_v1/lefthook | ||
LINUX_ARM64_BIN=$(DIST_DIR)/lefthook_linux_arm64/lefthook | ||
WINDOWS_AMD64_BIN=$(DIST_DIR)/lefthook_windows_amd64_v1/lefthook.exe | ||
WINDOWS_ARM64_BIN=$(DIST_DIR)/lefthook_windows_arm64/lefthook.exe | ||
DARWIN_AMD64_BIN=$(DIST_DIR)/lefthook_darwin_amd64_v1/lefthook | ||
DARWIN_ARM64_BIN=$(DIST_DIR)/lefthook_darwin_arm64/lefthook | ||
|
||
prepare: clean set-version put-readme put-binaries | ||
|
||
publish: | ||
find . -type d -name 'lefthook*' -exec npm publish --access public \{} \; | ||
|
||
# Update versions of all packages | ||
set-version: | ||
find . -name 'package.json' -type f -print0 | xargs -0 sed -E -i "s/\"version\": \".+\"/\"version\": \"$(VERSION)\"/" | ||
sed -E -i "s/\"(lefthook-.+)\": \".+\"/\"\1\": \"$(VERSION)\"/g" lefthook/package.json | ||
|
||
put-binaries: | ||
install -D $(LINUX_AMD64_BIN) lefthook-linux-x64/bin/lefthook | ||
install -D $(LINUX_ARM64_BIN) lefthook-linux-arm64/bin/lefthook | ||
install -D $(WINDOWS_AMD64_BIN) lefthook-windows-x64/bin/lefthook.exe | ||
install -D $(WINDOWS_ARM64_BIN) lefthook-windows-arm64/bin/lefthook.exe | ||
install -D $(DARWIN_AMD64_BIN) lefthook-darwin-x64/bin/lefthook | ||
install -D $(DARWIN_ARM64_BIN) lefthook-darwin-arm64/bin/lefthook | ||
|
||
put-readme: | ||
find . -type d -name 'lefthook*' -exec cp -f ../../README.md \{} \; | ||
|
||
clean: | ||
find . -name 'README.md' -exec rm \{} \; | ||
find . -type f -executable -exec rm \{} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "lefthook-darwin-arm64", | ||
"version": "1.0.0", | ||
"description": "The macOS ARM 64-bit binary for lefthook, git hooks manager.", | ||
"preferUnplugged": false, | ||
"repository": "https://github.com/evilmartians/lefthook", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/evilmartians/lefthook/issues" | ||
}, | ||
"homepage": "https://github.com/evilmartians/lefthook#readme", | ||
"os": [ | ||
"darwin" | ||
], | ||
"cpu": [ | ||
"arm64" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "lefthook-darwin-x64", | ||
"version": "1.0.0", | ||
"description": "The macOS 64-bit binary for lefthook, git hooks manager.", | ||
"preferUnplugged": false, | ||
"repository": "https://github.com/evilmartians/lefthook", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/evilmartians/lefthook/issues" | ||
}, | ||
"homepage": "https://github.com/evilmartians/lefthook#readme", | ||
"os": [ | ||
"darwin" | ||
], | ||
"cpu": [ | ||
"x64" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "lefthook-linux-arm64", | ||
"version": "1.0.0", | ||
"description": "The Linux ARM 64-bit binary for lefthook, git hooks manager.", | ||
"preferUnplugged": false, | ||
"repository": "https://github.com/evilmartians/lefthook", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/evilmartians/lefthook/issues" | ||
}, | ||
"homepage": "https://github.com/evilmartians/lefthook#readme", | ||
"os": [ | ||
"linux" | ||
], | ||
"cpu": [ | ||
"arm64" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "lefthook-linux-x64", | ||
"version": "1.0.0", | ||
"description": "The Linux 64-bit binary for lefthook, git hooks manager.", | ||
"preferUnplugged": false, | ||
"repository": "https://github.com/evilmartians/lefthook", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/evilmartians/lefthook/issues" | ||
}, | ||
"homepage": "https://github.com/evilmartians/lefthook#readme", | ||
"os": [ | ||
"linux" | ||
], | ||
"cpu": [ | ||
"x64" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "lefthook-windows-arm64", | ||
"version": "1.0.0", | ||
"description": "The Windows ARM 64-bit binary for lefthook, git hooks manager.", | ||
"preferUnplugged": false, | ||
"repository": "https://github.com/evilmartians/lefthook", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/evilmartians/lefthook/issues" | ||
}, | ||
"homepage": "https://github.com/evilmartians/lefthook#readme", | ||
"os": [ | ||
"win32" | ||
], | ||
"cpu": [ | ||
"arm64" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "lefthook-windows-x64", | ||
"version": "1.0.0", | ||
"description": "The Windows 64-bit binary for lefthook, git hooks manager.", | ||
"preferUnplugged": false, | ||
"repository": "https://github.com/evilmartians/lefthook", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/evilmartians/lefthook/issues" | ||
}, | ||
"homepage": "https://github.com/evilmartians/lefthook#readme", | ||
"os": [ | ||
"win32" | ||
], | ||
"cpu": [ | ||
"x64" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const path = require("path") | ||
|
||
function getExePath() { | ||
// Detect OS | ||
// https://nodejs.org/api/process.html#process_process_platform | ||
let os = process.platform; | ||
let extension = ''; | ||
if (['win32', 'cygwin'].includes(process.platform)) { | ||
os = 'windows'; | ||
extension = '.exe'; | ||
} | ||
|
||
// Detect architecture | ||
// https://nodejs.org/api/process.html#process_process_arch | ||
let arch = process.arch; | ||
|
||
return require.resolve(`lefthook-${os}-${arch}/bin/lefthook${extension}`) | ||
} | ||
|
||
exports.getExePath = getExePath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "lefthook", | ||
"version": "1.0.0", | ||
"description": "Simple git hooks manager", | ||
"main": "index.js", | ||
"repository": "https://github.com/evilmartians/lefthook", | ||
"bin": { | ||
"lefthook": "bin/index.js" | ||
}, | ||
"keywords": [ | ||
"git", | ||
"hook", | ||
"manager" | ||
], | ||
"author": "mrexox", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/evilmartians/lefthook/issues" | ||
}, | ||
"homepage": "https://github.com/evilmartians/lefthook#readme", | ||
"optionalDependencies": { | ||
"lefthook-darwin-arm64": "1.0.0", | ||
"lefthook-darwin-x64": "1.0.0", | ||
"lefthook-linux-arm64": "1.0.0", | ||
"lefthook-linux-x64": "1.0.0", | ||
"lefthook-windows-arm64": "1.0.0", | ||
"lefthook-windows-x64": "1.0.0" | ||
} | ||
} |