Skip to content

Commit

Permalink
Run config files and scripts through prettier and fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cmil committed Sep 19, 2024
1 parent 88c5750 commit 4e2b934
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20.x'
node-version: "20.x"
- name: Restore node_modules
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: "18.x"
- name: Restore node_modules
uses: actions/cache@v3
with:
Expand Down
60 changes: 30 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@ jobs:
build_assets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20.x'
- name: Restore node_modules
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: "20.x"
- name: Restore node_modules
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}

- run: yarn install
- run: yarn csv
- run: yarn json
- run: yarn install
- run: yarn csv
- run: yarn json

- name: Upload JSON
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./data.json
asset_name: einakter-${{ github.event.release.tag_name }}.json
asset_content_type: application/json
- name: Upload JSON
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./data.json
asset_name: einakter-${{ github.event.release.tag_name }}.json
asset_content_type: application/json

- name: Upload CSV
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./data.csv
asset_name: einakter-${{ github.event.release.tag_name }}.csv
asset_content_type: text/csv
- name: Upload CSV
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./data.csv
asset_name: einakter-${{ github.event.release.tag_name }}.csv
asset_content_type: text/csv
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
data.yaml
originals.yaml
src/authors.json
src/locations.json
lingui.config.js
10 changes: 9 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@
"tabWidth": 2,
"bracketSpacing": false,
"arrowParens": "always",
"trailingComma": "es5"
"trailingComma": "es5",
"overrides": [
{
"files": ["**/*.yml", "**/*.yaml"],
"options": {
"singleQuote": false
}
}
]
}
4 changes: 2 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import pluginReact from 'eslint-plugin-react';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

export default [
{ files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] },
{ languageOptions: { globals: globals.browser } },
{files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}']},
{languageOptions: {globals: globals.browser}},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat['jsx-runtime'],
Expand Down
28 changes: 14 additions & 14 deletions fetch-authors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ interface Author {
ambiguous?: boolean;
}

const authors: {[index: string]: any} = {...authorData};
const authors: {[index: string]: Author} = {...authorData};

