Skip to content

Commit 2cda6d5

Browse files
Merge pull request #31 from bitgopatmcl/vendor-dependencies
Vendor or remove github dependencies
2 parents c8ddf4a + b7248a8 commit 2cda6d5

File tree

3 files changed

+104
-175
lines changed

3 files changed

+104
-175
lines changed

package-lock.json

Lines changed: 0 additions & 170 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515
"jest": "jest",
1616
"prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --list-different \"{src,test}/**/*.ts\"",
1717
"fix-prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --write \"{src,test,examples,exercises}/**/*.ts\"",
18-
"test": "npm run prettier && npm run lint && npm run dtslint && npm run declaration && npm run jest && npm run docs",
18+
"test": "npm run prettier && npm run lint && npm run declaration && npm run jest && npm run docs",
1919
"clean": "rimraf lib/* es6/*",
2020
"build": "npm run clean && tsc && tsc -p tsconfig.es6.json && npm run import-path-rewrite",
2121
"prepublish": "npm run build",
2222
"perf": "ts-node perf/index",
23-
"dtslint": "dtslint dtslint",
2423
"declaration": "tsc -p declaration/tsconfig.json",
2524
"mocha": "TS_NODE_CACHE=false mocha -r ts-node/register test/*.ts",
2625
"doctoc": "doctoc README.md",
2726
"docs": "docs-ts",
28-
"import-path-rewrite": "import-path-rewrite"
27+
"import-path-rewrite": "node scripts/import-path-rewrite.js"
2928
},
3029
"repository": {
3130
"type": "git",
@@ -48,9 +47,7 @@
4847
"benchmark": "2.1.4",
4948
"docs-ts": "^0.3.4",
5049
"doctoc": "^2.2.1",
51-
"dtslint": "github:gcanti/dtslint",
5250
"fp-ts": "^2.0.0",
53-
"import-path-rewrite": "github:gcanti/import-path-rewrite",
5451
"jest": "^24.8.0",
5552
"mocha": "^10.6.0",
5653
"prettier": "^1.19.1",

scripts/import-path-rewrite.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
'use strict'
2+
Object.defineProperty(exports, '__esModule', { value: true })
3+
/**
4+
* @since 0.0.1
5+
*/
6+
var A = require('fp-ts/lib/Array')
7+
var Console_1 = require('fp-ts/lib/Console')
8+
var IO = require('fp-ts/lib/IO')
9+
var pipeable_1 = require('fp-ts/lib/pipeable')
10+
var T = require('fp-ts/lib/Task')
11+
var TE = require('fp-ts/lib/TaskEither')
12+
var fs = require('fs')
13+
var glob = require('glob')
14+
var ES6_GLOB_PATTERN = 'es6/**/*.@(d.ts|js)'
15+
var DIST_ES6_GLOB_PATTERN = 'dist/es6/**/*.@(d.ts|js)'
16+
var packages = [
17+
'fp-ts',
18+
'monocle-ts',
19+
'io-ts',
20+
'io-ts-types',
21+
'elm-ts',
22+
'fp-ts-contrib',
23+
'fp-ts-rxjs',
24+
'fp-ts-routing',
25+
'newtype-ts',
26+
'fp-ts-fluture',
27+
'parser-ts',
28+
'retry-ts',
29+
'hyper-ts',
30+
'fp—ts-local-storage'
31+
]
32+
var regexp = new RegExp('(\\s(?:from|module)\\s[\'|"](?:' + packages.join('|') + '))\\/lib\\/([\\w-\\/]+[\'|"])', 'gm')
33+
/**
34+
* @since 0.0.1
35+
*/
36+
exports.replace = function (s) {
37+
return s.replace(regexp, '$1/es6/$2')
38+
}
39+
var readFile = TE.taskify(fs.readFile)
40+
var writeFile = TE.taskify(fs.writeFile)
41+
function modifyFile(f) {
42+
return function (path) {
43+
return pipeable_1.pipe(
44+
readFile(path, 'utf8'),
45+
TE.map(f),
46+
TE.chain(function (content) {
47+
return writeFile(path, content)
48+
}),
49+
TE.chain(function () {
50+
return TE.rightIO(Console_1.log(path + ' rewritten'))
51+
})
52+
)
53+
}
54+
}
55+
function modifyFiles(f) {
56+
return function (paths) {
57+
return pipeable_1.pipe(
58+
A.array.traverse(TE.taskEither)(paths, modifyFile(f)),
59+
TE.map(function () {
60+
return undefined
61+
})
62+
)
63+
}
64+
}
65+
function modifyGlob(f) {
66+
return function (pattern) {
67+
return pipeable_1.pipe(glob.sync(pattern), TE.right, TE.chain(modifyFiles(f)))
68+
}
69+
}
70+
var modify = modifyGlob(exports.replace)
71+
var replaceFiles = pipeable_1.pipe(
72+
modify(ES6_GLOB_PATTERN),
73+
TE.chain(function () {
74+
return modify(DIST_ES6_GLOB_PATTERN)
75+
})
76+
)
77+
var exit = function (code) {
78+
return function () {
79+
return process.exit(code)
80+
}
81+
}
82+
function onLeft(e) {
83+
return T.fromIO(
84+
pipeable_1.pipe(
85+
Console_1.log(e),
86+
IO.chain(function () {
87+
return exit(1)
88+
})
89+
)
90+
)
91+
}
92+
function onRight() {
93+
return T.fromIO(Console_1.log('import rewrite succeeded!'))
94+
}
95+
/**
96+
* @since 0.0.1
97+
*/
98+
const main = pipeable_1.pipe(replaceFiles, TE.fold(onLeft, onRight))
99+
100+
main().catch(function (e) {
101+
return console.log('Unexpected error: ' + e)
102+
})

0 commit comments

Comments
 (0)