Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonneal committed Sep 17, 2024
0 parents commit 53c1424
Show file tree
Hide file tree
Showing 24 changed files with 3,974 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
86 changes: 86 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: main

on:
push:
branches: [main]

jobs:
lint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/setup
- uses: actions/setup-python@v5
with:
python-version: 3.12
- run: just install
- uses: pre-commit/action@v3.0.1

docs-publish:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/setup
- run: just install
- run: just docs-build
- uses: actions/upload-pages-artifact@v3
with:
path: docs

docs-deploy:
runs-on: ubuntu-24.04
needs: docs-publish
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4

ts-standard-type-check:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/setup
- run: just ts-standard-install
- run: just ts-standard-type-check

ts-standard-test-cov:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/setup
- run: just ts-standard-install
- run: just ts-standard-test-cov

libs-publish:
runs-on: ubuntu-24.04
needs:
- lint
- ts-standard-type-check
- ts-standard-test-cov
permissions:
contents: write
packages: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/setup
- run: just ts-standard-install
- run: |
cat << EOF > "$HOME/.npmrc"
@jacksonneal:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN
EOF
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: changesets/action@v1
with:
version: changeset version
publish: pnpm publish -r
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: git push --follow-tags
23 changes: 23 additions & 0 deletions .github/workflows/setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: setup

inputs:
NODE_VERSION:
required: true
default: 22.7.0
PNPM_VERSION:
required: true
default: 9.9.0

runs:
using: "composite"
steps:
- uses: ConorMacBride/install-package@v1
with:
apt: just
- uses: pnpm/action-setup@v4
with:
version: ${{ inputs.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.NODE_VERSION }}
cache: pnpm
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage
dist
docs
node_modules
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-json
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: lint
name: lint
language: system
entry: just lint
30 changes: 30 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import eslintConfigPrettier from "eslint-config-prettier";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import typescriptEslint from 'typescript-eslint';

export default typescriptEslint.config(
...typescriptEslint.configs.strictTypeChecked,
...typescriptEslint.configs.stylisticTypeChecked,
eslintConfigPrettier,
{
ignores: ['**/*.{js,mjs}', '**/dist/*', '**/coverage/*'],
},
{
languageOptions: {
parserOptions: {
project: ['./libs/**/tsconfig.json'],
// @ts-expect-error
tsconfigRootDir: import.meta.dirname,
},
},
},
{
plugins: {
"simple-import-sort": simpleImportSort,
},
rules: {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
},
},
);
46 changes: 46 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
set positional-arguments

default:
@just --list

pc:
@pre-commit run --all-files

lint *args='':
@pnpm lint

lint-fix:
@pnpm lint-fix

docs-build:
@pnpm docs-build

install:
@pnpm install

change:
@pnpm changeset

workspace *args='':
@pnpm workspace $@

workspace-install:
@pnpm workspace install

ts-standard *args='':
@pnpm ts-standard $@

ts-standard-install:
@just ts-standard install

ts-standard-type-check:
@just ts-standard type-check

ts-standard-test:
@just ts-standard test

ts-standard-test-cov:
@just ts-standard test-cov

ts-standard-build:
@just ts-standard build
3 changes: 3 additions & 0 deletions libs/ts-standard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ts-standard

TypeScript utilities
12 changes: 12 additions & 0 deletions libs/ts-standard/ex/filter.ex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Example type usage for `@/filter` module
*
* @module
*/

import { isNonNullable } from "@";

import { is } from "./shared.ex";

// isNonNullable
is<string[]>(["hello", "there", null, undefined].filter(isNonNullable));
15 changes: 15 additions & 0 deletions libs/ts-standard/ex/shared.ex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Shared utilities for type examples
*
* @module
*/

/**
* Type check value against type parameter.
*
* @typeParam T - type
*
* @param _ - to check
*/
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unnecessary-type-parameters, @typescript-eslint/no-unused-vars
export function is<T>(_: T) { }
18 changes: 18 additions & 0 deletions libs/ts-standard/ex/type.ex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Example type usage for `@/type` module
*
* @module
*/

import { Nullable, Opt } from "@";

import { is } from "./shared.ex";

// Opt<T>
is<Opt<string>>("hello");
is<Opt<string>>(null);

// Nullable<T>
is<Nullable<string>>("hello");
is<Nullable<string>>(null);
is<Nullable<string>>(undefined);
24 changes: 24 additions & 0 deletions libs/ts-standard/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/package.json",
"name": "@jacksonneal/ts-standard",
"description": "TypeScript utilities",
"version": "0.0.0",
"type": "module",
"main": "./dist/ts-standard.js",
"typings": "./dist/src/index.d.ts",
"scripts": {
"type-check": "tsc",
"test": "vitest run",
"test-cov": "vitest run --coverage",
"build": "tsc && vite build"
},
"devDependencies": {
"@types/node": "^22.5.4",
"@vitest/coverage-v8": "^2.0.5",
"typescript": "^5.5.3",
"vite": "^5.4.1",
"vite-plugin-dts": "^4.2.1",
"vite-tsconfig-paths": "^5.0.1",
"vitest": "^2.0.5"
}
}
25 changes: 25 additions & 0 deletions libs/ts-standard/src/filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Utility functions for filtering and type checking
*
* @module
*/

import { Nullable } from "@";

/**
* Check if a value is not `null` and not `undefined`.
*
* @typeParam T - type of value to check
*
* @param value - to check
* @returns whether value is not `null` and not `undefined`
*
* @example
* const isString = isNonNullable<string>("hello"); // true
* const isNull = isNonNullable(null); // false
* const isUndefined = isNonNullable(undefined); // false
* const nonNullables: number[] = [1, 2, null, undefined].filter(isNonNullable); // [1, 2]
*/
export function isNonNullable<T>(value: Nullable<T>): value is NonNullable<T> {
return value != null;
}
8 changes: 8 additions & 0 deletions libs/ts-standard/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* TypeScript utilities
*
* @module ts-standard
*/

export { isNonNullable } from './filter';
export type { Nullable, Opt } from './type';
29 changes: 29 additions & 0 deletions libs/ts-standard/src/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Utility types
*
* @module
*/

/**
* Optional type that may be `T` or `null`
*
* @typeParam T - non-null type
*
* @example
* const optString: Opt<string> = "hello";
* const optNull: Opt<string> = null;
*/
export type Opt<T> = T | null;

/**
* Nullable type that may be `Opt<T>` or `undefined`,
* opposite of the typescript builtin `NonNullable<T>`
*
* @typeParam T - non-null type
*
* @example
* const nullableString: Nullable<string> = "hello";
* const nullableNull: Nullable<string> = null;
* const nullableUndefined: Nullable<string> = undefined;
*/
export type Nullable<T> = Opt<T> | undefined;
Loading

0 comments on commit 53c1424

Please sign in to comment.