Skip to content

Commit

Permalink
chore: 使用 lerna 进行 monorepo 改造
Browse files Browse the repository at this point in the history
  • Loading branch information
lexmin0412 committed Apr 15, 2024
1 parent 065c31e commit 4047f9a
Show file tree
Hide file tree
Showing 28 changed files with 2,708 additions and 174 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
- run: npm install pnpm -g
- run: pnpm install
- run: pnpm build
- run: export COMMIT_TOKEN=${{secrets.COMMIT_TOKEN}} && pnpm release
- name: Publish with Lerna
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
GH_TOKEN: ${{secrets.COMMIT_TOKEN}}
run: |
pnpm ci:release
pnpm ci:publish
19 changes: 19 additions & 0 deletions lerna-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
0 silly argv {
0 silly argv _: [ 'create' ],
0 silly argv lernaVersion: '8.1.2',
0 silly argv '$0': 'node_modules/lerna/dist/cli.js',
0 silly argv name: 'core'
0 silly argv }
1 notice cli v8.1.2
2 verbose packageConfigs Package manager "pnpm" detected. Resolving packages using `pnpm-workspace.yaml`.
3 verbose rootPath /Users/cellerchan/code/git_repos/gcm
4 error Error: canceled
4 error at Interface.<anonymous> (/Users/cellerchan/code/git_repos/gcm/node_modules/.pnpm/[email protected]/node_modules/read/dist/commonjs/read.js:89:21)
4 error at Interface.emit (node:events:514:28)
4 error at [_ttyWrite] [as _ttyWrite] (node:internal/readline/interface:1131:18)
4 error at ReadStream.onkeypress (node:internal/readline/interface:270:20)
4 error at ReadStream.emit (node:events:514:28)
4 error at emitKeys (node:internal/readline/utils:357:14)
4 error at emitKeys.next (<anonymous>)
4 error at ReadStream.onData (node:internal/readline/emitKeypressEvents:64:36)
4 error at ReadStream.emit (node:events:514:28)
5 changes: 5 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "1.7.0",
"npmClient": "pnpm"
}
150 changes: 71 additions & 79 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,81 +1,73 @@
{
"name": "@lexmin0412/gcm",
"version": "1.6.14",
"description": "快速切换本地 Git 用户配置",
"main": "./lib/index.js",
"bin": {
"gcm": "./bin/gcm.js",
"gitconf": "./bin/gcm.js"
},
"scripts": {
"test:version": "pnpm build && node lib/index.js --version",
"test:use": "pnpm build && node lib/index.js use github",
"test:add": "pnpm build && node lib/index.js add",
"test:remove": "pnpm build && node lib/index.js remove",
"test:list": "pnpm build && node lib/index.js list",
"test:scan": "pnpm build && node lib/index.js scan",
"test:current": "pnpm build && node lib/index.js current",
"test:doctor": "pnpm build && node lib/index.js doctor",
"test:upgrade": "pnpm build && node lib/index.js upgrade",
"build:commonjs": "rimraf lib && tsc --target es5 --outDir lib --module commonjs --declaration",
"build:es": "rimraf es && tsc --target es6 --outDir es --module es6",
"build": "npm run build:commonjs && npm run build:es",
"ts": "ts-node src/",
"prepublishOnly": "npm run build",
"release": "release-it --ci"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lexmin0412/gcm.git"
},
"keywords": [
"gcm",
"tools",
"cli",
"git",
"userConfig"
],
"author": {
"name": "lexmin0412",
"email": "[email protected]",
"url": "https://blog.cellerchan.top"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/lexmin0412/gcm/issues"
},
"homepage": "https://github.com/lexmin0412/gcm#readme",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"@release-it/conventional-changelog": "^5.1.1",
"@types/inquirer": "^8.2.1",
"@types/node": "^18.6.3",
"@types/semver": "^7.3.12",
"release-it": "^15.5.0",
"rimraf": "^3.0.2",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
},
"files": [
"es",
"lib"
],
"types": "./lib/index.d.ts",
"jsnext:main": "./es/index.js",
"module": "./es/index.js",
"engines": {
"node": ">=18.0.0"
},
"dependencies": {
"@lexmin0412/run": "^0.0.1",
"commander": "^9.4.0",
"figlet": "^1.5.2",
"inquirer": "8.2.3",
"latest-version": "5.1.0",
"picocolors": "^1.0.0",
"semver": "^7.3.7"
}
"name": "root",
"private": true,
"version": "1.6.14",
"description": "快速切换本地 Git 用户配置",
"main": "./lib/index.js",
"bin": {
"gcm": "./bin/gcm.js",
"gitconf": "./bin/gcm.js"
},
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"new:pkg": "lerna create",
"test:version": "pnpm build && node lib/index.js --version",
"test:use": "pnpm build && node lib/index.js use github",
"test:add": "pnpm build && node lib/index.js add",
"test:remove": "pnpm build && node lib/index.js remove",
"test:list": "pnpm build && node lib/index.js list",
"test:scan": "pnpm build && node lib/index.js scan",
"test:current": "pnpm build && node lib/index.js current",
"test:doctor": "pnpm build && node lib/index.js doctor",
"test:upgrade": "pnpm build && node lib/index.js upgrade",
"build": "pnpm --filter=@lexmin0412/gcm* run build",
"ts": "ts-node src/",
"ci:version": "lerna version patch --yes --conventional-commits --create-release github",
"ci:publish": "lerna publish from-package --yes"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lexmin0412/gcm.git"
},
"keywords": [
"gcm",
"tools",
"cli",
"git",
"userConfig"
],
"author": {
"name": "lexmin0412",
"email": "[email protected]",
"url": "https://blog.cellerchan.top"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/lexmin0412/gcm/issues"
},
"homepage": "https://github.com/lexmin0412/gcm#readme",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"@release-it/conventional-changelog": "^5.1.1",
"@types/inquirer": "^8.2.1",
"@types/node": "^18.6.3",
"@types/semver": "^7.3.12",
"lerna": "^8.1.2",
"release-it": "^15.5.0",
"rimraf": "^3.0.2",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
},
"files": [
"es",
"lib"
],
"types": "./lib/index.d.ts",
"jsnext:main": "./es/index.js",
"module": "./es/index.js"
}
3 changes: 3 additions & 0 deletions packages/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lib
es
node_modules
3 changes: 3 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @lexmin0412/gcm-cli

