From 76cda56bea10efbea0794f32e471db127c90eec5 Mon Sep 17 00:00:00 2001 From: Shigma Date: Wed, 13 Dec 2023 01:15:01 +0800 Subject: [PATCH] chore: migrate to yakumo v1 & node:test --- package.json | 20 +++++++------------- packages/core/package.json | 2 +- packages/core/tests/array.spec.ts | 5 +++-- packages/core/tests/bitset.spec.ts | 7 ++++--- packages/core/tests/date.spec.ts | 3 ++- packages/core/tests/dict.spec.ts | 5 +++-- packages/core/tests/i18n.spec.ts | 3 ++- packages/core/tests/index.spec.ts | 17 +++++++++-------- packages/core/tests/intersect.spec.ts | 13 +++++++------ packages/core/tests/misc.spec.ts | 5 +++-- packages/core/tests/number.spec.ts | 7 ++++--- packages/core/tests/object.spec.ts | 3 ++- packages/core/tests/simplify.spec.ts | 3 ++- packages/core/tests/string.spec.ts | 7 ++++--- packages/core/tests/transform.spec.ts | 13 +++++++------ packages/core/tests/tuple.spec.ts | 3 ++- packages/core/tests/union.spec.ts | 7 ++++--- packages/form/package.json | 4 ++-- yakumo.yml | 8 ++++++++ 19 files changed, 76 insertions(+), 59 deletions(-) create mode 100644 yakumo.yml diff --git a/package.json b/package.json index 785f7f9..849b2ca 100644 --- a/package.json +++ b/package.json @@ -17,32 +17,26 @@ "bump": "yakumo version", "dep": "yakumo upgrade", "pub": "yakumo publish", - "test": "yakumo mocha -r esbuild-register core", + "test": "yakumo test -r esbuild-register core", "test:json": "shx rm -rf coverage && c8 -r json yarn test", "test:html": "shx rm -rf coverage && c8 -r html yarn test", "test:text": "shx rm -rf coverage && c8 -r text yarn test" }, "devDependencies": { - "@types/chai": "^4.3.9", - "@types/mocha": "^9.1.1", - "@types/node": "^20.8.9", + "@types/chai": "^4.3.11", + "@types/node": "^20.10.2", "c8": "^7.14.0", "chai": "^4.3.10", "element-plus": "2.4.0", "esbuild": "^0.18.20", "esbuild-register": "^3.5.0", "marked-vue": "^1.2.3", - "mocha": "^9.2.2", "serve": "^13.0.4", "shx": "^0.3.4", - "typescript": "^5.2.2", + "typescript": "^5.3.2", "vitepress": "1.0.0-rc.24", - "yakumo": "^0.3.13", - "yakumo-esbuild": "^0.3.26", - "yakumo-mocha": "^0.3.1", - "yakumo-publish": "^0.3.5", - "yakumo-tsc": "^0.3.12", - "yakumo-upgrade": "^0.3.4", - "yakumo-version": "^0.3.4" + "yakumo": "^1.0.0-alpha.3", + "yakumo-esbuild": "^1.0.0-alpha.0", + "yakumo-tsc": "^1.0.0-alpha.1" } } diff --git a/packages/core/package.json b/packages/core/package.json index 37cc6ef..55b8657 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "schemastery", "description": "Type driven schema validator", - "version": "3.14.1", + "version": "3.14.2", "main": "lib/index.cjs", "module": "lib/index.mjs", "typings": "lib/index.d.ts", diff --git a/packages/core/tests/array.spec.ts b/packages/core/tests/array.spec.ts index 5a8b03c..27cd139 100644 --- a/packages/core/tests/array.spec.ts +++ b/packages/core/tests/array.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Array', () => { - it('array', () => { + test('array', () => { const Config = Schema.array(String) expect(Config.toString()).to.equal('string[]') @@ -17,7 +18,7 @@ describe('Array', () => { expect(() => new Config([0])).to.throw() }) - it('array (length)', () => { + test('array (length)', () => { const Config = Schema.array(String).min(2).max(3) expect(new Config(['dress', 'skirt'])).to.deep.equal(['dress', 'skirt']) diff --git a/packages/core/tests/bitset.spec.ts b/packages/core/tests/bitset.spec.ts index ce53382..e316869 100644 --- a/packages/core/tests/bitset.spec.ts +++ b/packages/core/tests/bitset.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Bitset', () => { - it('basic usage', () => { + test('basic usage', () => { const validate = Schema.bitset({ a: 1, b: 2, c: 4 }) expect(validate()).to.equal(0) @@ -17,7 +18,7 @@ describe('Bitset', () => { expect(() => validate('a')).to.throw() }) - it('enumeration support', () => { + test('enumeration support', () => { enum Foo { a = 1, b = 2, @@ -34,7 +35,7 @@ describe('Bitset', () => { expect(() => validate('a')).to.throw() }) - it('transform', () => { + test('transform', () => { const validate = Schema.object({ foo: Schema.bitset({ a: 1, b: 2, c: 4 }), }) diff --git a/packages/core/tests/date.spec.ts b/packages/core/tests/date.spec.ts index 12b7417..8982921 100644 --- a/packages/core/tests/date.spec.ts +++ b/packages/core/tests/date.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Date', () => { - it('date', () => { + test('date', () => { const Config = Schema.object({ date: Schema.date(), }) diff --git a/packages/core/tests/dict.spec.ts b/packages/core/tests/dict.spec.ts index 2a24313..6530389 100644 --- a/packages/core/tests/dict.spec.ts +++ b/packages/core/tests/dict.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Dictionary', () => { - it('dict (basic)', () => { + test('dict (basic)', () => { const Config = Schema.dict(RegExp) expect(Config.toString()).to.equal('{ [key: string]: RegExp }') @@ -19,7 +20,7 @@ describe('Dictionary', () => { expect(() => new Config({ a: '' })).to.throw() }) - it('dict (key schema)', () => { + test('dict (key schema)', () => { const validate = Schema.dict(Number, Schema.union([ 'foo' as const, Schema.transform('bar' as const, () => 'foo' as const), diff --git a/packages/core/tests/i18n.spec.ts b/packages/core/tests/i18n.spec.ts index 98ffaf5..ba3b8c1 100644 --- a/packages/core/tests/i18n.spec.ts +++ b/packages/core/tests/i18n.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('I18n', () => { - it('basic support', () => { + test('basic support', () => { const schema = Schema.intersect([ Schema.object({ enabled: Schema.boolean().default(false), diff --git a/packages/core/tests/index.spec.ts b/packages/core/tests/index.spec.ts index 584fc9b..49b520f 100644 --- a/packages/core/tests/index.spec.ts +++ b/packages/core/tests/index.spec.ts @@ -1,15 +1,16 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Schema API', () => { - it('unknown', () => { + test('unknown', () => { const validate1 = new Schema({ type: 'unknown' }) expect(() => validate1(0)).to.throw() expect(() => Schema.array(Symbol('unknown'))).to.throw() }) - it('any', () => { + test('any', () => { const config = Schema.any() expect(config.toString()).to.equal('any') @@ -17,7 +18,7 @@ describe('Schema API', () => { expect(config(null)).to.equal(null) }) - it('never', () => { + test('never', () => { const config = Schema.never() expect(config.toString()).to.equal('never') @@ -26,7 +27,7 @@ describe('Schema API', () => { expect(() => config(123)).to.throw() }) - it('number', () => { + test('number', () => { const config = Schema.number().min(1).step(2).default(123) expect(config.toString()).to.equal('number') @@ -39,7 +40,7 @@ describe('Schema API', () => { expect(() => config(456)).to.throw() }) - it('boolean', () => { + test('boolean', () => { const config = Schema.boolean().default(true) expect(config.toString()).to.equal('boolean') @@ -51,7 +52,7 @@ describe('Schema API', () => { expect(() => config(1)).to.throw() }) - it('function', () => { + test('function', () => { const config = Schema.function() expect(config.toString()).to.equal('function') @@ -62,7 +63,7 @@ describe('Schema API', () => { expect(() => config(1)).to.throw() }) - it('is', () => { + test('is', () => { const config = Schema.is(RegExp) expect(config.toString()).to.equal('RegExp') @@ -74,7 +75,7 @@ describe('Schema API', () => { expect(() => config('1')).to.throw() }) - it('loose', () => { + test('loose', () => { const config = Schema.object({ foo: Schema.union([1, 2, 3]).loose().default(1), bar: Schema.union([1, 2, 3]), diff --git a/packages/core/tests/intersect.spec.ts b/packages/core/tests/intersect.spec.ts index 0490f9e..6842e91 100644 --- a/packages/core/tests/intersect.spec.ts +++ b/packages/core/tests/intersect.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Intersect', () => { - it('intersect (primitive 1)', () => { + test('intersect (primitive 1)', () => { const validate = Schema.intersect([String, Number]) expect(validate.toString()).to.equal('string & number') @@ -13,7 +14,7 @@ describe('Intersect', () => { expect(() => validate(123)).to.throw() }) - it('intersect (primitive 2)', () => { + test('intersect (primitive 2)', () => { const validate = Schema.intersect([String, 'foo']) expect(validate.toString()).to.equal('string & "foo"') @@ -23,7 +24,7 @@ describe('Intersect', () => { expect(() => validate('bar')).to.throw() }) - it('intersect (object)', () => { + test('intersect (object)', () => { const validate = Schema.intersect([ Schema.object({ a: Schema.string().default('foo') }), Schema.object({ b: Schema.number().required() }), @@ -38,7 +39,7 @@ describe('Intersect', () => { expect(() => validate({ b: '' })).to.throw() }) - it('intersect (nested)', () => { + test('intersect (nested)', () => { const validate = Schema.intersect([ Schema.intersect([ Schema.object({ a: Schema.string() }), @@ -57,7 +58,7 @@ describe('Intersect', () => { expect(() => validate({ c: '' })).to.throw() }) - it('intersect (tagged union)', () => { + test('intersect (tagged union)', () => { // https://github.com/shigma/schemastery/issues/31 const validate = Schema.intersect([ Schema.object({ e: Schema.boolean().default(true) }), @@ -76,7 +77,7 @@ describe('Intersect', () => { expect(validate(null)).to.deep.equal({ e: true, x: 114 }) }) - it('intersect (shared default)', () => { + test('intersect (shared default)', () => { // https://github.com/shigma/schemastery/issues/45 const validate = Schema.intersect([ Schema.object({ diff --git a/packages/core/tests/misc.spec.ts b/packages/core/tests/misc.spec.ts index c8dfd9c..4bc78f0 100644 --- a/packages/core/tests/misc.spec.ts +++ b/packages/core/tests/misc.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Miscellaneous', () => { - it('serialization (basic)', () => { + test('serialization (basic)', () => { const Number = Schema.number() const validate = new Schema(JSON.parse(JSON.stringify(Number))) @@ -11,7 +12,7 @@ describe('Miscellaneous', () => { expect(() => validate('0')).to.throw() }) - it('serialization (recursive)', () => { + test('serialization (recursive)', () => { const Node = Schema.object({ id: Number }) Node.set('children', Schema.array(Node)) const validate = new Schema(JSON.parse(JSON.stringify(Node))) diff --git a/packages/core/tests/number.spec.ts b/packages/core/tests/number.spec.ts index 6006bb4..ef13c32 100644 --- a/packages/core/tests/number.spec.ts +++ b/packages/core/tests/number.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Number', () => { - it('number', () => { + test('number', () => { const config = Schema.number().default(42) expect(config.toString()).to.equal('number') @@ -14,7 +15,7 @@ describe('Number', () => { expect(() => config('42')).to.throw() }) - it('number (range)', () => { + test('number (range)', () => { // https://github.com/shigma/schemastery/issues/44 const config = Schema.number().min(1).max(3).step(0.1) expect(config(1)).to.equal(1) @@ -25,7 +26,7 @@ describe('Number', () => { expect(() => config(2.718)).to.throw() }) - it('number (decimal)', () => { + test('number (decimal)', () => { // https://github.com/shigma/schemastery/issues/44 const config = Schema.number().min(-1).max(0).step(0.01) expect(config(-0.55)).to.equal(-0.55) diff --git a/packages/core/tests/object.spec.ts b/packages/core/tests/object.spec.ts index 6968a62..bac97c9 100644 --- a/packages/core/tests/object.spec.ts +++ b/packages/core/tests/object.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Object', () => { - it('basic support', () => { + test('basic support', () => { const Config = Schema.object({ a: Schema.string().required(), b: Schema.number().default(123), diff --git a/packages/core/tests/simplify.spec.ts b/packages/core/tests/simplify.spec.ts index 671ae56..3b840f6 100644 --- a/packages/core/tests/simplify.spec.ts +++ b/packages/core/tests/simplify.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Simplify', () => { - it('basic support', () => { + test('basic support', () => { const schema = Schema.intersect([ Schema.object({ a: Schema.string().default('a'), diff --git a/packages/core/tests/string.spec.ts b/packages/core/tests/string.spec.ts index c478a09..74c6a0b 100644 --- a/packages/core/tests/string.spec.ts +++ b/packages/core/tests/string.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('String', () => { - it('string', () => { + test('string', () => { const config = Schema.string().default('bar') expect(config.toString()).to.equal('string') @@ -14,7 +15,7 @@ describe('String', () => { expect(() => config(123)).to.throw() }) - it('string (length)', () => { + test('string (length)', () => { const config = Schema.string().min(5).max(6) expect(config('dress')).to.equal('dress') @@ -22,7 +23,7 @@ describe('String', () => { expect(() => config('uniform')).to.throw() }) - it('string (pattern)', () => { + test('string (pattern)', () => { const config = Schema.string().pattern(/^[a-z]+$/i) expect(config('dress')).to.equal('dress') expect(config('SKIRT')).to.equal('SKIRT') diff --git a/packages/core/tests/transform.spec.ts b/packages/core/tests/transform.spec.ts index fcc3328..d703afd 100644 --- a/packages/core/tests/transform.spec.ts +++ b/packages/core/tests/transform.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Transform', () => { - it('transform with array', () => { + test('transform with array', () => { const Config = Schema.array(Schema.union([ String, Schema.transform(Number, data => data.toString()), @@ -20,7 +21,7 @@ describe('Transform', () => { expect(() => new Config([{}])).to.throw() }) - it('transform with object', () => { + test('transform with object', () => { const Config = Schema.object({ foo: Schema.union([ Schema.array(Number), @@ -43,7 +44,7 @@ describe('Transform', () => { expect(() => new Config({ foo: [''] })).to.throw() }) - it.skip('transform with intersect', () => { + test.skip('transform with intersect', () => { const Inner = Schema.object({ a: Schema.number().required(), d: Schema.number().default(0), @@ -72,7 +73,7 @@ describe('Transform', () => { expect(() => new Config({ a: 1, c: 'foo' })).to.throw() }) - it('recursive adaptive structure', () => { + test('recursive adaptive structure', () => { const original = Schema.object({ id: Number }) const validate = Schema.union([ original, @@ -87,7 +88,7 @@ describe('Transform', () => { expect(() => validate({ id: 1, children: {} })).to.throw() }) - it('adaptive root', () => { + test('adaptive root', () => { const original = Schema.object({ bar: Schema.boolean().default(false), id: Schema.never(), @@ -110,7 +111,7 @@ describe('Transform', () => { expect(root).to.deep.equal({ foo: { id: 1 } }) }) - it('autofix', () => { + test('autofix', () => { const validate = Schema.object({ foo: Schema.number().default(0), }) diff --git a/packages/core/tests/tuple.spec.ts b/packages/core/tests/tuple.spec.ts index cc3d1f7..41ece95 100644 --- a/packages/core/tests/tuple.spec.ts +++ b/packages/core/tests/tuple.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Tuple', () => { - it('basic support', () => { + test('basic support', () => { const Config = Schema.tuple([ Schema.string().required(), Schema.number().default(123), diff --git a/packages/core/tests/union.spec.ts b/packages/core/tests/union.spec.ts index 0945741..89bdebb 100644 --- a/packages/core/tests/union.spec.ts +++ b/packages/core/tests/union.spec.ts @@ -1,8 +1,9 @@ +import { describe, test } from 'node:test' import { expect } from 'chai' import Schema from 'schemastery' describe('Union', () => { - it('primitive', () => { + test('primitive', () => { const config = Schema.union([1, 2]) expect(config.toString()).to.equal('1 | 2') @@ -13,7 +14,7 @@ describe('Union', () => { expect(() => config('1')).to.throw() }) - it('object', () => { + test('object', () => { const validate = Schema.union([ Schema.object({ a: 'foo', b: Schema.number() }), Schema.object({ a: 'bar', c: Schema.string() }), @@ -29,7 +30,7 @@ describe('Union', () => { expect(() => validate({ c: 'x' })).to.throw() }) - it('default', () => { + test('default', () => { const validate = Schema.union([ Schema.object({ a: 'foo', b: Schema.number().default(123) }), Schema.object({ a: 'bar', b: Schema.number().default(456) }), diff --git a/packages/form/package.json b/packages/form/package.json index 2d2b64a..d5db7e1 100644 --- a/packages/form/package.json +++ b/packages/form/package.json @@ -1,7 +1,7 @@ { "name": "schemastery-vue", "description": "Type driven schema validator", - "version": "7.1.5", + "version": "7.2.0", "main": "src/index.ts", "files": [ "src" @@ -23,6 +23,6 @@ "vue": "^3" }, "dependencies": { - "schemastery": "^3.14.1" + "schemastery": "^3.14.2" } } diff --git a/yakumo.yml b/yakumo.yml new file mode 100644 index 0000000..ee9a2ce --- /dev/null +++ b/yakumo.yml @@ -0,0 +1,8 @@ +- name: yakumo + config: + pipeline: + build: + - tsc + - esbuild +- name: yakumo-esbuild +- name: yakumo-tsc