chore: updating dependencies and node versions

* Updated supported Node.js versions

Dropped support for 14 and 16 in favor of the current LTS versions 18
and 20.

* Updated Node.js dependencies

Bumped nearly all dependencies to the latest. The exception being
`node-fetch` which made the jump to using ESM which is still causing
folks a lot of grief.

* Shored code coverage back up to 100%

Had some remnants from when this library did sanity checks pre-flight to
the API that required additional tests to cover them, or just adjusting
the argument defaults.

* Removed the "build" badge from the README

Seems there were some gotchas with that badge that makes it kind of a
pain, as it has to be hard coded a certain way. I messed with it and
couldn't get it working, seems like more trouble than it's worth.

Further details: https://github.com/badges/shields/issues/8671

* Added .nvmrc file

Pretty self explanatory.

* Bumped version number

Lucky number 7, y'all!
This commit is contained in:
Josh Sherman 2023-10-25 20:55:27 -05:00
parent 5a62ac8b5f
commit 250fb4b4e9
8 changed files with 2242 additions and 6455 deletions

View file

@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node-version: ['14', '16'] node-version: ['18', '20']
steps: steps:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -25,7 +25,7 @@ jobs:
- name: Run Tests - name: Run Tests
run: npm run test:coverage run: npm run test:coverage
- name: Upload Coverage - name: Upload Coverage
if: ${{ matrix.node-version == '16' }} if: ${{ matrix.node-version == '20' }}
uses: codecov/codecov-action@v1 uses: codecov/codecov-action@v1
with: with:
file: ./coverage/lcov.info file: ./coverage/lcov.info

1
.nvmrc Normal file
View file

@ -0,0 +1 @@
v20

View file

