From 20d9e1c2968127801023f048216ea65f9b1a1c2f Mon Sep 17 00:00:00 2001 From: Christoph Thiede Date: Sun, 30 May 2021 02:42:49 +0200 Subject: [PATCH 1/5] Oclif: Add support for autocompletion --- package.json | 9 ++++++--- yarn.lock | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3e340f14..5b4aaba9 100644 --- a/package.json +++ b/package.json @@ -16,24 +16,27 @@ "*" ], "license": "UNLICENSED", - "main": "lib/index.js", + "main": "bin/run.js", "scripts": { "lint": "eslint . --ext=.js,.ts,.json", "test": "jest" }, "oclif": { "bin": "dowdep", - "commands": "./lib/cli/commands", + "commands": "./src/cli/commands", "description": "downstream repository mining CLI", "hooks": { "init": "./src/cli/oclif.init.ts" }, "plugins": [ - "@oclif/plugin-help" + "@oclif/plugin-autocomplete", + "@oclif/plugin-help", + "@oclif/plugin-not-found" ] }, "types": "lib/index.d.ts", "dependencies": { + "@oclif/plugin-autocomplete": "^0.3.0", "@types/node": "^15.0.3", "dotenv": "^9.0.2", "download-package-tarball": "^1.0.7", diff --git a/yarn.lock b/yarn.lock index 0177af5a..93ac8f8c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -577,7 +577,7 @@ supports-color "^5.4.0" tslib "^1" -"@oclif/command@^1.5.10", "@oclif/command@^1.5.20", "@oclif/command@^1.6", "@oclif/command@^1.6.0": +"@oclif/command@^1.5.10", "@oclif/command@^1.5.13", "@oclif/command@^1.5.20", "@oclif/command@^1.6", "@oclif/command@^1.6.0": version "1.8.0" resolved "https://registry.yarnpkg.com/@oclif/command/-/command-1.8.0.tgz#c1a499b10d26e9d1a611190a81005589accbb339" integrity sha512-5vwpq6kbvwkQwKqAoOU3L72GZ3Ta8RRrewKj9OJRolx28KLJJ8Dg9Rf7obRwt5jQA9bkYd8gqzMTrI7H3xLfaw== @@ -589,7 +589,7 @@ debug "^4.1.1" semver "^7.3.2" -"@oclif/config@^1.12.10", "@oclif/config@^1.12.6", "@oclif/config@^1.12.8", "@oclif/config@^1.15.1": +"@oclif/config@^1.12.10", "@oclif/config@^1.12.6", "@oclif/config@^1.12.8", "@oclif/config@^1.13.0", "@oclif/config@^1.15.1": version "1.17.0" resolved "https://registry.yarnpkg.com/@oclif/config/-/config-1.17.0.tgz#ba8639118633102a7e481760c50054623d09fcab" integrity sha512-Lmfuf6ubjQ4ifC/9bz1fSCHc6F6E653oyaRXxg+lgT4+bYf9bk+nqrUpAbrXyABkCqgIBiFr3J4zR/kiFdE1PA== @@ -637,6 +637,19 @@ chalk "^2.4.2" tslib "^1.9.3" +"@oclif/plugin-autocomplete@^0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@oclif/plugin-autocomplete/-/plugin-autocomplete-0.3.0.tgz#eec788596a88a4ca5170a9103b6c2835119a8fbd" + integrity sha512-gCuIUCswvoU1BxDDvHSUGxW8rFagiacle8jHqE49+WnuniXD/N8NmJvnzmlNyc8qLE192CnKK+qYyAF+vaFQBg== + dependencies: + "@oclif/command" "^1.5.13" + "@oclif/config" "^1.13.0" + chalk "^4.1.0" + cli-ux "^5.2.1" + debug "^4.0.0" + fs-extra "^9.0.1" + moment "^2.22.1" + "@oclif/plugin-help@^3": version "3.2.2" resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-3.2.2.tgz#063ee08cee556573a5198fbdfdaa32796deba0ed" From 2f2024aebf0c22ef83348a285a15140c5e1fc828 Mon Sep 17 00:00:00 2001 From: Christoph Thiede Date: Sun, 30 May 2021 02:44:09 +0200 Subject: [PATCH 2/5] Command search: Print out search results eagerly --- src/cli/commands/search.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cli/commands/search.ts b/src/cli/commands/search.ts index ba732ef7..a1b09fa0 100644 --- a/src/cli/commands/search.ts +++ b/src/cli/commands/search.ts @@ -1,6 +1,5 @@ import { Command, flags } from '@oclif/command' import * as util from 'util' -import asyncIteratorToArray from "it-all" import { ReferenceSearcher } from '../../references' @@ -26,8 +25,10 @@ export default class Search extends Command { const limit = flags.limit == -1 ? undefined : flags.limit const searcher = new ReferenceSearcher(packageName) - const references = await asyncIteratorToArray(searcher.searchReferences(limit)) + const references = searcher.searchReferences(limit) - console.log(util.inspect(references, { showHidden: false, depth: null, maxArrayLength: Infinity })) + for await (const reference of references) { + console.log(util.inspect(reference, { showHidden: false, depth: null, maxArrayLength: Infinity })) + } } } From 45752ab00dbff6f80fd64fb36be098ed3d94097f Mon Sep 17 00:00:00 2001 From: Christoph Thiede Date: Tue, 1 Jun 2021 23:00:32 +0000 Subject: [PATCH 3/5] Fix off-by-one error in references search --- src/references.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/references.ts b/src/references.ts index cdf7d27e..514f3dfc 100644 --- a/src/references.ts +++ b/src/references.ts @@ -70,7 +70,7 @@ export class ReferenceSearcher { for await (const depDirectory of depDirectories) { for await (const reference of this.basicSearchReferences(path.join(rootDirectory, depDirectory.name), undefined, depth + 1)) { yield reference - if (limit && ++i > limit) { + if (limit && ++i >= limit) { return } } From b4ecfbbf001958bd59838b9210381e6e9e4dd200 Mon Sep 17 00:00:00 2001 From: Christoph Thiede Date: Thu, 3 Jun 2021 18:24:17 +0000 Subject: [PATCH 4/5] Update README.md --- README.md | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d25ca533..23db6d62 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,46 @@ [![Test](https://github.com/LinqLover/downstream-repository-mining/actions/workflows/test.yml/badge.svg)](https://github.com/LinqLover/downstream-repository-mining/actions/workflows/test.yml) [![CodeFactor](https://www.codefactor.io/repository/github/linqlover/downstream-repository-mining/badge)](https://www.codefactor.io/repository/github/linqlover/downstream-repository-mining) -Student project as part of the course "Software Mining and Applications" offered by the Computer Graphics System Group ([@hpicgs](https://github.com/hpicgs)/[@varg-dev](https://github.com/varg-dev)) at the Hasso Plattner Institute (HPI), Potsdam, Germany. +Mine usage information about your JavaScript/TypeScript package from dependent repositories. For more information, read the [exposé](./docs/exposé.md): [![Exposé](https://github.com/LinqLover/downstream-repository-mining/actions/workflows/expos%C3%A9.yml/badge.svg?branch=master)](https://github.com/LinqLover/downstream-repository-mining/actions/workflows/exposé.yml?query=branch%3Amaster) +This is currently a student project for the course "Software Mining and Applications" offered by the Computer Graphics System Group ([@hpicgs](https://github.com/hpicgs)/[@varg-dev](https://github.com/varg-dev)) at the Hasso Plattner Institute (HPI), Potsdam, Germany. +Thanks to my supervisors, Daniel Limberger ([@cgcostume](https://github.com/cgcostume)) and Willy Scheibel ([@scheibel](https://github.com/scheibel))! + +## Installation + +```sh +$ yarn install +$ npm bind + +# Install autocompletion (optional) +$ dowdep autocomplete +``` + ## Usage -```bash -./bin/run.js +Find downstream dependencies of a package: + +```sh +dowdep list [--limit=] +``` + +Download downstream dependencies: + +```sh +NPM_CACHE= dowdep download [--limit=] +``` + +Search downloaded dependencies for references to package: + +```sh +NPM_CACHE= dowdep search [--limit=] +``` + +Show help: + +```sh +dowdep help [] ``` From f8ff9404c954b7033ec86e5014e62b39f0d45c28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Jun 2021 18:29:39 +0000 Subject: [PATCH 5/5] Bump @types/node from 15.6.1 to 15.12.0 Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.6.1 to 15.12.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b526b560..70630868 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "types": "lib/index.d.ts", "dependencies": { "@oclif/plugin-autocomplete": "^0.3.0", - "@types/node": "^15.6.1", + "@types/node": "^15.12.0", "dotenv": "^10.0.0", "download-package-tarball": "^1.0.7", "escape-string-regexp": "^5.0.0", diff --git a/yarn.lock b/yarn.lock index fb9d41f9..2926c842 100644 --- a/yarn.lock +++ b/yarn.lock @@ -849,10 +849,10 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21" integrity sha512-1z8k4wzFnNjVK/tlxvrWuK5WMt6mydWWP7+zvH5eFep4oj+UkrfiJTRtjCeBXNpwaA/FYqqtb4/QS4ianFpIRA== -"@types/node@*", "@types/node@^15.6.1": - version "15.6.1" - resolved "https://registry.yarnpkg.com/@types/node/-/node-15.6.1.tgz#32d43390d5c62c5b6ec486a9bc9c59544de39a08" - integrity sha512-7EIraBEyRHEe7CH+Fm1XvgqU6uwZN8Q7jppJGcqjROMT29qhAuuOxYB1uEY5UMYQKEmA5D+5tBnhdaPXSsLONA== +"@types/node@*", "@types/node@^15.12.0": + version "15.12.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.0.tgz#6a459d261450a300e6865faeddb5af01c3389bb3" + integrity sha512-+aHJvoCsVhO2ZCuT4o5JtcPrCPyDE3+1nvbDprYes+pPkEsbjH7AGUCNtjMOXS0fqH14t+B7yLzaqSz92FPWyw== "@types/node@^12.0.4": version "12.20.11"