Socket
Socket
Sign inDemoInstall

@jamesives/github-sponsors-readme-action

Package Overview
Dependencies
7
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 1.0.6

4

__tests__/template.test.ts

@@ -539,3 +539,3 @@ import {GitHubResponse, PrivacyLevel, Status, Urls} from '../src/constants'

} catch (error) {
expect(error.message).toBe(
expect(error instanceof Error && error.message).toBe(
'There was an error generating the updated file: Mocked throw ❌'

@@ -612,3 +612,3 @@ )

} catch (error) {
expect(error.message).toBe(
expect(error instanceof Error && error.message).toBe(
'There was an error with the GitHub API request: Mocked throw ❌'

@@ -615,0 +615,0 @@ )

import {
checkParameters,
extractErrorMessage,
suppressSensitiveInformation,

@@ -44,4 +45,4 @@ isNullOrUndefined

checkParameters(action)
} catch (e) {
expect(e.message).toMatch(
} catch (error) {
expect(extractErrorMessage(error)).toMatch(
'No deployment token was provided. You must provide the action with a Personal Access Token scoped to user:read or org:read.'

@@ -88,2 +89,20 @@ )

})
describe('extractErrorMessage', () => {
it('gets the message of a Error', () => {
expect(extractErrorMessage(new Error('a error message'))).toBe(
'a error message'
)
})
it('gets the message of a string', () => {
expect(extractErrorMessage('a error message')).toBe('a error message')
})
it('gets the message of a object', () => {
expect(extractErrorMessage({special: 'a error message'})).toBe(
`{"special":"a error message"}`
)
})
})
})

@@ -5,3 +5,3 @@ ---

labels:
- bug
- triage ⚠️
---

@@ -8,0 +8,0 @@

@@ -8,21 +8,21 @@ "use strict";

exports.action = {
token: core_1.getInput('token'),
template: !util_1.isNullOrUndefined(core_1.getInput('template'))
? core_1.getInput('template')
token: (0, core_1.getInput)('token'),
template: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('template'))
? (0, core_1.getInput)('template')
: `<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="60px" alt="" /></a>`,
minimum: !util_1.isNullOrUndefined(core_1.getInput('minimum'))
? parseInt(core_1.getInput('minimum'))
minimum: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('minimum'))
? parseInt((0, core_1.getInput)('minimum'))
: 0,
maximum: !util_1.isNullOrUndefined(core_1.getInput('maximum'))
? parseInt(core_1.getInput('maximum'))
maximum: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('maximum'))
? parseInt((0, core_1.getInput)('maximum'))
: 0,
marker: !util_1.isNullOrUndefined(core_1.getInput('marker'))
? core_1.getInput('marker')
marker: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('marker'))
? (0, core_1.getInput)('marker')
: 'sponsors',
file: !util_1.isNullOrUndefined(core_1.getInput('file')) ? core_1.getInput('file') : 'README.md',
fallback: !util_1.isNullOrUndefined(core_1.getInput('fallback'))
? core_1.getInput('fallback')
file: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('file')) ? (0, core_1.getInput)('file') : 'README.md',
fallback: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('fallback'))
? (0, core_1.getInput)('fallback')
: ``,
organization: !util_1.isNullOrUndefined(core_1.getInput('organization'))
? core_1.getInput('organization').toLowerCase() === 'true'
organization: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('organization'))
? (0, core_1.getInput)('organization').toLowerCase() === 'true'
: false

@@ -29,0 +29,0 @@ };

@@ -28,3 +28,3 @@ "use strict";

