Skip to content

Commit

Permalink
fix(bin): missing dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziothh committed Nov 15, 2023
1 parent b83a4f7 commit aaeb356
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
11 changes: 10 additions & 1 deletion lib/bin/binary.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import path from 'path';
import tar from 'tar';
// const rimraf = require("rimraf");

function error(msg: string, cause?: Error) {
function error(msg: string, cause?: Error): never {
console.error(msg, ...(cause ? [cause] : []));
process.exit(1);
};
Expand Down Expand Up @@ -66,6 +66,15 @@ export default class Binary {

const tarFileLocation = path.resolve(this.installDirectory, this.url.toString().split('/').pop() ?? 'download.tar.gz');
return await fetch(this.url)
.then(async (res) => {
if (res.ok) return res;

error([
`Could not fetch tarbal from "${this.url}"`,
'Status: ' + res.status,
'Error: ' + await res.text(),
].join('\n'));
})
.then(res => res.arrayBuffer())
.then(blob => {
// const file = new File([blob], tarFileLocation)
Expand Down
3 changes: 2 additions & 1 deletion lib/bin/shared.mts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ const getPlatformMetadata = () => {

export const getBinary = () => {
const platformMetadata = getPlatformMetadata();
const version = PACKAGE_JSON.version.split('-').shift()!;
// the url for this binary is constructed from values in `package.json`
// https://github.com/EverlastingBugstopper/binary-install/releases/download/v1.0.0/binary-install-example-v1.0.0-x86_64-apple-darwin.tar.gz
const url = `${PACKAGE_JSON.repository.url}/releases/download/v${PACKAGE_JSON.version}/${'ntr'}-${platformMetadata.RUST_TARGET}.tar.gz`;
const url = `${PACKAGE_JSON.repository.url}/releases/download/v${version}/${'ntr'}-${platformMetadata.RUST_TARGET}.tar.gz`;
// const url = `https://github.com/Ziothh/ntr/releases/download/v0.0.0/ntr-x86_64-unknown-linux-musl.tar.gz`;
const installDirectory = path.join(__dirname, "../../node_modules", ".bin");

Expand Down
7 changes: 4 additions & 3 deletions lib/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "@next-typed-routes/lib",
"version": "0.0.1",
"version": "0.0.2-rc.1",
"private": false,
"publishConfig": {
"tag": "rc-2",
"access": "public"
},
"description": "",
Expand Down Expand Up @@ -32,6 +31,9 @@
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"tar": "^6.2.0"
},
"devDependencies": {
"@types/node": "~20",
"@types/react": "^18.2.20",
Expand All @@ -40,7 +42,6 @@
"next": "^13.4.13",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tar": "^6.2.0",
"typescript": "^5.2.2"
},
"peerDependencies": {
Expand Down
21 changes: 11 additions & 10 deletions pnpm-lock.yaml

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

0 comments on commit aaeb356

Please sign in to comment.