https://github.com/danger/peril-settings-linter
A node module for listing the settings file
https://github.com/danger/peril-settings-linter
Last synced: 9 months ago
JSON representation
A node module for listing the settings file
- Host: GitHub
- URL: https://github.com/danger/peril-settings-linter
- Owner: danger
- License: mit
- Created: 2018-09-16T02:15:17.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-31T19:13:47.000Z (over 7 years ago)
- Last Synced: 2025-04-07T18:42:04.059Z (about 1 year ago)
- Language: TypeScript
- Size: 77.1 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @peril/utils
Maybe this will turn into a mono-repo with a lot of smaller packages, but for now - this is fine.
### Generating a Peril Settings Repo
```typescript
export const fileMapForPerilSettingsRepo = async (api: octokit, options: NewRepoOptions)
```
Which returns a [fileMap](https://github.com/orta/memfs-or-file-map-to-github-branch) for an example Peril settings
repo. There are a few options.
Usage:
```ts
const map = await fileMapForPerilSettingsRepo(api, {
isPublic: true,
setupTests: true,
useTypeScript: true,
repo: {
name: "Fake Repo",
owner: {
login: "User Name",
},
},
})
```
### Linting
Mainly one function:
```typescript
export function lint(
settingsReference: string,
api: octokit,
currentSettings?: FileRelatedPartOfJSON
): Promise
```
You pass in the dangerfile reference URL for the settings repo, an already set-up OctoKit `api` object (so you
handle auth basically) and you can optionally pass in the `currentSettings` - if you don't this lib will grab the
version in the `settingsReference`.
Usage:
```typescript
import { lint } from "peril-settings-linter"
const runLinter = async () => {
const results = await lint("artsy/peril-settings@settings.json", api)
if (results.networkErrors.length) {
console.error(`Could not find files at: ${results.networkErrors.join(",")}`)
}
if (results.schemaErrors.length) {
console.error(`Settings file did not pass schema validation: ${results.schemaHumanReadableErrors}`)
console.error(`Settings file did not pass schema validation: ${results.schemaErrors}`)
}
}
```
## How do I work on this?
```sh
git clone https://github.com/orta/peril-settings-linter.git
cd peril-settings-linter
yarn install
# Open VS Code with `code .`
code .
# Run tests
yarn jest
yarn type-check
```
## How do I deploy this?
```sh
yarn release
```