Skip to content

Commit

Permalink
feat: add github actions && update README
Browse files Browse the repository at this point in the history
  • Loading branch information
JuniorTour committed Sep 10, 2023
1 parent 9eb38fc commit eadd42a
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug report
about: Create a report to help us improve
title: "[Bug] Please describe your issue in short"
labels: need triage
assignees: ''

---

- [ ] Would you like to work on a fix?

## Current behavior

Describe how to re-produce your error.

This will help us fix it ASAP.

``` js
// or write your error code here
```

## Expected behavior

Describe the Expected behavior you want.

## Extra
- Usage: Webpack || Vite || ...
- Node.js Version: ?
31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the branches
push:
branches:
- '**'
pull_request:
branches: [main]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "test"
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Set node version to 16
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'npm'
- run: npm install
- run: npm run test
20 changes: 20 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'PublishLatestVersion'

on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16
- run: npm install --frozen-lockfile
- run: npm run test
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/publishBeta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'PublishBetaVersion'
on:
push:
tags:
- 'beta-v*' # Push events to matching beta-v*, i.e. beta-v1.0, beta-v20.15.10

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16
- run: npm install --frozen-lockfile
- run: npm run test
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
tag: 'beta'
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
## resource-hint-generator
## resource-hint-generator [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/JuniorTour/resource-hint-generator/pulls)
`prefetch`, `preconnect``dns-prefetch`等资源优先级提示自动化生成工具。

> 配套讲解文章《1.4秒到0.4秒-2行代码让JS加载耗时减少67%》:https://juejin.cn/post/7274889579076108348
<p align="center">
<a href="https://www.npmjs.com/package/resource-hint-generator" target="_blank">
<img
src="https://img.shields.io/npm/dt/resource-hint-generator"
alt="Downloads">
</a>
<a href="https://www.npmjs.com/package/resource-hint-generator" target="_blank">
<img
src="https://img.shields.io/github/size/JuniorTour/resource-hint-generator/lib/index.js"
alt="Size">
</a>
<a href="https://www.npmjs.com/package/resource-hint-generator" target="_blank">
<img
src="https://img.shields.io/npm/v/resource-hint-generator.svg?sanitize=true"
alt="Version">
</a>
<a href="https://github.com/JuniorTour/resource-hint-generator" target="_blank">
<img
src="https://img.shields.io/github/last-commit/JuniorTour/resource-hint-generator?sanitize=true"
alt="LastCommit">
</a>
<a href="https://github.com/JuniorTour/resource-hint-generator/actions/workflows/main.yml" target="_blank">
<img
src="https://github.com/JuniorTour/resource-hint-generator/actions/workflows/main.yml/badge.svg"
alt="CIStatus">
</a>
</p>


## 特性
1. 自动遍历构建产物,生成注入脚本,运行后注入`prefetch`资源优先级提示`link`标签
2. 指定域名,生成注入脚本,运行后注入`preconnect``dns-prefetch`资源优先级提示`link`标签
Expand Down Expand Up @@ -57,4 +86,4 @@ publicPath | 用于和`includeFileTestFunc`、`includeFileNames`匹配到的文
preconnectDomains | 指定一个数组,数组中的每个字符串元素,都将产生2个`href`属性值为当前字符串的`<link rel="preconnect">`标签和`<link rel="dns-prefetch">`标签 | String[] | `[]`
configFileName | 本地配置文件名称 | String | `'resource-hint-generator-config.js'`

欢迎 Issue && PR~
## 欢迎 Issue && PR

0 comments on commit eadd42a

Please sign in to comment.