From 19dc7ce3f11e79db82a23c99c1f845674ccdd18f Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:46:47 +0900 Subject: [PATCH 01/18] tsconfig setup matching that of fp-ts --- tsconfig.build-es6.json | 7 +++++++ tsconfig.es6.json => tsconfig.build.json | 6 +++--- tsconfig.json | 5 +++-- 3 files changed, 13 insertions(+), 5 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 000000000..6b5e341f1 --- /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 fa53d00ed..9d833c294 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 692989298..082d65dec 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,14 @@ { "compilerOptions": { - "outDir": "./lib", + "outDir": "./dist/lib", + "noEmit": true, "declaration": true, + "esModuleInterop": true, "module": "commonjs", "noImplicitReturns": false, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, - "noEmitOnError": false, "strict": true, "target": "es5", "moduleResolution": "node", From c4e6632485295d722dd9cb9b679b166b653e2445 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:47:04 +0900 Subject: [PATCH 02/18] copy over fp-ts build scripts --- 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 000000000..9e2c2c468 --- /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 000000000..ba6ec6f59 --- /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 000000000..0dc641bb5 --- /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 000000000..7629fe11d --- /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 1102b3bf3d15c4eb55d8f6c540949798d8798871 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:47:24 +0900 Subject: [PATCH 03/18] update all fp-ts usages in src --- src/Codec.ts | 8 ++++---- src/DecodeError.ts | 2 +- src/Decoder.ts | 18 +++++++++--------- src/Encoder.ts | 8 ++++---- src/Eq.ts | 6 +++--- src/FreeSemigroup.ts | 2 +- src/Guard.ts | 4 ++-- src/Kleisli.ts | 20 ++++++++++---------- src/PathReporter.ts | 2 +- src/Schema.ts | 2 +- src/Schemable.ts | 2 +- src/TaskDecoder.ts | 22 +++++++++++----------- src/ThrowReporter.ts | 2 +- src/Type.ts | 6 +++--- src/index.ts | 4 ++-- 15 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/Codec.ts b/src/Codec.ts index abbfbf323..2042f4bbf 100644 --- a/src/Codec.ts +++ b/src/Codec.ts @@ -8,9 +8,9 @@ * * @since 2.2.3 */ -import { identity } from 'fp-ts/lib/function' -import { Invariant3 } from 'fp-ts/lib/Invariant' -import { pipe } from 'fp-ts/lib/pipeable' +import { identity } from 'fp-ts/function' +import { Invariant3 } from 'fp-ts/Invariant' +import { pipe } from 'fp-ts/pipeable' import * as D from './Decoder' import * as E from './Encoder' import { Literal } from './Schemable' @@ -328,7 +328,7 @@ export const URI = 'io-ts/Codec' */ export type URI = typeof URI -declare module 'fp-ts/lib/HKT' { +declare module 'fp-ts/HKT' { interface URItoKind3 { readonly [URI]: Codec } diff --git a/src/DecodeError.ts b/src/DecodeError.ts index dac974485..274761d07 100644 --- a/src/DecodeError.ts +++ b/src/DecodeError.ts @@ -8,7 +8,7 @@ * * @since 2.2.7 */ -import { Semigroup } from 'fp-ts/lib/Semigroup' +import { Semigroup } from 'fp-ts/Semigroup' import * as FS from './FreeSemigroup' /** diff --git a/src/Decoder.ts b/src/Decoder.ts index 51d97db39..a6d3ff721 100644 --- a/src/Decoder.ts +++ b/src/Decoder.ts @@ -8,14 +8,14 @@ * * @since 2.2.7 */ -import { Alt2, Alt2C } from 'fp-ts/lib/Alt' -import { Bifunctor2 } from 'fp-ts/lib/Bifunctor' -import { Category2 } from 'fp-ts/lib/Category' -import * as E from 'fp-ts/lib/Either' -import { Refinement } from 'fp-ts/lib/function' -import { Functor2 } from 'fp-ts/lib/Functor' -import { MonadThrow2C } from 'fp-ts/lib/MonadThrow' -import { pipe } from 'fp-ts/lib/pipeable' +import { Alt2, Alt2C } from 'fp-ts/Alt' +import { Bifunctor2 } from 'fp-ts/Bifunctor' +import { Category2 } from 'fp-ts/Category' +import * as E from 'fp-ts/Either' +import { Refinement } from 'fp-ts/function' +import { Functor2 } from 'fp-ts/Functor' +import { MonadThrow2C } from 'fp-ts/MonadThrow' +import { pipe } from 'fp-ts/pipeable' import * as DE from './DecodeError' import * as FS from './FreeSemigroup' import * as G from './Guard' @@ -418,7 +418,7 @@ export const URI = 'io-ts/Decoder' */ export type URI = typeof URI -declare module 'fp-ts/lib/HKT' { +declare module 'fp-ts/HKT' { interface URItoKind2 { readonly [URI]: Decoder } diff --git a/src/Encoder.ts b/src/Encoder.ts index f06ad8832..9c4a0e448 100644 --- a/src/Encoder.ts +++ b/src/Encoder.ts @@ -8,10 +8,10 @@ * * @since 2.2.3 */ -import { Contravariant2 } from 'fp-ts/lib/Contravariant' -import { Category2 } from 'fp-ts/lib/Category' +import { Contravariant2 } from 'fp-ts/Contravariant' +import { Category2 } from 'fp-ts/Category' import { memoize, intersect_ } from './Schemable' -import { identity } from 'fp-ts/lib/function' +import { identity } from 'fp-ts/function' // ------------------------------------------------------------------------------------- // model @@ -207,7 +207,7 @@ export const URI = 'io-ts/Encoder' */ export type URI = typeof URI -declare module 'fp-ts/lib/HKT' { +declare module 'fp-ts/HKT' { interface URItoKind2 { readonly [URI]: Encoder } diff --git a/src/Eq.ts b/src/Eq.ts index 394a517fd..955084cba 100644 --- a/src/Eq.ts +++ b/src/Eq.ts @@ -8,9 +8,9 @@ * * @since 2.2.2 */ -import * as A from 'fp-ts/lib/Array' -import * as E from 'fp-ts/lib/Eq' -import * as R from 'fp-ts/lib/Record' +import * as A from 'fp-ts/Array' +import * as E from 'fp-ts/Eq' +import * as R from 'fp-ts/Record' import { memoize, Schemable1, WithRefine1, WithUnknownContainers1 } from './Schemable' import Eq = E.Eq diff --git a/src/FreeSemigroup.ts b/src/FreeSemigroup.ts index f1a764e70..815365574 100644 --- a/src/FreeSemigroup.ts +++ b/src/FreeSemigroup.ts @@ -8,7 +8,7 @@ * * @since 2.2.7 */ -import { Semigroup } from 'fp-ts/lib/Semigroup' +import { Semigroup } from 'fp-ts/Semigroup' /** * @category model diff --git a/src/Guard.ts b/src/Guard.ts index 2d8c7792f..1de88a422 100644 --- a/src/Guard.ts +++ b/src/Guard.ts @@ -8,7 +8,7 @@ * * @since 2.2.0 */ -import { pipe } from 'fp-ts/lib/pipeable' +import { pipe } from 'fp-ts/pipeable' import { Literal, memoize, Schemable1, WithRefine1, WithUnion1, WithUnknownContainers1 } from './Schemable' // ------------------------------------------------------------------------------------- @@ -290,7 +290,7 @@ export const URI = 'io-ts/Guard' */ export type URI = typeof URI -declare module 'fp-ts/lib/HKT' { +declare module 'fp-ts/HKT' { interface URItoKind { readonly [URI]: Guard } diff --git a/src/Kleisli.ts b/src/Kleisli.ts index b9ad74841..24dadce2c 100644 --- a/src/Kleisli.ts +++ b/src/Kleisli.ts @@ -8,18 +8,18 @@ * * @since 2.2.7 */ -import { Alt2C } from 'fp-ts/lib/Alt' -import { Applicative2C } from 'fp-ts/lib/Applicative' -import { Apply2C } from 'fp-ts/lib/Apply' -import { Bifunctor2 } from 'fp-ts/lib/Bifunctor' -import * as E from 'fp-ts/lib/Either' -import { Functor2C } from 'fp-ts/lib/Functor' -import { Kind2, URIS2 } from 'fp-ts/lib/HKT' -import { Monad2C } from 'fp-ts/lib/Monad' -import { MonadThrow2C } from 'fp-ts/lib/MonadThrow' +import { Alt2C } from 'fp-ts/Alt' +import { Applicative2C } from 'fp-ts/Applicative' +import { Apply2C } from 'fp-ts/Apply' +import { Bifunctor2 } from 'fp-ts/Bifunctor' +import * as E from 'fp-ts/Either' +import { Functor2C } from 'fp-ts/Functor' +import { Kind2, URIS2 } from 'fp-ts/HKT' +import { Monad2C } from 'fp-ts/Monad' +import { MonadThrow2C } from 'fp-ts/MonadThrow' import * as G from './Guard' import { intersect_, Literal, memoize } from './Schemable' -import { Lazy, Refinement } from 'fp-ts/lib/function' +import { Lazy, Refinement } from 'fp-ts/function' // ------------------------------------------------------------------------------------- // model diff --git a/src/PathReporter.ts b/src/PathReporter.ts index 66b953e98..a9559b47e 100644 --- a/src/PathReporter.ts +++ b/src/PathReporter.ts @@ -3,7 +3,7 @@ */ import { Reporter } from './Reporter' import { Context, getFunctionName, ValidationError } from '.' -import { fold } from 'fp-ts/lib/Either' +import { fold } from 'fp-ts/Either' function stringify(v: any): string { if (typeof v === 'function') { diff --git a/src/Schema.ts b/src/Schema.ts index 2a7e20652..c5ab7394a 100644 --- a/src/Schema.ts +++ b/src/Schema.ts @@ -8,7 +8,7 @@ * * @since 2.2.0 */ -import { HKT, Kind, Kind2, URIS, URIS2 } from 'fp-ts/lib/HKT' +import { HKT, Kind, Kind2, URIS, URIS2 } from 'fp-ts/HKT' import { memoize, Schemable, Schemable1, Schemable2C } from './Schemable' // ------------------------------------------------------------------------------------- diff --git a/src/Schemable.ts b/src/Schemable.ts index f5fc3929f..d64ae126d 100644 --- a/src/Schemable.ts +++ b/src/Schemable.ts @@ -8,7 +8,7 @@ * * @since 2.2.0 */ -import { HKT, Kind, Kind2, URIS, URIS2 } from 'fp-ts/lib/HKT' +import { HKT, Kind, Kind2, URIS, URIS2 } from 'fp-ts/HKT' /** * @since 2.2.0 diff --git a/src/TaskDecoder.ts b/src/TaskDecoder.ts index d8ef66dcd..d0619fdbf 100644 --- a/src/TaskDecoder.ts +++ b/src/TaskDecoder.ts @@ -8,16 +8,16 @@ * * @since 2.2.7 */ -import { Alt2, Alt2C } from 'fp-ts/lib/Alt' -import { Bifunctor2 } from 'fp-ts/lib/Bifunctor' -import { Category2 } from 'fp-ts/lib/Category' -import * as E from 'fp-ts/lib/Either' -import { Refinement } from 'fp-ts/lib/function' -import { Functor2 } from 'fp-ts/lib/Functor' -import { MonadThrow2C } from 'fp-ts/lib/MonadThrow' -import { pipe } from 'fp-ts/lib/pipeable' -import * as T from 'fp-ts/lib/Task' -import * as TE from 'fp-ts/lib/TaskEither' +import { Alt2, Alt2C } from 'fp-ts/Alt' +import { Bifunctor2 } from 'fp-ts/Bifunctor' +import { Category2 } from 'fp-ts/Category' +import * as E from 'fp-ts/Either' +import { Refinement } from 'fp-ts/function' +import { Functor2 } from 'fp-ts/Functor' +import { MonadThrow2C } from 'fp-ts/MonadThrow' +import { pipe } from 'fp-ts/pipeable' +import * as T from 'fp-ts/Task' +import * as TE from 'fp-ts/TaskEither' import * as DE from './DecodeError' import * as D from './Decoder' import * as FS from './FreeSemigroup' @@ -424,7 +424,7 @@ export const URI = 'io-ts/TaskDecoder' */ export type URI = typeof URI -declare module 'fp-ts/lib/HKT' { +declare module 'fp-ts/HKT' { interface URItoKind2 { readonly [URI]: TaskDecoder } diff --git a/src/ThrowReporter.ts b/src/ThrowReporter.ts index 8d991a992..667bfa2e3 100644 --- a/src/ThrowReporter.ts +++ b/src/ThrowReporter.ts @@ -4,7 +4,7 @@ */ import { Reporter } from './Reporter' import { PathReporter } from './PathReporter' -import { isLeft } from 'fp-ts/lib/Either' +import { isLeft } from 'fp-ts/Either' /** * @category deprecated diff --git a/src/Type.ts b/src/Type.ts index ace0caafe..ee845d68a 100644 --- a/src/Type.ts +++ b/src/Type.ts @@ -10,8 +10,8 @@ */ import * as t from './index' import { Literal, Schemable1, WithUnion1, WithRefine1, WithUnknownContainers1 } from './Schemable' -import * as E from 'fp-ts/lib/Either' -import { pipe } from 'fp-ts/lib/pipeable' +import * as E from 'fp-ts/Either' +import { pipe } from 'fp-ts/pipeable' // ------------------------------------------------------------------------------------- // model @@ -171,7 +171,7 @@ export const URI = 'io-ts/Type' */ export type URI = typeof URI -declare module 'fp-ts/lib/HKT' { +declare module 'fp-ts/HKT' { interface URItoKind { readonly [URI]: Type } diff --git a/src/index.ts b/src/index.ts index 10903a67e..8d5e967b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ /** * @since 1.0.0 */ -import { Either, isLeft, left, right } from 'fp-ts/lib/Either' -import { Predicate, Refinement } from 'fp-ts/lib/function' +import { Either, isLeft, left, right } from 'fp-ts/Either' +import { Predicate, Refinement } from 'fp-ts/function' // ------------------------------------------------------------------------------------- // model From 985dd78b80164d69a574467a301adb380aa90a2f Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:47:50 +0900 Subject: [PATCH 04/18] update all fp-ts usages in test (dont use lib) --- test/2.1.x/TypeClass.ts | 4 ++-- test/2.1.x/helpers.ts | 4 ++-- test/2.1.x/type.ts | 4 ++-- test/2.1.x/union.ts | 2 +- test/Arbitrary.ts | 2 +- test/Codec.ts | 4 ++-- test/Decoder.ts | 4 ++-- test/Encoder.ts | 2 +- test/Eq.ts | 4 ++-- test/Guard.ts | 2 +- test/Schema.ts | 4 ++-- test/TaskDecoder.ts | 6 +++--- test/Type.ts | 6 +++--- test/helpers.ts | 2 +- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/test/2.1.x/TypeClass.ts b/test/2.1.x/TypeClass.ts index c179b3e07..bc6f067f1 100644 --- a/test/2.1.x/TypeClass.ts +++ b/test/2.1.x/TypeClass.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' -import { Either, fold, right } from 'fp-ts/lib/Either' -import { pipe } from 'fp-ts/lib/pipeable' +import { Either, fold, right } from 'fp-ts/Either' +import { pipe } from 'fp-ts/pipeable' import * as t from '../../src/index' import { assertFailure, assertSuccess } from './helpers' diff --git a/test/2.1.x/helpers.ts b/test/2.1.x/helpers.ts index de7733520..9c1de5996 100644 --- a/test/2.1.x/helpers.ts +++ b/test/2.1.x/helpers.ts @@ -1,8 +1,8 @@ import * as assert from 'assert' -import { right, either, fold } from 'fp-ts/lib/Either' +import { right, either, fold } from 'fp-ts/Either' import * as t from '../../src/index' import { PathReporter } from '../../src/PathReporter' -import { pipe } from 'fp-ts/lib/pipeable' +import { pipe } from 'fp-ts/pipeable' export function assertStrictEqual(result: t.Validation, expected: any): void { pipe( diff --git a/test/2.1.x/type.ts b/test/2.1.x/type.ts index 66be70f60..b39c4bba1 100644 --- a/test/2.1.x/type.ts +++ b/test/2.1.x/type.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' -import { fold } from 'fp-ts/lib/Either' -import { pipe } from 'fp-ts/lib/pipeable' +import { fold } from 'fp-ts/Either' +import { pipe } from 'fp-ts/pipeable' import * as t from '../../src/index' import { assertFailure, assertStrictEqual, assertSuccess, NumberFromString } from './helpers' diff --git a/test/2.1.x/union.ts b/test/2.1.x/union.ts index d340cba05..385e9e747 100644 --- a/test/2.1.x/union.ts +++ b/test/2.1.x/union.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import * as t from '../../src/index' import { assertFailure, assertStrictEqual, assertSuccess, NumberFromString } from './helpers' -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' describe('union', () => { describe('name', () => { diff --git a/test/Arbitrary.ts b/test/Arbitrary.ts index 1126e1acf..995e4b63d 100644 --- a/test/Arbitrary.ts +++ b/test/Arbitrary.ts @@ -107,7 +107,7 @@ export const URI = 'Arbitrary' export type URI = typeof URI -declare module 'fp-ts/lib/HKT' { +declare module 'fp-ts/HKT' { interface URItoKind { readonly Arbitrary: Arbitrary } diff --git a/test/Codec.ts b/test/Codec.ts index 45ae60c7a..77b53b40a 100644 --- a/test/Codec.ts +++ b/test/Codec.ts @@ -1,10 +1,10 @@ import * as assert from 'assert' import * as _ from '../src/Codec' import * as D from '../src/Decoder' -import { pipe } from 'fp-ts/lib/pipeable' +import { pipe } from 'fp-ts/pipeable' import * as DE from '../src/DecodeError' import * as FS from '../src/FreeSemigroup' -import * as E from 'fp-ts/lib/Either' +import * as E from 'fp-ts/Either' import * as H from './helpers' const codecNumberFromString: _.Codec = _.make( diff --git a/test/Decoder.ts b/test/Decoder.ts index 0be76e0ac..59a0bf999 100644 --- a/test/Decoder.ts +++ b/test/Decoder.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' -import * as E from 'fp-ts/lib/Either' -import { pipe } from 'fp-ts/lib/pipeable' +import * as E from 'fp-ts/Either' +import { pipe } from 'fp-ts/pipeable' import * as DE from '../src/DecodeError' import * as FS from '../src/FreeSemigroup' import * as _ from '../src/Decoder' diff --git a/test/Encoder.ts b/test/Encoder.ts index 4bedd9563..0eac4f1c0 100644 --- a/test/Encoder.ts +++ b/test/Encoder.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' import * as E from '../src/Encoder' -import { pipe } from 'fp-ts/lib/pipeable' +import { pipe } from 'fp-ts/pipeable' import * as H from './helpers' describe('Encoder', () => { diff --git a/test/Eq.ts b/test/Eq.ts index 6e74bfc71..6b89bc4a6 100644 --- a/test/Eq.ts +++ b/test/Eq.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import * as E from '../src/Eq' -import { Eq } from 'fp-ts/lib/Eq' -import { pipe } from 'fp-ts/lib/pipeable' +import { Eq } from 'fp-ts/Eq' +import { pipe } from 'fp-ts/pipeable' describe('Eq', () => { it('literal', () => { diff --git a/test/Guard.ts b/test/Guard.ts index 5034563be..e0de97614 100644 --- a/test/Guard.ts +++ b/test/Guard.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' import * as G from '../src/Guard' -import { pipe } from 'fp-ts/lib/pipeable' +import { pipe } from 'fp-ts/pipeable' interface NonEmptyStringBrand { readonly NonEmptyString: unique symbol diff --git a/test/Schema.ts b/test/Schema.ts index e2ec4ffbe..e86fae9ee 100644 --- a/test/Schema.ts +++ b/test/Schema.ts @@ -1,6 +1,6 @@ import * as fc from 'fast-check' -import { isRight } from 'fp-ts/lib/Either' -import { pipe } from 'fp-ts/lib/pipeable' +import { isRight } from 'fp-ts/Either' +import { pipe } from 'fp-ts/pipeable' import * as D from '../src/Decoder' import * as Eq from '../src/Eq' import * as G from '../src/Guard' diff --git a/test/TaskDecoder.ts b/test/TaskDecoder.ts index aaafd270e..eb53fcbd9 100644 --- a/test/TaskDecoder.ts +++ b/test/TaskDecoder.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' -import * as E from 'fp-ts/lib/Either' -import { pipe } from 'fp-ts/lib/pipeable' -import * as TE from 'fp-ts/lib/TaskEither' +import * as E from 'fp-ts/Either' +import { pipe } from 'fp-ts/pipeable' +import * as TE from 'fp-ts/TaskEither' import * as DE from '../src/DecodeError' import * as FS from '../src/FreeSemigroup' import * as G from '../src/Guard' diff --git a/test/Type.ts b/test/Type.ts index 2c20a1562..70ed65281 100644 --- a/test/Type.ts +++ b/test/Type.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import * as fc from 'fast-check' -import { isRight, isLeft } from 'fp-ts/lib/Either' -import { Kind, URIS, HKT, URIS2, Kind2 } from 'fp-ts/lib/HKT' +import { isRight, isLeft } from 'fp-ts/Either' +import { Kind, URIS, HKT, URIS2, Kind2 } from 'fp-ts/HKT' import * as t from '../src' import * as D from '../src/Decoder' import * as G from '../src/Guard' @@ -19,7 +19,7 @@ import { } from '../src/Schemable' import * as _ from '../src/Type' import * as A from './Arbitrary' -import { pipe } from 'fp-ts/lib/pipeable' +import { pipe } from 'fp-ts/pipeable' interface Schema { (S: Schemable & WithUnknownContainers & WithUnion): HKT diff --git a/test/helpers.ts b/test/helpers.ts index 333b363bc..3a1395cf3 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -1,7 +1,7 @@ import * as G from '../src/Guard' import * as D from '../src/Decoder' import * as E from '../src/Encoder' -import { pipe } from 'fp-ts/lib/pipeable' +import { pipe } from 'fp-ts/pipeable' // ------------------------------------------------------------------------------------- // guards From 5728dd42fde46ff0e7f1511cf9f427a30131c50b Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:48:29 +0900 Subject: [PATCH 05/18] update all docs fp-ts imports --- Codec.md | 2 +- Decoder.md | 14 +++++++------- Eq.md | 2 +- Schema.md | 2 +- index.md | 14 +++++++------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Codec.md b/Codec.md index 9788eed56..117854a29 100644 --- a/Codec.md +++ b/Codec.md @@ -26,7 +26,7 @@ You can build a new codec using the `make` helper import * as C from 'io-ts/lib/Codec' import * as D from 'io-ts/lib/Decoder' import * as E from 'io-ts/lib/Encoder' -import { pipe } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/function' const decoder: D.Decoder = pipe( D.string, diff --git a/Decoder.md b/Decoder.md index 98cbadb72..30ecc265c 100644 --- a/Decoder.md +++ b/Decoder.md @@ -45,7 +45,7 @@ export const string: D.Decoder = { and we can use it as follows: ```ts -import { isRight } from 'fp-ts/lib/Either' +import { isRight } from 'fp-ts/Either' console.log(isRight(string.decode('a'))) // => true console.log(isRight(string.decode(null))) // => false @@ -54,8 +54,8 @@ console.log(isRight(string.decode(null))) // => false More generally the result of calling `decode` can be handled using [`fold`](https://gcanti.github.io/fp-ts/modules/Either.ts.html#fold) along with `pipe` (which is similar to the pipeline operator) ```ts -import { pipe } from 'fp-ts/lib/pipeable' -import { fold } from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/pipeable' +import { fold } from 'fp-ts/Either' console.log( pipe( @@ -289,7 +289,7 @@ const Bar: D.Decoder = D.lazy('Bar', () => The `refine` combinator allows to define refinements, for example a branded type ```ts -import { pipe } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/function' export interface PositiveBrand { readonly Positive: unique symbol @@ -311,8 +311,8 @@ console.log(isRight(Positive.decode(-1))) // => false The `parse` combinator is more powerful than `refine` in that you can change the output type ```ts -import { pipe } from 'fp-ts/lib/function' -import { isRight } from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/function' +import { isRight } from 'fp-ts/Either' export const NumberFromString: D.Decoder = pipe( D.string, @@ -354,7 +354,7 @@ export interface Person extends D.TypeOf {} # Built-in error reporter ```ts -import { isLeft } from 'fp-ts/lib/Either' +import { isLeft } from 'fp-ts/Either' export const Person = D.type({ name: D.string, diff --git a/Eq.md b/Eq.md index 0a3828586..9ce49b262 100644 --- a/Eq.md +++ b/Eq.md @@ -26,7 +26,7 @@ Instances must satisfy the following laws: **Example** ```ts -import { Eq } from 'fp-ts/lib/Eq' +import { Eq } from 'fp-ts/Eq' export const string: Eq = { equals: (x, y) => x === y diff --git a/Schema.md b/Schema.md index 3275a703a..95189845c 100644 --- a/Schema.md +++ b/Schema.md @@ -55,7 +55,7 @@ export type Int = number & IntBrand Now we must define a custom `MySchemable` type class containing a new member `Int`... ```ts -import { Kind2, URIS2, HKT } from 'fp-ts/lib/HKT' +import { Kind2, URIS2, HKT } from 'fp-ts/HKT' import * as S from 'io-ts/lib/Schemable' export interface MySchemable extends S.Schemable { diff --git a/index.md b/index.md index 4296fded5..b315f6df9 100644 --- a/index.md +++ b/index.md @@ -90,7 +90,7 @@ const string = new t.Type( and we can use it as follows: ```ts -import { isRight } from 'fp-ts/lib/Either' +import { isRight } from 'fp-ts/Either' isRight(string.decode('a string')) // true isRight(string.decode(null)) // false @@ -100,8 +100,8 @@ More generally the result of calling `decode` can be handled using [`fold`](http ```ts import * as t from 'io-ts' -import { pipe } from 'fp-ts/lib/pipeable' -import { fold } from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/pipeable' +import { fold } from 'fp-ts/Either' // failure handler const onLeft = (errors: t.Errors): string => `${errors.length} error(s) found` @@ -224,8 +224,8 @@ interface Errors extends Array {} Example ```ts -import { pipe } from 'fp-ts/lib/pipeable' -import { fold } from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/pipeable' +import { fold } from 'fp-ts/Either' const getPaths = (v: t.Validation): Array => { return pipe( @@ -247,7 +247,7 @@ You can set your own error message by providing a `message` argument to `failure Example ```ts -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' const NumberFromString = new t.Type( 'NumberFromString', @@ -434,7 +434,7 @@ type PartialUser = { You can define your own types. Let's see an example ```ts -import { either } from 'fp-ts/lib/Either' +import { either } from 'fp-ts/Either' // represents a Date from an ISO string const DateFromString = new t.Type( From d04d2910cf92b99cf3aa67d8908b57ef07e22895 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:49:18 +0900 Subject: [PATCH 06/18] remove import path rewrite, bump fp-ts peer dep --- package-lock.json | 75 ----------------------------------------------- package.json | 3 +- 2 files changed, 1 insertion(+), 77 deletions(-) diff --git a/package-lock.json b/package-lock.json index 382293c05..6046af13e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2941,81 +2941,6 @@ "resolve-cwd": "^3.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.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.0.tgz", - "integrity": "sha512-7kFQgnEaMdRtwf6uSfUnVr9gSGC7faurn+J/Mv90/W+iTtN0405/nLdopfMWwchyxhbGYl6TC4Sccn9TUkGAgg==", - "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 9b7511ce2..4d6063a99 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "homepage": "https://github.com/gcanti/io-ts", "dependencies": {}, "peerDependencies": { - "fp-ts": "^2.0.0" + "fp-ts": "^2.8.0" }, "devDependencies": { "@types/benchmark": "1.0.31", @@ -50,7 +50,6 @@ "dtslint": "github:gcanti/dtslint", "fast-check": "^1.24.2", "fp-ts": "^2.8.1", - "import-path-rewrite": "github:gcanti/import-path-rewrite", "jest": "25.2.7", "mocha": "7.1.1", "prettier": "2.0.2", From e69451220d06c49fc4f53f7747a110c8d4f4ff02 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:49:34 +0900 Subject: [PATCH 07/18] new build scripts --- package.json | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 4d6063a99..3080cba7b 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,6 @@ "name": "io-ts", "version": "2.2.9", "description": "TypeScript runtime type system for IO decoding/encoding", - "files": [ - "lib", - "es6" - ], "main": "lib/index.js", "module": "es6/index.js", "typings": "lib/index.d.ts", @@ -16,15 +12,16 @@ "prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --list-different \"{src,test}/**/*.ts\"", "fix-prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --write \"{src,test,examples,exercises}/**/*.ts\"", "test": "npm run prettier && npm run lint && npm run dtslint && npm run jest && npm run docs", - "clean": "rimraf lib/* es6/*", - "build": "npm run clean && tsc && tsc -p tsconfig.es6.json && npm run import-path-rewrite", - "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", "perf": "ts-node perf/index", "dtslint": "dtslint dtslint", "mocha": "TS_NODE_CACHE=false mocha -r ts-node/register test/*.ts", "doctoc": "doctoc README.md index.md Decoder.md Encoder.md Codec.md Eq.md Schema.md", - "docs": "docs-ts", - "import-path-rewrite": "import-path-rewrite" + "docs": "docs-ts" }, "repository": { "type": "git", From fd78cd18b80114be877bd24e547a39ad8f835a90 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:49:42 +0900 Subject: [PATCH 08/18] gitignore /dist --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1d675a13a..75c9cc260 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ *.log node_modules -lib -es6 +/dist dev coverage declaration/out/src From 603df65fc5e179a12f15080ae0e1bbb31aabf114 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 14:50:02 +0900 Subject: [PATCH 09/18] docs imports --- docs/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index 1075b9970..e9376c3e2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -73,7 +73,7 @@ const string = new t.Type( and we can use it as follows: ```ts -import { isRight } from 'fp-ts/lib/Either' +import { isRight } from 'fp-ts/Either' isRight(string.decode('a string')) // true isRight(string.decode(null)) // false @@ -83,8 +83,8 @@ More generally the result of calling `decode` can be handled using [`fold`](http ```ts import * as t from 'io-ts' -import { pipe } from 'fp-ts/lib/pipeable' -import { fold } from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/pipeable' +import { fold } from 'fp-ts/Either' // failure handler const onLeft = (errors: t.Errors): string => `${errors.length} error(s) found` From 94cf63fbc039686ea1cddcca52528a2a74aa6972 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 15:01:28 +0900 Subject: [PATCH 10/18] 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 0dc641bb5..c326efd04 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 dcf472aa205567510ac2f82162b498d68cb2ef1b Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 15:04:16 +0900 Subject: [PATCH 11/18] Release scripts --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3080cba7b..d73b1efc2 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,9 @@ "dtslint": "dtslint dtslint", "mocha": "TS_NODE_CACHE=false mocha -r ts-node/register test/*.ts", "doctoc": "doctoc README.md index.md Decoder.md Encoder.md Codec.md Eq.md Schema.md", - "docs": "docs-ts" + "docs": "docs-ts", + "prerelease": "npm run build", + "release": "ts-node scripts/release" }, "repository": { "type": "git", From e345417862b3bf9a1d7f71a04d7aa14c37c62256 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Sat, 8 Aug 2020 15:06:50 +0900 Subject: [PATCH 12/18] release script source --- 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 000000000..750f3eddd --- /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 c5c62047244158c357d1a655c7adf90a5b1f6658 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Mon, 10 Aug 2020 10:56:10 +0900 Subject: [PATCH 13/18] Revert "remove import path rewrite, bump fp-ts peer dep" This reverts commit d04d2910cf92b99cf3aa67d8908b57ef07e22895. --- package-lock.json | 75 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 +- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 6046af13e..382293c05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2941,6 +2941,81 @@ "resolve-cwd": "^3.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.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.0.tgz", + "integrity": "sha512-7kFQgnEaMdRtwf6uSfUnVr9gSGC7faurn+J/Mv90/W+iTtN0405/nLdopfMWwchyxhbGYl6TC4Sccn9TUkGAgg==", + "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 d73b1efc2..24af9c3b5 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "homepage": "https://github.com/gcanti/io-ts", "dependencies": {}, "peerDependencies": { - "fp-ts": "^2.8.0" + "fp-ts": "^2.0.0" }, "devDependencies": { "@types/benchmark": "1.0.31", @@ -49,6 +49,7 @@ "dtslint": "github:gcanti/dtslint", "fast-check": "^1.24.2", "fp-ts": "^2.8.1", + "import-path-rewrite": "github:gcanti/import-path-rewrite", "jest": "25.2.7", "mocha": "7.1.1", "prettier": "2.0.2", From ea7d26e7bc1d8c163b9b567e6012dfce0b73c594 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Mon, 10 Aug 2020 10:58:49 +0900 Subject: [PATCH 14/18] Revert "update all fp-ts usages in src" This reverts commit 1102b3bf3d15c4eb55d8f6c540949798d8798871. --- src/Codec.ts | 8 ++++---- src/DecodeError.ts | 2 +- src/Decoder.ts | 18 +++++++++--------- src/Encoder.ts | 8 ++++---- src/Eq.ts | 6 +++--- src/FreeSemigroup.ts | 2 +- src/Guard.ts | 4 ++-- src/Kleisli.ts | 20 ++++++++++---------- src/PathReporter.ts | 2 +- src/Schema.ts | 2 +- src/Schemable.ts | 2 +- src/TaskDecoder.ts | 22 +++++++++++----------- src/ThrowReporter.ts | 2 +- src/Type.ts | 6 +++--- src/index.ts | 4 ++-- 15 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/Codec.ts b/src/Codec.ts index 2042f4bbf..abbfbf323 100644 --- a/src/Codec.ts +++ b/src/Codec.ts @@ -8,9 +8,9 @@ * * @since 2.2.3 */ -import { identity } from 'fp-ts/function' -import { Invariant3 } from 'fp-ts/Invariant' -import { pipe } from 'fp-ts/pipeable' +import { identity } from 'fp-ts/lib/function' +import { Invariant3 } from 'fp-ts/lib/Invariant' +import { pipe } from 'fp-ts/lib/pipeable' import * as D from './Decoder' import * as E from './Encoder' import { Literal } from './Schemable' @@ -328,7 +328,7 @@ export const URI = 'io-ts/Codec' */ export type URI = typeof URI -declare module 'fp-ts/HKT' { +declare module 'fp-ts/lib/HKT' { interface URItoKind3 { readonly [URI]: Codec } diff --git a/src/DecodeError.ts b/src/DecodeError.ts index 274761d07..dac974485 100644 --- a/src/DecodeError.ts +++ b/src/DecodeError.ts @@ -8,7 +8,7 @@ * * @since 2.2.7 */ -import { Semigroup } from 'fp-ts/Semigroup' +import { Semigroup } from 'fp-ts/lib/Semigroup' import * as FS from './FreeSemigroup' /** diff --git a/src/Decoder.ts b/src/Decoder.ts index a6d3ff721..51d97db39 100644 --- a/src/Decoder.ts +++ b/src/Decoder.ts @@ -8,14 +8,14 @@ * * @since 2.2.7 */ -import { Alt2, Alt2C } from 'fp-ts/Alt' -import { Bifunctor2 } from 'fp-ts/Bifunctor' -import { Category2 } from 'fp-ts/Category' -import * as E from 'fp-ts/Either' -import { Refinement } from 'fp-ts/function' -import { Functor2 } from 'fp-ts/Functor' -import { MonadThrow2C } from 'fp-ts/MonadThrow' -import { pipe } from 'fp-ts/pipeable' +import { Alt2, Alt2C } from 'fp-ts/lib/Alt' +import { Bifunctor2 } from 'fp-ts/lib/Bifunctor' +import { Category2 } from 'fp-ts/lib/Category' +import * as E from 'fp-ts/lib/Either' +import { Refinement } from 'fp-ts/lib/function' +import { Functor2 } from 'fp-ts/lib/Functor' +import { MonadThrow2C } from 'fp-ts/lib/MonadThrow' +import { pipe } from 'fp-ts/lib/pipeable' import * as DE from './DecodeError' import * as FS from './FreeSemigroup' import * as G from './Guard' @@ -418,7 +418,7 @@ export const URI = 'io-ts/Decoder' */ export type URI = typeof URI -declare module 'fp-ts/HKT' { +declare module 'fp-ts/lib/HKT' { interface URItoKind2 { readonly [URI]: Decoder } diff --git a/src/Encoder.ts b/src/Encoder.ts index 9c4a0e448..f06ad8832 100644 --- a/src/Encoder.ts +++ b/src/Encoder.ts @@ -8,10 +8,10 @@ * * @since 2.2.3 */ -import { Contravariant2 } from 'fp-ts/Contravariant' -import { Category2 } from 'fp-ts/Category' +import { Contravariant2 } from 'fp-ts/lib/Contravariant' +import { Category2 } from 'fp-ts/lib/Category' import { memoize, intersect_ } from './Schemable' -import { identity } from 'fp-ts/function' +import { identity } from 'fp-ts/lib/function' // ------------------------------------------------------------------------------------- // model @@ -207,7 +207,7 @@ export const URI = 'io-ts/Encoder' */ export type URI = typeof URI -declare module 'fp-ts/HKT' { +declare module 'fp-ts/lib/HKT' { interface URItoKind2 { readonly [URI]: Encoder } diff --git a/src/Eq.ts b/src/Eq.ts index 955084cba..394a517fd 100644 --- a/src/Eq.ts +++ b/src/Eq.ts @@ -8,9 +8,9 @@ * * @since 2.2.2 */ -import * as A from 'fp-ts/Array' -import * as E from 'fp-ts/Eq' -import * as R from 'fp-ts/Record' +import * as A from 'fp-ts/lib/Array' +import * as E from 'fp-ts/lib/Eq' +import * as R from 'fp-ts/lib/Record' import { memoize, Schemable1, WithRefine1, WithUnknownContainers1 } from './Schemable' import Eq = E.Eq diff --git a/src/FreeSemigroup.ts b/src/FreeSemigroup.ts index 815365574..f1a764e70 100644 --- a/src/FreeSemigroup.ts +++ b/src/FreeSemigroup.ts @@ -8,7 +8,7 @@ * * @since 2.2.7 */ -import { Semigroup } from 'fp-ts/Semigroup' +import { Semigroup } from 'fp-ts/lib/Semigroup' /** * @category model diff --git a/src/Guard.ts b/src/Guard.ts index 1de88a422..2d8c7792f 100644 --- a/src/Guard.ts +++ b/src/Guard.ts @@ -8,7 +8,7 @@ * * @since 2.2.0 */ -import { pipe } from 'fp-ts/pipeable' +import { pipe } from 'fp-ts/lib/pipeable' import { Literal, memoize, Schemable1, WithRefine1, WithUnion1, WithUnknownContainers1 } from './Schemable' // ------------------------------------------------------------------------------------- @@ -290,7 +290,7 @@ export const URI = 'io-ts/Guard' */ export type URI = typeof URI -declare module 'fp-ts/HKT' { +declare module 'fp-ts/lib/HKT' { interface URItoKind { readonly [URI]: Guard } diff --git a/src/Kleisli.ts b/src/Kleisli.ts index 24dadce2c..b9ad74841 100644 --- a/src/Kleisli.ts +++ b/src/Kleisli.ts @@ -8,18 +8,18 @@ * * @since 2.2.7 */ -import { Alt2C } from 'fp-ts/Alt' -import { Applicative2C } from 'fp-ts/Applicative' -import { Apply2C } from 'fp-ts/Apply' -import { Bifunctor2 } from 'fp-ts/Bifunctor' -import * as E from 'fp-ts/Either' -import { Functor2C } from 'fp-ts/Functor' -import { Kind2, URIS2 } from 'fp-ts/HKT' -import { Monad2C } from 'fp-ts/Monad' -import { MonadThrow2C } from 'fp-ts/MonadThrow' +import { Alt2C } from 'fp-ts/lib/Alt' +import { Applicative2C } from 'fp-ts/lib/Applicative' +import { Apply2C } from 'fp-ts/lib/Apply' +import { Bifunctor2 } from 'fp-ts/lib/Bifunctor' +import * as E from 'fp-ts/lib/Either' +import { Functor2C } from 'fp-ts/lib/Functor' +import { Kind2, URIS2 } from 'fp-ts/lib/HKT' +import { Monad2C } from 'fp-ts/lib/Monad' +import { MonadThrow2C } from 'fp-ts/lib/MonadThrow' import * as G from './Guard' import { intersect_, Literal, memoize } from './Schemable' -import { Lazy, Refinement } from 'fp-ts/function' +import { Lazy, Refinement } from 'fp-ts/lib/function' // ------------------------------------------------------------------------------------- // model diff --git a/src/PathReporter.ts b/src/PathReporter.ts index a9559b47e..66b953e98 100644 --- a/src/PathReporter.ts +++ b/src/PathReporter.ts @@ -3,7 +3,7 @@ */ import { Reporter } from './Reporter' import { Context, getFunctionName, ValidationError } from '.' -import { fold } from 'fp-ts/Either' +import { fold } from 'fp-ts/lib/Either' function stringify(v: any): string { if (typeof v === 'function') { diff --git a/src/Schema.ts b/src/Schema.ts index c5ab7394a..2a7e20652 100644 --- a/src/Schema.ts +++ b/src/Schema.ts @@ -8,7 +8,7 @@ * * @since 2.2.0 */ -import { HKT, Kind, Kind2, URIS, URIS2 } from 'fp-ts/HKT' +import { HKT, Kind, Kind2, URIS, URIS2 } from 'fp-ts/lib/HKT' import { memoize, Schemable, Schemable1, Schemable2C } from './Schemable' // ------------------------------------------------------------------------------------- diff --git a/src/Schemable.ts b/src/Schemable.ts index d64ae126d..f5fc3929f 100644 --- a/src/Schemable.ts +++ b/src/Schemable.ts @@ -8,7 +8,7 @@ * * @since 2.2.0 */ -import { HKT, Kind, Kind2, URIS, URIS2 } from 'fp-ts/HKT' +import { HKT, Kind, Kind2, URIS, URIS2 } from 'fp-ts/lib/HKT' /** * @since 2.2.0 diff --git a/src/TaskDecoder.ts b/src/TaskDecoder.ts index d0619fdbf..d8ef66dcd 100644 --- a/src/TaskDecoder.ts +++ b/src/TaskDecoder.ts @@ -8,16 +8,16 @@ * * @since 2.2.7 */ -import { Alt2, Alt2C } from 'fp-ts/Alt' -import { Bifunctor2 } from 'fp-ts/Bifunctor' -import { Category2 } from 'fp-ts/Category' -import * as E from 'fp-ts/Either' -import { Refinement } from 'fp-ts/function' -import { Functor2 } from 'fp-ts/Functor' -import { MonadThrow2C } from 'fp-ts/MonadThrow' -import { pipe } from 'fp-ts/pipeable' -import * as T from 'fp-ts/Task' -import * as TE from 'fp-ts/TaskEither' +import { Alt2, Alt2C } from 'fp-ts/lib/Alt' +import { Bifunctor2 } from 'fp-ts/lib/Bifunctor' +import { Category2 } from 'fp-ts/lib/Category' +import * as E from 'fp-ts/lib/Either' +import { Refinement } from 'fp-ts/lib/function' +import { Functor2 } from 'fp-ts/lib/Functor' +import { MonadThrow2C } from 'fp-ts/lib/MonadThrow' +import { pipe } from 'fp-ts/lib/pipeable' +import * as T from 'fp-ts/lib/Task' +import * as TE from 'fp-ts/lib/TaskEither' import * as DE from './DecodeError' import * as D from './Decoder' import * as FS from './FreeSemigroup' @@ -424,7 +424,7 @@ export const URI = 'io-ts/TaskDecoder' */ export type URI = typeof URI -declare module 'fp-ts/HKT' { +declare module 'fp-ts/lib/HKT' { interface URItoKind2 { readonly [URI]: TaskDecoder } diff --git a/src/ThrowReporter.ts b/src/ThrowReporter.ts index 667bfa2e3..8d991a992 100644 --- a/src/ThrowReporter.ts +++ b/src/ThrowReporter.ts @@ -4,7 +4,7 @@ */ import { Reporter } from './Reporter' import { PathReporter } from './PathReporter' -import { isLeft } from 'fp-ts/Either' +import { isLeft } from 'fp-ts/lib/Either' /** * @category deprecated diff --git a/src/Type.ts b/src/Type.ts index ee845d68a..ace0caafe 100644 --- a/src/Type.ts +++ b/src/Type.ts @@ -10,8 +10,8 @@ */ import * as t from './index' import { Literal, Schemable1, WithUnion1, WithRefine1, WithUnknownContainers1 } from './Schemable' -import * as E from 'fp-ts/Either' -import { pipe } from 'fp-ts/pipeable' +import * as E from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/lib/pipeable' // ------------------------------------------------------------------------------------- // model @@ -171,7 +171,7 @@ export const URI = 'io-ts/Type' */ export type URI = typeof URI -declare module 'fp-ts/HKT' { +declare module 'fp-ts/lib/HKT' { interface URItoKind { readonly [URI]: Type } diff --git a/src/index.ts b/src/index.ts index 8d5e967b6..10903a67e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ /** * @since 1.0.0 */ -import { Either, isLeft, left, right } from 'fp-ts/Either' -import { Predicate, Refinement } from 'fp-ts/function' +import { Either, isLeft, left, right } from 'fp-ts/lib/Either' +import { Predicate, Refinement } from 'fp-ts/lib/function' // ------------------------------------------------------------------------------------- // model From ba5d9a99b65ae22cfb896307da8929ca11c5856e Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Mon, 10 Aug 2020 10:59:23 +0900 Subject: [PATCH 15/18] Revert "update all fp-ts usages in test (dont use lib)" This reverts commit 985dd78b80164d69a574467a301adb380aa90a2f. --- test/2.1.x/TypeClass.ts | 4 ++-- test/2.1.x/helpers.ts | 4 ++-- test/2.1.x/type.ts | 4 ++-- test/2.1.x/union.ts | 2 +- test/Arbitrary.ts | 2 +- test/Codec.ts | 4 ++-- test/Decoder.ts | 4 ++-- test/Encoder.ts | 2 +- test/Eq.ts | 4 ++-- test/Guard.ts | 2 +- test/Schema.ts | 4 ++-- test/TaskDecoder.ts | 6 +++--- test/Type.ts | 6 +++--- test/helpers.ts | 2 +- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/test/2.1.x/TypeClass.ts b/test/2.1.x/TypeClass.ts index bc6f067f1..c179b3e07 100644 --- a/test/2.1.x/TypeClass.ts +++ b/test/2.1.x/TypeClass.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' -import { Either, fold, right } from 'fp-ts/Either' -import { pipe } from 'fp-ts/pipeable' +import { Either, fold, right } from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/lib/pipeable' import * as t from '../../src/index' import { assertFailure, assertSuccess } from './helpers' diff --git a/test/2.1.x/helpers.ts b/test/2.1.x/helpers.ts index 9c1de5996..de7733520 100644 --- a/test/2.1.x/helpers.ts +++ b/test/2.1.x/helpers.ts @@ -1,8 +1,8 @@ import * as assert from 'assert' -import { right, either, fold } from 'fp-ts/Either' +import { right, either, fold } from 'fp-ts/lib/Either' import * as t from '../../src/index' import { PathReporter } from '../../src/PathReporter' -import { pipe } from 'fp-ts/pipeable' +import { pipe } from 'fp-ts/lib/pipeable' export function assertStrictEqual(result: t.Validation, expected: any): void { pipe( diff --git a/test/2.1.x/type.ts b/test/2.1.x/type.ts index b39c4bba1..66be70f60 100644 --- a/test/2.1.x/type.ts +++ b/test/2.1.x/type.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' -import { fold } from 'fp-ts/Either' -import { pipe } from 'fp-ts/pipeable' +import { fold } from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/lib/pipeable' import * as t from '../../src/index' import { assertFailure, assertStrictEqual, assertSuccess, NumberFromString } from './helpers' diff --git a/test/2.1.x/union.ts b/test/2.1.x/union.ts index 385e9e747..d340cba05 100644 --- a/test/2.1.x/union.ts +++ b/test/2.1.x/union.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import * as t from '../../src/index' import { assertFailure, assertStrictEqual, assertSuccess, NumberFromString } from './helpers' -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' describe('union', () => { describe('name', () => { diff --git a/test/Arbitrary.ts b/test/Arbitrary.ts index 995e4b63d..1126e1acf 100644 --- a/test/Arbitrary.ts +++ b/test/Arbitrary.ts @@ -107,7 +107,7 @@ export const URI = 'Arbitrary' export type URI = typeof URI -declare module 'fp-ts/HKT' { +declare module 'fp-ts/lib/HKT' { interface URItoKind { readonly Arbitrary: Arbitrary } diff --git a/test/Codec.ts b/test/Codec.ts index 77b53b40a..45ae60c7a 100644 --- a/test/Codec.ts +++ b/test/Codec.ts @@ -1,10 +1,10 @@ import * as assert from 'assert' import * as _ from '../src/Codec' import * as D from '../src/Decoder' -import { pipe } from 'fp-ts/pipeable' +import { pipe } from 'fp-ts/lib/pipeable' import * as DE from '../src/DecodeError' import * as FS from '../src/FreeSemigroup' -import * as E from 'fp-ts/Either' +import * as E from 'fp-ts/lib/Either' import * as H from './helpers' const codecNumberFromString: _.Codec = _.make( diff --git a/test/Decoder.ts b/test/Decoder.ts index 59a0bf999..0be76e0ac 100644 --- a/test/Decoder.ts +++ b/test/Decoder.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' -import * as E from 'fp-ts/Either' -import { pipe } from 'fp-ts/pipeable' +import * as E from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/lib/pipeable' import * as DE from '../src/DecodeError' import * as FS from '../src/FreeSemigroup' import * as _ from '../src/Decoder' diff --git a/test/Encoder.ts b/test/Encoder.ts index 0eac4f1c0..4bedd9563 100644 --- a/test/Encoder.ts +++ b/test/Encoder.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' import * as E from '../src/Encoder' -import { pipe } from 'fp-ts/pipeable' +import { pipe } from 'fp-ts/lib/pipeable' import * as H from './helpers' describe('Encoder', () => { diff --git a/test/Eq.ts b/test/Eq.ts index 6b89bc4a6..6e74bfc71 100644 --- a/test/Eq.ts +++ b/test/Eq.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import * as E from '../src/Eq' -import { Eq } from 'fp-ts/Eq' -import { pipe } from 'fp-ts/pipeable' +import { Eq } from 'fp-ts/lib/Eq' +import { pipe } from 'fp-ts/lib/pipeable' describe('Eq', () => { it('literal', () => { diff --git a/test/Guard.ts b/test/Guard.ts index e0de97614..5034563be 100644 --- a/test/Guard.ts +++ b/test/Guard.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' import * as G from '../src/Guard' -import { pipe } from 'fp-ts/pipeable' +import { pipe } from 'fp-ts/lib/pipeable' interface NonEmptyStringBrand { readonly NonEmptyString: unique symbol diff --git a/test/Schema.ts b/test/Schema.ts index e86fae9ee..e2ec4ffbe 100644 --- a/test/Schema.ts +++ b/test/Schema.ts @@ -1,6 +1,6 @@ import * as fc from 'fast-check' -import { isRight } from 'fp-ts/Either' -import { pipe } from 'fp-ts/pipeable' +import { isRight } from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/lib/pipeable' import * as D from '../src/Decoder' import * as Eq from '../src/Eq' import * as G from '../src/Guard' diff --git a/test/TaskDecoder.ts b/test/TaskDecoder.ts index eb53fcbd9..aaafd270e 100644 --- a/test/TaskDecoder.ts +++ b/test/TaskDecoder.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' -import * as E from 'fp-ts/Either' -import { pipe } from 'fp-ts/pipeable' -import * as TE from 'fp-ts/TaskEither' +import * as E from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/lib/pipeable' +import * as TE from 'fp-ts/lib/TaskEither' import * as DE from '../src/DecodeError' import * as FS from '../src/FreeSemigroup' import * as G from '../src/Guard' diff --git a/test/Type.ts b/test/Type.ts index 70ed65281..2c20a1562 100644 --- a/test/Type.ts +++ b/test/Type.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import * as fc from 'fast-check' -import { isRight, isLeft } from 'fp-ts/Either' -import { Kind, URIS, HKT, URIS2, Kind2 } from 'fp-ts/HKT' +import { isRight, isLeft } from 'fp-ts/lib/Either' +import { Kind, URIS, HKT, URIS2, Kind2 } from 'fp-ts/lib/HKT' import * as t from '../src' import * as D from '../src/Decoder' import * as G from '../src/Guard' @@ -19,7 +19,7 @@ import { } from '../src/Schemable' import * as _ from '../src/Type' import * as A from './Arbitrary' -import { pipe } from 'fp-ts/pipeable' +import { pipe } from 'fp-ts/lib/pipeable' interface Schema { (S: Schemable & WithUnknownContainers & WithUnion): HKT diff --git a/test/helpers.ts b/test/helpers.ts index 3a1395cf3..333b363bc 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -1,7 +1,7 @@ import * as G from '../src/Guard' import * as D from '../src/Decoder' import * as E from '../src/Encoder' -import { pipe } from 'fp-ts/pipeable' +import { pipe } from 'fp-ts/lib/pipeable' // ------------------------------------------------------------------------------------- // guards From afb69c3c07b4610440cf7b86e4e927f7e706cbb1 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Mon, 10 Aug 2020 11:01:25 +0900 Subject: [PATCH 16/18] Revert "update all docs fp-ts imports" This reverts commit 5728dd42fde46ff0e7f1511cf9f427a30131c50b. --- Codec.md | 2 +- Decoder.md | 14 +++++++------- Eq.md | 2 +- Schema.md | 2 +- index.md | 14 +++++++------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Codec.md b/Codec.md index 117854a29..9788eed56 100644 --- a/Codec.md +++ b/Codec.md @@ -26,7 +26,7 @@ You can build a new codec using the `make` helper import * as C from 'io-ts/lib/Codec' import * as D from 'io-ts/lib/Decoder' import * as E from 'io-ts/lib/Encoder' -import { pipe } from 'fp-ts/function' +import { pipe } from 'fp-ts/lib/function' const decoder: D.Decoder = pipe( D.string, diff --git a/Decoder.md b/Decoder.md index 30ecc265c..98cbadb72 100644 --- a/Decoder.md +++ b/Decoder.md @@ -45,7 +45,7 @@ export const string: D.Decoder = { and we can use it as follows: ```ts -import { isRight } from 'fp-ts/Either' +import { isRight } from 'fp-ts/lib/Either' console.log(isRight(string.decode('a'))) // => true console.log(isRight(string.decode(null))) // => false @@ -54,8 +54,8 @@ console.log(isRight(string.decode(null))) // => false More generally the result of calling `decode` can be handled using [`fold`](https://gcanti.github.io/fp-ts/modules/Either.ts.html#fold) along with `pipe` (which is similar to the pipeline operator) ```ts -import { pipe } from 'fp-ts/pipeable' -import { fold } from 'fp-ts/Either' +import { pipe } from 'fp-ts/lib/pipeable' +import { fold } from 'fp-ts/lib/Either' console.log( pipe( @@ -289,7 +289,7 @@ const Bar: D.Decoder = D.lazy('Bar', () => The `refine` combinator allows to define refinements, for example a branded type ```ts -import { pipe } from 'fp-ts/function' +import { pipe } from 'fp-ts/lib/function' export interface PositiveBrand { readonly Positive: unique symbol @@ -311,8 +311,8 @@ console.log(isRight(Positive.decode(-1))) // => false The `parse` combinator is more powerful than `refine` in that you can change the output type ```ts -import { pipe } from 'fp-ts/function' -import { isRight } from 'fp-ts/Either' +import { pipe } from 'fp-ts/lib/function' +import { isRight } from 'fp-ts/lib/Either' export const NumberFromString: D.Decoder = pipe( D.string, @@ -354,7 +354,7 @@ export interface Person extends D.TypeOf {} # Built-in error reporter ```ts -import { isLeft } from 'fp-ts/Either' +import { isLeft } from 'fp-ts/lib/Either' export const Person = D.type({ name: D.string, diff --git a/Eq.md b/Eq.md index 9ce49b262..0a3828586 100644 --- a/Eq.md +++ b/Eq.md @@ -26,7 +26,7 @@ Instances must satisfy the following laws: **Example** ```ts -import { Eq } from 'fp-ts/Eq' +import { Eq } from 'fp-ts/lib/Eq' export const string: Eq = { equals: (x, y) => x === y diff --git a/Schema.md b/Schema.md index 95189845c..3275a703a 100644 --- a/Schema.md +++ b/Schema.md @@ -55,7 +55,7 @@ export type Int = number & IntBrand Now we must define a custom `MySchemable` type class containing a new member `Int`... ```ts -import { Kind2, URIS2, HKT } from 'fp-ts/HKT' +import { Kind2, URIS2, HKT } from 'fp-ts/lib/HKT' import * as S from 'io-ts/lib/Schemable' export interface MySchemable extends S.Schemable { diff --git a/index.md b/index.md index b315f6df9..4296fded5 100644 --- a/index.md +++ b/index.md @@ -90,7 +90,7 @@ const string = new t.Type( and we can use it as follows: ```ts -import { isRight } from 'fp-ts/Either' +import { isRight } from 'fp-ts/lib/Either' isRight(string.decode('a string')) // true isRight(string.decode(null)) // false @@ -100,8 +100,8 @@ More generally the result of calling `decode` can be handled using [`fold`](http ```ts import * as t from 'io-ts' -import { pipe } from 'fp-ts/pipeable' -import { fold } from 'fp-ts/Either' +import { pipe } from 'fp-ts/lib/pipeable' +import { fold } from 'fp-ts/lib/Either' // failure handler const onLeft = (errors: t.Errors): string => `${errors.length} error(s) found` @@ -224,8 +224,8 @@ interface Errors extends Array {} Example ```ts -import { pipe } from 'fp-ts/pipeable' -import { fold } from 'fp-ts/Either' +import { pipe } from 'fp-ts/lib/pipeable' +import { fold } from 'fp-ts/lib/Either' const getPaths = (v: t.Validation): Array => { return pipe( @@ -247,7 +247,7 @@ You can set your own error message by providing a `message` argument to `failure Example ```ts -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' const NumberFromString = new t.Type( 'NumberFromString', @@ -434,7 +434,7 @@ type PartialUser = { You can define your own types. Let's see an example ```ts -import { either } from 'fp-ts/Either' +import { either } from 'fp-ts/lib/Either' // represents a Date from an ISO string const DateFromString = new t.Type( From 065a2d7114b0f861d631b9d70cc25ab0dfa413e9 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Mon, 10 Aug 2020 11:01:53 +0900 Subject: [PATCH 17/18] reintroduce import-path-rewrite for compatibility --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 24af9c3b5..ca1a93e80 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test": "npm run prettier && npm run lint && npm run dtslint && 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", "perf": "ts-node perf/index", @@ -23,7 +23,8 @@ "doctoc": "doctoc README.md index.md Decoder.md Encoder.md Codec.md Eq.md Schema.md", "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", From f6d15dca9f445671fecec4f61dd074fd422efbea Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Mon, 10 Aug 2020 11:05:07 +0900 Subject: [PATCH 18/18] Revert "docs imports" This reverts commit 603df65fc5e179a12f15080ae0e1bbb31aabf114. --- docs/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index e9376c3e2..1075b9970 100644 --- a/docs/index.md +++ b/docs/index.md @@ -73,7 +73,7 @@ const string = new t.Type( and we can use it as follows: ```ts -import { isRight } from 'fp-ts/Either' +import { isRight } from 'fp-ts/lib/Either' isRight(string.decode('a string')) // true isRight(string.decode(null)) // false @@ -83,8 +83,8 @@ More generally the result of calling `decode` can be handled using [`fold`](http ```ts import * as t from 'io-ts' -import { pipe } from 'fp-ts/pipeable' -import { fold } from 'fp-ts/Either' +import { pipe } from 'fp-ts/lib/pipeable' +import { fold } from 'fp-ts/lib/Either' // failure handler const onLeft = (errors: t.Errors): string => `${errors.length} error(s) found`