Fix failing license

co-authored-by: nate <nate@zed.dev>
This commit is contained in:
Mikayla Maki
2023-03-02 12:32:47 -08:00
co-authored by nate
parent f67c3f1f1d
commit 6a2a1303c4
21 changed files with 133 additions and 83 deletions
+36 -31
View File
@@ -1,7 +1,7 @@
import * as fs from "fs"
import toml from "toml"
import { schemeMeta } from "./colorSchemes"
import { Meta } from "./themes/common/colorScheme"
import { Meta, Verification } from "./themes/common/colorScheme"
import https from "https"
import crypto from "crypto"
@@ -36,40 +36,45 @@ function getLicenseText(
callback: (meta: Meta, license_text: string) => void
) {
for (let meta of schemeMeta) {
// The following copied from the example code on nodejs.org:
// https://nodejs.org/api/http.html#httpgetoptions-callback
https
.get(meta.license.https_url, (res) => {
const { statusCode } = res
if (typeof meta.license.license_text == "string") {
callback(meta, meta.license.license_text)
} else {
let license_text_obj: Verification = meta.license.license_text;
// The following copied from the example code on nodejs.org:
// https://nodejs.org/api/http.html#httpgetoptions-callback
https
.get(license_text_obj.https_url, (res) => {
const { statusCode } = res
if (statusCode < 200 || statusCode >= 300) {
throw new Error(
`Failed to fetch license for: ${meta.name}, Status Code: ${statusCode}`
)
}
res.setEncoding("utf8")
let rawData = ""
res.on("data", (chunk) => {
rawData += chunk
})
res.on("end", () => {
const hash = crypto
.createHash("sha256")
.update(rawData)
.digest("hex")
if (meta.license.license_checksum == hash) {
callback(meta, rawData)
} else {
throw Error(
`Checksum for ${meta.name} did not match file downloaded from ${meta.license.https_url}`
if (statusCode < 200 || statusCode >= 300) {
throw new Error(
`Failed to fetch license for: ${meta.name}, Status Code: ${statusCode}`
)
}
res.setEncoding("utf8")
let rawData = ""
res.on("data", (chunk) => {
rawData += chunk
})
res.on("end", () => {
const hash = crypto
.createHash("sha256")
.update(rawData)
.digest("hex")
if (license_text_obj.license_checksum == hash) {
callback(meta, rawData)
} else {
throw Error(
`Checksum for ${meta.name} did not match file downloaded from ${license_text_obj.https_url}`
)
}
})
})
})
.on("error", (e) => {
throw e
})
.on("error", (e) => {
throw e
})
}
}
}
+6 -4
View File
@@ -34,10 +34,12 @@ export const meta: Meta = {
author: "EliverLara",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/EliverLara/Andromeda/master/LICENSE.md",
license_checksum:
"2f7886f1a05cefc2c26f5e49de1a39fa4466413c1ccb06fc80960e73f5ed4b89",
license_text: {
https_url:
"https://raw.githubusercontent.com/EliverLara/Andromeda/master/LICENSE.md",
license_checksum:
"2f7886f1a05cefc2c26f5e49de1a39fa4466413c1ccb06fc80960e73f5ed4b89",
}
},
url: "https://github.com/EliverLara/Andromeda",
}
+5 -3
View File
@@ -55,9 +55,11 @@ export const meta: Meta = {
author: "atelierbram",
license: {
SPDX: "MIT",
https_url: "https://atelierbram.mit-license.org/license.txt",
license_checksum:
"f95ce526ef4e7eecf7a832bba0e3451cc1000f9ce63eb01ed6f64f8109f5d0a5",
license_text: {
https_url: "https://atelierbram.mit-license.org/license.txt",
license_checksum:
"f95ce526ef4e7eecf7a832bba0e3451cc1000f9ce63eb01ed6f64f8109f5d0a5",
}
},
url: "https://atelierbram.github.io/syntax-highlighting/atelier-schemes/cave/",
}
+5 -3
View File
@@ -35,9 +35,11 @@ export const meta: Meta = {
author: "atelierbram",
license: {
SPDX: "MIT",
https_url: "https://atelierbram.mit-license.org/license.txt",
license_checksum:
"f95ce526ef4e7eecf7a832bba0e3451cc1000f9ce63eb01ed6f64f8109f5d0a5",
license_text: {
https_url: "https://atelierbram.mit-license.org/license.txt",
license_checksum:
"f95ce526ef4e7eecf7a832bba0e3451cc1000f9ce63eb01ed6f64f8109f5d0a5",
}
},
url: "https://atelierbram.github.io/syntax-highlighting/atelier-schemes/sulphurpool/",
}
+4
View File
@@ -29,6 +29,10 @@ export interface Meta {
export interface License {
SPDX: SPDXExpression
/// A url where we can download the license's text
license_text: Verification | string
}
export interface Verification {
https_url: string
license_checksum: string
}
+1 -2
View File
@@ -248,8 +248,7 @@ export const meta: Meta = {
name,
license: {
SPDX: "MIT", // "MIT/X11"
https_url: "",
license_checksum: "",
license_text: "Copyright <YEAR> <COPYRIGHT HOLDER>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/ or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
},
author: "morhetz <morhetz@gmail.com>",
url: "https://github.com/morhetz/gruvbox",
+4 -1
View File
@@ -1,3 +1,6 @@
import { darkHard as dark, meta } from "./gruvbox-common";
import { darkHard as dark, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Dark Hard`
export { dark, meta }
+5 -1
View File
@@ -1,3 +1,7 @@
import { darkSoft as dark, meta } from "./gruvbox-common";
import { darkSoft as dark, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Dark Soft`
export { dark, meta }
+5 -1
View File
@@ -1,3 +1,7 @@
import { darkDefault as dark, meta } from "./gruvbox-common";
import { darkDefault as dark, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Dark`
export { dark, meta }
@@ -1,3 +0,0 @@
import { lightHard as light, meta } from "./gruvbox-common";
export { light, meta }
+6
View File
@@ -0,0 +1,6 @@
import { lightHard as light, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Dark Soft`
export { light, meta }
+4 -1
View File
@@ -1,3 +1,6 @@
import { lightSoft as light, meta } from "./gruvbox-common";
import { lightSoft as light, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Light Soft`
export { light, meta }
+4 -1
View File
@@ -1,3 +1,6 @@
import { lightDefault as light, meta } from "./gruvbox-common";
import { lightDefault as light, meta as commonMeta } from "./gruvbox-common";
let meta = { ...commonMeta };
meta.name = `${commonMeta.name} Light`
export { light, meta }
+6 -4
View File
@@ -72,10 +72,12 @@ export const meta: Meta = {
author: "simurai",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/atom/atom/master/packages/one-light-ui/LICENSE.md",
license_checksum:
"d5af8fc171f6f600c0ab4e7597dca398dda80dbe6821ce01cef78e859e7a00f8",
license_text: {
https_url:
"https://raw.githubusercontent.com/atom/atom/master/packages/one-light-ui/LICENSE.md",
license_checksum:
"d5af8fc171f6f600c0ab4e7597dca398dda80dbe6821ce01cef78e859e7a00f8",
}
},
url: "https://github.com/atom/atom/tree/master/packages/one-dark-ui",
}
+6 -4
View File
@@ -73,10 +73,12 @@ export const meta: Meta = {
author: "simurai",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/atom/atom/master/packages/one-light-ui/LICENSE.md",
license_checksum:
"d5af8fc171f6f600c0ab4e7597dca398dda80dbe6821ce01cef78e859e7a00f8",
license_text: {
https_url:
"https://raw.githubusercontent.com/atom/atom/master/packages/one-light-ui/LICENSE.md",
license_checksum:
"d5af8fc171f6f600c0ab4e7597dca398dda80dbe6821ce01cef78e859e7a00f8",
}
},
url: "https://github.com/atom/atom/tree/master/packages/one-light-ui",
}
+6 -4
View File
@@ -34,10 +34,12 @@ export const meta: Meta = {
author: "edunfelt",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
license_text: {
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
}
},
url: "https://github.com/edunfelt/base16-rose-pine-scheme",
}
+6 -4
View File
@@ -34,10 +34,12 @@ export const meta: Meta = {
author: "edunfelt",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
license_text: {
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
}
},
url: "https://github.com/edunfelt/base16-rose-pine-scheme",
}
+6 -4
View File
@@ -32,10 +32,12 @@ export const meta: Meta = {
author: "edunfelt",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
license_text: {
https_url:
"https://raw.githubusercontent.com/edunfelt/base16-rose-pine-scheme/main/LICENSE",
license_checksum:
"6ca1b9da8c78c8441c5aa43d024a4e4a7bf59d1ecca1480196e94fda0f91ee4a",
}
},
url: "https://github.com/edunfelt/base16-rose-pine-scheme",
}
+6 -4
View File
@@ -32,10 +32,12 @@ export const meta: Meta = {
author: "gessig",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/gessig/base16-sandcastle-scheme/master/LICENSE",
license_checksum:
"8399d44b4d935b60be9fee0a76d7cc9a817b4f3f11574c9d6d1e8fd57e72ffdc",
license_text: {
https_url:
"https://raw.githubusercontent.com/gessig/base16-sandcastle-scheme/master/LICENSE",
license_checksum:
"8399d44b4d935b60be9fee0a76d7cc9a817b4f3f11574c9d6d1e8fd57e72ffdc",
}
},
url: "https://github.com/gessig/base16-sandcastle-scheme",
}
+6 -4
View File
@@ -35,10 +35,12 @@ export const meta: Metadata = {
author: "Ethan Schoonover",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/altercation/solarized/master/LICENSE",
license_checksum:
"494aefdabf86acce06bd63001ad8aedad4ee38da23509d3f917d95aa3368b9a6",
license_text: {
https_url:
"https://raw.githubusercontent.com/altercation/solarized/master/LICENSE",
license_checksum:
"494aefdabf86acce06bd63001ad8aedad4ee38da23509d3f917d95aa3368b9a6",
}
},
url: "https://github.com/altercation/solarized",
}
+6 -4
View File
@@ -34,9 +34,11 @@ export const meta: Meta = {
url: "https://github.com/zoefiri/base16-sc",
license: {
SPDX: "MIT",
https_url:
"https://raw.githubusercontent.com/zoefiri/base16-sc/master/LICENSE",
license_checksum:
"fadcc834b7eaf2943800956600e8aeea4b495ecf6490f4c4b6c91556a90accaf",
license_text: {
https_url:
"https://raw.githubusercontent.com/zoefiri/base16-sc/master/LICENSE",
license_checksum:
"fadcc834b7eaf2943800956600e8aeea4b495ecf6490f4c4b6c91556a90accaf",
}
},
}