From da16847f4fdb6aceda278c33e2d43aa32543d513 Mon Sep 17 00:00:00 2001 From: Delusoire Date: Sun, 18 Aug 2024 22:39:22 +0100 Subject: [PATCH] y --- scripts/build-shared.ts | 6 +++--- scripts/classmap-fetch.ts | 1 - scripts/classmap-info.ts | 18 ++++++++---------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/scripts/build-shared.ts b/scripts/build-shared.ts index 46eb492..1482ab9 100644 --- a/scripts/build-shared.ts +++ b/scripts/build-shared.ts @@ -6,7 +6,7 @@ import { Builder, readJSON, Transpiler } from "jsr:@delu/tailor"; export type ClassmapInfo = { classmap: any; - version: string; + version: number; timestamp: number; }; @@ -14,9 +14,9 @@ export default async function (classmapInfos: ClassmapInfo[], inputDirs: string[ for (const inputDir of inputDirs) { const metadata = await readJSON(path.join(inputDir, "metadata.json")); - for (const { classmap, version: spVersion, timestamp } of classmapInfos) { + for (const { classmap, version, timestamp } of classmapInfos) { const m = Object.assign({}, metadata); - m.version += `+sp-${spVersion}-cm-${timestamp.toString(16)}`; + m.version += `+cm-${version}-${timestamp.toString(36)}`; const identifier = `${m.name}`; const fingerprint = `${m.name}@${m.version}`; diff --git a/scripts/classmap-fetch.ts b/scripts/classmap-fetch.ts index ceca1ab..cf222de 100644 --- a/scripts/classmap-fetch.ts +++ b/scripts/classmap-fetch.ts @@ -1,4 +1,3 @@ - import path from "node:path"; import { genClassMapDts } from "jsr:@delu/tailor"; diff --git a/scripts/classmap-info.ts b/scripts/classmap-info.ts index 8f476d8..b100299 100644 --- a/scripts/classmap-info.ts +++ b/scripts/classmap-info.ts @@ -1,7 +1,10 @@ -export const GH_RAW_CLASSMAP_URL = "https://raw.githubusercontent.com/spicetify/classmaps/main/1020040/classmap-1906ea8d2e9.json"; +export const GH_RAW_CLASSMAP_URL = + "https://raw.githubusercontent.com/spicetify/classmaps/main/1020040/classmap-1906ea8d2e9.json"; async function parseGhRawUrl(rawUrl: string) { - const urlMatch = rawUrl.match(/^https:\/\/raw\.githubusercontent\.com\/(?[^\/]+)\/(?[^\/]+)\/(?[^\/]+)\/(?.+)$/); + const urlMatch = rawUrl.match( + /^https:\/\/raw\.githubusercontent\.com\/(?[^\/]+)\/(?[^\/]+)\/(?[^\/]+)\/(?.+)$/, + ); if (!urlMatch) { throw new Error(`Invalid raw url: ${rawUrl}`); } @@ -12,16 +15,11 @@ async function parseGhRawUrl(rawUrl: string) { throw new Error(`Invalid path: ${path}`); } const { version, timestamp } = pathMatch.groups!; - const M = Number(version[0]); - const m = Number(version.slice(1, 3)); - const p = Number(version.slice(3, 7)); - const versionSemver = `${M}.${m}.${p}`; - const timestampDecimal = Number.parseInt(timestamp, 16); return { - classmap: await fetch(rawUrl).then(res => res.json()), - version: versionSemver, - timestamp: timestampDecimal, + classmap: await fetch(rawUrl).then((res) => res.json()), + version: Number(version), + timestamp: Number.parseInt(timestamp, 16), }; }