From 67dc5a2d3906e1c1f2088ddf3b2f61cc26de31af Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Fri, 7 Aug 2020 17:18:44 +0900 Subject: [PATCH 01/13] require fp-ts 2.8.0 --- package-lock.json | 8 ++++---- package.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 54bfa98..df3985e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "io-ts-types", - "version": "0.5.7", + "version": "0.5.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2004,9 +2004,9 @@ } }, "fp-ts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-2.0.0.tgz", - "integrity": "sha512-oz8L+EZiztqGVLhgdL+63b4hpfdJkEKH/4vRoS/AuUwYqmn7vHAzWMu1jtoYfB0pPxo5UioWVT2XOuftyivUSQ==", + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-2.8.1.tgz", + "integrity": "sha512-HuA/6roEliHoBgEOLCKmGRcM90e2trW/ITZZ9d9P/ra7PreqQagC3Jg6OzqWkai13KUbG90b8QO9rHPBGK/ckw==", "dev": true }, "fragment-cache": { diff --git a/package.json b/package.json index d2dea5d..455d17b 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ }, "homepage": "https://github.com/gcanti/io-ts-types", "peerDependencies": { - "fp-ts": "^2.0.0", + "fp-ts": "^2.8.0", "io-ts": "^2.0.0", "monocle-ts": "^2.0.0", "newtype-ts": "^0.3.2" @@ -45,7 +45,7 @@ "@types/node": "7.0.4", "docs-ts": "^0.3.4", "dtslint": "github:gcanti/dtslint", - "fp-ts": "^2.0.0", + "fp-ts": "^2.8.0", "import-path-rewrite": "github:gcanti/import-path-rewrite", "io-ts": "^2.0.0", "jest": "^24.8.0", From 6fbfbe485ab842f78e68354550e758cda6fafa12 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Fri, 7 Aug 2020 17:19:14 +0900 Subject: [PATCH 02/13] use bare fp-ts import everywhere --- docs/modules/DateFromISOString.ts.md | 2 +- docs/modules/DateFromNumber.ts.md | 2 +- docs/modules/DateFromUnixTime.ts.md | 2 +- docs/modules/IntFromString.ts.md | 2 +- docs/modules/NonEmptyString.ts.md | 2 +- docs/modules/UUID.ts.md | 2 +- docs/modules/either.ts.md | 2 +- docs/modules/fromNewtype.ts.md | 2 +- docs/modules/fromNullable.ts.md | 2 +- docs/modules/mapOutput.ts.md | 2 +- docs/modules/option.ts.md | 4 ++-- docs/modules/regexp.ts.md | 2 +- docs/modules/withFallback.ts.md | 2 +- docs/modules/withMessage.ts.md | 2 +- docs/modules/withValidate.ts.md | 2 +- dtslint/ts3.5/index.ts | 2 +- dtslint/ts3.5/readonlySetFromArray.ts | 2 +- src/BooleanFromString.ts | 2 +- src/DateFromISOString.ts | 4 ++-- src/DateFromNumber.ts | 4 ++-- src/DateFromUnixTime.ts | 4 ++-- src/IntFromString.ts | 4 ++-- src/NonEmptyString.ts | 2 +- src/NumberFromString.ts | 2 +- src/UUID.ts | 2 +- src/either.ts | 4 ++-- src/fromNewtype.ts | 4 ++-- src/fromNullable.ts | 2 +- src/mapOutput.ts | 2 +- src/nonEmptyArray.ts | 8 ++++---- src/option.ts | 6 +++--- src/optionFromNullable.ts | 4 ++-- src/readonlySetFromArray.ts | 2 +- src/regexp.ts | 2 +- src/setFromArray.ts | 6 +++--- src/withFallback.ts | 4 ++-- src/withMessage.ts | 4 ++-- src/withValidate.ts | 2 +- test/DateFromNumber.ts | 2 +- test/DateFromUnixTime.ts | 2 +- test/either.ts | 2 +- test/helpers.ts | 2 +- test/nonEmptyArray.ts | 2 +- test/option.ts | 2 +- test/optionFromNullable.ts | 2 +- test/readonlyNonEmptyArray.ts | 2 +- test/readonlySetFromArray.ts | 2 +- test/setFromArray.ts | 2 +- 48 files changed, 65 insertions(+), 65 deletions(-) diff --git a/docs/modules/DateFromISOString.ts.md b/docs/modules/DateFromISOString.ts.md index c21cab4..7cc930a 100644 --- a/docs/modules/DateFromISOString.ts.md +++ b/docs/modules/DateFromISOString.ts.md @@ -39,7 +39,7 @@ export const DateFromISOString: DateFromISOStringC = ... ```ts import { DateFromISOString } from 'io-ts-types/lib/DateFromISOString' -import { right } from 'fp-ts/lib/Either' +import { right } from 'fp-ts/Either' const date = new Date(1973, 10, 30) const input = date.toISOString() diff --git a/docs/modules/DateFromNumber.ts.md b/docs/modules/DateFromNumber.ts.md index b8dece6..7a16c31 100644 --- a/docs/modules/DateFromNumber.ts.md +++ b/docs/modules/DateFromNumber.ts.md @@ -39,7 +39,7 @@ export const DateFromNumber: DateFromNumberC = ... ```ts import { DateFromNumber } from 'io-ts-types/lib/DateFromNumber' -import { right } from 'fp-ts/lib/Either' +import { right } from 'fp-ts/Either' const date = new Date(1973, 10, 30) const input = date.getTime() diff --git a/docs/modules/DateFromUnixTime.ts.md b/docs/modules/DateFromUnixTime.ts.md index 6c1ba14..fd91425 100644 --- a/docs/modules/DateFromUnixTime.ts.md +++ b/docs/modules/DateFromUnixTime.ts.md @@ -39,7 +39,7 @@ export const DateFromUnixTime: DateFromUnixTimeC = ... ```ts import { DateFromUnixTime } from 'io-ts-types/lib/DateFromUnixTime' -import { right } from 'fp-ts/lib/Either' +import { right } from 'fp-ts/Either' const date = new Date(1973, 10, 30) const input = date.getTime() / 1000 diff --git a/docs/modules/IntFromString.ts.md b/docs/modules/IntFromString.ts.md index 028c485..e8a9572 100644 --- a/docs/modules/IntFromString.ts.md +++ b/docs/modules/IntFromString.ts.md @@ -41,7 +41,7 @@ export const IntFromString: IntFromStringC = ... ```ts import { IntFromString } from 'io-ts-types/lib/IntFromString' -import { right } from 'fp-ts/lib/Either' +import { right } from 'fp-ts/Either' import { PathReporter } from 'io-ts/lib/PathReporter' assert.deepStrictEqual(IntFromString.decode('1'), right(1)) diff --git a/docs/modules/NonEmptyString.ts.md b/docs/modules/NonEmptyString.ts.md index 30750f2..1a46be7 100644 --- a/docs/modules/NonEmptyString.ts.md +++ b/docs/modules/NonEmptyString.ts.md @@ -65,7 +65,7 @@ export const NonEmptyString: NonEmptyStringC = ... ```ts import { NonEmptyString } from 'io-ts-types/lib/NonEmptyString' -import { right } from 'fp-ts/lib/Either' +import { right } from 'fp-ts/Either' import { PathReporter } from 'io-ts/lib/PathReporter' assert.deepStrictEqual(NonEmptyString.decode('a'), right('a')) diff --git a/docs/modules/UUID.ts.md b/docs/modules/UUID.ts.md index e1e96fb..4b3283f 100644 --- a/docs/modules/UUID.ts.md +++ b/docs/modules/UUID.ts.md @@ -52,7 +52,7 @@ export const UUID: t.BrandC = ... ```ts import { UUID } from 'io-ts-types/lib/UUID' -import { right } from 'fp-ts/lib/Either' +import { right } from 'fp-ts/Either' import { PathReporter } from 'io-ts/lib/PathReporter' assert.deepStrictEqual( diff --git a/docs/modules/either.ts.md b/docs/modules/either.ts.md index a5bb167..b9bdee0 100644 --- a/docs/modules/either.ts.md +++ b/docs/modules/either.ts.md @@ -47,7 +47,7 @@ export function either( ```ts import { either } from 'io-ts-types/lib/either' -import { left, right } from 'fp-ts/lib/Either' +import { left, right } from 'fp-ts/Either' import * as t from 'io-ts' import { PathReporter } from 'io-ts/lib/PathReporter' diff --git a/docs/modules/fromNewtype.ts.md b/docs/modules/fromNewtype.ts.md index 153593b..1d389f8 100644 --- a/docs/modules/fromNewtype.ts.md +++ b/docs/modules/fromNewtype.ts.md @@ -34,7 +34,7 @@ export function fromNewtype( ```ts import { fromNewtype } from 'io-ts-types/lib/fromNewtype' import * as t from 'io-ts' -import { right } from 'fp-ts/lib/Either' +import { right } from 'fp-ts/Either' import { PathReporter } from 'io-ts/lib/PathReporter' import { Newtype, iso } from 'newtype-ts' diff --git a/docs/modules/fromNullable.ts.md b/docs/modules/fromNullable.ts.md index b239109..08febd8 100644 --- a/docs/modules/fromNullable.ts.md +++ b/docs/modules/fromNullable.ts.md @@ -31,7 +31,7 @@ export function fromNullable(codec: C, a: t.TypeOf, name = ```ts import { fromNullable } from 'io-ts-types/lib/fromNullable' import * as t from 'io-ts' -import { right } from 'fp-ts/lib/Either' +import { right } from 'fp-ts/Either' import { PathReporter } from 'io-ts/lib/PathReporter' const T = fromNullable(t.number, -1) diff --git a/docs/modules/mapOutput.ts.md b/docs/modules/mapOutput.ts.md index 6aba287..b51ce9e 100644 --- a/docs/modules/mapOutput.ts.md +++ b/docs/modules/mapOutput.ts.md @@ -36,7 +36,7 @@ export function mapOutput( import * as t from 'io-ts' import { mapOutput } from 'io-ts-types/lib/mapOutput' import { optionFromNullable } from 'io-ts-types/lib/optionFromNullable' -import { none, some } from 'fp-ts/lib/Option' +import { none, some } from 'fp-ts/Option' // Input: t.Type, number | null, t.mixed> const Input = optionFromNullable(t.number) diff --git a/docs/modules/option.ts.md b/docs/modules/option.ts.md index 642fef9..12e9921 100644 --- a/docs/modules/option.ts.md +++ b/docs/modules/option.ts.md @@ -32,8 +32,8 @@ export interface OptionC extends t.Type>, ```ts import { option } from 'io-ts-types/lib/option' -import { right } from 'fp-ts/lib/Either' -import { none, some } from 'fp-ts/lib/Option' +import { right } from 'fp-ts/Either' +import { none, some } from 'fp-ts/Option' import * as t from 'io-ts' import { PathReporter } from 'io-ts/lib/PathReporter' diff --git a/docs/modules/regexp.ts.md b/docs/modules/regexp.ts.md index 18ce435..d0be939 100644 --- a/docs/modules/regexp.ts.md +++ b/docs/modules/regexp.ts.md @@ -39,7 +39,7 @@ export const regexp: RegExpC = ... ```ts import { regexp } from 'io-ts-types/lib/regexp' -import { right } from 'fp-ts/lib/Either' +import { right } from 'fp-ts/Either' const input1 = /\w+/ const input2 = new RegExp('\\w+') diff --git a/docs/modules/withFallback.ts.md b/docs/modules/withFallback.ts.md index 8a5be87..4f69d06 100644 --- a/docs/modules/withFallback.ts.md +++ b/docs/modules/withFallback.ts.md @@ -31,7 +31,7 @@ export function withFallback(codec: C, a: t.TypeOf, name = ` ```ts import { withFallback } from 'io-ts-types/lib/withFallback' import * as t from 'io-ts' -import { right } from 'fp-ts/lib/Either' +import { right } from 'fp-ts/Either' const T = withFallback(t.number, -1) diff --git a/docs/modules/withMessage.ts.md b/docs/modules/withMessage.ts.md index 652557a..05eb1d4 100644 --- a/docs/modules/withMessage.ts.md +++ b/docs/modules/withMessage.ts.md @@ -32,7 +32,7 @@ export function withMessage(codec: C, message: (i: t.InputOf import { withMessage } from 'io-ts-types/lib/withMessage' import * as t from 'io-ts' import { PathReporter } from 'io-ts/lib/PathReporter' -import { right } from 'fp-ts/lib/Either' +import { right } from 'fp-ts/Either' const T = withMessage(t.number, () => 'Invalid number') diff --git a/docs/modules/withValidate.ts.md b/docs/modules/withValidate.ts.md index ba67d72..f598f8c 100644 --- a/docs/modules/withValidate.ts.md +++ b/docs/modules/withValidate.ts.md @@ -32,7 +32,7 @@ export function withValidate(codec: C, validate: C['validate'], import { withValidate } from 'io-ts-types/lib/withValidate' import * as t from 'io-ts' import { PathReporter } from 'io-ts/lib/PathReporter' -import { either, right } from 'fp-ts/lib/Either' +import { either, right } from 'fp-ts/Either' const T = withValidate(t.number, (u, c) => either.map(t.number.validate(u, c), n => n * 2)) diff --git a/dtslint/ts3.5/index.ts b/dtslint/ts3.5/index.ts index d4d896e..a7b09b2 100644 --- a/dtslint/ts3.5/index.ts +++ b/dtslint/ts3.5/index.ts @@ -1,4 +1,4 @@ -import { ordNumber } from 'fp-ts/lib/Ord' +import { ordNumber } from 'fp-ts/Ord' import * as t from 'io-ts' import { either, nonEmptyArray, NumberFromString, option, optionFromNullable, setFromArray } from '../../src' diff --git a/dtslint/ts3.5/readonlySetFromArray.ts b/dtslint/ts3.5/readonlySetFromArray.ts index a454baf..aabfb9f 100644 --- a/dtslint/ts3.5/readonlySetFromArray.ts +++ b/dtslint/ts3.5/readonlySetFromArray.ts @@ -1,6 +1,6 @@ import * as t from 'io-ts' import { readonlySetFromArray } from '../../src' -import { ordString } from 'fp-ts/lib/Ord' +import { ordString } from 'fp-ts/Ord' const RS = readonlySetFromArray(t.string, ordString) diff --git a/src/BooleanFromString.ts b/src/BooleanFromString.ts index d1a413c..0fd66ff 100644 --- a/src/BooleanFromString.ts +++ b/src/BooleanFromString.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' /** * @since 0.5.0 diff --git a/src/DateFromISOString.ts b/src/DateFromISOString.ts index c9675ed..7d3612f 100644 --- a/src/DateFromISOString.ts +++ b/src/DateFromISOString.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' /** * @since 0.5.0 @@ -12,7 +12,7 @@ export interface DateFromISOStringC extends t.Type {} /** * @example * import { DateFromISOString } from 'io-ts-types/lib/DateFromISOString' - * import { right } from 'fp-ts/lib/Either' + * import { right } from 'fp-ts/Either' * * const date = new Date(1973, 10, 30) * const input = date.toISOString() diff --git a/src/DateFromNumber.ts b/src/DateFromNumber.ts index c2555ca..00dcfeb 100644 --- a/src/DateFromNumber.ts +++ b/src/DateFromNumber.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' /** * @since 0.5.0 @@ -12,7 +12,7 @@ export interface DateFromNumberC extends t.Type {} /** * @example * import { DateFromNumber } from 'io-ts-types/lib/DateFromNumber' - * import { right } from 'fp-ts/lib/Either' + * import { right } from 'fp-ts/Either' * * const date = new Date(1973, 10, 30) * const input = date.getTime() diff --git a/src/DateFromUnixTime.ts b/src/DateFromUnixTime.ts index 7084168..a349bb2 100644 --- a/src/DateFromUnixTime.ts +++ b/src/DateFromUnixTime.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' /** * @since 0.5.0 @@ -12,7 +12,7 @@ export interface DateFromUnixTimeC extends t.Type {} /** * @example * import { DateFromUnixTime } from 'io-ts-types/lib/DateFromUnixTime' - * import { right } from 'fp-ts/lib/Either' + * import { right } from 'fp-ts/Either' * * const date = new Date(1973, 10, 30) * const input = date.getTime() / 1000 diff --git a/src/IntFromString.ts b/src/IntFromString.ts index c6af557..cd0c7e3 100644 --- a/src/IntFromString.ts +++ b/src/IntFromString.ts @@ -3,7 +3,7 @@ */ import * as t from 'io-ts' import { NumberFromString } from './NumberFromString' -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' /** * @since 0.4.4 @@ -15,7 +15,7 @@ export interface IntFromStringC extends t.Type {} * * @example * import { IntFromString } from 'io-ts-types/lib/IntFromString' - * import { right } from 'fp-ts/lib/Either' + * import { right } from 'fp-ts/Either' * import { PathReporter } from 'io-ts/lib/PathReporter' * * assert.deepStrictEqual(IntFromString.decode('1'), right(1)) diff --git a/src/NonEmptyString.ts b/src/NonEmptyString.ts index 5c7a725..14fd17f 100644 --- a/src/NonEmptyString.ts +++ b/src/NonEmptyString.ts @@ -25,7 +25,7 @@ export interface NonEmptyStringC extends t.Type * * @example * import { NonEmptyString } from 'io-ts-types/lib/NonEmptyString' - * import { right } from 'fp-ts/lib/Either' + * import { right } from 'fp-ts/Either' * import { PathReporter } from 'io-ts/lib/PathReporter' * * assert.deepStrictEqual(NonEmptyString.decode('a'), right('a')) diff --git a/src/NumberFromString.ts b/src/NumberFromString.ts index f7aa50f..1605459 100644 --- a/src/NumberFromString.ts +++ b/src/NumberFromString.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' /** * @since 0.5.0 diff --git a/src/UUID.ts b/src/UUID.ts index 2bf943d..b2e4ea5 100644 --- a/src/UUID.ts +++ b/src/UUID.ts @@ -20,7 +20,7 @@ export type UUID = t.Branded /** * @example * import { UUID } from 'io-ts-types/lib/UUID' - * import { right } from 'fp-ts/lib/Either' + * import { right } from 'fp-ts/Either' * import { PathReporter } from 'io-ts/lib/PathReporter' * * assert.deepStrictEqual(UUID.decode('00000000-0000-0000-0000-000000000000'), right('00000000-0000-0000-0000-000000000000')) diff --git a/src/either.ts b/src/either.ts index 14a248f..cebe89f 100644 --- a/src/either.ts +++ b/src/either.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { Either } from 'fp-ts/lib/Either' +import { Either } from 'fp-ts/Either' const leftLiteral = t.literal('Left') @@ -20,7 +20,7 @@ export interface EitherC * * @example * import { either } from 'io-ts-types/lib/either' - * import { left, right } from 'fp-ts/lib/Either' + * import { left, right } from 'fp-ts/Either' * import * as t from 'io-ts' * import { PathReporter } from 'io-ts/lib/PathReporter' * diff --git a/src/fromNewtype.ts b/src/fromNewtype.ts index ad7ba23..c3731dc 100644 --- a/src/fromNewtype.ts +++ b/src/fromNewtype.ts @@ -3,7 +3,7 @@ */ import { AnyNewtype, CarrierOf, iso } from 'newtype-ts' import * as t from 'io-ts' -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' /** * Returns a codec from a newtype @@ -11,7 +11,7 @@ import { either } from 'fp-ts/lib/Either' * @example * import { fromNewtype } from 'io-ts-types/lib/fromNewtype' * import * as t from 'io-ts' - * import { right } from 'fp-ts/lib/Either' + * import { right } from 'fp-ts/Either' * import { PathReporter } from 'io-ts/lib/PathReporter' * import { Newtype, iso } from 'newtype-ts' * diff --git a/src/fromNullable.ts b/src/fromNullable.ts index ccdd91d..f6343a5 100644 --- a/src/fromNullable.ts +++ b/src/fromNullable.ts @@ -10,7 +10,7 @@ import { withValidate } from './withValidate' * @example * import { fromNullable } from 'io-ts-types/lib/fromNullable' * import * as t from 'io-ts' - * import { right } from 'fp-ts/lib/Either' + * import { right } from 'fp-ts/Either' * import { PathReporter } from 'io-ts/lib/PathReporter' * * const T = fromNullable(t.number, -1) diff --git a/src/mapOutput.ts b/src/mapOutput.ts index d93a2c4..9e22ab1 100644 --- a/src/mapOutput.ts +++ b/src/mapOutput.ts @@ -10,7 +10,7 @@ import * as t from 'io-ts' * import * as t from 'io-ts' * import { mapOutput } from 'io-ts-types/lib/mapOutput' * import { optionFromNullable } from 'io-ts-types/lib/optionFromNullable' - * import { none, some } from 'fp-ts/lib/Option' + * import { none, some } from 'fp-ts/Option' * * // Input: t.Type, number | null, t.mixed> * const Input = optionFromNullable(t.number) diff --git a/src/nonEmptyArray.ts b/src/nonEmptyArray.ts index a59502a..5630fa4 100644 --- a/src/nonEmptyArray.ts +++ b/src/nonEmptyArray.ts @@ -2,10 +2,10 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { NonEmptyArray, fromArray } from 'fp-ts/lib/NonEmptyArray' -import { isNonEmpty } from 'fp-ts/lib/Array' -import { either } from 'fp-ts/lib/Either' -import { isNone } from 'fp-ts/lib/Option' +import { NonEmptyArray, fromArray } from 'fp-ts/NonEmptyArray' +import { isNonEmpty } from 'fp-ts/Array' +import { either } from 'fp-ts/Either' +import { isNone } from 'fp-ts/Option' /** * @since 0.5.0 diff --git a/src/option.ts b/src/option.ts index ffd7ef2..0159dc7 100644 --- a/src/option.ts +++ b/src/option.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { Option } from 'fp-ts/lib/Option' +import { Option } from 'fp-ts/Option' const None = t.strict({ _tag: t.literal('None') @@ -16,8 +16,8 @@ const someLiteral = t.literal('Some') * * @example * import { option } from 'io-ts-types/lib/option' - * import { right } from 'fp-ts/lib/Either' - * import { none, some } from 'fp-ts/lib/Option' + * import { right } from 'fp-ts/Either' + * import { none, some } from 'fp-ts/Option' * import * as t from 'io-ts' * import { PathReporter } from 'io-ts/lib/PathReporter' * diff --git a/src/optionFromNullable.ts b/src/optionFromNullable.ts index 92700e2..5bae549 100644 --- a/src/optionFromNullable.ts +++ b/src/optionFromNullable.ts @@ -1,8 +1,8 @@ /** * @since 0.5.0 */ -import { either } from 'fp-ts/lib/Either' -import { none, Option, option, some, toNullable } from 'fp-ts/lib/Option' +import { either } from 'fp-ts/Either' +import { none, Option, option, some, toNullable } from 'fp-ts/Option' import * as t from 'io-ts' import { option as o } from './option' diff --git a/src/readonlySetFromArray.ts b/src/readonlySetFromArray.ts index 74ac5bd..5f0b021 100644 --- a/src/readonlySetFromArray.ts +++ b/src/readonlySetFromArray.ts @@ -1,7 +1,7 @@ /** * @since 0.5.7 */ -import { Ord } from 'fp-ts/lib/Ord' +import { Ord } from 'fp-ts/Ord' import * as t from 'io-ts' import { setFromArray } from './setFromArray' diff --git a/src/regexp.ts b/src/regexp.ts index 8379542..14d7248 100644 --- a/src/regexp.ts +++ b/src/regexp.ts @@ -14,7 +14,7 @@ export interface RegExpC extends t.Type {} /** * @example * import { regexp } from 'io-ts-types/lib/regexp' - * import { right } from 'fp-ts/lib/Either' + * import { right } from 'fp-ts/Either' * * const input1 = /\w+/ * const input2 = new RegExp('\\w+') diff --git a/src/setFromArray.ts b/src/setFromArray.ts index 027742e..1f73061 100644 --- a/src/setFromArray.ts +++ b/src/setFromArray.ts @@ -1,10 +1,10 @@ /** * @since 0.5.0 */ -import { Ord } from 'fp-ts/lib/Ord' -import { every, fromArray, toArray } from 'fp-ts/lib/Set' +import { Ord } from 'fp-ts/Ord' +import { every, fromArray, toArray } from 'fp-ts/Set' import * as t from 'io-ts' -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' /** * @since 0.5.0 diff --git a/src/withFallback.ts b/src/withFallback.ts index 77e9b43..3860f71 100644 --- a/src/withFallback.ts +++ b/src/withFallback.ts @@ -3,7 +3,7 @@ */ import * as t from 'io-ts' import { withValidate } from './withValidate' -import { orElse } from 'fp-ts/lib/Either' +import { orElse } from 'fp-ts/Either' /** * Returns a clone of the given codec that always succeed using the given value `a` if the original codec fails @@ -11,7 +11,7 @@ import { orElse } from 'fp-ts/lib/Either' * @example * import { withFallback } from 'io-ts-types/lib/withFallback' * import * as t from 'io-ts' - * import { right } from 'fp-ts/lib/Either' + * import { right } from 'fp-ts/Either' * * const T = withFallback(t.number, -1) * diff --git a/src/withMessage.ts b/src/withMessage.ts index 1c07d7e..a515b69 100644 --- a/src/withMessage.ts +++ b/src/withMessage.ts @@ -3,7 +3,7 @@ */ import * as t from 'io-ts' import { withValidate } from './withValidate' -import { mapLeft } from 'fp-ts/lib/Either' +import { mapLeft } from 'fp-ts/Either' /** * Returns a clone of the given codec that sets the given string as error messsage @@ -12,7 +12,7 @@ import { mapLeft } from 'fp-ts/lib/Either' * import { withMessage } from 'io-ts-types/lib/withMessage' * import * as t from 'io-ts' * import { PathReporter } from 'io-ts/lib/PathReporter' - * import { right } from 'fp-ts/lib/Either' + * import { right } from 'fp-ts/Either' * * const T = withMessage(t.number, () => 'Invalid number') * diff --git a/src/withValidate.ts b/src/withValidate.ts index d0a3620..922756c 100644 --- a/src/withValidate.ts +++ b/src/withValidate.ts @@ -11,7 +11,7 @@ import { clone } from './clone' * import { withValidate } from 'io-ts-types/lib/withValidate' * import * as t from 'io-ts' * import { PathReporter } from 'io-ts/lib/PathReporter' - * import { either, right } from 'fp-ts/lib/Either' + * import { either, right } from 'fp-ts/Either' * * const T = withValidate(t.number, (u, c) => either.map(t.number.validate(u, c), n => n * 2)) * diff --git a/test/DateFromNumber.ts b/test/DateFromNumber.ts index d5fa208..5e38f5a 100644 --- a/test/DateFromNumber.ts +++ b/test/DateFromNumber.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import { DateFromNumber } from '../src' import { assertSuccess, assertFailure } from './helpers' -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' const d = new Date(1973, 10, 30) const n = d.getTime() diff --git a/test/DateFromUnixTime.ts b/test/DateFromUnixTime.ts index a30a74e..884f945 100644 --- a/test/DateFromUnixTime.ts +++ b/test/DateFromUnixTime.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import { DateFromUnixTime } from '../src' import { assertSuccess, assertFailure } from './helpers' -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' const d = new Date(1973, 10, 30) const n = d.getTime() diff --git a/test/either.ts b/test/either.ts index 4f4d06a..d308b96 100644 --- a/test/either.ts +++ b/test/either.ts @@ -1,5 +1,5 @@ import * as assert from 'assert' -import { left, right } from 'fp-ts/lib/Either' +import { left, right } from 'fp-ts/Either' import * as t from 'io-ts' import { either } from '../src' import { assertFailure, assertSuccess } from './helpers' diff --git a/test/helpers.ts b/test/helpers.ts index 62a5378..ab7aafc 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import * as t from 'io-ts' import { PathReporter } from 'io-ts/lib/PathReporter' -import { isRight, isLeft } from 'fp-ts/lib/Either' +import { isRight, isLeft } from 'fp-ts/Either' export function assertStrictEqual(result: t.Validation, expected: any): void { if (isRight(result)) { diff --git a/test/nonEmptyArray.ts b/test/nonEmptyArray.ts index ae34152..03b7e79 100644 --- a/test/nonEmptyArray.ts +++ b/test/nonEmptyArray.ts @@ -1,6 +1,6 @@ import { nonEmptyArray } from '../src' import * as t from 'io-ts' -import { cons } from 'fp-ts/lib/NonEmptyArray' +import { cons } from 'fp-ts/NonEmptyArray' import * as assert from 'assert' import { assertFailure, assertSuccess } from './helpers' diff --git a/test/option.ts b/test/option.ts index d458651..a1e61b3 100644 --- a/test/option.ts +++ b/test/option.ts @@ -1,5 +1,5 @@ import * as assert from 'assert' -import { none, some } from 'fp-ts/lib/Option' +import { none, some } from 'fp-ts/Option' import * as t from 'io-ts' import { NumberFromString } from '../src' import { option } from '../src' diff --git a/test/optionFromNullable.ts b/test/optionFromNullable.ts index 483b669..9377bc5 100644 --- a/test/optionFromNullable.ts +++ b/test/optionFromNullable.ts @@ -3,7 +3,7 @@ import { optionFromNullable } from '../src' import * as t from 'io-ts' import * as assert from 'assert' import { NumberFromString } from '../src' -import { none, some } from 'fp-ts/lib/Option' +import { none, some } from 'fp-ts/Option' describe('optionFromNullable', () => { it('name', () => { diff --git a/test/readonlyNonEmptyArray.ts b/test/readonlyNonEmptyArray.ts index 56b402f..74a636e 100644 --- a/test/readonlyNonEmptyArray.ts +++ b/test/readonlyNonEmptyArray.ts @@ -1,5 +1,5 @@ import * as assert from 'assert' -import { cons } from 'fp-ts/lib/NonEmptyArray' +import { cons } from 'fp-ts/NonEmptyArray' import * as t from 'io-ts' import { readonlyNonEmptyArray } from '../src' import { assertFailure, assertSuccess } from './helpers' diff --git a/test/readonlySetFromArray.ts b/test/readonlySetFromArray.ts index 018984d..7eb2cc5 100644 --- a/test/readonlySetFromArray.ts +++ b/test/readonlySetFromArray.ts @@ -2,7 +2,7 @@ import { readonlySetFromArray } from '../src' import * as t from 'io-ts' import * as assert from 'assert' import { assertFailure, assertSuccess } from './helpers' -import { ordNumber } from 'fp-ts/lib/Ord' +import { ordNumber } from 'fp-ts/Ord' describe('readonlySetFromArray', () => { it('name', () => { diff --git a/test/setFromArray.ts b/test/setFromArray.ts index 7c36319..001379a 100644 --- a/test/setFromArray.ts +++ b/test/setFromArray.ts @@ -2,7 +2,7 @@ import { setFromArray } from '../src' import * as t from 'io-ts' import * as assert from 'assert' import { assertFailure, assertSuccess } from './helpers' -import { ordNumber } from 'fp-ts/lib/Ord' +import { ordNumber } from 'fp-ts/Ord' describe('setFromArray', () => { it('name', () => { From 1f9726c62c675a5dc7cf59ada32cebf42d3269bd Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:32:20 +0900 Subject: [PATCH 03/13] copy build scripts from fp-ts --- scripts/FileSystem.ts | 29 ++++++++++++++ scripts/build.ts | 88 ++++++++++++++++++++++++++++++++++++++++++ scripts/pre-publish.ts | 7 ++++ scripts/run.ts | 21 ++++++++++ 4 files changed, 145 insertions(+) create mode 100644 scripts/FileSystem.ts create mode 100644 scripts/build.ts create mode 100644 scripts/pre-publish.ts create mode 100644 scripts/run.ts diff --git a/scripts/FileSystem.ts b/scripts/FileSystem.ts new file mode 100644 index 0000000..9e2c2c4 --- /dev/null +++ b/scripts/FileSystem.ts @@ -0,0 +1,29 @@ +import * as TE from 'fp-ts/TaskEither' +import { flow } from 'fp-ts/function' +import * as fs from 'fs' +import G from 'glob' + +export interface FileSystem { + readonly readFile: (path: string) => TE.TaskEither + readonly writeFile: (path: string, content: string) => TE.TaskEither + readonly copyFile: (from: string, to: string) => TE.TaskEither + readonly glob: (pattern: string) => TE.TaskEither> + readonly mkdir: (path: string) => TE.TaskEither +} + +const readFile = TE.taskify(fs.readFile) +const writeFile = TE.taskify(fs.writeFile) +const copyFile = TE.taskify(fs.copyFile) +const glob = TE.taskify>(G) +const mkdirTE = TE.taskify(fs.mkdir) + +export const fileSystem: FileSystem = { + readFile: (path) => readFile(path, 'utf8'), + writeFile, + copyFile, + glob, + mkdir: flow( + mkdirTE, + TE.map(() => undefined) + ) +} diff --git a/scripts/build.ts b/scripts/build.ts new file mode 100644 index 0000000..ba6ec6f --- /dev/null +++ b/scripts/build.ts @@ -0,0 +1,88 @@ +import * as path from 'path' +import * as E from 'fp-ts/Either' +import { pipe } from 'fp-ts/function' +import * as RTE from 'fp-ts/ReaderTaskEither' +import * as A from 'fp-ts/ReadonlyArray' +import * as TE from 'fp-ts/TaskEither' +import { FileSystem, fileSystem } from './FileSystem' +import { run } from './run' + +interface Build extends RTE.ReaderTaskEither {} + +const OUTPUT_FOLDER = 'dist' +const PKG = 'package.json' + +export const copyPackageJson: Build = (C) => + pipe( + C.readFile(PKG), + TE.chain((s) => TE.fromEither(E.parseJSON(s, E.toError))), + TE.map((v) => { + const clone = Object.assign({}, v as any) + + delete clone.scripts + delete clone.files + delete clone.devDependencies + + return clone + }), + TE.chain((json) => C.writeFile(path.join(OUTPUT_FOLDER, PKG), JSON.stringify(json, null, 2))) + ) + +export const FILES: ReadonlyArray = ['CHANGELOG.md', 'LICENSE', 'README.md'] + +export const copyFiles: Build> = (C) => + pipe( + FILES, + A.traverse(TE.taskEither)((from) => C.copyFile(from, path.resolve(OUTPUT_FOLDER, from))) + ) + +const traverse = A.traverse(TE.taskEither) + +export const makeModules: Build = (C) => + pipe( + C.glob(`${OUTPUT_FOLDER}/lib/*.js`), + TE.map(getModules), + TE.chain(traverse(makeSingleModule(C))), + TE.map(() => undefined) + ) + +function getModules(paths: ReadonlyArray): ReadonlyArray { + return paths.map((filePath) => path.basename(filePath, '.js')).filter((x) => x !== 'index') +} + +function makeSingleModule(C: FileSystem): (module: string) => TE.TaskEither { + return (m) => + pipe( + C.mkdir(path.join(OUTPUT_FOLDER, m)), + TE.chain(() => makePkgJson(m)), + TE.chain((data) => C.writeFile(path.join(OUTPUT_FOLDER, m, 'package.json'), data)) + ) +} + +function makePkgJson(module: string): TE.TaskEither { + return pipe( + JSON.stringify( + { + main: `../lib/${module}.js`, + module: `../es6/${module}.js`, + typings: `../lib/${module}.d.ts`, + sideEffects: false + }, + null, + 2 + ), + TE.right + ) +} + +const main: Build = pipe( + copyPackageJson, + RTE.chain(() => copyFiles), + RTE.chain(() => makeModules) +) + +run( + main({ + ...fileSystem + }) +) diff --git a/scripts/pre-publish.ts b/scripts/pre-publish.ts new file mode 100644 index 0000000..0dc641b --- /dev/null +++ b/scripts/pre-publish.ts @@ -0,0 +1,7 @@ +import { left } from '../src/TaskEither' +import { run } from './run' + +const main = left(new Error('"npm publish" can not be run from root, run "npm run release" instead')) + +run(main) + diff --git a/scripts/run.ts b/scripts/run.ts new file mode 100644 index 0000000..7629fe1 --- /dev/null +++ b/scripts/run.ts @@ -0,0 +1,21 @@ +import { fold } from 'fp-ts/Either' +import { TaskEither } from 'fp-ts/TaskEither' + +export function run(eff: TaskEither): void { + eff() + .then( + fold( + (e) => { + throw e + }, + (_) => { + process.exitCode = 0 + } + ) + ) + .catch((e) => { + console.error(e) // tslint:disable-line no-console + + process.exitCode = 1 + }) +} From b451059dc2f880ae581d39a837d99ac838e5f2a9 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:32:55 +0900 Subject: [PATCH 04/13] update node typings --- package-lock.json | 87 ++--------------------------------------------- package.json | 2 +- 2 files changed, 4 insertions(+), 85 deletions(-) diff --git a/package-lock.json b/package-lock.json index df3985e..9ec62fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -518,12 +518,6 @@ "@babel/types": "^7.3.0" } }, - "@types/color-name": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", - "dev": true - }, "@types/events": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", @@ -588,9 +582,9 @@ "dev": true }, "@types/node": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.4.tgz", - "integrity": "sha1-mqvBNZed7TgzJXSfUIiUxmKUjIs=", + "version": "14.0.27", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz", + "integrity": "sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g==", "dev": true }, "@types/stack-utils": { @@ -2881,81 +2875,6 @@ "resolve-cwd": "^2.0.0" } }, - "import-path-rewrite": { - "version": "github:gcanti/import-path-rewrite#0086599732ccc761a33255a702a07266895d0572", - "from": "github:gcanti/import-path-rewrite", - "dev": true, - "requires": { - "chalk": "^3.0.0", - "glob": "^7.1.6" - }, - "dependencies": { - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", diff --git a/package.json b/package.json index 455d17b..29b70cc 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "devDependencies": { "@types/jest": "^24.0.15", - "@types/node": "7.0.4", + "@types/node": "^14.0.27", "docs-ts": "^0.3.4", "dtslint": "github:gcanti/dtslint", "fp-ts": "^2.8.0", From d7b604640c9612c7b1761979ef99ff932606fbaa Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:33:21 +0900 Subject: [PATCH 05/13] reformat tsconfigs to match fp-ts's build structure --- tsconfig.build-es6.json | 7 +++++++ tsconfig.es6.json => tsconfig.build.json | 6 +++--- tsconfig.json | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 tsconfig.build-es6.json rename tsconfig.es6.json => tsconfig.build.json (55%) diff --git a/tsconfig.build-es6.json b/tsconfig.build-es6.json new file mode 100644 index 0000000..6b5e341 --- /dev/null +++ b/tsconfig.build-es6.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.build.json", + "compilerOptions": { + "outDir": "./dist/es6", + "module": "es6" + } +} diff --git a/tsconfig.es6.json b/tsconfig.build.json similarity index 55% rename from tsconfig.es6.json rename to tsconfig.build.json index fa53d00..9d833c2 100644 --- a/tsconfig.es6.json +++ b/tsconfig.build.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "./es6", - "module": "es6" - } + "noEmit": false + }, + "include": ["./src"] } diff --git a/tsconfig.json b/tsconfig.json index 293eb10..9c43f0d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,8 @@ { "compilerOptions": { - "outDir": "./lib", + "outDir": "./dist/lib", + "noEmit": true, + "esModuleInterop": true, "sourceMap": false, "declaration": true, "module": "commonjs", From 727a9c515f8898ae0be7896789f0530c33961009 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:33:33 +0900 Subject: [PATCH 06/13] git ignore dist folder --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 556d043..6c59b09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ *.log node_modules -lib -es6 +/dist dev coverage From 6683dbcc6a5211164e7fabebe31a274068616450 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:33:54 +0900 Subject: [PATCH 07/13] remove import-path-rewrite, update build scripts --- package.json | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 29b70cc..4c6bff3 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,6 @@ "name": "io-ts-types", "version": "0.5.8", "description": "A collection of codecs and combinators for use with io-ts", - "files": [ - "lib", - "es6" - ], "main": "lib/index.js", "module": "es6/index.js", "typings": "lib/index.d.ts", @@ -16,13 +12,14 @@ "fix-prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --write \"{src,test}/**/*.ts\"", "jest": "jest --ci", "test": "npm run build && npm run lint && npm run dtslint && npm run prettier && npm run jest && npm run docs", - "clean": "rm -rf lib/* es6/*", - "build": "npm run clean && tsc && tsc -p ./tsconfig.es6.json", - "prepublish": "npm run build", + "clean": "rm -rf ./dist", + "prebuild": "npm run clean", + "build": "tsc -p ./tsconfig.build.json && tsc -p ./tsconfig.build-es6.json && ts-node scripts/build", + "postbuild": "prettier --loglevel=silent --write \"./dist/**/*.ts\"", + "prepublishOnly": "ts-node scripts/pre-publish", "dtslint": "dtslint dtslint", "mocha": "mocha -r ts-node/register test/*.ts", - "docs": "docs-ts", - "postbuild": "import-path-rewrite" + "docs": "docs-ts" }, "repository": { "type": "git", @@ -46,7 +43,6 @@ "docs-ts": "^0.3.4", "dtslint": "github:gcanti/dtslint", "fp-ts": "^2.8.0", - "import-path-rewrite": "github:gcanti/import-path-rewrite", "io-ts": "^2.0.0", "jest": "^24.8.0", "mocha": "^5.2.0", From 9e5ea01e8593b2a3211ccb4faa97944761ed50b6 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 15:01:00 +0900 Subject: [PATCH 08/13] fp-ts import --- scripts/pre-publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pre-publish.ts b/scripts/pre-publish.ts index 0dc641b..c326efd 100644 --- a/scripts/pre-publish.ts +++ b/scripts/pre-publish.ts @@ -1,4 +1,4 @@ -import { left } from '../src/TaskEither' +import { left } from 'fp-ts/TaskEither' import { run } from './run' const main = left(new Error('"npm publish" can not be run from root, run "npm run release" instead')) From b7bea8f52a6140f498786517f3a81e95f993dc12 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 15:04:06 +0900 Subject: [PATCH 09/13] Release scripts --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4c6bff3..6e33626 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,9 @@ "prepublishOnly": "ts-node scripts/pre-publish", "dtslint": "dtslint dtslint", "mocha": "mocha -r ts-node/register test/*.ts", - "docs": "docs-ts" + "docs": "docs-ts", + "prerelease": "npm run build", + "release": "ts-node scripts/release" }, "repository": { "type": "git", From 3b87033ea1a2581b665263185327bd702b86aef6 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 15:06:27 +0900 Subject: [PATCH 10/13] release script src --- scripts/release.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 scripts/release.ts diff --git a/scripts/release.ts b/scripts/release.ts new file mode 100644 index 0000000..750f3ed --- /dev/null +++ b/scripts/release.ts @@ -0,0 +1,23 @@ +import { run } from './run' +import * as child_process from 'child_process' +import { left, right } from 'fp-ts/Either' +import * as TE from 'fp-ts/TaskEither' + +const DIST = 'dist' + +const exec = (cmd: string, args?: child_process.ExecOptions): TE.TaskEither => () => + new Promise((resolve) => { + child_process.exec(cmd, args, (err) => { + if (err !== null) { + return resolve(left(err)) + } + + return resolve(right(undefined)) + }) + }) + +export const main = exec('npm publish', { + cwd: DIST +}) + +run(main) From fa50e42a173110a6b6f04a4712585ccaa2311cc2 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Mon, 10 Aug 2020 11:06:09 +0900 Subject: [PATCH 11/13] Revert "use bare fp-ts import everywhere" This reverts commit 6fbfbe485ab842f78e68354550e758cda6fafa12. --- docs/modules/DateFromISOString.ts.md | 2 +- docs/modules/DateFromNumber.ts.md | 2 +- docs/modules/DateFromUnixTime.ts.md | 2 +- docs/modules/IntFromString.ts.md | 2 +- docs/modules/NonEmptyString.ts.md | 2 +- docs/modules/UUID.ts.md | 2 +- docs/modules/either.ts.md | 2 +- docs/modules/fromNewtype.ts.md | 2 +- docs/modules/fromNullable.ts.md | 2 +- docs/modules/mapOutput.ts.md | 2 +- docs/modules/option.ts.md | 4 ++-- docs/modules/regexp.ts.md | 2 +- docs/modules/withFallback.ts.md | 2 +- docs/modules/withMessage.ts.md | 2 +- docs/modules/withValidate.ts.md | 2 +- dtslint/ts3.5/index.ts | 2 +- dtslint/ts3.5/readonlySetFromArray.ts | 2 +- src/BooleanFromString.ts | 2 +- src/DateFromISOString.ts | 4 ++-- src/DateFromNumber.ts | 4 ++-- src/DateFromUnixTime.ts | 4 ++-- src/IntFromString.ts | 4 ++-- src/NonEmptyString.ts | 2 +- src/NumberFromString.ts | 2 +- src/UUID.ts | 2 +- src/either.ts | 4 ++-- src/fromNewtype.ts | 4 ++-- src/fromNullable.ts | 2 +- src/mapOutput.ts | 2 +- src/nonEmptyArray.ts | 8 ++++---- src/option.ts | 6 +++--- src/optionFromNullable.ts | 4 ++-- src/readonlySetFromArray.ts | 2 +- src/regexp.ts | 2 +- src/setFromArray.ts | 6 +++--- src/withFallback.ts | 4 ++-- src/withMessage.ts | 4 ++-- src/withValidate.ts | 2 +- test/DateFromNumber.ts | 2 +- test/DateFromUnixTime.ts | 2 +- test/either.ts | 2 +- test/helpers.ts | 2 +- test/nonEmptyArray.ts | 2 +- test/option.ts | 2 +- test/optionFromNullable.ts | 2 +- test/readonlyNonEmptyArray.ts | 2 +- test/readonlySetFromArray.ts | 2 +- test/setFromArray.ts | 2 +- 48 files changed, 65 insertions(+), 65 deletions(-) diff --git a/docs/modules/DateFromISOString.ts.md b/docs/modules/DateFromISOString.ts.md index 7cc930a..c21cab4 100644 --- a/docs/modules/DateFromISOString.ts.md +++ b/docs/modules/DateFromISOString.ts.md @@ -39,7 +39,7 @@ export const DateFromISOString: DateFromISOStringC = ... ```ts import { DateFromISOString } from 'io-ts-types/lib/DateFromISOString' -import { right } from 'fp-ts/Either' +import { right } from 'fp-ts/lib/Either' const date = new Date(1973, 10, 30) const input = date.toISOString() diff --git a/docs/modules/DateFromNumber.ts.md b/docs/modules/DateFromNumber.ts.md index 7a16c31..b8dece6 100644 --- a/docs/modules/DateFromNumber.ts.md +++ b/docs/modules/DateFromNumber.ts.md @@ -39,7 +39,7 @@ export const DateFromNumber: DateFromNumberC = ... ```ts import { DateFromNumber } from 'io-ts-types/lib/DateFromNumber' -import { right } from 'fp-ts/Either' +import { right } from 'fp-ts/lib/Either' const date = new Date(1973, 10, 30) const input = date.getTime() diff --git a/docs/modules/DateFromUnixTime.ts.md b/docs/modules/DateFromUnixTime.ts.md index fd91425..6c1ba14 100644 --- a/docs/modules/DateFromUnixTime.ts.md +++ b/docs/modules/DateFromUnixTime.ts.md @@ -39,7 +39,7 @@ export const DateFromUnixTime: DateFromUnixTimeC = ... ```ts import { DateFromUnixTime } from 'io-ts-types/lib/DateFromUnixTime' -import { right } from 'fp-ts/Either' +import { right } from 'fp-ts/lib/Either' const date = new Date(1973, 10, 30) const input = date.getTime() / 1000 diff --git a/docs/modules/IntFromString.ts.md b/docs/modules/IntFromString.ts.md index e8a9572..028c485 100644 --- a/docs/modules/IntFromString.ts.md +++ b/docs/modules/IntFromString.ts.md @@ -41,7 +41,7 @@ export const IntFromString: IntFromStringC = ... ```ts import { IntFromString } from 'io-ts-types/lib/IntFromString' -import { right } from 'fp-ts/Either' +import { right } from 'fp-ts/lib/Either' import { PathReporter } from 'io-ts/lib/PathReporter' assert.deepStrictEqual(IntFromString.decode('1'), right(1)) diff --git a/docs/modules/NonEmptyString.ts.md b/docs/modules/NonEmptyString.ts.md index 1a46be7..30750f2 100644 --- a/docs/modules/NonEmptyString.ts.md +++ b/docs/modules/NonEmptyString.ts.md @@ -65,7 +65,7 @@ export const NonEmptyString: NonEmptyStringC = ... ```ts import { NonEmptyString } from 'io-ts-types/lib/NonEmptyString' -import { right } from 'fp-ts/Either' +import { right } from 'fp-ts/lib/Either' import { PathReporter } from 'io-ts/lib/PathReporter' assert.deepStrictEqual(NonEmptyString.decode('a'), right('a')) diff --git a/docs/modules/UUID.ts.md b/docs/modules/UUID.ts.md index 4b3283f..e1e96fb 100644 --- a/docs/modules/UUID.ts.md +++ b/docs/modules/UUID.ts.md @@ -52,7 +52,7 @@ export const UUID: t.BrandC = ... ```ts import { UUID } from 'io-ts-types/lib/UUID' -import { right } from 'fp-ts/Either' +import { right } from 'fp-ts/lib/Either' import { PathReporter } from 'io-ts/lib/PathReporter' assert.deepStrictEqual( diff --git a/docs/modules/either.ts.md b/docs/modules/either.ts.md index b9bdee0..a5bb167 100644 --- a/docs/modules/either.ts.md +++ b/docs/modules/either.ts.md @@ -47,7 +47,7 @@ export function either( ```ts import { either } from 'io-ts-types/lib/either' -import { left, right } from 'fp-ts/Either' +import { left, right } from 'fp-ts/lib/Either' import * as t from 'io-ts' import { PathReporter } from 'io-ts/lib/PathReporter' diff --git a/docs/modules/fromNewtype.ts.md b/docs/modules/fromNewtype.ts.md index 1d389f8..153593b 100644 --- a/docs/modules/fromNewtype.ts.md +++ b/docs/modules/fromNewtype.ts.md @@ -34,7 +34,7 @@ export function fromNewtype( ```ts import { fromNewtype } from 'io-ts-types/lib/fromNewtype' import * as t from 'io-ts' -import { right } from 'fp-ts/Either' +import { right } from 'fp-ts/lib/Either' import { PathReporter } from 'io-ts/lib/PathReporter' import { Newtype, iso } from 'newtype-ts' diff --git a/docs/modules/fromNullable.ts.md b/docs/modules/fromNullable.ts.md index 08febd8..b239109 100644 --- a/docs/modules/fromNullable.ts.md +++ b/docs/modules/fromNullable.ts.md @@ -31,7 +31,7 @@ export function fromNullable(codec: C, a: t.TypeOf, name = ```ts import { fromNullable } from 'io-ts-types/lib/fromNullable' import * as t from 'io-ts' -import { right } from 'fp-ts/Either' +import { right } from 'fp-ts/lib/Either' import { PathReporter } from 'io-ts/lib/PathReporter' const T = fromNullable(t.number, -1) diff --git a/docs/modules/mapOutput.ts.md b/docs/modules/mapOutput.ts.md index b51ce9e..6aba287 100644 --- a/docs/modules/mapOutput.ts.md +++ b/docs/modules/mapOutput.ts.md @@ -36,7 +36,7 @@ export function mapOutput( import * as t from 'io-ts' import { mapOutput } from 'io-ts-types/lib/mapOutput' import { optionFromNullable } from 'io-ts-types/lib/optionFromNullable' -import { none, some } from 'fp-ts/Option' +import { none, some } from 'fp-ts/lib/Option' // Input: t.Type, number | null, t.mixed> const Input = optionFromNullable(t.number) diff --git a/docs/modules/option.ts.md b/docs/modules/option.ts.md index 12e9921..642fef9 100644 --- a/docs/modules/option.ts.md +++ b/docs/modules/option.ts.md @@ -32,8 +32,8 @@ export interface OptionC extends t.Type>, ```ts import { option } from 'io-ts-types/lib/option' -import { right } from 'fp-ts/Either' -import { none, some } from 'fp-ts/Option' +import { right } from 'fp-ts/lib/Either' +import { none, some } from 'fp-ts/lib/Option' import * as t from 'io-ts' import { PathReporter } from 'io-ts/lib/PathReporter' diff --git a/docs/modules/regexp.ts.md b/docs/modules/regexp.ts.md index d0be939..18ce435 100644 --- a/docs/modules/regexp.ts.md +++ b/docs/modules/regexp.ts.md @@ -39,7 +39,7 @@ export const regexp: RegExpC = ... ```ts import { regexp } from 'io-ts-types/lib/regexp' -import { right } from 'fp-ts/Either' +import { right } from 'fp-ts/lib/Either' const input1 = /\w+/ const input2 = new RegExp('\\w+') diff --git a/docs/modules/withFallback.ts.md b/docs/modules/withFallback.ts.md index 4f69d06..8a5be87 100644 --- a/docs/modules/withFallback.ts.md +++ b/docs/modules/withFallback.ts.md @@ -31,7 +31,7 @@ export function withFallback(codec: C, a: t.TypeOf, name = ` ```ts import { withFallback } from 'io-ts-types/lib/withFallback' import * as t from 'io-ts' -import { right } from 'fp-ts/Either' +import { right } from 'fp-ts/lib/Either' const T = withFallback(t.number, -1) diff --git a/docs/modules/withMessage.ts.md b/docs/modules/withMessage.ts.md index 05eb1d4..652557a 100644 --- a/docs/modules/withMessage.ts.md +++ b/docs/modules/withMessage.ts.md @@ -32,7 +32,7 @@ export function withMessage(codec: C, message: (i: t.InputOf import { withMessage } from 'io-ts-types/lib/withMessage' import * as t from 'io-ts' import { PathReporter } from 'io-ts/lib/PathReporter' -import { right } from 'fp-ts/Either' +import { right } from 'fp-ts/lib/Either' const T = withMessage(t.number, () => 'Invalid number') diff --git a/docs/modules/withValidate.ts.md b/docs/modules/withValidate.ts.md index f598f8c..ba67d72 100644 --- a/docs/modules/withValidate.ts.md +++ b/docs/modules/withValidate.ts.md @@ -32,7 +32,7 @@ export function withValidate(codec: C, validate: C['validate'], import { withValidate } from 'io-ts-types/lib/withValidate' import * as t from 'io-ts' import { PathReporter } from 'io-ts/lib/PathReporter' -import { either, right } from 'fp-ts/Either' +import { either, right } from 'fp-ts/lib/Either' const T = withValidate(t.number, (u, c) => either.map(t.number.validate(u, c), n => n * 2)) diff --git a/dtslint/ts3.5/index.ts b/dtslint/ts3.5/index.ts index a7b09b2..d4d896e 100644 --- a/dtslint/ts3.5/index.ts +++ b/dtslint/ts3.5/index.ts @@ -1,4 +1,4 @@ -import { ordNumber } from 'fp-ts/Ord' +import { ordNumber } from 'fp-ts/lib/Ord' import * as t from 'io-ts' import { either, nonEmptyArray, NumberFromString, option, optionFromNullable, setFromArray } from '../../src' diff --git a/dtslint/ts3.5/readonlySetFromArray.ts b/dtslint/ts3.5/readonlySetFromArray.ts index aabfb9f..a454baf 100644 --- a/dtslint/ts3.5/readonlySetFromArray.ts +++ b/dtslint/ts3.5/readonlySetFromArray.ts @@ -1,6 +1,6 @@ import * as t from 'io-ts' import { readonlySetFromArray } from '../../src' -import { ordString } from 'fp-ts/Ord' +import { ordString } from 'fp-ts/lib/Ord' const RS = readonlySetFromArray(t.string, ordString) diff --git a/src/BooleanFromString.ts b/src/BooleanFromString.ts index 0fd66ff..d1a413c 100644 --- a/src/BooleanFromString.ts +++ b/src/BooleanFromString.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' /** * @since 0.5.0 diff --git a/src/DateFromISOString.ts b/src/DateFromISOString.ts index 7d3612f..c9675ed 100644 --- a/src/DateFromISOString.ts +++ b/src/DateFromISOString.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' /** * @since 0.5.0 @@ -12,7 +12,7 @@ export interface DateFromISOStringC extends t.Type {} /** * @example * import { DateFromISOString } from 'io-ts-types/lib/DateFromISOString' - * import { right } from 'fp-ts/Either' + * import { right } from 'fp-ts/lib/Either' * * const date = new Date(1973, 10, 30) * const input = date.toISOString() diff --git a/src/DateFromNumber.ts b/src/DateFromNumber.ts index 00dcfeb..c2555ca 100644 --- a/src/DateFromNumber.ts +++ b/src/DateFromNumber.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' /** * @since 0.5.0 @@ -12,7 +12,7 @@ export interface DateFromNumberC extends t.Type {} /** * @example * import { DateFromNumber } from 'io-ts-types/lib/DateFromNumber' - * import { right } from 'fp-ts/Either' + * import { right } from 'fp-ts/lib/Either' * * const date = new Date(1973, 10, 30) * const input = date.getTime() diff --git a/src/DateFromUnixTime.ts b/src/DateFromUnixTime.ts index a349bb2..7084168 100644 --- a/src/DateFromUnixTime.ts +++ b/src/DateFromUnixTime.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' /** * @since 0.5.0 @@ -12,7 +12,7 @@ export interface DateFromUnixTimeC extends t.Type {} /** * @example * import { DateFromUnixTime } from 'io-ts-types/lib/DateFromUnixTime' - * import { right } from 'fp-ts/Either' + * import { right } from 'fp-ts/lib/Either' * * const date = new Date(1973, 10, 30) * const input = date.getTime() / 1000 diff --git a/src/IntFromString.ts b/src/IntFromString.ts index cd0c7e3..c6af557 100644 --- a/src/IntFromString.ts +++ b/src/IntFromString.ts @@ -3,7 +3,7 @@ */ import * as t from 'io-ts' import { NumberFromString } from './NumberFromString' -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' /** * @since 0.4.4 @@ -15,7 +15,7 @@ export interface IntFromStringC extends t.Type {} * * @example * import { IntFromString } from 'io-ts-types/lib/IntFromString' - * import { right } from 'fp-ts/Either' + * import { right } from 'fp-ts/lib/Either' * import { PathReporter } from 'io-ts/lib/PathReporter' * * assert.deepStrictEqual(IntFromString.decode('1'), right(1)) diff --git a/src/NonEmptyString.ts b/src/NonEmptyString.ts index 14fd17f..5c7a725 100644 --- a/src/NonEmptyString.ts +++ b/src/NonEmptyString.ts @@ -25,7 +25,7 @@ export interface NonEmptyStringC extends t.Type * * @example * import { NonEmptyString } from 'io-ts-types/lib/NonEmptyString' - * import { right } from 'fp-ts/Either' + * import { right } from 'fp-ts/lib/Either' * import { PathReporter } from 'io-ts/lib/PathReporter' * * assert.deepStrictEqual(NonEmptyString.decode('a'), right('a')) diff --git a/src/NumberFromString.ts b/src/NumberFromString.ts index 1605459..f7aa50f 100644 --- a/src/NumberFromString.ts +++ b/src/NumberFromString.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' /** * @since 0.5.0 diff --git a/src/UUID.ts b/src/UUID.ts index b2e4ea5..2bf943d 100644 --- a/src/UUID.ts +++ b/src/UUID.ts @@ -20,7 +20,7 @@ export type UUID = t.Branded /** * @example * import { UUID } from 'io-ts-types/lib/UUID' - * import { right } from 'fp-ts/Either' + * import { right } from 'fp-ts/lib/Either' * import { PathReporter } from 'io-ts/lib/PathReporter' * * assert.deepStrictEqual(UUID.decode('00000000-0000-0000-0000-000000000000'), right('00000000-0000-0000-0000-000000000000')) diff --git a/src/either.ts b/src/either.ts index cebe89f..14a248f 100644 --- a/src/either.ts +++ b/src/either.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { Either } from 'fp-ts/Either' +import { Either } from 'fp-ts/lib/Either' const leftLiteral = t.literal('Left') @@ -20,7 +20,7 @@ export interface EitherC * * @example * import { either } from 'io-ts-types/lib/either' - * import { left, right } from 'fp-ts/Either' + * import { left, right } from 'fp-ts/lib/Either' * import * as t from 'io-ts' * import { PathReporter } from 'io-ts/lib/PathReporter' * diff --git a/src/fromNewtype.ts b/src/fromNewtype.ts index c3731dc..ad7ba23 100644 --- a/src/fromNewtype.ts +++ b/src/fromNewtype.ts @@ -3,7 +3,7 @@ */ import { AnyNewtype, CarrierOf, iso } from 'newtype-ts' import * as t from 'io-ts' -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' /** * Returns a codec from a newtype @@ -11,7 +11,7 @@ import { either } from 'fp-ts/Either' * @example * import { fromNewtype } from 'io-ts-types/lib/fromNewtype' * import * as t from 'io-ts' - * import { right } from 'fp-ts/Either' + * import { right } from 'fp-ts/lib/Either' * import { PathReporter } from 'io-ts/lib/PathReporter' * import { Newtype, iso } from 'newtype-ts' * diff --git a/src/fromNullable.ts b/src/fromNullable.ts index f6343a5..ccdd91d 100644 --- a/src/fromNullable.ts +++ b/src/fromNullable.ts @@ -10,7 +10,7 @@ import { withValidate } from './withValidate' * @example * import { fromNullable } from 'io-ts-types/lib/fromNullable' * import * as t from 'io-ts' - * import { right } from 'fp-ts/Either' + * import { right } from 'fp-ts/lib/Either' * import { PathReporter } from 'io-ts/lib/PathReporter' * * const T = fromNullable(t.number, -1) diff --git a/src/mapOutput.ts b/src/mapOutput.ts index 9e22ab1..d93a2c4 100644 --- a/src/mapOutput.ts +++ b/src/mapOutput.ts @@ -10,7 +10,7 @@ import * as t from 'io-ts' * import * as t from 'io-ts' * import { mapOutput } from 'io-ts-types/lib/mapOutput' * import { optionFromNullable } from 'io-ts-types/lib/optionFromNullable' - * import { none, some } from 'fp-ts/Option' + * import { none, some } from 'fp-ts/lib/Option' * * // Input: t.Type, number | null, t.mixed> * const Input = optionFromNullable(t.number) diff --git a/src/nonEmptyArray.ts b/src/nonEmptyArray.ts index 5630fa4..a59502a 100644 --- a/src/nonEmptyArray.ts +++ b/src/nonEmptyArray.ts @@ -2,10 +2,10 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { NonEmptyArray, fromArray } from 'fp-ts/NonEmptyArray' -import { isNonEmpty } from 'fp-ts/Array' -import { either } from 'fp-ts/Either' -import { isNone } from 'fp-ts/Option' +import { NonEmptyArray, fromArray } from 'fp-ts/lib/NonEmptyArray' +import { isNonEmpty } from 'fp-ts/lib/Array' +import { either } from 'fp-ts/lib/Either' +import { isNone } from 'fp-ts/lib/Option' /** * @since 0.5.0 diff --git a/src/option.ts b/src/option.ts index 0159dc7..ffd7ef2 100644 --- a/src/option.ts +++ b/src/option.ts @@ -2,7 +2,7 @@ * @since 0.5.0 */ import * as t from 'io-ts' -import { Option } from 'fp-ts/Option' +import { Option } from 'fp-ts/lib/Option' const None = t.strict({ _tag: t.literal('None') @@ -16,8 +16,8 @@ const someLiteral = t.literal('Some') * * @example * import { option } from 'io-ts-types/lib/option' - * import { right } from 'fp-ts/Either' - * import { none, some } from 'fp-ts/Option' + * import { right } from 'fp-ts/lib/Either' + * import { none, some } from 'fp-ts/lib/Option' * import * as t from 'io-ts' * import { PathReporter } from 'io-ts/lib/PathReporter' * diff --git a/src/optionFromNullable.ts b/src/optionFromNullable.ts index 5bae549..92700e2 100644 --- a/src/optionFromNullable.ts +++ b/src/optionFromNullable.ts @@ -1,8 +1,8 @@ /** * @since 0.5.0 */ -import { either } from 'fp-ts/Either' -import { none, Option, option, some, toNullable } from 'fp-ts/Option' +import { either } from 'fp-ts/lib/Either' +import { none, Option, option, some, toNullable } from 'fp-ts/lib/Option' import * as t from 'io-ts' import { option as o } from './option' diff --git a/src/readonlySetFromArray.ts b/src/readonlySetFromArray.ts index 5f0b021..74ac5bd 100644 --- a/src/readonlySetFromArray.ts +++ b/src/readonlySetFromArray.ts @@ -1,7 +1,7 @@ /** * @since 0.5.7 */ -import { Ord } from 'fp-ts/Ord' +import { Ord } from 'fp-ts/lib/Ord' import * as t from 'io-ts' import { setFromArray } from './setFromArray' diff --git a/src/regexp.ts b/src/regexp.ts index 14d7248..8379542 100644 --- a/src/regexp.ts +++ b/src/regexp.ts @@ -14,7 +14,7 @@ export interface RegExpC extends t.Type {} /** * @example * import { regexp } from 'io-ts-types/lib/regexp' - * import { right } from 'fp-ts/Either' + * import { right } from 'fp-ts/lib/Either' * * const input1 = /\w+/ * const input2 = new RegExp('\\w+') diff --git a/src/setFromArray.ts b/src/setFromArray.ts index 1f73061..027742e 100644 --- a/src/setFromArray.ts +++ b/src/setFromArray.ts @@ -1,10 +1,10 @@ /** * @since 0.5.0 */ -import { Ord } from 'fp-ts/Ord' -import { every, fromArray, toArray } from 'fp-ts/Set' +import { Ord } from 'fp-ts/lib/Ord' +import { every, fromArray, toArray } from 'fp-ts/lib/Set' import * as t from 'io-ts' -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' /** * @since 0.5.0 diff --git a/src/withFallback.ts b/src/withFallback.ts index 3860f71..77e9b43 100644 --- a/src/withFallback.ts +++ b/src/withFallback.ts @@ -3,7 +3,7 @@ */ import * as t from 'io-ts' import { withValidate } from './withValidate' -import { orElse } from 'fp-ts/Either' +import { orElse } from 'fp-ts/lib/Either' /** * Returns a clone of the given codec that always succeed using the given value `a` if the original codec fails @@ -11,7 +11,7 @@ import { orElse } from 'fp-ts/Either' * @example * import { withFallback } from 'io-ts-types/lib/withFallback' * import * as t from 'io-ts' - * import { right } from 'fp-ts/Either' + * import { right } from 'fp-ts/lib/Either' * * const T = withFallback(t.number, -1) * diff --git a/src/withMessage.ts b/src/withMessage.ts index a515b69..1c07d7e 100644 --- a/src/withMessage.ts +++ b/src/withMessage.ts @@ -3,7 +3,7 @@ */ import * as t from 'io-ts' import { withValidate } from './withValidate' -import { mapLeft } from 'fp-ts/Either' +import { mapLeft } from 'fp-ts/lib/Either' /** * Returns a clone of the given codec that sets the given string as error messsage @@ -12,7 +12,7 @@ import { mapLeft } from 'fp-ts/Either' * import { withMessage } from 'io-ts-types/lib/withMessage' * import * as t from 'io-ts' * import { PathReporter } from 'io-ts/lib/PathReporter' - * import { right } from 'fp-ts/Either' + * import { right } from 'fp-ts/lib/Either' * * const T = withMessage(t.number, () => 'Invalid number') * diff --git a/src/withValidate.ts b/src/withValidate.ts index 922756c..d0a3620 100644 --- a/src/withValidate.ts +++ b/src/withValidate.ts @@ -11,7 +11,7 @@ import { clone } from './clone' * import { withValidate } from 'io-ts-types/lib/withValidate' * import * as t from 'io-ts' * import { PathReporter } from 'io-ts/lib/PathReporter' - * import { either, right } from 'fp-ts/Either' + * import { either, right } from 'fp-ts/lib/Either' * * const T = withValidate(t.number, (u, c) => either.map(t.number.validate(u, c), n => n * 2)) * diff --git a/test/DateFromNumber.ts b/test/DateFromNumber.ts index 5e38f5a..d5fa208 100644 --- a/test/DateFromNumber.ts +++ b/test/DateFromNumber.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import { DateFromNumber } from '../src' import { assertSuccess, assertFailure } from './helpers' -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' const d = new Date(1973, 10, 30) const n = d.getTime() diff --git a/test/DateFromUnixTime.ts b/test/DateFromUnixTime.ts index 884f945..a30a74e 100644 --- a/test/DateFromUnixTime.ts +++ b/test/DateFromUnixTime.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import { DateFromUnixTime } from '../src' import { assertSuccess, assertFailure } from './helpers' -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' const d = new Date(1973, 10, 30) const n = d.getTime() diff --git a/test/either.ts b/test/either.ts index d308b96..4f4d06a 100644 --- a/test/either.ts +++ b/test/either.ts @@ -1,5 +1,5 @@ import * as assert from 'assert' -import { left, right } from 'fp-ts/Either' +import { left, right } from 'fp-ts/lib/Either' import * as t from 'io-ts' import { either } from '../src' import { assertFailure, assertSuccess } from './helpers' diff --git a/test/helpers.ts b/test/helpers.ts index ab7aafc..62a5378 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import * as t from 'io-ts' import { PathReporter } from 'io-ts/lib/PathReporter' -import { isRight, isLeft } from 'fp-ts/Either' +import { isRight, isLeft } from 'fp-ts/lib/Either' export function assertStrictEqual(result: t.Validation, expected: any): void { if (isRight(result)) { diff --git a/test/nonEmptyArray.ts b/test/nonEmptyArray.ts index 03b7e79..ae34152 100644 --- a/test/nonEmptyArray.ts +++ b/test/nonEmptyArray.ts @@ -1,6 +1,6 @@ import { nonEmptyArray } from '../src' import * as t from 'io-ts' -import { cons } from 'fp-ts/NonEmptyArray' +import { cons } from 'fp-ts/lib/NonEmptyArray' import * as assert from 'assert' import { assertFailure, assertSuccess } from './helpers' diff --git a/test/option.ts b/test/option.ts index a1e61b3..d458651 100644 --- a/test/option.ts +++ b/test/option.ts @@ -1,5 +1,5 @@ import * as assert from 'assert' -import { none, some } from 'fp-ts/Option' +import { none, some } from 'fp-ts/lib/Option' import * as t from 'io-ts' import { NumberFromString } from '../src' import { option } from '../src' diff --git a/test/optionFromNullable.ts b/test/optionFromNullable.ts index 9377bc5..483b669 100644 --- a/test/optionFromNullable.ts +++ b/test/optionFromNullable.ts @@ -3,7 +3,7 @@ import { optionFromNullable } from '../src' import * as t from 'io-ts' import * as assert from 'assert' import { NumberFromString } from '../src' -import { none, some } from 'fp-ts/Option' +import { none, some } from 'fp-ts/lib/Option' describe('optionFromNullable', () => { it('name', () => { diff --git a/test/readonlyNonEmptyArray.ts b/test/readonlyNonEmptyArray.ts index 74a636e..56b402f 100644 --- a/test/readonlyNonEmptyArray.ts +++ b/test/readonlyNonEmptyArray.ts @@ -1,5 +1,5 @@ import * as assert from 'assert' -import { cons } from 'fp-ts/NonEmptyArray' +import { cons } from 'fp-ts/lib/NonEmptyArray' import * as t from 'io-ts' import { readonlyNonEmptyArray } from '../src' import { assertFailure, assertSuccess } from './helpers' diff --git a/test/readonlySetFromArray.ts b/test/readonlySetFromArray.ts index 7eb2cc5..018984d 100644 --- a/test/readonlySetFromArray.ts +++ b/test/readonlySetFromArray.ts @@ -2,7 +2,7 @@ import { readonlySetFromArray } from '../src' import * as t from 'io-ts' import * as assert from 'assert' import { assertFailure, assertSuccess } from './helpers' -import { ordNumber } from 'fp-ts/Ord' +import { ordNumber } from 'fp-ts/lib/Ord' describe('readonlySetFromArray', () => { it('name', () => { diff --git a/test/setFromArray.ts b/test/setFromArray.ts index 001379a..7c36319 100644 --- a/test/setFromArray.ts +++ b/test/setFromArray.ts @@ -2,7 +2,7 @@ import { setFromArray } from '../src' import * as t from 'io-ts' import * as assert from 'assert' import { assertFailure, assertSuccess } from './helpers' -import { ordNumber } from 'fp-ts/Ord' +import { ordNumber } from 'fp-ts/lib/Ord' describe('setFromArray', () => { it('name', () => { From 3e337eea83ebfa768c21c7e7f863b7a363ac8309 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Mon, 10 Aug 2020 11:09:08 +0900 Subject: [PATCH 12/13] Re-add import-path-rewrite to avoid breaking changes --- package-lock.json | 81 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 8 +++-- 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9ec62fd..3052e3c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -518,6 +518,12 @@ "@babel/types": "^7.3.0" } }, + "@types/color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", + "dev": true + }, "@types/events": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", @@ -2875,6 +2881,81 @@ "resolve-cwd": "^2.0.0" } }, + "import-path-rewrite": { + "version": "github:gcanti/import-path-rewrite#39b4178f9ff80aed3fa18a702584e0d0f0d6d8bc", + "from": "github:gcanti/import-path-rewrite", + "dev": true, + "requires": { + "chalk": "^3.0.0", + "glob": "^7.1.6" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", diff --git a/package.json b/package.json index 6e33626..7351e73 100644 --- a/package.json +++ b/package.json @@ -14,14 +14,15 @@ "test": "npm run build && npm run lint && npm run dtslint && npm run prettier && npm run jest && npm run docs", "clean": "rm -rf ./dist", "prebuild": "npm run clean", - "build": "tsc -p ./tsconfig.build.json && tsc -p ./tsconfig.build-es6.json && ts-node scripts/build", + "build": "tsc -p ./tsconfig.build.json && tsc -p ./tsconfig.build-es6.json && npm run import-path-rewrite && ts-node scripts/build", "postbuild": "prettier --loglevel=silent --write \"./dist/**/*.ts\"", "prepublishOnly": "ts-node scripts/pre-publish", "dtslint": "dtslint dtslint", "mocha": "mocha -r ts-node/register test/*.ts", "docs": "docs-ts", "prerelease": "npm run build", - "release": "ts-node scripts/release" + "release": "ts-node scripts/release", + "import-path-rewrite": "import-path-rewrite" }, "repository": { "type": "git", @@ -55,7 +56,8 @@ "ts-node": "3.2.1", "tslint": "^5.12.1", "tslint-config-standard": "^8.0.1", - "typescript": "^3.9.3" + "typescript": "^3.9.3", + "import-path-rewrite": "github:gcanti/import-path-rewrite" }, "tags": [ "io-ts", From 0a88803e77427dd3c705fce6bda5bb931c4cda3a Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Mon, 10 Aug 2020 11:09:26 +0900 Subject: [PATCH 13/13] revert fp-ts peer dep --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7351e73..4238a2c 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ }, "homepage": "https://github.com/gcanti/io-ts-types", "peerDependencies": { - "fp-ts": "^2.8.0", + "fp-ts": "^2.0.0", "io-ts": "^2.0.0", "monocle-ts": "^2.0.0", "newtype-ts": "^0.3.2"