From 6a2a1303c41fe0aacf5174c209994d1ae56ceb18 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 2 Mar 2023 12:32:29 -0800 Subject: [PATCH] Fix failing license co-authored-by: nate --- styles/src/buildLicenses.ts | 67 +++++++++++--------- styles/src/themes/andromeda.ts | 10 +-- styles/src/themes/atelier-cave.ts | 8 ++- styles/src/themes/atelier-sulphurpool.ts | 8 ++- styles/src/themes/common/colorScheme.ts | 4 ++ styles/src/themes/gruvbox-common.ts | 3 +- styles/src/themes/gruvbox-dark-hard.ts | 5 +- styles/src/themes/gruvbox-dark-soft.ts | 6 +- styles/src/themes/gruvbox-dark.ts | 6 +- styles/src/themes/gruvbox-light-hard copy.ts | 3 - styles/src/themes/gruvbox-light-hard.ts | 6 ++ styles/src/themes/gruvbox-light-soft.ts | 5 +- styles/src/themes/gruvbox-light.ts | 5 +- styles/src/themes/one-dark.ts | 10 +-- styles/src/themes/one-light.ts | 10 +-- styles/src/themes/rose-pine-dawn.ts | 10 +-- styles/src/themes/rose-pine-moon.ts | 10 +-- styles/src/themes/rose-pine.ts | 10 +-- styles/src/themes/sandcastle.ts | 10 +-- styles/src/themes/solarized.ts | 10 +-- styles/src/themes/summercamp.ts | 10 +-- 21 files changed, 133 insertions(+), 83 deletions(-) delete mode 100644 styles/src/themes/gruvbox-light-hard copy.ts create mode 100644 styles/src/themes/gruvbox-light-hard.ts diff --git a/styles/src/buildLicenses.ts b/styles/src/buildLicenses.ts index b1e130e800..793a14a3b2 100644 --- a/styles/src/buildLicenses.ts +++ b/styles/src/buildLicenses.ts @@ -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 + }) + } } } diff --git a/styles/src/themes/andromeda.ts b/styles/src/themes/andromeda.ts index 37a4d3c345..369f1d7f2b 100644 --- a/styles/src/themes/andromeda.ts +++ b/styles/src/themes/andromeda.ts @@ -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", } diff --git a/styles/src/themes/atelier-cave.ts b/styles/src/themes/atelier-cave.ts index 7a85db97e9..21b846d708 100644 --- a/styles/src/themes/atelier-cave.ts +++ b/styles/src/themes/atelier-cave.ts @@ -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/", } diff --git a/styles/src/themes/atelier-sulphurpool.ts b/styles/src/themes/atelier-sulphurpool.ts index bfd105172a..e34bc80238 100644 --- a/styles/src/themes/atelier-sulphurpool.ts +++ b/styles/src/themes/atelier-sulphurpool.ts @@ -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/", } diff --git a/styles/src/themes/common/colorScheme.ts b/styles/src/themes/common/colorScheme.ts index d2f0d17201..3b5b8f6932 100644 --- a/styles/src/themes/common/colorScheme.ts +++ b/styles/src/themes/common/colorScheme.ts @@ -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 } diff --git a/styles/src/themes/gruvbox-common.ts b/styles/src/themes/gruvbox-common.ts index 4c270d6f84..c3e63a31cf 100644 --- a/styles/src/themes/gruvbox-common.ts +++ b/styles/src/themes/gruvbox-common.ts @@ -248,8 +248,7 @@ export const meta: Meta = { name, license: { SPDX: "MIT", // "MIT/X11" - https_url: "", - license_checksum: "", + license_text: "Copyright \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 ", url: "https://github.com/morhetz/gruvbox", diff --git a/styles/src/themes/gruvbox-dark-hard.ts b/styles/src/themes/gruvbox-dark-hard.ts index c734555250..a6e20e1020 100644 --- a/styles/src/themes/gruvbox-dark-hard.ts +++ b/styles/src/themes/gruvbox-dark-hard.ts @@ -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 } \ No newline at end of file diff --git a/styles/src/themes/gruvbox-dark-soft.ts b/styles/src/themes/gruvbox-dark-soft.ts index 6f43c3d69f..7eaefaa99a 100644 --- a/styles/src/themes/gruvbox-dark-soft.ts +++ b/styles/src/themes/gruvbox-dark-soft.ts @@ -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 } \ No newline at end of file diff --git a/styles/src/themes/gruvbox-dark.ts b/styles/src/themes/gruvbox-dark.ts index ded3381517..ea21933714 100644 --- a/styles/src/themes/gruvbox-dark.ts +++ b/styles/src/themes/gruvbox-dark.ts @@ -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 } \ No newline at end of file diff --git a/styles/src/themes/gruvbox-light-hard copy.ts b/styles/src/themes/gruvbox-light-hard copy.ts deleted file mode 100644 index 4925eb74ee..0000000000 --- a/styles/src/themes/gruvbox-light-hard copy.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { lightHard as light, meta } from "./gruvbox-common"; - -export { light, meta } \ No newline at end of file diff --git a/styles/src/themes/gruvbox-light-hard.ts b/styles/src/themes/gruvbox-light-hard.ts new file mode 100644 index 0000000000..b0f42ca4b7 --- /dev/null +++ b/styles/src/themes/gruvbox-light-hard.ts @@ -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 } \ No newline at end of file diff --git a/styles/src/themes/gruvbox-light-soft.ts b/styles/src/themes/gruvbox-light-soft.ts index 1a38bb78f1..6743d29232 100644 --- a/styles/src/themes/gruvbox-light-soft.ts +++ b/styles/src/themes/gruvbox-light-soft.ts @@ -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 } \ No newline at end of file diff --git a/styles/src/themes/gruvbox-light.ts b/styles/src/themes/gruvbox-light.ts index acb50a8d31..f64778d856 100644 --- a/styles/src/themes/gruvbox-light.ts +++ b/styles/src/themes/gruvbox-light.ts @@ -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 } \ No newline at end of file diff --git a/styles/src/themes/one-dark.ts b/styles/src/themes/one-dark.ts index 48305e5bd9..e8e4089d4c 100644 --- a/styles/src/themes/one-dark.ts +++ b/styles/src/themes/one-dark.ts @@ -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", } diff --git a/styles/src/themes/one-light.ts b/styles/src/themes/one-light.ts index 267345ed4e..534e4c1648 100644 --- a/styles/src/themes/one-light.ts +++ b/styles/src/themes/one-light.ts @@ -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", } diff --git a/styles/src/themes/rose-pine-dawn.ts b/styles/src/themes/rose-pine-dawn.ts index bcd4e268bd..7f7d52079d 100644 --- a/styles/src/themes/rose-pine-dawn.ts +++ b/styles/src/themes/rose-pine-dawn.ts @@ -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", } diff --git a/styles/src/themes/rose-pine-moon.ts b/styles/src/themes/rose-pine-moon.ts index d40ea390ac..a89d44487e 100644 --- a/styles/src/themes/rose-pine-moon.ts +++ b/styles/src/themes/rose-pine-moon.ts @@ -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", } diff --git a/styles/src/themes/rose-pine.ts b/styles/src/themes/rose-pine.ts index 7b61ab56e7..87c9d34ffe 100644 --- a/styles/src/themes/rose-pine.ts +++ b/styles/src/themes/rose-pine.ts @@ -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", } diff --git a/styles/src/themes/sandcastle.ts b/styles/src/themes/sandcastle.ts index b38416a966..86179db3db 100644 --- a/styles/src/themes/sandcastle.ts +++ b/styles/src/themes/sandcastle.ts @@ -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", } diff --git a/styles/src/themes/solarized.ts b/styles/src/themes/solarized.ts index 51baeed564..42306f68c3 100644 --- a/styles/src/themes/solarized.ts +++ b/styles/src/themes/solarized.ts @@ -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", } diff --git a/styles/src/themes/summercamp.ts b/styles/src/themes/summercamp.ts index 1114f496c2..e8d1bd40b2 100644 --- a/styles/src/themes/summercamp.ts +++ b/styles/src/themes/summercamp.ts @@ -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", + } }, }