Skip to content
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
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
dist
node_modules
dist
transpiled
*.js
27 changes: 0 additions & 27 deletions .github/workflows/build.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .github/workflows/bump.yaml → .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- "master"
jobs:
bump-version:
name: "Bump Version"
name: "Bump version on master"
timeout-minutes: 60
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci: version bump to ')"
Expand All @@ -21,6 +21,8 @@ jobs:
with:
node-version: current
cache: 'npm'
- name: Update NPM
run: npm install -g npm
- name: "Version Bump"
id: version-bump
uses: "phips28/gh-action-bump-version@master"
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
pull_request:

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.10.0
cache: 'npm'
- run: npm install
- run: npm run build
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.10.0
cache: 'npm'
- run: npm install
- run: npm run test
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.10.0
cache: 'npm'
- run: npm install
- run: npm run lint
audit:
name: Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: current
cache: 'npm'
- run: npm audit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- "release-*"
jobs:
publish:
name: "Publish"
name: "Publish from master"
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
Expand All @@ -17,10 +17,8 @@ jobs:
with:
node-version: current
cache: 'npm'
- uses: actions/cache@v3
with:
path: '**/node_modules'
key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: Update NPM
run: npm install -g npm
- name: Install
run: npm install
- name: Build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
dist
.env
.npmrc
coverage/
49 changes: 43 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,72 @@
{
"files.exclude": {
".*": true,
".sh": true,
"*.sh": true,
"*.json": true,
"CODEOWNERS": true,
"dist": true,
"README.md": true,
"LICENSE": true,
"tsconfig.*": true,
"node_modules": true,
"*.code-workspace": true
"*.code-workspace": true,
"*.config.ts": true,
"coverage": true
},
"search.exclude": {
".*": false,
"*.sh": false,
"*.json": false,
"CODEOWNERS": false,
"dist": false,
"README.md": false,
"LICENSE": false,
"tsconfig.*": false,
"node_modules": false,
"*.code-workspace": false,
"*.config.ts": false,
"coverage": false
},
"files.insertFinalNewline": true,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"eslint.autoFixOnSave": "explicit"
},
"files.insertFinalNewline": true,
"eslint.format.enable": true,
"eslint.lintTask.enable": true,
"javascript.format.enable": false,
"typescript.format.enable": false,
"cSpell.words": [
"authly",
"cloudly",
"cogneco",
"completor",
"Completor",
"criterias",
"cryptly",
"flagly",
"gracely",
"isly",
"isoly",
"langly",
"nand",
"paramly",
"persistly",
"prettierx",
"utily"
]
"Renamer",
"selectivly",
"servly",
"servly-azure",
"smoothly",
"tidily",
"transactly",
"typedly",
"uply",
"Utily"
],
"typescript.tsdk": "node_modules/typescript/lib"
}
31 changes: 4 additions & 27 deletions And.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,16 @@ describe("and", () => {
expect(selectively.and("test", { type: "type" })).toMatchObject({
class: "And",
rules: [
{
class: "Is",
value: "test",
},
{
class: "Property",
criteria: {
class: "Is",
value: "type",
},
name: "type",
},
{ class: "Is", value: "test" },
{ class: "Property", criteria: { class: "Is", value: "type" }, name: "type" },
],
}))
it("generalize", () =>
expect(selectively.and("test", { type: "type" }).generalize()).toMatchObject({
class: "And",
rules: [
{
class: "Any",
criteria: {
class: "Is",
value: "test",
},
},
{
class: "Property",
criteria: {
class: "Is",
value: "type",
},
name: "type",
},
{ class: "Any", criteria: { class: "Is", value: "test" } },
{ class: "Property", criteria: { class: "Is", value: "type" }, name: "type" },
],
}))
})
2 changes: 1 addition & 1 deletion Not.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Type } from "./Type"
import { Completor } from "./Type/Completor"

export class Not extends Rule {
static readonly precedence = 90
readonly precedence = Not.precedence
readonly class = "Not"
constructor(readonly criteria: Rule) {
Expand All @@ -16,7 +17,6 @@ export class Not extends Rule {
toString(): string {
return `!${this.criteria.stringify(this.precedence)}`
}
static readonly precedence = 90
}
export function not(criteria: Criteria): Not
export function not(criteria: Criteria, value: any): boolean
Expand Down
2 changes: 1 addition & 1 deletion Or.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { create, Rule } from "./Rule"
import { Type } from "./Type"

export class Or extends Rule {
static readonly precedence = 30
readonly precedence = Or.precedence
readonly class = "Or"
readonly criteria: Rule[]
Expand All @@ -17,7 +18,6 @@ export class Or extends Rule {
toString() {
return this.criteria.map(c => c.stringify(this.precedence)).join(" | ")
}
static readonly precedence = 30
}
export function or(...criterias: Criteria[]): Or {
return new Or(criterias.map(create))
Expand Down
2 changes: 1 addition & 1 deletion Property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Criteria } from "./Criteria"
import { add, create, Rule } from "./Rule"

export class Property extends Rule {
static readonly precedence = 80
readonly precedence = Property.precedence
readonly class = "Property"
readonly symbol = "."
Expand All @@ -21,7 +22,6 @@ export class Property extends Rule {
this.criteria?.stringify(this.precedence) ?? ""
}`
}
static readonly precedence = 80
}
export function property(name: string | string[], criteria: Criteria): Property
export function property(name: string | string[], criteria: Criteria, value: any): boolean
Expand Down
2 changes: 1 addition & 1 deletion Type/Array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Array extends Base {
}

isType(value: any): boolean {
return global.Array.isArray(value)
return globalThis.Array.isArray(value)
}
private static readonly completor: Completor<Base>[] = []
static add(...pattern: Completor<Base>[]) {
Expand Down
1 change: 0 additions & 1 deletion Type/Boolean.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-types */
import { Token } from "../lexer"
import { Base as SType } from "./Base"
import { Completion } from "./Completion"
Expand Down
3 changes: 1 addition & 2 deletions Type/Number.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-types */
import { Token } from "../lexer"
import { Base as SType } from "./Base"
import { Completion } from "./Completion"
Expand Down Expand Up @@ -43,6 +42,6 @@ export class Number extends SType {
this.completorArgument.push(...pattern)
}
static is(value: any | Number): value is Number {
return value instanceof Number || !global.Number.isNaN(value)
return value instanceof Number || !globalThis.Number.isNaN(value)
}
}
1 change: 0 additions & 1 deletion Type/String.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-types */
import { Token } from "../lexer"
import { Base as SType } from "./Base"
import { Completion } from "./Completion"
Expand Down
4 changes: 2 additions & 2 deletions Type/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export namespace Type {
let result: Base
switch (typeof value) {
case "object":
result = global.Array.isArray(value)
result = globalThis.Array.isArray(value)
? new TArray(value.map(e => convert(e)))
: new TObject(
global.Object.entries(value).reduce((r, c) => {
globalThis.Object.entries(value).reduce((r, c) => {
return { ...r, [c[0]]: convert(c[1]) }
}, {})
)
Expand Down
2 changes: 1 addition & 1 deletion Value.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Expression } from "./Expression"

export class Value extends Expression {
static readonly precedence = 19
readonly precedence = Value.precedence
readonly class = "Value"
readonly value: Value | string | number
Expand All @@ -11,7 +12,6 @@ export class Value extends Expression {
else
this.value = value
}
static readonly precedence = 19
toString(): string {
return this.name ? `${this.name?.toString()}.` + this.value.toString() : this.value.toString()
}
Expand Down
Loading
Loading