build: refactor & use handlebars for generate templating (#343)

This commit is contained in:
winston authored and GitHub committed 2023-11-20 02:16:54 +01:00
1 parent b1f864c1c8
commit f48eba6354
23 files changed
+681 -408

No files matched your search

+3 -3
View File
@@ -1,10 +1,10 @@
import { exists } from "std/fs/mod.ts";
import { exists } from "std/fs/exists.ts";
import { join, relative } from "std/path/mod.ts";
import core from "@actions/core";
import { REPO_ROOT } from "@/deps.ts";
import { log } from "./logger.ts";
import chalk from "chalk";
import * as color from "std/fmt/colors.ts";
const requiredFiles = [
"catppuccin.user.css",
@@ -39,7 +39,7 @@ export const checkForMissingFiles = async () => {
.write();
} else {
missingFiles.map((f) => {
log(chalk.red(`Missing file:`) + ` ${f}`, { file: f }, "error");
log(color.red(`Missing file:`) + ` ${f}`, { file: f }, "error");
});
}
+9 -9
View File
@@ -1,5 +1,5 @@
import { sprintf } from "std/fmt/printf.ts";
import chalk from "chalk";
import * as color from "std/fmt/colors.ts";
import core from "@actions/core";
export type LoggerProps = core.AnnotationProperties & { content?: string };
@@ -15,7 +15,7 @@ const pretty_print = (
const lines = (props.content ?? "").split("\n");
const error = [
chalk[severity === "error" ? "red" : "yellow"](severity),
color[severity === "error" ? "red" : "yellow"](severity),
message,
].join(" ");
@@ -24,7 +24,7 @@ const pretty_print = (
const endCol = (props.endColumn ?? Infinity) - 1;
if (i >= startCol && i <= endCol) {
return chalk[severity === "error" ? "red" : "yellow"](char);
return color[severity === "error" ? "red" : "yellow"](char);
} else {
return char;
}
@@ -33,7 +33,7 @@ const pretty_print = (
const pad = startLine.toString().length;
console.log(
[
chalk.underline(
color.underline(
sprintf(
"%s%s%d%s%d",
file,
@@ -46,15 +46,15 @@ const pretty_print = (
sprintf(
"%*s│ %s",
pad,
chalk.dim(startLine - 1),
chalk.dim(lines[startLine - 2]),
color.dim(String(startLine - 1)),
color.dim(lines[startLine - 2]),
),
sprintf("%*s│ %s", pad, chalk.bold(startLine), line),
sprintf("%*s│ %s", pad, color.bold(String(startLine)), line),
sprintf(
"%*s│ %s",
pad,
chalk.dim(startLine + 1),
chalk.dim(lines[startLine]),
color.dim(String(startLine + 1)),
color.dim(lines[startLine]),
),
sprintf("%*s╰─► %s", pad, "", error),
undefined,
+1 -1
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env -S deno run -A
import { walk } from "std/fs/mod.ts";
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";
+6 -6
View File
@@ -1,9 +1,9 @@
import chalk from "chalk";
// @deno-types="../usercss-meta.d.ts";
// @deno-types="@/types/usercss-meta.d.ts";
import usercssMeta from "usercss-meta";
import { log } from "./logger.ts";
import * as color from "std/fmt/colors.ts";
import { sprintf } from "std/fmt/printf.ts";
import type { WalkEntry } from "std/fs/mod.ts";
import type { WalkEntry } from "std/fs/walk.ts";
import { relative } from "std/path/mod.ts";
import { REPO_ROOT } from "@/deps.ts";
@@ -39,9 +39,9 @@ export const verifyMetadata = (
const message = sprintf(
"Metadata %s should be %s but is %s",
chalk.bold(k),
chalk.green(v),
chalk.red(defacto),
color.bold(k),
color.green(v),
color.red(String(defacto)),
);
log(message, {
+3 -3
View File
@@ -1,6 +1,6 @@
import { deepMerge } from "std/collections/mod.ts";
import { deepMerge } from "std/collections/deep_merge.ts";
import chalk from "chalk";
import * as color from "std/fmt/colors.ts";
import stylelint from "npm:stylelint";
import stylelintConfigStandard from "npm:stylelint-config-standard";
import stylelintConfigRecommended from "npm:stylelint-config-recommended";
@@ -184,7 +184,7 @@ export const lint = (entry: WalkEntry, content: string, fix: boolean) => {
// some cleanup for fancier logging, dims the rule name
const message = warning.text?.replace(
new RegExp(`\\(?${warning.rule}\\)?`),
chalk.dim(`(${warning.rule})`),
color.dim(`(${warning.rule})`),
) ?? "unspecified stylelint error";
log(message, {