Skip to content

Commit 598df34

Browse files
authored
Merge pull request #17 from alqmc/feat/nrm
feat: gnrm use can selete package(fix #16)
2 parents 270fb2a + b363a9b commit 598df34

File tree

8 files changed

+63
-38
lines changed

8 files changed

+63
-38
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

-3
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ body:
1515
### **Check if the issue is reproducible with the latest stable version.**
1616
You can use the command `pnpm view gacm versions` to view it
1717
placeholder: latest
18-
validations:
19-
required: true
2018
- type: textarea
2119
id: reproduce
2220
attributes:
2321
label: Step to reproduce
2422
description: |
2523
**After the replay is turned on, what actions do we need to perform to make the bug appear? Simple and clear steps can help us locate the problem more quickly. Please clearly describe the steps of reproducing the issue. Issues without clear reproducing steps will not be repaired. If the issue marked with 'need reproduction' does not provide relevant steps within 7 days, it will be closed directly.**
2624
placeholder: Please Input
27-
validations:
2825
- type: textarea
2926
id: expected
3027
attributes:

.github/ISSUE_TEMPLATE/feature-request.yml

-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ body:
1010
description: |
1111
Explain your use case, context, and rationale behind this feature request. More importantly, what is the end user experience you are trying to build that led to the need for this feature?
1212
placeholder: Please Input
13-
validations:
14-
required: true
1513
- type: textarea
1614
id: feature-api
1715
attributes:
1816
label: What does the proposed API look like
1917
description: |
2018
Describe how you propose to solve the problem and provide code samples of how the API would work once implemented. Note that you can use Markdown to format your code blocks.
2119
placeholder: Please Input
22-
validations:
23-
required: true

dist/gacm.js

+2-2
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.1";
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.1";
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

+28-13
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.1";
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.1";
85+
var version = "1.2.2";
8686
var description = "gacm";
8787
var scripts = {
8888
build: "gulp --require sucrase/register/ts --gulpfile build/gulpfile.ts",
@@ -317,26 +317,42 @@ const useLs = async (cmd) => {
317317
printMessages(messages);
318318
};
319319

320+
const defaultPackageManager = ["npm", "yarn", "npm", "pnpm"];
320321
const useUse = async ([name], cmd) => {
321322
const userConfig = await getFileUser(registriesPath);
322323
let registrylist = defaultNpmMirror;
324+
let packageManager = "npm";
323325
if (userConfig && userConfig.registry)
324326
registrylist = userConfig.registry;
325327
let useRegistry = void 0;
326328
if (name) {
327329
useRegistry = registrylist.find((x) => x.alias === name);
328330
} else {
329-
const { registry } = await prompts__default["default"]({
330-
type: "select",
331-
name: "registry",
332-
message: "Pick a registry",
333-
choices: registrylist.map((x) => {
334-
return {
335-
title: `${x.alias}${x.alias === x.name ? "" : `(${x.name})`} ${x.registry}`,
331+
const { registry, pkg } = await prompts__default["default"]([
332+
{
333+
type: "select",
334+
name: "registry",
335+
message: "Pick a registry",
336+
choices: registrylist.map((x) => {
337+
return {
338+
title: `${x.alias}${x.alias === x.name ? "" : `(${x.name})`} ${x.registry}`,
339+
value: x
340+
};
341+
})
342+
},
343+
{
344+
type: "select",
345+
name: "pkg",
346+
message: "Pick a packageManager,and you will set registry for it",
347+
initial: 0,
348+
choices: defaultPackageManager.map((x) => ({
349+
title: x,
336350
value: x
337-
};
338-
})
339-
});
351+
}))
352+
}
353+
]);
354+
if (pkg)
355+
packageManager = pkg;
340356
if (!registry) {
341357
log.error(`user cancel operation`);
342358
return;
@@ -345,7 +361,6 @@ const useUse = async ([name], cmd) => {
345361
}
346362
if (!useRegistry)
347363
return log.error(`${name} not found`);
348-
let packageManager = "npm";
349364
if (cmd.packageManager)
350365
packageManager = cmd.packageManager;
351366
await execCommand(packageManager, [

dist/package.json

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

package.json

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

package/commands/gnrm/useUse.ts

+30-13
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,46 @@ import { log } from '../../utils/log';
66
import { execCommand } from '../../utils/shell';
77
import type { NrmCmd, RegistryInfo } from '../../type/shell.type';
88

9+
const defaultPackageManager = ['npm', 'yarn', 'npm', 'pnpm'];
10+
911
export const useUse = async ([name]: string[], cmd: NrmCmd) => {
1012
const userConfig = await getFileUser(registriesPath);
1113
let registrylist = defaultNpmMirror;
14+
let packageManager = 'npm';
1215
if (userConfig && userConfig.registry) registrylist = userConfig.registry;
1316

1417
let useRegistry: RegistryInfo | undefined = undefined;
1518
if (name) {
1619
useRegistry = registrylist.find((x) => x.alias === name);
1720
} else {
18-
const { registry } = await prompts({
19-
type: 'select',
20-
name: 'registry',
21-
message: 'Pick a registry',
22-
choices: registrylist.map((x) => {
23-
return {
24-
title: `${x.alias}${x.alias === x.name ? '' : `(${x.name})`} ${
25-
x.registry
26-
}`,
21+
const { registry, pkg } = await prompts([
22+
{
23+
type: 'select',
24+
name: 'registry',
25+
message: 'Pick a registry',
26+
choices: registrylist.map((x) => {
27+
return {
28+
title: `${x.alias}${x.alias === x.name ? '' : `(${x.name})`} ${
29+
x.registry
30+
}`,
31+
value: x,
32+
};
33+
}),
34+
},
35+
{
36+
type: 'select',
37+
name: 'pkg',
38+
message: 'Pick a packageManager,and you will set registry for it',
39+
initial: 0,
40+
choices: defaultPackageManager.map((x) => ({
41+
title: x,
2742
value: x,
28-
};
29-
}),
30-
});
43+
})),
44+
},
45+
]);
46+
47+
if (pkg) packageManager = pkg;
48+
3149
if (!registry) {
3250
log.error(`user cancel operation`);
3351
return;
@@ -36,7 +54,6 @@ export const useUse = async ([name]: string[], cmd: NrmCmd) => {
3654
}
3755
if (!useRegistry) return log.error(`${name} not found`);
3856

39-
let packageManager = 'npm';
4057
if (cmd.packageManager) packageManager = cmd.packageManager;
4158

4259
await execCommand(packageManager, [

package/package.json

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

0 commit comments

Comments
 (0)