36 Commits

Author SHA1 Message Date
simonecorsi
17e7434940 chore(release): 1.1.0-next.2 [skip ci]
# [1.1.0-next.2](https://github.com/simonecorsi/mawesome/compare/v1.1.0-next.1...v1.1.0-next.2) (2022-05-09)

### Features

* using gh-star-fetch ([a8b6577](a8b657735b))
2022-05-09 15:25:56 +00:00
Simone Corsi
feff4b4d2a test: fixed old suites 2022-05-09 17:22:12 +02:00
Simone Corsi
91f90aedbe ci: console 2022-05-09 17:09:32 +02:00
Simone Corsi
cd1c89b2ef ci: moves templates check 2022-05-09 16:50:41 +02:00
Simone Corsi
52bf53cb39 ci: adds logs 2022-05-09 16:49:56 +02:00
Simone Corsi
a8b657735b feat: using gh-star-fetch 2022-05-09 15:57:03 +02:00
simonecorsi
7fb87741a2 chore(release): 1.1.0-next.1 [skip ci]
# [1.1.0-next.1](https://github.com/simonecorsi/mawesome/compare/v1.0.45...v1.1.0-next.1) (2022-04-13)

### Bug Fixes

* pre-tags ([602befc](602befcb54))

### Features

* **template:** adds templates ([791de9a](791de9ab50)), closes [#14](https://github.com/simonecorsi/mawesome/issues/14)
2022-04-13 13:54:00 +00:00
Simone Corsi
602befcb54 fix: pre-tags 2022-04-13 15:51:20 +02:00
Simone Corsi
791de9ab50 feat(template): adds templates
if an `TEMPLATE.ejs` file is found in the repo it will be used for rendering

closes #14
2022-04-13 15:34:08 +02:00
GitHub Actions
3c630ecb73 ci: adds next release channel 2022-04-13 12:55:15 +02:00
Simone Corsi
62cc7b142a Merge pull request #25 from simonecorsi/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-4.33.0
build(deps-dev): bump @typescript-eslint/eslint-plugin from 4.12.0 to 4.33.0
2022-04-12 12:44:36 +02:00
dependabot[bot]
49c817ef10 build(deps-dev): bump @typescript-eslint/eslint-plugin
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.12.0 to 4.33.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.33.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-12 10:20:53 +00:00
Simone Corsi
e17f0be682 Merge pull request #26 from simonecorsi/dependabot/npm_and_yarn/types/got-9.6.12
build(deps-dev): bump @types/got from 9.6.11 to 9.6.12
2022-04-12 12:15:57 +02:00
dependabot[bot]
97c305eeb7 build(deps-dev): bump @types/got from 9.6.11 to 9.6.12
Bumps [@types/got](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/got) from 9.6.11 to 9.6.12.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/got)

