Skip to content

Commit d30bcc2

Browse files
committed
docs: improve inline help and docs
1 parent e5288f4 commit d30bcc2

23 files changed

+251
-51
lines changed

.github/workflows/runtime-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
4141
- run: npm install ./dist/apps/cli/herodevs-cli-0.0.0-local.tgz
4242

43-
- run: npx @herodevs/cli --version
43+
- run: npx hd --version
4444

45-
- run: npx @herodevs/cli report committers
45+
- run: npx hd report committers
4646

4747
via-sea:
4848
runs-on: ubuntu-latest

README.md

+38-17
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,56 @@
1-
# HeroDevs CLI -- `@herodevs/cli`
1+
# HeroDevs CLI - `@herodevs/cli`
22

3-
## Installation
3+
## Node Setup & Installation
44

5-
```
6-
npm install -g @herodevs/cli
7-
```
8-
9-
## Usage
5+
Node versions 14+
106

11-
after global installation
7+
No installation:
128

139
```
14-
@herodevs/cli ____
10+
npx @herodevs/cli ...
1511
```
1612

17-
or
13+
Global installation:
1814

1915
```
20-
hd ____
16+
npm install -g @herodevs/cli
17+
hd ...
18+
# or
19+
hdcli ...
2120
```
2221

23-
without installation:
22+
## Non-Node or Node < 14 Setup & Installation
2423

