Skip to content

Commit b6dfbb4

Browse files
alqmckinfuy
authored andcommitted
style: log style
1 parent 426f58d commit b6dfbb4

File tree

4 files changed

+31
-36
lines changed

4 files changed

+31
-36
lines changed

dist/README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<img width="300px" src="./assets/git.svg">
2+
<img width="300px" src="./package/assets/git.svg">
33
</p>
44

55
<p align="center">
@@ -18,15 +18,17 @@
1818
<br>
1919
</p>
2020

21-
<p align="center"> 极简的git账号管理工具(Git Account Management Tools )</p>
21+
<p align="center"> Git Account Management Tools</p>
22+
23+
English | [简体中文](./README-zh_CN.md)
2224

2325
### Features
2426

25-
-git账户无缝切换
27+
-Seamless switching of GIT account
2628

27-
- 🚀 极简的操作方式,just like nvm
29+
- 🚀Minimalist operation,just like nvm
2830

29-
- 😊 gacm ls 自动添加本地git账户
31+
- 😊 gacm ls Automatically add local git account
3032

3133

3234
### Getting Started
@@ -46,17 +48,23 @@ npm install gacm -g
4648
```shell
4749
## just like nvm
4850

51+
## View the user list, and local users will be automatically added
4952
gacm ls
5053

5154

52-
gacm use xxx ---local
55+
## Switch git account
56+
gacm use xxx ---local
5357

5458
gacm use xxx ---global
5559

60+
61+
## Add user,--alias Optional define user alias
5662
gacm add --name xxx --email xxx --alias xxx
5763

64+
## Define user alias
5865
gacm alias xxxx xxxx
5966

67+
## Delete user
6068
gacm delate user
6169

6270
```

dist/main.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ var pkg = {
4848
dependencies: dependencies
4949
};
5050

51-
const PREFIX = "gacm";
51+
const PREFIX = "[gacm]:";
5252
const success = (msg) => console.log(`
53-
${kolorist.bgLightGreen(PREFIX)}:${kolorist.green(msg)}
53+
${kolorist.green(PREFIX + msg)}
5454
`);
5555
const error = (msg) => console.log(`
56-
${kolorist.bgLightRed(PREFIX)}:${kolorist.red(msg)}
56+
${kolorist.red(PREFIX + msg)}
5757
`);
5858
const warning = (msg) => console.log(`
59-
${kolorist.bgLightYellow(PREFIX)}:${kolorist.lightYellow(msg)}
59+
${kolorist.yellow(PREFIX + msg)}
6060
`);
6161
const info = (msg) => console.log(`
62-
${kolorist.bgLightBlue(PREFIX)}:${kolorist.blue(msg)}
62+
${PREFIX + kolorist.blue(msg)}
6363
`);
6464
const log = {
6565
success,
@@ -158,7 +158,7 @@ const useAction = async (name, cmd) => {
158158
env = "local";
159159
await run(`git config --${env} user.name ${useUser[0].name}`);
160160
await run(`git config --${env} user.email ${useUser[0].email}`);
161-
log.success(`git user changed [${env}]:${useUser[0].alias !== useUser[0].name ? `(${useUser[0].name})` : ""}${useUser[0].alias}`);
161+
log.success(`git user changed [${env}]:${useUser[0].alias}${useUser[0].alias !== useUser[0].name ? `(${useUser[0].name})` : ""}`);
162162
};
163163
const lsAction = async () => {
164164
let userList = await getFileUser(registriesPath) || {};
@@ -203,7 +203,7 @@ const deleteAction = async (name) => {
203203
return log.error(`${name} not found`);
204204
for (let i = 0; i < userList.users.length; i++) {
205205
if (!userList.users[i].alias && userList.users[i].name === name || userList.users[i].alias === name) {
206-
log.success(`[delete]: ${userList.users[i].alias !== userList.users[i].name ? `(${userList.users[i].name})` : ""}${userList.users[i].alias}`);
206+
log.success(`[delete]: ${userList.users[i].alias}${userList.users[i].alias !== userList.users[i].name ? `(${userList.users[i].name})` : ""}`);
207207
userList.users.splice(i, 1);
208208
}
209209
}
@@ -222,7 +222,7 @@ const aliasAction = async (origin, target) => {
222222
if (x.alias === origin) {
223223
if (userList && !isExistAlias(userList?.users, target)) {
224224
x.alias = target;
225-
log.success(`[update]:(${x.name}) ${origin}=>${x.alias}`);
225+
log.success(`[update]: ${origin}=>${x.alias} (${x.name})`);
226226
} else {
227227
log.error(`${target} is exist, please enter another one `);
228228
}
@@ -245,7 +245,7 @@ const insertUser = async (name, email, alias = name) => {
245245
user.alias = alias === name ? user.alias ? user.alias : alias : alias;
246246
user.email = email;
247247
user.name = name;
248-
log.success(`[update]:${user.alias !== name ? `(${user.name})` : ""} ${alias}`);
248+
log.success(`[update]:${alias} ${user.alias !== name ? `(${user.name})` : ""}`);
249249
}
250250
});
251251
} else {
@@ -254,7 +254,7 @@ const insertUser = async (name, email, alias = name) => {
254254
email,
255255
alias
256256
});
257-
log.success(`[add]:${alias && `(${alias})`} ${name}`);
257+
log.success(`[add]: ${alias} ${alias !== name ? `(${name})` : ""}`);
258258
}
259259
await writeFileUser(registriesPath, userList);
260260
};

dist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
"kolorist": "^1.5.1",
2323
"minimist": "^1.2.6"
2424
}
25-
}
25+
}

package/utils/log.ts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
import {
2-
bgLightBlue,
3-
bgLightGreen,
4-
bgLightRed,
5-
bgLightYellow,
6-
blue,
7-
green,
8-
lightYellow,
9-
red,
10-
} from 'kolorist';
11-
const PREFIX = 'gacm';
12-
const success = (msg: string) =>
13-
console.log(`\n ${bgLightGreen(PREFIX)}:${green(msg)}\n`);
14-
const error = (msg: string) =>
15-
console.log(`\n ${bgLightRed(PREFIX)}:${red(msg)}\n`);
16-
const warning = (msg: string) =>
17-
console.log(`\n ${bgLightYellow(PREFIX)}:${lightYellow(msg)}\n`);
18-
const info = (msg: string) =>
19-
console.log(`\n ${bgLightBlue(PREFIX)}:${blue(msg)}\n`);
1+
import { blue, green, red, yellow } from 'kolorist';
2+
const PREFIX = '[gacm]:';
3+
const success = (msg: string) => console.log(`\n${green(PREFIX + msg)}\n`);
4+
const error = (msg: string) => console.log(`\n${red(PREFIX + msg)}\n`);
5+
const warning = (msg: string) => console.log(`\n${yellow(PREFIX + msg)}\n`);
6+
const info = (msg: string) => console.log(`\n${PREFIX + blue(msg)}\n`);
207
export const log = {
218
success,
229
error,

0 commit comments

Comments
 (0)