Skip to content

Commit

Permalink
y
Browse files Browse the repository at this point in the history
  • Loading branch information
Delusoire committed Aug 18, 2024
1 parent e6a226c commit da16847
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
6 changes: 3 additions & 3 deletions scripts/build-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { Builder, readJSON, Transpiler } from "jsr:@delu/tailor";

export type ClassmapInfo = {
classmap: any;
version: string;
version: number;
timestamp: number;
};

export default async function (classmapInfos: ClassmapInfo[], inputDirs: string[]) {
for (const inputDir of inputDirs) {
const metadata = await readJSON<any>(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}`;
Expand Down
1 change: 0 additions & 1 deletion scripts/classmap-fetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import path from "node:path";

import { genClassMapDts } from "jsr:@delu/tailor";
Expand Down
18 changes: 8 additions & 10 deletions scripts/classmap-info.ts
Original file line number Diff line number Diff line change
@@ -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\/(?<owner>[^\/]+)\/(?<repo>[^\/]+)\/(?<branch>[^\/]+)\/(?<path>.+)$/);
const urlMatch = rawUrl.match(
/^https:\/\/raw\.githubusercontent\.com\/(?<owner>[^\/]+)\/(?<repo>[^\/]+)\/(?<branch>[^\/]+)\/(?<path>.+)$/,
);
if (!urlMatch) {
throw new Error(`Invalid raw url: ${rawUrl}`);
}
Expand All @@ -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),
};
}

Expand Down

0 comments on commit da16847

Please sign in to comment.