25-
```
26-
npx @herodevs/cli ____
24+
Navigate [here](https://github.com/herodevs/cli/releases) to download the version for your operating system from the most recent release.
25+
26+
## Available Commands
27+
28+
```bash
29+
# Initializes your project to use NES libraries
30+
hdcli nes init
2731
```
2832

29-
## Commands
33+
```bash
34+
# Shows a list of committers in git repository
35+
hdcli report committers
36+
```
3037

31-
Get a list of committers within a git repository
38+
```bash
39+
# Shows diagnostic information about your project
40+
hdcli report diagnostics
41+
```
3242

43+
```bash
44+
# Initializes the project for the lines-of-code tracker
45+
hdcli tracker init
3346
```
34-
hd report committers
47+
48+
```bash
49+
# Runs a lines-of-code tracker to gather project
50+
hdcli tracker run
3551
```
52+
53+
## Tutorials
54+
55+
- [Configure your project to consume a Never-Ending Support package](docs/nes-init.md)
56+
- [Get an audit of the users who have committed to a project](docs/git-audit.md)

apps/cli/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"name": "@herodevs/cli",
33
"version": "0.0.0",
4-
"bin": "./src/main.js",
4+
"bin": {
5+
"hd": "./src/main.js",
6+
"hdcli": "./src/main.js"
7+
},
58
"dependencies": {
69
"@apollo/client": "^3.10.1",
710
"@inquirer/prompts": "^5.0.2",

apps/cli/src/lib/cli.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ export function cli(): void {
1212
const packageVersion = pkg.version;
1313

1414
yargs
15-
.scriptName(packageName)
15+
.scriptName('hdcli')
1616
.usage('Usage: $0 <command> [options]')
1717
.middleware(() => ensureVersionIsUpToDate(packageName, packageVersion))
1818
.command(commands)
19+
.showHelpOnFail(false)
1920
.parse(hideBin(process.argv));
2021
}

apps/cli/src/lib/ensure-version.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,13 @@ async function getLatestVersion(pkgName: string) {
4242

4343
export async function isVersionUpToDate(
4444
packageName: string,
45-
packageVersion: string,
46-
quietIfSuccessful = false
45+
packageVersion: string
4746
): Promise<boolean> {
4847
if (packageVersion.startsWith('0.0.0')) {
4948
return true;
5049
}
5150
const latestVersion = await getLatestVersion(packageName);
5251
if (latestVersion === packageVersion) {
53-
if (!quietIfSuccessful) {
54-
console.log(`${packageName}@${latestVersion} is up to date`);
55-
}
5652
return true;
5753
}
5854
console.log(

apps/cli/src/lib/get-commands.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ describe('getCommands', () => {
44
it('should return the commands', () => {
55
const result = getCommands();
66
const commandNames = result.map((command) => command.command);
7-
expect(commandNames.length).toEqual(3);
7+
expect(commandNames.length).toEqual(4);
8+
expect(commandNames).toContain('$0'); // default command
89
expect(commandNames).toContain('nes <command>');
910
expect(commandNames).toContain('report <type>');
1011
expect(commandNames).toContain('tracker <command>');

apps/cli/src/lib/get-commands.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import * as yargs from 'yargs';
2+
import { CommandModule } from 'yargs';
13
import { reportCommittersCommand } from '@herodevs/report-committers';
24
import { reportDiagnosticsCommand } from '@herodevs/report-diagnostics';
35
import { trackerInitCommand } from '@herodevs/tracker-init';
46
import { trackerRunCommand } from '@herodevs/tracker-run';
57
import { createGroupCommand } from './create-group-command';
68
import { nesInitCommand } from '@herodevs/nes-init';
7-
import { CommandModule } from 'yargs';
89

910
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1011
export function getCommands(): CommandModule<any, any>[] {
@@ -38,5 +39,14 @@ export function getCommands(): CommandModule<any, any>[] {
3839
'Invalid tracker command'
3940
);
4041

41-
return [nesCommand, reportCommand, trackerCommand];
42+
return [defaultCommand, nesCommand, reportCommand, trackerCommand];
4243
}
44+
45+
const defaultCommand: CommandModule<object, unknown> = {
46+
command: '$0',
47+
describe: false,
48+
handler: (): void => {
49+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
50+
yargs.showHelp('log');
51+
},
52+
};

docs/git-audit-screenshot.png

69.3 KB
Loading

docs/git-audit.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Git Audit
2+
3+
Get a list of committers in a project.
4+
5+
![screenshot of running a git audit](git-audit-screenshot.png)
6+
7+
## Installation
8+
9+
Follow the instructions [here](installation-and-running.md) to install the HeroDevs CLI.

docs/installation-and-running.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Installation and running the HeroDevs CLI
2+
3+
## Installation
4+
5+
Do you have NodeJS installed with version 14 or higher?
6+
7+
- Yes
8+
- No need to install.
9+
- No
10+
- Get the HeroDevs CLI installer [here](https://github.com/herodevs/cli/releases).
11+
- Download the version for your operating system.
12+
- Unzip the download into your project's root directory.
13+
- The command that you run is based upon your operating system.
14+
- linux: `hdcli`
15+
- mac: `hdcli`
16+
- windows: `hdcli.exe`
17+
18+
## Run
19+
20+
Run the appropriate command based upon your environment. Noting that `...` represents the command and arguments you wish to run
21+
22+
### NodeJS v14+
23+
24+
```bash
25+
npx @herodevs/cli@latest ...
26+
```
27+
28+
### Without NodeJS v14+:
29+
30+
linux/mac:
31+
32+
```bash
33+
hdcli ...
34+
```
35+
36+
windows:
37+
38+
```bash
39+
hdcli.exe ...
40+
```

docs/nes-init-1.png

28 KB
Loading

docs/nes-init-2.png

31.3 KB
Loading

docs/nes-init-3.png

87.7 KB
Loading

docs/nes-init-4.png

54.4 KB
Loading

docs/nes-init-5.png

63.1 KB
Loading

docs/nes-init.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# NES Init
2+
3+
Configure a project to use a [Never-Ending Support](https://www.herodevs.com/support#NES-Products) product.
4+
5+
## Installation
6+
7+
Follow the instructions [here](installation-and-running.md) to install the HeroDevs CLI.
8+
9+
## Running the command
10+
11+
```
12+
hdcli nes init
13+
```
14+
15+
## Steps/procedure
16+
17+
Confirm all changes have been committed to source control/git.
18+
19+
![screenshot of confirmation](nes-init-1.png)
20+
21+
Enter your access token.
22+
23+
![screenshot of entering access token](nes-init-2.png)
24+
25+
Select your product.
26+
27+
![screenshot of entering access token](nes-init-3.png)
28+
29+
Select your version.
30+
31+
![screenshot of entering access token](nes-init-4.png)
32+
33+
CONGRATULATIONS! Your product is now configured to use a NES product.
34+
35+
![screenshot of entering access token](nes-init-5.png)

libs/nes/init/src/lib/get-product-choices.spec.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ describe('getProductChoices', () => {
1818
const mockTrains: any[] = [
1919
{
2020
name: 'b',
21+
products: [{ name: 'b' }],
22+
},
23+
{
24+
name: 'a',
25+
products: [{ name: 'a' }],
2126
},
22-
{ name: 'a' },
2327
];
2428

2529
getReleaseTrainsMock.mockResolvedValue(mockTrains);

libs/nes/init/src/lib/get-product-choices.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,25 @@ import { getReleaseTrains } from './get-release-trains';
66
export async function getProductChoices(
77
accessToken: string,
88
types: ProjectType[]
9-
): Promise<Choice<ReleaseTrain>[]> {
9+
): Promise<Choice<ReleaseTrain[]>[]> {
1010
const releaseTrains = await getReleaseTrains(accessToken, types);
1111

12-
return releaseTrains
13-
.map((rt) => ({
14-
name: rt.name,
15-
value: rt,
12+
const products = releaseTrains.reduce((acc, rt) => {
13+
rt.products.forEach((product) => {
14+
if (acc[product.name]) {
15+
acc[product.name].push(rt);
16+
} else {
17+
acc[product.name] = [rt];
18+
}
19+
});
20+
21+
return acc;
22+
}, {} as { [key: string]: ReleaseTrain[] });
23+
24+
return Object.entries(products)
25+
.map(([key, value]) => ({
26+
name: key,
27+
value,
1628
}))
1729
.sort(sortByName);
1830
}

libs/nes/init/src/lib/init.spec.ts

+49-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getPackageChoices } from './get-package-choices';
55
import { checkbox, confirm, password, select } from '@inquirer/prompts';
66
import { configureProject } from './configure-project';
77
import { Choice, ReleaseTrain } from './models';
8+
import { sortByName } from '@herodevs/utility';
89

910
jest.mock('./verify-project-type');
1011
jest.mock('@inquirer/prompts');
@@ -32,7 +33,7 @@ describe('nesInitCommand', () => {
3233
let getProductChoicesMock: jest.Mock;
3334
let getPackageChoicesMock: jest.Mock;
3435
let mockReleaseTrains: ReleaseTrain[] = [];
35-
let mockReleaseTrainChoices: Choice<ReleaseTrain>[] = [];
36+
let mockReleaseTrainChoices: Choice<ReleaseTrain[]>[] = [];
3637
let configureProjectMock: jest.Mock;
3738

3839
beforeEach(() => {
@@ -74,8 +75,52 @@ describe('nesInitCommand', () => {
7475
},
7576
],
7677
},
78+
{
79+
id: 3,
80+
key: 'release-train-3',
81+
name: 'release train 3',
82+
products: [
83+
{
84+
id: 333,
85+
key: 'vue_essentials',
86+
name: 'Vue 3 Essentials',
87+
},
88+
],
89+
entries: [
90+
{
91+
packageVersion: {
92+
id: 444,
93+
name: '4.5.6',
94+
fqns: '@neverendingsupport/[email protected]',
95+
origination: {
96+
name: 'vue',
97+
type: 'npm',
98+
version: '4.5.6',
99+
},
100+
},
101+
},
102+
],
103+
},
77104
];
78-
mockReleaseTrainChoices = mockReleaseTrains.map((rt) => ({ name: rt.name, value: rt }));
105+
const products = mockReleaseTrains.reduce((acc, rt) => {
106+
rt.products.forEach((product) => {
107+
if (acc[product.name]) {
108+
acc[product.name].push(rt);
109+
} else {
110+
acc[product.name] = [rt];
111+
}
112+
});
113+
114+
return acc;
115+
}, {} as { [key: string]: ReleaseTrain[] });
116+
117+
mockReleaseTrainChoices = Object.entries(products)
118+
.map(([key, value]) => ({
119+
name: key,
120+
value,
121+
}))
122+
.sort(sortByName);
123+
79124
const packageChoices = mockReleaseTrains[0].entries.map((e) => ({
80125
name: e.packageVersion,
81126
value: e,
@@ -87,7 +132,7 @@ describe('nesInitCommand', () => {
87132
});
88133
confirmMock.mockReturnValue(Promise.resolve(true));
89134
passwordMock.mockReturnValue(Promise.resolve('abc123'));
90-
selectMock.mockReturnValue(Promise.resolve(mockReleaseTrains[0]));
135+
selectMock.mockReturnValue(Promise.resolve(mockReleaseTrainChoices[0].value));
91136
checkboxMock.mockReturnValue(Promise.resolve(packageChoices.map((c) => c.value)));
92137
getProductChoicesMock.mockReturnValue(Promise.resolve(mockReleaseTrainChoices));
93138
getPackageChoicesMock.mockReturnValue(packageChoices);
@@ -150,6 +195,7 @@ describe('nesInitCommand', () => {
150195
message: 'select a product',
151196
choices: mockReleaseTrainChoices,
152197
pageSize: mockReleaseTrainChoices.length,
198+
loop: false,
153199
});
154200
});
155201

0 commit comments

Comments
 (0)