Skip to content

Commit

Permalink
Refactor code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 11, 2024
1 parent 9347d95 commit f87ff9a
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 104 deletions.
8 changes: 4 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
34 changes: 14 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
name: main
on:
push:
branches:
- website
schedule:
- cron: '45 7 2 * *'
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- uses: dcodeIO/setup-node-nvm@master
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: node
- run: npm install
- run: npm test
- name: Deploy
uses: JamesIves/[email protected]
- uses: JamesIves/github-pages-deploy-action@releases/v4
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
BRANCH: gh-pages
FOLDER: dest
SINGLE_COMMIT: true
COMMIT_MESSAGE: .
GIT_CONFIG_NAME: Titus Wormer
GIT_CONFIG_EMAIL: [email protected]
branch: gh-pages
commit-message: .
folder: dest
git-config-email: [email protected]
git-config-name: Titus Wormer
single-commit: true
name: main
on:
push:
branches:
- website
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
*.log
.DS_Store
dest/
node_modules/
src/fixtures.js
src/to-name.js
dest/
yarn.lock
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ignore-scripts=true
package-lock=false
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dest/
*.html
*.md
dest/
33 changes: 0 additions & 33 deletions build.js

This file was deleted.

24 changes: 24 additions & 0 deletions crawl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import fs from 'node:fs/promises'
import {iso6393} from 'iso-639-3'
import {fetch} from 'undici'

const iso6393ToName = {}

let index = -1

while (++index < iso6393.length) {
const language = iso6393[index]
iso6393ToName[language.iso6393] = language.name
}

const response = await fetch(
'https://raw.githubusercontent.com/wooorm/franc/main/test/fixtures.js'
)
const body = await response.text()

await fs.writeFile(new URL('src/fixtures.js', import.meta.url), body)

await fs.writeFile(
new URL('src/to-name.js', import.meta.url),
'export const toName = ' + JSON.stringify(iso6393ToName, undefined, 2) + '\n'
)
72 changes: 36 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
{
"name": "franc-www",
"private": true,
"license": "MIT",
"repository": "wooorm/franc",
"bugs": "https://github.com/wooorm/franc/issues",
"author": "Titus Wormer <[email protected]> (http://wooorm.com)",
"bugs": "https://github.com/wooorm/franc/issues",
"contributors": [
"Titus Wormer <[email protected]> (http://wooorm.com)"
],
"type": "module",
"devDependencies": {
"bail": "^2.0.0",
"cssnano": "^6.0.0",
"debounce": "^2.0.0",
"esbuild": "^0.19.0",
Expand All @@ -26,48 +20,54 @@
"stylelint": "^14.0.0",
"stylelint-config-prettier": "^9.0.0",
"stylelint-config-standard": "^28.0.0",
"undici": "^6.0.0",
"xo": "^0.56.0"
},
"license": "MIT",
"name": "franc-www",
"postcss": {
"plugins": {
"cssnano": {
"preset": "default"
}
}
},
"prettier": {
"bracketSpacing": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false
},
"private": true,
"remarkConfig": {
"plugins": [
"remark-preset-wooorm"
]
},
"repository": "wooorm/franc",
"scripts": {
"generate": "node build",
"format": "remark . -qfo && prettier . -w --log-level warn && xo --fix && stylelint src/index.css --fix",
"build:js": "esbuild src/index.js --bundle --minify --target=es6 --outfile=dest/index.nomodule.js && esbuild src/index.js --bundle --minify --target=es2020 --format=esm --outfile=dest/index.module.js",
"build:css": "postcss src/index.css > dest/index.css",
"build:html": "rehype -u preset-minify -u prevent-favicon-request src -o dest",
"build": "npm run build:js && npm run build:css && npm run build:html",
"test": "npm run generate && npm run format && npm run build"
"crawl": "node --conditions development crawl.js",
"format": "remark --frail --output --quiet -- . && prettier . --log-level warn --write && xo --fix && stylelint src/index.css --fix",
"generate:script": "esbuild src/index.js --bundle --minify --outfile=dest/index.nomodule.js --target=es6 && esbuild src/index.js --bundle --format=esm --minify --outfile=dest/index.module.js --target=es2020",
"generate:structure": "rehype -u rehype-preset-minify -u rehype-prevent-favicon-request src -o dest",
"generate:style": "postcss src/index.css > dest/index.css",
"generate": "npm run generate:script && npm run generate:style && npm run generate:structure",
"test": "npm run crawl && npm run format && npm run generate"
},
"stylelint": {
"extends": [
"stylelint-config-standard",
"stylelint-config-prettier"
"stylelint-config-prettier",
"stylelint-config-standard"
]
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"type": "module",
"xo": {
"prettier": true,
"ignore": [
"src/fixtures.js",
"src/to-name.js"
]
},
"postcss": {
"plugins": {
"cssnano": {
"preset": "default"
}
}
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
}
}
16 changes: 8 additions & 8 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<html lang=en>
<meta charset=utf8>
<title>franc</title>
<meta property=og:title content=Franc>
<meta name=viewport content=width=device-width,initial-scale=1>
<meta name=description content="Natural language detection">
<meta property=og:description content="Natural language detection">
<meta property=og:image content=https://raw.githubusercontent.com/wooorm/franc/website/screenshot.png>
<link rel=stylesheet href=index.css>
<meta content=Franc property=og:title>
<meta content=width=device-width,initial-scale=1 name=viewport>
<meta content="Natural language detection" name=description>
<meta content="Natural language detection" property=og:description>
<meta content=https://raw.githubusercontent.com/wooorm/franc/website/screenshot.png property=og:image>
<link href=index.css rel=stylesheet>
<main>
<section class=highlight>
<h1><span class=hl>fr</span>anc</h1>
Expand Down Expand Up @@ -36,9 +36,9 @@ <h2>Probability</h2>
<a href=https://github.com/wooorm/franc/blob/website/license>MIT</a>
<a href=http://wooorm.com>@wooorm</a>
<a href=https://wooorm.com>@wooorm</a>
</p>
</section>
</main>
<script type=module src=index.module.js></script>
<script src=index.module.js type=module></script>
<script nomodule src=index.nomodule.js></script>

0 comments on commit f87ff9a

Please sign in to comment.