Skip to content

Commit ee535ec

Browse files
authored
Improve GH Pages, publish to GH Pages with GH Action (#51)
1 parent 77f3675 commit ee535ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+36455
-65
lines changed

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/tests/ export-ignore
21
/.* export-ignore
2+
/gh-pages/ export-ignore
3+
/tests/ export-ignore
34
/README.md export-ignore
45
/phpunit.xml export-ignore

.github/workflows/gh-pages.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags-ignore:
8+
- "**"
9+
workflow_dispatch:
10+
inputs:
11+
recreate-json:
12+
description: 'Re-create JSON files'
13+
type: boolean
14+
15+
permissions:
16+
contents: write
17+
pages: write
18+
id-token: write
19+
20+
jobs:
21+
publish:
22+
name: Build
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
- name: Delete existing JSON files
28+
if: github.event.inputs.recreate-json
29+
run: rm -rf gh-pages/public/data/versions
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: 22
34+
cache: npm
35+
cache-dependency-path: gh-pages/package-lock.json
36+
- name: Install dependencies
37+
working-directory: gh-pages
38+
run: npm ci
39+
- name: Check coding style
40+
working-directory: gh-pages
41+
run: npm run lint:check
42+
- name: Build
43+
run: npm run build
44+
- name: Setup Pages
45+
uses: actions/configure-pages@v5
46+
- name: Upload artifact
47+
uses: actions/upload-pages-artifact@v3
48+
with:
49+
path: gh-pages/dist
50+
- name: Deploy to GitHub Pages
51+
id: deployment
52+
uses: actions/deploy-pages@v4

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
- main
1010
tags-ignore:
1111
- "**"
12+
paths-ignore:
13+
- .github/workflows/gh-pages.yml
14+
- "gh-pages/**"
1215
pull_request:
1316
branches:
1417
- main

gh-pages/.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/dist/
2+
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
pnpm-debug.log*
10+
lerna-debug.log*
11+
12+
node_modules
13+
dist
14+
dist-ssr
15+
*.local
16+
17+
# Editor directories and files
18+
.vscode/*
19+
!.vscode/extensions.json
20+
.idea
21+
.DS_Store
22+
*.suo
23+
*.ntvs*
24+
*.njsproj
25+
*.sln
26+
*.sw?

gh-pages/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/public/

gh-pages/.prettierrc.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# See https://prettier.io/docs/options
2+
printWidth: 80
3+
tabWidth: 2
4+
useTabs: false
5+
semi: true
6+
singleQuote: true
7+
quoteProps: as-needed
8+
jsxSingleQuote: false
9+
trailingComma: all
10+
bracketSpacing: false
11+
bracketSameLine: false
12+
arrowParens: always
13+
vueIndentScriptAndStyle: false
14+
endOfLine: lf
15+
singleAttributePerLine: false

gh-pages/.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["Vue.volar", "esbenp.prettier-vscode"]
3+
}

gh-pages/.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnPaste": true,
4+
"editor.formatOnSave": true,
5+
"[yaml]": {
6+
"editor.defaultFormatter": "esbenp.prettier-vscode"
7+
}
8+
}

gh-pages/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Development
2+
3+
### Install dependencies (keeping the configured one)
4+
5+
```sh
6+
npm ci
7+
```
8+
9+
### Install dependencies (updating to the latest available versions)
10+
11+
```sh
12+
npm install
13+
```
14+
15+
### Build for development
16+
17+
```sh
18+
npm run dev
19+
```
20+
21+
### Checking coding style
22+
23+
```sh
24+
npm run lint:check
25+
```
26+
27+
### Fixing coding style
28+
29+
```sh
30+
npm run lint:fix
31+
```
32+
33+
### Build for production
34+
35+
```sh
36+
npm run build
37+
```
38+
39+
### Preview the app built for production
40+
41+
```sh
42+
npm run preview
43+
```

gh-pages/bin/create-cldr-data.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import child_process from 'node:child_process';
2+
import fs from 'node:fs';
3+
import path from 'node:path';
4+
import {fileURLToPath} from 'node:url';
5+
6+
const PROJECT_ROOT = path
7+
.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..')
8+
.replaceAll(path.sep, '/')
9+
.replace(/\/$/, '');
10+
11+
const DATADIR =
12+
path
13+
.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
14+
.replaceAll(path.sep, '/')
15+
.replace(/\/$/, '') + '/public/data';
16+
17+
const VERSIONS = JSON.parse(fs.readFileSync(`${DATADIR}/versions.json`));
18+
if (!fs.existsSync(`${DATADIR}/versions`)) {
19+
fs.mkdirSync(`${DATADIR}/versions`);
20+
}
21+
22+
for (let version of VERSIONS) {
23+
const outputFileCompressed = `${DATADIR}/versions/${version}.min.json`;
24+
const outputFileUncompressed = `${DATADIR}/versions/${version}.json`;
25+
if (
26+
fs.existsSync(outputFileCompressed) &&
27+
fs.existsSync(outputFileUncompressed)
28+
) {
29+
continue;
30+
}
31+
process.stdout.write(`# Creating data for version ${version}\n`);
32+
const importer = child_process.spawn(
33+
'php',
34+
[`${PROJECT_ROOT}/bin/import-cldr-data`, version],
35+
{
36+
stdio: [
37+
// stdin
38+
'ignore',
39+
// stout
40+
'inherit',
41+
// stderr
42+
'inherit',
43+
],
44+
},
45+
);
46+
await new Promise((resolve, reject) => {
47+
importer.on('close', (code) => {
48+
if (code === 0) {
49+
resolve();
50+
} else {
51+
reject(new Error(`Child process exited with code ${code}`));
52+
}
53+
});
54+
});
55+
process.stdout.write('Creating json files\n');
56+
for (let compressed of [false, true]) {
57+
const outputFile = compressed
58+
? outputFileCompressed
59+
: outputFileUncompressed;
60+
const exporter = child_process.spawn(
61+
'php',
62+
[
63+
`${PROJECT_ROOT}/bin/export-plural-rules`,
64+
`--output=${outputFile}`,
65+
compressed ? 'json' : 'prettyjson',
66+
],
67+
{
68+
stdio: [
69+
// stdin
70+
'ignore',
71+
// stout
72+
'inherit',
73+
// stderr
74+
'inherit',
75+
],
76+
},
77+
);
78+
await new Promise((resolve, reject) => {
79+
exporter.on('close', (code) => {
80+
if (code === 0) {
81+
resolve();
82+
} else {
83+
reject(new Error(`Child process exited with code ${code}`));
84+
}
85+
});
86+
});
87+
}
88+
}

0 commit comments

Comments
 (0)