Compare commits
103 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bb3b0b0f0a | ||
|
0f8e9ce378 | ||
|
aed446506b | ||
|
7458edb49a | ||
|
4d7eef0991 | ||
|
176cc5dbe1 | ||
|
8d6a751c11 | ||
|
9c234abace | ||
|
a771f0d61a | ||
|
20cd1f1a35 | ||
|
49f66875e3 | ||
|
30fa351b37 | ||
|
01cfb39a41 | ||
|
9dfa1f3dae | ||
|
8100d06ca5 | ||
|
3960276c1d | ||
|
25164d9ec0 | ||
|
1f861e88e7 | ||
|
2cfb2e8114 | ||
|
f6ecfc7440 | ||
|
f37ca8b773 | ||
|
32fb9e910c | ||
|
8eb8cc4c59 | ||
|
dbb98a14ae | ||
|
b4e5073bb0 | ||
|
a9d96a00bc | ||
|
b0655c22bb | ||
|
49a4af2752 | ||
|
d6561b1729 | ||
|
2152ebc21c | ||
|
9c15d766c2 | ||
|
2be0173bbd | ||
|
7a183c8410 | ||
|
4c72f2977d | ||
|
85994c7177 | ||
|
bf78ae9dce | ||
|
97597c3d71 | ||
|
4f9c923d3b | ||
|
fdb357799c | ||
|
0d2b3a558d | ||
|
61764d6d43 | ||
|
c6e7479b7a | ||
|
46b290aa80 | ||
|
eb50438144 | ||
|
5af2376029 | ||
|
e70557ee7b | ||
|
19d67ba086 | ||
|
d1a261ea11 | ||
|
272215218f | ||
|
80fb1a3b1d | ||
|
eb304f9781 | ||
|
aaa3781d20 | ||
|
332aefb25f | ||
|
f8db7df1fa | ||
|
e8d96f5bfa | ||
|
8d17e1730c | ||
|
ab4bef3cc9 | ||
|
690615ff33 | ||
|
0247a1d217 | ||
|
b0d602913a | ||
|
d7bd75a6e5 | ||
|
deef7d2365 | ||
|
cc4baa2e7a | ||
|
9e363cf1b1 | ||
|
5ad7208983 | ||
|
7d1718e953 | ||
|
863c2645ac | ||
|
ea66e9399e | ||
|
4fe2d07f1f | ||
|
f6989bb074 | ||
|
568d458479 | ||
|
5b3c6d79e0 | ||
|
4f99babd41 | ||
|
274973fd7f | ||
|
37d007814a | ||
|
9705acd4f4 | ||
|
e7c4dd0d63 | ||
|
a7c247d5a5 | ||
|
61d9615e6b | ||
|
145ea9348b | ||
|
fd31bcfc19 | ||
|
40b1871114 | ||
|
f7f9d4af71 | ||
|
d224150e09 | ||
|
27d0b8c74a | ||
|
c5954d9a47 | ||
|
9bc1aa57fa | ||
|
2ed57c1e23 | ||
|
918f8a8281 | ||
|
57eb1a81ac | ||
|
f095537441 | ||
|
d9d94e819c | ||
|
3da3ade364 | ||
|
8975c7657d | ||
|
42d5f64ed1 | ||
|
bd3c955fcf | ||
|
2c10a5b742 | ||
|
1661e6f8e0 | ||
|
5fd3e07811 | ||
|
7327599c78 | ||
|
8da6e2ca19 | ||
|
745877e26d | ||
|
d0e125fa3e |
@@ -23,7 +23,7 @@
|
|||||||
"@saithodev/semantic-release-backmerge",
|
"@saithodev/semantic-release-backmerge",
|
||||||
{
|
{
|
||||||
"branches": [{ "from": "main", "to": "next" }],
|
"branches": [{ "from": "main", "to": "next" }],
|
||||||
"backmergeStrategy": "rebase"
|
"clearWorkspace": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,3 +1,18 @@
|
|||||||
|
# [2.2.0](https://github.com/simonecorsi/mawesome/compare/v2.1.0...v2.2.0) (2022-07-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* compact by topic check ([49f6687](https://github.com/simonecorsi/mawesome/commit/49f66875e34ef186f183e370979ef751694d08b2))
|
||||||
|
* compact by topic check ([01cfb39](https://github.com/simonecorsi/mawesome/commit/01cfb39a41a2f60c709fd6dd6a46073149d96c20))
|
||||||
|
* docs ([4d7eef0](https://github.com/simonecorsi/mawesome/commit/4d7eef0991d896027ac464a40edfc564ced6bdd2))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* adds compacted by topics ([30fa351](https://github.com/simonecorsi/mawesome/commit/30fa351b37a04357303f59c79a90f92219f8072c))
|
||||||
|
* adds compacted by topics ([9dfa1f3](https://github.com/simonecorsi/mawesome/commit/9dfa1f3dae6c69033c682211c0e6bd9dc5a81eaf))
|
||||||
|
|
||||||
# [2.1.0](https://github.com/simonecorsi/mawesome/compare/v2.0.0...v2.1.0) (2022-05-11)
|
# [2.1.0](https://github.com/simonecorsi/mawesome/compare/v2.0.0...v2.1.0) (2022-05-11)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@ You can see an example of the output at my own [simonecorsi/awesome](https://git
|
|||||||
- [Requirements](#requirements)
|
- [Requirements](#requirements)
|
||||||
- [Configuration](#configuration)
|
- [Configuration](#configuration)
|
||||||
- [`api-token`](#api-token)
|
- [`api-token`](#api-token)
|
||||||
|
- [`compact-by-topic`](#compact-by-topic)
|
||||||
- [`template-path`](#template-path)
|
- [`template-path`](#template-path)
|
||||||
- [Example workflow](#example-workflow)
|
- [Example workflow](#example-workflow)
|
||||||
|
|
||||||
@@ -29,8 +30,9 @@ You can see an example of the output at my own [simonecorsi/awesome](https://git
|
|||||||
The service can be configured setting the appropriate environment variables or writing an `.env` file.
|
The service can be configured setting the appropriate environment variables or writing an `.env` file.
|
||||||
|
|
||||||
| Variable | Description | Default |
|
| Variable | Description | Default |
|
||||||
| ----------------- | ------------------------------------------------------------------- | -------------------------------- |
|
| ------------------ | ------------------------------------------------------------------- | -------------------------------- |
|
||||||
| `api-token` | Personal Token is used to avoid rate limit, [read more](#api-token) | `${{ secrets.API_TOKEN }}` |
|
| `api-token` | Personal Token is used to avoid rate limit, [read more](#api-token) | `${{ secrets.API_TOKEN }}` |
|
||||||
|
| `compact-by-topic` | Render another list in `TOPICS.md` compacted by github topics | `'false'` |
|
||||||
| `github-name` | Name used for the commit | Github Action |
|
| `github-name` | Name used for the commit | Github Action |
|
||||||
| `github-email` | email used for commit | actions@users.noreply.github.com |
|
| `github-email` | email used for commit | actions@users.noreply.github.com |
|
||||||
| `template-path` | Custom `README.md` template, [read more](#template-path) |
|
| `template-path` | Custom `README.md` template, [read more](#template-path) |
|
||||||
@@ -42,6 +44,10 @@ The Personal API Access Token is mandatory to fetch stars from the API without i
|
|||||||
|
|
||||||
You'll have to generate a [personal api token](https://github.com/settings/tokens/new) and then add
|
You'll have to generate a [personal api token](https://github.com/settings/tokens/new) and then add
|
||||||
|
|
||||||
|
#### `compact-by-topic`
|
||||||
|
|
||||||
|
If `compact-by-topic` is `'true'` it will generate another markdown file `TOPICS.md` whith all stars compacted by their github topics, be aware that this list will be bigger since data is duplicated.
|
||||||
|
|
||||||
#### `template-path`
|
#### `template-path`
|
||||||
|
|
||||||
If you don't like the output (default example [here](./TEMPLATE.ejs) ), you can provide your custom template that will be rendered using [EJS](https://ejs.co/) template engine.
|
If you don't like the output (default example [here](./TEMPLATE.ejs) ), you can provide your custom template that will be rendered using [EJS](https://ejs.co/) template engine.
|
||||||
|
@@ -4,6 +4,10 @@ branding:
|
|||||||
icon: align-justify
|
icon: align-justify
|
||||||
color: yellow
|
color: yellow
|
||||||
inputs:
|
inputs:
|
||||||
|
compact-by-topic:
|
||||||
|
description: 'Generate another page with output compacted by github topics'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
api-token:
|
api-token:
|
||||||
description: 'Personal API Token'
|
description: 'Personal API Token'
|
||||||
required: true
|
required: true
|
||||||
|
515
index.js
515
index.js
@@ -425,6 +425,13 @@ Object.defineProperty(exports, "summary", ({ enumerable: true, get: function ()
|
|||||||
*/
|
*/
|
||||||
var summary_2 = __nccwpck_require__(1327);
|
var summary_2 = __nccwpck_require__(1327);
|
||||||
Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } }));
|
Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } }));
|
||||||
|
/**
|
||||||
|
* Path exports
|
||||||
|
*/
|
||||||
|
var path_utils_1 = __nccwpck_require__(2981);
|
||||||
|
Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } }));
|
||||||
|
Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } }));
|
||||||
|
Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } }));
|
||||||
//# sourceMappingURL=core.js.map
|
//# sourceMappingURL=core.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -494,8 +501,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.OidcClient = void 0;
|
exports.OidcClient = void 0;
|
||||||
const http_client_1 = __nccwpck_require__(9925);
|
const http_client_1 = __nccwpck_require__(6255);
|
||||||
const auth_1 = __nccwpck_require__(3702);
|
const auth_1 = __nccwpck_require__(5526);
|
||||||
const core_1 = __nccwpck_require__(2186);
|
const core_1 = __nccwpck_require__(2186);
|
||||||
class OidcClient {
|
class OidcClient {
|
||||||
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
||||||
@@ -562,6 +569,71 @@ exports.OidcClient = OidcClient;
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 2981:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0;
|
||||||
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
|
/**
|
||||||
|
* toPosixPath converts the given path to the posix form. On Windows, \\ will be
|
||||||
|
* replaced with /.
|
||||||
|
*
|
||||||
|
* @param pth. Path to transform.
|
||||||
|
* @return string Posix path.
|
||||||
|
*/
|
||||||
|
function toPosixPath(pth) {
|
||||||
|
return pth.replace(/[\\]/g, '/');
|
||||||
|
}
|
||||||
|
exports.toPosixPath = toPosixPath;
|
||||||
|
/**
|
||||||
|
* toWin32Path converts the given path to the win32 form. On Linux, / will be
|
||||||
|
* replaced with \\.
|
||||||
|
*
|
||||||
|
* @param pth. Path to transform.
|
||||||
|
* @return string Win32 path.
|
||||||
|
*/
|
||||||
|
function toWin32Path(pth) {
|
||||||
|
return pth.replace(/[/]/g, '\\');
|
||||||
|
}
|
||||||
|
exports.toWin32Path = toWin32Path;
|
||||||
|
/**
|
||||||
|
* toPlatformPath converts the given path to a platform-specific path. It does
|
||||||
|
* this by replacing instances of / and \ with the platform-specific path
|
||||||
|
* separator.
|
||||||
|
*
|
||||||
|
* @param pth The path to platformize.
|
||||||
|
* @return string The platform-specific path.
|
||||||
|
*/
|
||||||
|
function toPlatformPath(pth) {
|
||||||
|
return pth.replace(/[/\\]/g, path.sep);
|
||||||
|
}
|
||||||
|
exports.toPlatformPath = toPlatformPath;
|
||||||
|
//# sourceMappingURL=path-utils.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 1327:
|
/***/ 1327:
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
@@ -1634,28 +1706,41 @@ class ExecState extends events.EventEmitter {
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 3702:
|
/***/ 5526:
|
||||||
/***/ ((__unused_webpack_module, exports) => {
|
/***/ (function(__unused_webpack_module, exports) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
|
||||||
class BasicCredentialHandler {
|
class BasicCredentialHandler {
|
||||||
constructor(username, password) {
|
constructor(username, password) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
prepareRequest(options) {
|
prepareRequest(options) {
|
||||||
options.headers['Authorization'] =
|
if (!options.headers) {
|
||||||
'Basic ' +
|
throw Error('The request has no headers');
|
||||||
Buffer.from(this.username + ':' + this.password).toString('base64');
|
}
|
||||||
|
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
|
||||||
}
|
}
|
||||||
// This handler cannot handle 401
|
// This handler cannot handle 401
|
||||||
canHandleAuthentication(response) {
|
canHandleAuthentication() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
handleAuthentication(httpClient, requestInfo, objs) {
|
handleAuthentication() {
|
||||||
return null;
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
throw new Error('not implemented');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.BasicCredentialHandler = BasicCredentialHandler;
|
exports.BasicCredentialHandler = BasicCredentialHandler;
|
||||||
@@ -1666,14 +1751,19 @@ class BearerCredentialHandler {
|
|||||||
// currently implements pre-authorization
|
// currently implements pre-authorization
|
||||||
// TODO: support preAuth = false where it hooks on 401
|
// TODO: support preAuth = false where it hooks on 401
|
||||||
prepareRequest(options) {
|
prepareRequest(options) {
|
||||||
options.headers['Authorization'] = 'Bearer ' + this.token;
|
if (!options.headers) {
|
||||||
|
throw Error('The request has no headers');
|
||||||
|
}
|
||||||
|
options.headers['Authorization'] = `Bearer ${this.token}`;
|
||||||
}
|
}
|
||||||
// This handler cannot handle 401
|
// This handler cannot handle 401
|
||||||
canHandleAuthentication(response) {
|
canHandleAuthentication() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
handleAuthentication(httpClient, requestInfo, objs) {
|
handleAuthentication() {
|
||||||
return null;
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
throw new Error('not implemented');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.BearerCredentialHandler = BearerCredentialHandler;
|
exports.BearerCredentialHandler = BearerCredentialHandler;
|
||||||
@@ -1684,32 +1774,66 @@ class PersonalAccessTokenCredentialHandler {
|
|||||||
// currently implements pre-authorization
|
// currently implements pre-authorization
|
||||||
// TODO: support preAuth = false where it hooks on 401
|
// TODO: support preAuth = false where it hooks on 401
|
||||||
prepareRequest(options) {
|
prepareRequest(options) {
|
||||||
options.headers['Authorization'] =
|
if (!options.headers) {
|
||||||
'Basic ' + Buffer.from('PAT:' + this.token).toString('base64');
|
throw Error('The request has no headers');
|
||||||
|
}
|
||||||
|
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
|
||||||
}
|
}
|
||||||
// This handler cannot handle 401
|
// This handler cannot handle 401
|
||||||
canHandleAuthentication(response) {
|
canHandleAuthentication() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
handleAuthentication(httpClient, requestInfo, objs) {
|
handleAuthentication() {
|
||||||
return null;
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
throw new Error('not implemented');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
||||||
|
//# sourceMappingURL=auth.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 9925:
|
/***/ 6255:
|
||||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const http = __nccwpck_require__(3685);
|
exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
|
||||||
const https = __nccwpck_require__(5687);
|
const http = __importStar(__nccwpck_require__(3685));
|
||||||
const pm = __nccwpck_require__(6443);
|
const https = __importStar(__nccwpck_require__(5687));
|
||||||
let tunnel;
|
const pm = __importStar(__nccwpck_require__(9835));
|
||||||
|
const tunnel = __importStar(__nccwpck_require__(4294));
|
||||||
var HttpCodes;
|
var HttpCodes;
|
||||||
(function (HttpCodes) {
|
(function (HttpCodes) {
|
||||||
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
||||||
@@ -1754,7 +1878,7 @@ var MediaTypes;
|
|||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||||
*/
|
*/
|
||||||
function getProxyUrl(serverUrl) {
|
function getProxyUrl(serverUrl) {
|
||||||
let proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
||||||
return proxyUrl ? proxyUrl.href : '';
|
return proxyUrl ? proxyUrl.href : '';
|
||||||
}
|
}
|
||||||
exports.getProxyUrl = getProxyUrl;
|
exports.getProxyUrl = getProxyUrl;
|
||||||
@@ -1787,7 +1911,8 @@ class HttpClientResponse {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
readBody() {
|
readBody() {
|
||||||
return new Promise(async (resolve, reject) => {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
||||||
let output = Buffer.alloc(0);
|
let output = Buffer.alloc(0);
|
||||||
this.message.on('data', (chunk) => {
|
this.message.on('data', (chunk) => {
|
||||||
output = Buffer.concat([output, chunk]);
|
output = Buffer.concat([output, chunk]);
|
||||||
@@ -1795,12 +1920,13 @@ class HttpClientResponse {
|
|||||||
this.message.on('end', () => {
|
this.message.on('end', () => {
|
||||||
resolve(output.toString());
|
resolve(output.toString());
|
||||||
});
|
});
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.HttpClientResponse = HttpClientResponse;
|
exports.HttpClientResponse = HttpClientResponse;
|
||||||
function isHttps(requestUrl) {
|
function isHttps(requestUrl) {
|
||||||
let parsedUrl = new URL(requestUrl);
|
const parsedUrl = new URL(requestUrl);
|
||||||
return parsedUrl.protocol === 'https:';
|
return parsedUrl.protocol === 'https:';
|
||||||
}
|
}
|
||||||
exports.isHttps = isHttps;
|
exports.isHttps = isHttps;
|
||||||
@@ -1843,86 +1969,111 @@ class HttpClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
options(requestUrl, additionalHeaders) {
|
options(requestUrl, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
get(requestUrl, additionalHeaders) {
|
get(requestUrl, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
del(requestUrl, additionalHeaders) {
|
del(requestUrl, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
post(requestUrl, data, additionalHeaders) {
|
post(requestUrl, data, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
patch(requestUrl, data, additionalHeaders) {
|
patch(requestUrl, data, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
put(requestUrl, data, additionalHeaders) {
|
put(requestUrl, data, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
head(requestUrl, additionalHeaders) {
|
head(requestUrl, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return this.request(verb, requestUrl, stream, additionalHeaders);
|
return this.request(verb, requestUrl, stream, additionalHeaders);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets a typed object from an endpoint
|
* Gets a typed object from an endpoint
|
||||||
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
||||||
*/
|
*/
|
||||||
async getJson(requestUrl, additionalHeaders = {}) {
|
getJson(requestUrl, additionalHeaders = {}) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
let res = await this.get(requestUrl, additionalHeaders);
|
const res = yield this.get(requestUrl, additionalHeaders);
|
||||||
return this._processResponse(res, this.requestOptions);
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async postJson(requestUrl, obj, additionalHeaders = {}) {
|
postJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
let data = JSON.stringify(obj, null, 2);
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const data = JSON.stringify(obj, null, 2);
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
let res = await this.post(requestUrl, data, additionalHeaders);
|
const res = yield this.post(requestUrl, data, additionalHeaders);
|
||||||
return this._processResponse(res, this.requestOptions);
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async putJson(requestUrl, obj, additionalHeaders = {}) {
|
putJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
let data = JSON.stringify(obj, null, 2);
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const data = JSON.stringify(obj, null, 2);
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
let res = await this.put(requestUrl, data, additionalHeaders);
|
const res = yield this.put(requestUrl, data, additionalHeaders);
|
||||||
return this._processResponse(res, this.requestOptions);
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async patchJson(requestUrl, obj, additionalHeaders = {}) {
|
patchJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
let data = JSON.stringify(obj, null, 2);
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const data = JSON.stringify(obj, null, 2);
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
let res = await this.patch(requestUrl, data, additionalHeaders);
|
const res = yield this.patch(requestUrl, data, additionalHeaders);
|
||||||
return this._processResponse(res, this.requestOptions);
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Makes a raw http request.
|
* Makes a raw http request.
|
||||||
* All other methods such as get, post, patch, and request ultimately call this.
|
* All other methods such as get, post, patch, and request ultimately call this.
|
||||||
* Prefer get, del, post and patch
|
* Prefer get, del, post and patch
|
||||||
*/
|
*/
|
||||||
async request(verb, requestUrl, data, headers) {
|
request(verb, requestUrl, data, headers) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (this._disposed) {
|
if (this._disposed) {
|
||||||
throw new Error('Client has already been disposed.');
|
throw new Error('Client has already been disposed.');
|
||||||
}
|
}
|
||||||
let parsedUrl = new URL(requestUrl);
|
const parsedUrl = new URL(requestUrl);
|
||||||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
let info = this._prepareRequest(verb, parsedUrl, headers);
|
||||||
// Only perform retries on reads since writes may not be idempotent.
|
// Only perform retries on reads since writes may not be idempotent.
|
||||||
let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1
|
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
|
||||||
? this._maxRetries + 1
|
? this._maxRetries + 1
|
||||||
: 1;
|
: 1;
|
||||||
let numTries = 0;
|
let numTries = 0;
|
||||||
let response;
|
let response;
|
||||||
while (numTries < maxTries) {
|
do {
|
||||||
response = await this.requestRaw(info, data);
|
response = yield this.requestRaw(info, data);
|
||||||
// Check if it's an authentication challenge
|
// Check if it's an authentication challenge
|
||||||
if (response &&
|
if (response &&
|
||||||
response.message &&
|
response.message &&
|
||||||
response.message.statusCode === HttpCodes.Unauthorized) {
|
response.message.statusCode === HttpCodes.Unauthorized) {
|
||||||
let authenticationHandler;
|
let authenticationHandler;
|
||||||
for (let i = 0; i < this.handlers.length; i++) {
|
for (const handler of this.handlers) {
|
||||||
if (this.handlers[i].canHandleAuthentication(response)) {
|
if (handler.canHandleAuthentication(response)) {
|
||||||
authenticationHandler = this.handlers[i];
|
authenticationHandler = handler;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1936,7 +2087,8 @@ class HttpClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let redirectsRemaining = this._maxRedirects;
|
let redirectsRemaining = this._maxRedirects;
|
||||||
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&
|
while (response.message.statusCode &&
|
||||||
|
HttpRedirectCodes.includes(response.message.statusCode) &&
|
||||||
this._allowRedirects &&
|
this._allowRedirects &&
|
||||||
redirectsRemaining > 0) {
|
redirectsRemaining > 0) {
|
||||||
const redirectUrl = response.message.headers['location'];
|
const redirectUrl = response.message.headers['location'];
|
||||||
@@ -1944,18 +2096,18 @@ class HttpClient {
|
|||||||
// if there's no location to redirect to, we won't
|
// if there's no location to redirect to, we won't
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let parsedRedirectUrl = new URL(redirectUrl);
|
const parsedRedirectUrl = new URL(redirectUrl);
|
||||||
if (parsedUrl.protocol == 'https:' &&
|
if (parsedUrl.protocol === 'https:' &&
|
||||||
parsedUrl.protocol != parsedRedirectUrl.protocol &&
|
parsedUrl.protocol !== parsedRedirectUrl.protocol &&
|
||||||
!this._allowRedirectDowngrade) {
|
!this._allowRedirectDowngrade) {
|
||||||
throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
|
throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
|
||||||
}
|
}
|
||||||
// we need to finish reading the response before reassigning response
|
// we need to finish reading the response before reassigning response
|
||||||
// which will leak the open socket.
|
// which will leak the open socket.
|
||||||
await response.readBody();
|
yield response.readBody();
|
||||||
// strip authorization header if redirected to a different hostname
|
// strip authorization header if redirected to a different hostname
|
||||||
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
||||||
for (let header in headers) {
|
for (const header in headers) {
|
||||||
// header names are case insensitive
|
// header names are case insensitive
|
||||||
if (header.toLowerCase() === 'authorization') {
|
if (header.toLowerCase() === 'authorization') {
|
||||||
delete headers[header];
|
delete headers[header];
|
||||||
@@ -1964,20 +2116,22 @@ class HttpClient {
|
|||||||
}
|
}
|
||||||
// let's make the request with the new redirectUrl
|
// let's make the request with the new redirectUrl
|
||||||
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
||||||
response = await this.requestRaw(info, data);
|
response = yield this.requestRaw(info, data);
|
||||||
redirectsRemaining--;
|
redirectsRemaining--;
|
||||||
}
|
}
|
||||||
if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) {
|
if (!response.message.statusCode ||
|
||||||
|
!HttpResponseRetryCodes.includes(response.message.statusCode)) {
|
||||||
// If not a retry code, return immediately instead of retrying
|
// If not a retry code, return immediately instead of retrying
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
numTries += 1;
|
numTries += 1;
|
||||||
if (numTries < maxTries) {
|
if (numTries < maxTries) {
|
||||||
await response.readBody();
|
yield response.readBody();
|
||||||
await this._performExponentialBackoff(numTries);
|
yield this._performExponentialBackoff(numTries);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} while (numTries < maxTries);
|
||||||
return response;
|
return response;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Needs to be called if keepAlive is set to true in request options.
|
* Needs to be called if keepAlive is set to true in request options.
|
||||||
@@ -1994,15 +2148,23 @@ class HttpClient {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
requestRaw(info, data) {
|
requestRaw(info, data) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let callbackForResult = function (err, res) {
|
function callbackForResult(err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
|
else if (!res) {
|
||||||
|
// If `err` is not passed, then `res` must be passed.
|
||||||
|
reject(new Error('Unknown error'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
resolve(res);
|
resolve(res);
|
||||||
};
|
}
|
||||||
|
}
|
||||||
this.requestRawWithCallback(info, data, callbackForResult);
|
this.requestRawWithCallback(info, data, callbackForResult);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Raw request with callback.
|
* Raw request with callback.
|
||||||
@@ -2011,21 +2173,24 @@ class HttpClient {
|
|||||||
* @param onResult
|
* @param onResult
|
||||||
*/
|
*/
|
||||||
requestRawWithCallback(info, data, onResult) {
|
requestRawWithCallback(info, data, onResult) {
|
||||||
let socket;
|
|
||||||
if (typeof data === 'string') {
|
if (typeof data === 'string') {
|
||||||
|
if (!info.options.headers) {
|
||||||
|
info.options.headers = {};
|
||||||
|
}
|
||||||
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
||||||
}
|
}
|
||||||
let callbackCalled = false;
|
let callbackCalled = false;
|
||||||
let handleResult = (err, res) => {
|
function handleResult(err, res) {
|
||||||
if (!callbackCalled) {
|
if (!callbackCalled) {
|
||||||
callbackCalled = true;
|
callbackCalled = true;
|
||||||
onResult(err, res);
|
onResult(err, res);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
let req = info.httpModule.request(info.options, (msg) => {
|
const req = info.httpModule.request(info.options, (msg) => {
|
||||||
let res = new HttpClientResponse(msg);
|
const res = new HttpClientResponse(msg);
|
||||||
handleResult(null, res);
|
handleResult(undefined, res);
|
||||||
});
|
});
|
||||||
|
let socket;
|
||||||
req.on('socket', sock => {
|
req.on('socket', sock => {
|
||||||
socket = sock;
|
socket = sock;
|
||||||
});
|
});
|
||||||
@@ -2034,12 +2199,12 @@ class HttpClient {
|
|||||||
if (socket) {
|
if (socket) {
|
||||||
socket.end();
|
socket.end();
|
||||||
}
|
}
|
||||||
handleResult(new Error('Request timeout: ' + info.options.path), null);
|
handleResult(new Error(`Request timeout: ${info.options.path}`));
|
||||||
});
|
});
|
||||||
req.on('error', function (err) {
|
req.on('error', function (err) {
|
||||||
// err has statusCode property
|
// err has statusCode property
|
||||||
// res should have headers
|
// res should have headers
|
||||||
handleResult(err, null);
|
handleResult(err);
|
||||||
});
|
});
|
||||||
if (data && typeof data === 'string') {
|
if (data && typeof data === 'string') {
|
||||||
req.write(data, 'utf8');
|
req.write(data, 'utf8');
|
||||||
@@ -2060,7 +2225,7 @@ class HttpClient {
|
|||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||||
*/
|
*/
|
||||||
getAgent(serverUrl) {
|
getAgent(serverUrl) {
|
||||||
let parsedUrl = new URL(serverUrl);
|
const parsedUrl = new URL(serverUrl);
|
||||||
return this._getAgent(parsedUrl);
|
return this._getAgent(parsedUrl);
|
||||||
}
|
}
|
||||||
_prepareRequest(method, requestUrl, headers) {
|
_prepareRequest(method, requestUrl, headers) {
|
||||||
@@ -2084,21 +2249,19 @@ class HttpClient {
|
|||||||
info.options.agent = this._getAgent(info.parsedUrl);
|
info.options.agent = this._getAgent(info.parsedUrl);
|
||||||
// gives handlers an opportunity to participate
|
// gives handlers an opportunity to participate
|
||||||
if (this.handlers) {
|
if (this.handlers) {
|
||||||
this.handlers.forEach(handler => {
|
for (const handler of this.handlers) {
|
||||||
handler.prepareRequest(info.options);
|
handler.prepareRequest(info.options);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
_mergeHeaders(headers) {
|
_mergeHeaders(headers) {
|
||||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
if (this.requestOptions && this.requestOptions.headers) {
|
||||||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
|
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
|
||||||
}
|
}
|
||||||
return lowercaseKeys(headers || {});
|
return lowercaseKeys(headers || {});
|
||||||
}
|
}
|
||||||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
||||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
|
||||||
let clientHeader;
|
let clientHeader;
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
if (this.requestOptions && this.requestOptions.headers) {
|
||||||
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
||||||
@@ -2107,8 +2270,8 @@ class HttpClient {
|
|||||||
}
|
}
|
||||||
_getAgent(parsedUrl) {
|
_getAgent(parsedUrl) {
|
||||||
let agent;
|
let agent;
|
||||||
let proxyUrl = pm.getProxyUrl(parsedUrl);
|
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
||||||
let useProxy = proxyUrl && proxyUrl.hostname;
|
const useProxy = proxyUrl && proxyUrl.hostname;
|
||||||
if (this._keepAlive && useProxy) {
|
if (this._keepAlive && useProxy) {
|
||||||
agent = this._proxyAgent;
|
agent = this._proxyAgent;
|
||||||
}
|
}
|
||||||
@@ -2116,29 +2279,22 @@ class HttpClient {
|
|||||||
agent = this._agent;
|
agent = this._agent;
|
||||||
}
|
}
|
||||||
// if agent is already assigned use that agent.
|
// if agent is already assigned use that agent.
|
||||||
if (!!agent) {
|
if (agent) {
|
||||||
return agent;
|
return agent;
|
||||||
}
|
}
|
||||||
const usingSsl = parsedUrl.protocol === 'https:';
|
const usingSsl = parsedUrl.protocol === 'https:';
|
||||||
let maxSockets = 100;
|
let maxSockets = 100;
|
||||||
if (!!this.requestOptions) {
|
if (this.requestOptions) {
|
||||||
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
||||||
}
|
}
|
||||||
if (useProxy) {
|
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
|
||||||
// If using proxy, need tunnel
|
if (proxyUrl && proxyUrl.hostname) {
|
||||||
if (!tunnel) {
|
|
||||||
tunnel = __nccwpck_require__(4294);
|
|
||||||
}
|
|
||||||
const agentOptions = {
|
const agentOptions = {
|
||||||
maxSockets: maxSockets,
|
maxSockets,
|
||||||
keepAlive: this._keepAlive,
|
keepAlive: this._keepAlive,
|
||||||
proxy: {
|
proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
|
||||||
...((proxyUrl.username || proxyUrl.password) && {
|
|
||||||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
||||||
}),
|
})), { host: proxyUrl.hostname, port: proxyUrl.port })
|
||||||
host: proxyUrl.hostname,
|
|
||||||
port: proxyUrl.port
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let tunnelAgent;
|
let tunnelAgent;
|
||||||
const overHttps = proxyUrl.protocol === 'https:';
|
const overHttps = proxyUrl.protocol === 'https:';
|
||||||
@@ -2153,7 +2309,7 @@ class HttpClient {
|
|||||||
}
|
}
|
||||||
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
||||||
if (this._keepAlive && !agent) {
|
if (this._keepAlive && !agent) {
|
||||||
const options = { keepAlive: this._keepAlive, maxSockets: maxSockets };
|
const options = { keepAlive: this._keepAlive, maxSockets };
|
||||||
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
||||||
this._agent = agent;
|
this._agent = agent;
|
||||||
}
|
}
|
||||||
@@ -2172,39 +2328,42 @@ class HttpClient {
|
|||||||
return agent;
|
return agent;
|
||||||
}
|
}
|
||||||
_performExponentialBackoff(retryNumber) {
|
_performExponentialBackoff(retryNumber) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
||||||
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
||||||
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
static dateTimeDeserializer(key, value) {
|
_processResponse(res, options) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const statusCode = res.message.statusCode || 0;
|
||||||
|
const response = {
|
||||||
|
statusCode,
|
||||||
|
result: null,
|
||||||
|
headers: {}
|
||||||
|
};
|
||||||
|
// not found leads to null obj returned
|
||||||
|
if (statusCode === HttpCodes.NotFound) {
|
||||||
|
resolve(response);
|
||||||
|
}
|
||||||
|
// get the result from the body
|
||||||
|
function dateTimeDeserializer(key, value) {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
let a = new Date(value);
|
const a = new Date(value);
|
||||||
if (!isNaN(a.valueOf())) {
|
if (!isNaN(a.valueOf())) {
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
async _processResponse(res, options) {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
const statusCode = res.message.statusCode;
|
|
||||||
const response = {
|
|
||||||
statusCode: statusCode,
|
|
||||||
result: null,
|
|
||||||
headers: {}
|
|
||||||
};
|
|
||||||
// not found leads to null obj returned
|
|
||||||
if (statusCode == HttpCodes.NotFound) {
|
|
||||||
resolve(response);
|
|
||||||
}
|
|
||||||
let obj;
|
let obj;
|
||||||
let contents;
|
let contents;
|
||||||
// get the result from the body
|
|
||||||
try {
|
try {
|
||||||
contents = await res.readBody();
|
contents = yield res.readBody();
|
||||||
if (contents && contents.length > 0) {
|
if (contents && contents.length > 0) {
|
||||||
if (options && options.deserializeDates) {
|
if (options && options.deserializeDates) {
|
||||||
obj = JSON.parse(contents, HttpClient.dateTimeDeserializer);
|
obj = JSON.parse(contents, dateTimeDeserializer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
obj = JSON.parse(contents);
|
obj = JSON.parse(contents);
|
||||||
@@ -2228,53 +2387,58 @@ class HttpClient {
|
|||||||
msg = contents;
|
msg = contents;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg = 'Failed request: (' + statusCode + ')';
|
msg = `Failed request: (${statusCode})`;
|
||||||
}
|
}
|
||||||
let err = new HttpClientError(msg, statusCode);
|
const err = new HttpClientError(msg, statusCode);
|
||||||
err.result = response.result;
|
err.result = response.result;
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
}
|
}
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.HttpClient = HttpClient;
|
exports.HttpClient = HttpClient;
|
||||||
|
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 6443:
|
/***/ 9835:
|
||||||
/***/ ((__unused_webpack_module, exports) => {
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.checkBypass = exports.getProxyUrl = void 0;
|
||||||
function getProxyUrl(reqUrl) {
|
function getProxyUrl(reqUrl) {
|
||||||
let usingSsl = reqUrl.protocol === 'https:';
|
const usingSsl = reqUrl.protocol === 'https:';
|
||||||
let proxyUrl;
|
|
||||||
if (checkBypass(reqUrl)) {
|
if (checkBypass(reqUrl)) {
|
||||||
return proxyUrl;
|
return undefined;
|
||||||
}
|
}
|
||||||
let proxyVar;
|
const proxyVar = (() => {
|
||||||
if (usingSsl) {
|
if (usingSsl) {
|
||||||
proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
return process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
||||||
}
|
}
|
||||||
|
})();
|
||||||
if (proxyVar) {
|
if (proxyVar) {
|
||||||
proxyUrl = new URL(proxyVar);
|
return new URL(proxyVar);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
return proxyUrl;
|
|
||||||
}
|
}
|
||||||
exports.getProxyUrl = getProxyUrl;
|
exports.getProxyUrl = getProxyUrl;
|
||||||
function checkBypass(reqUrl) {
|
function checkBypass(reqUrl) {
|
||||||
if (!reqUrl.hostname) {
|
if (!reqUrl.hostname) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
||||||
if (!noProxy) {
|
if (!noProxy) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2290,12 +2454,12 @@ function checkBypass(reqUrl) {
|
|||||||
reqPort = 443;
|
reqPort = 443;
|
||||||
}
|
}
|
||||||
// Format the request hostname and hostname with port
|
// Format the request hostname and hostname with port
|
||||||
let upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
||||||
if (typeof reqPort === 'number') {
|
if (typeof reqPort === 'number') {
|
||||||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
||||||
}
|
}
|
||||||
// Compare request host against noproxy
|
// Compare request host against noproxy
|
||||||
for (let upperNoProxyItem of noProxy
|
for (const upperNoProxyItem of noProxy
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(x => x.trim().toUpperCase())
|
.map(x => x.trim().toUpperCase())
|
||||||
.filter(x => x)) {
|
.filter(x => x)) {
|
||||||
@@ -2306,7 +2470,7 @@ function checkBypass(reqUrl) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
exports.checkBypass = checkBypass;
|
exports.checkBypass = checkBypass;
|
||||||
|
//# sourceMappingURL=proxy.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@@ -5577,6 +5741,8 @@ if (typeof window != 'undefined') {
|
|||||||
|
|
||||||
|
|
||||||
var regExpChars = /[|\\{}()[\]^$+*?.]/g;
|
var regExpChars = /[|\\{}()[\]^$+*?.]/g;
|
||||||
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
|
var hasOwn = function (obj, key) { return hasOwnProperty.apply(obj, [key]); };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escape characters reserved in regular expressions.
|
* Escape characters reserved in regular expressions.
|
||||||
@@ -5668,6 +5834,12 @@ exports.shallowCopy = function (to, from) {
|
|||||||
from = from || {};
|
from = from || {};
|
||||||
if ((to !== null) && (to !== undefined)) {
|
if ((to !== null) && (to !== undefined)) {
|
||||||
for (var p in from) {
|
for (var p in from) {
|
||||||
|
if (!hasOwn(from, p)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (p === '__proto__' || p === 'constructor') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
to[p] = from[p];
|
to[p] = from[p];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5693,6 +5865,12 @@ exports.shallowCopyFromList = function (to, from, list) {
|
|||||||
for (var i = 0; i < list.length; i++) {
|
for (var i = 0; i < list.length; i++) {
|
||||||
var p = list[i];
|
var p = list[i];
|
||||||
if (typeof from[p] != 'undefined') {
|
if (typeof from[p] != 'undefined') {
|
||||||
|
if (!hasOwn(from, p)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (p === '__proto__' || p === 'constructor') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
to[p] = from[p];
|
to[p] = from[p];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6172,7 +6350,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.setHttpClient = exports.getNextPage = void 0;
|
exports.setHttpClient = exports.compactByTopic = exports.compactByLanguage = exports.getNextPage = void 0;
|
||||||
const parse_link_header_1 = __importDefault(__nccwpck_require__(1940));
|
const parse_link_header_1 = __importDefault(__nccwpck_require__(1940));
|
||||||
const client_1 = __nccwpck_require__(7094);
|
const client_1 = __nccwpck_require__(7094);
|
||||||
function getNextPage({ next, last }) {
|
function getNextPage({ next, last }) {
|
||||||
@@ -6211,26 +6389,47 @@ async function* paginateStars(url, opts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function compactByLanguage(data, _transform = transform) {
|
||||||
|
return data.reduce((acc, val) => {
|
||||||
|
const language = val.language || 'miscellaneous';
|
||||||
|
acc[language] ||= [];
|
||||||
|
const parsed = typeof _transform !== 'function' ? val : _transform(val);
|
||||||
|
acc[language].push(parsed);
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
exports.compactByLanguage = compactByLanguage;
|
||||||
|
function compactByTopic(data, _transform = transform) {
|
||||||
|
return data.reduce((acc, val) => {
|
||||||
|
if (!Array.isArray(val.topics))
|
||||||
|
return acc;
|
||||||
|
const topics = val.topics.length === 0 ? ['miscellaneous'] : val.topics;
|
||||||
|
for (const topic of topics) {
|
||||||
|
if (!Array.isArray(acc[topic]))
|
||||||
|
acc[topic] = [];
|
||||||
|
const parsed = typeof _transform !== 'function' ? val : _transform(val);
|
||||||
|
acc[topic].push(parsed);
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
exports.compactByTopic = compactByTopic;
|
||||||
async function apiGetStar(opts) {
|
async function apiGetStar(opts) {
|
||||||
const data = [];
|
const data = [];
|
||||||
const API_STARRED_URL = `users/${opts.username}/starred`;
|
const API_STARRED_URL = `users/${opts.username}/starred`;
|
||||||
for await (const star of paginateStars(API_STARRED_URL, opts)) {
|
for await (const star of paginateStars(API_STARRED_URL, opts)) {
|
||||||
data.push(star);
|
data.push(star);
|
||||||
}
|
}
|
||||||
if (!opts.compactByLanguage) {
|
if (opts.compactByLanguage) {
|
||||||
|
return compactByLanguage(data, opts.transform);
|
||||||
|
}
|
||||||
|
if (opts.compactByTopic) {
|
||||||
|
return compactByTopic(data, opts.transform);
|
||||||
|
}
|
||||||
if (typeof opts.transform !== 'function')
|
if (typeof opts.transform !== 'function')
|
||||||
return data;
|
return data;
|
||||||
return data.map((star) => opts.transform(star));
|
return data.map((star) => opts.transform(star));
|
||||||
}
|
}
|
||||||
const sorted = data.reduce((acc, val) => {
|
|
||||||
const language = val.language || 'miscellaneous';
|
|
||||||
acc[language] ||= [];
|
|
||||||
const parsed = typeof opts.transform !== 'function' ? val : opts.transform(val);
|
|
||||||
acc[language].push(parsed);
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
return sorted;
|
|
||||||
}
|
|
||||||
function transform(star) {
|
function transform(star) {
|
||||||
return {
|
return {
|
||||||
id: star.id,
|
id: star.id,
|
||||||
@@ -6264,6 +6463,7 @@ const DEFAULT_OPTIONS = {
|
|||||||
accessToken: process.env.GITHUB_TOKEN,
|
accessToken: process.env.GITHUB_TOKEN,
|
||||||
username: process.env.GITHUB_USERNAME,
|
username: process.env.GITHUB_USERNAME,
|
||||||
compactByLanguage: false,
|
compactByLanguage: false,
|
||||||
|
compactByTopic: false,
|
||||||
transform,
|
transform,
|
||||||
};
|
};
|
||||||
function setHttpClient(opts) {
|
function setHttpClient(opts) {
|
||||||
@@ -12954,7 +13154,7 @@ exports.run = exports.main = void 0;
|
|||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const promises_1 = __nccwpck_require__(3292);
|
const promises_1 = __nccwpck_require__(3292);
|
||||||
const gh_star_fetch_1 = __importDefault(__nccwpck_require__(6636));
|
const gh_star_fetch_1 = __importStar(__nccwpck_require__(6636));
|
||||||
const helpers_1 = __nccwpck_require__(3015);
|
const helpers_1 = __nccwpck_require__(3015);
|
||||||
const git_1 = __importDefault(__nccwpck_require__(6350));
|
const git_1 = __importDefault(__nccwpck_require__(6350));
|
||||||
function main() {
|
function main() {
|
||||||
@@ -12970,26 +13170,37 @@ function main() {
|
|||||||
catch (_a) {
|
catch (_a) {
|
||||||
core.info("Couldn't find template file, using default");
|
core.info("Couldn't find template file, using default");
|
||||||
}
|
}
|
||||||
const sortedByLanguages = yield (0, gh_star_fetch_1.default)({
|
const opts = {
|
||||||
accessToken: core.getInput('api-token', { required: true }),
|
accessToken: core.getInput('api-token', { required: true }),
|
||||||
compactByLanguage: true,
|
};
|
||||||
});
|
const results = yield (0, gh_star_fetch_1.default)(opts);
|
||||||
const rendered = yield (0, helpers_1.renderer)({
|
const files = [];
|
||||||
|
const compactedByLanguage = (0, gh_star_fetch_1.compactByLanguage)(results);
|
||||||
|
const byLanguage = yield (0, helpers_1.renderer)({
|
||||||
username: helpers_1.REPO_USERNAME,
|
username: helpers_1.REPO_USERNAME,
|
||||||
stars: Object.entries(sortedByLanguages),
|
stars: Object.entries(compactedByLanguage),
|
||||||
updatedAt: Date.now(),
|
updatedAt: Date.now(),
|
||||||
}, template);
|
}, template);
|
||||||
const markdown = yield (0, helpers_1.generateMd)(rendered);
|
files.push({
|
||||||
yield git_1.default.pushNewFiles([
|
|
||||||
{
|
|
||||||
filename: helpers_1.MARKDOWN_FILENAME,
|
filename: helpers_1.MARKDOWN_FILENAME,
|
||||||
data: markdown,
|
data: yield (0, helpers_1.generateMd)(byLanguage),
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
filename: 'data.json',
|
filename: 'data.json',
|
||||||
data: JSON.stringify(sortedByLanguages, null, 2),
|
data: JSON.stringify(compactedByLanguage, null, 2),
|
||||||
},
|
});
|
||||||
]);
|
if (core.getInput('compact-by-topic') === 'true') {
|
||||||
|
const compactedByTopic = (0, gh_star_fetch_1.compactByTopic)(results);
|
||||||
|
const byTopic = yield (0, helpers_1.renderer)({
|
||||||
|
username: helpers_1.REPO_USERNAME,
|
||||||
|
stars: Object.entries(compactedByTopic),
|
||||||
|
updatedAt: Date.now(),
|
||||||
|
}, template);
|
||||||
|
files.push({
|
||||||
|
filename: 'TOPICS.md',
|
||||||
|
data: yield (0, helpers_1.generateMd)(byTopic),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
yield git_1.default.pushNewFiles(files);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.main = main;
|
exports.main = main;
|
||||||
@@ -28490,7 +28701,7 @@ function ok() {
|
|||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports = {"i8":"3.1.7"};
|
module.exports = {"i8":"3.1.8"};
|
||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
|
|
||||||
|
2612
package-lock.json
generated
2612
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
36
package.json
36
package.json
@@ -22,41 +22,41 @@
|
|||||||
"javascript"
|
"javascript"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^16.2.4",
|
"@commitlint/cli": "^17.0.3",
|
||||||
"@commitlint/config-conventional": "^16.2.4",
|
"@commitlint/config-conventional": "^17.0.3",
|
||||||
"@octokit/rest": "^18.12.0",
|
"@octokit/rest": "^18.12.0",
|
||||||
"@octokit/types": "^6.2.1",
|
"@octokit/types": "^6.39.0",
|
||||||
"@saithodev/semantic-release-backmerge": "^2.1.2",
|
"@saithodev/semantic-release-backmerge": "^2.1.2",
|
||||||
"@semantic-release/changelog": "^6.0.1",
|
"@semantic-release/changelog": "^6.0.1",
|
||||||
"@semantic-release/commit-analyzer": "^9.0.2",
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
||||||
"@semantic-release/git": "^10.0.1",
|
"@semantic-release/git": "^10.0.1",
|
||||||
"@semantic-release/github": "^8.0.4",
|
"@semantic-release/github": "^8.0.4",
|
||||||
"@semantic-release/release-notes-generator": "^10.0.3",
|
"@semantic-release/release-notes-generator": "^10.0.3",
|
||||||
"@types/ejs": "^3.1.0",
|
"@types/ejs": "^3.1.1",
|
||||||
"@types/got": "^9.6.12",
|
"@types/got": "^9.6.12",
|
||||||
"@types/node": "^17.0.32",
|
"@types/node": "^18.0.3",
|
||||||
"@types/sinon": "^10.0.11",
|
"@types/sinon": "^10.0.12",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.23.0",
|
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
||||||
"@typescript-eslint/parser": "^5.23.0",
|
"@typescript-eslint/parser": "^5.30.5",
|
||||||
"@vercel/ncc": "^0.33.4",
|
"@vercel/ncc": "^0.34.0",
|
||||||
"eslint": "^8.15.0",
|
"eslint": "^8.19.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"husky": "^8.0.1",
|
"husky": "^8.0.1",
|
||||||
"lint-staged": "^12.4.1",
|
"lint-staged": "^13.0.3",
|
||||||
"markdown-toc": "^1.2.0",
|
"markdown-toc": "^1.2.0",
|
||||||
"nyc": "^15.0.1",
|
"nyc": "^15.0.1",
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.7.1",
|
||||||
"sinon": "^14.0.0",
|
"sinon": "^14.0.0",
|
||||||
"ts-node-dev": "^1.1.8",
|
"ts-node-dev": "^2.0.0",
|
||||||
"typescript": "^4.6.4"
|
"typescript": "^4.7.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.8.0",
|
"@actions/core": "^1.9.0",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"ejs": "^3.1.7",
|
"ejs": "^3.1.8",
|
||||||
"gh-star-fetch": "^1.3.0",
|
"gh-star-fetch": "^1.5.0",
|
||||||
"got": "^11.8.1",
|
"got": "^11.8.1",
|
||||||
"remark": "^14.0.2",
|
"remark": "^14.0.2",
|
||||||
"remark-toc": "^8.0.1"
|
"remark-toc": "^8.0.1"
|
||||||
|
48
src/index.ts
48
src/index.ts
@@ -1,7 +1,11 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import { readFile } from 'fs/promises';
|
import { readFile } from 'fs/promises';
|
||||||
import ghStarFetch from 'gh-star-fetch';
|
import ghStarFetch, {
|
||||||
|
Options,
|
||||||
|
compactByLanguage,
|
||||||
|
compactByTopic,
|
||||||
|
} from 'gh-star-fetch';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
renderer,
|
renderer,
|
||||||
@@ -27,32 +31,52 @@ export async function main() {
|
|||||||
core.info("Couldn't find template file, using default");
|
core.info("Couldn't find template file, using default");
|
||||||
}
|
}
|
||||||
|
|
||||||
const sortedByLanguages = await ghStarFetch({
|
const opts: Partial<Options> = {
|
||||||
accessToken: core.getInput('api-token', { required: true }),
|
accessToken: core.getInput('api-token', { required: true }),
|
||||||
compactByLanguage: true,
|
};
|
||||||
});
|
|
||||||
|
|
||||||
const rendered = await renderer(
|
const results = await ghStarFetch(opts);
|
||||||
|
|
||||||
|
const files = [];
|
||||||
|
|
||||||
|
const compactedByLanguage = compactByLanguage(results);
|
||||||
|
const byLanguage = await renderer(
|
||||||
{
|
{
|
||||||
username: REPO_USERNAME,
|
username: REPO_USERNAME,
|
||||||
stars: Object.entries(sortedByLanguages),
|
stars: Object.entries(compactedByLanguage),
|
||||||
updatedAt: Date.now(),
|
updatedAt: Date.now(),
|
||||||
},
|
},
|
||||||
template
|
template
|
||||||
);
|
);
|
||||||
|
|
||||||
const markdown: string = await generateMd(rendered);
|
files.push(
|
||||||
|
|
||||||
await git.pushNewFiles([
|
|
||||||
{
|
{
|
||||||
filename: MARKDOWN_FILENAME,
|
filename: MARKDOWN_FILENAME,
|
||||||
data: markdown,
|
data: await generateMd(byLanguage),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename: 'data.json',
|
filename: 'data.json',
|
||||||
data: JSON.stringify(sortedByLanguages, null, 2),
|
data: JSON.stringify(compactedByLanguage, null, 2),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (core.getInput('compact-by-topic') === 'true') {
|
||||||
|
const compactedByTopic = compactByTopic(results);
|
||||||
|
const byTopic = await renderer(
|
||||||
|
{
|
||||||
|
username: REPO_USERNAME,
|
||||||
|
stars: Object.entries(compactedByTopic),
|
||||||
|
updatedAt: Date.now(),
|
||||||
},
|
},
|
||||||
]);
|
template
|
||||||
|
);
|
||||||
|
files.push({
|
||||||
|
filename: 'TOPICS.md',
|
||||||
|
data: await generateMd(byTopic),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await git.pushNewFiles(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
|
Reference in New Issue
Block a user