Compare commits
75 Commits
v2.0.0
...
v2.2.0-nex
Author | SHA1 | Date | |
---|---|---|---|
|
97820aeb9c | ||
|
9dfa1f3dae | ||
|
bf78ae9dce | ||
|
97597c3d71 | ||
|
4f9c923d3b | ||
|
fdb357799c | ||
|
0d2b3a558d | ||
|
61764d6d43 | ||
|
c6e7479b7a | ||
|
46b290aa80 | ||
|
eb50438144 | ||
|
5af2376029 | ||
|
e70557ee7b | ||
|
19d67ba086 | ||
|
d1a261ea11 | ||
|
272215218f | ||
|
80fb1a3b1d | ||
|
eb304f9781 | ||
|
aaa3781d20 | ||
|
332aefb25f | ||
|
f8db7df1fa | ||
|
e8d96f5bfa | ||
|
8d17e1730c | ||
|
ab4bef3cc9 | ||
|
690615ff33 | ||
|
0247a1d217 | ||
|
b0d602913a | ||
|
d7bd75a6e5 | ||
|
deef7d2365 | ||
|
cc4baa2e7a | ||
|
9e363cf1b1 | ||
|
5ad7208983 | ||
|
7d1718e953 | ||
|
863c2645ac | ||
|
ea66e9399e | ||
|
4fe2d07f1f | ||
|
f6989bb074 | ||
|
568d458479 | ||
|
5b3c6d79e0 | ||
|
4f99babd41 | ||
|
274973fd7f | ||
|
37d007814a | ||
|
9705acd4f4 | ||
|
e7c4dd0d63 | ||
|
a7c247d5a5 | ||
|
61d9615e6b | ||
|
145ea9348b | ||
|
fd31bcfc19 | ||
|
40b1871114 | ||
|
f7f9d4af71 | ||
|
d224150e09 | ||
|
27d0b8c74a | ||
|
c5954d9a47 | ||
|
9bc1aa57fa | ||
|
2ed57c1e23 | ||
|
918f8a8281 | ||
|
57eb1a81ac | ||
|
f095537441 | ||
|
d9d94e819c | ||
|
3da3ade364 | ||
|
8975c7657d | ||
|
42d5f64ed1 | ||
|
bd3c955fcf | ||
|
2c10a5b742 | ||
|
1661e6f8e0 | ||
|
5fd3e07811 | ||
|
7327599c78 | ||
|
8da6e2ca19 | ||
|
745877e26d | ||
|
1343e95f52 | ||
|
d0e125fa3e | ||
|
0dc2a51ddf | ||
|
90a2e06350 | ||
|
7841262e74 | ||
|
c9ff7972ed |
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,3 +1,22 @@
|
|||||||
|
# [2.2.0-next.1](https://github.com/simonecorsi/mawesome/compare/v2.1.0...v2.2.0-next.1) (2022-07-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* adds compacted by topics ([9dfa1f3](https://github.com/simonecorsi/mawesome/commit/9dfa1f3dae6c69033c682211c0e6bd9dc5a81eaf))
|
||||||
|
|
||||||
|
# [2.1.0](https://github.com/simonecorsi/mawesome/compare/v2.0.0...v2.1.0) (2022-05-11)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* removes console.log ([7841262](https://github.com/simonecorsi/mawesome/commit/7841262e741f05debb7ffe6fed636a508a8f7c12))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* removes github-token need ([0dc2a51](https://github.com/simonecorsi/mawesome/commit/0dc2a51ddf3cf93414afd674ed3c34ec681f3e4b))
|
||||||
|
|
||||||
# [2.0.0](https://github.com/simonecorsi/mawesome/compare/v1.0.45...v2.0.0) (2022-05-11)
|
# [2.0.0](https://github.com/simonecorsi/mawesome/compare/v1.0.45...v2.0.0) (2022-05-11)
|
||||||
|
|
||||||
|
|
||||||
|
22
README.md
22
README.md
@@ -12,6 +12,7 @@ You can see an example of the output at my own [simonecorsi/awesome](https://git
|
|||||||
- [Requirements](#requirements)
|
- [Requirements](#requirements)
|
||||||
- [Configuration](#configuration)
|
- [Configuration](#configuration)
|
||||||
- [`api-token`](#api-token)
|
- [`api-token`](#api-token)
|
||||||
|
- [`template-path`](#template-path)
|
||||||
- [Example workflow](#example-workflow)
|
- [Example workflow](#example-workflow)
|
||||||
|
|
||||||
<!-- tocstop -->
|
<!-- tocstop -->
|
||||||
@@ -27,14 +28,13 @@ You can see an example of the output at my own [simonecorsi/awesome](https://git
|
|||||||
|
|
||||||
The service can be configured setting the appropriate environment variables or writing an `.env` file.
|
The service can be configured setting the appropriate environment variables or writing an `.env` file.
|
||||||
|
|
||||||
| Variable | Description | Default |
|
| Variable | Description | Default |
|
||||||
| ----------------- | -------------------------------------------------------------------- | -------------------------------- |
|
| ----------------- | ------------------------------------------------------------------- | -------------------------------- |
|
||||||
| `api-token` | Personal github api token. | `${{ secrets.API_TOKEN }}` |
|
| `api-token` | Personal Token is used to avoid rate limit, [read more](#api-token) | `${{ secrets.API_TOKEN }}` |
|
||||||
| `github-token` | Action Token | `${{ secrets.GITHUB_TOKEN }}` |
|
| `github-name` | Name used for the commit | Github Action |
|
||||||
| `github-name` | Name used for the commit, default to action | Github Action |
|
| `github-email` | email used for commit | actions@users.noreply.github.com |
|
||||||
| `github-email` | email used for commit, default to action | actions@users.noreply.github.com |
|
| `template-path` | Custom `README.md` template, [read more](#template-path) |
|
||||||
| `template-path` | Custom output template file ([EJS](https://ejs.co/) template engine) | [TEMPLATE.ejs](./TEMPLATE.ejs) |
|
| `output-filename` | Output filename | `README.md` |
|
||||||
| `output-filename` | Output filename | `README.md` |
|
|
||||||
|
|
||||||
#### `api-token`
|
#### `api-token`
|
||||||
|
|
||||||
@@ -42,6 +42,12 @@ The Personal API Access Token is mandatory to fetch stars from the API without i
|
|||||||
|
|
||||||
You'll have to generate a [personal api token](https://github.com/settings/tokens/new) and then add
|
You'll have to generate a [personal api token](https://github.com/settings/tokens/new) and then add
|
||||||
|
|
||||||
|
#### `template-path`
|
||||||
|
|
||||||
|
If you don't like the output (default example [here](./TEMPLATE.ejs) ), you can provide your custom template that will be rendered using [EJS](https://ejs.co/) template engine.
|
||||||
|
|
||||||
|
Path provided is relative to your current repository directory, if file is not found it will default.
|
||||||
|
|
||||||
## Example workflow
|
## Example workflow
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
|
@@ -4,9 +4,10 @@ branding:
|
|||||||
icon: align-justify
|
icon: align-justify
|
||||||
color: yellow
|
color: yellow
|
||||||
inputs:
|
inputs:
|
||||||
github-token:
|
compact-by-topic:
|
||||||
description: 'Github token'
|
description: 'Generate another page with output compacted by github topics'
|
||||||
required: true
|
default: 'false'
|
||||||
|
required: false
|
||||||
api-token:
|
api-token:
|
||||||
description: 'Personal API Token'
|
description: 'Personal API Token'
|
||||||
required: true
|
required: true
|
||||||
|
2477
package-lock.json
generated
2477
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@@ -22,8 +22,8 @@
|
|||||||
"javascript"
|
"javascript"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^16.2.4",
|
"@commitlint/cli": "^17.0.2",
|
||||||
"@commitlint/config-conventional": "^16.2.4",
|
"@commitlint/config-conventional": "^17.0.2",
|
||||||
"@octokit/rest": "^18.12.0",
|
"@octokit/rest": "^18.12.0",
|
||||||
"@octokit/types": "^6.2.1",
|
"@octokit/types": "^6.2.1",
|
||||||
"@saithodev/semantic-release-backmerge": "^2.1.2",
|
"@saithodev/semantic-release-backmerge": "^2.1.2",
|
||||||
@@ -32,31 +32,31 @@
|
|||||||
"@semantic-release/git": "^10.0.1",
|
"@semantic-release/git": "^10.0.1",
|
||||||
"@semantic-release/github": "^8.0.4",
|
"@semantic-release/github": "^8.0.4",
|
||||||
"@semantic-release/release-notes-generator": "^10.0.3",
|
"@semantic-release/release-notes-generator": "^10.0.3",
|
||||||
"@types/ejs": "^3.1.0",
|
"@types/ejs": "^3.1.1",
|
||||||
"@types/got": "^9.6.12",
|
"@types/got": "^9.6.12",
|
||||||
"@types/node": "^17.0.32",
|
"@types/node": "^17.0.41",
|
||||||
"@types/sinon": "^10.0.11",
|
"@types/sinon": "^10.0.11",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.23.0",
|
"@typescript-eslint/eslint-plugin": "^5.27.1",
|
||||||
"@typescript-eslint/parser": "^5.23.0",
|
"@typescript-eslint/parser": "^5.27.1",
|
||||||
"@vercel/ncc": "^0.33.4",
|
"@vercel/ncc": "^0.34.0",
|
||||||
"eslint": "^8.15.0",
|
"eslint": "^8.17.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"husky": "^8.0.1",
|
"husky": "^8.0.1",
|
||||||
"lint-staged": "^12.4.1",
|
"lint-staged": "^13.0.1",
|
||||||
"markdown-toc": "^1.2.0",
|
"markdown-toc": "^1.2.0",
|
||||||
"nyc": "^15.0.1",
|
"nyc": "^15.0.1",
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"sinon": "^14.0.0",
|
"sinon": "^14.0.0",
|
||||||
"ts-node-dev": "^1.1.8",
|
"ts-node-dev": "^2.0.0",
|
||||||
"typescript": "^4.6.4"
|
"typescript": "^4.7.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.8.0",
|
"@actions/core": "^1.8.2",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"ejs": "^3.1.7",
|
"ejs": "^3.1.8",
|
||||||
"gh-star-fetch": "^1.3.0",
|
"gh-star-fetch": "^1.5.0",
|
||||||
"got": "^11.8.1",
|
"got": "^11.8.1",
|
||||||
"remark": "^14.0.2",
|
"remark": "^14.0.2",
|
||||||
"remark-toc": "^8.0.1"
|
"remark-toc": "^8.0.1"
|
||||||
|
@@ -15,7 +15,7 @@ type File = {
|
|||||||
|
|
||||||
class Git {
|
class Git {
|
||||||
constructor() {
|
constructor() {
|
||||||
const githubToken = core.getInput('github-token', { required: true });
|
const githubToken = core.getInput('api-token', { required: true });
|
||||||
core.setSecret(githubToken);
|
core.setSecret(githubToken);
|
||||||
|
|
||||||
const githubName = core.getInput('github-name') || 'GitHub Actions';
|
const githubName = core.getInput('github-name') || 'GitHub Actions';
|
||||||
|
55
src/index.ts
55
src/index.ts
@@ -1,7 +1,11 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import { readFile } from 'fs/promises';
|
import { readFile } from 'fs/promises';
|
||||||
import ghStarFetch from 'gh-star-fetch';
|
import ghStarFetch, {
|
||||||
|
Options,
|
||||||
|
compactByLanguage,
|
||||||
|
compactByTopic,
|
||||||
|
} from 'gh-star-fetch';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
renderer,
|
renderer,
|
||||||
@@ -27,33 +31,56 @@ export async function main() {
|
|||||||
core.info("Couldn't find template file, using default");
|
core.info("Couldn't find template file, using default");
|
||||||
}
|
}
|
||||||
|
|
||||||
const sortedByLanguages = await ghStarFetch({
|
const opts: Partial<Options> = {
|
||||||
accessToken: core.getInput('api-token', { required: true }),
|
accessToken: core.getInput('api-token', { required: true }),
|
||||||
compactByLanguage: true,
|
};
|
||||||
});
|
|
||||||
console.log('sortedByLanguages :>> ', sortedByLanguages);
|
|
||||||
|
|
||||||
const rendered = await renderer(
|
const results = await ghStarFetch(opts);
|
||||||
|
|
||||||
|
const files = [];
|
||||||
|
|
||||||
|
const compactedByLanguage = compactByLanguage(results);
|
||||||
|
const byLanguage = await renderer(
|
||||||
{
|
{
|
||||||
username: REPO_USERNAME,
|
username: REPO_USERNAME,
|
||||||
stars: Object.entries(sortedByLanguages),
|
stars: Object.entries(compactedByLanguage),
|
||||||
updatedAt: Date.now(),
|
updatedAt: Date.now(),
|
||||||
},
|
},
|
||||||
template
|
template
|
||||||
);
|
);
|
||||||
|
|
||||||
const markdown: string = await generateMd(rendered);
|
files.push(
|
||||||
|
|
||||||
await git.pushNewFiles([
|
|
||||||
{
|
{
|
||||||
filename: MARKDOWN_FILENAME,
|
filename: MARKDOWN_FILENAME,
|
||||||
data: markdown,
|
data: await generateMd(byLanguage),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: 'data.json',
|
filename: 'data.json',
|
||||||
data: JSON.stringify(sortedByLanguages, null, 2),
|
data: JSON.stringify(compactedByLanguage, null, 2),
|
||||||
},
|
}
|
||||||
]);
|
);
|
||||||
|
|
||||||
|
const shouldCompactByTopic =
|
||||||
|
!!core.getInput('compact-by-topic') ||
|
||||||
|
core.getInput('compact-by-topic') === 'true';
|
||||||
|
|
||||||
|
if (shouldCompactByTopic) {
|
||||||
|
const compactedByTopic = compactByTopic(results);
|
||||||
|
const byTopic = await renderer(
|
||||||
|
{
|
||||||
|
username: REPO_USERNAME,
|
||||||
|
stars: Object.entries(compactedByTopic),
|
||||||
|
updatedAt: Date.now(),
|
||||||
|
},
|
||||||
|
template
|
||||||
|
);
|
||||||
|
files.push({
|
||||||
|
filename: 'TOPICS.md',
|
||||||
|
data: await generateMd(byTopic),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await git.pushNewFiles(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
|
Reference in New Issue
Block a user