@ -2,7 +2,6 @@
[![License](https://img.shields.io/npm/l/holidayapi-node?style=for-the-badge)](https://github.com/holidayapi/holidayapi-node/blob/master/LICENSE) [![License](https://img.shields.io/npm/l/holidayapi-node?style=for-the-badge)](https://github.com/holidayapi/holidayapi-node/blob/master/LICENSE)
![Node Version](https://img.shields.io/node/v/holidayapi?style=for-the-badge) ![Node Version](https://img.shields.io/node/v/holidayapi?style=for-the-badge)
[![Test Status](https://img.shields.io/github/workflow/status/holidayapi/holidayapi-node/Test?style=for-the-badge)](https://github.com/holidayapi/holidayapi-node/actions)
[![Code Coverage](https://img.shields.io/codecov/c/github/holidayapi/holidayapi-node?style=for-the-badge)](https://codecov.io/gh/holidayapi/holidayapi-node) [![Code Coverage](https://img.shields.io/codecov/c/github/holidayapi/holidayapi-node?style=for-the-badge)](https://codecov.io/gh/holidayapi/holidayapi-node)
Official Node.js library for [Holiday API](https://holidayapi.com) providing Official Node.js library for [Holiday API](https://holidayapi.com) providing

5
dist/holidayapi.js vendored
View file

@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
function verb(n) { return function (v) { return step([n, v]); }; } function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) { function step(op) {
if (f) throw new TypeError("Generator is already executing."); if (f) throw new TypeError("Generator is already executing.");
while (_) try { while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value]; if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) { switch (op[0]) {
@ -109,7 +109,6 @@ var HolidayAPI = (function () {
}); });
}; };
HolidayAPI.prototype.holidays = function (request) { HolidayAPI.prototype.holidays = function (request) {
if (request === void 0) { request = {}; }
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) { return __generator(this, function (_a) {
return [2, this.request('holidays', request)]; return [2, this.request('holidays', request)];
@ -124,7 +123,6 @@ var HolidayAPI = (function () {
}); });
}; };
HolidayAPI.prototype.workday = function (request) { HolidayAPI.prototype.workday = function (request) {
if (request === void 0) { request = {}; }
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) { return __generator(this, function (_a) {
return [2, this.request('workday', request)]; return [2, this.request('workday', request)];
@ -132,7 +130,6 @@ var HolidayAPI = (function () {
}); });
}; };
HolidayAPI.prototype.workdays = function (request) { HolidayAPI.prototype.workdays = function (request) {
if (request === void 0) { request = {}; }
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) { return __generator(this, function (_a) {
return [2, this.request('workdays', request)]; return [2, this.request('workdays', request)];

32
dist/types.d.ts vendored
View file

@ -1,19 +1,19 @@
export declare type Endpoint = 'countries' | 'holidays' | 'languages' | 'workday' | 'workdays'; export type Endpoint = 'countries' | 'holidays' | 'languages' | 'workday' | 'workdays';
export declare type Weekday = { export type Weekday = {
name: 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday' | 'Sunday'; name: 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday' | 'Sunday';
numeric: 1 | 2 | 3 | 4 | 5 | 6 | 7; numeric: 1 | 2 | 3 | 4 | 5 | 6 | 7;
}; };
declare type Request = { type Request = {
format?: 'csv' | 'json' | 'php' | 'tsv' | 'xml' | 'yaml'; format?: 'csv' | 'json' | 'php' | 'tsv' | 'xml' | 'yaml';
key?: string; key?: string;
pretty?: boolean; pretty?: boolean;
search?: string; search?: string;
}; };
export declare type CountriesRequest = Request & { export type CountriesRequest = Request & {
country?: string; country?: string;
public?: boolean; public?: boolean;
}; };
export declare type HolidaysRequest = Request & { export type HolidaysRequest = Request & {
country?: string; country?: string;
day?: number; day?: number;
language?: string; language?: string;
@ -24,20 +24,20 @@ export declare type HolidaysRequest = Request & {
upcoming?: boolean; upcoming?: boolean;
year?: number; year?: number;
}; };
export declare type LanguagesRequest = Request & { export type LanguagesRequest = Request & {
language?: string; language?: string;
}; };
export declare type WorkdayRequest = Request & { export type WorkdayRequest = Request & {
country?: string; country?: string;
start?: string; start?: string;
days?: number; days?: number;
}; };
export declare type WorkdaysRequest = Request & { export type WorkdaysRequest = Request & {
country?: string; country?: string;
start?: string; start?: string;
end?: string; end?: string;
}; };
export declare type Response = { export type Response = {
requests: { requests: {
available: number; available: number;
resets: string; resets: string;
@ -46,7 +46,7 @@ export declare type Response = {
status: number; status: number;
error?: string; error?: string;
}; };
export declare type CountriesResponse = Response & { export type CountriesResponse = Response & {
countries?: { countries?: {
code: string; code: string;
codes: { codes: {
@ -68,7 +68,7 @@ export declare type CountriesResponse = Response & {
}; };
}[]; }[];
}; };
export declare type HolidaysResponse = Response & { export type HolidaysResponse = Response & {
holidays?: { holidays?: {
country: string; country: string;
date: string; date: string;
@ -79,21 +79,21 @@ export declare type HolidaysResponse = Response & {
subdivisions?: string[]; subdivisions?: string[];
}[]; }[];
}; };
export declare type LanguagesResponse = Response & { export type LanguagesResponse = Response & {
languages?: { languages?: {
code: string; code: string;
name: string; name: string;
}[]; }[];
}; };
export declare type WorkdayResponse = Response & { export type WorkdayResponse = Response & {
workday?: { workday?: {
date: string; date: string;
weekday: Weekday; weekday: Weekday;
}; };
}; };
export declare type WorkdaysResponse = Response & { export type WorkdaysResponse = Response & {
workdays?: number; workdays?: number;
}; };
export declare type Requests = (CountriesRequest | HolidaysRequest | LanguagesRequest | WorkdayRequest | WorkdaysRequest); export type Requests = (CountriesRequest | HolidaysRequest | LanguagesRequest | WorkdayRequest | WorkdaysRequest);
export declare type Responses = (CountriesResponse | HolidaysResponse | LanguagesResponse | WorkdayResponse | WorkdaysResponse); export type Responses = (CountriesResponse | HolidaysResponse | LanguagesResponse | WorkdayResponse | WorkdaysResponse);
export {}; export {};

8624
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{ {
"name": "holidayapi", "name": "holidayapi",
"version": "6.0.1", "version": "7.0.0",
"description": "Official Node.js library for Holiday API", "description": "Official Node.js library for Holiday API",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
@ -21,26 +21,26 @@
}, },
"homepage": "https://holidayapi.com", "homepage": "https://holidayapi.com",
"engines": { "engines": {
"node": ">= 14.0.0" "node": ">= 18.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^27.4.1", "@types/jest": "^29.5.6",
"@types/nock": "^11.1.0", "@types/nock": "^11.1.0",
"@types/node": "^17.0.23", "@types/node": "^20.8.9",
"@types/node-fetch": "^2.6.1", "@types/node-fetch": "^2.6.7",
"@typescript-eslint/eslint-plugin": "^5.18.0", "@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^5.18.0", "@typescript-eslint/parser": "^6.9.0",
"eslint": "^8.12.0", "eslint": "^8.12.0",
"eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.1.3", "eslint-plugin-jest": "^27.4.3",
"jest": "^27.5.1", "jest": "^29.7.0",
"nock": "^13.2.4", "nock": "^13.2.4",
"ts-jest": "^27.1.4", "ts-jest": "^29.1.1",
"typescript": "^4.6.3" "typescript": "^5.2.2"
}, },
"dependencies": { "dependencies": {
"node-fetch": "^2" "node-fetch": "^2.7.0"
}, },
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",

View file

@ -75,7 +75,7 @@ export class HolidayAPI {
return this.request('countries', request); return this.request('countries', request);
} }
async holidays(request: HolidaysRequest = {}): Promise<HolidaysResponse> { async holidays(request?: HolidaysRequest): Promise<HolidaysResponse> {
return this.request('holidays', request); return this.request('holidays', request);
} }
@ -83,11 +83,11 @@ export class HolidayAPI {
return this.request('languages', request); return this.request('languages', request);
} }
async workday(request: WorkdayRequest = {}): Promise<WorkdayResponse> { async workday(request?: WorkdayRequest): Promise<WorkdayResponse> {
return this.request('workday', request); return this.request('workday', request);
} }
async workdays(request: WorkdaysRequest = {}): Promise<WorkdaysResponse> { async workdays(request?: WorkdaysRequest): Promise<WorkdaysResponse> {
return this.request('workdays', request); return this.request('workdays', request);
} }
} }