-
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
- Loading branch information
1 parent
c497d9e
commit d5231c4
Showing
15 changed files
with
493 additions
and
5 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
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,6 @@ | ||
## .env | ||
generate-environment-type-definition: | ||
pnpm vite-node script/type-def.ts | ||
|
||
generate-data: | ||
pnpm vite-node script/data.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,15 @@ | ||
{ | ||
"name": "@periotable/data", | ||
"version": "0.0.0", | ||
"author": "PoolOfDeath20", | ||
"private": true, | ||
"license": "GPL", | ||
"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,36 @@ | ||
import fs from 'fs'; | ||
|
||
import { Octokit } from 'octokit'; | ||
|
||
import dotenv from 'dotenv'; | ||
|
||
import axios from 'axios'; | ||
|
||
const main = async () => { | ||
dotenv.config(); | ||
|
||
const octokit = new Octokit({ | ||
auth: process.env.TOKEN, | ||
}); | ||
|
||
const result = await octokit.rest.repos.getContent({ | ||
owner: process.env.OWNER, | ||
repo: process.env.REPO, | ||
path: 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.