Skip to content

Commit 8b29abf

Browse files
Nicholas LiffenNicholas Liffen
Nicholas Liffen
authored and
Nicholas Liffen
committed
v1
1 parent 10f8040 commit 8b29abf

16 files changed

+8571
-3813
lines changed

.env.sample

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DIRECTORY_OF_CSV_CONTENT=__tests__/data/

.eslintrc.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,5 @@
1717
"plugin:jest/recommended",
1818
"prettier"
1919
],
20-
"rules": {
21-
// The following rule is enabled only to supplement the inline suppression
22-
// examples, and because it is not a recommended rule, you should either
23-
// disable it, or understand what it enforces.
24-
// https://typescript-eslint.io/rules/explicit-function-return-type/
25-
"@typescript-eslint/explicit-function-return-type": "warn"
26-
}
20+
"rules": {}
2721
}

.github/FUNDING.yml

-12
This file was deleted.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ coverage
1111

1212
# Transpiled files
1313
build/
14+
lib/
15+
.env
1416

1517
# VS Code
1618
.vscode

README.md

+44-85
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,72 @@
1-
# node-typescript-boilerplate
1+
# Collecting GHAS Unique Active Committers
22

3-
[![Sponsor][sponsor-badge]][sponsor]
4-
[![TypeScript version][ts-badge]][typescript-4-9]
5-
[![Node.js version][nodejs-badge]][nodejs]
6-
[![APLv2][license-badge]][license]
7-
[![Build Status - GitHub Actions][gha-badge]][gha-ci]
3+
## Purpose
84

9-
👩🏻‍💻 Developer Ready: A comprehensive template. Works out of the box for most [Node.js][nodejs] projects.
5+
The purpose of this repository is to help enterprise administrators who maintain multiple GHE instances work out unique developers across multiple GHE instances. This script works for both maximum committers and currently consumed GHAS committers.
106

11-
🏃🏽 Instant Value: All basic tools included and configured:
7+
## Prerequisites
128

