39 Commits

Author SHA1 Message Date
Conventional Changelog Action
f7a8341bb1 chore(release): v1.0.39 2021-08-31 09:17:17 +00:00
Simone Corsi
c361d6e2b6 Merge pull request #12 from simonecorsi/dependabot/npm_and_yarn/path-parse-1.0.7
build(deps): bump path-parse from 1.0.6 to 1.0.7
2021-08-31 11:16:32 +02:00
dependabot[bot]
ef137b518e build(deps): bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-12 23:57:13 +00:00
Conventional Changelog Action
3e66d85077 chore(release): v1.0.38 2021-06-23 22:10:04 +00:00
Conventional Changelog Action
16430922c4 chore(release): v1.0.37 2021-06-23 22:09:38 +00:00
Simone Corsi
20b7de127d Merge pull request #7 from simonecorsi/dependabot/npm_and_yarn/hosted-git-info-2.8.9
build(deps): bump hosted-git-info from 2.8.8 to 2.8.9
2021-06-24 00:09:33 +02:00
Simone Corsi
9def6961a9 Merge pull request #9 from simonecorsi/dependabot/npm_and_yarn/normalize-url-4.5.1
build(deps): bump normalize-url from 4.5.0 to 4.5.1
2021-06-24 00:09:23 +02:00
Simone Corsi
f846c5ee47 Merge pull request #10 from simonecorsi/dependabot/npm_and_yarn/glob-parent-5.1.2
build(deps): bump glob-parent from 5.1.1 to 5.1.2
2021-06-24 00:09:00 +02:00
Simone Corsi
8133f1f32e Merge branch 'main' into dependabot/npm_and_yarn/normalize-url-4.5.1 2021-06-24 00:08:00 +02:00
Simone Corsi
19e564c928 Merge branch 'main' into dependabot/npm_and_yarn/glob-parent-5.1.2 2021-06-24 00:07:19 +02:00
Conventional Changelog Action
9c0b62271d chore(release): v1.0.36 2021-06-23 22:05:32 +00:00
GitHub Actions
7ceb9cb783 feat: saving json data for future use 2021-06-24 00:04:22 +02:00
Conventional Changelog Action
cee1906a39 chore(release): v1.0.35 2021-06-22 13:35:23 +00:00
Simone Corsi
0211f01bfb Merge pull request #11 from simonecorsi/dependabot/npm_and_yarn/set-getter-0.1.1
build(deps): bump set-getter from 0.1.0 to 0.1.1
2021-06-22 15:34:31 +02:00
dependabot[bot]
970d603c2e build(deps): bump set-getter from 0.1.0 to 0.1.1
Bumps [set-getter](https://github.com/doowb/set-getter) from 0.1.0 to 0.1.1.
- [Release notes](https://github.com/doowb/set-getter/releases)
- [Commits](https://github.com/doowb/set-getter/commits/0.1.1)

---
updated-dependencies:
- dependency-name: set-getter
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-21 21:38:21 +00:00
dependabot[bot]
e558e07817 build(deps): bump glob-parent from 5.1.1 to 5.1.2
Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 5.1.1 to 5.1.2.
- [Release notes](https://github.com/gulpjs/glob-parent/releases)
- [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gulpjs/glob-parent/compare/v5.1.1...v5.1.2)

---
updated-dependencies:
- dependency-name: glob-parent
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-12 15:27:03 +00:00
dependabot[bot]
202d6fe6c3 build(deps): bump normalize-url from 4.5.0 to 4.5.1
Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/sindresorhus/normalize-url/releases)
- [Commits](https://github.com/sindresorhus/normalize-url/commits)

---
updated-dependencies:
- dependency-name: normalize-url
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-12 03:41:41 +00:00
Conventional Changelog Action
ab02c0d880 chore(release): v1.0.34 2021-05-19 09:24:47 +00:00
dependabot[bot]
110a667b31 build(deps): bump hosted-git-info from 2.8.8 to 2.8.9
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-19 09:24:36 +00:00
Conventional Changelog Action
fc187df45e chore(release): v1.0.33 2021-05-19 09:24:33 +00:00
Simone Corsi
389dc4441f Merge pull request #6 from simonecorsi/dependabot/npm_and_yarn/handlebars-4.7.7
build(deps): bump handlebars from 4.7.6 to 4.7.7
2021-05-19 11:24:02 +02:00
Simone Corsi
bbc8ec9ca5 Merge pull request #8 from simonecorsi/dependabot/npm_and_yarn/lodash-4.17.21
build(deps): bump lodash from 4.17.20 to 4.17.21
2021-05-19 11:23:53 +02:00
dependabot[bot]
10151792e7 build(deps): bump lodash from 4.17.20 to 4.17.21
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 23:57:18 +00:00
dependabot[bot]
012928bcda build(deps): bump handlebars from 4.7.6 to 4.7.7
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.7.6 to 4.7.7.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.7.6...v4.7.7)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-09 12:33:24 +00:00
Conventional Changelog Action
fe15d9358c chore(release): v1.0.32 2021-01-22 14:34:57 +00:00
Simone Corsi
5753aefaa3 docs: added documentation 2021-01-22 15:33:27 +01:00
GitHub Actions
fb228f6b20 Merge branch 'main' of github.com:simonecorsi/mawesome into main 2021-01-22 15:23:53 +01:00
Conventional Changelog Action
903c070e54 chore(release): v1.0.31 2021-01-21 21:53:35 +00:00
Simone Corsi
58a7dc17bf feat: added user/email input for commiting 2021-01-21 22:53:21 +01:00
GitHub Actions
3ad155575d chore: removed unused npm packages 2021-01-19 11:17:49 +01:00
Conventional Changelog Action
a5f15dac32 chore(release): v1.0.30 2021-01-16 21:53:23 +00:00
GitHub Actions
7f42ca053b fix: removed push 2021-01-16 22:52:30 +01:00
Conventional Changelog Action
874894bf33 chore(release): v1.0.29 2021-01-16 21:50:46 +00:00
Simone Corsi
7440c23ddc Merge pull request #5 from simonecorsi/fix/added-test-on-mr
feat: added test workflow for pr
2021-01-16 22:50:02 +01:00
Simone Corsi
226c9425d1 ci: test on push 2021-01-16 22:49:19 +01:00
Simone Corsi
748c821dc3 ci: on pull_request hook 2021-01-16 22:48:10 +01:00
GitHub Actions
1bd01f60bd feat: added test workflow for pr 2021-01-16 22:45:45 +01:00
Conventional Changelog Action
c8058222e5 chore(release): v1.0.28 2021-01-16 21:43:10 +00:00
GitHub Actions
b8890fc6d7 tests: added tests 2021-01-16 22:42:23 +01:00
14 changed files with 444 additions and 1034 deletions

19
.github/workflows/merge.yaml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Test
on: [pull_request]
jobs:
version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: tests
run: npm cit

View File

@@ -19,8 +19,11 @@ jobs:
path: '**/node_modules' path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: tests
run: npm cit
- name: build - name: build
run: npm ci && npm run build run: npm run build
- name: Bump version and push tag - name: Bump version and push tag
id: changelog id: changelog

View File

@@ -1,86 +1,35 @@
## <small>1.0.27 (2021-01-16)</small> ## <small>1.0.39 (2021-08-31)</small>
* docs: typo ([46172a5](https://github.com/simonecorsi/mawesome/commit/46172a5)) * build(deps): bump path-parse from 1.0.6 to 1.0.7 ([ef137b5](https://github.com/simonecorsi/mawesome/commit/ef137b5))
## <small>1.0.26 (2021-01-16)</small> ## <small>1.0.38 (2021-06-23)</small>
* chore: added link to project ([0543c05](https://github.com/simonecorsi/mawesome/commit/0543c05)) * chore(release): v1.0.38 ([3e66d85](https://github.com/simonecorsi/mawesome/commit/3e66d85))
* chore(release): v1.0.26 ([8bc2714](https://github.com/simonecorsi/mawesome/commit/8bc2714))
## <small>1.0.25 (2021-01-16)</small> ## <small>1.0.37 (2021-06-23)</small>
* chore: action name ([8f3ce98](https://github.com/simonecorsi/mawesome/commit/8f3ce98)) * chore(release): v1.0.37 ([1643092](https://github.com/simonecorsi/mawesome/commit/1643092))
* chore: moved helpers in own file ([29bcf41](https://github.com/simonecorsi/mawesome/commit/29bcf41)) * build(deps): bump glob-parent from 5.1.1 to 5.1.2 ([e558e07](https://github.com/simonecorsi/mawesome/commit/e558e07))
* chore: namings ([b16fdb0](https://github.com/simonecorsi/mawesome/commit/b16fdb0)) * build(deps): bump hosted-git-info from 2.8.8 to 2.8.9 ([110a667](https://github.com/simonecorsi/mawesome/commit/110a667))
* chore: post release script ([12dd0e4](https://github.com/simonecorsi/mawesome/commit/12dd0e4)) * build(deps): bump normalize-url from 4.5.0 to 4.5.1 ([202d6fe](https://github.com/simonecorsi/mawesome/commit/202d6fe))
* chore(action.yml): node downgrated to 12 ([f91b26b](https://github.com/simonecorsi/mawesome/commit/f91b26b))
* chore(action.yml): updated ([7bdae48](https://github.com/simonecorsi/mawesome/commit/7bdae48))
* chore(release): 1.0.1 ([4193d0e](https://github.com/simonecorsi/mawesome/commit/4193d0e))
* chore(release): 1.0.2 ([00b27bf](https://github.com/simonecorsi/mawesome/commit/00b27bf)) ## <small>1.0.36 (2021-06-23)</small>
* chore(release): 1.0.3 ([bb5dd1f](https://github.com/simonecorsi/mawesome/commit/bb5dd1f))
* chore(release): 1.0.4 ([be86777](https://github.com/simonecorsi/mawesome/commit/be86777)) * chore(release): v1.0.36 ([9c0b622](https://github.com/simonecorsi/mawesome/commit/9c0b622))
* chore(release): 1.0.5 ([a47a53f](https://github.com/simonecorsi/mawesome/commit/a47a53f)) * feat: saving json data for future use ([7ceb9cb](https://github.com/simonecorsi/mawesome/commit/7ceb9cb))
* chore(release): v1.0.1 ([e297342](https://github.com/simonecorsi/mawesome/commit/e297342))
* chore(release): v1.0.10 ([c2a11da](https://github.com/simonecorsi/mawesome/commit/c2a11da))
* chore(release): v1.0.11 ([ab4322e](https://github.com/simonecorsi/mawesome/commit/ab4322e))
* chore(release): v1.0.12 ([0be94f1](https://github.com/simonecorsi/mawesome/commit/0be94f1)) ## <small>1.0.35 (2021-06-22)</small>
* chore(release): v1.0.13 ([ee21996](https://github.com/simonecorsi/mawesome/commit/ee21996))
* chore(release): v1.0.14 ([91de25f](https://github.com/simonecorsi/mawesome/commit/91de25f)) * chore(release): v1.0.35 ([cee1906](https://github.com/simonecorsi/mawesome/commit/cee1906))
* chore(release): v1.0.15 ([03e1973](https://github.com/simonecorsi/mawesome/commit/03e1973)) * build(deps): bump set-getter from 0.1.0 to 0.1.1 ([970d603](https://github.com/simonecorsi/mawesome/commit/970d603))
* chore(release): v1.0.16 ([f8cb892](https://github.com/simonecorsi/mawesome/commit/f8cb892))
* chore(release): v1.0.17 ([380a0ec](https://github.com/simonecorsi/mawesome/commit/380a0ec))
* chore(release): v1.0.18 ([d82b715](https://github.com/simonecorsi/mawesome/commit/d82b715))
* chore(release): v1.0.19 ([7a46627](https://github.com/simonecorsi/mawesome/commit/7a46627))
* chore(release): v1.0.2 ([3cba062](https://github.com/simonecorsi/mawesome/commit/3cba062))
* chore(release): v1.0.20 ([738785e](https://github.com/simonecorsi/mawesome/commit/738785e))
* chore(release): v1.0.21 ([3c3ab0a](https://github.com/simonecorsi/mawesome/commit/3c3ab0a))
* chore(release): v1.0.22 ([3f66738](https://github.com/simonecorsi/mawesome/commit/3f66738))
* chore(release): v1.0.23 ([f41befa](https://github.com/simonecorsi/mawesome/commit/f41befa))
* chore(release): v1.0.24 ([9badeaf](https://github.com/simonecorsi/mawesome/commit/9badeaf))
* chore(release): v1.0.25 ([14ccc97](https://github.com/simonecorsi/mawesome/commit/14ccc97))
* chore(release): v1.0.3 ([71625bd](https://github.com/simonecorsi/mawesome/commit/71625bd))
* chore(release): v1.0.4 ([46583c7](https://github.com/simonecorsi/mawesome/commit/46583c7))
* chore(release): v1.0.5 ([ba24bdf](https://github.com/simonecorsi/mawesome/commit/ba24bdf))
* chore(release): v1.0.6 ([6cb192b](https://github.com/simonecorsi/mawesome/commit/6cb192b))
* chore(release): v1.0.7 ([410e2a7](https://github.com/simonecorsi/mawesome/commit/410e2a7))
* chore(release): v1.0.8 ([324332b](https://github.com/simonecorsi/mawesome/commit/324332b))
* chore(release): v1.0.9 ([7499f86](https://github.com/simonecorsi/mawesome/commit/7499f86))
* fix: added latest tag at release ([6b8b525](https://github.com/simonecorsi/mawesome/commit/6b8b525))
* fix: added missing info for action publishing ([3703b66](https://github.com/simonecorsi/mawesome/commit/3703b66))
* fix: added required label ([173ce50](https://github.com/simonecorsi/mawesome/commit/173ce50))
* fix: bad quotes in url ([76d0173](https://github.com/simonecorsi/mawesome/commit/76d0173))
* fix: better errors ([f302126](https://github.com/simonecorsi/mawesome/commit/f302126))
* fix: better template management ([9d06abc](https://github.com/simonecorsi/mawesome/commit/9d06abc))
* fix: exit condition ([914a115](https://github.com/simonecorsi/mawesome/commit/914a115))
* fix: git pull strategy ([edb4a38](https://github.com/simonecorsi/mawesome/commit/edb4a38))
* fix: git push ([c8fb3f4](https://github.com/simonecorsi/mawesome/commit/c8fb3f4))
* fix: if tempalte fail should exit(1) ([ee824d1](https://github.com/simonecorsi/mawesome/commit/ee824d1))
* fix: imports ([2e421f0](https://github.com/simonecorsi/mawesome/commit/2e421f0))
* fix: imports ([376451a](https://github.com/simonecorsi/mawesome/commit/376451a))
* fix: should fix unshallow repo ([17c5d85](https://github.com/simonecorsi/mawesome/commit/17c5d85))
* fix: somehow runner wont see template ([808c35c](https://github.com/simonecorsi/mawesome/commit/808c35c))
* fix: splitting tokens ([bd47078](https://github.com/simonecorsi/mawesome/commit/bd47078))
* fix: template cannot be loaded from ejs file ([78c0f37](https://github.com/simonecorsi/mawesome/commit/78c0f37))
* fix: variable name ([13e1fd1](https://github.com/simonecorsi/mawesome/commit/13e1fd1))
* fix(action.yml): output file now correct path ([98b17f8](https://github.com/simonecorsi/mawesome/commit/98b17f8))
* fix(ci): bad syntax ([caaf6ab](https://github.com/simonecorsi/mawesome/commit/caaf6ab))
* fix(index.ts): fs promise fixed path ([285e193](https://github.com/simonecorsi/mawesome/commit/285e193))
* docs: added authors ([3de0e12](https://github.com/simonecorsi/mawesome/commit/3de0e12))
* docs: added readme ([e1c9ca0](https://github.com/simonecorsi/mawesome/commit/e1c9ca0))
* docs: readme updated ([192aa8a](https://github.com/simonecorsi/mawesome/commit/192aa8a))
* feat: better errors ([1700aa3](https://github.com/simonecorsi/mawesome/commit/1700aa3))
* feat: generate awesome list from stars ([0f6fa76](https://github.com/simonecorsi/mawesome/commit/0f6fa76))
* feat: git user now is action ([aa70ac9](https://github.com/simonecorsi/mawesome/commit/aa70ac9))
* ci: added github user setup ([a4bbd4b](https://github.com/simonecorsi/mawesome/commit/a4bbd4b))
* ci: better release ([ea34727](https://github.com/simonecorsi/mawesome/commit/ea34727))
* ci(version): prefixed now with v ([f3d2757](https://github.com/simonecorsi/mawesome/commit/f3d2757))
* build: better releasing workflow ([ac6e274](https://github.com/simonecorsi/mawesome/commit/ac6e274))
* build(index.js): build ([e007c3b](https://github.com/simonecorsi/mawesome/commit/e007c3b))
* Initial commit ([e884018](https://github.com/simonecorsi/mawesome/commit/e884018))

View File

@@ -1,20 +1,41 @@
# My Awesome list # My Awesome List
This action query the github api to get starred list of the user and then generates a list ordered by languages. This action query the github api to get starred list of the user and then generates a list ordered by languages.
You can see an example of the output at my own [simonecorsi/awesome](https://github.com/simonecorsi/awesome) You can see an example of the output at my own [simonecorsi/awesome](https://github.com/simonecorsi/awesome)
## Setup ## Table of Contents
To use this action you have to create your own repository (eg: `yourname/awesome`), then create a new empty action in it and then use the [example workflow](#example-workflow) below as a starting point. <!-- toc -->
## Inputs - [Table of Contents](#table-of-contents)
- [Documentation](#documentation)
- [Requirements](#requirements)
- [Configuration](#configuration)
- [`api-token`](#api-token)
- [Example workflow](#example-workflow)
### `github-token` <!-- tocstop -->
The github workflow token is mandatory ## Documentation
### `api-token` ### Requirements
- An empty repository
- A personal github api key
### Configuration
The service can be configured setting the appropriate environment variables or writing an `.env` file.
| Variable | Description | Default |
| -------------- | ------------------------------------------- | -------------------------------- |
| `api-token` | Personal github api token. | `${{ secrets.API_TOKEN }}` |
| `github-token` | Action Token | `${{ secrets.GITHUB_TOKEN }}` |
| `github-name` | Name used for the commit, default to action | Github Action |
| `github-email` | email used for commit, default to action | actions@users.noreply.github.com |
#### `api-token`
The Personal API Access Token is mandatory to fetch stars from the API without incurring in Rate Limits. The Personal API Access Token is mandatory to fetch stars from the API without incurring in Rate Limits.
@@ -36,8 +57,11 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Awesome generator - name: Awesome generator
uses: simonecorsi/mawesome@lastest uses: simonecorsi/mawesome@latest
with: with:
api-token: ${{ secrets.API_TOKEN }} api-token: ${{ secrets.API_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
github-email: ${{ secrets.USER_EMAIL }}
github-name: ${{ github.repository_owner }}
``` ```

View File

@@ -10,6 +10,10 @@ inputs:
api-token: api-token:
description: 'Personal API Token' description: 'Personal API Token'
required: true required: true
github-name:
description: 'Name shown in the commit'
github-email:
description: 'Email shown in the commit'
runs: runs:
using: 'node12' using: 'node12'
main: 'index.js' main: 'index.js'

7
ava.config.js Normal file
View File

@@ -0,0 +1,7 @@
/* eslint-disable node/no-unsupported-features/es-syntax */
export default {
files: ['!templates/**/*'],
extensions: ['ts'],
require: ['ts-node/register/transpile-only'],
};

View File

@@ -18482,7 +18482,7 @@ const testParameter = (name, filters) => {
}; };
const normalizeDataURL = (urlString, {stripHash}) => { const normalizeDataURL = (urlString, {stripHash}) => {
const parts = urlString.match(/^data:(.*?),(.*?)(?:#(.*))?$/); const parts = urlString.match(/^data:([^,]*?),([^#]*?)(?:#(.*))?$/);
if (!parts) { if (!parts) {
throw new Error(`Invalid URL: ${urlString}`); throw new Error(`Invalid URL: ${urlString}`);
@@ -20801,6 +20801,7 @@ function factory(key, options) {
* https://github.com/jhermsmeier/node-http-link-header * https://github.com/jhermsmeier/node-http-link-header
*/ */
/* istanbul ignore file */
var COMPATIBLE_ENCODING_PATTERN = /^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i; var COMPATIBLE_ENCODING_PATTERN = /^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i;
@@ -21263,7 +21264,7 @@ const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514)); const exec = __importStar(__nccwpck_require__(1514));
const { GITHUB_REPOSITORY, GITHUB_REF } = process.env; const { GITHUB_REPOSITORY, GITHUB_REF } = process.env;
const branch = GITHUB_REF === null || GITHUB_REF === void 0 ? void 0 : GITHUB_REF.replace('refs/heads/', ''); const branch = GITHUB_REF === null || GITHUB_REF === void 0 ? void 0 : GITHUB_REF.replace('refs/heads/', '');
exports.default = new (class Git { class Git {
constructor() { constructor() {
this.isShallow = () => __awaiter(this, void 0, void 0, function* () { this.isShallow = () => __awaiter(this, void 0, void 0, function* () {
const isShallow = yield this.exec('rev-parse --is-shallow-repository'); const isShallow = yield this.exec('rev-parse --is-shallow-repository');
@@ -21307,14 +21308,17 @@ exports.default = new (class Git {
this.createTag = (tag) => this.exec(`tag -a ${tag} -m "${tag}"`); this.createTag = (tag) => this.exec(`tag -a ${tag} -m "${tag}"`);
const githubToken = core.getInput('github-token', { required: true }); const githubToken = core.getInput('github-token', { required: true });
core.setSecret(githubToken); core.setSecret(githubToken);
const githubName = core.getInput('github-name') || 'GitHub Actions';
const githubEmail = core.getInput('github-email') || 'actions@users.noreply.github.com';
// Set config // Set config
this.config('user.name', 'GitHub Actions'); this.config('user.name', githubName);
this.config('user.email', 'actions@users.noreply.github.com'); this.config('user.email', githubEmail);
this.config('pull.rebase', 'false'); this.config('pull.rebase', 'false');
// Update the origin // Update the origin
this.updateOrigin(`https://x-access-token:${githubToken}@github.com/${GITHUB_REPOSITORY}.git`); this.updateOrigin(`https://x-access-token:${githubToken}@github.com/${GITHUB_REPOSITORY}.git`);
} }
})(); }
exports.default = new Git();
/***/ }), /***/ }),
@@ -21357,7 +21361,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
}; };
var _a; var _a;
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.pushNewFile = exports.OUTPUT_FILENAME = exports.generateMd = exports.paginate = exports.API_STARRED_URL = exports.REPO_USERNAME = exports.apiGetStar = exports.renderer = exports.isLastPage = exports.wait = void 0; exports.pushNewFiles = exports.MARKDOWN_FILENAME = exports.generateMd = exports.paginate = exports.API_STARRED_URL = exports.REPO_USERNAME = exports.apiGetStar = exports.renderer = exports.isLastPage = exports.wait = void 0;
const ejs_1 = __importDefault(__nccwpck_require__(8431)); const ejs_1 = __importDefault(__nccwpck_require__(8431));
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const remark_1 = __importDefault(__nccwpck_require__(2081)); const remark_1 = __importDefault(__nccwpck_require__(2081));
@@ -21429,17 +21433,21 @@ function generateMd(data) {
}); });
} }
exports.generateMd = generateMd; exports.generateMd = generateMd;
exports.OUTPUT_FILENAME = core.getInput('output-filename') || 'README.md'; exports.MARKDOWN_FILENAME = core.getInput('output-filename') || 'README.md';
function pushNewFile(markdown) { function pushNewFiles(files = []) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
yield fsp.writeFile(exports.OUTPUT_FILENAME, markdown); if (!files.length)
return;
yield git_1.default.pull(); yield git_1.default.pull();
yield git_1.default.add(exports.OUTPUT_FILENAME); yield Promise.all(files.map(({ filename, data }) => __awaiter(this, void 0, void 0, function* () {
yield git_1.default.commit(`chore(${exports.OUTPUT_FILENAME}): updated ${exports.OUTPUT_FILENAME}`); yield fsp.writeFile(filename, data);
yield git_1.default.add(filename);
yield git_1.default.commit(`chore(${filename}): updated ${filename}`);
})));
yield git_1.default.push(); yield git_1.default.push();
}); });
} }
exports.pushNewFile = pushNewFile; exports.pushNewFiles = pushNewFiles;
/***/ }), /***/ }),
@@ -21507,7 +21515,16 @@ function main() {
updatedAt: Date.now(), updatedAt: Date.now(),
}); });
const markdown = yield helpers_1.generateMd(rendered); const markdown = yield helpers_1.generateMd(rendered);
yield helpers_1.pushNewFile(markdown); yield helpers_1.pushNewFiles([
{
filename: helpers_1.MARKDOWN_FILENAME,
data: markdown,
},
{
filename: 'data.json',
data: JSON.stringify(sortedByLanguages, null, 2),
},
]);
}); });
} }
exports.main = main; exports.main = main;

1088
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,18 @@
{ {
"name": "mawesome", "name": "mawesome",
"version": "1.0.27", "version": "1.0.39",
"description": "Generate awesome list from user starred repositories", "description": "Generate awesome list from user starred repositories",
"main": "index.js", "main": "index.js",
"author": "Simone Corsi<simonecorsi.dev@gmail.com>", "author": "Simone Corsi<simonecorsi.dev@gmail.com>",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "nyc --reporter=lcov --reporter=text-summary ava -s -v",
"test:watch": "ava -w",
"style:lint": "eslint src --ext .ts", "style:lint": "eslint src --ext .ts",
"style:prettier": "prettier \"src/**/*.ts\" --list-different --write", "style:prettier": "prettier \"src/**/*.ts\" --list-different --write",
"build": "./node_modules/.bin/ncc build src/index.ts -o ./", "build": "./node_modules/.bin/ncc build src/index.ts -o ./",
"dev": "ts-node-dev src/index.ts", "dev": "ts-node-dev src/index.ts",
"prerelease": "npm run build && " "prerelease": "npm run build"
}, },
"keywords": [ "keywords": [
"github", "github",
@@ -30,12 +31,12 @@
"@types/ejs": "^3.0.5", "@types/ejs": "^3.0.5",
"@types/got": "^9.6.11", "@types/got": "^9.6.11",
"@types/node": "^14.14.5", "@types/node": "^14.14.5",
"@types/sinon": "^9.0.10",
"@typescript-eslint/eslint-plugin": "^4.6.0", "@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0", "@typescript-eslint/parser": "^4.6.0",
"@vercel/ncc": "^0.26.2", "@vercel/ncc": "^0.26.2",
"ava": "^3.8.2", "ava": "^3.8.2",
"benchmark": "^2.1.4", "benchmark": "^2.1.4",
"conventional-gitlab-releaser": "^4.0.1",
"cz-conventional-changelog": "^3.2.0", "cz-conventional-changelog": "^3.2.0",
"eslint": "^7.17.0", "eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0", "eslint-config-prettier": "^7.1.0",
@@ -44,9 +45,9 @@
"husky": "^4.2.5", "husky": "^4.2.5",
"lint-staged": "^10.2.2", "lint-staged": "^10.2.2",
"markdown-toc": "^1.2.0", "markdown-toc": "^1.2.0",
"ninos": "^3.0.0",
"nyc": "^15.0.1", "nyc": "^15.0.1",
"prettier": "^2.0.5", "prettier": "^2.0.5",
"sinon": "^9.2.3",
"standard-version": "^9.0.0", "standard-version": "^9.0.0",
"ts-node-dev": "^1.1.1", "ts-node-dev": "^1.1.1",
"typescript": "^4.1.3" "typescript": "^4.1.3"
@@ -54,7 +55,6 @@
"dependencies": { "dependencies": {
"@actions/exec": "^1.0.4", "@actions/exec": "^1.0.4",
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"ejs": "^3.1.5", "ejs": "^3.1.5",
"got": "^11.8.1", "got": "^11.8.1",
"remark": "^13.0.0", "remark": "^13.0.0",

View File

@@ -6,15 +6,18 @@ import * as exec from '@actions/exec';
const { GITHUB_REPOSITORY, GITHUB_REF } = process.env; const { GITHUB_REPOSITORY, GITHUB_REF } = process.env;
const branch = GITHUB_REF?.replace('refs/heads/', ''); const branch = GITHUB_REF?.replace('refs/heads/', '');
class Git {
export default new (class Git {
constructor() { constructor() {
const githubToken = core.getInput('github-token', { required: true }); const githubToken = core.getInput('github-token', { required: true });
core.setSecret(githubToken); core.setSecret(githubToken);
const githubName = core.getInput('github-name') || 'GitHub Actions';
const githubEmail =
core.getInput('github-email') || 'actions@users.noreply.github.com';
// Set config // Set config
this.config('user.name', 'GitHub Actions'); this.config('user.name', githubName);
this.config('user.email', 'actions@users.noreply.github.com'); this.config('user.email', githubEmail);
this.config('pull.rebase', 'false'); this.config('pull.rebase', 'false');
// Update the origin // Update the origin
@@ -80,4 +83,6 @@ export default new (class Git {
updateOrigin = (repo: string) => this.exec(`remote set-url origin ${repo}`); updateOrigin = (repo: string) => this.exec(`remote set-url origin ${repo}`);
createTag = (tag: string) => this.exec(`tag -a ${tag} -m "${tag}"`); createTag = (tag: string) => this.exec(`tag -a ${tag} -m "${tag}"`);
})(); }
export default new Git();

View File

@@ -77,12 +77,26 @@ export function generateMd(data: string): Promise<string> {
}); });
} }
export const OUTPUT_FILENAME: string = export const MARKDOWN_FILENAME: string =
core.getInput('output-filename') || 'README.md'; core.getInput('output-filename') || 'README.md';
export async function pushNewFile(markdown: string): Promise<any> {
await fsp.writeFile(OUTPUT_FILENAME, markdown); type File = {
filename: string;
data: string;
};
export async function pushNewFiles(files: File[] = []): Promise<any> {
if (!files.length) return;
await git.pull(); await git.pull();
await git.add(OUTPUT_FILENAME);
await git.commit(`chore(${OUTPUT_FILENAME}): updated ${OUTPUT_FILENAME}`); await Promise.all(
files.map(async ({ filename, data }) => {
await fsp.writeFile(filename, data);
await git.add(filename);
await git.commit(`chore(${filename}): updated ${filename}`);
})
);
await git.push(); await git.push();
} }

View File

@@ -1,11 +1,13 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import { data } from 'remark';
import { import {
renderer, renderer,
paginate, paginate,
REPO_USERNAME, REPO_USERNAME,
generateMd, generateMd,
pushNewFile, pushNewFiles,
MARKDOWN_FILENAME,
} from './helpers'; } from './helpers';
import type { SortedLanguageList, Stars, Star } from './types'; import type { SortedLanguageList, Stars, Star } from './types';
@@ -41,7 +43,16 @@ export async function main(): Promise<any> {
const markdown: string = await generateMd(rendered); const markdown: string = await generateMd(rendered);
await pushNewFile(markdown); await pushNewFiles([
{
filename: MARKDOWN_FILENAME,
data: markdown,
},
{
filename: 'data.json',
data: JSON.stringify(sortedByLanguages, null, 2),
},
]);
} }
export async function run(): Promise<any> { export async function run(): Promise<any> {

View File

@@ -3,6 +3,7 @@
* https://github.com/jhermsmeier/node-http-link-header * https://github.com/jhermsmeier/node-http-link-header
*/ */
/* istanbul ignore file */
'use strict'; 'use strict';
var COMPATIBLE_ENCODING_PATTERN = /^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i; var COMPATIBLE_ENCODING_PATTERN = /^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i;

106
test/helpers.spec.ts Normal file
View File

@@ -0,0 +1,106 @@
import test from 'ava';
import * as sinon from 'sinon';
import fs from 'fs';
import * as core from '@actions/core';
sinon.replace(core, 'getInput', sinon.fake());
import GithubApi from '../src/api';
const GithubApiFake = sinon.fake((rul) => ({
body: 'data',
headers: {
link:
'<https://api.github.com/user/5617452/starred?page=2>; rel="next", <https://api.github.com/user/5617452/starred?page=2>; rel="last"',
},
}));
sinon.replace(GithubApi, 'get', GithubApiFake);
import Git from '../src/git';
const pull = sinon.fake();
sinon.replace(Git, 'pull', pull);
const add = sinon.fake();
sinon.replace(Git, 'add', add);
const commit = sinon.fake();
sinon.replace(Git, 'commit', commit);
const push = sinon.fake();
sinon.replace(Git, 'push', push);
sinon.replace(Git, 'config', sinon.fake());
sinon.replace(Git, 'updateOrigin', sinon.fake());
const fsp = fs.promises;
const writeFile = sinon.fake();
sinon.replace(fsp, 'writeFile', writeFile);
import {
isLastPage,
wait,
renderer,
apiGetStar,
paginate,
generateMd,
pushNewFiles,
} from '../src/helpers';
test('wait should wait', async (t) => {
await wait(200);
t.pass();
});
test('isLastPage', (t) => {
t.true(
isLastPage({
next: 'last',
last: 'last',
})
);
t.false(
isLastPage({
next: 'last',
last: undefined,
})
);
});
test('renderer should render', async (t) => {
const output = await renderer({ variable: 123 }, 'Test: <%= variable %>');
t.is(output, 'Test: 123');
});
test('apiGetStar', async (t) => {
let { data, links } = await apiGetStar('url');
t.true(GithubApiFake.called);
t.is(data, 'data');
t.deepEqual(links, {
last: 'https://api.github.com/user/5617452/starred?page=2',
next: 'https://api.github.com/user/5617452/starred?page=2',
});
});
test('paginate', async (t) => {
await paginate();
const res = await paginate();
t.is(res, null);
});
test('generateMd should create TOC', async (t) => {
const tpl = `# title
## Table of Contents
## Javascript
`;
const result = await generateMd(tpl);
t.is(
result,
`# title\n\n## Table of Contents\n\n* [Javascript](#javascript)\n\n## Javascript\n`
);
});
test('should push', async (t) => {
await pushNewFiles([{filename: "README.md", data: '# title'}]);
t.true(writeFile.calledWith('README.md', '# title'));
t.true(pull.called);
t.true(add.calledWith('README.md'));
t.true(commit.calledWith('chore(README.md): updated README.md'));
t.true(push.called);
});