-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 999b9c9
Showing
13 changed files
with
349 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Main CI | ||
|
||
on: | ||
push: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Setup repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Deno | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: vx.x.x | ||
|
||
- name: Verify formatting | ||
run: deno fmt --check | ||
|
||
- name: Lint | ||
run: deno lint | ||
|
||
- name: Test | ||
run: deno test -A |
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,39 @@ | ||
name: Pull Request | ||
|
||
on: | ||
pull_request: | ||
branches: ["main"] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Setup repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Deno | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: vx.x.x | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
standalone: true | ||
run_install: false | ||
|
||
- name: Build | ||
run: deno task build | ||
|
||
- name: Publish build to npm | ||
run: cd build && pnpm publish --dry-run | ||
|
||
- name: Upload build | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: npm-build | ||
path: build |
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,45 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Setup repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Deno | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: vx.x.x | ||
|
||
- name: Prepare pnpm | ||
run: "touch package.json && echo '{ 'packageManager': 'pnpm@latest' }' >> package.json" | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
standalone: true | ||
run_install: false | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Build | ||
run: deno task build ${{ github.ref_name }} | ||
|
||
- name: Publish build to npm | ||
run: cd build && pnpm publish | ||
|
||
- name: Upload build | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: npm-build | ||
path: build |
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,69 @@ | ||
/build/ | ||
|
||
# Created by https://www.toptal.com/developers/gitignore/api/deno,visualstudiocode,macos | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=deno,visualstudiocode,macos | ||
|
||
### Deno ### | ||
/.idea/ | ||
/.vscode/ | ||
|
||
/node_modules | ||
|
||
.env | ||
*.orig | ||
*.pyc | ||
*.swp | ||
|
||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### macOS Patch ### | ||
# iCloud generated files | ||
*.icloud | ||
|
||
### VisualStudioCode ### | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
!.vscode/*.code-snippets | ||
|
||
# Local History for Visual Studio Code | ||
.history/ | ||
|
||
# Built Visual Studio Code Extensions | ||
*.vsix | ||
|
||
### VisualStudioCode Patch ### | ||
# Ignore all local history of files | ||
.history | ||
.ionide | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/deno,visualstudiocode,macos |
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,20 @@ | ||
# License | ||
|
||
Copyright 2023 Benjamin Laird | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the “Software”), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,39 @@ | ||
# Pluriverity | ||
|
||
A library dedicated to programming the unknown! Pluriverity got its name from | ||
the Latin "plures veritates", meaning "several truths"; as such, this library | ||
aims to enhance working with TypeScript enums by providing utility functions | ||
aimed at handling things that could be in one of several states. | ||
|
||
## Features | ||
|
||
- Performant | ||
- Great DX | ||
|
||
## Installation | ||
|
||
Using a package manager like `npm`: | ||
|
||
```sh | ||
npm install pluriverity | ||
``` | ||
|
||
```ts | ||
import { p } from "pluriverity"; | ||
``` | ||
|
||
Using Deno: | ||
|
||
```ts | ||
import { p } from "https://deno.land/x/pluriverity/mod.ts"; | ||
``` | ||
|
||
## Usage and Patterns | ||
|
||
## Support | ||
|
||
If you like this library, thanks so much! I'm glad to make something people like | ||
using. If you _really_ like it and want to support me, star this library on | ||
[GitHub](https://github.com/ben-laird/pluriverity) or | ||
[buy me a coffee](https://www.buymeacoffee.com/benlaird). Any | ||
support/encouragement is greatly appreciated! |
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,5 @@ | ||
{ | ||
"tasks": { | ||
"build": "deno run -A scripts/build/npm.dnt.config.ts" | ||
} | ||
} |
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 @@ | ||
export * from "./src/index.ts"; |
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,49 @@ | ||
import { build, emptyDir } from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
||
const outDir = "./build"; | ||
|
||
await emptyDir(outDir); | ||
|
||
await build({ | ||
entryPoints: ["./src/index.ts"], | ||
outDir, | ||
package: { | ||
name: "yatabl", | ||
version: Deno.args[0], | ||
description: | ||
"Yet another tagging and branding library. Safety, dx, and perf conscious!", | ||
keywords: [ | ||
"yatabl", | ||
"tagging", | ||
"branding", | ||
"validation", | ||
"safe", | ||
"safety", | ||
"schema validation", | ||
"schema", | ||
], | ||
license: "MIT", | ||
repository: { | ||
type: "git", | ||
url: "git+https://github.com/ben-laird/yatabl.git", | ||
}, | ||
bugs: { | ||
url: "https://github.com/ben-laird/yatabl/issues", | ||
}, | ||
}, | ||
postBuild() { | ||
copyToOutDir("LICENSE.md"); | ||
copyToOutDir("README.md"); | ||
}, | ||
|
||
scriptModule: "cjs", | ||
packageManager: "pnpm", | ||
shims: { | ||
// see JS docs for overview and more options | ||
deno: true, | ||
}, | ||
}); | ||
|
||
function copyToOutDir(path: string) { | ||
Deno.copyFileSync(path, `${outDir}/${path}`); | ||
} |
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 @@ | ||
export * from "./lib.types.ts"; |
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,5 @@ | ||
export * from "./index.staging.ts"; | ||
|
||
import * as p from "./index.staging.ts"; | ||
export { p }; | ||
export default p; |
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 @@ | ||
import * as Types from "./lib.types.ts"; |
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,46 @@ | ||
// deno-lint-ignore-file no-namespace | ||
|
||
export type Attach<T extends Constraint.Dict> = Attach.Dict<T>; | ||
export namespace Attach { | ||
type Determine<T extends Identifier, U = unknown> = unknown extends U | ||
? { type: T } | ||
: { type: T; value: U }; | ||
|
||
type TupleDetermine<T extends Identifier, U = unknown> = unknown extends U | ||
? [type: T] | ||
: [type: T, value: U]; | ||
|
||
export type XOR<T extends Constraint.Dict> = { | ||
[K in keyof T]: { [L in K]: T[K] }; | ||
}[keyof T]; | ||
|
||
export type Enum< | ||
T extends Constraint.Enum, | ||
U extends Partial<Record<keyof T, unknown>>, | ||
> = { | ||
[K in keyof T]: Determine<T[K], U[K]>; | ||
}[keyof T]; | ||
|
||
export type Dict<T extends Constraint.Dict> = { | ||
[K in keyof T]: Determine<K, T[K]>; | ||
}[keyof T]; | ||
|
||
export type DictTuple<T extends Constraint.Dict> = { | ||
[K in keyof T]: TupleDetermine<K, T[K]>; | ||
}[keyof T]; | ||
|
||
export type EnumTuple< | ||
T extends Constraint.Enum, | ||
U extends Partial<Record<keyof T, unknown>>, | ||
> = { | ||
[K in keyof T]: TupleDetermine<T[K], U[K]>; | ||
}[keyof T]; | ||
} | ||
|
||
export type Key = string | number | symbol; | ||
export type Identifier = Key | boolean | null | undefined; | ||
|
||
export namespace Constraint { | ||
export type Enum = Record<string, string | number>; | ||
export type Dict = Record<Key, unknown>; | ||
} |