-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor(periodic-data): extract periodic data into separate package * ci(*): set up proper ci * fix(ci): fix faulty commands and its order * fix(ci/generate-data): pass `secrets` as environment variables * fix(ci/command): fix `Unrecognized named-value: 'secrests'` * fix(apps/web/lint): fix `knip` lint issue * fix(ci): generated web stuffs * fix(ci): generate schema and images * fix(ci/run): split command * fix(ci/run): chain command with two ampersand * fix(apps/web/schema): create directory if not created before writing schema * fix(ci): generated web page instead of web stuffs * fix(ci): generate web pages first before schema * fix(apps/web): generate dummy schema file before generating real one to solve chicken and egg problem * fix(apps/web): terminate schema generation upon completion * fix(packages/data): added `typecheck` command * fix(packages/data): parse environment variables as string * fix(apps/data): added format commands * fix(apps/web): formatted all files with `prettier` * fix(apps/web): ignore cache * fix(apps/web): fixed `pretest-ci` puppeteer installation command * test(apps/web): increase snapshot timeout * test(apps/web): reduce number of test files during CI
- Loading branch information
1 parent
c497d9e
commit 412b3d3
Showing
23 changed files
with
608 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
import fs from 'fs'; | ||
|
||
import { generatePaths } from '../../test/snapshot/data'; | ||
const main = async () => { | ||
if (!fs.existsSync('src/web/generated')) { | ||
fs.mkdirSync('src/web/generated'); | ||
} | ||
|
||
const main = () => { | ||
const paths = generatePaths(); | ||
// create a dummy file to solve chicken and egg problem | ||
fs.writeFileSync( | ||
'src/web/generated/schema.ts', | ||
`const paths = [] as ReadonlyArray<string>\n; export default paths;` | ||
); | ||
|
||
const paths = await import('../../test/snapshot/data').then((data) => { | ||
return data.generatePaths(); | ||
}); | ||
|
||
fs.writeFileSync( | ||
'src/web/generated/schema.ts', | ||
`const paths = ${JSON.stringify(paths, undefined, 4)}; export default paths;` | ||
`const paths = ${JSON.stringify(paths, undefined, 4)}\n; export default paths;` | ||
); | ||
|
||
process.exit(0); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
index.ts | ||
.env | ||
env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
index.ts | ||
.env | ||
env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# .env | ||
generate-environment-type-definition: | ||
pnpm vite-node script/type-def.ts | ||
|
||
generate-data: | ||
pnpm vite-node script/data.ts | ||
|
||
# format | ||
format: | ||
pnpm prettier --$(type) . | ||
|
||
format-check: | ||
make format type=check | ||
|
||
format-write: | ||
make format type=write | ||
|
||
# typecheck | ||
typecheck: | ||
pnpm tsc -p tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "@periotable/data", | ||
"version": "0.0.0", | ||
"author": "PoolOfDeath20", | ||
"private": true, | ||
"license": "GPL", | ||
"scripts": { | ||
"format-check": "make format-check", | ||
"format-write": "make format-write", | ||
"typecheck": "make typecheck" | ||
}, | ||
"devDependencies": { | ||
"@poolofdeath20/tsconfig": "^0.0.0", | ||
"axios": "^1.6.8", | ||
"dotenv": "^16.4.5", | ||
"gen-env-type-def": "^0.0.4", | ||
"octokit": "^3.2.0", | ||
"vite-node": "^1.4.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import fs from 'fs'; | ||
|
||
import { Octokit } from 'octokit'; | ||
|
||
import dotenv from 'dotenv'; | ||
|
||
import axios from 'axios'; | ||
|
||
const asString = <Str extends string>(string: Str | undefined) => { | ||
if (string) { | ||
return string; | ||
} | ||
|
||
throw new Error(''); | ||
}; | ||
|
||
const main = async () => { | ||
dotenv.config(); | ||
|
||
const octokit = new Octokit({ | ||
auth: process.env.TOKEN, | ||
}); | ||
|
||
const result = await octokit.rest.repos.getContent({ | ||
owner: asString(process.env.OWNER), | ||
repo: asString(process.env.REPO), | ||
path: asString(process.env.DATA_PATH), | ||
}); | ||
|
||
// @ts-expect-error: Download URL exists because data is of type "file" but it doesn't have type | ||
const url = result.data.download_url as string; | ||
|
||
const content = await axios.get(url).then((response) => { | ||
if (typeof response.data !== 'string') { | ||
throw new Error('Data is not a string'); | ||
} | ||
|
||
return response.data; | ||
}); | ||
|
||
fs.writeFileSync('index.ts', content); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { genEnvTypeDef } from 'gen-env-type-def'; | ||
|
||
const main = () => { | ||
genEnvTypeDef([ | ||
{ | ||
inDir: '.', | ||
envType: 'process.env', | ||
}, | ||
]); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": ["@poolofdeath20/tsconfig/node"], | ||
"include": ["*.d.ts", "**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
Oops, something went wrong.