Skip to content

Commit

Permalink
release: v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Aug 5, 2024
1 parent 59dfe51 commit 28fbc07
Show file tree
Hide file tree
Showing 15 changed files with 575 additions and 512 deletions.
14 changes: 0 additions & 14 deletions .eslintrc.js

This file was deleted.

14 changes: 14 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"env": {
"browser": true,
"es6": true,
"amd": true,
"commonjs": true
},
"extends": "eslint:recommended",
"rules": {
"indent": ["error", 2],
"quotes": ["error", "single"],
"no-extra-semi": "off"
}
}
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ko_fi: surunzi
open_collective: eruda
27 changes: 27 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
workflow_dispatch:
push:
branches:
- 'master'
paths:
- 'src/**/*'

jobs:
ci:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm i
- run: npm run ci
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish to NPM

on:
workflow_dispatch:
release:
types: [created]

jobs:
publish:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Build eruda-features
run: |
npm i
npm run build
- name: Publish package on NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules/
eruda-features.js
eruda-features.js.map
eruda-features.js.map
package-lock.json
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/src/modernizr.js
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v2.1.0 (5 Aug 2024)

* feat: remove html5test link

## v2.0.0 (5 Jan 2020)

* feat: theme support
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# eruda-features

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Build status][ci-image]][ci-url]
[![License][license-image]][npm-url]

[npm-image]: https://img.shields.io/npm/v/eruda-features.svg
[npm-url]: https://npmjs.org/package/eruda-features
[travis-image]: https://img.shields.io/travis/liriliri/eruda-features.svg
[travis-url]: https://travis-ci.org/liriliri/eruda-features
[ci-image]: https://img.shields.io/github/actions/workflow/status/liriliri/eruda-features/main.yml?branch=master&style=flat-square
[ci-url]: https://github.com/liriliri/eruda-features/actions/workflows/main.yml
[license-image]: https://img.shields.io/npm/l/eruda-features.svg

Eruda plugin for browser feature detections, thanks to [modernizr](https://github.com/Modernizr/Modernizr) project.
Expand All @@ -17,7 +17,7 @@ Red means unsupported, otherwise ok. All buttons is linked directly to related m
## Demo

Browse it on your phone:
[http://eruda.liriliri.io/](http://eruda.liriliri.io/)
[https://eruda.liriliri.io/?plugin=features](https://eruda.liriliri.io/?plugin=features)

## Install

Expand Down
63 changes: 34 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
{
"name": "eruda-features",
"version": "2.0.0",
"description": "Eruda plugin for browser feature detections",
"version": "2.1.0",
"main": "eruda-features.js",
"description": "Eruda plugin for browser feature detections",
"browserslist": [
"since 2015",
"not dead"
],
"files": [
"eruda-features.js",
"eruda-features.js.map"
],
"scripts": {
"dev": "webpack-dev-server --host 0.0.0.0",
"build": "webpack && webpack -p",
"ci": "npm run lint && npm run build",
"dev": "webpack-dev-server --host 0.0.0.0 --mode development",
"build": "webpack --mode production",
"ci": "npm run lint && npm run build && npm run es5",
"lint": "eslint src/**/*.js",
"format": "prettier src/index.js src/style.scss *.js .*.js --write",
"buildModernizr": "node script/buildModernizr"
},
"repository": {
"type": "git",
"url": "git+https://github.com/liriliri/eruda-features.git"
"format": "lsla prettier \"src/*.{js,scss}\" \"*.json\" --write",
"buildModernizr": "node script/buildModernizr",
"es5": "es-check es5 eruda-features.js"
},
"keywords": [
"eruda",
Expand All @@ -27,24 +32,24 @@
},
"homepage": "https://github.com/liriliri/eruda-features#readme",
"devDependencies": {
"autoprefixer": "^7.2.2",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"css-loader": "^0.28.7",
"eruda": "^2.0.0",
"eslint": "^6.8.0",
"handlebars": "^4.0.11",
"handlebars-loader": "^1.6.0",
"modernizr": "^3.5.0",
"node-sass": "^4.7.2",
"postcss": "^6.0.14",
"@babel/core": "^7.21.3",
"@babel/plugin-transform-runtime": "^7.21.0",
"@babel/preset-env": "^7.20.2",
"autoprefixer": "^10.4.14",
"babel-loader": "^9.1.2",
"css-loader": "^3.4.2",
"eruda": "^3.2.0",
"es-check": "^7.2.1",
"eslint": "^8.57.0",
"licia": "^1.41.1",
"modernizr": "^3.13.0",
"postcss": "^8.4.21",
"postcss-class-prefix": "^0.3.0",
"postcss-loader": "^2.0.9",
"prettier": "^1.19.1",
"sass-loader": "^6.0.6",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.9.7"
"postcss-loader": "^7.0.2",
"sass": "^1.77.8",
"sass-loader": "^14.2.1",
"webpack": "^5.93.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.12.0"
}
}
26 changes: 16 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import modernizr from './modernizr'
const map = require('licia/map')
const modernizr = require('./modernizr')

let featureList = require('../script/featureList.json')

let featureNames = featureList['feature-detects'],
specialNames = featureList['special-names']

module.exports = function(eruda) {
module.exports = function (eruda) {
let { evalCss } = eruda.util

class Features extends eruda.Tool {
Expand All @@ -14,14 +15,9 @@ module.exports = function(eruda) {
this.name = 'features'
this._style = evalCss(require('./style.scss'))

this._tpl = require('./template.hbs')
this._features = {}
this._isInit = false
}
init($el, container) {
super.init($el, container)
$el.html(require('./template.hbs')())
}
show() {
super.show()

Expand All @@ -42,19 +38,29 @@ module.exports = function(eruda) {
let i = 0,
featureNum = featureNames.length

featureNames.forEach(feature => {
featureNames.forEach((feature) => {
if (specialNames[feature]) feature = specialNames[feature]
feature = feature.replace(/\//g, '')

modernizr.on(feature, result => {
modernizr.on(feature, (result) => {
this._features[feature] = result
i++
if (i === featureNum) this._render()
})
})
}
_render() {
this._$el.html(this._tpl({ features: this._features }))
const features = map(this._features, (feature, key) => {
const ok = feature ? 'eruda-ok' : ''

return `<li>
<a href="http://caniuse.com/#search=${key}" target="_blank" class="eruda-inner-wrapper ${ok}">
${key}
</a>
</li>`
}).join('')
const html = `<ul>${features}</ul>`
this._$el.html(html)
}
}

Expand Down
Loading

0 comments on commit 28fbc07

Please sign in to comment.