Fix failing license

Mikayla Maki and nate created

co-authored-by: nate <nate@zed.dev>

Change summary

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          |  2 
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, 132 insertions(+), 83 deletions(-)

Detailed changes

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
+                })
+        }
     }
 }
 

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",
 }

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/",
 }

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/",
 }

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
 }

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 }

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 }

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 }

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 }

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 }

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 }

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",
 }

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",
 }

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",
 }

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",
 }

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",
 }

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",
 }

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",
 }

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",
+        }
     },
 }