From 492b1ca4b23d10bec91a5483b27a77b22796728a Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Thu, 17 Nov 2022 00:12:49 -0300 Subject: [PATCH] feat!: support custom decompress plugins, drop support for xz by default Through a `decompressPlugins` array in the config file, users can specify custom decompress plugins. You can restore the previous support for xz files by adding the following to your config file: ```js // bindl.config.js module.exports = { decompressPlugins: [ "@felipecrs/decompress-tarxz" ], binaries: [ // ... ] } ``` --- package-lock.json | 19 ++++++++++++++++--- package.json | 2 +- src/index.ts | 8 +++++++- test/index.test.ts | 2 -- test/res/bindl.config.js | 17 +++-------------- 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index e19bcb07..4bac7793 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "3.0.0", "license": "MIT", "dependencies": { - "@felipecrs/decompress-tarxz": "^4.0.0", "@oclif/command": "^1.8.0", "@oclif/config": "^1.17.0", "@oclif/plugin-help": "^3.2.0", @@ -30,6 +29,7 @@ "devDependencies": { "@commitlint/cli": "^12.0.0", "@commitlint/config-conventional": "^12.0.0", + "@felipecrs/decompress-tarxz": "^4.0.0", "@oclif/dev-cli": "^1.22.2", "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", @@ -972,6 +972,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/@felipecrs/decompress-tarxz/-/decompress-tarxz-4.0.0.tgz", "integrity": "sha512-dOzgzpLXYd2wbqAzK+YVX7U9Y1Wm5rJLTQ52zfBDyL3uwRVY5vtzyH9wntAgGa7Z29m5F2CehBdDBdCvC9WMSg==", + "dev": true, "dependencies": { "decompress-tar": "^4.1.0", "file-type": "^16.5.2", @@ -2247,7 +2248,8 @@ "node_modules/@tokenizer/token": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz", - "integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==" + "integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==", + "dev": true }, "node_modules/@tootallnate/once": { "version": "1.1.2", @@ -6947,6 +6949,7 @@ "version": "16.5.4", "resolved": "https://registry.npmjs.org/file-type/-/file-type-16.5.4.tgz", "integrity": "sha512-/yFHK0aGjFEgDJjEKP0pWCplsPFPhwyfwevf/pVxiN0tmE4L9LmwWxWukdJSHdoCli4VgQLehjJtwQBnqmsKcw==", + "dev": true, "dependencies": { "readable-web-to-node-stream": "^3.0.0", "strtok3": "^6.2.4", @@ -8286,6 +8289,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, "engines": { "node": ">=8" }, @@ -10030,6 +10034,7 @@ "version": "8.0.6", "resolved": "https://registry.npmjs.org/lzma-native/-/lzma-native-8.0.6.tgz", "integrity": "sha512-09xfg67mkL2Lz20PrrDeNYZxzeW7ADtpYFbwSQh9U8+76RIzx5QsJBMy8qikv3hbUPfpy6hqwxt6FcGK81g9AA==", + "dev": true, "hasInstallScript": true, "dependencies": { "node-addon-api": "^3.1.0", @@ -10047,6 +10052,7 @@ "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -10424,7 +10430,8 @@ "node_modules/node-addon-api": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", - "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==" + "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==", + "dev": true }, "node_modules/node-emoji": { "version": "1.11.0", @@ -10481,6 +10488,7 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.5.0.tgz", "integrity": "sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==", + "dev": true, "bin": { "node-gyp-build": "bin.js", "node-gyp-build-optional": "optional.js", @@ -13797,6 +13805,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-4.1.0.tgz", "integrity": "sha512-ZI3LnwUv5nOGbQzD9c2iDG6toheuXSZP5esSHBjopsXH4dg19soufvpUGA3uohi5anFtGb2lhAVdHzH6R/Evvg==", + "dev": true, "engines": { "node": ">=8" }, @@ -14755,6 +14764,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/readable-web-to-node-stream/-/readable-web-to-node-stream-3.0.2.tgz", "integrity": "sha512-ePeK6cc1EcKLEhJFt/AebMCLL+GgSKhuygrZ/GLaKZYEecIgIECf4UaUuaByiGtzckwR4ain9VzUh95T1exYGw==", + "dev": true, "dependencies": { "readable-stream": "^3.6.0" }, @@ -14770,6 +14780,7 @@ "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -15751,6 +15762,7 @@ "version": "6.3.0", "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-6.3.0.tgz", "integrity": "sha512-fZtbhtvI9I48xDSywd/somNqgUHl2L2cstmXCCif0itOf96jeW18MBSyrLuNicYQVkvpOxkZtkzujiTJ9LW5Jw==", + "dev": true, "dependencies": { "@tokenizer/token": "^0.3.0", "peek-readable": "^4.1.0" @@ -16118,6 +16130,7 @@ "version": "4.2.1", "resolved": "https://registry.npmjs.org/token-types/-/token-types-4.2.1.tgz", "integrity": "sha512-6udB24Q737UD/SDsKAHI9FCRP7Bqc9D/MQUV02ORQg5iskjtLJlZJNdN4kKtcdtwCeWIwIHDGaUsTsCCAa8sFQ==", + "dev": true, "dependencies": { "@tokenizer/token": "^0.3.0", "ieee754": "^1.2.1" diff --git a/package.json b/package.json index fec8e3b4..63e7904b 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ }, "bugs": "https://github.com/felipecrs/bindl/issues", "dependencies": { - "@felipecrs/decompress-tarxz": "^4.0.0", "@oclif/command": "^1.8.0", "@oclif/config": "^1.17.0", "@oclif/plugin-help": "^3.2.0", @@ -26,6 +25,7 @@ "devDependencies": { "@commitlint/cli": "^12.0.0", "@commitlint/config-conventional": "^12.0.0", + "@felipecrs/decompress-tarxz": "^4.0.0", "@oclif/dev-cli": "^1.22.2", "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", diff --git a/src/index.ts b/src/index.ts index 53a2c36b..9a57ae29 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,9 +42,15 @@ class Bindl extends Command { require("decompress-tarbz2")(), require("decompress-targz")(), require("decompress-unzip")(), - require("@felipecrs/decompress-tarxz")(), ]; + // Load the custom decompressPlugins + if (result.config.decompressPlugins && result.config.decompressPlugins.length > 0) { + for (const plugin of result.config.decompressPlugins) { + plugins.push(require(plugin)()); + } + } + result.config.binaries.forEach( async (binary: { platform: "linux" | "darwin" | "win32"; diff --git a/test/index.test.ts b/test/index.test.ts index 3e348617..492bb312 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -34,7 +34,6 @@ describe("bindl", () => { expect(shell.test("-f", "./binaries/linux/arm/shellcheck")).toBeTruthy(); expect(shell.test("-f", "./binaries/linux/arm64/shellcheck")).toBeTruthy(); expect(shell.test("-f", "./binaries/darwin/x64/shellcheck")).toBeTruthy(); - expect(shell.test("-f", "./binaries/darwin/arm64/shellcheck")).toBeTruthy(); expect( shell.test("-f", "./binaries/win32/x32/shellcheck.exe") ).toBeTruthy(); @@ -62,7 +61,6 @@ describe("bindl", () => { } expect(shell.test("-f", "./binaries/linux/arm/shellcheck")).toBeFalsy(); expect(shell.test("-f", "./binaries/linux/arm64/shellcheck")).toBeFalsy(); - expect(shell.test("-f", "./binaries/darwin/arm64/shellcheck")).toBeFalsy(); expect(shell.test("-f", "./binaries/win32/x32/shellcheck.exe")).toBeFalsy(); }); }); diff --git a/test/res/bindl.config.js b/test/res/bindl.config.js index 35dcd2ec..f9476f85 100644 --- a/test/res/bindl.config.js +++ b/test/res/bindl.config.js @@ -1,9 +1,10 @@ const version = "v0.8.0"; -const shortVersion = version.substring(1); const shellcheckReleaseUrl = `https://github.com/koalaman/shellcheck/releases/download/${version}/shellcheck-${version}`; -const shellcheckM1DownloadBaseUrl = `https://github.com/vscode-shellcheck/shellcheck-m1/releases/download/${version}/`; module.exports = { + decompressPlugins: [ + "@felipecrs/decompress-tarxz" + ], binaries: [ { platform: "linux", @@ -49,18 +50,6 @@ module.exports = { }, ], }, - { - platform: "darwin", - arch: "arm64", - // Sync from homebrew - url: `${shellcheckM1DownloadBaseUrl}shellcheck-${shortVersion}.tar.gz`, - files: [ - { - source: `shellcheck/${shortVersion}/bin/shellcheck`, - target: "shellcheck", - }, - ], - }, { platform: "win32", arch: "x32",