diff --git a/package-lock.json b/package-lock.json index 40a2335d..c6c2adab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,9 +15,7 @@ "benchmark": "2.1.4", "docs-ts": "^0.3.4", "doctoc": "^2.2.1", - "dtslint": "github:gcanti/dtslint", "fp-ts": "^2.0.0", - "import-path-rewrite": "github:gcanti/import-path-rewrite", "jest": "^24.8.0", "mocha": "^10.6.0", "prettier": "^1.19.1", @@ -675,12 +673,6 @@ "integrity": "sha512-F6fVNOkGEkSdo/19yWYOwVKGvzbTeWkR/XQYBKtGBQ9oGRjBN9f/L4aJI4sDcVPJO58Y1CJZN8va9V2BhrZapA==", "dev": true }, - "node_modules/@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 - }, "node_modules/@types/events": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", @@ -2435,50 +2427,6 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, - "node_modules/dtslint": { - "version": "0.4.2", - "resolved": "git+ssh://git@github.com/gcanti/dtslint.git#fc1e289597786080ce559b4f8cc8798bb537080e", - "integrity": "sha512-ISpb4arQhIsk1vuxm3/upxJwZVbl1PJGxErDumjOiljxX0nRw69YqKiBMJJTHwN43vTr1yso01q2b8iM1NDEPg==", - "dev": true, - "license": "MIT", - "dependencies": { - "fs-extra": "^6.0.1", - "parsimmon": "^1.12.0", - "strip-json-comments": "^2.0.1", - "tslint": "^5.12.0", - "typescript": "next" - }, - "bin": { - "dtslint": "bin/index.js" - }, - "engines": { - "node": ">=6.10.0" - } - }, - "node_modules/dtslint/node_modules/fs-extra": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", - "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "node_modules/dtslint/node_modules/typescript": { - "version": "3.8.0-dev.20191105", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.0-dev.20191105.tgz", - "integrity": "sha512-bKujrrC0aQRihwWPuavqvlCArHqwXqGmUTwzpyojkTiHBMbfuuVxqM5fYDYLALe6B1eRGm5bFeNtFF/d/8CpCQ==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -3732,109 +3680,6 @@ "node": ">=6" } }, - "node_modules/import-path-rewrite": { - "version": "0.0.1", - "resolved": "git+ssh://git@github.com/gcanti/import-path-rewrite.git#0086599732ccc761a33255a702a07266895d0572", - "integrity": "sha512-VZzpN+7tj6RchW2ESfITEcJny0JEFjq+NpF48CDOqvGMPfcZRDNw14FPuFaM0GPQ8shMqI0YUQyy3eeZuDKFiw==", - "dev": true, - "license": "MIT", - "dependencies": { - "chalk": "^3.0.0", - "glob": "^7.1.6" - }, - "bin": { - "import-path-rewrite": "lib/bin.js" - }, - "peerDependencies": { - "fp-ts": "^2.0.0" - } - }, - "node_modules/import-path-rewrite/node_modules/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, - "dependencies": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/import-path-rewrite/node_modules/chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/import-path-rewrite/node_modules/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, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/import-path-rewrite/node_modules/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 - }, - "node_modules/import-path-rewrite/node_modules/glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dev": true, - "dependencies": { - "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" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/import-path-rewrite/node_modules/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, - "engines": { - "node": ">=8" - } - }, - "node_modules/import-path-rewrite/node_modules/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, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -6997,12 +6842,6 @@ "integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==", "dev": true }, - "node_modules/parsimmon": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.13.0.tgz", - "integrity": "sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==", - "dev": true - }, "node_modules/pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", @@ -8405,15 +8244,6 @@ "node": ">=0.10.0" } }, - "node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", diff --git a/package.json b/package.json index c6f5060e..457e2ce3 100644 --- a/package.json +++ b/package.json @@ -15,17 +15,16 @@ "jest": "jest", "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 declaration && npm run jest && npm run docs", + "test": "npm run prettier && npm run lint && npm run declaration && 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", "perf": "ts-node perf/index", - "dtslint": "dtslint dtslint", "declaration": "tsc -p declaration/tsconfig.json", "mocha": "TS_NODE_CACHE=false mocha -r ts-node/register test/*.ts", "doctoc": "doctoc README.md", "docs": "docs-ts", - "import-path-rewrite": "import-path-rewrite" + "import-path-rewrite": "node scripts/import-path-rewrite.js" }, "repository": { "type": "git", @@ -48,9 +47,7 @@ "benchmark": "2.1.4", "docs-ts": "^0.3.4", "doctoc": "^2.2.1", - "dtslint": "github:gcanti/dtslint", "fp-ts": "^2.0.0", - "import-path-rewrite": "github:gcanti/import-path-rewrite", "jest": "^24.8.0", "mocha": "^10.6.0", "prettier": "^1.19.1", diff --git a/scripts/import-path-rewrite.js b/scripts/import-path-rewrite.js new file mode 100644 index 00000000..9927ffcd --- /dev/null +++ b/scripts/import-path-rewrite.js @@ -0,0 +1,102 @@ +'use strict' +Object.defineProperty(exports, '__esModule', { value: true }) +/** + * @since 0.0.1 + */ +var A = require('fp-ts/lib/Array') +var Console_1 = require('fp-ts/lib/Console') +var IO = require('fp-ts/lib/IO') +var pipeable_1 = require('fp-ts/lib/pipeable') +var T = require('fp-ts/lib/Task') +var TE = require('fp-ts/lib/TaskEither') +var fs = require('fs') +var glob = require('glob') +var ES6_GLOB_PATTERN = 'es6/**/*.@(d.ts|js)' +var DIST_ES6_GLOB_PATTERN = 'dist/es6/**/*.@(d.ts|js)' +var packages = [ + 'fp-ts', + 'monocle-ts', + 'io-ts', + 'io-ts-types', + 'elm-ts', + 'fp-ts-contrib', + 'fp-ts-rxjs', + 'fp-ts-routing', + 'newtype-ts', + 'fp-ts-fluture', + 'parser-ts', + 'retry-ts', + 'hyper-ts', + 'fp—ts-local-storage' +] +var regexp = new RegExp('(\\s(?:from|module)\\s[\'|"](?:' + packages.join('|') + '))\\/lib\\/([\\w-\\/]+[\'|"])', 'gm') +/** + * @since 0.0.1 + */ +exports.replace = function (s) { + return s.replace(regexp, '$1/es6/$2') +} +var readFile = TE.taskify(fs.readFile) +var writeFile = TE.taskify(fs.writeFile) +function modifyFile(f) { + return function (path) { + return pipeable_1.pipe( + readFile(path, 'utf8'), + TE.map(f), + TE.chain(function (content) { + return writeFile(path, content) + }), + TE.chain(function () { + return TE.rightIO(Console_1.log(path + ' rewritten')) + }) + ) + } +} +function modifyFiles(f) { + return function (paths) { + return pipeable_1.pipe( + A.array.traverse(TE.taskEither)(paths, modifyFile(f)), + TE.map(function () { + return undefined + }) + ) + } +} +function modifyGlob(f) { + return function (pattern) { + return pipeable_1.pipe(glob.sync(pattern), TE.right, TE.chain(modifyFiles(f))) + } +} +var modify = modifyGlob(exports.replace) +var replaceFiles = pipeable_1.pipe( + modify(ES6_GLOB_PATTERN), + TE.chain(function () { + return modify(DIST_ES6_GLOB_PATTERN) + }) +) +var exit = function (code) { + return function () { + return process.exit(code) + } +} +function onLeft(e) { + return T.fromIO( + pipeable_1.pipe( + Console_1.log(e), + IO.chain(function () { + return exit(1) + }) + ) + ) +} +function onRight() { + return T.fromIO(Console_1.log('import rewrite succeeded!')) +} +/** + * @since 0.0.1 + */ +const main = pipeable_1.pipe(replaceFiles, TE.fold(onLeft, onRight)) + +main().catch(function (e) { + return console.log('Unexpected error: ' + e) +})