refactor(scripts): use deno's std on jsr (#1091)
This commit is contained in:
1 parent
89c3e2a7ef
commit
a801279ae1
18 files changed
+178
-290
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ import userStylesSchema from "@/userstyles.schema.json" with {
|
||||
type: "json",
|
||||
};
|
||||
|
||||
import { join } from "std/path/mod.ts";
|
||||
import { join } from "@std/path";
|
||||
|
||||
const ROOT = import.meta.dirname;
|
||||
if (!ROOT) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { join } from "std/path/mod.ts";
|
||||
import { join } from "@std/path";
|
||||
|
||||
import { REPO_ROOT } from "@/deps.ts";
|
||||
import { updateFile } from "@/generate/utils.ts";
|
||||
import { UserStylesSchema } from "@/types/mod.ts";
|
||||
import { stringify } from "std/yaml/stringify.ts";
|
||||
import { stringify } from "@std/yaml";
|
||||
import { type ColorName, flavors } from "@catppuccin/palette";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env -S deno run -A
|
||||
import { join } from "std/path/mod.ts";
|
||||
import { join } from "@std/path";
|
||||
import { portsSchema, REPO_ROOT, userStylesSchema } from "@/deps.ts";
|
||||
import type { PortsSchema, UserStylesSchema } from "@/types/mod.ts";
|
||||
|
||||
@@ -53,7 +53,7 @@ await syncIssueLabels(userstylesData.userstyles);
|
||||
* Keep `.github/CODEOWNERS` in sync with the userstyle metadata.
|
||||
*/
|
||||
const maintainersCodeOwners = () => {
|
||||
return Object.entries(userstylesData.userstyles)
|
||||
return Object.entries(userstylesData.userstyles!)
|
||||
.filter(([_, { "current-maintainers": currentMaintainers }]) =>
|
||||
currentMaintainers.length > 0
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { join } from "std/path/mod.ts";
|
||||
import { join } from "@std/path";
|
||||
import Handlebars from "handlebars";
|
||||
|
||||
import { REPO_ROOT } from "@/deps.ts";
|
||||
@@ -52,13 +52,15 @@ export const generateMainReadme = async (
|
||||
return {
|
||||
emoji: meta.emoji,
|
||||
name: meta.name,
|
||||
ports: ports.map(({ name, path, "current-maintainers": currentMaintainers }) => {
|
||||
return {
|
||||
name: [name].flat(),
|
||||
maintained: currentMaintainers.length > 0,
|
||||
path,
|
||||
};
|
||||
}),
|
||||
ports: ports.map(
|
||||
({ name, path, "current-maintainers": currentMaintainers }) => {
|
||||
return {
|
||||
name: [name].flat(),
|
||||
maintained: currentMaintainers.length > 0,
|
||||
path,
|
||||
};
|
||||
},
|
||||
),
|
||||
};
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UserStylesSchema } from "@/types/mod.ts";
|
||||
import { join } from "std/path/mod.ts";
|
||||
import { join } from "@std/path";
|
||||
import { REPO_ROOT } from "@/deps.ts";
|
||||
import Handlebars from "handlebars";
|
||||
|
||||
@@ -53,21 +53,33 @@ export const generateStyleReadmes = (
|
||||
);
|
||||
const stylesReadmeContent = Deno.readTextFileSync(stylesReadmePath);
|
||||
|
||||
Object.entries(userstyles).map(([slug, { name, readme, "current-maintainers": currentMaintainers, "past-maintainers": pastMaintainers }]) => {
|
||||
console.log(`Generating README for ${slug}`);
|
||||
const readmeContent = Handlebars.compile(stylesReadmeContent)({
|
||||
heading: heading(name, readme["app-link"]),
|
||||
slug,
|
||||
usage: readme.usage,
|
||||
faq: readme.faq,
|
||||
collaborators: {
|
||||
currentMaintainers: extractName(currentMaintainers),
|
||||
pastMaintainers: extractName(pastMaintainers),
|
||||
},
|
||||
});
|
||||
Deno.writeTextFile(
|
||||
join(REPO_ROOT, "styles", slug.toString(), "README.md"),
|
||||
readmeContent,
|
||||
).catch((e) => console.error(e));
|
||||
});
|
||||
Object.entries(userstyles).map(
|
||||
(
|
||||
[
|
||||
slug,
|
||||
{
|
||||
name,
|
||||
readme,
|
||||
"current-maintainers": currentMaintainers,
|
||||
"past-maintainers": pastMaintainers,
|
||||
},
|
||||
],
|
||||
) => {
|
||||
console.log(`Generating README for ${slug}`);
|
||||
const readmeContent = Handlebars.compile(stylesReadmeContent)({
|
||||
heading: heading(name, readme["app-link"]),
|
||||
slug,
|
||||
usage: readme.usage,
|
||||
faq: readme.faq,
|
||||
collaborators: {
|
||||
currentMaintainers: extractName(currentMaintainers),
|
||||
pastMaintainers: extractName(pastMaintainers),
|
||||
},
|
||||
});
|
||||
Deno.writeTextFile(
|
||||
join(REPO_ROOT, "styles", slug.toString(), "README.md"),
|
||||
readmeContent,
|
||||
).catch((e) => console.error(e));
|
||||
},
|
||||
);
|
||||
};
|
||||
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env -S deno run -A
|
||||
import usercssMeta from "usercss-meta";
|
||||
import { ensureDir } from "std/fs/mod.ts";
|
||||
import { walk } from "std/fs/walk.ts";
|
||||
import { join } from "std/path/mod.ts";
|
||||
import { ensureDir, walk } from "@std/fs";
|
||||
import { join } from "@std/path";
|
||||
|
||||
import { REPO_ROOT } from "@/deps.ts";
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { exists } from "std/fs/exists.ts";
|
||||
import { join, relative } from "std/path/mod.ts";
|
||||
import { exists } from "@std/fs";
|
||||
import { join, relative } from "@std/path";
|
||||
import core from "@actions/core";
|
||||
|
||||
import { REPO_ROOT } from "@/deps.ts";
|
||||
import { log } from "@/lint/logger.ts";
|
||||
import * as color from "std/fmt/colors.ts";
|
||||
import * as color from "@std/fmt/colors";
|
||||
|
||||
const requiredFiles = [
|
||||
"catppuccin.user.css",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { sprintf } from "std/fmt/printf.ts";
|
||||
import * as color from "std/fmt/colors.ts";
|
||||
import { sprintf } from "@std/fmt/printf";
|
||||
import * as color from "@std/fmt/colors";
|
||||
import core from "@actions/core";
|
||||
|
||||
export type LoggerProps = core.AnnotationProperties & { content?: string };
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env -S deno run -A
|
||||
import { walk } from "std/fs/walk.ts";
|
||||
import { parse as parseFlags } from "std/flags/mod.ts";
|
||||
import { basename, dirname, join, relative } from "std/path/mod.ts";
|
||||
// @deno-types="npm:@types/less";
|
||||
import { walk } from "@std/fs";
|
||||
import { parseArgs } from "@std/cli";
|
||||
import { basename, dirname, join, relative } from "@std/path";
|
||||
// @ts-types="npm:@types/less";
|
||||
import less from "less";
|
||||
|
||||
import { REPO_ROOT } from "@/deps.ts";
|
||||
@@ -13,8 +13,8 @@ import { lint } from "@/lint/stylelint.ts";
|
||||
import { getUserstylesData } from "@/utils.ts";
|
||||
import stylelintConfig from "../../.stylelintrc.js";
|
||||
|
||||
const flags = parseFlags(Deno.args, { boolean: ["fix"] });
|
||||
const subDir = flags._[0]?.toString() ?? "";
|
||||
const args = parseArgs(Deno.args, { boolean: ["fix"] });
|
||||
const subDir = args._[0]?.toString() ?? "";
|
||||
const stylesheets = walk(join(REPO_ROOT, "styles", subDir), {
|
||||
includeFiles: true,
|
||||
includeDirs: false,
|
||||
@@ -37,7 +37,7 @@ for await (const entry of stylesheets) {
|
||||
content,
|
||||
dir,
|
||||
userstyles,
|
||||
flags.fix,
|
||||
args.fix,
|
||||
);
|
||||
|
||||
content = fixed;
|
||||
@@ -58,7 +58,7 @@ for await (const entry of stylesheets) {
|
||||
);
|
||||
|
||||
// Lint with Stylelint.
|
||||
await lint(entry, content, flags.fix, stylelintConfig).catch(() =>
|
||||
await lint(entry, content, args.fix, stylelintConfig).catch(() =>
|
||||
failed = true
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// @deno-types="@/types/usercss-meta.d.ts";
|
||||
// @ts-types="@/types/usercss-meta.d.ts";
|
||||
import usercssMeta from "usercss-meta";
|
||||
import * as color from "std/fmt/colors.ts";
|
||||
import { sprintf } from "std/fmt/printf.ts";
|
||||
import type { WalkEntry } from "std/fs/walk.ts";
|
||||
import { join, relative } from "std/path/mod.ts";
|
||||
import * as color from "@std/fmt/colors";
|
||||
import { sprintf } from "@std/fmt/printf";
|
||||
import type { WalkEntry } from "@std/fs";
|
||||
import { join, relative } from "@std/path";
|
||||
|
||||
import { REPO_ROOT } from "@/deps.ts";
|
||||
import { log } from "@/lint/logger.ts";
|
||||
@@ -47,7 +47,10 @@ export const verifyMetadata = async (
|
||||
.findIndex((line) => line.includes(key)) + 1;
|
||||
|
||||
const message = current === undefined
|
||||
? sprintf("Metadata `%s` should not be undefined", color.bold(key))
|
||||
? sprintf(
|
||||
"Metadata `%s` should not be undefined",
|
||||
color.bold(key),
|
||||
)
|
||||
: sprintf(
|
||||
'Metadata `%s` should be "%s" but is "%s"',
|
||||
color.bold(key),
|
||||
@@ -63,9 +66,10 @@ export const verifyMetadata = async (
|
||||
}
|
||||
}
|
||||
|
||||
const template =
|
||||
(await Deno.readTextFile(join(REPO_ROOT, "template/catppuccin.user.css")))
|
||||
.split("\n");
|
||||
const template = (await Deno.readTextFile(
|
||||
join(REPO_ROOT, "template/catppuccin.user.css"),
|
||||
))
|
||||
.split("\n");
|
||||
|
||||
for (const variable of ["darkFlavor", "lightFlavor", "accentColor"]) {
|
||||
const declaration = `@var select ${variable}`;
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ const ruleFunction = (primary, _secondary, context) => {
|
||||
"mergePaths",
|
||||
"removeComments",
|
||||
"removeUselessDefs",
|
||||
"removeScriptElement"
|
||||
"removeScriptElement",
|
||||
],
|
||||
}).data;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as color from "std/fmt/colors.ts";
|
||||
import type { WalkEntry } from "std/fs/walk.ts";
|
||||
import { relative } from "std/path/mod.ts";
|
||||
import * as color from "@std/fmt/colors";
|
||||
import type { WalkEntry } from "@std/fs";
|
||||
import { relative } from "@std/path";
|
||||
|
||||
import "postcss-less";
|
||||
import stylelint from "stylelint";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env -S deno run -A
|
||||
import * as assert from "std/assert/mod.ts";
|
||||
import * as assert from "@std/assert";
|
||||
import { Octokit } from "@octokit/rest";
|
||||
|
||||
import type { UserStylesSchema } from "@/types/mod.ts";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S deno run -A
|
||||
// deno-lint-ignore-file no-explicit-any
|
||||
import { join } from "std/path/mod.ts";
|
||||
import { join } from "@std/path";
|
||||
import { compile, Options } from "json-schema-to-typescript";
|
||||
import { REPO_ROOT, userStylesSchema } from "@/deps.ts";
|
||||
|
||||
|
||||
+4
-5
@@ -1,13 +1,12 @@
|
||||
import Ajv, { Schema } from "ajv";
|
||||
import { parse } from "std/yaml/parse.ts";
|
||||
import { join } from "std/path/join.ts";
|
||||
import { parse } from "@std/yaml";
|
||||
import { join } from "@std/path";
|
||||
import { SetRequired } from "type-fest/source/set-required.d.ts";
|
||||
|
||||
import { REPO_ROOT, userStylesSchema } from "@/deps.ts";
|
||||
import { UserstylesSchema } from "@/types/userstyles.d.ts";
|
||||
import { YAMLError } from "std/yaml/_error.ts";
|
||||
import { log } from "@/lint/logger.ts";
|
||||
import { sprintf } from "std/fmt/printf.ts";
|
||||
import { sprintf } from "@std/fmt/printf";
|
||||
|
||||
/**
|
||||
* @param content A string of YAML content
|
||||
@@ -64,7 +63,7 @@ export const getUserstylesData = (): Userstyles => {
|
||||
|
||||
return data as Userstyles;
|
||||
} catch (err) {
|
||||
if (err instanceof YAMLError) {
|
||||
if (err.name === "YAMLError") {
|
||||
const groups =
|
||||
/(?<message>.*) at line (?<line>\d+), column (?<column>\d+):[\S\s]*/
|
||||
.exec(err.message)?.groups;
|
||||
|
||||
Reference in new issue
Block a user