diff --git a/.prettierignore b/.prettierignore index 3a574777ae..da4e7973bb 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,4 +2,6 @@ /scripts/ # auto-generated files +/.github/ISSUE_TEMPLATE/userstyle.yml +/.github/*.yml /styles/**/*.md diff --git a/deno.json b/deno.json index f3a52b271a..6a4141c8e7 100644 --- a/deno.json +++ b/deno.json @@ -5,16 +5,16 @@ "catppuccin-repo/": "https://raw.githubusercontent.com/catppuccin/catppuccin/91d6b5433730103c504dcf43583b594e418ee7c1/", "@actions/core": "npm:@actions/core@1.10.1", "@octokit/rest": "npm:@octokit/rest@20.0.2", - "usercss-meta": "npm:usercss-meta@0.12.0", "ajv": "npm:ajv@8.12.0", - "chalk": "npm:chalk@5.3.0", - "less": "npm:less@4.2.0" + "handlebars": "npm:handlebars@4.7.8", + "less": "npm:less@4.2.0", + "usercss-meta": "npm:usercss-meta@0.12.0" }, "tasks": { "ci:generate": "deno run -A ./scripts/generate/main.ts", "ci:sync-maintainers": "deno run -A ./scripts/sync-maintainers/main.ts", "lint": "deno run -A ./scripts/lint/main.ts", "lint:fix": "deno task lint --fix", - "update-types": "deno run -A 'npm:json-schema-to-typescript' ./scripts/userstyles.schema.json ./scripts/types/userstyles.d.ts" + "update-types": "deno run -A ./scripts/update-types.ts" } } diff --git a/deno.lock b/deno.lock index b638cf7d09..1cb61ec22a 100644 --- a/deno.lock +++ b/deno.lock @@ -6,7 +6,8 @@ "npm:@octokit/rest@20.0.2": "npm:@octokit/rest@20.0.2_@octokit+core@5.0.1", "npm:@types/less": "npm:@types/less@3.0.6", "npm:ajv@8.12.0": "npm:ajv@8.12.0", - "npm:chalk@5.3.0": "npm:chalk@5.3.0", + "npm:handlebars@4.7.8": "npm:handlebars@4.7.8", + "npm:json-schema-to-typescript": "npm:json-schema-to-typescript@13.1.1_glob@7.2.3", "npm:less@4.2.0": "npm:less@4.2.0", "npm:postcss-less": "npm:postcss-less@6.0.0_postcss@8.4.31", "npm:stylelint": "npm:stylelint@15.11.0_@csstools+css-tokenizer@2.2.1_@csstools+css-parser-algorithms@2.3.2__@csstools+css-tokenizer@2.2.1_postcss-selector-parser@6.0.13_postcss@8.4.31", @@ -48,6 +49,15 @@ "js-tokens": "js-tokens@4.0.0" } }, + "@bcherny/json-schema-ref-parser@10.0.5-fork": { + "integrity": "sha512-E/jKbPoca1tfUPj3iSbitDZTGnq6FUFjkH6L8U2oDwSuwK1WhnnVtCG7oFOTg/DDnyoXbQYUiUiGOibHqaGVnw==", + "dependencies": { + "@jsdevtools/ono": "@jsdevtools/ono@7.1.3", + "@types/json-schema": "@types/json-schema@7.0.15", + "call-me-maybe": "call-me-maybe@1.0.2", + "js-yaml": "js-yaml@4.1.0" + } + }, "@csstools/css-parser-algorithms@2.3.2_@csstools+css-tokenizer@2.2.1": { "integrity": "sha512-sLYGdAdEY2x7TSw9FtmdaTrh2wFtRJO5VMbBrA8tEqEod7GEggFmxTSK9XqExib3yMuYNcvcTdCZIP6ukdjAIA==", "dependencies": { @@ -75,6 +85,10 @@ "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==", "dependencies": {} }, + "@jsdevtools/ono@7.1.3": { + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==", + "dependencies": {} + }, "@nodelib/fs.scandir@2.1.5": { "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dependencies": { @@ -182,18 +196,45 @@ "@octokit/openapi-types": "@octokit/openapi-types@19.0.2" } }, + "@types/glob@7.2.0": { + "integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==", + "dependencies": { + "@types/minimatch": "@types/minimatch@5.1.2", + "@types/node": "@types/node@18.16.19" + } + }, + "@types/json-schema@7.0.15": { + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dependencies": {} + }, "@types/less@3.0.6": { "integrity": "sha512-PecSzorDGdabF57OBeQO/xFbAkYWo88g4Xvnsx7LRwqLC17I7OoKtA3bQB9uXkY6UkMWCOsA8HSVpaoitscdXw==", "dependencies": {} }, + "@types/lodash@4.14.201": { + "integrity": "sha512-y9euML0cim1JrykNxADLfaG0FgD1g/yTHwUs/Jg9ZIU7WKj2/4IW9Lbb1WZbvck78W/lfGXFfe+u2EGfIJXdLQ==", + "dependencies": {} + }, + "@types/minimatch@5.1.2": { + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", + "dependencies": {} + }, "@types/minimist@1.2.5": { "integrity": "sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==", "dependencies": {} }, + "@types/node@18.16.19": { + "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", + "dependencies": {} + }, "@types/normalize-package-data@2.4.4": { "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==", "dependencies": {} }, + "@types/prettier@2.7.3": { + "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", + "dependencies": {} + }, "ajv@8.12.0": { "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "dependencies": { @@ -219,6 +260,10 @@ "color-convert": "color-convert@2.0.1" } }, + "any-promise@1.3.0": { + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dependencies": {} + }, "argparse@2.0.1": { "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dependencies": {} @@ -260,6 +305,10 @@ "fill-range": "fill-range@7.0.1" } }, + "call-me-maybe@1.0.2": { + "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==", + "dependencies": {} + }, "callsites@3.1.0": { "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dependencies": {} @@ -285,9 +334,15 @@ "supports-color": "supports-color@5.5.0" } }, - "chalk@5.3.0": { - "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", - "dependencies": {} + "cli-color@2.0.3": { + "integrity": "sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==", + "dependencies": { + "d": "d@1.0.1", + "es5-ext": "es5-ext@0.10.62", + "es6-iterator": "es6-iterator@2.0.3", + "memoizee": "memoizee@0.4.15", + "timers-ext": "timers-ext@0.1.7" + } }, "color-convert@1.9.3": { "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", @@ -347,6 +402,13 @@ "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", "dependencies": {} }, + "d@1.0.1": { + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dependencies": { + "es5-ext": "es5-ext@0.10.62", + "type": "type@1.2.0" + } + }, "debug@3.2.7": { "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "dependencies": { @@ -400,10 +462,55 @@ "is-arrayish": "is-arrayish@0.2.1" } }, + "es5-ext@0.10.62": { + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "dependencies": { + "es6-iterator": "es6-iterator@2.0.3", + "es6-symbol": "es6-symbol@3.1.3", + "next-tick": "next-tick@1.1.0" + } + }, + "es6-iterator@2.0.3": { + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "dependencies": { + "d": "d@1.0.1", + "es5-ext": "es5-ext@0.10.62", + "es6-symbol": "es6-symbol@3.1.3" + } + }, + "es6-symbol@3.1.3": { + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "dependencies": { + "d": "d@1.0.1", + "ext": "ext@1.7.0" + } + }, + "es6-weak-map@2.0.3": { + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "dependencies": { + "d": "d@1.0.1", + "es5-ext": "es5-ext@0.10.62", + "es6-iterator": "es6-iterator@2.0.3", + "es6-symbol": "es6-symbol@3.1.3" + } + }, "escape-string-regexp@1.0.5": { "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dependencies": {} }, + "event-emitter@0.3.5": { + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "dependencies": { + "d": "d@1.0.1", + "es5-ext": "es5-ext@0.10.62" + } + }, + "ext@1.7.0": { + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "dependencies": { + "type": "type@2.7.2" + } + }, "fast-deep-equal@3.1.3": { "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dependencies": {} @@ -467,12 +574,23 @@ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", "dependencies": {} }, + "get-stdin@8.0.0": { + "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", + "dependencies": {} + }, "glob-parent@5.1.2": { "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dependencies": { "is-glob": "is-glob@4.0.3" } }, + "glob-promise@4.2.2_glob@7.2.3": { + "integrity": "sha512-xcUzJ8NWN5bktoTIX7eOclO1Npxd/dyVqUJxlLIDasT4C7KZyqlPIwkdJ0Ypiy3p2ZKahTjK4M9uC3sNSfNMzw==", + "dependencies": { + "@types/glob": "@types/glob@7.2.0", + "glob": "glob@7.2.3" + } + }, "glob@7.2.3": { "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dependencies": { @@ -517,6 +635,16 @@ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dependencies": {} }, + "handlebars@4.7.8": { + "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==", + "dependencies": { + "minimist": "minimist@1.2.8", + "neo-async": "neo-async@2.6.2", + "source-map": "source-map@0.6.1", + "uglify-js": "uglify-js@3.17.4", + "wordwrap": "wordwrap@1.0.0" + } + }, "hard-rejection@2.1.0": { "integrity": "sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==", "dependencies": {} @@ -629,6 +757,10 @@ "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", "dependencies": {} }, + "is-promise@2.2.2": { + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==", + "dependencies": {} + }, "is-what@3.14.1": { "integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==", "dependencies": {} @@ -655,6 +787,25 @@ "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", "dependencies": {} }, + "json-schema-to-typescript@13.1.1_glob@7.2.3": { + "integrity": "sha512-F3CYhtA7F3yPbb8vF7sFchk/2dnr1/yTKf8RcvoNpjnh67ZS/ZMH1ElLt5KHAtf2/bymiejLQQszszPWEeTdSw==", + "dependencies": { + "@bcherny/json-schema-ref-parser": "@bcherny/json-schema-ref-parser@10.0.5-fork", + "@types/json-schema": "@types/json-schema@7.0.15", + "@types/lodash": "@types/lodash@4.14.201", + "@types/prettier": "@types/prettier@2.7.3", + "cli-color": "cli-color@2.0.3", + "get-stdin": "get-stdin@8.0.0", + "glob": "glob@7.2.3", + "glob-promise": "glob-promise@4.2.2_glob@7.2.3", + "is-glob": "is-glob@4.0.3", + "lodash": "lodash@4.17.21", + "minimist": "minimist@1.2.8", + "mkdirp": "mkdirp@1.0.4", + "mz": "mz@2.7.0", + "prettier": "prettier@2.8.8" + } + }, "json-schema-traverse@1.0.0": { "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "dependencies": {} @@ -702,12 +853,22 @@ "integrity": "sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==", "dependencies": {} }, + "lodash@4.17.21": { + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dependencies": {} + }, "lru-cache@6.0.0": { "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dependencies": { "yallist": "yallist@4.0.0" } }, + "lru-queue@0.1.0": { + "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==", + "dependencies": { + "es5-ext": "es5-ext@0.10.62" + } + }, "make-dir@2.1.0": { "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", "dependencies": { @@ -731,6 +892,19 @@ "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", "dependencies": {} }, + "memoizee@0.4.15": { + "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", + "dependencies": { + "d": "d@1.0.1", + "es5-ext": "es5-ext@0.10.62", + "es6-weak-map": "es6-weak-map@2.0.3", + "event-emitter": "event-emitter@0.3.5", + "is-promise": "is-promise@2.2.2", + "lru-queue": "lru-queue@0.1.0", + "next-tick": "next-tick@1.1.0", + "timers-ext": "timers-ext@0.1.7" + } + }, "meow@10.1.5": { "integrity": "sha512-/d+PQ4GKmGvM9Bee/DPa8z3mXs/pkvJE2KEThngVNOqtmljC6K7NMPxtc2JeZYTmpWb9k/TmxjeL18ez3h7vCw==", "dependencies": { @@ -781,10 +955,26 @@ "kind-of": "kind-of@6.0.3" } }, + "minimist@1.2.8": { + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dependencies": {} + }, + "mkdirp@1.0.4": { + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dependencies": {} + }, "ms@2.1.2": { "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dependencies": {} }, + "mz@2.7.0": { + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dependencies": { + "any-promise": "any-promise@1.3.0", + "object-assign": "object-assign@4.1.1", + "thenify-all": "thenify-all@1.6.0" + } + }, "nanoid@3.3.7": { "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", "dependencies": {} @@ -797,6 +987,14 @@ "sax": "sax@1.3.0" } }, + "neo-async@2.6.2": { + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", + "dependencies": {} + }, + "next-tick@1.1.0": { + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==", + "dependencies": {} + }, "normalize-package-data@3.0.3": { "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==", "dependencies": { @@ -810,6 +1008,10 @@ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dependencies": {} }, + "object-assign@4.1.1": { + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dependencies": {} + }, "once@1.4.0": { "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dependencies": { @@ -906,6 +1108,10 @@ "source-map-js": "source-map-js@1.0.2" } }, + "prettier@2.8.8": { + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dependencies": {} + }, "prr@1.0.1": { "integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==", "dependencies": {} @@ -1153,6 +1359,25 @@ "strip-ansi": "strip-ansi@6.0.1" } }, + "thenify-all@1.6.0": { + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dependencies": { + "thenify": "thenify@3.3.1" + } + }, + "thenify@3.3.1": { + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dependencies": { + "any-promise": "any-promise@1.3.0" + } + }, + "timers-ext@0.1.7": { + "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", + "dependencies": { + "es5-ext": "es5-ext@0.10.62", + "next-tick": "next-tick@1.1.0" + } + }, "to-regex-range@5.0.1": { "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dependencies": { @@ -1175,6 +1400,18 @@ "integrity": "sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==", "dependencies": {} }, + "type@1.2.0": { + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==", + "dependencies": {} + }, + "type@2.7.2": { + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==", + "dependencies": {} + }, + "uglify-js@3.17.4": { + "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", + "dependencies": {} + }, "undici@5.27.2": { "integrity": "sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==", "dependencies": { @@ -1216,6 +1453,10 @@ "isexe": "isexe@2.0.0" } }, + "wordwrap@1.0.0": { + "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", + "dependencies": {} + }, "wrappy@1.0.2": { "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dependencies": {} @@ -1284,74 +1525,13 @@ "https://deno.land/std@0.206.0/assert/mod.ts": "37c49a26aae2b254bbe25723434dc28cd7532e444cf0b481a97c045d110ec085", "https://deno.land/std@0.206.0/assert/unimplemented.ts": "d56fbeecb1f108331a380f72e3e010a1f161baa6956fd0f7cf3e095ae1a4c75a", "https://deno.land/std@0.206.0/assert/unreachable.ts": "4600dc0baf7d9c15a7f7d234f00c23bca8f3eba8b140286aaca7aa998cf9a536", - "https://deno.land/std@0.206.0/collections/_unstable_binary_search_node.ts": "8d99dd95901d73a0edbe105826ef7ce0e1111ce184d2d0410dbfda172c9ebf35", - "https://deno.land/std@0.206.0/collections/_unstable_red_black_node.ts": "62eb878fff714fdb4eb2e16165336618c443b2a09a904fd42c4ea895dadfadc3", "https://deno.land/std@0.206.0/collections/_utils.ts": "5114abc026ddef71207a79609b984614e66a63a4bda17d819d56b0e72c51527e", - "https://deno.land/std@0.206.0/collections/aggregate_groups.ts": "2ed1698695e7b4877afa2281ad10ce3ce67395aa7479e98cc2ebb751add1c4e9", - "https://deno.land/std@0.206.0/collections/associate_by.ts": "64869182eeed3be9222137d071224ac6a01bcc3c5236610306f99e3e3107ec47", - "https://deno.land/std@0.206.0/collections/associate_with.ts": "cf9735d7b4d345275fd3b7420eaba9726a2844e847f2d9e4be9f103f6f3e2c8b", - "https://deno.land/std@0.206.0/collections/binary_heap.ts": "5cba2b4b79aa42c775e4e881a5726f40d9f0e3920e69dfde1c92d6c2c6928f8f", - "https://deno.land/std@0.206.0/collections/binary_search_tree.ts": "fb4508db4be63cbde1f4886abbc2482b4212adea89d8e9f608f9671f726cc059", - "https://deno.land/std@0.206.0/collections/chunk.ts": "f82c52a82ad9338018570c42f6de0fb132fcb14914c31a444e360ac104d7b55b", "https://deno.land/std@0.206.0/collections/deep_merge.ts": "9db788ba56cb05b65c77166b789e58e125dff159b7f41bf4d19dc1cba19ecb8b", - "https://deno.land/std@0.206.0/collections/distinct.ts": "01595bd8e608a5e2de8a8631055587e6f01d68861e463eef34f8e295713500b8", - "https://deno.land/std@0.206.0/collections/distinct_by.ts": "3afe11d81eafb30c7c9dbf568d94357f3d88153292c00671b72cd695deae6602", - "https://deno.land/std@0.206.0/collections/drop_last_while.ts": "03dd8c55c362efea4f2738b93f102d7487f68beff7b4e4ed67495046b3fe1e4c", - "https://deno.land/std@0.206.0/collections/drop_while.ts": "74cfa9d6b74b3503d5dc70c8ab96af21e7cb2eaff8b9f11aca2aca403e56aeae", - "https://deno.land/std@0.206.0/collections/filter_entries.ts": "77d3f0b3dddcb43e92fc745dd66d01b4922d0eff2a3e2bd25d9d826889f203d8", - "https://deno.land/std@0.206.0/collections/filter_keys.ts": "a29cfe8730ddb54e9e071ea45e8a82e166c7629d18675652def70c1bf80e2ef6", - "https://deno.land/std@0.206.0/collections/filter_values.ts": "16e1fc456a7969e770ec5b89edf5ac97b295ca534b47c1a83f061b409aad7814", - "https://deno.land/std@0.206.0/collections/find_single.ts": "d941876fbec0c1d8b7f41a52f8c1b03198c5695dfaa8d7a12e7a6317d2e6085b", - "https://deno.land/std@0.206.0/collections/first_not_nullish_of.ts": "08d92c4f9c66ff1b1f64a48fa7c1e557e3e6d43f48a46d53a98c3383041b98ae", - "https://deno.land/std@0.206.0/collections/group_by.ts": "f90f483598b38f0174f946589f3af25b1c3cf89d4f3b14d4f0fbe3aaaca0abdd", - "https://deno.land/std@0.206.0/collections/includes_value.ts": "8284a0b3178465b6565d234c1995117320b248dbcff332f77c5e891a11459e0c", - "https://deno.land/std@0.206.0/collections/intersect.ts": "0b4924e2aceaddd5e55591bd9d648cf75745151795ee8a76beddf4facec77548", - "https://deno.land/std@0.206.0/collections/join_to_string.ts": "a487ccc99dbac988698cf5b7c6cc4bb50eefd1784042d0b958a77af413683fe0", - "https://deno.land/std@0.206.0/collections/map_entries.ts": "282b0e5141fbe73a45903674597fb10ec2b211fab8cbac85874eebd97f522a62", - "https://deno.land/std@0.206.0/collections/map_keys.ts": "3dd2cf3a940f1432628cb0252b919d268e8bb38fe8bcd78153a440909173ae98", - "https://deno.land/std@0.206.0/collections/map_not_nullish.ts": "8793a340ca245664902a309ac02861b9eb01780f7b78aa5ad329da7d95e011ec", - "https://deno.land/std@0.206.0/collections/map_values.ts": "c88f306b2b3ec84043e16ab4e1b062055ab32cf4d68bb1d7447afaafa0a1b3bf", - "https://deno.land/std@0.206.0/collections/max_by.ts": "9d5940986aac51b2e4feaebef9cd8bf6e1eceeee5edcf3303e334b737f99520d", - "https://deno.land/std@0.206.0/collections/max_of.ts": "aa29268f102159364bc296eea9f45b0d4f1b041ae9d0037c3dce1c43e21e30be", - "https://deno.land/std@0.206.0/collections/max_with.ts": "252fe7788b6dfcf30cf8c4138cf9bae006a5d545408064ff520293ff0e2fe304", - "https://deno.land/std@0.206.0/collections/min_by.ts": "0fcf1973e8e309da83070dc22def47f468e410d7da462a294c5513ae2c5d6479", - "https://deno.land/std@0.206.0/collections/min_of.ts": "7f2b64620f4f54b75badddfac17e0a84660457233d0921b4c9d9ab31bd3323a8", - "https://deno.land/std@0.206.0/collections/min_with.ts": "ecca4ba5da922fb4b1be515949c59f287e580166985f2b12ee711f768004b33f", - "https://deno.land/std@0.206.0/collections/mod.ts": "c745508c522ecaf9fe4717850a2c6e1e13fd175847f0ae4d2c99d2033095879c", - "https://deno.land/std@0.206.0/collections/partition.ts": "28336d4af97eb8a2a2c3ec4ce28597e657e724be5969417eb697ff0860b9711c", - "https://deno.land/std@0.206.0/collections/partition_entries.ts": "7a30b99b64a31af8e9d6da24239f7778b1cff9cd2f240f41aa2f535d647d54f9", - "https://deno.land/std@0.206.0/collections/permutations.ts": "3e3a9d7a8cc806a9ce9ae8fb0c7f3d37d884b3c7429fcaca4bc5d177d92d8217", - "https://deno.land/std@0.206.0/collections/reduce_groups.ts": "0cbb29ec3281f457dd1bd653c4420cef0a92544b51f31f5ae047436ff01712a2", - "https://deno.land/std@0.206.0/collections/running_reduce.ts": "e25f165456b946e7689a27e0e7fbb2f53d8189ef7cd0937b903e737bd37bacc6", - "https://deno.land/std@0.206.0/collections/sample.ts": "6330fb6567573b252a2ed9da475e54c4b98ca06e6266d34e5f0392095020c86b", - "https://deno.land/std@0.206.0/collections/sliding_windows.ts": "d1c8d18d86b8f02b407379e8681881880b7e3e173d152c5d8dc89d458031b740", - "https://deno.land/std@0.206.0/collections/sort_by.ts": "1207755af756a5da04bebff39146c93cbe54f7870a5d67cf6922e871d96a01d5", - "https://deno.land/std@0.206.0/collections/sum_of.ts": "76db7f04a66bdfa4911c4a592b868c854c690d6f0f83140c315f70caf742c761", - "https://deno.land/std@0.206.0/collections/take_last_while.ts": "9adcfe94a3dd56fbd55951099a121267aa42d8ccbc8152ed3aa210f86c74ca57", - "https://deno.land/std@0.206.0/collections/take_while.ts": "cd9a494d56e6a0a9c3f1e1123d1370633f0d4c6525ccf8aa3bd00b006742bddf", - "https://deno.land/std@0.206.0/collections/union.ts": "0577babef67dd38dc584accbcf75605318346046fe4ff476f0f6e2a1b1092391", - "https://deno.land/std@0.206.0/collections/unstable_binary_heap.ts": "c009225d9f9d93e9cd963565186b2d6cdf3fb8404b3ca0c94b4f15c85031d5fe", - "https://deno.land/std@0.206.0/collections/unstable_binary_search_tree.ts": "d9b4817c9af5b5ec1051345bc56bc0a88e03fb726b66eb27c0072860c0f44e34", - "https://deno.land/std@0.206.0/collections/unstable_comparators.ts": "fa7f9a44cea1d270098a2a5a6f8bb30c61b595c1b1f983bd67c6297d766adffa", - "https://deno.land/std@0.206.0/collections/unstable_red_black_tree.ts": "740b6baf26fd8d90564641d0ea15c2aba6b16071a2b91c314909d171649f57b4", - "https://deno.land/std@0.206.0/collections/unzip.ts": "3d3469c616b04200ff6a883e0d6dc82cac4c205aa65742e375afb8816be75b35", - "https://deno.land/std@0.206.0/collections/without_all.ts": "1e3cccb1ed0659455b473c0766d9414b7710d8cef48862c899f445178f66b779", - "https://deno.land/std@0.206.0/collections/zip.ts": "d5def5cf3a0a3fa167956b7eb2ebdc3aca63a41f7ebdfac8c0d1c44fa0dd588d", "https://deno.land/std@0.206.0/flags/mod.ts": "0948466fc437f017f00c0b972a422b3dc3317a790bcf326429d23182977eaf9f", "https://deno.land/std@0.206.0/fmt/colors.ts": "c51c4642678eb690dcf5ffee5918b675bf01a33fba82acf303701ae1a4f8c8d9", "https://deno.land/std@0.206.0/fmt/printf.ts": "b4ca7dc4b2323b2614c7d11b3e6dc80442e5d56c33665cdf9b9de0dabb80f9ec", "https://deno.land/std@0.206.0/fs/_util.ts": "fbf57dcdc9f7bc8128d60301eece608246971a7836a3bb1e78da75314f08b978", - "https://deno.land/std@0.206.0/fs/copy.ts": "ca19e4837965914471df38fbd61e16f9e8adfe89f9cffb0c83615c83ea3fc2bf", - "https://deno.land/std@0.206.0/fs/empty_dir.ts": "0b4a2508232446eed232ad1243dd4b0f07ac503a281633ae1324d1528df70964", - "https://deno.land/std@0.206.0/fs/ensure_dir.ts": "dc64c4c75c64721d4e3fb681f1382f803ff3d2868f08563ff923fdd20d071c40", - "https://deno.land/std@0.206.0/fs/ensure_file.ts": "39ac83cc283a20ec2735e956adf5de3e8a3334e0b6820547b5772f71c49ae083", - "https://deno.land/std@0.206.0/fs/ensure_link.ts": "c15e69c48556d78aae31b83e0c0ece04b7b8bc0951412f5b759aceb6fde7f0ac", - "https://deno.land/std@0.206.0/fs/ensure_symlink.ts": "b389c8568f0656d145ac7ece472afe710815cccbb2ebfd19da7978379ae143fe", - "https://deno.land/std@0.206.0/fs/eol.ts": "f1f2eb348a750c34500741987b21d65607f352cf7205f48f4319d417fff42842", "https://deno.land/std@0.206.0/fs/exists.ts": "cb59a853d84871d87acab0e7936a4dac11282957f8e195102c5a7acb42546bb8", - "https://deno.land/std@0.206.0/fs/expand_glob.ts": "4f98c508fc9e40d6311d2f7fd88aaad05235cc506388c22dda315e095305811d", - "https://deno.land/std@0.206.0/fs/mod.ts": "bc3d0acd488cc7b42627044caf47d72019846d459279544e1934418955ba4898", - "https://deno.land/std@0.206.0/fs/move.ts": "b4f8f46730b40c32ea3c0bc8eb0fd0e8139249a698883c7b3756424cf19785c9", "https://deno.land/std@0.206.0/fs/walk.ts": "c1e6b43f72a46e89b630140308bd51a4795d416a416b4cfb7cd4bd1e25946723", "https://deno.land/std@0.206.0/path/_common/assert_path.ts": "061e4d093d4ba5aebceb2c4da3318bfe3289e868570e9d3a8e327d91c2958946", "https://deno.land/std@0.206.0/path/_common/basename.ts": "0d978ff818f339cd3b1d09dc914881f4d15617432ae519c1b8fdc09ff8d3789a", @@ -1374,7 +1554,6 @@ "https://deno.land/std@0.206.0/path/extname.ts": "2da4e2490f3b48b7121d19fb4c91681a5e11bd6bd99df4f6f47d7a71bb6ecdf2", "https://deno.land/std@0.206.0/path/format.ts": "3457530cc85d1b4bab175f9ae73998b34fd456c830d01883169af0681b8894fb", "https://deno.land/std@0.206.0/path/from_file_url.ts": "e7fa233ea1dff9641e8d566153a24d95010110185a6f418dd2e32320926043f8", - "https://deno.land/std@0.206.0/path/glob.ts": "b8333cbb4aaaeb54ca6d6c43e0b69fb13c9481c69ed7a3c64a3d0d9daf2af769", "https://deno.land/std@0.206.0/path/glob_to_regexp.ts": "74d7448c471e293d03f05ccb968df4365fed6aaa508506b6325a8efdc01d8271", "https://deno.land/std@0.206.0/path/is_absolute.ts": "67232b41b860571c5b7537f4954c88d86ae2ba45e883ee37d3dec27b74909d13", "https://deno.land/std@0.206.0/path/is_glob.ts": "567dce5c6656bdedfc6b3ee6c0833e1e4db2b8dff6e62148e94a917f289c06ad", @@ -1456,7 +1635,6 @@ "https://deno.land/std@0.206.0/yaml/_type/timestamp.ts": "706ea80a76a73e48efaeb400ace087da1f927647b53ad6f754f4e06d51af087f", "https://deno.land/std@0.206.0/yaml/_type/undefined.ts": "94a316ca450597ccbc6750cbd79097ad0d5f3a019797eed3c841a040c29540ba", "https://deno.land/std@0.206.0/yaml/_utils.ts": "26b311f0d42a7ce025060bd6320a68b50e52fd24a839581eb31734cd48e20393", - "https://deno.land/std@0.206.0/yaml/mod.ts": "28ecda6652f3e7a7735ee29c247bfbd32a2e2fc5724068e9fd173ec4e59f66f7", "https://deno.land/std@0.206.0/yaml/parse.ts": "1fbbda572bf3fff578b6482c0d8b85097a38de3176bf3ab2ca70c25fb0c960ef", "https://deno.land/std@0.206.0/yaml/schema.ts": "96908b78dc50c340074b93fc1598d5e7e2fe59103f89ff81e5a49b2dedf77a67", "https://deno.land/std@0.206.0/yaml/schema/core.ts": "fa406f18ceedc87a50e28bb90ec7a4c09eebb337f94ef17468349794fa828639", @@ -1467,6 +1645,12 @@ "https://deno.land/std@0.206.0/yaml/schema/mod.ts": "4472e827bab5025e92bc2eb2eeefa70ecbefc64b2799b765c69af84822efef32", "https://deno.land/std@0.206.0/yaml/stringify.ts": "fffc09c65c68d3d63f8159e8cbaa3f489bc20a8e55b4fbb61a8c2e9f914d1d02", "https://deno.land/std@0.206.0/yaml/type.ts": "65553da3da3c029b6589c6e4903f0afbea6768be8fca61580711457151f2b30f", - "https://raw.githubusercontent.com/catppuccin/catppuccin/91d6b5433730103c504dcf43583b594e418ee7c1/resources/ports.schema.json": "f1bfc1f4c68af258cd2f1a254d70069b7d254ab0cfe298b9b52bcd78299d8e40" + "https://esm.sh/type-fest@4.8.1": "fabf6997a3adf11e45d11e3c4d58d0634ab98f9d72f3116f3694123818ccd457", + "https://esm.sh/v134/type-fest@4.8.1/denonext/source/simplify.d.js": "a3a0888441b04e1ab9ac5db803dc2bba5509a78f916ca78e583d26b47f429e5f", + "https://esm.sh/v134/type-fest@4.8.1/denonext/source/union-to-intersection.d.js": "4dda98575465ccb71439587d666e602980113bf8d01bb42067ca6ffeb4fae0e3", + "https://esm.sh/v134/type-fest@4.8.1/source/simplify.d": "75d5f739975152accd8282ecb89818cc4644e1ee2c73b13055de5e0ad6349f2e", + "https://esm.sh/v134/type-fest@4.8.1/source/union-to-intersection.d": "7be1a6951fbb06a27c1ad9820a5af2571c77adb65d8fb818ef7c7053e6ed14fa", + "https://raw.githubusercontent.com/catppuccin/catppuccin/91d6b5433730103c504dcf43583b594e418ee7c1/resources/ports.schema.json": "f1bfc1f4c68af258cd2f1a254d70069b7d254ab0cfe298b9b52bcd78299d8e40", + "https://raw.githubusercontent.com/catppuccin/palette/v0.2.0/palette-porcelain.json": "a13a97027e630bdac3a498696b9465f6f947ec6abc2acfee9084e9a951effe4b" } } diff --git a/scripts/deps.ts b/scripts/deps.ts index 5dd21e1ede..49f7c80bf3 100644 --- a/scripts/deps.ts +++ b/scripts/deps.ts @@ -1,11 +1,15 @@ -import schema from "./userstyles.schema.json" assert { type: "json" }; import portsSchema from "catppuccin-repo/resources/ports.schema.json" assert { type: "json", }; +import userStylesSchema from "@/userstyles.schema.json" assert { + type: "json", +}; import { join } from "std/path/mod.ts"; const ROOT = new URL(".", import.meta.url).pathname; -/** absolute path to the repository */ +/** + * absolute path to the repository + */ export const REPO_ROOT = join(ROOT, ".."); -export { portsSchema, schema }; +export { portsSchema, userStylesSchema }; diff --git a/scripts/generate/labels.ts b/scripts/generate/labels.ts new file mode 100644 index 0000000000..f6ba905461 --- /dev/null +++ b/scripts/generate/labels.ts @@ -0,0 +1,76 @@ +import { join } from "std/path/mod.ts"; + +import { REPO_ROOT } from "@/deps.ts"; +import { updateFile } from "@/generate/utils.ts"; +import { UserStylesSchema } from "@/types/mod.d.ts"; +import { stringify } from "std/yaml/stringify.ts"; +import palette from "https://raw.githubusercontent.com/catppuccin/palette/v0.2.0/palette-porcelain.json" assert { + type: "json", +}; + +/** + * Macchiato color definitions as hex values. + */ +const macchiatoHex = Object.entries(palette.macchiato) + .reduce((acc, [k, v]) => { + acc[k] = `#${v.hex}`; + return acc; + }, {} as Record); + +const toIssueLabel = (slug: string | number) => `lbl:${slug}`; + +export const syncIssueLabels = async ( + userstyles: UserStylesSchema.Userstyles, +) => { + updateFile( + join(REPO_ROOT, ".github/issue-labeler.yml"), + stringify( + Object.entries(userstyles) + .reduce((acc, [key]) => { + acc[key.toString()] = [`(${toIssueLabel(key)})`]; + return acc; + }, {} as Record), + ), + ); + + const userstyleIssueContent = Deno.readTextFileSync(join( + REPO_ROOT, + "scripts/generate/templates/userstyle-issue.yml", + )); + Deno.writeTextFileSync( + join(REPO_ROOT, ".github/ISSUE_TEMPLATE/userstyle.yml"), + userstyleIssueContent.replace( + `"$LABELS"`, + `${ + Object.entries(userstyles) + .map(([key]) => `"${toIssueLabel(key)}"`) + .join(", ") + }`, + ), + ); + + // .github/pr-labeler.yml + updateFile( + join(REPO_ROOT, ".github/pr-labeler.yml"), + stringify( + Object.entries(userstyles) + .reduce((acc, [key]) => { + acc[`${key}`] = `styles/${key}/**/*`; + return acc; + }, {} as Record), + ), + ); + + // .github/labels.yml + const syncLabelsContent = Object.entries(userstyles) + .map(([slug, style]) => { + return { + name: slug, + description: [style.name].flat().join(", "), + color: style.color ? macchiatoHex[style.color] : macchiatoHex.blue, + }; + }); + const syncLabels = join(REPO_ROOT, ".github/labels.yml"); + // deno-lint-ignore no-explicit-any + await updateFile(syncLabels, stringify(syncLabelsContent as any)); +}; diff --git a/scripts/generate/main.ts b/scripts/generate/main.ts index 202db93636..4e0f53f0c7 100755 --- a/scripts/generate/main.ts +++ b/scripts/generate/main.ts @@ -1,287 +1,66 @@ -#!/usr/bin/env -S deno run --allow-env --allow-read --allow-write --allow-net +#!/usr/bin/env -S deno run -A +import { join } from "std/path/mod.ts"; -import * as path from "std/path/mod.ts"; -import { parse as parseYaml } from "std/yaml/mod.ts"; -import Ajv from "ajv"; +import { portsSchema, REPO_ROOT, userStylesSchema } from "@/deps.ts"; +import type { PortsSchema, UserStylesSchema } from "@/types/mod.d.ts"; -import { portsSchema, REPO_ROOT, schema } from "@/deps.ts"; - -import { - ApplicationLink, - CurrentMaintainers, - FAQ, - Name, - PastMaintainers, - PortCategories, - Usage, - Userstyle, - Userstyles, -} from "@/types.d.ts"; - -const ROOT = new URL(".", import.meta.url).pathname; -const ISSUE_PREFIX = "lbl:"; - -type Metadata = { - userstyles: Userstyles; -}; - -type PortMetadata = { - categories: PortCategories; -}; - -type CollaboratorsData = { - collaborators: CurrentMaintainers | PastMaintainers | undefined; - heading: string; -}; - -export type MappedPort = Userstyle & { path: string }; - -const ajv = new (Ajv as unknown as (typeof Ajv)["default"])(); -const validate = ajv.compile(schema); -const validatePorts = ajv.compile(portsSchema); +import { syncIssueLabels } from "@/generate/labels.ts"; +import { generateMainReadme } from "@/generate/readme-repo.ts"; +import { generateStyleReadmes } from "@/generate/readme-styles.ts"; +import { updateFile } from "@/generate/utils.ts"; +import { validateYaml } from "@/utils.ts"; const userstylesYaml = Deno.readTextFileSync( - path.join(REPO_ROOT, "scripts/userstyles.yml"), + join(REPO_ROOT, "scripts/userstyles.yml"), ); -const userstylesData = parseYaml(userstylesYaml); -if (!validate(userstylesData)) { - console.log(validate.errors); - Deno.exit(1); -} - const portsYaml = await fetch( "https://raw.githubusercontent.com/catppuccin/catppuccin/main/resources/ports.yml", -); -const portsData = parseYaml(await portsYaml.text()); -if (!validatePorts(portsData)) { - console.log(validate.errors); +).then((res) => res.text()); + +const [portsData, userstylesData] = await Promise.all([ + await validateYaml( + portsYaml, + portsSchema, + ), + await validateYaml( + userstylesYaml, + userStylesSchema, + ), +]); + +if (!userstylesData.userstyles) { + console.error("No userstyles found"); Deno.exit(1); } -const categorized = Object.entries(userstylesData.userstyles).reduce( - (acc, [slug, { category, ...port }]) => { - acc[category] ??= []; - acc[category].push({ path: `styles/${slug}`, category, ...port }); - acc[category].sort((a, b) => { - const aName = typeof a.name === "string" ? a.name : a.name.join(", "); - const bName = typeof b.name === "string" ? b.name : b.name.join(", "); - return aName.localeCompare(bName); - }); - return acc; - }, - {} as Record, -); - -const portListData = portsData.categories - .filter((category) => categorized[category.key] !== undefined) - .map((category) => { - return { - meta: category, - ports: categorized[category.key], - }; - }); - -const portContent = portListData - .map( - (data) => - `
-${data.meta.emoji} ${data.meta.name} - -${ - data.ports - .map((port) => { - const name = Array.isArray(port.name) - ? port.name.join(", ") - : port.name; - return `- [${name}](${port.path})`; - }) - .join("\n") - } - -
`, - ) - .join("\n"); - -const updateReadme = ({ - readme, - section, - newContent, -}: { - readme: string; - section: string; - newContent: string; -}): string => { - const preamble = - ""; - const startMarker = ``; - const endMarker = ``; - const wrapped = `${startMarker}\n${preamble}\n${newContent}\n${endMarker}`; - - if ( - !(readmeContent.includes(startMarker) && readmeContent.includes(endMarker)) - ) { - throw new Error("Markers not found in README.md"); - } - - const pre = readme.split(startMarker)[0]; - const end = readme.split(endMarker)[1]; - return pre + wrapped + end; -}; - -const updateFile = (filePath: string, fileContent: string, comment = true) => { - const preamble = comment - ? "# THIS FILE IS AUTOGENERATED. DO NOT EDIT IT BY HAND.\n" - : ""; - Deno.writeTextFileSync(filePath, preamble + fileContent); -}; - -const readmePath = path.join(REPO_ROOT, "README.md"); -let readmeContent = Deno.readTextFileSync(readmePath); -try { - readmeContent = updateReadme({ - readme: readmeContent, - section: "userstyles", - newContent: portContent, - }); - updateFile(readmePath, readmeContent, false); -} catch (e) { - console.log("Failed to update the README:", e); -} - -const pullRequestLabelerPath = path.join(REPO_ROOT, ".github/pr-labeler.yml"); -const pullRequestLabelerContent = Object.entries(userstylesData.userstyles) - .map(([key]) => `${key}: styles/${key}/**/*`) - .join("\n"); -updateFile(pullRequestLabelerPath, pullRequestLabelerContent); - -const syncLabels = path.join(REPO_ROOT, ".github/labels.yml"); -const syncLabelsContent = Object.entries(userstylesData.userstyles) - .map( - ([key, style]) => - `- name: ${key} - description: ${style.name} - color: "#8aadf4"`, - ) - .join("\n"); -updateFile(syncLabels, syncLabelsContent); - -const issuesLabelerPath = path.join(REPO_ROOT, ".github/issue-labeler.yml"); -const issuesLabelerContent = Object.entries(userstylesData.userstyles) - .map(([key]) => `${key}: ['(${ISSUE_PREFIX + key})']`) - .join("\n"); -updateFile(issuesLabelerPath, issuesLabelerContent); - -const ownersPath = path.join(REPO_ROOT, ".github/CODEOWNERS"); -const ownersContent = Object.entries(userstylesData.userstyles) - .map(([key, style]) => { - const currentMaintainers = style.readme["current-maintainers"] - .map((maintainer) => `@${maintainer.url.split("/").pop()}`) - .join(" "); - return `/styles/${key} ${currentMaintainers}`; - }) - .join("\n"); -updateFile(ownersPath, ownersContent); - -const userstyleIssuePath = path.join(ROOT, "templates/userstyle-issue.yml"); -const userstyleIssueContent = Deno.readTextFileSync(userstyleIssuePath); -const replacedUserstyleIssueContent = userstyleIssueContent.replace( - "$PORTS", - `${ - Object.entries(userstylesData.userstyles) - .map(([key]) => `'${ISSUE_PREFIX + key}'`) - .join(", ") - }`, -); -Deno.writeTextFileSync( - path.join(REPO_ROOT, ".github/ISSUE_TEMPLATE/userstyle.yml"), - replacedUserstyleIssueContent, -); - -const heading = (name: Name, link: ApplicationLink) => { - const nameArray = Array.isArray(name) ? name : [name]; - const linkArray = Array.isArray(link) ? link : [link]; - - if (nameArray.length !== linkArray.length) { - throw new Error( - 'The "name" and "app-link" arrays must have the same length', - ); - } - - return `Catppuccin for ${ - nameArray - .map((name, index) => `${name}`) - .join(", ") - }`; -}; - -const usageContent = (usage?: Usage) => { - return !usage ? "" : `## Usage \n${usage}`; -}; - -const faqContent = (faq?: FAQ) => { - if (!faq) { - return ""; - } - return `## šŸ™‹ FAQ -${ - faq - .map(({ question, answer }) => `- Q: ${question} \n\tA: ${answer}`) - .join("\n") - }`; -}; - -const collaboratorsContent = (allCollaborators: CollaboratorsData[]) => { - return allCollaborators - .filter(({ collaborators }) => collaborators !== undefined) - .map(({ collaborators, heading }) => { - const collaboratorBody = collaborators - ?.map(({ name, url }) => `- [${name ?? url.split("/").pop()}](${url})`) - .join("\n"); - return `${heading}\n${collaboratorBody}`; +/** + * Generate the main README.md, listing all ports as a table of contents + */ +await generateMainReadme(userstylesData.userstyles, portsData); +/** + * Generate README.md files for each style + */ +generateStyleReadmes(userstylesData.userstyles); +/** + * Keep + * - `.github/issue-labeler.yml` + * - `.github/labels.yml` + * - `.github/pr-labeler.yml` + * in sync with the userstyle metadata. + */ +await syncIssueLabels(userstylesData.userstyles); + +/** + * Keep `.github/CODEOWNERS` in sync with the userstyle metadata. + */ +await updateFile( + join(REPO_ROOT, ".github/CODEOWNERS"), + Object.entries(userstylesData.userstyles) + .map(([slug, { readme }]) => { + const currentMaintainers = readme["current-maintainers"] + .map((maintainer) => `@${maintainer.url.split("/").pop()}`) + .join(" "); + return `/styles/${slug} ${currentMaintainers}`; }) - .join("\n\n"); -}; - -const updateStylesReadmeContent = ( - readme: string, - key: string, - userstyle: Userstyle, -) => { - return readme - .replace("$TITLE", heading(userstyle.name, userstyle.readme["app-link"])) - .replaceAll("$LOWERCASE-PORT", key) - .replace("$USAGE", usageContent(userstyle.readme.usage)) - .replace("$FAQ", faqContent(userstyle.readme.faq)) - .replace( - "$COLLABORATORS", - collaboratorsContent([ - { - collaborators: userstyle.readme["current-maintainers"], - heading: "## šŸ’ Current Maintainer(s)", - }, - { - collaborators: userstyle.readme["past-maintainers"], - heading: "## šŸ’– Past Maintainer(s)", - }, - ]), - ); -}; - -const stylesReadmePath = path.join(ROOT, "templates/userstyle.md"); -const stylesReadmeContent = Deno.readTextFileSync(stylesReadmePath); -for (const [key, userstyle] of Object.entries(userstylesData.userstyles)) { - try { - console.log(`Generating README for ${key}`); - readmeContent = updateStylesReadmeContent( - stylesReadmeContent, - key, - userstyle, - ); - Deno.writeTextFileSync( - path.join(REPO_ROOT, "styles", key, "README.md"), - readmeContent, - ); - } catch (e) { - console.log(`Failed to update ${userstyle} README:`, e); - } -} + .join("\n"), +); diff --git a/scripts/generate/readme-repo.ts b/scripts/generate/readme-repo.ts new file mode 100644 index 0000000000..22714f6524 --- /dev/null +++ b/scripts/generate/readme-repo.ts @@ -0,0 +1,74 @@ +import { join } from "std/path/mod.ts"; +import Handlebars from "handlebars"; + +import { REPO_ROOT } from "@/deps.ts"; +import { PortsSchema, UserStylesSchema } from "@/types/mod.d.ts"; +import { updateFile, updateReadme } from "@/generate/utils.ts"; + +type MappedPorts = { + [k: string]: ( + UserStylesSchema.Userstyle & { path: string } + )[]; +}; + +export const generateMainReadme = async ( + userstyles: UserStylesSchema.Userstyles, + portsData: PortsSchema.PortsSchema, +) => { + if (!portsData.categories) throw ("Ports data is missing categories"); + + const categorized = Object.entries(userstyles) + .reduce((acc, [slug, { category, ...port }]) => { + // initialize category array if it doesn't exist + acc[category] ??= []; + + acc[category].push({ path: `styles/${slug}`, category, ...port }); + + // Sort by name, first array entry if necessary + acc[category].sort((a, b) => + [a.name].flat()[0].localeCompare([b.name].flat()[0]) + ); + return acc; + }, {} as MappedPorts); + + const portListData = portsData.categories + .filter((category) => categorized[category.key] !== undefined) + .map((category) => { + return { meta: category, ports: categorized[category.key] }; + }); + + const portContent = Handlebars.compile(`{{#each category}} +
+{{emoji}} {{name}} + +{{#each ports}} +- [{{#each name}}{{ this }}{{#unless @last}}, {{/unless}}{{/each}}]({{ path }}) +{{/each}} + +
+{{/each}}`)({ + category: portListData.map(({ meta, ports }) => { + return { + emoji: meta.emoji, + name: meta.name, + ports: ports.map(({ name, path }) => { + return { + name: [name].flat(), + path, + }; + }), + }; + }), + }); + + const readmePath = join(REPO_ROOT, "README.md"); + await updateFile( + readmePath, + updateReadme({ + readme: Deno.readTextFileSync(readmePath), + section: "userstyles", + newContent: portContent, + }), + false, + ).catch((e) => console.error(e)); +}; diff --git a/scripts/generate/readme-styles.ts b/scripts/generate/readme-styles.ts new file mode 100644 index 0000000000..d9c34e5896 --- /dev/null +++ b/scripts/generate/readme-styles.ts @@ -0,0 +1,63 @@ +import { UserStylesSchema } from "@/types/mod.d.ts"; +import { join } from "std/path/mod.ts"; +import { REPO_ROOT } from "@/deps.ts"; +import Handlebars from "handlebars"; + +const heading = ( + name: UserStylesSchema.Name, + link: UserStylesSchema.ApplicationLink, +) => { + const [nameArray, linkArray] = [[name].flat(), [link].flat()]; + + if (nameArray.length !== linkArray.length) { + throw new Error( + 'The "name" and "app-link" arrays must have the same length', + ); + } + + return nameArray.map((title, i) => { + return { title, url: linkArray[i] }; + }); +}; + +const extractName = ( + collaborators?: + | UserStylesSchema.CurrentMaintainers + | UserStylesSchema.PastMaintainers, +) => { + // no-op when undefined + if (!collaborators) return; + // set the name to the github.com/ + return collaborators.map((c) => { + c.name ??= c.url.split("/").pop(); + return c; + }); +}; + +export const generateStyleReadmes = ( + userstyles: UserStylesSchema.Userstyles, +) => { + const stylesReadmePath = join( + REPO_ROOT, + "scripts/generate/templates/userstyle.md", + ); + const stylesReadmeContent = Deno.readTextFileSync(stylesReadmePath); + + Object.entries(userstyles).map(([slug, { name, readme }]) => { + 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(readme["current-maintainers"]), + pastMaintainers: extractName(readme["past-maintainers"]), + }, + }); + Deno.writeTextFile( + join(REPO_ROOT, "styles", slug.toString(), "README.md"), + readmeContent, + ).catch((e) => console.error(e)); + }); +}; diff --git a/scripts/generate/templates/userstyle-issue.yml b/scripts/generate/templates/userstyle-issue.yml index 68482e0461..fc208f635b 100644 --- a/scripts/generate/templates/userstyle-issue.yml +++ b/scripts/generate/templates/userstyle-issue.yml @@ -14,7 +14,7 @@ body: label: What userstyles are you seeing the problem on? description: "Don't worry about the `lbl:` prefix, it allows issues to be automatically labeled!" multiple: true - options: [$PORTS] + options: ["$LABELS"] validations: required: true - type: textarea @@ -38,4 +38,5 @@ body: - type: textarea attributes: label: Any additional comments? - description: Add any information that hasn't been covered in the previous sections! \ No newline at end of file + description: Add any information that hasn't been covered in the previous sections! +# yaml-language-server: $schema=https://json.schemastore.org/github-issue-forms.json diff --git a/scripts/generate/templates/userstyle.md b/scripts/generate/templates/userstyle.md index dfe5f242cc..808d07166f 100644 --- a/scripts/generate/templates/userstyle.md +++ b/scripts/generate/templates/userstyle.md @@ -4,13 +4,13 @@

Logo
- $TITLE + Catppuccin for {{#each heading}}{{ this.title }}{{#unless @last}}, {{/unless}}{{/each}}

- - + +

@@ -36,11 +36,30 @@ -$USAGE +{{#if usage}} +## Usage +{{{ usage }}} +{{/if}} -$FAQ +{{#if faq}} +## šŸ™‹ FAQ +{{#each faq}} +- Q: {{{ question }}}\ + A: {{{ answer }}} +{{/each}} +{{/if}} -$COLLABORATORS +## šŸ’ Current Maintainer(s) +{{#each collaborators.currentMaintainers}} +- [{{name}}]({{url}}) +{{/each}} + +{{#if collaborators.pastMaintainers}} +## šŸ’ Past Maintainer(s) +{{#each collaborators.pastMaintainers}} +- [{{name}}]({{url}}) +{{/each}} +{{/if}}   diff --git a/scripts/generate/utils.ts b/scripts/generate/utils.ts new file mode 100644 index 0000000000..1293f5b52e --- /dev/null +++ b/scripts/generate/utils.ts @@ -0,0 +1,36 @@ +export const updateFile = ( + filePath: string, + fileContent: string, + comment = true, +) => { + const preamble = comment + ? "# THIS FILE IS AUTOGENERATED. DO NOT EDIT IT BY HAND.\n" + : ""; + return Deno.writeTextFile(filePath, preamble + fileContent); +}; + +export const updateReadme = ({ + readme, + section, + newContent, +}: { + readme: string; + section: string; + newContent: string; +}): string => { + const preamble = + ""; + const startMarker = ``; + const endMarker = ``; + const wrapped = `${startMarker}\n${preamble}\n${newContent}\n${endMarker}`; + + if ( + !(readme.includes(startMarker) && readme.includes(endMarker)) + ) { + throw new Error("Markers not found in README.md"); + } + + const pre = readme.split(startMarker)[0]; + const end = readme.split(endMarker)[1]; + return pre + wrapped + end; +}; diff --git a/scripts/lint/file-checker.ts b/scripts/lint/file-checker.ts index 8802dc4cd7..2af304bade 100644 --- a/scripts/lint/file-checker.ts +++ b/scripts/lint/file-checker.ts @@ -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"); }); } diff --git a/scripts/lint/logger.ts b/scripts/lint/logger.ts index c8eba67769..cdce1d771d 100644 --- a/scripts/lint/logger.ts +++ b/scripts/lint/logger.ts @@ -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, diff --git a/scripts/lint/main.ts b/scripts/lint/main.ts index 7b6deb8706..fbc9f21862 100755 --- a/scripts/lint/main.ts +++ b/scripts/lint/main.ts @@ -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"; diff --git a/scripts/lint/metadata.ts b/scripts/lint/metadata.ts index e85019bd47..5054c2e192 100644 --- a/scripts/lint/metadata.ts +++ b/scripts/lint/metadata.ts @@ -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, { diff --git a/scripts/lint/stylelint.ts b/scripts/lint/stylelint.ts index 259bd0f5b2..da583a2e7b 100644 --- a/scripts/lint/stylelint.ts +++ b/scripts/lint/stylelint.ts @@ -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, { diff --git a/scripts/sync-maintainers/main.ts b/scripts/sync-maintainers/main.ts index 9eec4d8d6c..721906dc35 100755 --- a/scripts/sync-maintainers/main.ts +++ b/scripts/sync-maintainers/main.ts @@ -1,28 +1,21 @@ -#!/usr/bin/env -S deno run --allow-read --allow-net --allow-env +#!/usr/bin/env -S deno run -A import * as assert from "std/assert/mod.ts"; import * as path from "std/path/mod.ts"; -import { parse as parseYaml } from "std/yaml/mod.ts"; -import Ajv from "ajv"; import { Octokit } from "@octokit/rest"; -import { REPO_ROOT, schema } from "@/deps.ts"; -import { Userstyle, UserstylesSchema } from "@/types.d.ts"; +import { REPO_ROOT, userStylesSchema } from "@/deps.ts"; +import type { UserStylesSchema } from "../types/mod.d.ts"; +import { validateYaml } from "@/utils.ts"; +import { UserstylesSchema } from "@/types/userstyles.d.ts"; const octokit = new Octokit({ auth: Deno.env.get("GITHUB_TOKEN") }); const team = { org: "catppuccin", team_slug: "userstyles-maintainers" }; -const ajv = new Ajv.default(); -const validate = ajv.compile(schema); - -const userstylesYaml = Deno.readTextFileSync( - path.join(REPO_ROOT, "scripts/userstyles.yml"), +const userstylesData = await validateYaml( + Deno.readTextFileSync(path.join(REPO_ROOT, "scripts/userstyles.yml")), + userStylesSchema, ); -const userstylesData = parseYaml(userstylesYaml); -if (!validate(userstylesData)) { - console.error(validate.errors); - Deno.exit(1); -} if (userstylesData.userstyles === undefined) { Deno.exit(1); } @@ -30,7 +23,9 @@ if (userstylesData.userstyles === undefined) { // lowercase usernames of all the "current-maintainers" in the file const maintainers = [ ...new Set( - Object.values(userstylesData.userstyles).flatMap((style: Userstyle) => + Object.values(userstylesData.userstyles).flatMap(( + style: UserStylesSchema.Userstyle, + ) => style.readme["current-maintainers"].map((m) => { const username = m.url.split("github.com/")?.pop(); // check that they follow github.com/username pattern diff --git a/scripts/types.d.ts b/scripts/types.d.ts deleted file mode 100644 index 4554da8ee9..0000000000 --- a/scripts/types.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./types/userstyles.d.ts"; -export type { Categories as PortCategories } from "catppuccin-repo/resources/generate/types.d.ts"; diff --git a/scripts/types/mod.d.ts b/scripts/types/mod.d.ts new file mode 100644 index 0000000000..9f5add9053 --- /dev/null +++ b/scripts/types/mod.d.ts @@ -0,0 +1,9 @@ +export * as UserStylesSchema from "./userstyles.d.ts"; +export * as PortsSchema from "catppuccin-repo/resources/generate/types.d.ts"; + +import { Entries } from "https://esm.sh/type-fest@4.8.1"; +declare global { + interface ObjectConstructor { + entries(o: T): Entries; + } +} diff --git a/scripts/usercss-meta.d.ts b/scripts/types/usercss-meta.d.ts similarity index 100% rename from scripts/usercss-meta.d.ts rename to scripts/types/usercss-meta.d.ts diff --git a/scripts/types/userstyles.d.ts b/scripts/types/userstyles.d.ts index 806e590cb6..677a9bf594 100644 --- a/scripts/types/userstyles.d.ts +++ b/scripts/types/userstyles.d.ts @@ -1,9 +1,4 @@ -/* eslint-disable */ -/** - * This file was automatically generated by json-schema-to-typescript. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run json-schema-to-typescript to regenerate this file. - */ +// deno-fmt-ignore-file /** * The name of the userstyle(s). @@ -74,7 +69,7 @@ export type FAQ = [ question: Question; answer: Answer; [k: string]: unknown; - }[], + }[] ]; /** * A question that a user may have about the userstyle. @@ -99,7 +94,7 @@ export type CurrentMaintainers = [ name?: DisplayName; url: GitHubProfile; [k: string]: unknown; - }[], + }[] ]; /** * The display name of the collaborator to show in the userstyle README. @@ -124,7 +119,7 @@ export type PastMaintainers = [ name?: DisplayName; url: GitHubProfile; [k: string]: unknown; - }[], + }[] ]; /** * Represents all maintainers and contributors to all userstyles. @@ -141,7 +136,7 @@ export type AllCollaborators = [ name?: DisplayName; url: GitHubProfile; [k: string]: unknown; - }[], + }[] ]; export interface UserstylesSchema { diff --git a/scripts/update-types.ts b/scripts/update-types.ts new file mode 100755 index 0000000000..0b7c938e49 --- /dev/null +++ b/scripts/update-types.ts @@ -0,0 +1,16 @@ +#!/usr/bin/env -S deno run -A +// deno-lint-ignore-file no-explicit-any +import { join } from "std/path/mod.ts"; +import { compile, Options } from "npm:json-schema-to-typescript"; +import { REPO_ROOT, userStylesSchema } from "@/deps.ts"; + +const options = { + bannerComment: "// deno-fmt-ignore-file", +} satisfies Partial; + +const TYPES_ROOT = join(REPO_ROOT, "scripts/types"); + +compile(userStylesSchema as any, "UserstylesSchema", options) + .then((ts) => + Deno.writeTextFileSync(join(TYPES_ROOT, "userstyles.d.ts"), ts) + ); diff --git a/scripts/utils.ts b/scripts/utils.ts new file mode 100644 index 0000000000..c600ff56a8 --- /dev/null +++ b/scripts/utils.ts @@ -0,0 +1,22 @@ +import Ajv, { Schema } from "ajv"; +import { parse } from "std/yaml/parse.ts"; + +/** + * @param content A string of YAML content + * @param schema A JSON schema + * @returns A promise that resolves to the parsed YAML content, verified against the schema. Rejects if the content is invalid. + */ +export const validateYaml = ( + content: string, + schema: Schema, +): Promise => { + return new Promise((resolve, reject) => { + const ajv = new Ajv.default(); + const validate = ajv.compile(schema); + const data = parse(content); + + if (!validate(data)) return reject(validate.errors); + + return resolve(data); + }); +};