Skip to content

Commit

Permalink
refactor: cleanup and migrate to new build system
Browse files Browse the repository at this point in the history
  • Loading branch information
rocktimsaikia committed Jan 27, 2024
1 parent 1556ee6 commit 7be5556
Show file tree
Hide file tree
Showing 17 changed files with 2,364 additions and 4,968 deletions.
11 changes: 0 additions & 11 deletions .editorconfig

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

37 changes: 23 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
name: CI
on: [push]

on:
push:
branches: [main, develop]
pull_request:
branches: [main]

jobs:
build:
name: lint, and test with Node ${{ matrix.node }} on ubuntu-latest

runs-on: ubuntu-latest
environment: actions

strategy:
matrix:
node: ['10.x', '12.x', '14.x']
node-version: [16.x, 18.x, 19.x, 20.x]

steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v4

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
- name: Install Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.node-version }}

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Lint
run: yarn lint
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Test
- name: Run the tests
run: pnpm test
run: yarn test --ci --coverage --maxWorkers=2
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# meta-fetcher

![npm](https://img.shields.io/npm/v/meta-fetcher?style=flat&color=success&logo=npm)

Simple metadata scrapper.

## Installation

```sh
yarn add meta-fetcher
```

## Usage

```js
import metaFetcher from 'meta-fetcher';

const result = await metaFetcher('https://hoppscotch.io/');

console.log(result);
```

Output:

```json
{
"title": "Hoppscotch - Open source API development ecosystem",
"description": "Helps you create requests faster, saving precious time on development.",
"image": "https://hoppscotch.io/og.png",
"url": "https://hoppscotch.io/",
"siteName": "Hoppscotch",
"type": "website"
}
```

## API

### metaFetcher(input)

Takes one url string as a parameter and returns an object containing the meta-information.

#### input

type: `string` \
default: `'none'`

The url string to be scrapped.

## Related

[**page-scrapper**](https://github.com/rocktimsaikia/page-scrapper): Node.js scrapper that pulls out all links and images of a given site.

## License

2024 [MIT](https://choosealicense.com/licenses/mit/) © [Rocktim Saikia](https://rocktimsaikia.dev)
126 changes: 53 additions & 73 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,75 +1,55 @@
{
"name": "meta-fetcher",
"version": "3.1.1",
"description": "simple metadata scrapper for node.js",
"keywords": [
"meta-fetcher",
"url-metadata",
"url-metadata-scrapper",
"metadata-scrapper",
"website-metadata",
"website-metadata-scrapper",
"metadata",
"scrapper"
],
"repository": "rocktimsaikia/meta-fetcher",
"funding": "https://www.buymeacoffee.com/rocktimcodes",
"license": "MIT",
"author": {
"name": "Rocktim Saikia",
"email": "[email protected]",
"url": "https://rocktimcodes.site"
},
"main": "dist/index.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"files": [
"dist",
"src"
],
"scripts": {
"prebuild": "rm -rf dist",
"build": "rollup --config",
"lint": "eslint .",
"test": "jest",
"postversion": "git push && git push --tags",
"prepublishOnly": "npm run lint && yarn test && yarn build"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint && npm run test"
}
},
"prettier": {
"printWidth": 80,
"semi": true,
"singleQuote": true,
"trailingComma": "es5"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node"
},
"dependencies": {
"cheerio": "^1.0.0-rc.6",
"isomorphic-unfetch": "^3.1.0"
},
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/node": "^15.0.1",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"eslint": "^7.25.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"husky": "4",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"rollup": "^2.46.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"ts-jest": "^26.5.5",
"tslib": "^2.2.0",
"typescript": "^4.2.4"
}
"name": "my-npm-package",
"description": "Get country information via currency code",
"version": "0.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"files": [
"dist"
],
"license": "MIT",
"author": {
"email": "[email protected]",
"name": "Rocktim Saikia",
"url": "https://rocktimsaikia.dev"
},
"funding": "https://github.com/sponsors/rocktimsaikia",
"repository": "rocktimsaikia/my-npm-package",
"scripts": {
"build": "tsup",
"test": "pnpm build && ava",
"release": "pnpm test && np --no-tests"
},
"dependencies": {
"cheerio": "1.0.0-rc.12",
"node-fetch": "^3.3.2"
},
"devDependencies": {
"@rocktimsaikia/prettier-config": "^1.0.4",
"@types/node": "^17.0.23",
"ava": "^4.2.0",
"tsup": "^5.12.4",
"tsx": "^4.7.0",
"typescript": "^4.6.3"
},
"np": {
"contents": "dist"
},
"keywords": [
"my-npm-package"
],
"prettier": "@rocktimsaikia/prettier-config",
"tsup": {
"entry": [
"src/index.ts"
],
"format": [
"cjs",
"esm"
],
"minify": true,
"clean": true,
"dts": true
}
}
Loading

0 comments on commit 7be5556

Please sign in to comment.