13-
- [TypeScript][typescript] [4.9][typescript-4-9]
14-
- [ESM][esm]
15-
- [ESLint][eslint] with some initial rules recommendation
16-
- [Jest][jest] for fast unit testing and code coverage
17-
- Type definitions for Node.js and Jest
18-
- [Prettier][prettier] to enforce consistent code style
19-
- NPM [scripts](#available-scripts) for common operations
20-
- [EditorConfig][editorconfig] for consistent coding style
21-
- Reproducible environments thanks to [Volta][volta]
22-
- Example configuration for [GitHub Actions][gh-actions]
23-
- Simple example of TypeScript code and unit test
9+
- [Node v18](https://nodejs.org/en/download/) or higher installed.
10+
- [Git](https://git-scm.com/downloads) installed on the (user's) machine running this tool.
2411

25-
🤲 Free as in speech: available under the APLv2 license.
12+
## Set up Instructions
2613

27-
## Getting Started
14+
1. Clone this repository onto your local machine.
2815

29-
This project is intended to be used with the latest Active LTS release of [Node.js][nodejs].
16+
```bash
17+
git clone https://github.com/advanced-security/ghes-cross-instance-committers.git
18+
```
3019

31-
### Use as a repository template
20+
2. Change the directory to the repository you have just installed.
3221

33-
To start, just click the **[Use template][repo-template-action]** link (or the green button). Start adding your code in the `src` and unit tests in the `__tests__` directories.
22+
```bash
23+
cd ghes-cross-instance-committers
24+
```
3425

35-
### Clone repository
26+
4. Copy the `.env.sample` to `.env`. On a Mac, this can be done via the following terminal command:
3627

37-
To clone the repository, use the following commands:
28+
```bash
29+
cp .env.sample .env
30+
```
3831

39-
```sh
40-
git clone https://github.com/jsynowiec/node-typescript-boilerplate
41-
cd node-typescript-boilerplate
42-
npm install
43-
```
44-
45-
### Download latest release
32+
## Collecting the content
4633

47-
Download and unzip the current **main** branch or one of the tags:
34+
Head to the following URL in each of your GHES instances:
4835

49-
```sh
50-
wget https://github.com/jsynowiec/node-typescript-boilerplate/archive/main.zip -O node-typescript-boilerplate.zip
51-
unzip node-typescript-boilerplate.zip && rm node-typescript-boilerplate.zip
36+
```
37+
https://${ghes-url}.com/stafftools/ghas_committers
5238
```
5339
54-
## Available Scripts
55-
56-
- `clean` - remove coverage data, Jest cache and transpiled files,
57-
- `prebuild` - lint source files and tests before building,
58-
- `build` - transpile TypeScript to ES6,
59-
- `build:watch` - interactive watch mode to automatically transpile source files,
60-
- `lint` - lint source files and tests,
61-
- `prettier` - reformat files,
62-
- `test` - run tests,
63-
- `test:watch` - interactive watch mode to automatically re-run tests
64-
65-
## Additional Information
40+
If you are interested in knowing your maximum committer number (e.g. the total number of unique developers across your whole GHE instance), click the download button next to the `Total billable committers if GHAS is enabled for all repositories` option.
6641
67-
### Why include Volta
42+
If you are interested in knowing your current committer number (e.g. the total number of unique developers across your whole GHE instance who are curently consuming a GHAS licence), click the download button next to the `Current active committer count` option.
6843
69-
[Volta][volta]’s toolchain always keeps track of where you are, it makes sure the tools you use always respect the settings of the project you’re working on. This means you don’t have to worry about changing the state of your installed software when switching between projects. For example, it's [used by engineers at LinkedIn][volta-tomdale] to standardize tools and have reproducible development environments.
44+
Once that's downloaded, create a new folder and drop the CSV into that folder.
7045
71-
I recommend to [install][volta-getting-started] Volta and use it to manage your project's toolchain.
46+
Repeat the steps above across all your GHES instances. Make sure you drop the content **into the same folder**, you do not need to create a new folder every time.
7247
73-
### ES Modules
48+
## Running the script
7449
75-
This template uses native [ESM][esm]. Make sure to read [this][nodejs-esm], and [this][ts47-esm] first.
50+
1. Install dependencies
7651
77-
If your project requires CommonJS, you will have to [convert to ESM][sindresorhus-esm].
52+
```bash
53+
npm install
54+
```
7855
79-
Please do not open issues for questions regarding CommonJS or ESM on this repo.
56+
3. Update the `.env. (Replace the XXX with the relative directory of the csv content you created above)
8057
81-
## Backers & Sponsors
58+
```bash
59+
DIRECTORY_OF_CSV_CONTENT=XXX
60+
```
8261
83-
Support this project by becoming a [sponsor][sponsor].
62+
2. Run the script
8463
85-
## License
64+
```bash
65+
npm run start
66+
```
8667
87-
Licensed under the APLv2. See the [LICENSE](https://github.com/jsynowiec/node-typescript-boilerplate/blob/main/LICENSE) file for details.
68+
The above script should output something like:
8869
89-
[ts-badge]: https://img.shields.io/badge/TypeScript-4.9-blue.svg
90-
[nodejs-badge]: https://img.shields.io/badge/Node.js->=%2018.12-blue.svg
91-
[nodejs]: https://nodejs.org/dist/latest-v18.x/docs/api/
92-
[gha-badge]: https://github.com/jsynowiec/node-typescript-boilerplate/actions/workflows/nodejs.yml/badge.svg
93-
[gha-ci]: https://github.com/jsynowiec/node-typescript-boilerplate/actions/workflows/nodejs.yml
94-
[typescript]: https://www.typescriptlang.org/
95-
[typescript-4-9]: https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/
96-
[license-badge]: https://img.shields.io/badge/license-APLv2-blue.svg
97-
[license]: https://github.com/jsynowiec/node-typescript-boilerplate/blob/main/LICENSE
98-
[sponsor-badge]: https://img.shields.io/badge/♥-Sponsor-fc0fb5.svg
99-
[sponsor]: https://github.com/sponsors/jsynowiec
100-
[jest]: https://facebook.github.io/jest/
101-
[eslint]: https://github.com/eslint/eslint
102-
[wiki-js-tests]: https://github.com/jsynowiec/node-typescript-boilerplate/wiki/Unit-tests-in-plain-JavaScript
103-
[prettier]: https://prettier.io
104-
[volta]: https://volta.sh
105-
[volta-getting-started]: https://docs.volta.sh/guide/getting-started
106-
[volta-tomdale]: https://twitter.com/tomdale/status/1162017336699838467?s=20
107-
[gh-actions]: https://github.com/features/actions
108-
[repo-template-action]: https://github.com/jsynowiec/node-typescript-boilerplate/generate
109-
[esm]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
110-
[sindresorhus-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
111-
[nodejs-esm]: https://nodejs.org/docs/latest-v16.x/api/esm.html
112-
[ts47-esm]: https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/#esm-nodejs
113-
[editorconfig]: https://editorconfig.org
70+
```
71+
You have a total of XX unique developers across your GitHub instances.
72+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
User login,Organization / repository,Last pushed date
2+
user1,org/repo,2023-01-27
3+
user1,org1/repo2,2022-11-28
4+
user1,org1/repo2,2022-11-28
5+
user2,org1/repo2,2022-11-28
6+
user2,org1/repo2,2022-11-28
7+
user2,org1/repo2,2022-11-28
8+
user2,org1/repo3,2023-01-10
9+
user3,org1/repo2,2022-11-28
10+
user3,org1/repo2,2022-11-28
11+
user3,org1/repo2,2022-11-28
12+
user3,org1/repo2,2022-11-28
13+
user4,org3/repo1,2022-12-16
14+
user4,org5/repo8,2023-01-25
15+
user4,org1/repo2,2022-11-28
16+
user4,org4/repo6,2022-12-02
17+
user4,org8/repo1,2022-12-02
18+
user5,org6/repo2,2023-01-04
19+
user5,org1/repo2,2022-12-01
20+
user5,org2/repo3,2023-01-06
21+
user5,org4/repo9,2023-01-06
22+
user5,org10/repo4,2023-01-06
23+
user6,org1/repo2,2022-11-28
24+
user6,org1/repo2,2022-11-28
25+
user6,org1/repo2,2022-11-28
26+
user6,org9/repo3,2023-01-18
27+
user7,org9/repo3,2023-01-08
28+
user7,org10/repo1,2023-01-10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
User login,Organization / repository,Last pushed date
2+
user1,org/repo,2023-01-27
3+
user1,org1/repo2,2022-11-28
4+
user1,org1/repo2,2022-11-28
5+
user2,org1/repo2,2022-11-28
6+
user2,org1/repo2,2022-11-28
7+
user2,org1/repo2,2022-11-28
8+
user2,org1/repo3,2023-01-10
9+
user1,org1/repo2,2022-11-28
10+
user3,org1/repo2,2022-11-28
11+
user3,org1/repo2,2022-11-28
12+
user1,org1/repo2,2022-11-28
13+
user4,org3/repo1,2022-12-16
14+
user1,org5/repo8,2023-01-25
15+
user4,org1/repo2,2022-11-28
16+
user4,org4/repo6,2022-12-02
17+
user4,org8/repo1,2022-12-02
18+
user5,org6/repo2,2023-01-04
19+
user5,org1/repo2,2022-12-01
20+
user9,org2/repo3,2023-01-06
21+
user5,org4/repo9,2023-01-06
22+
user5,org10/repo4,2023-01-06
23+
user6,org1/repo2,2022-11-28
24+
user2,org1/repo2,2022-11-28
25+
user6,org1/repo2,2022-11-28
26+
user6,org9/repo3,2023-01-18
27+
user12,org9/repo3,2023-01-08
28+
user7,org10/repo1,2023-01-10
29+
user8,org10/repo1,2023-01-10

0 commit comments

Comments
 (0)