-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve build system, documentation and types
- Loading branch information
Showing
30 changed files
with
818 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
name: Linting | ||
name: Linting and Testing | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
run: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
node-versions: | ||
- 10 | ||
- 12 | ||
- 14 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Node | ||
uses: actions/setup-node@v1 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14.x' | ||
- name: Install dependencies | ||
run: yarn | ||
- name: Lint | ||
run: yarn lint | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: node_modules/ | ||
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('yarn*.lock') }} | ||
|
||
- run: yarn ci | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
|
||
- run: yarn test:ci | ||
- run: yarn lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v1.* | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- run : yarn ci | ||
- run : yarn build:docs | ||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./docs/build | ||
keep_files: true | ||
- name: Publish to npm | ||
run : | | ||
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} | ||
npm publish --ignore-scripts | ||
env : | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,4 +108,7 @@ types | |
.tern-port | ||
|
||
# Mac local files | ||
.DS_Store | ||
.DS_Store | ||
|
||
# Documentation page | ||
docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { replicate, str, num, oneOf, date, listOf, text } from '../src/index' | ||
|
||
interface Worker | ||
{ | ||
name: string; | ||
age: number; | ||
position: 'manager' | 'director' | 'clerk'; | ||
dateOfEmployment: Date; | ||
achievements: Array<'owl' | 'hard worker' | 'coffee lower' | 'gambler'> | null; | ||
place: { | ||
officeId: string; | ||
floor: number; | ||
}; | ||
biography: string; | ||
} | ||
|
||
// Spawn 100 workers schema | ||
const workers: Array<Worker> = replicate({ | ||
size: 100, | ||
schema: () => ({ | ||
// Spawn capitalized string of chars with size in range of 4 to 8 | ||
name: text({ size: 1, type: 'names' }), | ||
|
||
// Spawn number from 15 to 90 | ||
age: num({ min: 15, max: 90 }), | ||
|
||
// Select on of the options provided in list | ||
position: oneOf({ list: ['manager', 'director', 'clerk'] as const }), | ||
|
||
// Spawn date in selected edges | ||
dateOfEmployment: date({ min: new Date('2018'), max: new Date('2020') }), | ||
|
||
// Spawn list of achievements. Count of achievements can be from 1 to 4, or null | ||
achievements: listOf({ | ||
list: ['owl', 'hard worker', 'coffee lower', 'gambler'] as const, | ||
size: num({ min: 1, max: 4 }), | ||
nullable: true, | ||
}), | ||
|
||
place: { | ||
// Spawn 10 length alphanumeric string | ||
officeId: str({ type: 'alphanumeric', size: 10 }), | ||
// Spawn number from 1 to 20 | ||
floor: num({ min: 1, max: 20 }), | ||
}, | ||
|
||
biography: text({ size: num({ min: 10, max: 30 }) }), | ||
}), | ||
}) | ||
|
||
console.log(workers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.