@typescript-tools/internal-dependencies
Advanced tools
Comparing version 2.1.2 to 2.1.3
@@ -6,2 +6,13 @@ # Change Log | ||
## [2.1.3](https://github.com/typescript-tools/typescript-tools/compare/@typescript-tools/internal-dependencies@2.1.2...@typescript-tools/internal-dependencies@2.1.3) (2021-03-04) | ||
### Bug Fixes | ||
* run program by invoking task ([70bfd73](https://github.com/typescript-tools/typescript-tools/commit/70bfd73bf38baeb6824afaf8291b9f31746e3307)) | ||
## [2.1.2](https://github.com/typescript-tools/typescript-tools/compare/@typescript-tools/internal-dependencies@2.1.1...@typescript-tools/internal-dependencies@2.1.2) (2021-02-20) | ||
@@ -8,0 +19,0 @@ |
@@ -46,17 +46,22 @@ #!/usr/bin/env node | ||
const PackageName_1 = require("@typescript-tools/io-ts/dist/lib/PackageName"); | ||
const monorepo_root_1 = require("@typescript-tools/monorepo-root"); | ||
const docstring = ` | ||
Usage: | ||
internal-dependencies [--path] <root> <package>... | ||
internal-dependencies [--root <root>] [--path] <package>... | ||
Options: | ||
root Root of lerna mono-repository | ||
packages Packages to print dependencies of (also reads from stdin) | ||
--path Print the relative path to each package from root | ||
packages Packages to print dependencies of (also reads from stdin) | ||
--root=<root> Root of lerna mono-repository | ||
--path Print the relative path to each package from root | ||
`; | ||
const CommandLineOptions = io_ts_docopt_1.withEncode(t.type({ | ||
'<root>': t.string, | ||
'<package>': t.array(PackageName_1.PackageName), | ||
'--path': t.boolean | ||
}), a => ({ | ||
root: a['<root>'], | ||
const CommandLineOptions = io_ts_docopt_1.withEncode(t.intersection([ | ||
t.type({ | ||
'<package>': t.array(PackageName_1.PackageName), | ||
'--path': t.boolean | ||
}), | ||
t.partial({ | ||
'--root': t.string, | ||
}), | ||
]), a => ({ | ||
root: a['--root'], | ||
packages: a['<package>'], | ||
@@ -67,18 +72,18 @@ mode: a['--path'] ? 'path' : 'name' | ||
// Widens the type of a particular Err into an Err | ||
const error = (error) => error; | ||
const error = t.identity; | ||
const decodeDocopt = (codec, docstring, options) => pipeable_1.pipe(io_ts_docopt_1.decodeDocopt(codec, docstring, options), E.mapLeft((err) => ({ type: 'docopt decode', err: PathReporter.failure(err).join('\n') })), TE.fromEither); | ||
const findMonorepoRoot = (a) => pipeable_1.pipe(O.fromNullable(a.root), O.fold(function_1.flow(monorepo_root_1.monorepoRoot, E.mapLeft(error)), E.right), E.map(root => Object.assign(a, { root })), TE.fromEither); | ||
const dependencyGraph = function_1.flow(dependency_graph_1.dependencyGraph, TE.mapLeft(error)); | ||
function main() { | ||
pipeable_1.pipe(decodeDocopt(CommandLineOptions, docstring, { | ||
argv: [ | ||
...process.argv.slice(2), | ||
// file descriptor '0' is stdin | ||
...!process.stdin.isTTY ? fs.readFileSync(0, 'utf-8').trim().split('\n') : [] | ||
] | ||
}), TE.chain(options => pipeable_1.pipe(dependencyGraph(options.root), TE.map(graph => pipeable_1.pipe(options.packages, A.chain(pkg => pipeable_1.pipe(O.fromNullable(graph.get(pkg)), O.getOrElseW(function_1.constant(A.empty)))))), TE.map(dependencies => ts_pattern_1.match(options.mode) | ||
.with('path', () => dependencies | ||
.map(shades_1.get('location')) | ||
.map(location => path.relative(options.root, location))) | ||
.otherwise(() => dependencies.map(shades_1.get('name')))), TE.map(A.uniq(Ord_1.ordString)), TE.map((dependencies) => dependencies.forEach(unary(console.log))))), TE.fold(function_1.flow(Console.error, IO.chain(() => process.exit(1)), T.fromIO), function_1.constant(T.of(undefined)))); | ||
} | ||
const exit = (code) => () => process.exit(code); | ||
const main = pipeable_1.pipe(decodeDocopt(CommandLineOptions, docstring, { | ||
argv: [ | ||
...process.argv.slice(2), | ||
// file descriptor '0' is stdin | ||
...!process.stdin.isTTY ? fs.readFileSync(0, 'utf-8').trim().split('\n') : [] | ||
] | ||
}), TE.chain(findMonorepoRoot), TE.chain(options => pipeable_1.pipe(dependencyGraph(options.root), TE.map(graph => pipeable_1.pipe(options.packages, A.chain(pkg => pipeable_1.pipe(O.fromNullable(graph.get(pkg)), O.getOrElseW(function_1.constant(A.empty)))))), TE.map(dependencies => ts_pattern_1.match(options.mode) | ||
.with('path', () => dependencies | ||
.map(shades_1.get('location')) | ||
.map(location => path.relative(options.root, location))) | ||
.otherwise(() => dependencies.map(shades_1.get('name')))), TE.map(A.uniq(Ord_1.ordString)), TE.map((dependencies) => dependencies.forEach(unary(console.log))))), TE.fold(function_1.flow(Console.error, IO.chain(() => exit(1)), T.fromIO), function_1.constant(T.of(undefined)))); | ||
main(); | ||
@@ -85,0 +90,0 @@ // Local Variables: |
{ | ||
"name": "@typescript-tools/internal-dependencies", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "Calculate package dependencies living in the same monorepo", | ||
@@ -54,2 +54,3 @@ "main": "dist/src/index.js", | ||
"@typescript-tools/io-ts": "^2.2.0", | ||
"@typescript-tools/monorepo-root": "^1.3.1", | ||
"fp-ts": "^2.9.3", | ||
@@ -112,3 +113,3 @@ "io-ts": "~2.1.3", | ||
}, | ||
"gitHead": "118dd51722697e77eb92251f8a9e38af1c20c529" | ||
"gitHead": "8bc17081f4fa1e60a960bf11a224e0884640cad7" | ||
} |
@@ -24,8 +24,8 @@ # internal-dependencies | ||
Usage: | ||
internal-dependencies [--path] <root> <package>... | ||
internal-dependencies [--root <root>] [--path] <package>... | ||
Options: | ||
root Root of lerna mono-repository | ||
packages Packages to print dependencies of (also reads from stdin) | ||
--path Print the relative path to each package from root | ||
packages Packages to print dependencies of (also reads from stdin) | ||
--root=<root> Root of lerna mono-repository | ||
--path Print the relative path to each package from root | ||
``` | ||
@@ -42,3 +42,3 @@ | ||
``` shell | ||
$ echo @typescript-tools/lerna-utils | node ./packages/internal-dependencies/dist/src/internal-dependencies.js . | ||
$ echo @typescript-tools/lerna-utils | node ./packages/internal-dependencies/dist/src/internal-dependencies.js | ||
@typescript-tools/io-ts | ||
@@ -51,5 +51,5 @@ ``` | ||
``` shell | ||
$ internal-dependencies --path . @typescript-tools/internal-dependencies | ||
$ internal-dependencies --path @typescript-tools/internal-dependencies | ||
packages/io-ts | ||
packages/lerna-utils | ||
``` |
Sorry, the diff of this file is not supported yet
19684
97
8