Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple fixes #161

Merged
merged 10 commits into from
Oct 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
test/
dist/
node_modules/
esm/
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build (CI)

on:
pull_request:
branches: [ master ]
types: [ opened, synchronize, closed ]
push:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 12.x, 14.x, 16.x ]

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

- name: Determine Yarn Cache Path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

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

- name: Install Packages
run: yarn install --frozen-lockfile

- name: Build
run: yarn build
env:
CI: true

- name: Test
run: yarn run test
env:
CI: true
47 changes: 47 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish

on:
push:
tags:
- v*.*.*

jobs:
publish:
runs-on: ubuntu-latest

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

- name: Setup Node.js 12.x to publish to npmjs.org
uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'

- name: Install Packages
run: yarn install --frozen-lockfile

- name: Build
run: yarn build
env:
CI: true

- name: Test
run: yarn run test
env:
CI: true

- name: Generate Release Body
run: npx extract-changelog-release > RELEASE_BODY.md

- name: Publish to NPM
run: yarn publish --non-interactive
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
bodyFile: "RELEASE_BODY.md"
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .mocharc.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require: blanket,should,spec
require: blanket,should,spec,"ts-node/register"
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Fast HTML Parser [![NPM version](https://badge.fury.io/js/node-html-parser.png)](http://badge.fury.io/js/node-html-parser) [![Build Status](https://travis-ci.org/taoqf/node-html-parser.svg?branch=master)](https://travis-ci.org/taoqf/node-html-parser)
# Fast HTML Parser [![NPM version](https://badge.fury.io/js/node-html-parser.png)](http://badge.fury.io/js/node-html-parser) [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Ftaoqf%2Fnode-html-parser%2Fbadge%3Fref%3Dmaster&style=flat)](https://actions-badge.atrox.dev/taoqf/node-html-parser/goto?ref=master)

Fast HTML Parser is a _very fast_ HTML parser. Which will generate a simplified
DOM tree, with element query support.
Expand Down Expand Up @@ -78,7 +78,7 @@ Parse given data, and return root of the generated DOM.
```js
{
lowerCaseTagName: false, // convert tag name to lower case (hurt performance heavily)
comment: false // retrieve comments (hurt performance slightly)
comment: false, // retrieve comments (hurt performance slightly)
blockTextElements: {
script: true, // keep text content when parsing
noscript: true, // keep text content when parsing
Expand Down
11 changes: 11 additions & 0 deletions esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import nhp from '../dist/index.js'

export const CommentNode = nhp.CommentNode;
export const HTMLElement = nhp.HTMLElement;
export const parse = nhp.parse;
export const valid = nhp.valid;
export const Node = nhp.Node;
export const TextNode = nhp.TextNode;
export const NodeType = nhp.NodeType;

export default nhp;
3 changes: 3 additions & 0 deletions esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
34 changes: 22 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
"version": "4.1.5",
"description": "A very fast HTML parser, generating a simplified DOM, with basic element query support.",
"main": "dist/index.js",
"module": "dist/esm/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "mocha",
"compile": "tsc",
"build": "npm run lint && npm run clean && npm run compile:cjs && npm run compile:amd",
"compile:cjs": "tsc -m commonjs",
"compile:amd": "tsc -t es5 -m amd -d false --outFile ./dist/main.js",
"---------------": "",
"test": "mocha ./test/tests/**/*.js",
"test:src": "cross-env TEST_TARGET=src mocha ./test/tests",
"test:dist": "cross-env TEST_TARGET=dist mocha ./test/tests",
"benchmark": "node ./test/benchmark/compare.mjs",
"--------------- ": "",
"lint": "eslint ./src/*.ts ./src/**/*.ts",
"clean": "del-cli ./dist/",
"ts:cjs": "tsc -m commonjs",
"ts:amd": "tsc -t es5 -m amd -d false --outFile ./dist/main.js",
"ts:esm": "tsc -t es2019 -m esnext -d false --outDir ./dist/esm/",
"build": "npm run lint && npm run clean && npm run ts:cjs && npm run ts:amd && npm run ts:esm",
"dev": "tsc -w & mocha -w ./test/*.js",
"pretest": "tsc -m commonjs",
"release": "yarn build && np",
"prepare": "npm run build"
"--------------- ": "",
"posttest": "yarn run benchmark",
"prepare": "cd test && yarn install"
Comment on lines -19 to +22
Copy link

@milahu milahu Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove the npm run build prepare script?
this is required for "install from git" (#125), cd test && yarn install is not

fixed in #253

},
"keywords": [
"parser",
Expand Down Expand Up @@ -59,8 +62,11 @@
"parse5": "^6.0.1",
"should": "latest",
"spec": "latest",
"standard-version": "^9.3.1",
"travis-cov": "latest",
"typescript": "next"
"ts-node": "^10.2.1",
"typescript": "latest",
"cross-env": "^7.0.3"
},
"config": {
"blanket": {
Expand All @@ -84,5 +90,9 @@
"url": "https://github.com/taoqf/node-fast-html-parser/issues"
},
"homepage": "https://github.com/taoqf/node-fast-html-parser",
"sideEffects": false
"sideEffects": false,
"exports": {
"require": "./dist/index.js",
"import": "./esm/index.js"
}
}
Loading