Skip to content

Commit 1d49d1f

Browse files
committed
Refactor package-dependencies tool for global usage
- Updated package-dependencies.ts to include a shebang for execution as a script. - Changed the main entry point in package.json to point to the compiled JavaScript file. - Added bin configuration in package.json for global command usage as 'java-dependency-mapper'. - Enhanced README.md with instructions for global installation and usage of the tool.
1 parent ad9bc28 commit 1d49d1f

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ The input JSONL files are typically generated from Jarviz-lib static analysis of
2727
npm install
2828
```
2929

30+
### Global Installation
31+
32+
You can install this tool globally to use it from anywhere on your system:
33+
34+
```bash
35+
# From the project directory
36+
npm install -g .
37+
38+
# Or directly from npm (if published)
39+
# npm install -g java-dependency-mapper
40+
```
41+
42+
After global installation, you can run the tool using the `java-dependency-mapper` command.
43+
3044
## Usage
3145

3246
### Dependency Mapper
@@ -42,7 +56,11 @@ npm start -- path/to/your/dependencies.jsonl
4256
The package dependencies extractor tool generates a Markdown report of all base packages that a project depends on:
4357

4458
```bash
59+
# When installed locally
4560
npx ts-node package-dependencies.ts <jsonl-file-path> [--output <output-file-path>]
61+
62+
# When installed globally
63+
java-dependency-mapper <jsonl-file-path> [--output <output-file-path>]
4664
```
4765

4866
Where:
@@ -51,14 +69,17 @@ Where:
5169

5270
Example usage:
5371
```bash
54-
# Basic usage with default output file
72+
# Basic usage with default output file (local)
5573
npx ts-node package-dependencies.ts sample-dependencies.jsonl
5674

75+
# Basic usage with default output file (global)
76+
java-dependency-mapper sample-dependencies.jsonl
77+
5778
# Specify custom output file
58-
npx ts-node package-dependencies.ts sample-dependencies.jsonl --output reports/packages.md
79+
java-dependency-mapper sample-dependencies.jsonl --output reports/packages.md
5980

6081
# Using shorthand parameter
61-
npx ts-node package-dependencies.ts sample-dependencies.jsonl -o custom-output.md
82+
java-dependency-mapper sample-dependencies.jsonl -o custom-output.md
6283
```
6384

6485
## Development

package-dependencies.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env node
2+
13
import * as fs from 'fs';
24
import * as readline from 'readline';
35
import * as path from 'path';
@@ -281,7 +283,7 @@ class PackageDependencyExtractor {
281283

282284
async function main() {
283285
// Define usage information
284-
const usage = `Usage: ts-node package-dependencies.ts <jsonl-file-path> [options]
286+
const usage = `Usage: java-dependency-mapper <jsonl-file-path> [options]
285287
286288
Options:
287289
--output, -o <file> Specify output file path (default: package-dependencies.md)

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"name": "java-dependency-mapper",
33
"version": "1.0.0",
44
"description": "Tool for mapping Java dependencies from extracted EAR files",
5-
"main": "dependency-mapper.ts",
5+
"main": "dist/package-dependencies.js",
6+
"bin": {
7+
"java-dependency-mapper": "./dist/package-dependencies.js"
8+
},
69
"scripts": {
710
"start": "ts-node dependency-mapper.ts",
811
"build": "tsc",

0 commit comments

Comments
 (0)