Skip to content

Commit

Permalink
feat(src/utils/osuvalidators.ts): added and fully tested osu validators
Browse files Browse the repository at this point in the history
utils to validate using regexp osu name dot num, osu email, buckeyemail, and either.
  • Loading branch information
KemingHe committed Jul 31, 2024
1 parent 311de68 commit c79afea
Show file tree
Hide file tree
Showing 20 changed files with 5,424 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .czrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "./node_modules/cz-conventional-changelog"
}
80 changes: 80 additions & 0 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# ./github/workflows/lint-test.yml
#
# Per push, PR, or manual trigger,
# run Super-Linter and report coverage to Codecov.

# Run all-around linting and testing per every push and PR.
on:
push :
pull_request :
workflow_dispatch:

jobs:
run-super-linter:
name : Run Super-Linter
runs-on: ubuntu-latest

permissions:
contents: read # For checking out the code.
packages: read # For installing pnpm and other packages.
statuses: write # For reporting GitHub Actions status checks.

steps:
- name: Checkout code
uses: 'actions/checkout@v4'
with:
# super-linter needs the full git history to get the
# list of files that changed across commits
fetch-depth: 0

- name: Run super-linter
uses: 'super-linter/super-linter@v6'
env :
# For reporting GitHub Actions status checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

report-codecov:
name : Report Codecov
runs-on: ubuntu-latest

permissions:
contents: read
packages: read

steps:
- name: Checkout code
uses: 'actions/checkout@v4'

# IMPORTANT!! when using pnpm,
# you MUST follow this EXACT order of:
# 1. Setup pnpm;
# 2. Install dependencies;
# 3. Setup Node.js;
# 4. Run tests.

- name: Install pnpm
uses: 'pnpm/action-setup@v4'
with:
version: 9.6.0
# WARNING!
# Do NOT use 'latest' as the version for pnpm.
# 'latest' may fall behind the actual latest stable release of pnpm.

- name: Install dependencies
run : pnpm install

- name: Set up Node.js 18
uses: 'actions/setup-node@v4'
with:
node-version: 18.x
cache : pnpm

- name: Run tests
run : pnpm test:coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug : KemingHe/OSU

20 changes: 14 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Custome local files and dir.
tmp
temp

# Hugo generated files
docs/public

# Stores VSCode versions used for testing VSCode extensions
.vscode
.vscode-test

# Logs
logs
*.log
Expand Down Expand Up @@ -84,12 +95,12 @@ web_modules/
.parcel-cache

# Next.js build output
.next
.next/
out

# Nuxt.js build / generate output
.nuxt
dist
.nuxt/
dist/

# Gatsby files
.cache/
Expand Down Expand Up @@ -119,9 +130,6 @@ dist
# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
Expand Down
13 changes: 13 additions & 0 deletions .husky/install.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// ./.husky/install.mjs
//
// Official instructions on skipping husky install in prod/CI environments.
if (process.env.NODE_ENV === "production" || process.env.CI) {
console.log(
"Husky > Skipping Git hooks installation in production environment",
);
process.exit(0);
}

const husky = (await import("husky")).default;
console.log("Husky > Installing Git hooks");
console.log(husky());
9 changes: 9 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ./.husky/post-commit
#
# Post-commit hook script,
# runs release-it to generate changelog and release package.

# Disable Husky during release-it to avoid infinite commit loop.
export HUSKY=0
pnpm release-it --ci
unset HUSKY
25 changes: 25 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ./.husky/pre-commit
#
# Pre-commit hook script, updates dependencies,
# runs linter, tests, and build before commiting.

# IMPORTANT!!
# This is NOT exactly a shell script.
# This IS a hook script run by Husky.
# To avoid Husky errors, AVOID shell syntax in this file.

# Install dependencies and update.
pnpm install
pnpm update

# Run linter.
pnpm run lint

# Stage any changes made by the commands above.
git add --all

# Run test and enforce 100% coverage.
pnpm run test:coverage

# Test build the package in preperation for release.
pnpm run build
14 changes: 14 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# ./.husky/prepare-commit-msg
#
# Husky integration with commitizen,
# lets commitizen's CLI handle commit message generation.

# Step 1. give script access to terminal (tty)
# for interactive commit message generation.
exec < /dev/tty

# Step 2. run commitizen w/out local installation,
# fallback to doing nothing if fails.
pnpm cz --hook || true
12 changes: 12 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# .npmrc
#
# Config file for npm/pnpm.

