Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Commit

Permalink
chore(release): 0.5.1
Browse files Browse the repository at this point in the history
Try again.
  • Loading branch information
dsherret committed Jan 30, 2022
1 parent 449f890 commit 6f822c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
@@ -1,5 +1,5 @@
{
"deno.enable": true,
"deno.lint": false,
"deno.unstable": true
"deno.unstable": false
}
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "dprint-plugin-rustfmt"
version = "0.5.0"
version = "0.5.1"
authors = ["David Sherret <dsherret@gmail.com>"]
edition = "2021"

Expand Down
23 changes: 13 additions & 10 deletions scripts/createPluginFile.ts
@@ -1,6 +1,3 @@
import { createHash } from "https://deno.land/std@0.122.0/hash/mod.ts";
import * as hex from "https://deno.land/std@0.122.0/encoding/hex.ts";

const packageText = Deno.readTextFileSync("Cargo.toml");
// version = "x.x.x"
const version = packageText.match(/version\s*=\s*\"(\d+\.\d+\.\d+)\"/)![1];
Expand All @@ -13,20 +10,26 @@ const outputFile = {
schemaVersion: 1,
name: "dprint-plugin-rustfmt",
version,
"mac-x86_64": getPlatformObject("dprint-plugin-rustfmt-x86_64-apple-darwin.zip"),
"linux-x86_64": getPlatformObject("dprint-plugin-rustfmt-x86_64-unknown-linux-gnu.zip"),
"windows-x86_64": getPlatformObject("dprint-plugin-rustfmt-x86_64-pc-windows-msvc.zip"),
"mac-x86_64": await getPlatformObject("dprint-plugin-rustfmt-x86_64-apple-darwin.zip"),
"linux-x86_64": await getPlatformObject("dprint-plugin-rustfmt-x86_64-unknown-linux-gnu.zip"),
"windows-x86_64": await getPlatformObject("dprint-plugin-rustfmt-x86_64-pc-windows-msvc.zip"),
};
Deno.writeTextFile("plugin.exe-plugin", JSON.stringify(outputFile, undefined, 2) + "\n");

function getPlatformObject(zipFileName: string) {
async function getPlatformObject(zipFileName: string) {
const fileBytes = Deno.readFileSync(zipFileName);
const hash = createHash("sha256");
hash.update(fileBytes);
const checksum = hex.encodeToString(new Uint8Array(hash.digest()));
const checksum = await getChecksum(fileBytes);
console.log(zipFileName + ": " + checksum);
return {
"reference": `https://github.com/dprint/dprint-plugin-rustfmt/releases/download/${version}/${zipFileName}`,
"checksum": checksum,
};
}

async function getChecksum(bytes: Uint8Array) {
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#converting_a_digest_to_a_hex_string
const hashBuffer = await crypto.subtle.digest("SHA-256", bytes);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
return hashHex;
}

0 comments on commit 6f822c4

Please sign in to comment.