Compare commits
39 Commits
v1.0.41
...
v1.1.0-nex
Author | SHA1 | Date | |
---|---|---|---|
|
7fb87741a2 | ||
|
602befcb54 | ||
|
791de9ab50 | ||
|
3c630ecb73 | ||
|
62cc7b142a | ||
|
49c817ef10 | ||
|
e17f0be682 | ||
|
97c305eeb7 | ||
|
a443da7025 | ||
|
07b2bb76e0 | ||
|
2ad49c269e | ||
|
fd0321acf5 | ||
|
dbd50a89e4 | ||
|
5027ab963e | ||
|
95daa3318c | ||
|
c93b1511f1 | ||
|
0ceab70142 | ||
|
2eb10280a7 | ||
|
e4a2588002 | ||
|
694ba91ecc | ||
|
a683b39f9f | ||
|
8253c064fe | ||
|
7af34fda05 | ||
|
d4dd907bb0 | ||
|
b0c97c8ec6 | ||
|
a0b73020ce | ||
|
04fbe0af6f | ||
|
d4184b0b6b | ||
|
064eb14315 | ||
|
b07cc92b5c | ||
|
e5ba2cf34b | ||
|
f68439999d | ||
|
1da350a3d0 | ||
|
6ffe17f8b4 | ||
|
4aef61f232 | ||
|
5e0ef822fd | ||
|
94635fe447 | ||
|
5b36813618 | ||
|
dcf9898d67 |
13
.github/CODEOWNERS
vendored
Normal file
13
.github/CODEOWNERS
vendored
Normal 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
18
.github/dependabot.yml
vendored
Normal 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
15
.github/pull_request_template.md
vendored
Normal 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
|
19
.github/workflows/merge.yaml
vendored
19
.github/workflows/merge.yaml
vendored
@@ -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
21
.github/workflows/merge.yml
vendored
Normal 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
|
47
.github/workflows/release.yaml
vendored
47
.github/workflows/release.yaml
vendored
@@ -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
46
.github/workflows/release.yml
vendored
Normal 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
1
.husky/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
_
|
4
.husky/commit-msg
Executable file
4
.husky/commit-msg
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npx --no-install commitlint --edit $1
|
4
.husky/pre-commit
Executable file
4
.husky/pre-commit
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npx --no-install lint-staged
|
@@ -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
25
.releaserc.json
Normal 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"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
69
CHANGELOG.md
69
CHANGELOG.md
@@ -1,37 +1,36 @@
|
||||
# [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))
|
||||
|
||||
## <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))
|
||||
|
||||
## <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))
|
||||
|
||||
## <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))
|
||||
|
||||
## <small>1.0.41 (2021-10-14)</small>
|
||||
|
||||
* test: fixs suite ([b97833f](https://github.com/simonecorsi/mawesome/commit/b97833f))
|
||||
* fix: should avoid index lock ([1d6848c](https://github.com/simonecorsi/mawesome/commit/1d6848c))
|
||||
|
||||
|
||||
|
||||
## <small>1.0.40 (2021-10-13)</small>
|
||||
|
||||
* chore(release): v1.0.40 ([0e016f4](https://github.com/simonecorsi/mawesome/commit/0e016f4))
|
||||
* fix: fixes while exit condition ([8f9b4cc](https://github.com/simonecorsi/mawesome/commit/8f9b4cc))
|
||||
* feat: paginates using async generator ([51da6c2](https://github.com/simonecorsi/mawesome/commit/51da6c2))
|
||||
|
||||
|
||||
|
||||
## <small>1.0.39 (2021-08-31)</small>
|
||||
|
||||
* chore(release): v1.0.39 ([f7a8341](https://github.com/simonecorsi/mawesome/commit/f7a8341))
|
||||
* build(deps): bump path-parse from 1.0.6 to 1.0.7 ([ef137b5](https://github.com/simonecorsi/mawesome/commit/ef137b5))
|
||||
|
||||
|
||||
|
||||
## <small>1.0.38 (2021-06-23)</small>
|
||||
|
||||
* chore(release): v1.0.38 ([3e66d85](https://github.com/simonecorsi/mawesome/commit/3e66d85))
|
||||
|
||||
|
||||
|
||||
## <small>1.0.37 (2021-06-23)</small>
|
||||
|
||||
* chore(release): v1.0.37 ([1643092](https://github.com/simonecorsi/mawesome/commit/1643092))
|
||||
* build(deps): bump glob-parent from 5.1.1 to 5.1.2 ([e558e07](https://github.com/simonecorsi/mawesome/commit/e558e07))
|
||||
* build(deps): bump hosted-git-info from 2.8.8 to 2.8.9 ([110a667](https://github.com/simonecorsi/mawesome/commit/110a667))
|
||||
* build(deps): bump normalize-url from 4.5.0 to 4.5.1 ([202d6fe](https://github.com/simonecorsi/mawesome/commit/202d6fe))
|
||||
|
||||
|
||||
|
||||
- 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))
|
||||
|
58
index.js
58
index.js
@@ -21291,7 +21291,16 @@ class Git {
|
||||
}));
|
||||
};
|
||||
this.config = (prop, value) => this.exec(`config ${prop} "${value}"`);
|
||||
this.add = (file) => this.exec(`add ${file}`);
|
||||
this.add = (file) => {
|
||||
let str = '';
|
||||
if (Array.isArray(file)) {
|
||||
file.map((f) => (str += ` ${f}`));
|
||||
}
|
||||
else {
|
||||
str = file;
|
||||
}
|
||||
return this.exec(`add ${str}`);
|
||||
};
|
||||
this.commit = (message) => this.exec(`commit -m "${message}"`);
|
||||
this.pull = () => __awaiter(this, void 0, void 0, function* () {
|
||||
const args = ['pull'];
|
||||
@@ -21415,7 +21424,7 @@ function getNextPage(links) {
|
||||
if (!next || !last)
|
||||
return null;
|
||||
const matchNext = next.uri.match(/page=([0-9]*)/);
|
||||
const matchLast = next.uri.match(/page=([0-9]*)/);
|
||||
const matchLast = last.uri.match(/page=([0-9]*)/);
|
||||
if (!matchNext || !matchLast)
|
||||
return null;
|
||||
if (matchNext[1] === matchLast[1])
|
||||
@@ -21446,18 +21455,47 @@ function paginateStars(url) {
|
||||
}
|
||||
function apiGetStar(url = exports.API_STARRED_URL) {
|
||||
var e_1, _a;
|
||||
var _b, _c, _d, _e, _f;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let data = [];
|
||||
const data = [];
|
||||
try {
|
||||
for (var _b = __asyncValues(paginateStars(url)), _c; _c = yield _b.next(), !_c.done;) {
|
||||
const stars = _c.value;
|
||||
data = data.concat(stars);
|
||||
for (var _g = __asyncValues(paginateStars(url)), _h; _h = yield _g.next(), !_h.done;) {
|
||||
const stars = _h.value;
|
||||
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: (_b = star === null || star === void 0 ? void 0 : star.owner) === null || _b === void 0 ? void 0 : _b.login,
|
||||
id: (_c = star === null || star === void 0 ? void 0 : star.owner) === null || _c === void 0 ? void 0 : _c.id,
|
||||
avatar_url: (_d = star === null || star === void 0 ? void 0 : star.owner) === null || _d === void 0 ? void 0 : _d.avatar_url,
|
||||
url: (_e = star === null || star === void 0 ? void 0 : star.owner) === null || _e === void 0 ? void 0 : _e.url,
|
||||
html_url: (_f = star === null || star === void 0 ? void 0 : star.owner) === null || _f === void 0 ? void 0 : _f.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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
|
||||
if (_h && !_h.done && (_a = _g.return)) yield _a.call(_g);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
@@ -21486,10 +21524,8 @@ function pushNewFiles(files = []) {
|
||||
if (!files.length)
|
||||
return;
|
||||
yield git_1.default.pull();
|
||||
yield Promise.all(files.map(({ filename, data }) => __awaiter(this, void 0, void 0, function* () {
|
||||
yield fsp.writeFile(filename, data);
|
||||
yield git_1.default.add(filename);
|
||||
})));
|
||||
yield Promise.all(files.map(({ filename, data }) => fsp.writeFile(filename, data)));
|
||||
yield git_1.default.add(files.map(({ filename }) => filename));
|
||||
yield git_1.default.commit(`chore(updates): updated entries in files`);
|
||||
yield git_1.default.push();
|
||||
});
|
||||
|
19239
package-lock.json
generated
19239
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
39
package.json
39
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mawesome",
|
||||
"version": "1.0.41",
|
||||
"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,47 @@
|
||||
"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/eslint-plugin": "^4.33.0",
|
||||
"@typescript-eslint/parser": "^4.6.0",
|
||||
"@vercel/ncc": "^0.26.2",
|
||||
"@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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/core": "^1.2.6",
|
||||
"ejs": "^3.1.5",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"ejs": "^3.1.6",
|
||||
"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
13
prepare.js
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
let isCi = false;
|
||||
|
||||
try {
|
||||
isCi = require('is-ci');
|
||||
} catch (_) {
|
||||
isCi = true;
|
||||
}
|
||||
|
||||
if (!isCi) {
|
||||
require('husky').install();
|
||||
}
|
10
src/git.ts
10
src/git.ts
@@ -60,7 +60,15 @@ class Git {
|
||||
config = (prop: string, value: string) =>
|
||||
this.exec(`config ${prop} "${value}"`);
|
||||
|
||||
add = (file: string) => this.exec(`add ${file}`);
|
||||
add = (file: string | string[]) => {
|
||||
let str = '';
|
||||
if (Array.isArray(file)) {
|
||||
file.map((f) => (str += ` ${f}`));
|
||||
} else {
|
||||
str = file;
|
||||
}
|
||||
return this.exec(`add ${str}`);
|
||||
};
|
||||
|
||||
commit = (message: string) => this.exec(`commit -m "${message}"`);
|
||||
|
||||
|
@@ -9,7 +9,7 @@ import GithubApi from './api';
|
||||
import link from './link';
|
||||
import git from './git';
|
||||
|
||||
import type { PaginationLink, ApiGetStarResponse, Stars } from './types';
|
||||
import type { PaginationLink, ApiGetStarResponse, Stars, Star } from './types';
|
||||
|
||||
export const REPO_USERNAME = process.env.GITHUB_REPOSITORY?.split('/')[0];
|
||||
export const API_STARRED_URL = `${process.env.GITHUB_API_URL}/users/${REPO_USERNAME}/starred`;
|
||||
@@ -37,8 +37,7 @@ export function getNextPage(links: PaginationLink[]): string | null {
|
||||
const last = links.find((l) => l.rel === 'last');
|
||||
if (!next || !last) return null;
|
||||
const matchNext = next.uri.match(/page=([0-9]*)/);
|
||||
const matchLast = 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];
|
||||
@@ -66,9 +65,37 @@ async function* paginateStars(url: string): AsyncGenerator<Stars> {
|
||||
export async function apiGetStar(
|
||||
url: string = API_STARRED_URL
|
||||
): Promise<ApiGetStarResponse> {
|
||||
let data: Stars[] = [];
|
||||
const data: Partial<Star>[] = [];
|
||||
for await (const stars of paginateStars(url)) {
|
||||
data = data.concat(stars);
|
||||
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;
|
||||
}
|
||||
@@ -102,12 +129,10 @@ export async function pushNewFiles(files: File[] = []): Promise<any> {
|
||||
await git.pull();
|
||||
|
||||
await Promise.all(
|
||||
files.map(async ({ filename, data }) => {
|
||||
await fsp.writeFile(filename, data);
|
||||
await git.add(filename);
|
||||
})
|
||||
files.map(({ filename, data }) => fsp.writeFile(filename, data))
|
||||
);
|
||||
|
||||
await git.add(files.map(({ filename }) => filename));
|
||||
await git.commit(`chore(updates): updated entries in files`);
|
||||
await git.push();
|
||||
}
|
||||
|
25
src/index.ts
25
src/index.ts
@@ -1,4 +1,5 @@
|
||||
import * as core from '@actions/core';
|
||||
import { readdir, readFile } from 'fs/promises';
|
||||
|
||||
import {
|
||||
renderer,
|
||||
@@ -27,11 +28,25 @@ export async function main(): Promise<any> {
|
||||
{}
|
||||
);
|
||||
|
||||
const rendered = await renderer({
|
||||
username: REPO_USERNAME,
|
||||
stars: Object.entries(sortedByLanguages),
|
||||
updatedAt: Date.now(),
|
||||
});
|
||||
// get template if found in the repo
|
||||
let template;
|
||||
try {
|
||||
const dir = await readdir('./');
|
||||
core.info(dir.join('\n'));
|
||||
template = await readFile('TEMPLATE.ejs', 'utf8');
|
||||
core.info(template);
|
||||
} catch {
|
||||
core.warning("Couldn't find template file, using default");
|
||||
}
|
||||
|
||||
const rendered = await renderer(
|
||||
{
|
||||
username: REPO_USERNAME,
|
||||
stars: Object.entries(sortedByLanguages),
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
template
|
||||
);
|
||||
|
||||
const markdown: string = await generateMd(rendered);
|
||||
|
||||
|
Reference in New Issue
Block a user