Skip to content

Commit b363a9b

Browse files
alqmcalqmc
authored andcommitted
Merge branch 'master' into feat/nrm
2 parents 9d2d342 + 270fb2a commit b363a9b

File tree

9 files changed

+94
-89
lines changed

9 files changed

+94
-89
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"tabWidth": 2,
33
"singleQuote": true,
4-
"endOfLine": "crlf",
4+
"endOfLine": "lf",
55
"semi": true
66
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# [v1.2.1](https://github.com/alqmc/gacm/compare/v1.2.0...v1.2.1)(2022-10-24)
2+
3+
4+
## What's Changed
5+
- Fix: gnrm add params error ([#14](https://github.com/alqmc/gacm/pull/#14))
16
# [v1.2.0](https://github.com/alqmc/gacm/compare/v1.1.5...v1.2.0)(2022-10-24)
27

38

dist/gacm.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
1616
var prompts__default = /*#__PURE__*/_interopDefaultLegacy(prompts);
1717

1818
var name$1 = "gacm";
19-
var version$1 = "1.2.0";
19+
var version$1 = "1.2.2";
2020
var description$1 = "git account manage";
2121
var keywords = [
2222
"git",
@@ -82,7 +82,7 @@ const log = {
8282
};
8383

8484
var name = "gacm";
85-
var version = "1.2.0";
85+
var version = "1.2.2";
8686
var description = "gacm";
8787
var scripts = {
8888
build: "gulp --require sucrase/register/ts --gulpfile build/gulpfile.ts",

dist/gnrm.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
1616
var prompts__default = /*#__PURE__*/_interopDefaultLegacy(prompts);
1717

1818
var name$1 = "gacm";
19-
var version$1 = "1.2.0";
19+
var version$1 = "1.2.2";
2020
var description$1 = "git account manage";
2121
var keywords = [
2222
"git",
@@ -82,7 +82,7 @@ const log = {
8282
};
8383

8484
var name = "gacm";
85-
var version = "1.2.0";
85+
var version = "1.2.2";
8686
var description = "gacm";
8787
var scripts = {
8888
build: "gulp --require sucrase/register/ts --gulpfile build/gulpfile.ts",
@@ -377,7 +377,7 @@ const useUse = async ([name], cmd) => {
377377

378378
const useAdd = async (cmd) => {
379379
if (cmd.name && cmd.registry) {
380-
await insertRegistry(cmd.name, cmd.registry, cmd.alias);
380+
await insertRegistry(cmd.name, cmd.alias, cmd.registry);
381381
}
382382
};
383383

dist/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gacm",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"private": false,
55
"description": "git account manage",
66
"keywords": [
@@ -23,4 +23,4 @@
2323
"kolorist": "^1.5.1",
2424
"prompts": "^2.4.2"
2525
}
26-
}
26+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gacm",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"description": "gacm",
55
"scripts": {
66
"build": "gulp --require sucrase/register/ts --gulpfile build/gulpfile.ts",

package/commands/gnrm/useAdd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export interface AddCmd {
88
// 相同的情况直接覆盖更新
99
export const useAdd = async (cmd: AddCmd) => {
1010
if (cmd.name && cmd.registry) {
11-
await insertRegistry(cmd.name, cmd.registry, cmd.alias);
11+
await insertRegistry(cmd.name, cmd.alias, cmd.registry);
1212
}
1313
};

package/commands/gnrm/useLs.ts

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,78 @@
1-
import { gray, green } from 'kolorist';
2-
import prompts from 'prompts';
3-
import { registriesPath } from '../../config/path';
4-
import { getFileUser, writeFileUser } from '../../utils/getUserList';
5-
import { defaultNpmMirror } from '../../config/registry';
6-
import { execCommand } from '../../utils/shell';
7-
import { geneDashLine, printMessages } from '../../utils/tools';
8-
import { log } from '../../utils/log';
9-
import { insertRegistry } from '../../utils/helper';
10-
import type { NrmCmd } from '../../type/shell.type';
11-
12-
export const useLs = async (cmd: NrmCmd) => {
13-
const userConfig = await getFileUser(registriesPath);
14-
let registryList = defaultNpmMirror;
15-
if (userConfig) {
16-
if (!userConfig.registry || userConfig.registry.length === 0) {
17-
userConfig.registry = registryList;
18-
writeFileUser(registriesPath, userConfig);
19-
} else registryList = userConfig.registry;
20-
}
21-
22-
let packageManager = 'npm';
23-
if (cmd.packageManager) packageManager = cmd.packageManager;
24-
// npm config get registry
25-
26-
let currectRegistry = '';
27-
try {
28-
currectRegistry = await execCommand(packageManager, [
29-
'config',
30-
'get',
31-
'registry',
32-
]);
33-
} catch (error) {
34-
log.error(`${packageManager} is not found`);
35-
return;
36-
}
37-
38-
if (registryList.every((x) => x.registry !== currectRegistry)) {
39-
// 默认添加本地源
40-
try {
41-
const { name } = await prompts({
42-
type: 'text',
43-
name: 'name',
44-
message: `find new registry:${currectRegistry}, please give it a name`,
45-
});
46-
await insertRegistry(name, name, currectRegistry);
47-
48-
log.info(`[found new registry]: ${currectRegistry}`);
49-
50-
registryList.push({
51-
name,
52-
registry: currectRegistry,
53-
home: '',
54-
alias: name,
55-
});
56-
} catch (error) {}
57-
}
58-
59-
const length =
60-
Math.max(
61-
...registryList.map((x) => {
62-
return x.alias.length + (x.alias !== x.name ? x.name.length : 0);
63-
})
64-
) + 3;
65-
const prefix = ' ';
66-
67-
const messages = registryList.map((item) => {
68-
const currect = item.registry === currectRegistry ? `${green('*')}` : ' ';
69-
70-
const isSame = item.alias === item.name;
71-
72-
return `${prefix + currect}${
73-
isSame ? item.alias : `${item.alias}(${gray(item.name)})`
74-
}${geneDashLine(item.name, length)}${item.registry}`;
75-
});
76-
77-
printMessages(messages);
78-
};
1+
import { gray, green } from 'kolorist';
2+
import prompts from 'prompts';
3+
import { registriesPath } from '../../config/path';
4+
import { getFileUser, writeFileUser } from '../../utils/getUserList';
5+
import { defaultNpmMirror } from '../../config/registry';
6+
import { execCommand } from '../../utils/shell';
7+
import { geneDashLine, printMessages } from '../../utils/tools';
8+
import { log } from '../../utils/log';
9+
import { insertRegistry } from '../../utils/helper';
10+
import type { NrmCmd } from '../../type/shell.type';
11+
12+
export const useLs = async (cmd: NrmCmd) => {
13+
const userConfig = await getFileUser(registriesPath);
14+
let registryList = defaultNpmMirror;
15+
if (userConfig) {
16+
if (!userConfig.registry || userConfig.registry.length === 0) {
17+
userConfig.registry = registryList;
18+
writeFileUser(registriesPath, userConfig);
19+
} else registryList = userConfig.registry;
20+
}
21+
22+
let packageManager = 'npm';
23+
if (cmd.packageManager) packageManager = cmd.packageManager;
24+
// npm config get registry
25+
26+
let currectRegistry = '';
27+
try {
28+
currectRegistry = await execCommand(packageManager, [
29+
'config',
30+
'get',
31+
'registry',
32+
]);
33+
} catch (error) {
34+
log.error(`${packageManager} is not found`);
35+
return;
36+
}
37+
38+
if (registryList.every((x) => x.registry !== currectRegistry)) {
39+
// 默认添加本地源
40+
try {
41+
const { name } = await prompts({
42+
type: 'text',
43+
name: 'name',
44+
message: `find new registry:${currectRegistry}, please give it a name`,
45+
});
46+
await insertRegistry(name, name, currectRegistry);
47+
48+
log.info(`[found new registry]: ${currectRegistry}`);
49+
50+
registryList.push({
51+
name,
52+
registry: currectRegistry,
53+
home: '',
54+
alias: name,
55+
});
56+
} catch (error) {}
57+
}
58+
59+
const length =
60+
Math.max(
61+
...registryList.map((x) => {
62+
return x.alias.length + (x.alias !== x.name ? x.name.length : 0);
63+
})
64+
) + 3;
65+
const prefix = ' ';
66+
67+
const messages = registryList.map((item) => {
68+
const currect = item.registry === currectRegistry ? `${green('*')}` : ' ';
69+
70+
const isSame = item.alias === item.name;
71+
72+
return `${prefix + currect}${
73+
isSame ? item.alias : `${item.alias}(${gray(item.name)})`
74+
}${geneDashLine(item.name, length)}${item.registry}`;
75+
});
76+
77+
printMessages(messages);
78+
};

package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gacm",
3-
"version": "1.2.0",
3+
"version": "1.2.2",
44
"private": false,
55
"description": "git account manage",
66
"keywords": [

0 commit comments

Comments
 (0)