Skip to content

Commit

Permalink
Merge pull request #17 from alqmc/feat/nrm
Browse files Browse the repository at this point in the history
feat: gnrm use can selete package(fix #16)
  • Loading branch information
kinfuy authored Oct 26, 2022
2 parents 270fb2a + b363a9b commit 598df34
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 38 deletions.
3 changes: 0 additions & 3 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ body:
### **Check if the issue is reproducible with the latest stable version.**
You can use the command `pnpm view gacm versions` to view it
placeholder: latest
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Step to reproduce
description: |
**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.**
placeholder: Please Input
validations:
- type: textarea
id: expected
attributes:
Expand Down
4 changes: 0 additions & 4 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ body:
description: |
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?
placeholder: Please Input
validations:
required: true
- type: textarea
id: feature-api
attributes:
label: What does the proposed API look like
description: |
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.
placeholder: Please Input
validations:
required: true
4 changes: 2 additions & 2 deletions dist/gacm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
var prompts__default = /*#__PURE__*/_interopDefaultLegacy(prompts);

var name$1 = "gacm";
var version$1 = "1.2.1";
var version$1 = "1.2.2";
var description$1 = "git account manage";
var keywords = [
"git",
Expand Down Expand Up @@ -82,7 +82,7 @@ const log = {
};

var name = "gacm";
var version = "1.2.1";
var version = "1.2.2";
var description = "gacm";
var scripts = {
build: "gulp --require sucrase/register/ts --gulpfile build/gulpfile.ts",
Expand Down
41 changes: 28 additions & 13 deletions dist/gnrm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
var prompts__default = /*#__PURE__*/_interopDefaultLegacy(prompts);

var name$1 = "gacm";
var version$1 = "1.2.1";
var version$1 = "1.2.2";
var description$1 = "git account manage";
var keywords = [
"git",
Expand Down Expand Up @@ -82,7 +82,7 @@ const log = {
};

var name = "gacm";
var version = "1.2.1";
var version = "1.2.2";
var description = "gacm";
var scripts = {
build: "gulp --require sucrase/register/ts --gulpfile build/gulpfile.ts",
Expand Down Expand Up @@ -317,26 +317,42 @@ const useLs = async (cmd) => {
printMessages(messages);
};

const defaultPackageManager = ["npm", "yarn", "npm", "pnpm"];
const useUse = async ([name], cmd) => {
const userConfig = await getFileUser(registriesPath);
let registrylist = defaultNpmMirror;
let packageManager = "npm";
if (userConfig && userConfig.registry)
registrylist = userConfig.registry;
let useRegistry = void 0;
if (name) {
useRegistry = registrylist.find((x) => x.alias === name);
} else {
const { registry } = await prompts__default["default"]({
type: "select",
name: "registry",
message: "Pick a registry",
choices: registrylist.map((x) => {
return {
title: `${x.alias}${x.alias === x.name ? "" : `(${x.name})`} ${x.registry}`,
const { registry, pkg } = await prompts__default["default"]([
{
type: "select",
name: "registry",
message: "Pick a registry",
choices: registrylist.map((x) => {
return {
title: `${x.alias}${x.alias === x.name ? "" : `(${x.name})`} ${x.registry}`,
value: x
};
})
},
{
type: "select",
name: "pkg",
message: "Pick a packageManager,and you will set registry for it",
initial: 0,
choices: defaultPackageManager.map((x) => ({
title: x,
value: x
};
})
});
}))
}
]);
if (pkg)
packageManager = pkg;
if (!registry) {
log.error(`user cancel operation`);
return;
Expand All @@ -345,7 +361,6 @@ const useUse = async ([name], cmd) => {
}
if (!useRegistry)
return log.error(`${name} not found`);
let packageManager = "npm";
if (cmd.packageManager)
packageManager = cmd.packageManager;
await execCommand(packageManager, [
Expand Down
2 changes: 1 addition & 1 deletion dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gacm",
"version": "1.2.1",
"version": "1.2.2",
"private": false,
"description": "git account manage",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gacm",
"version": "1.2.1",
"version": "1.2.2",
"description": "gacm",
"scripts": {
"build": "gulp --require sucrase/register/ts --gulpfile build/gulpfile.ts",
Expand Down
43 changes: 30 additions & 13 deletions package/commands/gnrm/useUse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,46 @@ import { log } from '../../utils/log';
import { execCommand } from '../../utils/shell';
import type { NrmCmd, RegistryInfo } from '../../type/shell.type';

const defaultPackageManager = ['npm', 'yarn', 'npm', 'pnpm'];

export const useUse = async ([name]: string[], cmd: NrmCmd) => {
const userConfig = await getFileUser(registriesPath);
let registrylist = defaultNpmMirror;
let packageManager = 'npm';
if (userConfig && userConfig.registry) registrylist = userConfig.registry;

let useRegistry: RegistryInfo | undefined = undefined;
if (name) {
useRegistry = registrylist.find((x) => x.alias === name);
} else {
const { registry } = await prompts({
type: 'select',
name: 'registry',
message: 'Pick a registry',
choices: registrylist.map((x) => {
return {
title: `${x.alias}${x.alias === x.name ? '' : `(${x.name})`} ${
x.registry
}`,
const { registry, pkg } = await prompts([
{
type: 'select',
name: 'registry',
message: 'Pick a registry',
choices: registrylist.map((x) => {
return {
title: `${x.alias}${x.alias === x.name ? '' : `(${x.name})`} ${
x.registry
}`,
value: x,
};
}),
},
{
type: 'select',
name: 'pkg',
message: 'Pick a packageManager,and you will set registry for it',
initial: 0,
choices: defaultPackageManager.map((x) => ({
title: x,
value: x,
};
}),
});
})),
},
]);

if (pkg) packageManager = pkg;

if (!registry) {
log.error(`user cancel operation`);
return;
Expand All @@ -36,7 +54,6 @@ export const useUse = async ([name]: string[], cmd: NrmCmd) => {
}
if (!useRegistry) return log.error(`${name} not found`);

let packageManager = 'npm';
if (cmd.packageManager) packageManager = cmd.packageManager;

await execCommand(packageManager, [
Expand Down
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gacm",
"version": "1.2.1",
"version": "1.2.2",
"private": false,
"description": "git account manage",
"keywords": [
Expand Down

0 comments on commit 598df34

Please sign in to comment.