Skip to content

Commit

Permalink
Merge pull request #31 from bitgopatmcl/vendor-dependencies
Browse files Browse the repository at this point in the history
Vendor or remove github dependencies
  • Loading branch information
ericcrosson-bitgo authored Nov 21, 2024
2 parents c8ddf4a + b7248a8 commit 2cda6d5
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 175 deletions.
170 changes: 0 additions & 170 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
102 changes: 102 additions & 0 deletions scripts/import-path-rewrite.js
Original file line number Diff line number Diff line change
@@ -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)
})

0 comments on commit 2cda6d5

Please sign in to comment.