diff --git a/package.json b/package.json index 28c8d5a5..92325b3e 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,9 @@ "test": "vitest run", "coverage": "vitest run --coverage", "prepare": "husky install", - "commit": "git-cz" + "commit": "git-cz", + "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", + "release": "node scripts/release.js" }, "engines": { "node": ">=14" @@ -47,19 +49,25 @@ "@typescript-eslint/parser": "^4.28.0", "@vitejs/plugin-vue": "^1.2.3", "c8": "^7.11.3", + "chalk": "^4.1.0", + "conventional-changelog-cli": "^2.2.2", "cz-conventional-changelog": "^3.3.0", + "enquirer": "^2.3.6", "eslint": "^7.29.0", "eslint-config-tencent": "^1.0.1", "eslint-plugin-import": "^2.23.4", "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-simple-import-sort": "^7.0.0", "eslint-plugin-vue": "^7.11.1", + "execa": "^4.0.2", "husky": "^7.0.0", "jsdom": "^19.0.0", "lint-staged": "^11.0.1", + "minimist": "^1.2.6", "prettier": "^2.3.1", "recast": "^0.20.4", "rimraf": "^3.0.2", + "semver": "^7.3.7", "shx": "^0.3.4", "typescript": "^4.3.4", "vite": "^2.3.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c1775e8a..a7582111 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,19 +12,25 @@ importers: '@typescript-eslint/parser': ^4.28.0 '@vitejs/plugin-vue': ^1.2.3 c8: ^7.11.3 + chalk: ^4.1.0 + conventional-changelog-cli: ^2.2.2 cz-conventional-changelog: ^3.3.0 + enquirer: ^2.3.6 eslint: ^7.29.0 eslint-config-tencent: ^1.0.1 eslint-plugin-import: ^2.23.4 eslint-plugin-prettier: ^3.4.0 eslint-plugin-simple-import-sort: ^7.0.0 eslint-plugin-vue: ^7.11.1 + execa: ^4.0.2 husky: ^7.0.0 jsdom: ^19.0.0 lint-staged: ^11.0.1 + minimist: ^1.2.6 prettier: ^2.3.1 recast: ^0.20.4 rimraf: ^3.0.2 + semver: ^7.3.7 shx: ^0.3.4 typescript: ^4.3.4 vite: ^2.3.7 @@ -38,19 +44,25 @@ importers: '@typescript-eslint/parser': 4.33.0_kix3shd7zvxuvkzdjm72bpp2vy '@vitejs/plugin-vue': 1.10.2_vite@2.9.10 c8: 7.11.3 + chalk: 4.1.2 + conventional-changelog-cli: 2.2.2 cz-conventional-changelog: 3.3.0 + enquirer: 2.3.6 eslint: 7.32.0 eslint-config-tencent: 1.0.4_yc26u4iv6m7pqrlmpzebuxponm eslint-plugin-import: 2.26.0_ffi3uiz42rv3jyhs6cr7p7qqry eslint-plugin-prettier: 3.4.1_lk2fkjavihlcu7p5a3tdxfycz4 eslint-plugin-simple-import-sort: 7.0.0_eslint@7.32.0 eslint-plugin-vue: 7.20.0_eslint@7.32.0 + execa: 4.1.0 husky: 7.0.4 jsdom: 19.0.0 lint-staged: 11.2.6 + minimist: 1.2.6 prettier: 2.6.2 recast: 0.20.5 rimraf: 3.0.2 + semver: 7.3.7 shx: 0.3.4 typescript: 4.7.3 vite: 2.9.10 @@ -58,7 +70,7 @@ importers: packages/core: specifiers: - '@tmagic/schema': ^1.0.0-rc.6 + '@tmagic/schema': 1.0.0-rc.7 '@types/events': ^3.0.0 '@types/node': ^15.12.4 events: ^3.3.0 @@ -79,11 +91,11 @@ importers: specifiers: '@babel/core': ^7.18.0 '@element-plus/icons': 0.0.11 - '@tmagic/core': ^1.0.0-rc.6 - '@tmagic/form': ^1.0.0-rc.6 - '@tmagic/schema': ^1.0.0-rc.6 - '@tmagic/stage': ^1.0.0-rc.6 - '@tmagic/utils': ^1.0.0-rc.6 + '@tmagic/core': 1.0.0-rc.7 + '@tmagic/form': 1.0.0-rc.7 + '@tmagic/schema': 1.0.0-rc.7 + '@tmagic/stage': 1.0.0-rc.7 + '@tmagic/utils': 1.0.0-rc.7 '@types/events': ^3.0.0 '@types/lodash-es': ^4.17.4 '@types/node': ^15.12.4 @@ -144,7 +156,7 @@ importers: specifiers: '@babel/core': ^7.18.0 '@element-plus/icons': 0.0.11 - '@tmagic/utils': ^1.0.0-rc.6 + '@tmagic/utils': 1.0.0-rc.7 '@types/lodash-es': ^4.17.4 '@types/node': ^15.12.4 '@types/sortablejs': ^1.10.7 @@ -200,9 +212,9 @@ importers: packages/stage: specifiers: '@scena/guides': ^0.17.0 - '@tmagic/core': ^1.0.0-rc.6 - '@tmagic/schema': ^1.0.0-rc.6 - '@tmagic/utils': ^1.0.0-rc.6 + '@tmagic/core': 1.0.0-rc.7 + '@tmagic/schema': 1.0.0-rc.7 + '@tmagic/utils': 1.0.0-rc.7 '@types/events': ^3.0.0 '@types/lodash-es': ^4.17.4 '@types/node': ^15.12.4 @@ -234,7 +246,7 @@ importers: packages/table: specifiers: - '@tmagic/form': ^1.0.0-rc.6 + '@tmagic/form': 1.0.0-rc.7 '@types/color': ^3.0.1 '@types/lodash-es': ^4.17.4 '@types/node': ^15.12.4 @@ -270,7 +282,7 @@ importers: packages/ui: specifiers: '@testing-library/vue': ^6.4.2 - '@tmagic/schema': ^1.0.0-rc.6 + '@tmagic/schema': 1.0.0-rc.7 '@types/qrcode': ^1.4.2 '@vue/compiler-sfc': ^3.2.0 '@vue/test-utils': ^2.0.0 @@ -292,7 +304,7 @@ importers: packages/ui-react: specifiers: - '@tmagic/schema': ^1.0.0-rc.6 + '@tmagic/schema': 1.0.0-rc.7 '@types/react': ^17.0.37 '@types/react-dom': ^17.0.11 qrcode: ^1.5.0 @@ -311,7 +323,7 @@ importers: packages/ui-vue2: specifiers: - '@tmagic/schema': ^1.0.0-rc.6 + '@tmagic/schema': 1.0.0-rc.7 '@vue/composition-api': 1.0.5 qrcode: ^1.5.0 vite: ^2.3.7 @@ -330,7 +342,7 @@ importers: packages/utils: specifiers: - '@tmagic/schema': ^1.0.0-rc.6 + '@tmagic/schema': 1.0.0-rc.7 '@types/node': ^15.12.4 moment: ^2.29.2 typescript: ^4.3.4 @@ -1287,6 +1299,11 @@ packages: resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} dev: true + /@hutson/parse-repository-url/3.0.2: + resolution: {integrity: sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q==} + engines: {node: '>=6.9.0'} + dev: true + /@istanbuljs/schema/0.1.3: resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} engines: {node: '>=8'} @@ -2101,6 +2118,10 @@ packages: hasBin: true dev: true + /add-stream/1.0.0: + resolution: {integrity: sha512-qQLMr+8o0WC4FZGQTcJiKBVC59JylcPSrTtk6usvmIDFUOCKegapy1VHQwRbFMOFyb/inzUVqHs+eMYKDM1YeQ==} + dev: true + /agent-base/6.0.2: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} @@ -2965,6 +2986,32 @@ packages: q: 1.5.1 dev: true + /conventional-changelog-atom/2.0.8: + resolution: {integrity: sha512-xo6v46icsFTK3bb7dY/8m2qvc8sZemRgdqLb/bjpBsH2UyOS8rKNTgcb5025Hri6IpANPApbXMg15QLb1LJpBw==} + engines: {node: '>=10'} + dependencies: + q: 1.5.1 + dev: true + + /conventional-changelog-cli/2.2.2: + resolution: {integrity: sha512-8grMV5Jo8S0kP3yoMeJxV2P5R6VJOqK72IiSV9t/4H5r/HiRqEBQ83bYGuz4Yzfdj4bjaAEhZN/FFbsFXr5bOA==} + engines: {node: '>=10'} + hasBin: true + dependencies: + add-stream: 1.0.0 + conventional-changelog: 3.1.25 + lodash: 4.17.21 + meow: 8.1.2 + tempfile: 3.0.0 + dev: true + + /conventional-changelog-codemirror/2.0.8: + resolution: {integrity: sha512-z5DAsn3uj1Vfp7po3gpt2Boc+Bdwmw2++ZHa5Ak9k0UKsYAO5mH1UBTN0qSCuJZREIhX6WU4E1p3IW2oRCNzQw==} + engines: {node: '>=10'} + dependencies: + q: 1.5.1 + dev: true + /conventional-changelog-conventionalcommits/4.6.3: resolution: {integrity: sha512-LTTQV4fwOM4oLPad317V/QNQ1FY4Hju5qeBIM1uTHbrnCE+Eg4CdRZ3gO2pUeR+tzWdp80M2j3qFFEDWVqOV4g==} engines: {node: '>=10'} @@ -2974,10 +3021,112 @@ packages: q: 1.5.1 dev: true + /conventional-changelog-core/4.2.4: + resolution: {integrity: sha512-gDVS+zVJHE2v4SLc6B0sLsPiloR0ygU7HaDW14aNJE1v4SlqJPILPl/aJC7YdtRE4CybBf8gDwObBvKha8Xlyg==} + engines: {node: '>=10'} + dependencies: + add-stream: 1.0.0 + conventional-changelog-writer: 5.0.1 + conventional-commits-parser: 3.2.4 + dateformat: 3.0.3 + get-pkg-repo: 4.2.1 + git-raw-commits: 2.0.11 + git-remote-origin-url: 2.0.0 + git-semver-tags: 4.1.1 + lodash: 4.17.21 + normalize-package-data: 3.0.3 + q: 1.5.1 + read-pkg: 3.0.0 + read-pkg-up: 3.0.0 + through2: 4.0.2 + dev: true + + /conventional-changelog-ember/2.0.9: + resolution: {integrity: sha512-ulzIReoZEvZCBDhcNYfDIsLTHzYHc7awh+eI44ZtV5cx6LVxLlVtEmcO+2/kGIHGtw+qVabJYjdI5cJOQgXh1A==} + engines: {node: '>=10'} + dependencies: + q: 1.5.1 + dev: true + + /conventional-changelog-eslint/3.0.9: + resolution: {integrity: sha512-6NpUCMgU8qmWmyAMSZO5NrRd7rTgErjrm4VASam2u5jrZS0n38V7Y9CzTtLT2qwz5xEChDR4BduoWIr8TfwvXA==} + engines: {node: '>=10'} + dependencies: + q: 1.5.1 + dev: true + + /conventional-changelog-express/2.0.6: + resolution: {integrity: sha512-SDez2f3iVJw6V563O3pRtNwXtQaSmEfTCaTBPCqn0oG0mfkq0rX4hHBq5P7De2MncoRixrALj3u3oQsNK+Q0pQ==} + engines: {node: '>=10'} + dependencies: + q: 1.5.1 + dev: true + + /conventional-changelog-jquery/3.0.11: + resolution: {integrity: sha512-x8AWz5/Td55F7+o/9LQ6cQIPwrCjfJQ5Zmfqi8thwUEKHstEn4kTIofXub7plf1xvFA2TqhZlq7fy5OmV6BOMw==} + engines: {node: '>=10'} + dependencies: + q: 1.5.1 + dev: true + + /conventional-changelog-jshint/2.0.9: + resolution: {integrity: sha512-wMLdaIzq6TNnMHMy31hql02OEQ8nCQfExw1SE0hYL5KvU+JCTuPaDO+7JiogGT2gJAxiUGATdtYYfh+nT+6riA==} + engines: {node: '>=10'} + dependencies: + compare-func: 2.0.0 + q: 1.5.1 + dev: true + + /conventional-changelog-preset-loader/2.3.4: + resolution: {integrity: sha512-GEKRWkrSAZeTq5+YjUZOYxdHq+ci4dNwHvpaBC3+ENalzFWuCWa9EZXSuZBpkr72sMdKB+1fyDV4takK1Lf58g==} + engines: {node: '>=10'} + dev: true + + /conventional-changelog-writer/5.0.1: + resolution: {integrity: sha512-5WsuKUfxW7suLblAbFnxAcrvf6r+0b7GvNaWUwUIk0bXMnENP/PEieGKVUQrjPqwPT4o3EPAASBXiY6iHooLOQ==} + engines: {node: '>=10'} + hasBin: true + dependencies: + conventional-commits-filter: 2.0.7 + dateformat: 3.0.3 + handlebars: 4.7.7 + json-stringify-safe: 5.0.1 + lodash: 4.17.21 + meow: 8.1.2 + semver: 6.3.0 + split: 1.0.1 + through2: 4.0.2 + dev: true + + /conventional-changelog/3.1.25: + resolution: {integrity: sha512-ryhi3fd1mKf3fSjbLXOfK2D06YwKNic1nC9mWqybBHdObPd8KJ2vjaXZfYj1U23t+V8T8n0d7gwnc9XbIdFbyQ==} + engines: {node: '>=10'} + dependencies: + conventional-changelog-angular: 5.0.13 + conventional-changelog-atom: 2.0.8 + conventional-changelog-codemirror: 2.0.8 + conventional-changelog-conventionalcommits: 4.6.3 + conventional-changelog-core: 4.2.4 + conventional-changelog-ember: 2.0.9 + conventional-changelog-eslint: 3.0.9 + conventional-changelog-express: 2.0.6 + conventional-changelog-jquery: 3.0.11 + conventional-changelog-jshint: 2.0.9 + conventional-changelog-preset-loader: 2.3.4 + dev: true + /conventional-commit-types/3.0.0: resolution: {integrity: sha512-SmmCYnOniSsAa9GqWOeLqc179lfr5TRu5b4QFDkbsrJ5TZjPJx85wtOr3zn+1dbeNiXDKGPbZ72IKbPhLXh/Lg==} dev: true + /conventional-commits-filter/2.0.7: + resolution: {integrity: sha512-ASS9SamOP4TbCClsRHxIHXRfcGCnIoQqkvAzCSbZzTFLfcTqJVugB0agRgsEELsqaeWgsXv513eS116wnlSSPA==} + engines: {node: '>=10'} + dependencies: + lodash.ismatch: 4.4.0 + modify-values: 1.0.1 + dev: true + /conventional-commits-parser/3.2.4: resolution: {integrity: sha512-nK7sAtfi+QXbxHCYfhpZsfRtaitZLIA6889kFIouLvz6repszQDgxBu7wf2WbU+Dco7sAnNCJYERCwt54WPC2Q==} engines: {node: '>=10'} @@ -3135,6 +3284,10 @@ packages: whatwg-url: 11.0.0 dev: true + /dateformat/3.0.3: + resolution: {integrity: sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==} + dev: true + /dayjs/1.11.3: resolution: {integrity: sha512-xxwlswWOlGhzgQ4TKzASQkUhqERI3egRNqgV4ScR8wlANA/A9tZ7miXa44vTTKEq5l7vWoL5G57bG3zA+Kow0A==} dev: false @@ -3341,6 +3494,12 @@ packages: resolution: {integrity: sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw==} dev: false + /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: resolution: {integrity: sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==} engines: {node: '>=8.6'} @@ -3921,6 +4080,21 @@ packages: engines: {node: '>=0.8.x'} dev: false + /execa/4.1.0: + resolution: {integrity: sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==} + engines: {node: '>=10'} + dependencies: + cross-spawn: 7.0.3 + get-stream: 5.2.0 + human-signals: 1.1.1 + is-stream: 2.0.1 + merge-stream: 2.0.0 + npm-run-path: 4.0.1 + onetime: 5.1.2 + signal-exit: 3.0.7 + strip-final-newline: 2.0.0 + dev: true + /execa/5.1.1: resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} engines: {node: '>=10'} @@ -4184,6 +4358,24 @@ packages: resolution: {integrity: sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==} dev: true + /get-pkg-repo/4.2.1: + resolution: {integrity: sha512-2+QbHjFRfGB74v/pYWjd5OhU3TDIC2Gv/YKUTk/tCvAz0pkn/Mz6P3uByuBimLOcPvN2jYdScl3xGFSrx0jEcA==} + engines: {node: '>=6.9.0'} + hasBin: true + dependencies: + '@hutson/parse-repository-url': 3.0.2 + hosted-git-info: 4.1.0 + through2: 2.0.5 + yargs: 16.2.0 + dev: true + + /get-stream/5.2.0: + resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==} + engines: {node: '>=8'} + dependencies: + pump: 3.0.0 + dev: true + /get-stream/6.0.1: resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} engines: {node: '>=10'} @@ -4209,6 +4401,29 @@ packages: through2: 4.0.2 dev: true + /git-remote-origin-url/2.0.0: + resolution: {integrity: sha512-eU+GGrZgccNJcsDH5LkXR3PB9M958hxc7sbA8DFJjrv9j4L2P/eZfKhM+QD6wyzpiv+b1BpK0XrYCxkovtjSLw==} + engines: {node: '>=4'} + dependencies: + gitconfiglocal: 1.0.0 + pify: 2.3.0 + dev: true + + /git-semver-tags/4.1.1: + resolution: {integrity: sha512-OWyMt5zBe7xFs8vglMmhM9lRQzCWL3WjHtxNNfJTMngGym7pC1kh8sP6jevfydJ6LP3ZvGxfb6ABYgPUM0mtsA==} + engines: {node: '>=10'} + hasBin: true + dependencies: + meow: 8.1.2 + semver: 6.3.0 + dev: true + + /gitconfiglocal/1.0.0: + resolution: {integrity: sha512-spLUXeTAVHxDtKsJc8FkFVgFtMdEN9qPGpL23VfSHx4fP4+Ds097IXLvymbnDH8FnmxX5Nr9bPw3A+AQ6mWEaQ==} + dependencies: + ini: 1.3.8 + dev: true + /glob-parent/5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -4292,6 +4507,19 @@ packages: resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} dev: true + /handlebars/4.7.7: + resolution: {integrity: sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==} + engines: {node: '>=0.4.7'} + hasBin: true + dependencies: + minimist: 1.2.6 + neo-async: 2.6.2 + source-map: 0.6.1 + wordwrap: 1.0.0 + optionalDependencies: + uglify-js: 3.16.0 + dev: true + /hard-rejection/2.1.0: resolution: {integrity: sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==} engines: {node: '>=6'} @@ -4408,6 +4636,11 @@ packages: - supports-color dev: true + /human-signals/1.1.1: + resolution: {integrity: sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==} + engines: {node: '>=8.12.0'} + dev: true + /human-signals/2.1.0: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} @@ -4775,6 +5008,10 @@ packages: engines: {node: '>=4'} hasBin: true + /json-parse-better-errors/1.0.2: + resolution: {integrity: sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==} + dev: true + /json-parse-even-better-errors/2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} dev: true @@ -4791,6 +5028,10 @@ packages: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} dev: true + /json-stringify-safe/5.0.1: + resolution: {integrity: sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==} + dev: true + /json5/1.0.1: resolution: {integrity: sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==} hasBin: true @@ -4903,6 +5144,16 @@ packages: wrap-ansi: 7.0.0 dev: true + /load-json-file/4.0.0: + resolution: {integrity: sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw==} + engines: {node: '>=4'} + dependencies: + graceful-fs: 4.2.10 + parse-json: 4.0.0 + pify: 3.0.0 + strip-bom: 3.0.0 + dev: true + /local-pkg/0.4.1: resolution: {integrity: sha512-lL87ytIGP2FU5PWwNDo0w3WhIo2gopIAxPg9RxDYF7m4rr5ahuZxP22xnJHIvaLTe4Z9P6uKKY2UHiwyB4pcrw==} engines: {node: '>=14'} @@ -4945,6 +5196,10 @@ packages: lodash-es: 4.17.21 dev: false + /lodash.ismatch/4.4.0: + resolution: {integrity: sha512-fPMfXjGQEV9Xsq/8MTSgUf255gawYRbjwMyDbcvDhXgV7enSZA0hynz6vMPnpAb5iONEzBHBPsT+0zes5Z301g==} + dev: true + /lodash.kebabcase/4.1.1: resolution: {integrity: sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g==} dev: true @@ -5155,6 +5410,11 @@ packages: hasBin: true dev: true + /modify-values/1.0.1: + resolution: {integrity: sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==} + engines: {node: '>=0.10.0'} + dev: true + /moment/2.29.3: resolution: {integrity: sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw==} dev: false @@ -5202,6 +5462,10 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true + /neo-async/2.6.2: + resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} + dev: true + /node-releases/2.0.5: resolution: {integrity: sha512-U9h1NLROZTq9uE1SNffn6WuPDg8icmi3ns4rEl/oTfIle4iLjTliCzgTsbaIFMq/Xn078/lfY/BL0GWZ+psK4Q==} @@ -5401,6 +5665,14 @@ packages: callsites: 3.1.0 dev: true + /parse-json/4.0.0: + resolution: {integrity: sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==} + engines: {node: '>=4'} + dependencies: + error-ex: 1.3.2 + json-parse-better-errors: 1.0.2 + dev: true + /parse-json/5.2.0: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} @@ -5447,6 +5719,13 @@ packages: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: true + /path-type/3.0.0: + resolution: {integrity: sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==} + engines: {node: '>=4'} + dependencies: + pify: 3.0.0 + dev: true + /path-type/4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} @@ -5468,6 +5747,16 @@ packages: engines: {node: '>=8.6'} dev: true + /pify/2.3.0: + resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==} + engines: {node: '>=0.10.0'} + dev: true + + /pify/3.0.0: + resolution: {integrity: sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==} + engines: {node: '>=4'} + dev: true + /please-upgrade-node/3.2.0: resolution: {integrity: sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==} dependencies: @@ -5552,6 +5841,13 @@ packages: resolution: {integrity: sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==} dev: true + /pump/3.0.0: + resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==} + dependencies: + end-of-stream: 1.4.4 + once: 1.4.0 + dev: true + /punycode/2.1.1: resolution: {integrity: sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==} engines: {node: '>=6'} @@ -5694,6 +5990,14 @@ packages: object-assign: 4.1.1 dev: false + /read-pkg-up/3.0.0: + resolution: {integrity: sha512-YFzFrVvpC6frF1sz8psoHDBGF7fLPc+llq/8NB43oagqWkx8ar5zYtsTORtOjw9W2RHLpWP+zTWwBvf1bCmcSw==} + engines: {node: '>=4'} + dependencies: + find-up: 2.1.0 + read-pkg: 3.0.0 + dev: true + /read-pkg-up/7.0.1: resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} engines: {node: '>=8'} @@ -5703,6 +6007,15 @@ packages: type-fest: 0.8.1 dev: true + /read-pkg/3.0.0: + resolution: {integrity: sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA==} + engines: {node: '>=4'} + dependencies: + load-json-file: 4.0.0 + normalize-package-data: 2.5.0 + path-type: 3.0.0 + dev: true + /read-pkg/5.2.0: resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==} engines: {node: '>=8'} @@ -6106,6 +6419,12 @@ packages: resolution: {integrity: sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==} dev: true + /split/1.0.1: + resolution: {integrity: sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==} + dependencies: + through: 2.3.8 + dev: true + /split2/3.2.2: resolution: {integrity: sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==} dependencies: @@ -6199,7 +6518,7 @@ packages: ansi-regex: 5.0.1 /strip-bom/3.0.0: - resolution: {integrity: sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=} + resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} engines: {node: '>=4'} dev: true @@ -6278,6 +6597,19 @@ packages: strip-ansi: 6.0.1 dev: true + /temp-dir/2.0.0: + resolution: {integrity: sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==} + engines: {node: '>=8'} + dev: true + + /tempfile/3.0.0: + resolution: {integrity: sha512-uNFCg478XovRi85iD42egu+eSFUmmka750Jy7L5tfHI5hQKKtbPnxaSaXAbBqCDYrw3wx4tXjKwci4/QmsZJxw==} + engines: {node: '>=8'} + dependencies: + temp-dir: 2.0.0 + uuid: 3.4.0 + dev: true + /test-exclude/6.0.0: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} @@ -6300,6 +6632,13 @@ packages: resolution: {integrity: sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=} dev: true + /through2/2.0.5: + resolution: {integrity: sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==} + dependencies: + readable-stream: 2.3.7 + xtend: 4.0.2 + dev: true + /through2/4.0.2: resolution: {integrity: sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==} dependencies: @@ -6481,6 +6820,14 @@ packages: hasBin: true dev: true + /uglify-js/3.16.0: + resolution: {integrity: sha512-FEikl6bR30n0T3amyBh3LoiBdqHRy/f4H80+My34HOesOKyHfOsxAPAxOoqC0JUnC1amnO0IwkYC3sko51caSw==} + engines: {node: '>=0.8.0'} + hasBin: true + requiresBuild: true + dev: true + optional: true + /unbox-primitive/1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} dependencies: @@ -6525,6 +6872,12 @@ packages: resolution: {integrity: sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=} dev: true + /uuid/3.4.0: + resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} + deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. + hasBin: true + dev: true + /v8-compile-cache-lib/3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} dev: true @@ -6916,6 +7269,10 @@ packages: engines: {node: '>=0.10.0'} dev: true + /wordwrap/1.0.0: + resolution: {integrity: sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=} + dev: true + /wrap-ansi/6.2.0: resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==} engines: {node: '>=8'} @@ -6959,6 +7316,11 @@ packages: resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==} dev: true + /xtend/4.0.2: + resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} + engines: {node: '>=0.4'} + dev: true + /y18n/4.0.3: resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==} dev: false diff --git a/scripts/release.js b/scripts/release.js new file mode 100644 index 00000000..f5c15dc3 --- /dev/null +++ b/scripts/release.js @@ -0,0 +1,208 @@ +const args = require('minimist')(process.argv.slice(2)); +const fs = require('fs'); +const path = require('path'); +const chalk = require('chalk'); +const semver = require('semver'); +const currentVersion = require('../package.json').version; +const { prompt } = require('enquirer'); +const execa = require('execa'); + +const preId = args.preid || (semver.prerelease(currentVersion) && semver.prerelease(currentVersion)[0]); +const isDryRun = args.dry; +const { skipTests } = args; +const { skipBuild } = args; +const packages = fs + .readdirSync(path.resolve(__dirname, '../packages')) + .filter((p) => !p.endsWith('.ts') && !p.startsWith('.')); + +const skippedPackages = []; + +const versionIncrements = [ + 'patch', + 'minor', + 'major', + ...(preId ? ['prepatch', 'preminor', 'premajor', 'prerelease'] : []), +]; + +const inc = (i) => semver.inc(currentVersion, i, preId); +const run = (bin, args, opts = {}) => execa(bin, args, { stdio: 'inherit', ...opts }); +const dryRun = (bin, args, opts = {}) => console.log(chalk.blue(`[dryrun] ${bin} ${args.join(' ')}`), opts); +const runIfNotDry = isDryRun ? dryRun : run; +const getPkgRoot = (pkg) => path.resolve(__dirname, `../packages/${pkg}`); +const step = (msg) => console.log(chalk.cyan(msg)); + +async function main() { + let targetVersion = args._[0]; + + if (!targetVersion) { + // no explicit version, offer suggestions + const { release } = await prompt({ + type: 'select', + name: 'release', + message: 'Select release type', + choices: versionIncrements.map((i) => `${i} (${inc(i)})`).concat(['custom']), + }); + + if (release === 'custom') { + targetVersion = ( + await prompt({ + type: 'input', + name: 'version', + message: 'Input custom version', + initial: currentVersion, + }) + ).version; + } else { + [, targetVersion] = release.match(/\((.*)\)/); + } + } + + if (!semver.valid(targetVersion)) { + throw new Error(`invalid target version: ${targetVersion}`); + } + + const { yes } = await prompt({ + type: 'confirm', + name: 'yes', + message: `Releasing v${targetVersion}. Confirm?`, + }); + + if (!yes) { + return; + } + + // run tests before release + step('\nRunning tests...'); + if (!skipTests && !isDryRun) { + await run('pnpm', ['test']); + } else { + console.log(`(skipped)`); + } + + // update all package versions and inter-dependencies + step('\nUpdating cross dependencies...'); + updateVersions(targetVersion); + + // build all packages with types + step('\nBuilding all packages...'); + if (!skipBuild && !isDryRun) { + // await run('pnpm', ['run', 'build']); + } else { + console.log(`(skipped)`); + } + + // generate changelog + step('\nGenerating changelog...'); + await run(`pnpm`, ['run', 'changelog']); + + // update pnpm-lock.yaml + step('\nUpdating lockfile...'); + await run(`pnpm`, ['install', '--prefer-offline']); + + const { stdout } = await run('git', ['diff'], { stdio: 'pipe' }); + if (stdout) { + step('\nCommitting changes...'); + await runIfNotDry('git', ['add', '-A']); + // await runIfNotDry('git', ['commit', '-m', `chore: release v${targetVersion}`]); + } else { + console.log('No changes to commit.'); + } + + // publish packages + step('\nPublishing packages...'); + for (const pkg of packages) { + await publishPackage(pkg, targetVersion, runIfNotDry); + } + + // push to GitHub + step('\nPushing to GitHub...'); + await runIfNotDry('git', ['tag', `v${targetVersion}`]); + await runIfNotDry('git', ['push']); + + if (isDryRun) { + console.log(`\nDry run finished - run git diff to see package changes.`); + } + + if (skippedPackages.length) { + console.log( + chalk.yellow(`The following packages are skipped and NOT published:\n- ${skippedPackages.join('\n- ')}`), + ); + } + console.log(); +} + +function updateVersions(version) { + // 1. update root package.json + updatePackage(path.resolve(__dirname, '..'), version); + // 2. update all packages + packages.forEach((p) => updatePackage(getPkgRoot(p), version)); +} + +function updatePackage(pkgRoot, version) { + const pkgPath = path.resolve(pkgRoot, 'package.json'); + const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8')); + pkg.version = version; + updateDeps(pkg, 'dependencies', version); + updateDeps(pkg, 'peerDependencies', version); + fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`); +} + +function updateDeps(pkg, depType, version) { + const deps = pkg[depType]; + if (!deps) return; + Object.keys(deps).forEach((dep) => { + if (dep.startsWith('@tmagic') && packages.includes(dep.replace(/^@tmagic\//, ''))) { + console.log(chalk.yellow(`${pkg.name} -> ${depType} -> ${dep}@${version}`)); + deps[dep] = version; + } + }); +} + +async function publishPackage(pkgName, version, runIfNotDry) { + if (skippedPackages.includes(pkgName)) { + return; + } + const pkgRoot = getPkgRoot(pkgName); + const pkgPath = path.resolve(pkgRoot, 'package.json'); + const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8')); + if (pkg.private) { + return; + } + + let releaseTag = null; + if (args.tag) { + releaseTag = args.tag; + } else if (version.includes('alpha')) { + releaseTag = 'alpha'; + } else if (version.includes('beta')) { + releaseTag = 'beta'; + } else if (version.includes('rc')) { + releaseTag = 'rc'; + } + + step(`Publishing ${pkgName}...`); + try { + await runIfNotDry( + // note: use of yarn is intentional here as we rely on its publishing + // behavior. + 'yarn', + ['publish', '--new-version', version, ...(releaseTag ? ['--tag', releaseTag] : []), '--access', 'public'], + { + cwd: pkgRoot, + stdio: 'pipe', + }, + ); + console.log(chalk.green(`Successfully published ${pkgName}@${version}`)); + } catch (e) { + if (e.stderr.match(/previously published/)) { + console.log(chalk.red(`Skipping already published: ${pkgName}`)); + } else { + throw e; + } + } +} + +main().catch((err) => { + updateVersions(currentVersion); + console.error(err); +});