Skip to content

Commit 81efcaa

Browse files
committed
github workflow added to publish package
1 parent 17ee845 commit 81efcaa

File tree

8 files changed

+310
-214
lines changed

8 files changed

+310
-214
lines changed

.github/workflows/publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish Node.js Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Get code access
12+
uses: actions/checkout@v3
13+
- name: Setup node environment
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: 16
17+
- name: Install dependencies
18+
run: npm ci
19+
20+
publish-npm:
21+
needs: build
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Get code access
25+
uses: actions/checkout@v3
26+
- name: Setup node environment
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: 16
30+
registry-url: https://registry.npmjs.org/
31+
- name: Install dependencies
32+
run: npm ci
33+
- name: Publish package
34+
run: npm publish
35+
env:
36+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ junk
55
jest.config.jest
66
.prettierrc.json
77
.vscode
8-
.gitignore
8+
.gitignore
9+
.github

package-lock.json

Lines changed: 258 additions & 193 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "f1-api-node",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "A simple library written in typescript to fetch Formula-1 data",
55
"main": "dist/server.js",
66
"types": "dist/server.d.ts",

src/endpoints/endpoints.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ interface staticLinks {
55
}
66

77
interface dynamicLinks {
8-
driverStandings_1: string;
9-
driverStandings_2: string;
10-
constructorStandings_1: string;
11-
constructorStandings_2: string;
12-
results_1: string;
13-
results_2: string;
14-
fastestLap_1: string;
15-
fastestLap_2: string;
8+
rootLink: string;
9+
driverStandings: string;
10+
constructorStandings: string;
11+
results: string;
12+
fastestLap: string;
1613
}
1714

1815
export const staticLinks: staticLinks = {
@@ -22,12 +19,9 @@ export const staticLinks: staticLinks = {
2219
};
2320

2421
export const dynamicLinks: dynamicLinks = {
25-
driverStandings_1: "https://www.formula1.com/en/results.html",
26-
driverStandings_2: "drivers.html",
27-
constructorStandings_1: "https://www.formula1.com/en/results.html",
28-
constructorStandings_2: "team.html",
29-
results_1: "https://www.formula1.com/en/results.html",
30-
results_2: "races.html",
31-
fastestLap_1: "https://www.formula1.com/en/results.html",
32-
fastestLap_2: "fastest-laps.html",
22+
rootLink: "https://www.formula1.com/en/results.html",
23+
driverStandings: "drivers.html",
24+
constructorStandings: "team.html",
25+
results: "races.html",
26+
fastestLap: "fastest-laps.html",
3327
};

src/scraper/constructors-standings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const getConstructorStandings = async (year: number = new Date().getFullY
99
try {
1010
let constructorStandings: isConstructorStanding[] = [];
1111

12-
const response = await axios(`${dynamicLinks.constructorStandings_1}/${year}/${dynamicLinks.constructorStandings_2}`);
12+
const response = await axios(`${dynamicLinks.rootLink}/${year}/${dynamicLinks.constructorStandings}`);
1313
const $ = cheerio.load(response.data);
1414

1515
$("tr").each(function () {

src/scraper/driver-standings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const getDriverStandings = async (year: number = new Date().getFullYear()
99
try {
1010
let driverStandings: isDriverStanding[] = [];
1111

12-
const response = await axios(`${dynamicLinks.driverStandings_1}/${year}/${dynamicLinks.driverStandings_2}`);
12+
const response = await axios(`${dynamicLinks.rootLink}/${year}/${dynamicLinks.driverStandings}`);
1313
const $ = cheerio.load(response.data);
1414

1515
$("tr").each(function () {

src/scraper/race-results.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const getRaceResults = async (year: number): Promise<isRaceResult[]> => {
99
try {
1010
let raceResults: isRaceResult[] = [];
1111

12-
const response = await axios(`${dynamicLinks.results_1}/${year}/${dynamicLinks.results_2}`);
12+
const response = await axios(`${dynamicLinks.rootLink}/${year}/${dynamicLinks.results}`);
1313
const $ = cheerio.load(response.data);
1414

1515
$("tr").each(function () {

0 commit comments

Comments
 (0)