Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(all and breaking): removed clumbersome namespace setup in favor of simply getResource(); #12

Merged
merged 4 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ jobs:
contents: read
statuses: write

# Current default Node.js version is 18.x.
strategy:
matrix:
node-version:
- ${{ vars.DEFAULT_NODE_MAJOR_VERSION }}.x
- 20.x
- 22.x
# IMPORTANT!!
# Devdependencies requires node>=18.
# Do NOT use node<18 for the matrix.

steps:
- name: Checkout code
uses: 'actions/checkout@v4'
Expand All @@ -65,27 +54,21 @@ jobs:

- name: Install pnpm
uses: 'pnpm/action-setup@v4'
with:
version: ${{ vars.DEFAULT_PNPM_FULL_VERSION }}
# 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 --frozen-lockfile

- name: Set up Node.js ${{ vars.DEFAULT_NODE_MAJOR_VERSION }}
uses: 'actions/setup-node@v4'
with:
node-version: ${{ matrix.node-version }}
node-version: ${{ vars.DEFAULT_NODE_MAJOR_VERSION }}.x
cache : pnpm

- name: Run tests
run : pnpm test:coverage

# Only upload coverage reports for the default Node.js version.
- name: Upload coverage reports to Codecov
if : matrix.node-version == ${{ vars.DEFAULT_NODE_MAJOR_VERSION }}.x
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ jobs:

- name: Install pnpm
uses: 'pnpm/action-setup@v4'
with:
version: ${{ vars.DEFAULT_PNPM_FULL_VERSION }}

- name: Install dependencies
run : pnpm install --frozen-lockfile
Expand Down
2 changes: 2 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

# ./.husky/post-commit
#
# Post-commit hook script,
Expand Down
10 changes: 6 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

# ./.husky/pre-commit
#
# Pre-commit hook script, updates dependencies,
Expand All @@ -15,11 +17,11 @@ pnpm update
# Run linter.
pnpm run lint

# Stage any changes made by the commands above.
git add --all
# Test build the package in preperation for release.
pnpm run build

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

# Test build the package in preperation for release.
pnpm run build
# Stage any changes made by the commands above.
git add --all
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## [2.0.1](https://github.com/KemingHe/OSU/compare/v2.0.0...v2.0.1) (2024-08-29)

## [2.0.0](https://github.com/KemingHe/OSU/compare/v1.1.1...v2.0.0) (2024-08-29)


### ⚠ BREAKING CHANGES

* **schemas/:** * renamed isOSUEmail to isOSUDotEduEmail for clarity * renamed isNameDotNumber to
isNameDotNum for brivety * completely removed the osu namespace and sub-spaces in favor of importing
getResource functions to simplify usage

### Features