---
updated-dependencies:
- dependency-name: "@types/got"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-12 10:03:55 +00:00
Simone Corsi
a443da7025 Merge pull request #21 from simonecorsi/dependabot/npm_and_yarn/vercel/ncc-0.33.3
build(deps-dev): bump @vercel/ncc from 0.26.2 to 0.33.3
2022-04-11 09:56:15 +02:00
Simone Corsi
07b2bb76e0 Merge pull request #24 from simonecorsi/dependabot/npm_and_yarn/actions/exec-1.1.1
build(deps): bump @actions/exec from 1.0.4 to 1.1.1
2022-04-11 09:53:26 +02:00
Simone Corsi
2ad49c269e Merge pull request #15 from simonecorsi/dependabot/npm_and_yarn/ansi-regex-4.1.1
build(deps): bump ansi-regex from 4.1.0 to 4.1.1
2022-04-11 09:53:02 +02:00
Simone Corsi
fd0321acf5 Merge pull request #16 from simonecorsi/dependabot/npm_and_yarn/minimist-1.2.6
build(deps): bump minimist from 1.2.5 to 1.2.6
2022-04-11 09:52:42 +02:00
dependabot[bot]
dbd50a89e4 build(deps): bump @actions/exec from 1.0.4 to 1.1.1
Bumps [@actions/exec](https://github.com/actions/toolkit/tree/HEAD/packages/exec) from 1.0.4 to 1.1.1.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/exec/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/@actions/tool-cache@1.1.1/packages/exec)

---
updated-dependencies:
- dependency-name: "@actions/exec"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 07:52:34 +00:00
Simone Corsi
5027ab963e Merge pull request #23 from simonecorsi/dependabot/npm_and_yarn/husky-7.0.4
build(deps-dev): bump husky from 6.0.0 to 7.0.4
2022-04-11 09:52:26 +02:00
dependabot[bot]
95daa3318c build(deps): bump ansi-regex from 4.1.0 to 4.1.1
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 07:52:20 +00:00
dependabot[bot]
c93b1511f1 build(deps): bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 07:52:20 +00:00
dependabot[bot]
0ceab70142 build(deps-dev): bump husky from 6.0.0 to 7.0.4
Bumps [husky](https://github.com/typicode/husky) from 6.0.0 to 7.0.4.
- [Release notes](https://github.com/typicode/husky/releases)
- [Commits](https://github.com/typicode/husky/compare/v6.0.0...v7.0.4)

---
updated-dependencies:
- dependency-name: husky
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 07:52:18 +00:00
Simone Corsi
2eb10280a7 Merge pull request #22 from simonecorsi/dependabot/npm_and_yarn/ejs-3.1.6
build(deps): bump ejs from 3.1.5 to 3.1.6
2022-04-11 09:51:39 +02:00
Simone Corsi
e4a2588002 Merge pull request #20 from simonecorsi/dependabot/npm_and_yarn/lint-staged-12.3.7
build(deps-dev): bump lint-staged from 10.5.3 to 12.3.7
2022-04-11 09:51:06 +02:00
GitHub Actions
694ba91ecc ci: remove matrix test 2022-04-11 09:50:53 +02:00
Simone Corsi
a683b39f9f Merge pull request #19 from simonecorsi/dependabot/npm_and_yarn/octokit/rest-18.12.0
build(deps-dev): bump @octokit/rest from 18.0.12 to 18.12.0
2022-04-11 09:49:16 +02:00
Simone Corsi
8253c064fe Merge pull request #18 from simonecorsi/dependabot/npm_and_yarn/node-fetch-2.6.7
build(deps): bump node-fetch from 2.6.1 to 2.6.7
2022-04-11 09:48:51 +02:00
Simone Corsi
7af34fda05 Merge pull request #17 from simonecorsi/dependabot/npm_and_yarn/trim-off-newlines-1.0.3
build(deps): bump trim-off-newlines from 1.0.1 to 1.0.3
2022-04-11 09:48:26 +02:00
dependabot[bot]
d4dd907bb0 build(deps): bump ejs from 3.1.5 to 3.1.6
Bumps [ejs](https://github.com/mde/ejs) from 3.1.5 to 3.1.6.
- [Release notes](https://github.com/mde/ejs/releases)
- [Changelog](https://github.com/mde/ejs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mde/ejs/compare/v3.1.5...v3.1.6)

---
updated-dependencies:
- dependency-name: ejs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 07:29:07 +00:00
dependabot[bot]
b0c97c8ec6 build(deps-dev): bump @vercel/ncc from 0.26.2 to 0.33.3
Bumps [@vercel/ncc](https://github.com/vercel/ncc) from 0.26.2 to 0.33.3.
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](https://github.com/vercel/ncc/compare/0.26.2...0.33.3)

---
updated-dependencies:
- dependency-name: "@vercel/ncc"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 07:28:57 +00:00
dependabot[bot]
a0b73020ce build(deps-dev): bump lint-staged from 10.5.3 to 12.3.7
Bumps [lint-staged](https://github.com/okonet/lint-staged) from 10.5.3 to 12.3.7.
- [Release notes](https://github.com/okonet/lint-staged/releases)
- [Commits](https://github.com/okonet/lint-staged/compare/v10.5.3...v12.3.7)

---
updated-dependencies:
- dependency-name: lint-staged
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 07:28:47 +00:00
dependabot[bot]
04fbe0af6f build(deps-dev): bump @octokit/rest from 18.0.12 to 18.12.0
Bumps [@octokit/rest](https://github.com/octokit/rest.js) from 18.0.12 to 18.12.0.
- [Release notes](https://github.com/octokit/rest.js/releases)
- [Commits](https://github.com/octokit/rest.js/compare/v18.0.12...v18.12.0)

---
updated-dependencies:
- dependency-name: "@octokit/rest"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 07:28:33 +00:00
dependabot[bot]
d4184b0b6b build(deps): bump node-fetch from 2.6.1 to 2.6.7
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 07:28:25 +00:00
dependabot[bot]
064eb14315 build(deps): bump trim-off-newlines from 1.0.1 to 1.0.3
Bumps [trim-off-newlines](https://github.com/stevemao/trim-off-newlines) from 1.0.1 to 1.0.3.
- [Release notes](https://github.com/stevemao/trim-off-newlines/releases)
- [Commits](https://github.com/stevemao/trim-off-newlines/compare/v1.0.1...v1.0.3)

---
updated-dependencies:
- dependency-name: trim-off-newlines
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 07:28:24 +00:00
GitHub Actions
b07cc92b5c build: updates release and tooling flows 2022-04-11 09:27:43 +02:00
25 changed files with 16444 additions and 3826 deletions

View File

@@ -1,21 +0,0 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true
},
"extends": [
"prettier/@typescript-eslint",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"prefer-rest-params": "off",
"@typescript-eslint/no-non-null-assertion": "off"
}
}

17
.eslintrc.js Normal file
View File

@@ -0,0 +1,17 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
env: {
node: true,
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:prettier/recommended',
'plugin:@typescript-eslint/recommended',
],
};

13
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1,13 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.
# These owners will be the default owners for everything in the repo.
* @simonecorsi
# Order is important. The last matching pattern has the most precedence.
# So if a pull request only touches javascript files, only these owners
# will be requested to review.
# *.js @octocat @github/js
# You can also use email addresses if you prefer.
# docs/* docs@example.com

18
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: 'npm' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: 'daily'
open-pull-requests-limit: 10
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'daily'
open-pull-requests-limit: 10

15
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,15 @@
## 🚨 Proposed changes
> Please review the [guidelines for contributing](../../CONTRIBUTING.md) to this repository.
[[Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.]]
## ⚙️ Types of changes
What types of changes does your code introduce? _Put an `x` in the boxes that apply_
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation Update (if none of the other choices apply)
- [ ] Refactor

View File

@@ -1,19 +0,0 @@
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

21
.github/workflows/merge.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Run tests
on: [pull_request]
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm it

View File

@@ -1,47 +0,0 @@
name: Publish workflow
on:
push:
branches: main
jobs:
version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: fregante/setup-git-user@v1
- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: tests
run: npm cit
- name: build
run: npm run build
- name: Bump version and push tag
id: changelog
uses: TriPSs/conventional-changelog-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
git-message: 'chore(release): {version}'
preset: ''
- name: Create github Release
uses: actions/create-release@v1
if: ${{ steps.changelog.outputs.skipped == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.changelog.outputs.tag }}
release_name: ${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.changelog }}
- name: Latest tag
uses: EndBug/latest-tag@v1.4.0

46
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,46 @@
name: Release
on: [workflow_dispatch]
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm it
release:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: npm i
- name: Build
run: npm run build
- name: Semantic release
uses: codfish/semantic-release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: '${{ github.actor }}'
GIT_COMMITTER_NAME: '${{ github.actor }}'

1
.husky/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
_

4
.husky/commit-msg Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint --edit $1

4
.husky/pre-commit Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install lint-staged

View File

@@ -1,7 +0,0 @@
module.exports = {
hooks: {
'prepare-commit-msg': 'exec < /dev/tty && git cz --hook || true',
'pre-commit': 'lint-staged',
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
},
};

25
.releaserc.json Normal file
View File

@@ -0,0 +1,25 @@
{
"branches": [
{ "name": "main" },
{ "name": "next", "channel": "next", "prerelease": true }
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/git",
{
"assets": ["CHANGELOG.md", "package.json", "package-lock.json"]
}
],
"@semantic-release/github",
[
"@saithodev/semantic-release-backmerge",
{
"branches": [{ "from": "main", "to": "next" }],
"backmergeStrategy": "rebase"
}
]
]
}

View File

@@ -1,35 +1,43 @@
# [1.1.0-next.2](https://github.com/simonecorsi/mawesome/compare/v1.1.0-next.1...v1.1.0-next.2) (2022-05-09)
### Features
* using gh-star-fetch ([a8b6577](https://github.com/simonecorsi/mawesome/commit/a8b657735b9879636cc039d79fddcdca33ccf38e))
# [1.1.0-next.1](https://github.com/simonecorsi/mawesome/compare/v1.0.45...v1.1.0-next.1) (2022-04-13)
### Bug Fixes
* pre-tags ([602befc](https://github.com/simonecorsi/mawesome/commit/602befcb5494b5bfd74d2333899311b81ea9da6d))
### Features
* **template:** adds templates ([791de9a](https://github.com/simonecorsi/mawesome/commit/791de9ab504de50e2e9cb031b9e373d7cc0589c0)), closes [#14](https://github.com/simonecorsi/mawesome/issues/14)
## <small>1.0.45 (2022-01-17)</small>
* build(deps): bump shelljs from 0.8.4 to 0.8.5 ([1da350a](https://github.com/simonecorsi/mawesome/commit/1da350a))
- build(deps): bump shelljs from 0.8.4 to 0.8.5 ([1da350a](https://github.com/simonecorsi/mawesome/commit/1da350a))
## <small>1.0.44 (2021-10-26)</small>
* chore(release): v1.0.44 ([6ffe17f](https://github.com/simonecorsi/mawesome/commit/6ffe17f))
* feat: git add multiple files at once ([4aef61f](https://github.com/simonecorsi/mawesome/commit/4aef61f))
- chore(release): v1.0.44 ([6ffe17f](https://github.com/simonecorsi/mawesome/commit/6ffe17f))
- feat: git add multiple files at once ([4aef61f](https://github.com/simonecorsi/mawesome/commit/4aef61f))
## <small>1.0.43 (2021-10-15)</small>
* chore(release): v1.0.43 ([5e0ef82](https://github.com/simonecorsi/mawesome/commit/5e0ef82))
* feat: reduce json output size ([94635fe](https://github.com/simonecorsi/mawesome/commit/94635fe))
- chore(release): v1.0.43 ([5e0ef82](https://github.com/simonecorsi/mawesome/commit/5e0ef82))
- feat: reduce json output size ([94635fe](https://github.com/simonecorsi/mawesome/commit/94635fe))
## <small>1.0.42 (2021-10-14)</small>
* chore(release): v1.0.42 ([5b36813](https://github.com/simonecorsi/mawesome/commit/5b36813))
* fix(paginator): last page now correctly matches rex ([dcf9898](https://github.com/simonecorsi/mawesome/commit/dcf9898))
- chore(release): v1.0.42 ([5b36813](https://github.com/simonecorsi/mawesome/commit/5b36813))
- fix(paginator): last page now correctly matches rex ([dcf9898](https://github.com/simonecorsi/mawesome/commit/dcf9898))
## <small>1.0.41 (2021-10-14)</small>
* chore(release): v1.0.41 ([884fc90](https://github.com/simonecorsi/mawesome/commit/884fc90))
* test: fixs suite ([b97833f](https://github.com/simonecorsi/mawesome/commit/b97833f))
* fix: should avoid index lock ([1d6848c](https://github.com/simonecorsi/mawesome/commit/1d6848c))
- chore(release): v1.0.41 ([884fc90](https://github.com/simonecorsi/mawesome/commit/884fc90))
- test: fixs suite ([b97833f](https://github.com/simonecorsi/mawesome/commit/b97833f))
- fix: should avoid index lock ([1d6848c](https://github.com/simonecorsi/mawesome/commit/1d6848c))

View File

@@ -12,8 +12,20 @@ inputs:
required: true
github-name:
description: 'Name shown in the commit'
default: 'GitHub Actions'
required: false
github-email:
description: 'Email shown in the commit'
default: 'actions@users.noreply.github.com'
required: false
template-path:
required: false
description: 'EJS template path relative to project root directory'
default: 'TEMPLATE.ejs'
output-filename:
description: 'The output file name, default to README.md'
required: false
default: 'README.md'
runs:
using: 'node12'
main: 'index.js'

19302
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "mawesome",
"version": "1.0.45",
"version": "1.1.0-next.1",
"description": "Generate awesome list from user starred repositories",
"main": "index.js",
"author": "Simone Corsi<simonecorsi.dev@gmail.com>",
@@ -12,7 +12,8 @@
"style:prettier": "prettier \"src/**/*.ts\" --list-different --write",
"build": "./node_modules/.bin/ncc build src/index.ts -o ./",
"dev": "ts-node-dev src/index.ts",
"prerelease": "npm run build"
"prerelease": "npm run build",
"prepare": "node prepare.js || echo 'Skipping prepare'"
},
"keywords": [
"github",
@@ -24,43 +25,48 @@
"javascript"
],
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@octokit/rest": "^18.0.12",
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@octokit/rest": "^18.12.0",
"@octokit/types": "^6.2.1",
"@saithodev/semantic-release-backmerge": "^2.1.2",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.4",
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/ejs": "^3.0.5",
"@types/got": "^9.6.11",
"@types/got": "^9.6.12",
"@types/node": "^14.14.5",
"@types/sinon": "^9.0.10",
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
"@vercel/ncc": "^0.26.2",
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
"@vercel/ncc": "^0.33.3",
"ava": "^3.8.2",
"benchmark": "^2.1.4",
"cz-conventional-changelog": "^3.2.0",
"eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"husky": "^4.2.5",
"lint-staged": "^10.2.2",
"husky": "^7.0.4",
"lint-staged": "^12.3.7",
"markdown-toc": "^1.2.0",
"nyc": "^15.0.1",
"prettier": "^2.0.5",
"sinon": "^9.2.3",
"standard-version": "^9.0.0",
"ts-node-dev": "^1.1.1",
"typescript": "^4.1.3"
"typescript": "^4.6.4"
},
"dependencies": {
"@actions/exec": "^1.0.4",
"@actions/core": "^1.2.6",
"ejs": "^3.1.5",
"@actions/exec": "^1.1.1",
"ejs": "^3.1.6",
"gh-star-fetch": "^1.1.0",
"got": "^11.8.1",
"remark": "^13.0.0",
"remark-toc": "^7.0.0"
},
"volta": {
"node": "14.15.4"
"node": "16.14.2",
"npm": "8.6.0"
}
}
}

13
prepare.js Normal file
View File

@@ -0,0 +1,13 @@
'use strict';
let isCi = false;
try {
isCi = require('is-ci');
} catch (_) {
isCi = true;
}
if (!isCi) {
require('husky').install();
}

View File

@@ -1,11 +0,0 @@
import got from 'got';
import * as core from '@actions/core';
const GITHUB_TOKEN = core.getInput('api-token', { required: true });
export default got.extend({
headers: {
Authorization: `token ${GITHUB_TOKEN}`,
},
responseType: 'json',
});

View File

@@ -34,28 +34,26 @@ class Git {
return isShallow.trim().replace('\n', '') === 'true';
};
exec = (command: string): Promise<string> => {
return new Promise(async (resolve, reject) => {
let execOutput = '';
async exec(command: string): Promise<string> {
let execOutput = '';
const options = {
listeners: {
stdout: (data: Buffer) => {
execOutput += data.toString();
},
const options = {
listeners: {
stdout: (data: Buffer) => {
execOutput += data.toString();
},
};
},
};
const exitCode = await exec.exec(`git ${command}`, undefined, options);
const exitCode = await exec.exec(`git ${command}`, undefined, options);
if (exitCode === 0) {
return resolve(execOutput);
} else {
core.error(`Command "git ${command}" exited with code ${exitCode}.`);
return reject(`Command "git ${command}" exited with code ${exitCode}.`);
}
});
};
if (exitCode === 0) {
return execOutput;
} else {
core.error(`Command "git ${command}" exited with code ${exitCode}.`);
throw new Error(`Command "git ${command}" exited with code ${exitCode}.`);
}
}
config = (prop: string, value: string) =>
this.exec(`config ${prop} "${value}"`);

View File

@@ -3,10 +3,6 @@ import ejs from 'ejs';
import * as core from '@actions/core';
import remark from 'remark';
import toc from 'remark-toc';
import MD_TEMPLATE from './template';
import GithubApi from './api';
import link from './link';
import git from './git';
import type { PaginationLink, ApiGetStarResponse, Stars, Star } from './types';
@@ -16,13 +12,9 @@ export const API_STARRED_URL = `${process.env.GITHUB_API_URL}/users/${REPO_USERN
const fsp = fs.promises;
export function wait(time = 200): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, time));
}
export async function renderer(
data: { [key: string]: any },
templateString = MD_TEMPLATE
templateString: string
): Promise<string> {
try {
return ejs.render(templateString, data);
@@ -32,74 +24,6 @@ export async function renderer(
}
}
export function getNextPage(links: PaginationLink[]): string | null {
const next = links.find((l) => l.rel === 'next');
const last = links.find((l) => l.rel === 'last');
if (!next || !last) return null;
const matchNext = next.uri.match(/page=([0-9]*)/);
const matchLast = last.uri.match(/page=([0-9]*)/);
if (!matchNext || !matchLast) return null;
if (matchNext[1] === matchLast[1]) return null;
return matchNext[1];
}
async function* paginateStars(url: string): AsyncGenerator<Stars> {
let nextPage: string | null = '1';
while (nextPage) {
try {
const { headers, body } = await GithubApi.get(url, {
searchParams: {
page: nextPage,
},
});
yield (body as unknown) as Stars;
nextPage = getNextPage(link.parse(headers.link).refs);
await wait(1000); // avoid limits
} catch (e) {
console.error(e);
break;
}
}
}
export async function apiGetStar(
url: string = API_STARRED_URL
): Promise<ApiGetStarResponse> {
const data: Partial<Star>[] = [];
for await (const stars of paginateStars(url)) {
for (const star of stars) {
data.push({
id: star.id,
node_id: star.node_id,
name: star.name,
full_name: star.full_name,
owner: {
login: star?.owner?.login,
id: star?.owner?.id,
avatar_url: star?.owner?.avatar_url,
url: star?.owner?.url,
html_url: star?.owner?.html_url,
},
html_url: star.html_url,
description: star.description,
url: star.url,
languages_url: star.languages_url,
created_at: star.created_at,
updated_at: star.updated_at,
git_url: star.git_url,
ssh_url: star.ssh_url,
clone_url: star.clone_url,
homepage: star.homepage,
stargazers_count: star.stargazers_count,
watchers_count: star.watchers_count,
language: star.language,
topics: star.topics,
} as Partial<Star>);
}
}
return (data as unknown) as Stars;
}
export function generateMd(data: string): Promise<string> {
return new Promise((resolve) => {
remark()
@@ -115,8 +39,7 @@ export function generateMd(data: string): Promise<string> {
});
}
export const MARKDOWN_FILENAME: string =
core.getInput('output-filename') || 'README.md';
export const MARKDOWN_FILENAME: string = core.getInput('output-filename');
type File = {
filename: string;

View File

@@ -1,4 +1,6 @@
import * as core from '@actions/core';
import { readdir, readFile } from 'fs/promises';
import ghStarFetch from 'gh-star-fetch';
import {
renderer,
@@ -6,33 +8,38 @@ import {
generateMd,
pushNewFiles,
MARKDOWN_FILENAME,
apiGetStar,
} from './helpers';
import MD_TEMPLATE from './template';
import type { SortedLanguageList, Stars, Star } from './types';
export async function main() {
// set default template
let template = MD_TEMPLATE;
export async function main(): Promise<any> {
const results: Stars = await apiGetStar();
// get template if found in the repo
const customTemplatePath = core.getInput('template-path');
console.log(`check if customTemplatePath: ${customTemplatePath} exists`);
try {
const dir = await readdir('./');
console.log(dir.join('\n'));
template = await readFile('TEMPLATE.ejs', 'utf8');
} catch {
console.log("Couldn't find template file, using default");
}
const sortedByLanguages = results.reduce(
(acc: SortedLanguageList, val: Star) => {
const language = val.language || 'generic';
if (!acc[language]) {
acc[language] = [val];
} else {
acc[language].push(val);
}
return acc;
},
{}
);
const rendered = await renderer({
username: REPO_USERNAME,
stars: Object.entries(sortedByLanguages),
updatedAt: Date.now(),
const sortedByLanguages = await ghStarFetch({
accessToken: core.getInput('api-token', { required: true }),
compactByLanguage: true,
});
const rendered = await renderer(
{
username: REPO_USERNAME,
stars: Object.entries(sortedByLanguages),
updatedAt: Date.now(),
},
template
);
const markdown: string = await generateMd(rendered);
await pushNewFiles([
@@ -57,8 +64,9 @@ export async function run(): Promise<any> {
const catchAll = (info: any) => {
core.setFailed(`#catchAll: ${info}`);
core.error(info);
};
process.on('unhandledRejection', catchAll);
process.on('uncaughtException', catchAll);
run();
run().catch(core.error);

View File

@@ -1,384 +0,0 @@
/**
* Copyright (c) 2016 Jonas Hermsmeier
* https://github.com/jhermsmeier/node-http-link-header
*/
/* istanbul ignore file */
'use strict';
var COMPATIBLE_ENCODING_PATTERN = /^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i;
var WS_TRIM_PATTERN = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
var WS_CHAR_PATTERN = /\s|\uFEFF|\xA0/;
var WS_FOLD_PATTERN = /\r?\n[\x20\x09]+/g;
var DELIMITER_PATTERN = /[;,"]/;
var WS_DELIMITER_PATTERN = /[;,"]|\s/;
/**
* Token character pattern
* @type {RegExp}
* @see https://tools.ietf.org/html/rfc7230#section-3.2.6
*/
var TOKEN_PATTERN = /^[!#$%&'*+\-\.^_`|~\da-zA-Z]+$/;
var STATE = {
IDLE: 1 << 0,
URI: 1 << 1,
ATTR: 1 << 2,
};
function trim(value) {
return value.replace(WS_TRIM_PATTERN, '');
}
function hasWhitespace(value) {
return WS_CHAR_PATTERN.test(value);
}
function skipWhitespace(value, offset) {
while (hasWhitespace(value[offset])) {
offset++;
}
return offset;
}
function needsQuotes(value) {
return WS_DELIMITER_PATTERN.test(value) || !TOKEN_PATTERN.test(value);
}
class Link {
/**
* Link
* @constructor
* @param {String} [value]
* @returns {Link}
*/
constructor(value) {
/** @type {Array} URI references */
this.refs = [];
if (value) {
this.parse(value);
}
}
/**
* Get refs with given relation type
* @param {String} value
* @returns {Array<Object>}
*/
rel(value) {
var links = [];
var type = value.toLowerCase();
for (var i = 0; i < this.refs.length; i++) {
if (this.refs[i].rel.toLowerCase() === type) {
links.push(this.refs[i]);
}
}
return links;
}
/**
* Get refs where given attribute has a given value
* @param {String} attr
* @param {String} value
* @returns {Array<Object>}
*/
get(attr, value) {
attr = attr.toLowerCase();
var links = [];
for (var i = 0; i < this.refs.length; i++) {
if (this.refs[i][attr] === value) {
links.push(this.refs[i]);
}
}
return links;
}
set(link) {
this.refs.push(link);
return this;
}
has(attr, value) {
attr = attr.toLowerCase();
for (var i = 0; i < this.refs.length; i++) {
if (this.refs[i][attr] === value) {
return true;
}
}
return false;
}
parse(value, offset) {
offset = offset || 0;
value = offset ? value.slice(offset) : value;
// Trim & unfold folded lines
value = trim(value).replace(WS_FOLD_PATTERN, '');
var state = STATE.IDLE;
var length = value.length;
var offset = 0;
var ref = null;
while (offset < length) {
if (state === STATE.IDLE) {
if (hasWhitespace(value[offset])) {
offset++;
continue;
} else if (value[offset] === '<') {
if (ref != null) {
ref.rel != null
? this.refs.push(...Link.expandRelations(ref))
: this.refs.push(ref);
}
var end = value.indexOf('>', offset);
if (end === -1)
throw new Error(
'Expected end of URI delimiter at offset ' + offset
);
ref = { uri: value.slice(offset + 1, end) };
// this.refs.push( ref )
offset = end;
state = STATE.URI;
} else {
throw new Error(
'Unexpected character "' + value[offset] + '" at offset ' + offset
);
}
offset++;
} else if (state === STATE.URI) {
if (hasWhitespace(value[offset])) {
offset++;
continue;
} else if (value[offset] === ';') {
state = STATE.ATTR;
offset++;
} else if (value[offset] === ',') {
state = STATE.IDLE;
offset++;
} else {
throw new Error(
'Unexpected character "' + value[offset] + '" at offset ' + offset
);
}
} else if (state === STATE.ATTR) {
if (value[offset] === ';' || hasWhitespace(value[offset])) {
offset++;
continue;
}
var end = value.indexOf('=', offset);
if (end === -1)
throw new Error('Expected attribute delimiter at offset ' + offset);
var attr = trim(value.slice(offset, end)).toLowerCase();
var attrValue = '';
offset = end + 1;
offset = skipWhitespace(value, offset);
if (value[offset] === '"') {
offset++;
while (offset < length) {
if (value[offset] === '"') {
offset++;
break;
}
if (value[offset] === '\\') {
offset++;
}
attrValue += value[offset];
offset++;
}
} else {
var end = offset + 1;
while (!DELIMITER_PATTERN.test(value[end]) && end < length) {
end++;
}
attrValue = value.slice(offset, end);
offset = end;
}
if (ref[attr] && Link.isSingleOccurenceAttr(attr)) {
// Ignore multiples of attributes which may only appear once
} else if (attr[attr.length - 1] === '*') {
ref[attr] = Link.parseExtendedValue(attrValue);
} else {
attrValue = attr === 'type' ? attrValue.toLowerCase() : attrValue;
if (ref[attr] != null) {
if (Array.isArray(ref[attr])) {
ref[attr].push(attrValue);
} else {
ref[attr] = [ref[attr], attrValue];
}
} else {
ref[attr] = attrValue;
}
}
switch (value[offset]) {
case ',':
state = STATE.IDLE;
break;
case ';':
state = STATE.ATTR;
break;
}
offset++;
} else {
throw new Error('Unknown parser state "' + state + '"');
}
}
if (ref != null) {
ref.rel != null
? this.refs.push(...Link.expandRelations(ref))
: this.refs.push(ref);
}
ref = null;
return this;
}
toString() {
var refs = [];
var link = '';
var ref = null;
for (var i = 0; i < this.refs.length; i++) {
ref = this.refs[i];
link = Object.keys(this.refs[i]).reduce(function (link, attr) {
if (attr === 'uri') return link;
return link + '; ' + Link.formatAttribute(attr, ref[attr]);
}, '<' + ref.uri + '>');
refs.push(link);
}
return refs.join(', ');
}
}
/**
* Determines whether an encoding can be
* natively handled with a `Buffer`
* @param {String} value
* @returns {Boolean}
*/
Link.isCompatibleEncoding = function (value) {
return COMPATIBLE_ENCODING_PATTERN.test(value);
};
Link.parse = function (value, offset) {
return new Link().parse(value, offset);
};
Link.isSingleOccurenceAttr = function (attr) {
return (
attr === 'rel' ||
attr === 'type' ||
attr === 'media' ||
attr === 'title' ||
attr === 'title*'
);
};
Link.isTokenAttr = function (attr) {
return attr === 'rel' || attr === 'type' || attr === 'anchor';
};
Link.escapeQuotes = function (value) {
return value.replace(/"/g, '\\"');
};
Link.expandRelations = function (ref) {
var rels = ref.rel.split(' ');
return rels.map(function (rel) {
var value = Object.assign({}, ref);
value.rel = rel;
return value;
});
};
/**
* Parses an extended value and attempts to decode it
* @internal
* @param {String} value
* @return {Object}
*/
Link.parseExtendedValue = function (value) {
var parts = /([^']+)?(?:'([^']+)')?(.+)/.exec(value);
return {
language: parts[2].toLowerCase(),
encoding: Link.isCompatibleEncoding(parts[1])
? null
: parts[1].toLowerCase(),
value: Link.isCompatibleEncoding(parts[1])
? decodeURIComponent(parts[3])
: parts[3],
};
};
/**
* Format a given extended attribute and it's value
* @param {String} attr
* @param {Object} data
* @return {String}
*/
Link.formatExtendedAttribute = function (attr, data) {
var encoding = (data.encoding || 'utf-8').toUpperCase();
var language = data.language || 'en';
var encodedValue = '';
if (Buffer.isBuffer(data.value) && Link.isCompatibleEncoding(encoding)) {
encodedValue = data.value.toString(encoding);
} else if (Buffer.isBuffer(data.value)) {
encodedValue = data.value.toString('hex').replace(/[0-9a-f]{2}/gi, '%$1');
} else {
encodedValue = encodeURIComponent(data.value);
}
return attr + '=' + encoding + "'" + language + "'" + encodedValue;
};
/**
* Format a given attribute and it's value
* @param {String} attr
* @param {String|Object} value
* @return {String}
*/
Link.formatAttribute = function (attr, value) {
if (Array.isArray(value)) {
return value
.map((item) => {
return Link.formatAttribute(attr, item);
})
.join('; ');
}
if (attr[attr.length - 1] === '*' || typeof value !== 'string') {
return Link.formatExtendedAttribute(attr, value);
}
if (Link.isTokenAttr(attr)) {
value = needsQuotes(value)
? '"' + Link.escapeQuotes(value) + '"'
: Link.escapeQuotes(value);
} else if (needsQuotes(value)) {
value = encodeURIComponent(value);
// We don't need to escape <SP> <,> <;> within quotes
value = value
.replace(/%20/g, ' ')
.replace(/%2C/g, ',')
.replace(/%3B/g, ';');
value = '"' + value + '"';
}
return attr + '=' + value;
};
module.exports = Link;

View File

@@ -5,16 +5,6 @@ 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: [],
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);
@@ -31,30 +21,13 @@ const fsp = fs.promises;
const writeFile = sinon.fake();
sinon.replace(fsp, 'writeFile', writeFile);
import {
wait,
renderer,
apiGetStar,
generateMd,
pushNewFiles,
} from '../src/helpers';
test('wait should wait', async (t) => {
await wait(200);
t.pass();
});
import { renderer, generateMd, pushNewFiles } from '../src/helpers';
test('renderer should render', async (t) => {
const output = await renderer({ variable: 123 }, 'Test: <%= variable %>');
t.is(output, 'Test: 123');
});
test('apiGetStar', async (t) => {
let stars = await apiGetStar('url');
t.true(GithubApiFake.called);
t.true(Array.isArray(stars));
});
test('generateMd should create TOC', async (t) => {
const tpl = `# title