Skip to content

Commit 8701911

Browse files
authored
Fix builds (#585)
* WIP: Fix builds * Update lockfile
1 parent c45d017 commit 8701911

File tree

12 files changed

+502
-800
lines changed

12 files changed

+502
-800
lines changed

.eleventy.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
const htmlmin = require("html-minifier");
2-
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
3-
const {Liquid} = require("liquidjs");
4-
const markdownIt = require("markdown-it");
1+
import htmlmin from "html-minifier";
2+
import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
3+
import {Liquid} from "liquidjs";
4+
import markdownIt from "markdown-it";
5+
import octiconTag from "./js/octicons-liquid/tag.js";
56

67
function watchAndPass(file, config) {
78
config.addWatchTarget(file);
89
config.addPassthroughCopy(file);
910
}
10-
module.exports = function (eleventyConfig) {
11+
export default function (eleventyConfig) {
1112
watchAndPass("./assets/js", eleventyConfig);
1213
watchAndPass("./assets/dist", eleventyConfig);
1314
watchAndPass("./assets/img", eleventyConfig);
@@ -53,7 +54,7 @@ module.exports = function (eleventyConfig) {
5354
root: ["_includes"]
5455
};
5556
const liquid = new Liquid(options);
56-
liquid.registerTag('octicon', require("./js/octicons-liquid/tag.js"));
57+
liquid.registerTag('octicon', octiconTag);
5758
eleventyConfig.setLibrary("liquid", liquid);
5859

5960
// Customize markdown-it settings

.eslintrc.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.nojekyll

Whitespace-only changes.

apps/apps.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pagination:
44
size: 1
55
alias: app
66
permalink: "/apps/{{ app.data.slug | slug }}/index.html"
7-
layout: app.liquid
7+
layout: app
88
---
99

1010
{%- for item in pagination.items %}

eslint.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
import eslint from '@eslint/js';
3+
import tseslint from 'typescript-eslint';
4+
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
5+
6+
export default tseslint.config(
7+
eslint.configs.recommended,
8+
...tseslint.configs.recommendedTypeChecked,
9+
...tseslint.configs.stylisticTypeChecked,
10+
eslintPluginPrettierRecommended,
11+
{
12+
languageOptions: {
13+
parserOptions: {
14+
project: true,
15+
tsconfigRootDir: import.meta.dirname,
16+
},
17+
},
18+
},
19+
);

js/octicons-liquid/tag.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// From https://github.com/github/docs/blob/fa3bb7d4f5dcfdd1b998e1f6892000935e51c851/lib/liquid-tags/octicon.js
22

3-
const { TokenizationError } = require('liquidjs')
4-
const octicons = require('@primer/octicons')
3+
import { TokenizationError } from 'liquidjs'
4+
import octicons from '@primer/octicons'
55

66
const OptionsSyntax = /([a-zA-Z-]+)="([a-zA-Z0-9\d-_\s]+)"*/g
77
const Syntax = new RegExp('"(?<icon>[a-zA-Z-]+)"(?<options>(?:\\s' + OptionsSyntax.source + ')*)')
@@ -14,7 +14,7 @@ const SyntaxHelp = 'Syntax Error in tag \'octicon\' - Valid syntax: octicon "<na
1414
* {% octicon "check" %}
1515
* {% octicon "check" width="64" aria-label="Example label" %}
1616
*/
17-
module.exports = {
17+
export default {
1818
parse (tagToken) {
1919
const match = tagToken.args.match(Syntax)
2020
if (!match) {

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"watch:eleventy": "eleventy --serve",
99
"build": "eleventy",
1010
"lint": "eslint script/sync.ts",
11-
"sync-data": "ts-node script/sync.ts"
11+
"sync-data": "ts-node-esm script/sync.ts"
1212
},
1313
"dependencies": {
14-
"@11ty/eleventy": "^2.0.0",
14+
"@11ty/eleventy": "^3.0.0-alpha.14",
1515
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
1616
"@primer/css": "^21.0.0",
1717
"@primer/octicons": "^19.0.0",
@@ -26,17 +26,17 @@
2626
"devDependencies": {
2727
"@octokit/rest": "^21.0.0",
2828
"@types/node": "^20.0.0",
29-
"@typescript-eslint/eslint-plugin": "^7.0.0",
30-
"@typescript-eslint/parser": "^7.0.0",
3129
"eslint": "^9.0.0",
3230
"eslint-config-prettier": "^9.0.0",
3331
"eslint-plugin-prettier": "^5.0.0",
3432
"eslint-plugin-promise": "^6.0.0",
3533
"npm-run-all2": "^6.0.0",
3634
"prettier": "^3.0.0",
37-
"ts-node": "^10.5.0",
35+
"ts-node": "^10.9.2",
3836
"typescript": "^5.0.0",
37+
"typescript-eslint": "^8.0.0-alpha.37",
3938
"yaml": "2.4.5"
4039
},
41-
"packageManager": "[email protected]"
40+
"packageManager": "[email protected]",
41+
"type": "module"
4242
}

script/sass.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const sass = require("sass");
2-
const fs = require("fs");
1+
import fs from 'fs';
2+
import sass from 'sass';
33

44
const result = sass.renderSync({
55
file: "assets/sass/styles.scss",

script/sync.ts

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
2+
13
import { Octokit } from "@octokit/rest";
2-
import YAML from "yaml";
3-
import fs from "fs";
4+
import * as YAML from "yaml";
5+
import * as fs from "fs";
6+
import { join, extname } from "path";
47

58
function pad(number: number) {
69
if (number < 10) {
@@ -12,8 +15,13 @@ function pad(number: number) {
1215
// Modified version of the toISOString polyfill from https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
1316
// because I couldn't find a function which outputs the dates like it happened on ruby
1417
// but the diff from the TS output and the ruby output should be as low as possible
15-
// @ts-expect-error
16-
Date.prototype.toRubyString = function () {
18+
declare global {
19+
interface Date {
20+
toRubyString(): string;
21+
}
22+
}
23+
24+
Date.prototype.toRubyString = function (this: Date) {
1725
return (
1826
this.getUTCFullYear() +
1927
"-" +
@@ -31,59 +39,57 @@ Date.prototype.toRubyString = function () {
3139
};
3240

3341
const client = new Octokit({
34-
auth: process.env.GITHUB_TOKEN || "",
42+
auth: process.env.GITHUB_TOKEN ?? "",
3543
});
3644

3745
function walk(directory: string, filepaths: string[] = []): string[] {
3846
const files = fs.readdirSync(directory);
39-
for (let filename of files) {
40-
const filepath = require("path").join(directory, filename);
47+
for (const filename of files) {
48+
const filepath = join(directory, filename);
4149
if (fs.statSync(filepath).isDirectory()) {
4250
walk(filepath, filepaths);
43-
} else if (require("path").extname(filename) === ".md") {
51+
} else if (extname(filename) === ".md") {
4452
filepaths.push(filepath);
4553
}
4654
}
4755
return filepaths;
4856
}
4957

50-
const files = walk(require("path").join(__dirname, "..", "_apps"));
58+
const files = walk(join(__dirname, "..", "_apps"));
5159

52-
files.forEach(async (path) => {
53-
let data: string = "";
60+
for (const path of files) {
61+
let data = "";
5462
try {
5563
try {
5664
// @ts-expect-error
57-
data = fs
58-
.readFileSync(path)
59-
.toString()
60-
.match(/^---(((?!---).|[\r\n])*)[\r\n]---$/m)[0];
65+
data = /^---(((?!---).|[\r\n])*)[\r\n]---$/m.exec(
66+
fs.readFileSync(path).toString(),
67+
)[0];
6168
} catch {
6269
console.error(`Error parsing ${path}`);
6370
console.log(data);
6471
process.exit(1);
6572
}
66-
let app = YAML.parse(data.replaceAll("---", ""));
73+
const app = YAML.parse(data.replaceAll("---", ""));
6774
console.log(`Syncing ${app.title}`);
6875

69-
const repoName = app["repository"].split("/");
76+
const repoName = app.repository.split("/");
7077
const repo = await client.rest.repos.get({
7178
owner: repoName[0],
7279
repo: repoName[1],
7380
});
7481
app.stars = repo.data.stargazers_count;
75-
//@ts-expect-error
7682
app.updated = new Date(repo.data.pushed_at).toRubyString();
7783

7884
if (app.host) {
7985
const statsFromServer = await fetch(app.host + "/probot/stats");
8086
if (statsFromServer.status === 200) {
81-
let stats: Record<string, unknown> = YAML.parse(
82-
await statsFromServer.text()
87+
const stats: Record<string, unknown> = YAML.parse(
88+
await statsFromServer.text(),
8389
);
8490
if (stats.popular) {
85-
app.organizations = (<Array<unknown>>stats.popular).map(
86-
(org: any) => org.login
91+
app.organizations = (stats.popular as unknown[]).map(
92+
(org: any) => org.login as string,
8793
);
8894
}
8995
}
@@ -93,7 +99,7 @@ files.forEach(async (path) => {
9399
content = content.replace(
94100
data,
95101
`---
96-
${YAML.stringify(app)}---`
102+
${YAML.stringify(app)}---`,
97103
);
98104
fs.writeFileSync(path, content);
99105
console.log(`Done for ${app.title}`);
@@ -107,4 +113,4 @@ ${YAML.stringify(app)}---`
107113
console.log(e);
108114
process.exit(1);
109115
}
110-
});
116+
}

script/watchsass.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const fs = require('fs');
2-
const sass = require('sass');
1+
import fs from 'fs';
2+
import sass from 'sass';
33

44
const result = sass.renderSync({
55
file: "assets/sass/styles.scss",

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
33
"strict": true,
4-
"target": "ES2021",
5-
"esModuleInterop": true,
4+
"target": "ES2022",
5+
"module": "ES2022",
66
"moduleResolution": "node"
77
},
88
"ts-node": {},

0 commit comments

Comments
 (0)