Skip to content

Commit

Permalink
Damn you windows.
Browse files Browse the repository at this point in the history
reverted everything back to the olden times, no more direct windows builds, only linux. reverting back to the vacuum design which works consistently for npm

Signed-off-by: quobix <dave@quobix.com>
  • Loading branch information
daveshanley committed Mar 28, 2024
1 parent 500fa6e commit 33f30d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
1 change: 0 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ archives:
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
format: zip
checksum:
name_template: 'checksums.txt'

Expand Down
2 changes: 1 addition & 1 deletion npm-install/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const CONFIG = {
name: "openapi-changes",
path: "./bin",
url: "https://github.com/pb33f/openapi-changes/releases/download/v{{version}}/{{bin_name}}_{{version}}_{{platform}}_{{arch}}.zip",
url: "https://github.com/pb33f/openapi-changes/releases/download/v{{version}}/{{bin_name}}_{{version}}_{{platform}}_{{arch}}.tar.gz",
};
export const ARCH_MAPPING = {
ia32: "i386",
Expand Down
27 changes: 9 additions & 18 deletions npm-install/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import { createWriteStream } from "fs";
import * as fs from "fs";


import * as fs from "fs/promises";
import fetch from "node-fetch";
import { pipeline } from "stream/promises";
import tar from "tar";
import AdmZip from 'adm-zip'
import { execSync } from "child_process";

import { ARCH_MAPPING, CONFIG, PLATFORM_MAPPING } from "./config.js";

async function install() {
if (process.platform === "android") {
console.log("Installing openapi-changes, may take a moment...");
console.log("Installing, may take a moment...");
const cmd =
"pkg upgrade && pkg install golang git -y && git clone https://github.com/pb33f/openapi-changes.git && cd cli/ && go build -o $PREFIX/bin/openapi-changes";
execSync(cmd, { encoding: "utf-8" });
console.log("openapi-changes installation successful!");
console.log("Installation successful!");
return;
}
const packageJson = await fs.promises.readFile("package.json").then(JSON.parse);
const packageJson = await fs.readFile("package.json").then(JSON.parse);
let version = packageJson.version;

if (typeof version !== "string") {
Expand All @@ -42,18 +39,12 @@ async function install() {
throw new Error("Failed fetching the binary: " + response.statusText);
}

const zipFile = "downloaded.zip";
await fs.promises.mkdir(binPath, { recursive: true });
await pipeline(response.body, createWriteStream(zipFile));

// unzip binary
const zip = new AdmZip(zipFile);
zip.extractAllTo(binPath, true);
const tarFile = "downloaded.tar.gz";

// make the binary executable.
await fs.chmodSync(`${binPath}/openapi-changes`, 0o755);
await fs.promises.rm(zipFile);
console.log("openapi-changes installation successful!");
await fs.mkdir(binPath, { recursive: true });
await pipeline(response.body, createWriteStream(tarFile));
await tar.x({ file: tarFile, cwd: binPath });
await fs.rm(tarFile);
}

install()
Expand Down

0 comments on commit 33f30d0

Please sign in to comment.