# Critical for slow/unstable connections:
# Retry fetches up to 10 times, with exponential backoff,
# i.e. 1s, 2s, 4s, 8s, 16s, 32s, 64s, 128s.
fetch-retries=10
fetch-retry-factor=1.5
fetch-retry-mintimeout=1000
fetch-retry-maxtimeout=128000
fetch-timeout=120000
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
41 changes: 41 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"verbose": 2,
"hooks": {
"before:init": [
"echo",
"echo 'As post-commit standard procedure, begin release process...'",
],
"after:bump": [
"echo",
"echo 'Successfully bumped to version: v${ version }; now generating CHANGELOG.md...'",
],
"after:release": [
"echo",
"echo 'New release project: ${ name }, version: v${ version } is available to be push.'",
],
},
"git": {
"tag": true,
"tagName": "v${version}",
"requireCleanWorkingDir": true,
"commit": true,
"commitMessage": "chore(release): v${version} via release-it (auto, ci env)",
"commitArgs": ["--no-verify"],
"push": false,
},
"npm": {
"publish": false,
},
"github": {
"release": false,
},
"plugins": {
"@release-it/conventional-changelog": {
"infile": "CHANGELOG.md",
"header": "# Changelog",
"preset": {
"name": "conventionalcommits",
},
},
},
}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# OSU

Unofficial and publicly-available data about The Ohio State University.

## Features

1. OSU and buckeyemail email validator.
2. OSU all majors and degress.
1. Manually scraped as a .csv file into data/ dir.
2. Use util scripts to...
3. OSU all student orgs: name, mission statement, and catetories.
53 changes: 53 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "main"
},
"files": {
"include": [],
"ignore": ["dist", "coverage", "node_modules", "./*.json"],
"ignoreUnknown": true
},
"organizeImports": {
"enabled": true
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"ignore": [],
"attributePosition": "auto",
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80
},
"javascript": {
"formatter": {
"arrowParentheses": "always",
"bracketSameLine": false,
"bracketSpacing": true,
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"semicolons": "always",
"trailingCommas": "all"
},
"parser": {
"unsafeParameterDecoratorsEnabled": true
}
},
"json": {
"formatter": {
"trailingCommas": "all"
}
},
"linter": {
"enabled": true,
"ignore": [],
"rules": {
"recommended": true
}
}
}
58 changes: 58 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"type": "module",
"private": true,
"name": "osu",
"version": "0.1.0",
"description": "Unofficial, publicly available data about The Ohio State University.",
"keywords": [],
"homepage": "https://github.com/KemingHe/OSU",
"bugs": {
"url": "https://github.com/KemingHe/OSU/issues",
"email": "keminghe.career@gmail.com"
},
"license": "MIT",
"author": {
"name": "Keming He",
"email": "keminghe.career@gmail.com",
"url": "https://linkedin.com/in/keminghe"
},
"contributors": [],
"repository": {
"type": "git",
"url": "https://github.com/KemingHe/OSU.git"
},
"packageManager": "pnpm@9.6.0",
"scripts": {
"prepare": "husky || true",
"preinstall": "echo 'Currently using pnpm@9.6.0, remember to update: [ package.json and .github/workflows ].'",
"lint": "biome ci .",
"lint:fix": "biome check --write .",
"test": "NODE_ENV=test vitest",
"test:coverage": "NODE_ENV=test vitest --coverage.enabled --watch=false",
"test:bench": "NODE_ENV=test vitest bench --outputFile.json=benchmark.json",
"test:bench:compare": "NODE_ENV=test vitest bench --compare benchmark.json",
"build": "set -e; tsc --project tsconfig.build.json; tsc-alias -p tsconfig.build.json;",
"postbuild": "echo 'Build complete: src/ -> dist/. '"
},
"dependencies": {},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@release-it/conventional-changelog": "^8.0.1",
"@types/node": "^20.14.13",
"@vitest/coverage-v8": "^2.0.4",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"husky": "^9.1.4",
"release-it": "^17.6.0",
"ts-node": "^10.9.2",
"tsc-alias": "^1.8.10",
"typescript": "^5.5.4",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^2.0.4"
},
"engines": {
"node": ">=18"
},
"os": ["linux", "darwin", "win32"],
"cpu": ["x64", "arm64"]
}
Loading

0 comments on commit c79afea

Please sign in to comment.