let data: Play[] = [];
try {
data = loadAll(readFileSync('./data.yaml', 'utf8'), null, {
schema: CORE_SCHEMA
schema: CORE_SCHEMA,
}) as Play[];
} catch (error) {
console.log(error);
Expand All @@ -43,15 +43,15 @@ const plays = data.map((p: Play) => {
const argv = process.argv.slice(2);

const authorIds = plays
.map(p => p.authors.filter(a => a.wikidata).map(a => a.wikidata))
.map((p) => p.authors.filter((a) => a.wikidata).map((a) => a.wikidata))
.flat()
.filter((id, index, self) => self.indexOf(id) === index);

const endpoint = 'https://query.wikidata.org/sparql';

async function fetchAuthors () {
const results: {[index: string]: any} = {};
for(let i = 0; i < authorIds.length; i++) {
async function fetchAuthors() {
const results: {[index: string]: unknown} = {};
for (let i = 0; i < authorIds.length; i++) {
const id = authorIds[i];
const author = authors[id as string];
if (author && !argv.includes(id as string)) {
Expand Down Expand Up @@ -83,7 +83,7 @@ WHERE {
const response = await axios.get(url);
if (response.status === 200) {
const sparqlResults = response.data.results?.bindings || [];
let ambiguity = sparqlResults.length;
const ambiguity = sparqlResults.length;
if (ambiguity > 1) {
console.log(`multiple results (${ambiguity})`);
}
Expand All @@ -96,34 +96,34 @@ WHERE {
birth: {
date: a.birthDate?.value,
place: a.birthPlaceLabel?.value,
placeId: a.birthPlace?.value
placeId: a.birthPlace?.value,
},
death: {
date: a.deathDate?.value,
place: a.deathPlaceLabel?.value,
placeId: a.deathPlace?.value
placeId: a.deathPlace?.value,
},
};
if (a.gender?.value === 'http://www.wikidata.org/entity/Q6581097') {
newAuthor.gender = 'male';
newAuthor.gender = 'male';
}
if (a.gender?.value === 'http://www.wikidata.org/entity/Q6581072') {
newAuthor.gender = 'female';
newAuthor.gender = 'female';
}
if (ambiguity > 1) {
newAuthor.ambiguous = true;
newAuthor.ambiguous = true;
}
results[id as string] = newAuthor;
console.log(newAuthor);
} else {
console.log(response.status);
}
} catch (error) {
console.log(error)
console.log(error);
}

console.log('waiting...');
await new Promise(r => setTimeout(r, 1000));
await new Promise((r) => setTimeout(r, 1000));
}
}

Expand Down
25 changes: 14 additions & 11 deletions fetch-locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {Play} from './src/types';

import loc from './src/locations.json';

const locations: {[index: string]: any} = {...loc}
const locations: {[index: string]: number[]} = {...loc};

let data: Play[] = [];
try {
data = loadAll(readFileSync('./data.yaml', 'utf8'), null, {
schema: CORE_SCHEMA
schema: CORE_SCHEMA,
}) as Play[];
} catch (error) {
console.log(error);
Expand All @@ -20,17 +20,20 @@ const locationIds = data
// find plays with wikidata ID
.filter((p) => p.settings?.find((s) => s.location?.wikidataId))
// extract wikidata IDs
.map((p) => p.settings?.filter((s) => s.location?.wikidataId).map(
(s) => s.location?.wikidataId)
).flat()
.map((p) =>
p.settings
?.filter((s) => s.location?.wikidataId)
.map((s) => s.location?.wikidataId)
)
.flat()
// remove duplicates
.filter((id, index, self) => self.indexOf(id) === index);

const endpoint = 'https://query.wikidata.org/sparql';

async function fetchLocations () {
const results: {[index: string]: any} = {};
for(let i = 0; i < locationIds.length; i++) {
async function fetchLocations() {
const results: {[index: string]: number[]} = {};
for (let i = 0; i < locationIds.length; i++) {
const id = locationIds[i];
const loc = locations[id as string];
if (loc) {
Expand All @@ -50,18 +53,18 @@ async function fetchLocations () {
if (m) {
long = parseFloat(m[1]);
lat = parseFloat(m[2]);
results[id as string] = [lat, long]
results[id as string] = [lat, long];
console.log(loc, long, lat);
}
} else {
console.log(response.status);
}
} catch (error) {
console.log(error)
console.log(error);
}

console.log('waiting...');
await new Promise(r => setTimeout(r, 1000));
await new Promise((r) => setTimeout(r, 1000));
}
}

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
4 changes: 2 additions & 2 deletions postcss.config.js → postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
};
16 changes: 8 additions & 8 deletions tailwind.config.js → tailwind.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./src/**/*.{js,jsx,ts,tsx}',
],
import { default as typographyPlugin } from '@tailwindcss/typography';

export default {
content: ['./src/**/*.{js,jsx,ts,tsx}'],
theme: {
extend: {
colors: {
Expand All @@ -14,7 +14,7 @@ module.exports = {
neutral: {
100: '#ebf0f7',
200: '#1f244809',
}
},
},
typography: {
DEFAULT: {
Expand All @@ -34,7 +34,7 @@ module.exports = {
},
a: {
color: '#08f',
'&:hover': {
'&:hover': {
color: '#0056b3',
},
fontWeight: '400',
Expand All @@ -49,8 +49,8 @@ module.exports = {
},
},
plugins: [
require('@tailwindcss/typography')({
typographyPlugin({
className: 'markdown',
}),
],
}
};
10 changes: 6 additions & 4 deletions yml2beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Play} from './src/types';
let data: Play[] = [];
try {
data = loadAll(readFileSync('./data.yaml', 'utf8'), null, {
schema: CORE_SCHEMA
schema: CORE_SCHEMA,
}) as Play[];
} catch (error) {
console.log(error);
Expand All @@ -19,8 +19,10 @@ let beacon = `#FORMAT: BEACON
`;

data.filter((p: Play) => p.ids?.wikidata).forEach((p: Play) => {
beacon += `${p.ids?.wikidata}||${p.id}\n`;
});
data
.filter((p: Play) => p.ids?.wikidata)
.forEach((p: Play) => {
beacon += `${p.ids?.wikidata}||${p.id}\n`;
});

writeFileSync('./public/wikidata.txt', beacon);
Loading

0 comments on commit 4e2b934

Please sign in to comment.