* **schemas/:** replaced osu namespace with flat config, i.e. getResoruce functions ([4109ff9](https://github.com/KemingHe/OSU/commit/4109ff9fd0df412aa7cca2951d2b8ee137decb44))

## [1.1.1](https://github.com/KemingHe/OSU/compare/v1.1.0...v1.1.1) (2024-08-03)

## [1.1.0](https://github.com/KemingHe/OSU/compare/v1.0.10...v1.1.0) (2024-08-03)
Expand Down
131 changes: 102 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,18 @@

> [!IMPORTANT]
>
> **Versions 1.1.0 and below are DEPRECATED!** Please upgrade to the latest version.

> [!NOTE]
>
> Build by students, for students, with :heart:. **NOT** affiliated nor endorsed by official OSU.
>
> * Publicly-available data about OSU undergrad majors [here](https://undergrad.osu.edu/majors-and-academics/majors).
> * Publicly-available data about OSU student organizations [here](https://activities.osu.edu/involvement/student_organizations).

## :gear: Installation

Required: Node >= 14
Requires [Node.js](https://nodejs.org/en/download/package-manager) >= **14**

```bash
# Using npm:
Expand All @@ -67,57 +71,126 @@ pnpm add @keminghe/osu
### Using Validators

```typescript
import { isNameDotNumber, isOSUEmail, isBuckeyemail, isOSUOrBuckeyemail } from '@keminghe/osu';
// Using OSU email validator functions.
import {
isNameDotNum,
isOSUDotEduEmail,
isBuckeyemail,
isOSUEmail,
} from "@keminghe/osu";

isNameDotNum("buckeye.1"); // true
isOSUDotEduEmail("[email protected]"); // true
isBuckeyemail("[email protected]"); // true
isOSUEmail("[email protected]"); // false
```

### Using RegExp Patterns

```typescript
const flag1 = isNameDotNumber('brutus.1'); // true
const flag2 = isNameDotNumber('adams-brown-catlyn.3'); // true
const flag3 = isOSUEmail('[email protected]'); // true
const flag4 = isBuckeyemail('[email protected]'); // true
const flag5 = isOSUOrBuckeyemail('[email protected]'); // false
// Using OSU name dot num and email RegExp patterns.
import {
NAME_DOT_NUM_PATTERN,
OSU_DOT_EDU_EMAIL_PATTERN,
BUCKEYEMAIL_PATTERN
} from "@keminghe/osu";

NAME_DOT_NUM_PATTERN.test("buckeye.1"); // true
OSU_DOT_EDU_EMAIL_PATTERN.test("[email protected]"); // true
BUCKEYEMAIL_PATTERN.test("[email protected]"); // true
```

### Accessing Undergraduate Majors and Degrees
### Accessing Undergrad Majors Data

```typescript
import osu from '@keminghe/osu';
import { getUndergradMajors, type UndergradMajor } from "@keminghe/osu";

const majors = osu.undergrad.majors;
const majors: UndergradMajor[] = getUndergradMajors();
console.log(majors);
```

### Accessing Student Organizations
### Accessing Student Organization Data

```typescript
import osu from '@keminghe/osu';
import { getStudentOrgs, type StudentOrg } from "@keminghe/osu";

const studentOrgs = osu.studentOrgs;
console.log(studentOrgs);
const orgs: StudentOrg[] = getStudentOrgs();
console.log(orgs);
```

## :blue_book: API
<details>
<summary>DEPRECATED v1.1.0 Documentation</summary>

### (DEPRECATED v1.1.0) Using Validators

```typescript
interface StudentOrg {
name : string;
purposeStatement: string;
affiliation : string[];
}
import { isNameDotNumber, isOSUEmail, isBuckeyemail, isOSUOrBuckeyemail } from "@keminghe/osu";
```

```typescript
const flag1 = isNameDotNumber("brutus.1"); // true
const flag2 = isNameDotNumber("adams-brown-catlyn.3"); // true
const flag3 = isOSUEmail("[email protected]"); // true
const flag4 = isBuckeyemail("[email protected]"); // true
const flag5 = isOSUOrBuckeyemail("[email protected]"); // false
```

> [!NOTE]
>
> Certain majors are exploratory and are **NOT** associated with any degree.
### (DEPRECATED v1.1.0) Accessing Undergraduate Majors and Degrees

```typescript
import osu from "@keminghe/osu";

const majors = osu.undergrad.majors;
console.log(majors);
```

### (DEPRECATED v1.1.0) Accessing Student Organizations

```typescript
interface Major {
major : string;
degree : string | null;
campus : string;
college: string;
}
import osu from "@keminghe/osu";

const studentOrgs = osu.studentOrgs;
console.log(studentOrgs);
```

</details>

## :blue_book: API

### `StudentOrg` Type

```typescript path=src/schemas/StudentOrg.ts
/**
* TypeScript type inferred from the `StudentOrg` Zod schema.
*
* This type represents the structure of a student organization object as defined by the `StudentOrg` schema.
*
* @typedef {Object} StudentOrg
* @property {string} name - Name of the student organization, represented by a non-empty string.
* @property {string | null} purposeStatement - Purpose statement of the student organization, represented by a non-empty string, or null if not applicable or missing data.
* @property {Campus[] | null} campuses - Campuses where the student organization is active, represented by a non-empty array of `Campus` objects, or null if not applicable or missing data.
* @property {StudentOrgCategory[] | null} categories - Categories of the student organization, represented by a non-empty array of `StudentOrgCategory` objects, or null if not applicable or missing data.
*/
export type StudentOrg = z.infer<typeof StudentOrgSchema>;
```

### `UndergradMajor` Type

```typescript path=src/schemas/UndergradMajor.ts
/**
* TypeScript type inferred from the `UndergradMajor` Zod schema.
*
* This type represents the structure of an undergraduate major object as defined by the `UndergradMajor` schema.
*
* @typedef {Object} UndergradMajor
* @property {string} major - Name of the major, represented by a non-empty string.
* @property {UndergradDegree[] | null} degrees - Array of undergraduate degrees associated with the major, represented by a non-empty array of `UndergradDegree` objects, or null if not applicable or missing data.
* @property {Campus[] | null} campuses - Campuses where the major is offered, represented by a non-empty array of `Campus` objects, or null if not applicable or missing data.
* @property {College | null} college - College where the major belongs, represented by a `College` object, or null if not applicable or missing data.
*
* @see {@link UndergradMajorInterface} for the equivalent native TypeScript interface.
*/
export type UndergradMajor = z.infer<typeof UndergradMajorSchema>;
```

## :key: License
Expand Down
4 changes: 3 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
"dist",
"coverage",
"node_modules",
"src/osu.ts",
"scripts/genStudentOrgs/RawStudentOrg.ts",
"scripts/genUndergradMajors/RawUndergradMajor.ts",
"src/autoGenerated",
"src/schemas",
"**/__snapshots__",
"./*.json"
],
Expand Down
Loading