Skip to content

Commit

Permalink
Merge branch 'release/v2.0.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
JOU-amjs committed Apr 8, 2023
2 parents 2c99111 + 208620e commit 870669e
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 49 deletions.
54 changes: 26 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,35 @@ on:

# 任务
jobs:
# quality:
# # 服务器环境:最新版 Ubuntu
# runs-on: ubuntu-latest
# steps:
# # 拉取代码
# - name: Checkout
# uses: actions/checkout@v3
# - name: Use Node.js
# uses: actions/setup-node@v3
# with:
# node-version: 18.12.x
# registry-url: 'https://registry.npmjs.org'
# cache: 'npm'
quality:
# 服务器环境:最新版 Ubuntu
runs-on: ubuntu-latest
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.12.x
registry-url: 'https://registry.npmjs.org'
cache: 'npm'

# 执行测试和打包操作
- name: Install deps
run: npm ci

# # 执行测试和打包操作
# - name: Install deps
# run: npm ci
- name: Lint check
run: npm run lint

# - name: Lint check
# run: npm run lint
# 这条命令包含了测试
- name: Unit tests
run: npm run test

# # 这条命令包含了测试
# - name: Unit tests
# run: npm run test
# - run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_ALOVA_PUBLISH_TOKEN }}
release:
runs-on: ubuntu-latest
# needs: [quality]
# if: ${{ github.ref == 'refs/heads/main' }}
needs: [quality]
if: ${{ github.ref == 'refs/heads/main' }}
steps:
# 拉取代码
- name: Checkout
Expand All @@ -59,8 +57,8 @@ jobs:
run: npm ci

# 这条命令包含了测试和上传覆盖率
# - name: Coverage
# run: npm run coveralls
- name: Coverage
run: npm run coveralls

# 打包发布
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit $1
npx --no-install commitlint --edit "$1"
4 changes: 3 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
module.exports = {
extends: ['@commitlint/config-conventional']
};
15 changes: 6 additions & 9 deletions config/rollup.config.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Date: 2020-04-09 11:06:01
* @LastEditors: JOU(wx: huzhen555)
* @LastEditTime: 2022-06-12 09:51:50
*/
*/
// rollup.config.js
// umd
var { nodeResolve } = require('@rollup/plugin-node-resolve');
Expand All @@ -15,9 +15,6 @@ var prod = process.env.NODE_ENV === 'production';
var paths = config.compilePath;
var moduleType = prod ? 'umd.min' : 'umd';

const globals = {};
// 将externals中的内容放到globals对象中
config.external.forEach(key => globals[key] = key);
module.exports = {
input: paths.input,
output: {
Expand All @@ -26,8 +23,8 @@ module.exports = {
format: 'umd',
// When export and export default are not used at the same time, set legacy to true.
// legacy: true,
globals,
banner: config.banner,
globals: config.globals,
banner: config.banner
},
external: config.external,
plugins: [
Expand All @@ -37,11 +34,11 @@ module.exports = {
}),
commonjs(),
config.getCompiler(),
json(), // 可允许import json文件
json(), // 可允许import json文件
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
preventAssignment: true,
preventAssignment: true
}),
(prod && terser()),
prod && terser()
]
};
31 changes: 25 additions & 6 deletions config/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,48 @@ const compilePaths = {
vue: {
packageName: 'VueHook',
input: 'src/predefine/VueHook.ts',

// key作为external数组,external对象作为global对象
externalMap: {
vue: 'Vue'
},
output: suffix => `dist/hooks/vuehook.${suffix}.js`
},
react: {
packageName: 'ReactHook',
input: 'src/predefine/ReactHook.ts',
externalMap: {
react: 'React'
},
output: suffix => `dist/hooks/reacthook.${suffix}.js`
},
svelte: {
extraExternal: ['svelte/store'],
externalMap: {
// undefined或null表示需要从globals中过滤掉
svelte: undefined,
'svelte/store': undefined
},
packageName: 'SvelteHook',
input: 'src/predefine/SvelteHook.ts',
output: suffix => `dist/hooks/sveltehook.${suffix}.js`
},
globalFetch: {
extraExternal: [],
packageName: 'GlobalFetch',
input: 'src/predefine/GlobalFetch.ts',
output: suffix => `dist/adapter/globalfetch.${suffix}.js`
}
};
exports.external = Object.keys(compilePaths)
.reduce((prev, next) => [...prev, next, ...(compilePaths[next].extraExternal || [])], [])
.filter(key => key !== 'core');

const compileModule = process.env.MODULE || 'core';
exports.compilePath = compilePaths[compileModule];
const compilePath = (exports.compilePath = compilePaths[compileModule]);
// 计算external、globals
if (compilePath.externalMap) {
const external = (exports.external = Object.keys(compilePath.externalMap));
exports.globals = external.reduce((globals, key) => {
const globalVal = compilePath.externalMap[key];
if (![undefined, null].includes(globalVal)) {
globals[key] = globalVal;
}
return globals;
}, {});
}
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,11 @@
"build:reacthook:umd.min": "cross-env NODE_ENV=production MODULE=react rollup -c config/rollup.config.umd.js",
"build:reacthook": "npm run build:reacthook:esm && npm run build:reacthook:umd && npm run build:reacthook:umd.min",
"build:sveltehook:esm": "cross-env MODULE=svelte rollup -c config/rollup.config.esm.js",
"build:sveltehook:umd": "cross-env NODE_ENV=development MODULE=svelte rollup -c config/rollup.config.umd.js",
"build:sveltehook:umd.min": "cross-env NODE_ENV=production MODULE=svelte rollup -c config/rollup.config.umd.js",
"build:sveltehook": "npm run build:sveltehook:esm && npm run build:sveltehook:umd && npm run build:sveltehook:umd.min",
"build:globalfetch:esm": "cross-env MODULE=globalFetch rollup -c config/rollup.config.esm.js",
"build:globalfetch:umd": "cross-env NODE_ENV=development MODULE=globalFetch rollup -c config/rollup.config.umd.js",
"build:globalfetch:umd.min": "cross-env NODE_ENV=production MODULE=globalFetch rollup -c config/rollup.config.umd.js",
"build:globalfetch": "npm run build:globalfetch:esm && npm run build:globalfetch:umd && npm run build:globalfetch:umd.min",
"build": "npm run clean && npm run build:esm && npm run build:umd && npm run build:umd.min && npm run build:vuehook && npm run build:reacthook && npm run build:sveltehook && npm run build:globalfetch",
"build": "npm run clean && npm run build:esm && npm run build:umd && npm run build:umd.min && npm run build:vuehook && npm run build:reacthook && npm run build:sveltehook:esm && npm run build:globalfetch",
"coveralls": "npm run test:coverage && coveralls < coverage/lcov.info",
"prepare": "husky install",
"changelog": "conventional-changelog -p angular -u -i CHANGELOG.md -s -r 0",
Expand Down

0 comments on commit 870669e

Please sign in to comment.