@jamesives/github-sponsors-readme-action
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -26,3 +26,4 @@ import {setFailed} from '@actions/core' | ||
login: 'JamesIves', | ||
url: 'https://github.com/JamesIves' | ||
url: 'https://github.com/JamesIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -39,3 +40,4 @@ }, | ||
login: 'MontezumaIves', | ||
url: 'https://github.com/MontezumaIves' | ||
url: 'https://github.com/MontezumaIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -42,0 +44,0 @@ } |
@@ -35,3 +35,4 @@ import {GitHubResponse, PrivacyLevel, Status, Urls} from '../src/constants' | ||
login: 'JamesIves', | ||
url: 'https://github.com/JamesIves' | ||
url: 'https://github.com/JamesIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -48,3 +49,4 @@ }, | ||
login: 'MontezumaIves', | ||
url: 'https://github.com/MontezumaIves' | ||
url: 'https://github.com/MontezumaIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -62,3 +64,3 @@ } | ||
template: | ||
'<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="60px" alt="" /></a>', | ||
'<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="60px" alt="" /><span>{{{ websiteUrl}}}</span></a>', | ||
minimum: 0, | ||
@@ -72,3 +74,3 @@ maximum: 0, | ||
expect(generateTemplate(response, action)).toEqual( | ||
'<a href="https://github.com/JamesIves"><img src="https://github.com/JamesIves.png" width="60px" alt="" /></a><a href="https://github.com/MontezumaIves"><img src="https://github.com/MontezumaIves.png" width="60px" alt="" /></a>' | ||
'<a href="https://github.com/JamesIves"><img src="https://github.com/JamesIves.png" width="60px" alt="" /><span>https://jamesiv.es</span></a><a href="https://github.com/MontezumaIves"><img src="https://github.com/MontezumaIves.png" width="60px" alt="" /><span>https://jamesiv.es</span></a>' | ||
) | ||
@@ -96,3 +98,4 @@ }) | ||
login: 'JamesIves', | ||
url: 'https://github.com/JamesIves' | ||
url: 'https://github.com/JamesIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -109,3 +112,4 @@ }, | ||
login: 'MontezumaIves', | ||
url: 'https://github.com/MontezumaIves' | ||
url: 'https://github.com/MontezumaIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -155,3 +159,4 @@ } | ||
login: 'JamesIves', | ||
url: 'https://github.com/JamesIves' | ||
url: 'https://github.com/JamesIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -168,3 +173,4 @@ }, | ||
login: 'MontezumaIves', | ||
url: 'https://github.com/MontezumaIves' | ||
url: 'https://github.com/MontezumaIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -214,3 +220,4 @@ } | ||
login: 'JamesIves', | ||
url: 'https://github.com/JamesIves' | ||
url: 'https://github.com/JamesIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -227,3 +234,4 @@ }, | ||
login: 'MontezumaIves', | ||
url: 'https://github.com/MontezumaIves' | ||
url: 'https://github.com/MontezumaIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -273,3 +281,4 @@ } | ||
login: 'JamesIves', | ||
url: 'https://github.com/JamesIves' | ||
url: 'https://github.com/JamesIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -286,3 +295,4 @@ }, | ||
login: 'MontezumaIves', | ||
url: 'https://github.com/MontezumaIves' | ||
url: 'https://github.com/MontezumaIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -332,3 +342,4 @@ } | ||
login: 'JamesIves', | ||
url: 'https://github.com/JamesIves' | ||
url: 'https://github.com/JamesIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -345,3 +356,4 @@ }, | ||
login: 'MontezumaIves', | ||
url: 'https://github.com/MontezumaIves' | ||
url: 'https://github.com/MontezumaIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -391,3 +403,4 @@ } | ||
login: 'JamesIves', | ||
url: 'https://github.com/JamesIves' | ||
url: 'https://github.com/JamesIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -404,3 +417,4 @@ }, | ||
login: 'MontezumaIves', | ||
url: 'https://github.com/MontezumaIves' | ||
url: 'https://github.com/MontezumaIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -454,3 +468,4 @@ } | ||
login: 'JamesIves', | ||
url: 'https://github.com/JamesIves' | ||
url: 'https://github.com/JamesIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -467,3 +482,4 @@ }, | ||
login: 'MontezumaIves', | ||
url: 'https://github.com/MontezumaIves' | ||
url: 'https://github.com/MontezumaIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -521,3 +537,4 @@ } | ||
login: 'JamesIves', | ||
url: 'https://github.com/JamesIves' | ||
url: 'https://github.com/JamesIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -534,3 +551,4 @@ }, | ||
login: 'MontezumaIves', | ||
url: 'https://github.com/MontezumaIves' | ||
url: 'https://github.com/MontezumaIves', | ||
websiteUrl: 'https://jamesiv.es' | ||
} | ||
@@ -611,3 +629,3 @@ } | ||
it('should appropriate handle an error', async () => { | ||
it('should appropriately handle an error', async () => { | ||
;(info as jest.Mock).mockImplementationOnce(() => { | ||
@@ -614,0 +632,0 @@ throw new Error('Mocked throw') |
@@ -35,2 +35,3 @@ export interface ActionInterface { | ||
url: string; | ||
websiteUrl: string | null; | ||
}; | ||
@@ -52,5 +53,8 @@ createdAt: string; | ||
data: { | ||
viewer: { | ||
organization?: { | ||
sponsorshipsAsMaintainer: SponsorshipsAsMaintainer; | ||
}; | ||
viewer?: { | ||
sponsorshipsAsMaintainer: SponsorshipsAsMaintainer; | ||
}; | ||
}; | ||
@@ -57,0 +61,0 @@ } |
@@ -50,3 +50,3 @@ "use strict"; | ||
: status === constants_1.Status.SUCCESS | ||
? 'The data was succesfully retrieved and saved! β π' | ||
? 'The data was successfully retrieved and saved! β π' | ||
: `Unable to locate markers in your file. Please check the documentation and try again. β οΈ`}`); | ||
@@ -53,0 +53,0 @@ (0, core_1.setOutput)('sponsorship-status', status); |
import 'cross-fetch/polyfill'; | ||
import { ActionInterface, GitHubResponse, Status } from './constants'; | ||
/** Fetches */ | ||
/** | ||
* Fetches sponsors from the GitHub Sponsors API. | ||
*/ | ||
export declare function getSponsors(action: ActionInterface): Promise<GitHubResponse>; | ||
/** | ||
* Generates the sponsorship template. | ||
*/ | ||
export declare function generateTemplate(response: GitHubResponse, action: ActionInterface): string; | ||
export declare function generateFile(response: GitHubResponse, action: ActionInterface): Promise<Status>; |
@@ -19,3 +19,5 @@ "use strict"; | ||
const core_1 = require("@actions/core"); | ||
/** Fetches */ | ||
/** | ||
* Fetches sponsors from the GitHub Sponsors API. | ||
*/ | ||
function getSponsors(action) { | ||
@@ -26,3 +28,5 @@ return __awaiter(this, void 0, void 0, function* () { | ||
const query = `query { | ||
viewer { | ||
${action.organization | ||
? `organization (login: "${process.env.GITHUB_REPOSITORY_OWNER}")` | ||
: `viewer`} { | ||
login | ||
@@ -36,4 +40,2 @@ sponsorshipsAsMaintainer(first: 100, orderBy: {field: CREATED_AT, direction: ASC}, includePrivate: true) { | ||
sponsorEntity { | ||
${action.organization | ||
? ` | ||
... on Organization { | ||
@@ -43,5 +45,4 @@ name | ||
url | ||
}` | ||
: ``} | ||
websiteUrl | ||
} | ||
... on User { | ||
@@ -51,2 +52,3 @@ name | ||
url | ||
websiteUrl | ||
} | ||
@@ -82,20 +84,31 @@ } | ||
exports.getSponsors = getSponsors; | ||
/** | ||
* Generates the sponsorship template. | ||
*/ | ||
function generateTemplate(response, action) { | ||
let template = ``; | ||
(0, core_1.info)('Generating templateβ¦ β¨'); | ||
const { sponsorshipsAsMaintainer } = response.data.viewer; | ||
/* Appends the template, the API call returns all users regardless of if they are hidden or not. | ||
In an effort to respect a users decisison to be anoymous we filter these users out. */ | ||
let filteredSponsors = sponsorshipsAsMaintainer.nodes.filter((user) => user.privacyLevel !== constants_1.PrivacyLevel.PRIVATE && | ||
user.tier.monthlyPriceInCents >= action.minimum); | ||
if (action.maximum > 0) { | ||
filteredSponsors = filteredSponsors.filter((user) => user.tier.monthlyPriceInCents <= action.maximum); | ||
const data = action.organization | ||
? response.data.organization | ||
: response.data.viewer; | ||
const sponsorshipsAsMaintainer = data === null || data === void 0 ? void 0 : data.sponsorshipsAsMaintainer; | ||
if (sponsorshipsAsMaintainer) { | ||
/* Appends the template, the API call returns all users regardless of if they are hidden or not. | ||
In an effort to respect a users decision to be anonymous we filter these users out. */ | ||
let filteredSponsors = sponsorshipsAsMaintainer.nodes.filter((user) => user.privacyLevel !== constants_1.PrivacyLevel.PRIVATE && | ||
user.tier.monthlyPriceInCents >= action.minimum); | ||
if (action.maximum > 0) { | ||
filteredSponsors = filteredSponsors.filter((user) => user.tier.monthlyPriceInCents <= action.maximum); | ||
} | ||
/** If there are no valid sponsors then we return the provided fallback. */ | ||
if (!filteredSponsors.length) { | ||
return action.fallback; | ||
} | ||
filteredSponsors.map(({ sponsorEntity }) => { | ||
template = template += (0, mustache_1.render)(action.template, sponsorEntity); | ||
}); | ||
} | ||
/** If there are no valid sponsors then we return the provided fallback. */ | ||
if (!filteredSponsors.length) { | ||
return action.fallback; | ||
else { | ||
(0, core_1.info)(`No sponsorship data was foundβ¦ β`); | ||
} | ||
filteredSponsors.map(({ sponsorEntity }) => { | ||
template = template += (0, mustache_1.render)(action.template, sponsorEntity); | ||
}); | ||
return template; | ||
@@ -102,0 +115,0 @@ } |
import { ActionInterface } from './constants'; | ||
/** | ||
* Utility function that checks to see if a value is undefined or not. | ||
*/ | ||
export declare const isNullOrUndefined: (value: string | undefined | null) => boolean; | ||
/** | ||
* Verifies the action has the required parameters to run, otherwise throw an error. | ||
*/ | ||
export declare const checkParameters: (action: ActionInterface) => void; | ||
/** | ||
* Suppresses sensitive information from being exposed in error messages. | ||
*/ | ||
export declare const suppressSensitiveInformation: (str: string, action: ActionInterface) => string; | ||
/** | ||
* Extracts error message from an error. | ||
*/ | ||
export declare const extractErrorMessage: (error: unknown) => string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractErrorMessage = exports.suppressSensitiveInformation = exports.checkParameters = exports.isNullOrUndefined = void 0; | ||
/* Utility function that checks to see if a value is undefined or not. */ | ||
/** | ||
* Utility function that checks to see if a value is undefined or not. | ||
*/ | ||
const isNullOrUndefined = (value) => typeof value === 'undefined' || value === null || value === ''; | ||
exports.isNullOrUndefined = isNullOrUndefined; | ||
/* Checks for the required tokens and formatting. Throws an error if any case is matched. */ | ||
/** | ||
* Checks for the required tokens and formatting. Throws an error if any case is matched. | ||
*/ | ||
const hasRequiredParameters = (action, params) => { | ||
@@ -12,3 +16,5 @@ const nonNullParams = params.filter(param => !(0, exports.isNullOrUndefined)(action[param])); | ||
}; | ||
/* Verifies the action has the required parameters to run, otherwise throw an error. */ | ||
/** | ||
* Verifies the action has the required parameters to run, otherwise throw an error. | ||
*/ | ||
const checkParameters = (action) => { | ||
@@ -20,5 +26,9 @@ if (!hasRequiredParameters(action, ['token'])) { | ||
exports.checkParameters = checkParameters; | ||
/* Replaces all instances of a match in a string. */ | ||
/** | ||
* Replaces all instances of a match in a string. | ||
*/ | ||
const replaceAll = (input, find, replace) => input.split(find).join(replace); | ||
/* Suppresses sensitive information from being exposed in error messages. */ | ||
/** | ||
* Suppresses sensitive information from being exposed in error messages. | ||
*/ | ||
const suppressSensitiveInformation = (str, action) => { | ||
@@ -33,2 +43,5 @@ let value = str; | ||
exports.suppressSensitiveInformation = suppressSensitiveInformation; | ||
/** | ||
* Extracts error message from an error. | ||
*/ | ||
const extractErrorMessage = (error) => error instanceof Error | ||
@@ -35,0 +48,0 @@ ? error.message |
@@ -5,3 +5,3 @@ { | ||
"author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
@@ -37,3 +37,3 @@ "main": "lib/lib.js", | ||
"dependencies": { | ||
"@actions/core": "1.6.0", | ||
"@actions/core": "1.9.1", | ||
"@actions/io": "1.1.2", | ||
@@ -46,7 +46,7 @@ "cross-fetch": "3.1.5", | ||
"@types/jest": "27.4.1", | ||
"@types/mustache": "4.1.2", | ||
"@types/node": "18.0.0", | ||
"@types/mustache": "4.2.1", | ||
"@types/node": "18.7.6", | ||
"@typescript-eslint/eslint-plugin": "5.29.0", | ||
"@typescript-eslint/parser": "5.20.0", | ||
"eslint": "8.14.0", | ||
"eslint": "8.22.0", | ||
"eslint-config-prettier": "8.5.0", | ||
@@ -57,7 +57,7 @@ "eslint-plugin-jest": "26.5.3", | ||
"jest-circus": "27.5.1", | ||
"nock": "13.2.4", | ||
"nock": "13.2.9", | ||
"prettier": "2.7.1", | ||
"ts-jest": "27.1.4", | ||
"typescript": "4.6.4" | ||
"typescript": "4.7.4" | ||
} | ||
} |
@@ -33,11 +33,11 @@ <p align="center"> | ||
<p align="center"> | ||
Maintainence of this project is made possible by all the <a href="https://github.com/JamesIves/github-pages-deploy-action/graphs/contributors">contributors</a> and <a href="https://github.com/sponsors/JamesIves">sponsors</a>. If you'd like to sponsor this project and have your avatar or company logo appear below <a href="https://github.com/sponsors/JamesIves">click here</a>. π | ||
Maintenance of this project is made possible by all the <a href="https://github.com/JamesIves/github-pages-deploy-action/graphs/contributors">contributors</a> and <a href="https://github.com/sponsors/JamesIves">sponsors</a>. If you'd like to sponsor this project and have your avatar or company logo appear below <a href="https://github.com/sponsors/JamesIves">click here</a>. π | ||
</p> | ||
<p align="center"> | ||
<!-- real-premium --><a href="https://github.com/github"><img src="https://github.com/github.png" width="80px" alt="github" /></a> <!-- real-premium --> | ||
<!-- real-premium --><!-- real-premium --> | ||
</p> | ||
<p align="center"> | ||
<!-- real-sponsors --><a href="https://github.com/Chooksta69"><img src="https://github.com/Chooksta69.png" width="50px" alt="Chooksta69" /></a> <a href="https://github.com/robjtede"><img src="https://github.com/robjtede.png" width="50px" alt="robjtede" /></a> <a href="https://github.com/hadley"><img src="https://github.com/hadley.png" width="50px" alt="hadley" /></a> <a href="https://github.com/kevinchalet"><img src="https://github.com/kevinchalet.png" width="50px" alt="kevinchalet" /></a> <a href="https://github.com/Yousazoe"><img src="https://github.com/Yousazoe.png" width="50px" alt="Yousazoe" /></a> <!-- real-sponsors --> | ||
<!-- real-sponsors --><a href="https://github.com/Chooksta69"><img src="https://github.com/Chooksta69.png" width="50px" alt="Chooksta69" /></a> <a href="https://github.com/robjtede"><img src="https://github.com/robjtede.png" width="50px" alt="robjtede" /></a> <a href="https://github.com/hadley"><img src="https://github.com/hadley.png" width="50px" alt="hadley" /></a> <a href="https://github.com/kevinchalet"><img src="https://github.com/kevinchalet.png" width="50px" alt="kevinchalet" /></a> <a href="https://github.com/annegentle"><img src="https://github.com/annegentle.png" width="50px" alt="annegentle" /></a> <!-- real-sponsors --> | ||
</p> | ||
@@ -119,6 +119,6 @@ | ||
| Key | Value Information | Type | Required | | ||
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- | | ||
| `token` | You must provide the action with a Personal Access Token (PAT) with either the `user:read` or `org:read` permission scope and store it in the `secrets / with` menu **as a secret**. This should be generated from the account or organization that recieves sponsorship. [Learn more about creating and using encrypted secrets here](https://docs.github.com/en/actions/reference/encrypted-secrets). | `with` | **Yes** | | ||
| `file` | This should point to the file that you're generating, for example `README.md` or `path/to/CREDITS.md`. Defaults to `README.md` if no value is provided. | `with` | **Yes** | | ||
| Key | Value Information | Type | Required | | ||
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- | | ||
| `token` | You must provide the action with a Personal Access Token (PAT) with either the `user:read` or `org:read` permission scope and store it in the `secrets / with` menu **as a secret**. This should be generated from the account or organization that receives sponsorship, and depending on your use case you may need to provide additional scopes. [Learn more about creating and using encrypted secrets here](https://docs.github.com/en/actions/reference/encrypted-secrets). | `with` | **Yes** | | ||
| `file` | This should point to the file that you're generating, for example `README.md` or `path/to/CREDITS.md`. Defaults to `README.md` if no value is provided. | `with` | **Yes** | | ||
@@ -129,3 +129,3 @@ #### Optional Choices | ||
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- | | ||
| `organization` | If you're displaying sponsorship information as or for an organization you should toggle this option to `true`. You also need to provide the action with an `org:read` scoped PAT. | `with` | **No** | | ||
| `organization` | If you're displaying sponsorship information as or for an organization you should toggle this option to `true`. You also need to provide the action with an `org:read` and `user:read` scoped PAT. | `with` | **No** | | ||
| `minimum` | Using this input you can set the minimum sponsorship threshold. For example setting this to `500` will only display sponsors who give of `$5 USD` and more. By default the action will display all of your sponsors. | `with` | **No** | | ||
@@ -154,7 +154,8 @@ | `maximum` | Using this input you can set the maximum sponsorship threshold. For example setting this to `500` will only display sponsors who give of `$5 USD` and less. By default the action will display all of your sponsors. | `with` | **No** | | ||
| Status | Description | | ||
| ------- | ----------------------------------------------------------------------------------------------------------------------- | | ||
| `name` | The users full name. This can sometimes be `null` if the user hasn't set one. This can be accessed using `{{{ name }}}` | | ||
| `login` | The users login, this can be accessed using `{{{ login }}}` | | ||
| `url` | The users GitHub profile url, this can be accessed using `{{{ url }}}`. | | ||
| Status | Description | | ||
| ------------ | -------------------------------------------------------------------------------------------------------------------------------- | | ||
| `name` | The users full name. This can sometimes be `null` if the user hasn't set one. This can be accessed using `{{{ name }}}` | | ||
| `login` | The users login, this can be accessed using `{{{ login }}}` | | ||
| `url` | The users GitHub profile url, this can be accessed using `{{{ url }}}`. | | ||
| `websiteUrl` | The users website url. This can sometimes be `null` if the user hasn't set one. this can be accessed using `{{{ websiteUrl }}}`. | | ||
@@ -210,3 +211,3 @@ You're able to use markdown or GitHub approved basic HTML. The default template can be found [here](./src/constants.ts#L28). | ||
### Seperating by Sponsorship Tier β¨ | ||
### Separating by Sponsorship Tier β¨ | ||
@@ -213,0 +214,0 @@ If you'd like to highlight certain users who contribute to a specific sponsorship tier you can do so using a combination of the `minimum`, `maximum` and `marker` inputs. The `minimum / maximum` inputs equal their dollar contribution in cents. |
@@ -53,2 +53,3 @@ import {getInput} from '@actions/core' | ||
url: string | ||
websiteUrl: string | null | ||
} | ||
@@ -72,5 +73,8 @@ createdAt: string | ||
data: { | ||
viewer: { | ||
organization?: { | ||
sponsorshipsAsMaintainer: SponsorshipsAsMaintainer | ||
} | ||
viewer?: { | ||
sponsorshipsAsMaintainer: SponsorshipsAsMaintainer | ||
} | ||
} | ||
@@ -77,0 +81,0 @@ } |
@@ -44,3 +44,3 @@ import {info, setFailed, setOutput} from '@actions/core' | ||
: status === Status.SUCCESS | ||
? 'The data was succesfully retrieved and saved! β π' | ||
? 'The data was successfully retrieved and saved! β π' | ||
: `Unable to locate markers in your file. Please check the documentation and try again. β οΈ` | ||
@@ -47,0 +47,0 @@ }` |
@@ -8,3 +8,2 @@ import 'cross-fetch/polyfill' | ||
Sponsor, | ||
SponsorshipsAsMaintainer, | ||
Status, | ||
@@ -17,3 +16,5 @@ Urls | ||
/** Fetches */ | ||
/** | ||
* Fetches sponsors from the GitHub Sponsors API. | ||
*/ | ||
export async function getSponsors( | ||
@@ -30,3 +31,7 @@ action: ActionInterface | ||
const query = `query { | ||
viewer { | ||
${ | ||
action.organization | ||
? `organization (login: "${process.env.GITHUB_REPOSITORY_OWNER}")` | ||
: `viewer` | ||
} { | ||
login | ||
@@ -40,5 +45,2 @@ sponsorshipsAsMaintainer(first: 100, orderBy: {field: CREATED_AT, direction: ASC}, includePrivate: true) { | ||
sponsorEntity { | ||
${ | ||
action.organization | ||
? ` | ||
... on Organization { | ||
@@ -48,6 +50,4 @@ name | ||
url | ||
}` | ||
: `` | ||
websiteUrl | ||
} | ||
... on User { | ||
@@ -57,2 +57,3 @@ name | ||
url | ||
websiteUrl | ||
} | ||
@@ -93,2 +94,5 @@ } | ||
/** | ||
* Generates the sponsorship template. | ||
*/ | ||
export function generateTemplate( | ||
@@ -102,29 +106,35 @@ response: GitHubResponse, | ||
const { | ||
sponsorshipsAsMaintainer | ||
}: {sponsorshipsAsMaintainer: SponsorshipsAsMaintainer} = response.data.viewer | ||
const data = action.organization | ||
? response.data.organization | ||
: response.data.viewer | ||
/* Appends the template, the API call returns all users regardless of if they are hidden or not. | ||
In an effort to respect a users decisison to be anoymous we filter these users out. */ | ||
let filteredSponsors = sponsorshipsAsMaintainer.nodes.filter( | ||
(user: Sponsor) => | ||
user.privacyLevel !== PrivacyLevel.PRIVATE && | ||
user.tier.monthlyPriceInCents >= action.minimum | ||
) | ||
const sponsorshipsAsMaintainer = data?.sponsorshipsAsMaintainer | ||
if (action.maximum > 0) { | ||
filteredSponsors = filteredSponsors.filter( | ||
(user: Sponsor) => user.tier.monthlyPriceInCents <= action.maximum | ||
if (sponsorshipsAsMaintainer) { | ||
/* Appends the template, the API call returns all users regardless of if they are hidden or not. | ||
In an effort to respect a users decision to be anonymous we filter these users out. */ | ||
let filteredSponsors = sponsorshipsAsMaintainer.nodes.filter( | ||
(user: Sponsor) => | ||
user.privacyLevel !== PrivacyLevel.PRIVATE && | ||
user.tier.monthlyPriceInCents >= action.minimum | ||
) | ||
} | ||
/** If there are no valid sponsors then we return the provided fallback. */ | ||
if (!filteredSponsors.length) { | ||
return action.fallback | ||
if (action.maximum > 0) { | ||
filteredSponsors = filteredSponsors.filter( | ||
(user: Sponsor) => user.tier.monthlyPriceInCents <= action.maximum | ||
) | ||
} | ||
/** If there are no valid sponsors then we return the provided fallback. */ | ||
if (!filteredSponsors.length) { | ||
return action.fallback | ||
} | ||
filteredSponsors.map(({sponsorEntity}) => { | ||
template = template += render(action.template, sponsorEntity) | ||
}) | ||
} else { | ||
info(`No sponsorship data was foundβ¦ β`) | ||
} | ||
filteredSponsors.map(({sponsorEntity}) => { | ||
template = template += render(action.template, sponsorEntity) | ||
}) | ||
return template | ||
@@ -131,0 +141,0 @@ } |
import {ActionInterface, RequiredActionParameters} from './constants' | ||
/* Utility function that checks to see if a value is undefined or not. */ | ||
/** | ||
* Utility function that checks to see if a value is undefined or not. | ||
*/ | ||
export const isNullOrUndefined = (value: string | undefined | null): boolean => | ||
typeof value === 'undefined' || value === null || value === '' | ||
/* Checks for the required tokens and formatting. Throws an error if any case is matched. */ | ||
/** | ||
* Checks for the required tokens and formatting. Throws an error if any case is matched. | ||
*/ | ||
const hasRequiredParameters = <K extends keyof RequiredActionParameters>( | ||
@@ -18,3 +22,5 @@ action: ActionInterface, | ||
/* Verifies the action has the required parameters to run, otherwise throw an error. */ | ||
/** | ||
* Verifies the action has the required parameters to run, otherwise throw an error. | ||
*/ | ||
export const checkParameters = (action: ActionInterface): void => { | ||
@@ -28,7 +34,11 @@ if (!hasRequiredParameters(action, ['token'])) { | ||
/* Replaces all instances of a match in a string. */ | ||
/** | ||
* Replaces all instances of a match in a string. | ||
*/ | ||
const replaceAll = (input: string, find: string, replace: string): string => | ||
input.split(find).join(replace) | ||
/* Suppresses sensitive information from being exposed in error messages. */ | ||
/** | ||
* Suppresses sensitive information from being exposed in error messages. | ||
*/ | ||
export const suppressSensitiveInformation = ( | ||
@@ -51,2 +61,5 @@ str: string, | ||
/** | ||
* Extracts error message from an error. | ||
*/ | ||
export const extractErrorMessage = (error: unknown): string => | ||
@@ -53,0 +66,0 @@ error instanceof Error |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
190307
1656
269
2
+ Added@actions/core@1.9.1(transitive)
+ Added@actions/http-client@2.2.1(transitive)
+ Added@fastify/busboy@2.1.1(transitive)
+ Addedundici@5.28.4(transitive)
+ Addeduuid@8.3.2(transitive)
- Removed@actions/core@1.6.0(transitive)
- Removed@actions/http-client@1.0.11(transitive)
Updated@actions/core@1.9.1