GCM 的命令行接口。
7 changes: 7 additions & 0 deletions packages/cli/__tests__/cli.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const cli = require('..');
const assert = require('assert').strict;

assert.strictEqual(cli(), 'Hello from cli');
console.info('cli tests passed');
File renamed without changes.
59 changes: 59 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@lexmin0412/gcm",
"version": "1.7.0",
"description": "GCM 的命令行接口",
"bin": {
"gcm": "./bin/gcm.js",
"gitconf": "./bin/gcm.js"
},
"keywords": [
"git-config"
],
"author": "lexmin0412 <[email protected]>",
"homepage": "https://github.com/lexmin0412/gcm/tree/main/packages/cli#readme",
"license": "ISC",
"main": "./lib/index.js",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"es",
"lib"
],
"publishConfig": {
"registry": "https://registry.npmmirror.com/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lexmin0412/gcm.git"
},
"scripts": {
"test": "node ./__tests__/cli.test.js",
"build:commonjs": "rimraf lib && tsc --target es5 --outDir lib --module commonjs --declaration",
"build:es": "rimraf es && tsc --target es6 --outDir es --module es6",
"build": "npm run build:commonjs && npm run build:es",
"ts": "ts-node src/"
},
"bugs": {
"url": "https://github.com/lexmin0412/gcm/issues"
},
"devDependencies": {
"@types/node": "^18.6.3",
"rimraf": "^3.0.2",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
},
"dependencies": {
"@lexmin0412/run": "^0.0.1",
"commander": "^9.4.0",
"figlet": "^1.5.2",
"inquirer": "8.2.3",
"latest-version": "5.1.0",
"picocolors": "^1.0.0",
"semver": "^7.3.7"
},
"types": "./lib/index.d.ts",
"jsnext:main": "./es/index.js",
"module": "./es/index.js"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"moduleResolution": "node",
"esModuleInterop": true,
"lib": ["es6", "dom"],
"alwaysStrict": true,
"strictNullChecks": true,
"noImplicitAny": true,
"resolveJsonModule": true
},
"includes": ["src/*"]
}
Loading

0 comments on commit 4047f9a

Please sign in to comment.