try {
core_1.info(`
(0, core_1.info)(`
GitHub Sponsors Readme Action πŸ’–

@@ -38,13 +38,13 @@

πŸ’– Support: https://github.com/sponsors/JamesIves`);
core_1.info('Checking configuration and initializing… 🚚');
util_1.checkParameters(settings);
const response = yield template_1.getSponsors(settings);
status = yield template_1.generateFile(response, settings);
(0, core_1.info)('Checking configuration and initializing… 🚚');
(0, util_1.checkParameters)(settings);
const response = yield (0, template_1.getSponsors)(settings);
status = yield (0, template_1.generateFile)(response, settings);
}
catch (error) {
status = constants_1.Status.FAILED;
core_1.setFailed(error.message);
(0, core_1.setFailed)((0, util_1.extractErrorMessage)(error));
}
finally {
core_1.info(`${status === constants_1.Status.FAILED
(0, core_1.info)(`${status === constants_1.Status.FAILED
? 'There was an error generating sponsors. ❌'

@@ -54,3 +54,3 @@ : status === constants_1.Status.SUCCESS

: `Unable to locate markers in your file. Please check the documentation and try again. ⚠️`}`);
core_1.setOutput('sponsorship-status', status);
(0, core_1.setOutput)('sponsorship-status', status);
}

@@ -57,0 +57,0 @@ });

@@ -8,2 +8,2 @@ "use strict";

const lib_1 = __importDefault(require("./lib"));
lib_1.default(constants_1.action);
(0, lib_1.default)(constants_1.action);

@@ -23,3 +23,3 @@ "use strict";

try {
core_1.info(`Fetching data from the GitHub API as ${action.organization ? 'Organization' : 'User'}… ⚽`);
(0, core_1.info)(`Fetching data from the GitHub API as ${action.organization ? 'Organization' : 'User'}… ⚽`);
const query = `query {

@@ -75,3 +75,3 @@ viewer {

catch (error) {
throw new Error(`There was an error with the GitHub API request: ${util_1.suppressSensitiveInformation(error.message, action)} ❌`);
throw new Error(`There was an error with the GitHub API request: ${(0, util_1.suppressSensitiveInformation)((0, util_1.extractErrorMessage)(error), action)} ❌`);
}

@@ -83,3 +83,3 @@ });

let template = ``;
core_1.info('Generating template… ✨');
(0, core_1.info)('Generating template… ✨');
const { sponsorshipsAsMaintainer } = response.data.viewer;

@@ -98,3 +98,3 @@ /* Appends the template, the API call returns all users regardless of if they are hidden or not.

filteredSponsors.map(({ sponsorEntity }) => {
template = template += mustache_1.render(action.template, sponsorEntity);
template = template += (0, mustache_1.render)(action.template, sponsorEntity);
});

@@ -107,3 +107,3 @@ return template;

try {
core_1.info(`Generating updated ${action.file} file… πŸ“`);
(0, core_1.info)(`Generating updated ${action.file} file… πŸ“`);
/** Replaces the content within the comments and re appends/prepends the comments to the replace for follow-up workflow runs. */

@@ -120,3 +120,3 @@ const regex = new RegExp(`(<!-- ${action.marker} -->)[\\s\\S]*?(<!-- ${action.marker} -->)`, 'g');

catch (error) {
throw new Error(`There was an error generating the updated file: ${util_1.suppressSensitiveInformation(error.message, action)} ❌`);
throw new Error(`There was an error generating the updated file: ${(0, util_1.suppressSensitiveInformation)((0, util_1.extractErrorMessage)(error), action)} ❌`);
}

@@ -123,0 +123,0 @@ });

@@ -5,1 +5,2 @@ import { ActionInterface } from './constants';

export declare const suppressSensitiveInformation: (str: string, action: ActionInterface) => string;
export declare const extractErrorMessage: (error: unknown) => string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.suppressSensitiveInformation = exports.checkParameters = exports.isNullOrUndefined = void 0;
exports.extractErrorMessage = exports.suppressSensitiveInformation = exports.checkParameters = exports.isNullOrUndefined = void 0;
/* Utility function that checks to see if a value is undefined or not. */
exports.isNullOrUndefined = (value) => typeof value === 'undefined' || value === null || value === '';
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. */
const hasRequiredParameters = (action, params) => {
const nonNullParams = params.filter(param => !exports.isNullOrUndefined(action[param]));
const nonNullParams = params.filter(param => !(0, exports.isNullOrUndefined)(action[param]));
return Boolean(nonNullParams.length);
};
/* Verifies the action has the required parameters to run, otherwise throw an error. */
exports.checkParameters = (action) => {
const checkParameters = (action) => {
if (!hasRequiredParameters(action, ['token'])) {

@@ -17,6 +18,7 @@ throw new Error('No deployment token was provided. You must provide the action with a Personal Access Token scoped to user:read or org:read.');

};
exports.checkParameters = checkParameters;
/* 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. */
exports.suppressSensitiveInformation = (str, action) => {
const suppressSensitiveInformation = (str, action) => {
let value = str;

@@ -29,1 +31,8 @@ const orderedByLength = [action.token, action.token].filter(Boolean).sort((a, b) => b.length - a.length);

};
exports.suppressSensitiveInformation = suppressSensitiveInformation;
const extractErrorMessage = (error) => error instanceof Error
? error.message
: typeof error == 'string'
? error
: JSON.stringify(error);
exports.extractErrorMessage = extractErrorMessage;

@@ -5,3 +5,3 @@ {

"author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)",
"version": "1.0.5",
"version": "1.0.6",
"license": "MIT",

@@ -35,4 +35,4 @@ "main": "lib/lib.js",

"dependencies": {
"@actions/core": "1.2.6",
"@actions/io": "1.1.0",
"@actions/core": "1.6.0",
"@actions/io": "1.1.1",
"cross-fetch": "3.1.4",

@@ -42,19 +42,19 @@ "mustache": "4.2.0"

"devDependencies": {
"@types/async-retry": "1.4.2",
"@types/jest": "26.0.23",
"@types/mustache": "4.1.1",
"@types/node": "15.0.1",
"@typescript-eslint/eslint-plugin": "4.22.1",
"@typescript-eslint/parser": "4.22.0",
"eslint": "7.25.0",
"@types/async-retry": "1.4.3",
"@types/jest": "27.0.3",
"@types/mustache": "4.1.2",
"@types/node": "17.0.0",
"@typescript-eslint/eslint-plugin": "5.7.0",
"@typescript-eslint/parser": "5.7.0",
"eslint": "8.5.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-jest": "24.3.6",
"eslint-plugin-prettier": "3.4.0",
"jest": "25.5.4",
"jest-circus": "26.6.3",
"nock": "13.0.11",
"prettier": "2.2.1",
"ts-jest": "25.5.1",
"typescript": "3.9.9"
"eslint-plugin-jest": "25.3.0",
"eslint-plugin-prettier": "4.0.0",
"jest": "27.4.5",
"jest-circus": "27.4.5",
"nock": "13.2.1",
"prettier": "2.5.1",
"ts-jest": "27.1.2",
"typescript": "4.5.4"
}
}

@@ -33,6 +33,6 @@ <p align="center">

<p align="center"><a href="https://github.com/sponsors/JamesIves">Made possible by the following</a>:</p>
<p align="center">You can find an example of this below:</p>
<p align="center">
<!-- real-sponsors --><a href="https://github.com/Chooksta69"><img src="https://github.com/Chooksta69.png" width="40px" alt="" /></a><!-- real-sponsors -->
<!-- real-sponsors --><a href="https://github.com/milanpollock"><img src="https://github.com/milanpollock.png" width="40px" alt="" /></a><a href="https://github.com/raoulvdberge"><img src="https://github.com/raoulvdberge.png" width="40px" alt="" /></a><!-- real-sponsors -->
</p>

@@ -58,3 +58,3 @@

- name: Generate Sponsors πŸ’–
uses: JamesIves/github-sponsors-readme-action@1.0.0
uses: JamesIves/github-sponsors-readme-action@1.0.5
with:

@@ -115,6 +115,6 @@ token: ${{ secrets.PAT }}

| 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]. | `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 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** |

@@ -127,3 +127,3 @@ #### Optional Choices

| `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** |
| `maximum` | 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 less. By default the action will display all of your sponsors. | `with` | **No** |
| `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** |
| `marker` | This allows you to modify the marker comment that is placed in your file. By default this is set to sponsors - `<!-- sponsors --> <!-- sponsors -->`, if you set this to `gold` for example you can place `<!-- gold --> <!-- gold -->` in your file. | `with` | **No** |

@@ -175,3 +175,3 @@ | `fallback` | Allows you to specify a fallback if you have no sponsors. By default nothing is displayed. | `with` | **No** |

- name: Generate Sponsors πŸ’–
uses: JamesIves/github-sponsors-readme-action@1.0.0
uses: JamesIves/github-sponsors-readme-action@1.0.5
with:

@@ -227,3 +227,3 @@ token: ${{ secrets.PAT }}

- name: Generate Sponsors πŸ’–
uses: JamesIves/github-sponsors-readme-action@1.0.0
uses: JamesIves/github-sponsors-readme-action@1.0.5
with:

@@ -237,3 +237,3 @@ token: ${{ secrets.PAT }}

- name: Generate Sponsors πŸ’–
uses: JamesIves/github-sponsors-readme-action@1.0.0
uses: JamesIves/github-sponsors-readme-action@1.0.5
with:

@@ -270,1 +270,9 @@ token: ${{ secrets.PAT }}

</details>
---
## Support πŸ’–
This project would not be possible without all of our fantastic [contributors](https://github.com/JamesIves/github-sponsors-readme-action/graphs/contributors) and [sponsors](https://github.com/sponsors/JamesIves). If you'd like to support the maintenance and upkeep of this project you can [donate via GitHub Sponsors](https://github.com/sponsors/JamesIves).
<!-- sponsors --><a href="https://github.com/milanpollock"><img src="https://github.com/milanpollock.png" width="50px" alt="" /></a><a href="https://github.com/raoulvdberge"><img src="https://github.com/raoulvdberge.png" width="50px" alt="" /></a><!-- sponsors -->
import {info, setFailed, setOutput} from '@actions/core'
import {ActionInterface, Status} from './constants'
import {generateFile, getSponsors} from './template'
import {checkParameters} from './util'
import {checkParameters, extractErrorMessage} from './util'

@@ -37,3 +37,3 @@ /** Initializes and runs the action.

status = Status.FAILED
setFailed(error.message)
setFailed(extractErrorMessage(error))
} finally {

@@ -40,0 +40,0 @@ info(

@@ -13,3 +13,3 @@ import 'cross-fetch/polyfill'

import {render} from 'mustache'
import {suppressSensitiveInformation} from './util'
import {extractErrorMessage, suppressSensitiveInformation} from './util'
import {info} from '@actions/core'

@@ -83,3 +83,3 @@

`There was an error with the GitHub API request: ${suppressSensitiveInformation(
error.message,
extractErrorMessage(error),
action

@@ -155,3 +155,3 @@ )} ❌`

`There was an error generating the updated file: ${suppressSensitiveInformation(
error.message,
extractErrorMessage(error),
action

@@ -158,0 +158,0 @@ )} ❌`

@@ -38,5 +38,5 @@ import {ActionInterface, RequiredActionParameters} from './constants'

const orderedByLength = ([action.token, action.token].filter(
Boolean
) as string[]).sort((a, b) => b.length - a.length)
const orderedByLength = (
[action.token, action.token].filter(Boolean) as string[]
).sort((a, b) => b.length - a.length)

@@ -49,1 +49,8 @@ for (const find of orderedByLength) {

}
export const extractErrorMessage = (error: unknown): string =>
error instanceof Error
? error.message
: typeof error == 'string'
? error
: JSON.stringify(error)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc