diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml index 209c6f7..0d7b46e 100644 --- a/.github/workflows/contributors.yml +++ b/.github/workflows/contributors.yml @@ -2,12 +2,13 @@ name: gen-org-contributors on: schedule: - - cron: "0 0 * * *" + - cron: '0 0 * * *' workflow_dispatch: jobs: generate: runs-on: ubuntu-latest + if: github.repository == 'EternalHeartTeam/leetcode-practice' steps: - uses: thinkasany/organize-contributors@master with: @@ -16,5 +17,5 @@ jobs: png_path: images/contributors.png json_path: contributors.json branch: svg - commit_message: "chore: update contributors" - excludes_list: "ImgBotApp,github-actions[bot],actions-user,imgbot[bot],dependabot[bot]" \ No newline at end of file + commit_message: 'chore: update contributors' + excludes_list: 'ImgBotApp,github-actions[bot],actions-user,imgbot[bot],dependabot[bot]' diff --git a/.github/workflows/pr-add-label.yml b/.github/workflows/pr-add-label.yml index 5eb10eb..e3e8cae 100644 --- a/.github/workflows/pr-add-label.yml +++ b/.github/workflows/pr-add-label.yml @@ -20,5 +20,5 @@ jobs: with: github_token: ${{ secrets.ACTION_TOKEN }} pr_number: ${{ env.PR_NUMBER }} - organize_name: "EternalHeartTeam" - team_name: "eternalheartteam" + organize_name: EternalHeartTeam + team_name: eternalheartteam diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml new file mode 100644 index 0000000..df27140 --- /dev/null +++ b/.github/workflows/release-cli.yml @@ -0,0 +1,23 @@ +name: Create Cli Release + +on: + push: + tags: + - 'cli-v*' + +jobs: + build: + runs-on: ubuntu-latest + if: github.repository == 'EternalHeartTeam/leetcode-practice' + steps: + - uses: actions/checkout@v3 + # Setup .npmrc file to publish to npm + - uses: actions/setup-node@v3 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + - run: npm install + - run: npm run build-cli + - run: npm run publish-cli + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..f185b90 --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +.tgz +httpData/ diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..38f11c6 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry=https://registry.npmjs.org diff --git a/.release-it.json b/.release-it.json index b42f281..a9c4073 100644 --- a/.release-it.json +++ b/.release-it.json @@ -5,22 +5,26 @@ "autoGenerate": true }, "git": { - "commitMessage": "release: v${version}" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org" + "commitMessage": "feat: v${version}", + "tagName": "cli-v${version}", + "tag": true, + "push": true, + "pushArgs": ["--follow-tags"] }, "npm": { - "publish": true, - "skipChecks": true + "publish": false }, "hooks": { "after:bump": "echo 更新版本成功" }, "plugins": { + "@release-it/bumper": { + "preset": "angular" + }, "@release-it/conventional-changelog": { "preset": "angular", - "infile": "CHANGELOG.md" + "infile": "CHANGELOG.md", + "ignoreRecommendedBump": true } } } diff --git a/CHANGELOG.md b/CHANGELOG.md index d133cf1..47ff5e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,41 +1,157 @@ -# CHANGELOG -## 1.0.5 release [2024-3-] + +## [1.0.5-beta.0](https://github.com/wh131462/leetcode-practice/compare/cli-v1.0.5-bera.0...cli-v1.0.5-beta.0) (2024-03-11) + +## [1.0.5-bera.0](https://github.com/wh131462/leetcode-practice/compare/cli-v1.0.4-beta...cli-v1.0.5-bera.0) (2024-03-11) + +## [1.0.4-beta](https://github.com/wh131462/leetcode-practice/compare/cli-v0.0.1...cli-v1.0.4-beta) (2024-03-11) + +## 1.0.4 (2024-03-11) + +### Bug Fixes + +- add break before default ([08094b4](https://github.com/wh131462/leetcode-practice/commit/08094b4389a3fd1e442615dd687a55a08bd5ac62)) +- change ([1eb6e3c](https://github.com/wh131462/leetcode-practice/commit/1eb6e3c5ba35b22d7d3ef6893b6ace2d80050d6e)) +- change ([0801a1d](https://github.com/wh131462/leetcode-practice/commit/0801a1d6c63fef76d570ed7d943bd0d6f85c70e6)) +- change template ([872e867](https://github.com/wh131462/leetcode-practice/commit/872e867021c347e1fe4236e94cbd67aed47010a9)) +- console table text length verflow dislocation error ([3a563a2](https://github.com/wh131462/leetcode-practice/commit/3a563a2169bae2dd0ef26fb16e9bdedce21c8be2)) +- correct packageManager's format (fix [#7](https://github.com/wh131462/leetcode-practice/issues/7)) ([faa2280](https://github.com/wh131462/leetcode-practice/commit/faa2280746facefd2bd11d45d85cc70026821c0c)) +- delete src ([a932ce4](https://github.com/wh131462/leetcode-practice/commit/a932ce42227a8fab5d83d8bbe7a2add78c0d26a6)) +- delete src file ([2a53e63](https://github.com/wh131462/leetcode-practice/commit/2a53e634bbb7da7f0bf9df129901bb4c7839ba57)) +- find question by keyword error ([69da517](https://github.com/wh131462/leetcode-practice/commit/69da51740ff7f78a89c05ea534f80cc56f588d7f)) +- find question list ([6f78bfa](https://github.com/wh131462/leetcode-practice/commit/6f78bfa8fbab5d375f48d541c1b50bbfec55f9aa)) +- fix all lint error ([e99e76b](https://github.com/wh131462/leetcode-practice/commit/e99e76b2e1c7c9d387ab658a4c1f4057bf1a60da)) +- format readme form ([f002d77](https://github.com/wh131462/leetcode-practice/commit/f002d77f6e3f9e9a1259de2a5fee4b1858768620)) +- format readme form ([df5e45c](https://github.com/wh131462/leetcode-practice/commit/df5e45c9d55fc98dbe6bbc5b7fc80d6716d5bd34)) +- format readme form ([2f182ca](https://github.com/wh131462/leetcode-practice/commit/2f182ca85575fa8d2963fc0e657ee425b2215153)) +- format readme lint ([85b97f6](https://github.com/wh131462/leetcode-practice/commit/85b97f64258eadf4dcf1b29747e0ed0c3d161440)) +- getTestCase ([4ac7f65](https://github.com/wh131462/leetcode-practice/commit/4ac7f6505a47ab60d4ea74c659bb49c0d19667e6)) +- **headers:** remove useless header configuration ([105c841](https://github.com/wh131462/leetcode-practice/commit/105c84141206dfcf11d6a4ea46775f7546150acd)) +- **headers:** remove useless header configuration ([3ba1a98](https://github.com/wh131462/leetcode-practice/commit/3ba1a982a5e1d4c3b29d09af40df910f9d9dd3a5)) +- ignore lint ([46a9135](https://github.com/wh131462/leetcode-practice/commit/46a91358376a387b1e395e99424012685c21e09b)) +- ignore lint ([d376299](https://github.com/wh131462/leetcode-practice/commit/d376299a7f7e20453aaee978bba4178079b1e931)) +- lint ([cc63e57](https://github.com/wh131462/leetcode-practice/commit/cc63e572de4afa50b82791e1e896234b8d6b8ee4)) +- listnode check ([b8b3b47](https://github.com/wh131462/leetcode-practice/commit/b8b3b475637647035ac3eb9bfc5b27b61bde9a49)) +- log ([bd1d01b](https://github.com/wh131462/leetcode-practice/commit/bd1d01b4a440f8f80dfc67b04180dde29bac9da9)) +- memory calc error ([c09b344](https://github.com/wh131462/leetcode-practice/commit/c09b3440f81d0a3d6bf740aec06b320e00574b2c)) +- perfect version for cli install ([5a257f4](https://github.com/wh131462/leetcode-practice/commit/5a257f43fe897be40dd64a8ff8532387290a15fa)) +- readme_cn ([63dab20](https://github.com/wh131462/leetcode-practice/commit/63dab20f3956ae5f2abbc5df721c4ccc61d90bd2)) +- rename README ([2b8c294](https://github.com/wh131462/leetcode-practice/commit/2b8c294b0259d3476285ca985b8ad1e3fb2c6c2b)) +- rewrite log ([53d15b4](https://github.com/wh131462/leetcode-practice/commit/53d15b491c57d9e36a6fd6c36193517edb915425)) +- search ([5bb93dd](https://github.com/wh131462/leetcode-practice/commit/5bb93dd323c0786a17b1a4e4eae1ae3e1ba9625b)) +- **store:** fix the bug for create dir outside ([7254f29](https://github.com/wh131462/leetcode-practice/commit/7254f2988a656c28c0e7fbc685e16ff85cc1cbe6)) +- **tempate:** 修复空格导致字符串匹配失效问题 ([07bdbdc](https://github.com/wh131462/leetcode-practice/commit/07bdbdc88b1e50c781a65863dd1ba45c98eb5d79)) +- **test:** 修复挂掉的测试用例 ([4593058](https://github.com/wh131462/leetcode-practice/commit/4593058a065accc9e55e916352013de7bc6d4533)) +- update view for cli ([0b8ecf0](https://github.com/wh131462/leetcode-practice/commit/0b8ecf0ac7b2567168e35a6513308825aa514070)) +- 优化代码 ([da6aa6d](https://github.com/wh131462/leetcode-practice/commit/da6aa6d5ab87c4ecb626f1762033062a9ac432e4)) +- 修复原始创建不中止问题 ([ddb0ea1](https://github.com/wh131462/leetcode-practice/commit/ddb0ea11ca02abe73ee80ec8b0130466efbce457)) +- 模版文件路径错误 ([e46c94c](https://github.com/wh131462/leetcode-practice/commit/e46c94c85583b367d831326e4e873512b6ccf504)) + +### Code Refactoring + +- directory refactor ([7a3a948](https://github.com/wh131462/leetcode-practice/commit/7a3a94806a1843e1c4bb86ece65d4e19ef9817fa)) + +- cli finish basically (#5) ([5af52e3](https://github.com/wh131462/leetcode-practice/commit/5af52e31b466517d2fdea9443376d27bff646bdf)), closes [#5](https://github.com/wh131462/leetcode-practice/issues/5) ### Features -- Added eslint, prettier, and commit-lint to development dependencies. -- Implemented a hot 100 list feature and added keyword search functionality. +- add ([fb3fadc](https://github.com/wh131462/leetcode-practice/commit/fb3fadc7fca166be0eefe51a817899466ab48b27)) +- add cz plugin ([4fd5af1](https://github.com/wh131462/leetcode-practice/commit/4fd5af151ac32d3daabcdc862505962fcd32f129)) +- add eslint ([be523ea](https://github.com/wh131462/leetcode-practice/commit/be523ea0f3085e003a2e0b5fb1c568b65cc21714)) +- add get question ([e5572b6](https://github.com/wh131462/leetcode-practice/commit/e5572b6357c8c056aa32eab53476736561261ebe)) +- add get question by keyword function ([097302a](https://github.com/wh131462/leetcode-practice/commit/097302afe095ad70d1c58942dc8ac8fb516e1eed)) +- add getQuestionChineseName function to get chinese name ([9520e75](https://github.com/wh131462/leetcode-practice/commit/9520e757741ff008439affd20db582458a37b674)) +- add getQuestionCode ([dbdb255](https://github.com/wh131462/leetcode-practice/commit/dbdb2553a2c47c9ee40fada33bfec7458ae4ccb6)) +- add memory calculate ([e6c315a](https://github.com/wh131462/leetcode-practice/commit/e6c315ab1524327697278e3b41c622fb22928896)) +- add memory demo ([8065924](https://github.com/wh131462/leetcode-practice/commit/8065924ca451e043f80644a31eb5d9543946f026)) +- add open process ([80dc9f5](https://github.com/wh131462/leetcode-practice/commit/80dc9f530eaae98e5449b3ebdf5c9e69ec452a17)) +- add prettier and commitlint ([608f4df](https://github.com/wh131462/leetcode-practice/commit/608f4dfdc4c0aebb9ead3e46abcde71fcc962b39)) +- change git push rules ([ee3e558](https://github.com/wh131462/leetcode-practice/commit/ee3e558496ef72f2daee071b88e79ddd06503e7c)) +- **cli:** 简化命令 使得命令可以在任何路径下运行 ([26fcffb](https://github.com/wh131462/leetcode-practice/commit/26fcffb8daa0e0a70e78c47772ef5059c1c825d1)) +- **commit:** finish set question range tag in file and get code in file by range tag ([61e2924](https://github.com/wh131462/leetcode-practice/commit/61e2924d2607e96bbd37947f05e718a10ac9edd6)) +- eslint忽略文件 ([f91889c](https://github.com/wh131462/leetcode-practice/commit/f91889c8348766a63136ada6fcd49e79a0e54378)) +- finish the view create & check ([9e96e0a](https://github.com/wh131462/leetcode-practice/commit/9e96e0a24f0232827196ce2bdb6c3d04966f42bd)) +- get js code ([b1fd6bb](https://github.com/wh131462/leetcode-practice/commit/b1fd6bb8d85d080c1f89a53cd99416c84e3abd10)) +- hot100合并代码 ([3ddd7c6](https://github.com/wh131462/leetcode-practice/commit/3ddd7c6237bd43655c4e3d0e490bd997afb1df5a)) +- node vm执行index.js脚本 ([f894e30](https://github.com/wh131462/leetcode-practice/commit/f894e3096c15d9939e0b93688f37c4272775d300)) +- publish config & build config ([1affd2a](https://github.com/wh131462/leetcode-practice/commit/1affd2ab7b1e1ad942d5dc3fbe5c300b5a92f240)) +- sucess log with green and fail log with red ([1eccefb](https://github.com/wh131462/leetcode-practice/commit/1eccefb023d28ca734c1886e0dc64a576d03f860)) +- update function basic ([a01c873](https://github.com/wh131462/leetcode-practice/commit/a01c8738aa060221421f2f17158c92a9069929a0)) +- update project using github ([a879d29](https://github.com/wh131462/leetcode-practice/commit/a879d29f9686f5c71d02bfe5c9122bc6fc90dc81)) +- v1.0.4 ([87428c2](https://github.com/wh131462/leetcode-practice/commit/87428c2c18200492e79e332a149d5af3c8eb6408)) +- v1.0.4 ([8356a57](https://github.com/wh131462/leetcode-practice/commit/8356a57b4d6908d40906d4759cb04367f34e09c3)) +- v1.0.4 ([9c6fca0](https://github.com/wh131462/leetcode-practice/commit/9c6fca0e433f013340dfed5c3e495789dc7e84ca)) +- version 1.0.2 ([4afe55e](https://github.com/wh131462/leetcode-practice/commit/4afe55e35ecea82dedbba3e6a3d9a2738365aa79)) +- **忽略测试覆盖率文件:** 忽略测试覆盖率文件 ([b05e380](https://github.com/wh131462/leetcode-practice/commit/b05e380ef84384f5f1ebbfb64628bd689933f755)) +- 新增填充markdown功能 ([1b8324d](https://github.com/wh131462/leetcode-practice/commit/1b8324d212898e8d0b7b2edc15244da31157a3c9)) +- 新增无向连通图数据结构 parse toArray实现,补充测试用例等 fix: 优化了转换逻辑 ([08f3787](https://github.com/wh131462/leetcode-practice/commit/08f3787f70de41d82610c1ce940f35c878dbf0d1)) +- 新增测试覆盖率 ([2627ecd](https://github.com/wh131462/leetcode-practice/commit/2627ecd00105d4af59e5c2fa59608da1144f17a8)) +- 测试用例中补充树和链表的数据结构以及转换逻辑,新增单元测试模块 ([ac9ccd1](https://github.com/wh131462/leetcode-practice/commit/ac9ccd155358306f667e9ffaa0aac9f16d58988a)) +- 统一数据结构 ([f15a8da](https://github.com/wh131462/leetcode-practice/commit/f15a8dad2500cef476e1340b93053be48364bf3e)) + +### Performance Improvements + +- better scripts and easy mode to create question in project ([ffd9e29](https://github.com/wh131462/leetcode-practice/commit/ffd9e29ca35d9f4b8b6b2f8b94516e8f053261a5)) +- http dir structure and functions modify ([553ad58](https://github.com/wh131462/leetcode-practice/commit/553ad5861aa67423c1092f798f39b2bd4faf68f6)) + +### BREAKING CHANGES + +- srcipts即将废弃,视图交互性代码完善1/3 + +- feat: finish the view create & check + +- feat:完成lc&lk指令 + +- fix: 优化代码 + +- feat: add getQuestionChineseName function to get chinese name + +- chore: del scripts and .vscode files & ignore .vscode + +- docs: update todo & achive + +- perf: better scripts and easy mode to create question in project + +- feat: publish config & build config + +- chore: del src + +- fix: perfect version for cli install + +- fix:指令打包完善 + +- fix:easy mode script -## 1.0.4 release [2024-3-5 22:10] +- docs:todo 拆分成单独文件 -### Fixes +- chore:路径调整成全局路径 -- fix the bug cannot create question +- docs: add CHANGELOG and TO-DO +- srcipts即将废弃,视图交互性代码完善1/3 -## 1.0.3 release [2024-3-3 20:26] +# 1.0.3 [2024-03-03] ### Features -- you can create question in any supported language file -- the file name from 'index' to 'question' +- You can now create questions in any supported language file. +- Renamed the file from 'index' to 'question'. -## 1.0.2 release [2024-2-29 19:02] +# 1.0.2 [2024-02-29] ### Features -- add i18n docs +- Added i18n docs. -## 1.0.1 release [2024-2-8 13:49] +# 1.0.1 [2024-02-08] ### Features -- add `author` info and `repository` in package.json +- Added `author` info and `repository` in package.json. -## 1.0.0 release [2024-2-8 13:49] +# 1.0.0 [2024-02-08] ### Features -- cli: lk/lf/lc 脚本实现 检测/查找/创建 功能,强而有力地支持了题目的便捷创建. -- template project: easy mode 实现交互性创建,leet-create和leet-check保持src目录下创建题解. -- plugin: 插件化的设计完善,进行立项. +- **CLI:** Implemented scripts lk/lf/lc for detection, search, and creation functions, providing convenient creation of questions. +- **Template Project:** Implemented interactive creation with easy mode, leet-create and leet-check now create solutions under the src directory. +- **Plugin:** Perfected the plugin design and initiated the project. diff --git a/README.md b/README.md index 1a1a1df..d1ed329 100644 --- a/README.md +++ b/README.md @@ -499,4 +499,4 @@ If you encounter any `issues` or have some `great suggestions`, feel free to joi ## Star History -[![Star History Chart](https://api.star-history.com/svg?repos=EternalHeartTeam/leetcode-practice&type=Date)](https://star-history.com/#EternalHeartTeam/leetcode-practice&Date) \ No newline at end of file +[![Star History Chart](https://api.star-history.com/svg?repos=EternalHeartTeam/leetcode-practice&type=Date)](https://star-history.com/#EternalHeartTeam/leetcode-practice&Date) diff --git a/common/utils/file/getRootPath.js b/common/utils/file/getRootPath.js index 5f7b831..0971a80 100644 --- a/common/utils/file/getRootPath.js +++ b/common/utils/file/getRootPath.js @@ -1,6 +1,7 @@ import path from 'node:path' import { __dirname } from '#common/utils/file/getDirname.js' import { currentEnv } from '#common/utils/etc/checkEnv.js' + // 在cli环境下 执行目录为 bin 目录 根目录就是上一层目录 export const rootPath = currentEnv() === 'project' diff --git a/package.json b/package.json index 0d60a9d..9456a1e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "leetcode-practice", "type": "module", - "version": "1.0.4", + "version": "1.0.5-beta.0", "packageManager": "yarn@1.22.0", "description": "A powerful practice platform for leetcode.Using any way you want to create questions.", "author": { @@ -29,6 +29,7 @@ "lc": "node bin/lc.js -d src", "lk": "node bin/lk.js -d src", "lf": "node bin/lf.js -d src", + "release:cli": "node scripts/release.js", "update": "node scripts/update.js", "build-cli": "node esbuild.config.js", "publish-cli": "cd pl-cli && npm publish --registry https://registry.npmjs.org/", @@ -62,6 +63,7 @@ "@antfu/eslint-config": "^2.8.0", "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", + "@release-it/bumper": "^6.0.1", "@release-it/conventional-changelog": "^8.0.1", "@types/node": "^20.11.5", "@vitest/coverage-v8": "^1.2.2", diff --git a/scripts/release.js b/scripts/release.js new file mode 100644 index 0000000..0f81b06 --- /dev/null +++ b/scripts/release.js @@ -0,0 +1,52 @@ +import fs from 'node:fs' +import { fileURLToPath } from 'node:url' +import path, { dirname } from 'node:path' +import * as child_process from 'node:child_process' +import packageJson from '../package.json' assert { type: 'json' } + +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) +;(async function () { + // 自动更新版本 + // version可以传递如 6.1.1 | patch | minor | major + const execCommand = (arr) => + (Array.isArray(arr) ? arr : [arr]).forEach((c) => { + try { + console.log(`start: ${c}...`) + console.log(child_process.execSync(c).toString('utf8')) + } catch (error) { + console.log('\x1B[31m%s\x1B[0m', error.stdout.toString()) + process.exit(1) + } + }) + const getNewVersion = (oldVersion, version = 'patch') => { + // [ | major | minor | patch] + if (/^([0-9]+\.*)+$/.test(version)) return version + const types = ['major', 'minor', 'patch'] + const index = types.indexOf(version) + if (index >= 0) { + const versionArr = oldVersion.split('.') + versionArr[index] = Number(versionArr[index]) + 1 + return versionArr.map((e, i) => (i > index ? 0 : e)).join('.') + } + return getNewVersion(oldVersion) + } + const newVersionObj = { + version: getNewVersion(packageJson.version, process.argv[2]) + } + fs.writeFileSync( + path.resolve(__dirname, '../package.json'), + `${JSON.stringify( + Object.assign({}, packageJson, newVersionObj), + null, + 2 + )}\n` + ) + console.log(newVersionObj) + execCommand([ + `git commit -a -m 'chore: update version cli-v${newVersionObj.version}'`, + `git tag cli-v${newVersionObj.version}`, + 'git push && git push --tags' + ]) + console.log('\x1B[32m%s\x1B[0m', '发布完成,请关注github CI构建') +})()