build: 新增构建脚本 build:zip

pull/41/head
zjx0905 2023-03-24 19:41:17 +08:00
parent 0d9e93a117
commit acb110bd41
15 changed files with 157 additions and 227 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -24,16 +24,18 @@ module.exports = {
}, },
prompt: { prompt: {
messages: { messages: {
type: '请选择提交类型:', type: '请选择提交类型',
subject: '请输入变更描述:\n', subject: '请输入变更描述',
footer: '列举关联的 issue (可选) 例如: #31, #I3244\n', breaking: '列举非兼容性重大的变更,如果有多行,使用 "|" 换行(选填项)\n',
confirmCommit: '是否提交?', footer: '列举关联的 issue例如#31,#I3244选填项\n',
confirmCommit: '是否提交',
}, },
types: metas.map((meta) => ({ types: metas.map((meta) => ({
value: meta.type, value: meta.type,
name: `${`${meta.type}:`.padEnd(10, ' ')}${meta.section}`, name: `${`${meta.type}:`.padEnd(10, ' ')}${meta.section}`,
})), })),
skipQuestions: ['scope', 'body', 'breaking', 'footerPrefix'], allowBreakingChanges: ['feat', 'fix'],
skipQuestions: ['scope', 'body', 'footerPrefix'],
formatMessageCB: (commit) => formatMessageCB: (commit) =>
`${commit?.defaultMessage}\n\nCo-authored-by: ${readGitUser( `${commit?.defaultMessage}\n\nCo-authored-by: ${readGitUser(
'name', 'name',

View File

@ -33,7 +33,7 @@ jobs:
run: pnpm lint run: pnpm lint
- name: Build - name: Build
run: pnpm build run: pnpm build -a
- name: Test - name: Test
run: pnpm test run: pnpm test

2
global.d.ts vendored
View File

@ -8,4 +8,4 @@ declare const qh: unknown;
declare const ks: unknown; declare const ks: unknown;
declare const dd: unknown; declare const dd: unknown;
declare type AnyObject<T = any> = Record<string, T>; type AnyObject<T = any> = Record<string, T>;

View File

@ -1,7 +1,7 @@
{ {
"name": "axios-miniprogram", "name": "axios-miniprogram",
"type": "module", "type": "module",
"version": "2.0.0.alpha.0", "version": "2.0.0-alpha.0",
"description": "基于 Promise 的 HTTP 请求库,适用于各大小程序平台。", "description": "基于 Promise 的 HTTP 请求库,适用于各大小程序平台。",
"main": "dist/axios-miniprogram.esm.js", "main": "dist/axios-miniprogram.esm.js",
"module": "dist/axios-miniprogram.cjs.js", "module": "dist/axios-miniprogram.cjs.js",
@ -31,6 +31,7 @@
"scripts": { "scripts": {
"cz": "czg", "cz": "czg",
"build": "esno scripts/build.ts", "build": "esno scripts/build.ts",
"build:zip": "esno scripts/build-zip.ts",
"release": "esno scripts/release.ts", "release": "esno scripts/release.ts",
"test": "vitest run", "test": "vitest run",
"lint": "eslint --cache .", "lint": "eslint --cache .",
@ -45,13 +46,15 @@
"@types/node": "^18.15.5", "@types/node": "^18.15.5",
"@typescript-eslint/eslint-plugin": "^5.55.0", "@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0", "@typescript-eslint/parser": "^5.55.0",
"archiver": "^5.3.1", "chalk": "^5.2.0",
"consola": "^2.15.3", "consola": "^2.15.3",
"cz-git": "1.3.8", "cz-git": "1.3.8",
"czg": "1.3.8", "czg": "1.3.8",
"enquirer": "^2.3.6", "enquirer": "^2.3.6",
"eslint": "^8.36.0", "eslint": "^8.36.0",
"esno": "^0.16.3", "esno": "^0.16.3",
"fast-glob": "^3.2.12",
"jszip": "^3.10.1",
"lint-staged": "13.2.0", "lint-staged": "13.2.0",
"minimist": "^1.2.8", "minimist": "^1.2.8",
"prettier": "2.8.5", "prettier": "2.8.5",

View File

@ -8,13 +8,15 @@ specifiers:
'@types/node': ^18.15.5 '@types/node': ^18.15.5
'@typescript-eslint/eslint-plugin': ^5.55.0 '@typescript-eslint/eslint-plugin': ^5.55.0
'@typescript-eslint/parser': ^5.55.0 '@typescript-eslint/parser': ^5.55.0
archiver: ^5.3.1 chalk: ^5.2.0
consola: ^2.15.3 consola: ^2.15.3
cz-git: 1.3.8 cz-git: 1.3.8
czg: 1.3.8 czg: 1.3.8
enquirer: ^2.3.6 enquirer: ^2.3.6
eslint: ^8.36.0 eslint: ^8.36.0
esno: ^0.16.3 esno: ^0.16.3
fast-glob: ^3.2.12
jszip: ^3.10.1
lint-staged: 13.2.0 lint-staged: 13.2.0
minimist: ^1.2.8 minimist: ^1.2.8
prettier: 2.8.5 prettier: 2.8.5
@ -36,13 +38,15 @@ devDependencies:
'@types/node': 18.15.5 '@types/node': 18.15.5
'@typescript-eslint/eslint-plugin': 5.56.0_2hcjazgfnbtq42tcc73br2vup4 '@typescript-eslint/eslint-plugin': 5.56.0_2hcjazgfnbtq42tcc73br2vup4
'@typescript-eslint/parser': 5.56.0_j4766f7ecgqbon3u7zlxn5zszu '@typescript-eslint/parser': 5.56.0_j4766f7ecgqbon3u7zlxn5zszu
archiver: 5.3.1 chalk: 5.2.0
consola: 2.15.3 consola: 2.15.3
cz-git: 1.3.8 cz-git: 1.3.8
czg: 1.3.8 czg: 1.3.8
enquirer: 2.3.6 enquirer: 2.3.6
eslint: 8.36.0 eslint: 8.36.0
esno: 0.16.3 esno: 0.16.3
fast-glob: 3.2.12
jszip: 3.10.1
lint-staged: 13.2.0_enquirer@2.3.6 lint-staged: 13.2.0_enquirer@2.3.6
minimist: 1.2.8 minimist: 1.2.8
prettier: 2.8.5 prettier: 2.8.5
@ -1279,35 +1283,6 @@ packages:
engines: {node: '>=12'} engines: {node: '>=12'}
dev: true dev: true
/archiver-utils/2.1.0:
resolution: {integrity: sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==}
engines: {node: '>= 6'}
dependencies:
glob: 7.2.3
graceful-fs: 4.2.11
lazystream: 1.0.1
lodash.defaults: 4.2.0
lodash.difference: 4.5.0
lodash.flatten: 4.4.0
lodash.isplainobject: 4.0.6
lodash.union: 4.6.0
normalize-path: 3.0.0
readable-stream: 2.3.8
dev: true
/archiver/5.3.1:
resolution: {integrity: sha512-8KyabkmbYrH+9ibcTScQ1xCJC/CGcugdVIwB+53f5sZziXgwUh3iXlAlANMxcZyDEfTHMe6+Z5FofV8nopXP7w==}
engines: {node: '>= 10'}
dependencies:
archiver-utils: 2.1.0
async: 3.2.4
buffer-crc32: 0.2.13
readable-stream: 3.6.2
readdir-glob: 1.1.2
tar-stream: 2.2.0
zip-stream: 4.1.0
dev: true
/arg/4.1.3: /arg/4.1.3:
resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==}
dev: true dev: true
@ -1339,26 +1314,10 @@ packages:
engines: {node: '>=8'} engines: {node: '>=8'}
dev: true dev: true
/async/3.2.4:
resolution: {integrity: sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==}
dev: true
/balanced-match/1.0.2: /balanced-match/1.0.2:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
dev: true dev: true
/base64-js/1.5.1:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
dev: true
/bl/4.1.0:
resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==}
dependencies:
buffer: 5.7.1
inherits: 2.0.4
readable-stream: 3.6.2
dev: true
/body-scroll-lock/4.0.0-beta.0: /body-scroll-lock/4.0.0-beta.0:
resolution: {integrity: sha512-a7tP5+0Mw3YlUJcGAKUqIBkYYGlYxk2fnCasq/FUph1hadxlTRjF+gAcZksxANnaMnALjxEddmSi/H3OR8ugcQ==} resolution: {integrity: sha512-a7tP5+0Mw3YlUJcGAKUqIBkYYGlYxk2fnCasq/FUph1hadxlTRjF+gAcZksxANnaMnALjxEddmSi/H3OR8ugcQ==}
dev: true dev: true
@ -1383,21 +1342,10 @@ packages:
fill-range: 7.0.1 fill-range: 7.0.1
dev: true dev: true
/buffer-crc32/0.2.13:
resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==}
dev: true
/buffer-from/1.1.2: /buffer-from/1.1.2:
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
dev: true dev: true
/buffer/5.7.1:
resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
dependencies:
base64-js: 1.5.1
ieee754: 1.2.1
dev: true
/cac/6.7.14: /cac/6.7.14:
resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -1540,16 +1488,6 @@ packages:
dot-prop: 5.3.0 dot-prop: 5.3.0
dev: true dev: true
/compress-commons/4.1.1:
resolution: {integrity: sha512-QLdDLCKNV2dtoTorqgxngQCMA+gWXkM/Nwu7FpeBhk/RdkzimqC3jueb/FDmaZeXh+uby1jkBqE3xArsLBE5wQ==}
engines: {node: '>= 10'}
dependencies:
buffer-crc32: 0.2.13
crc32-stream: 4.0.2
normalize-path: 3.0.0
readable-stream: 3.6.2
dev: true
/concat-map/0.0.1: /concat-map/0.0.1:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
dev: true dev: true
@ -1617,20 +1555,6 @@ packages:
path-type: 4.0.0 path-type: 4.0.0
dev: true dev: true
/crc-32/1.2.2:
resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==}
engines: {node: '>=0.8'}
hasBin: true
dev: true
/crc32-stream/4.0.2:
resolution: {integrity: sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==}
engines: {node: '>= 10'}
dependencies:
crc-32: 1.2.2
readable-stream: 3.6.2
dev: true
/create-require/1.1.1: /create-require/1.1.1:
resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}
dev: true dev: true
@ -1746,12 +1670,6 @@ packages:
resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
dev: true dev: true
/end-of-stream/1.4.4:
resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==}
dependencies:
once: 1.4.0
dev: true
/enquirer/2.3.6: /enquirer/2.3.6:
resolution: {integrity: sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==} resolution: {integrity: sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==}
engines: {node: '>=8.6'} engines: {node: '>=8.6'}
@ -2050,10 +1968,6 @@ packages:
resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==}
dev: true dev: true
/fs-constants/1.0.0:
resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
dev: true
/fs-extra/11.1.1: /fs-extra/11.1.1:
resolution: {integrity: sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==} resolution: {integrity: sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==}
engines: {node: '>=14.14'} engines: {node: '>=14.14'}
@ -2221,15 +2135,15 @@ packages:
engines: {node: '>=14.18.0'} engines: {node: '>=14.18.0'}
dev: true dev: true
/ieee754/1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
dev: true
/ignore/5.2.4: /ignore/5.2.4:
resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==}
engines: {node: '>= 4'} engines: {node: '>= 4'}
dev: true dev: true
/immediate/3.0.6:
resolution: {integrity: sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==}
dev: true
/import-fresh/3.3.0: /import-fresh/3.3.0:
resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==}
engines: {node: '>=6'} engines: {node: '>=6'}
@ -2445,18 +2359,20 @@ packages:
engines: {'0': node >= 0.2.0} engines: {'0': node >= 0.2.0}
dev: true dev: true
/jszip/3.10.1:
resolution: {integrity: sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==}
dependencies:
lie: 3.3.0
pako: 1.0.11
readable-stream: 2.3.8
setimmediate: 1.0.5
dev: true
/kind-of/6.0.3: /kind-of/6.0.3:
resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
dev: true dev: true
/lazystream/1.0.1:
resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==}
engines: {node: '>= 0.6.3'}
dependencies:
readable-stream: 2.3.8
dev: true
/levn/0.4.1: /levn/0.4.1:
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
engines: {node: '>= 0.8.0'} engines: {node: '>= 0.8.0'}
@ -2465,6 +2381,12 @@ packages:
type-check: 0.4.0 type-check: 0.4.0
dev: true dev: true
/lie/3.3.0:
resolution: {integrity: sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==}
dependencies:
immediate: 3.0.6
dev: true
/lilconfig/2.1.0: /lilconfig/2.1.0:
resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==} resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -2540,18 +2462,6 @@ packages:
resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==}
dev: true dev: true
/lodash.defaults/4.2.0:
resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==}
dev: true
/lodash.difference/4.5.0:
resolution: {integrity: sha512-dS2j+W26TQ7taQBGN8Lbbq04ssV3emRw4NY58WErlTO29pIqS0HmoT5aJ9+TUQ1N3G+JOZSji4eugsWwGp9yPA==}
dev: true
/lodash.flatten/4.4.0:
resolution: {integrity: sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==}
dev: true
/lodash.isfunction/3.0.9: /lodash.isfunction/3.0.9:
resolution: {integrity: sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw==} resolution: {integrity: sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw==}
dev: true dev: true
@ -2580,10 +2490,6 @@ packages:
resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==}
dev: true dev: true
/lodash.union/4.6.0:
resolution: {integrity: sha512-c4pB2CdGrGdjMKYLA+XiRDO7Y0PRQbm/Gzg8qMj+QH+pFVAoTp5sBpO0odL3FjoPCGjK96p6qsP+yQoiLoOBcw==}
dev: true
/lodash.uniq/4.5.0: /lodash.uniq/4.5.0:
resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==} resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==}
dev: true dev: true
@ -2706,13 +2612,6 @@ packages:
brace-expansion: 1.1.11 brace-expansion: 1.1.11
dev: true dev: true
/minimatch/5.1.6:
resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==}
engines: {node: '>=10'}
dependencies:
brace-expansion: 2.0.1
dev: true
/minimatch/7.4.3: /minimatch/7.4.3:
resolution: {integrity: sha512-5UB4yYusDtkRPbRiy1cqZ1IpGNcJCGlEMG17RKzPddpyiPKoCdwohbED8g4QXT0ewCt8LTkQXuljsUfQ3FKM4A==} resolution: {integrity: sha512-5UB4yYusDtkRPbRiy1cqZ1IpGNcJCGlEMG17RKzPddpyiPKoCdwohbED8g4QXT0ewCt8LTkQXuljsUfQ3FKM4A==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -2886,6 +2785,10 @@ packages:
engines: {node: '>=6'} engines: {node: '>=6'}
dev: true dev: true
/pako/1.0.11:
resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==}
dev: true
/parent-module/1.0.1: /parent-module/1.0.1:
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
engines: {node: '>=6'} engines: {node: '>=6'}
@ -3084,12 +2987,6 @@ packages:
util-deprecate: 1.0.2 util-deprecate: 1.0.2
dev: true dev: true
/readdir-glob/1.1.2:
resolution: {integrity: sha512-6RLVvwJtVwEDfPdn6X6Ille4/lxGl0ATOY4FN/B9nxQcgOazvvI0nodiD19ScKq0PvA/29VpaOQML36o5IzZWA==}
dependencies:
minimatch: 5.1.6
dev: true
/redent/3.0.0: /redent/3.0.0:
resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -3238,6 +3135,10 @@ packages:
lru-cache: 6.0.0 lru-cache: 6.0.0
dev: true dev: true
/setimmediate/1.0.5:
resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==}
dev: true
/shebang-command/2.0.0: /shebang-command/2.0.0:
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -3465,17 +3366,6 @@ packages:
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
dev: true dev: true
/tar-stream/2.2.0:
resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==}
engines: {node: '>=6'}
dependencies:
bl: 4.1.0
end-of-stream: 1.4.4
fs-constants: 1.0.0
inherits: 2.0.4
readable-stream: 3.6.2
dev: true
/text-extensions/1.9.0: /text-extensions/1.9.0:
resolution: {integrity: sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ==} resolution: {integrity: sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ==}
engines: {node: '>=0.10'} engines: {node: '>=0.10'}
@ -3930,12 +3820,3 @@ packages:
resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==}
engines: {node: '>=12.20'} engines: {node: '>=12.20'}
dev: true dev: true
/zip-stream/4.1.0:
resolution: {integrity: sha512-zshzwQW7gG7hjpBlgeQP9RuyPGNxvJdzR8SUM3QhxCnLjWN2E7j3dOvpeDcQoETfHx0urRS7EtmVToql7YpU4A==}
engines: {node: '>= 10'}
dependencies:
archiver-utils: 2.1.0
compress-commons: 4.1.1
readable-stream: 3.6.2
dev: true

