Skip to content

Commit

Permalink
github workflow added to publish package
Browse files Browse the repository at this point in the history
  • Loading branch information
yashkathe committed Dec 28, 2022
1 parent 17ee845 commit 81efcaa
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 214 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Get code access
uses: actions/checkout@v3
- name: Setup node environment
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: npm ci

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- name: Get code access
uses: actions/checkout@v3
- name: Setup node environment
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci
- name: Publish package
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ junk
jest.config.jest
.prettierrc.json
.vscode
.gitignore
.gitignore
.github
451 changes: 258 additions & 193 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "f1-api-node",
"version": "0.2.0",
"version": "0.2.1",
"description": "A simple library written in typescript to fetch Formula-1 data",
"main": "dist/server.js",
"types": "dist/server.d.ts",
Expand Down
26 changes: 10 additions & 16 deletions src/endpoints/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ interface staticLinks {
}

interface dynamicLinks {
driverStandings_1: string;
driverStandings_2: string;
constructorStandings_1: string;
constructorStandings_2: string;
results_1: string;
results_2: string;
fastestLap_1: string;
fastestLap_2: string;
rootLink: string;
driverStandings: string;
constructorStandings: string;
results: string;
fastestLap: string;
}

export const staticLinks: staticLinks = {
Expand All @@ -22,12 +19,9 @@ export const staticLinks: staticLinks = {
};

export const dynamicLinks: dynamicLinks = {
driverStandings_1: "https://www.formula1.com/en/results.html",
driverStandings_2: "drivers.html",
constructorStandings_1: "https://www.formula1.com/en/results.html",
constructorStandings_2: "team.html",
results_1: "https://www.formula1.com/en/results.html",
results_2: "races.html",
fastestLap_1: "https://www.formula1.com/en/results.html",
fastestLap_2: "fastest-laps.html",
rootLink: "https://www.formula1.com/en/results.html",
driverStandings: "drivers.html",
constructorStandings: "team.html",
results: "races.html",
fastestLap: "fastest-laps.html",
};
2 changes: 1 addition & 1 deletion src/scraper/constructors-standings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const getConstructorStandings = async (year: number = new Date().getFullY
try {
let constructorStandings: isConstructorStanding[] = [];

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

$("tr").each(function () {
Expand Down
2 changes: 1 addition & 1 deletion src/scraper/driver-standings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const getDriverStandings = async (year: number = new Date().getFullYear()
try {
let driverStandings: isDriverStanding[] = [];

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

$("tr").each(function () {
Expand Down
2 changes: 1 addition & 1 deletion src/scraper/race-results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const getRaceResults = async (year: number): Promise<isRaceResult[]> => {
try {
let raceResults: isRaceResult[] = [];

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

$("tr").each(function () {
Expand Down

0 comments on commit 81efcaa

Please sign in to comment.