View File

@ -1,11 +1,12 @@
import path from 'node:path'; import path from 'node:path';
import esbuild from 'rollup-plugin-esbuild'; import esbuildPlugin from 'rollup-plugin-esbuild';
import dtsPlugin from 'rollup-plugin-dts'; import dtsPlugin from 'rollup-plugin-dts';
import { __dirname, getPkgJSON } from './scripts/utils.js'; import { __dirname, distPath, getPkgJSON } from './scripts/utils.js';
import { readFileSync } from 'node:fs';
const pkg = getPkgJSON(); const pkg = getPkgJSON();
const inputPath = path.resolve(__dirname, 'src/index.ts'); const inputPath = path.resolve(__dirname, 'src/index.ts');
const outputPath = path.resolve(__dirname, 'dist');
const sourceMap = process.env.SOURCE_MAP === 'true'; const sourceMap = process.env.SOURCE_MAP === 'true';
const dts = process.env.DTS === 'true'; const dts = process.env.DTS === 'true';
@ -19,6 +20,11 @@ function main() {
return configs; return configs;
} }
/**
*
* @param {*} format
* @returns {import('rollup').InputOptions}
*/
function buildConfig(format) { function buildConfig(format) {
const isDts = format === 'dts'; const isDts = format === 'dts';
const output = { const output = {
@ -35,11 +41,14 @@ function buildConfig(format) {
output, output,
plugins: [ plugins: [
isDts isDts
? dtsPlugin({ ? [
tsconfig: path.resolve(__dirname, 'tsconfig.build.json'), dtsPlugin({
}) tsconfig: path.resolve(__dirname, 'tsconfig.json'),
: esbuild({ }),
tsconfig: path.resolve(__dirname, 'tsconfig.build.json'), compleTypePlugin([path.resolve(__dirname, 'global.d.ts')]),
]
: esbuildPlugin({
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
sourceMap: output.sourcemap, sourceMap: output.sourcemap,
minify: true, minify: true,
}), }),
@ -49,7 +58,22 @@ function buildConfig(format) {
function resolvePath(format, isDts) { function resolvePath(format, isDts) {
return path.resolve( return path.resolve(
outputPath, distPath,
`${pkg.name}${isDts ? '.d.ts' : `.${format}.js`}`, `${pkg.name}${isDts ? '.d.ts' : `.${format}.js`}`,
); );
} }
function compleTypePlugin(files) {
return {
name: 'comple-type',
renderChunk: (code) =>
`${files
.map(
(file) =>
`// ${file.replace(__dirname, '')}\n${readFileSync(
file,
).toString()}\n// ${file.replace(__dirname, '')} end\n`,
)
.join('')}\n${code}`,
};
}

50
scripts/build-zip.ts Normal file
View File

@ -0,0 +1,50 @@
import fs from 'node:fs';
import fg from 'fast-glob';
import JSZip from 'jszip';
import consola from 'consola';
import chalk from 'chalk';
import { distPath, exec } from './utils';
main();
async function main() {
exec('pnpm build');
consola.info('Generate zip\n');
for (const filePath of await fg(`${distPath}/**.js`)) {
await generateZip(filePath, filePath.replace(/\.js$/, '.zip'));
}
}
function generateZip(inputPath: string, outputPath: string) {
return new Promise((resolve, reject) => {
const inputName = getFileName(inputPath);
const outputName = getFileName(outputPath);
console.log(chalk.cyanBright.bold(`${inputPath} → dist/${outputName}...`));
const start = Date.now();
JSZip()
.file(inputName, fs.createReadStream(inputPath))
.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
.pipe(fs.createWriteStream(outputPath))
.on('finish', (result) => {
console.log(
`${chalk.green('created')} ${chalk.greenBright.bold(
`dist/${outputName} in ${Date.now() - start}ms\n`,
)}`,
);
exec(`rimraf ${inputPath}`);
resolve(result);
})
.on('error', reject);
});
}
function getFileName(filePath: string) {
const result = filePath.match(/\/([^/]*)$/);
if (!result) {
throw new Error(`无效的文件路径 ${filePath}`);
}
return result[1];
}

View File

@ -3,20 +3,22 @@ import consola from 'consola';
import { exec } from './utils'; import { exec } from './utils';
const args = minimist(process.argv.slice(2)); const args = minimist(process.argv.slice(2));
const watching = Boolean(args.watch || args.w); const watch = Boolean(args.watch || args.w);
const release = Boolean(args.release || args.r); const all = Boolean(args.all || args.a);
const sourceMap = release || Boolean(args.sourceMap || args.s); const sourceMap = all || Boolean(args.sourceMap || args.s);
const dts = release || Boolean(args.dts || args.d); const dts = all || Boolean(args.dts || args.d);
build(); build();
function build() { function build() {
exec('rimraf dist'); exec('rimraf dist');
consola.info('构建产物'); consola.info('Rollup');
exec( exec(
`rollup -c ${ `rollup -c ${
watching ? '-w' : '' watch ? '-w' : ''
} --environment SOURCE_MAP:${sourceMap},DTS:${dts}`, } --environment SOURCE_MAP:${sourceMap},DTS:${dts}`,
); );
console.info('\n');
} }

0
scripts/publish.ts Normal file
View File

View File

@ -7,10 +7,7 @@ import { exec, pkgPath, getPkgJSON } from './utils';
const pkg = getPkgJSON(); const pkg = getPkgJSON();
const { version: currentVersion } = pkg; const { version: currentVersion } = pkg;
main().catch((err) => { main().catch((err) => exit(err.message));
updateVersion(currentVersion);
console.error(err);
});
async function main() { async function main() {
checkBranch(); checkBranch();
@ -36,11 +33,12 @@ function checkBranch() {
const releaseBranch = 'main'; const releaseBranch = 'main';
const currentBranch = exec('git branch --show-current', { const currentBranch = exec('git branch --show-current', {
stdio: 'pipe', stdio: 'pipe',
}).toString(); })
.toString()
.trim();
if (currentBranch !== releaseBranch) { if (currentBranch !== releaseBranch) {
consola.warn(`请切回 ${releaseBranch} 分支进行发版!`); exit(`请切回 ${releaseBranch} 分支进行发版!`);
process.exit();
} }
} }
@ -73,8 +71,7 @@ async function inputVersion() {
!semver.valid(targetVersion) || !semver.valid(targetVersion) ||
!semver.lt(currentVersion, targetVersion) !semver.lt(currentVersion, targetVersion)
) { ) {
consola.error(`无效的版本号: ${targetVersion}`); exit(`无效的版本号: ${targetVersion}`);
process.exit();
} }
const { yes: confirmRelease } = await enquirer.prompt<{ yes: boolean }>({ const { yes: confirmRelease } = await enquirer.prompt<{ yes: boolean }>({
@ -84,8 +81,7 @@ async function inputVersion() {
}); });
if (!confirmRelease) { if (!confirmRelease) {
consola.error(`取消发布: v${targetVersion}`); exit(`取消发布: v${targetVersion}`);
process.exit();
} }
return targetVersion; return targetVersion;
@ -108,6 +104,12 @@ function createReleases() {
return releases; return releases;
} }
function exit(msg: string) {
updateVersion(currentVersion);
consola.error(msg || '已退出');
process.exit();
}
function updateVersion(version: string) { function updateVersion(version: string) {
pkg.version = version; pkg.version = version;
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');

View File

@ -5,7 +5,10 @@ import { execSync } from 'node:child_process';
export const __dirname = fileURLToPath(new URL('../', import.meta.url)); export const __dirname = fileURLToPath(new URL('../', import.meta.url));
export const require = createRequire(import.meta.url); export const require = createRequire(import.meta.url);
export const pkgPath = path.resolve(__dirname, 'package.json');
export const distPath = path.resolve(__dirname, 'dist');
export const exec = (command, options) => export const exec = (command, options) =>
execSync(command, { stdio: 'inherit', ...(options ?? {}) }); execSync(command, { stdio: 'inherit', ...(options ?? {}) });
export const pkgPath = path.resolve(__dirname, 'package.json');
export const getPkgJSON = () => require(pkgPath); export const getPkgJSON = () => require(pkgPath);

View File

@ -1,37 +0,0 @@
// import fs from 'node:fs';
// import path from 'node:path';
// import archiver from 'archiver';
// import { getPkgJSON } from './utils';
// const pkg = getPkgJSON();
// const zip = archiver.create('zip', {});
// const distPath = path.resolve(__dirname, '..', 'dist');
// const distZipName = `download/${pkg.version}.zip`;
// const distZipPath = path.resolve(__dirname, '..', distZipName);
// function main() {
// const outputStream = fs.createWriteStream(distZipPath);
// const startTime = +new Date();
// zip.glob()
// zip.on('error', (error) => {
// throw error;
// });
// zip.on('finish', () => {
// const endTime = +new Date();
// const ss = ((endTime - startTime) / 1000).toFixed(1);
// });
// zip.pipe(outputStream);
// zip.directory(distPath, pkg.name);
// zip.finalize();
// }
// function getFilePaths(){
// }
// function createZipName(){
// return
// }

View File

@ -24,7 +24,7 @@ export function isNull(value: any): value is null {
return value === null; return value === null;
} }
export function isPlainObject(value: any): value is object { export function isPlainObject(value: any): value is object & AnyObject {
return _toString.call(value) === '[object Object]'; return _toString.call(value) === '[object Object]';
} }

View File

@ -8,6 +8,6 @@
"strict": true, "strict": true,
"noEmit": true "noEmit": true
}, },
"include": ["src", "test", "global.d.ts"], "include": ["./src", "./test", "./global.d.ts"],
"exclude": ["node_modules"] "exclude": ["node_modules"]
} }