importy 0.0.10 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +44 -3
  2. package/dist/index.js +38 -30
  3. package/package.json +27 -3
package/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Importy
2
+ <img align="right" src="public/importy.png" alt="Importy CLI Tool" height="120" />
2
3
 
3
4
  A powerful CLI tool for analyzing JavaScript/TypeScript imports from libraries.
4
5
 
5
6
  [![npm version](https://img.shields.io/npm/v/importy.svg)](https://www.npmjs.com/package/importy)
6
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
- [![Publish](https://github.com/tvshevchuk/Importy/actions/workflows/publish.yml/badge.svg)](https://github.com/tvshevchuk/Importy/actions/workflows/publish.yml)
8
+
9
+ > **Version 0.1.0** - First stable release! 🎉 See [CHANGELOG.md](CHANGELOG.md) for details.
8
10
 
9
11
  ## Overview
10
12
 
@@ -26,6 +28,9 @@ yarn global add importy
26
28
 
27
29
  # Using pnpm
28
30
  pnpm add -g importy
31
+
32
+ # Verify installation
33
+ importy --version # Should output: 0.1.0
29
34
  ```
30
35
 
31
36
  ## Usage
@@ -112,7 +117,7 @@ Importy uses parallel processing with promises, making it efficient even for lar
112
117
 
113
118
  ### Prerequisites
114
119
 
115
- - Node.js 16+
120
+ - Node.js 18+
116
121
  - npm, yarn, or pnpm
117
122
 
118
123
  ### Setup
@@ -159,13 +164,49 @@ Contributions are welcome! Please feel free to submit a Pull Request.
159
164
  4. Push to the branch (`git push origin feature/amazing-feature`)
160
165
  5. Open a Pull Request
161
166
 
167
+ ### Development Workflow
168
+
169
+ ```bash
170
+ # Setup
171
+ git clone https://github.com/tvshevchuk/Importy.git
172
+ cd importy
173
+ pnpm install
174
+
175
+ # Development
176
+ npm run dev # Development mode
177
+ npm run check # Code quality checks
178
+ npm test # Run tests
179
+ npm run build # Build project
180
+
181
+ # Release (maintainers only)
182
+ npm run release:check # Check if ready for release
183
+ npm run release:patch # Create patch release
184
+ npm run release:minor # Create minor release
185
+ npm run release:major # Create major release
186
+ ```
187
+
188
+ ### Automated Releases
189
+
190
+ This project uses automated releases via GitHub Actions. When a pull request with a version bump is merged to main, it automatically:
191
+
192
+ - Runs tests and quality checks
193
+ - Updates the changelog
194
+ - Creates a GitHub release
195
+ - Publishes to npm
196
+
197
+ See [Release Process](.github/RELEASE_PROCESS.md) for detailed information.
198
+
162
199
  ## Troubleshooting
163
200
 
164
201
  ### Common Issues
165
202
 
166
- - **ES Module Compatibility**: If you encounter issues with ES modules, ensure your Node.js version is compatible (16+) and you're using the correct import syntax.
203
+ - **ES Module Compatibility**: If you encounter issues with ES modules, ensure your Node.js version is compatible (18+) and you're using the correct import syntax.
167
204
  - **Parsing Errors**: Complex TypeScript/JSX syntax may occasionally cause parsing errors. These files are skipped with a warning.
168
205
 
206
+ ## Changelog
207
+
208
+ See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes and releases.
209
+
169
210
  ## License
170
211
 
171
212
  This project is licensed under the MIT License - see the LICENSE file for details.
package/dist/index.js CHANGED
@@ -3,16 +3,16 @@
3
3
  // src/index.ts
4
4
  import fs2 from "fs";
5
5
  import path2 from "path";
6
- import { program } from "commander";
7
- import { fileURLToPath } from "url";
8
6
  import { dirname } from "path";
7
+ import { fileURLToPath } from "url";
8
+ import { program } from "commander";
9
9
 
10
10
  // src/cli.ts
11
11
  import fs from "fs";
12
+ import os from "os";
12
13
  import path from "path";
13
14
  import * as parser from "@babel/parser";
14
15
  import _traverse from "@babel/traverse";
15
- import os from "os";
16
16
  var traverse = _traverse.default;
17
17
  function isJavaScriptFile(file) {
18
18
  return /\.(js|ts|jsx|tsx)$/.test(file);
@@ -40,11 +40,17 @@ function getAllFiles(dirPath, arrayOfFiles = [], includePattern, excludePattern,
40
40
  }
41
41
  }
42
42
  } catch (error) {
43
- if (verbose) console.warn(`Error accessing file ${fullPath}: ${error instanceof Error ? error.message : String(error)}`);
43
+ if (verbose)
44
+ console.warn(
45
+ `Error accessing file ${fullPath}: ${error instanceof Error ? error.message : String(error)}`
46
+ );
44
47
  }
45
48
  }
46
49
  } catch (error) {
47
- if (verbose) console.error(`Error reading directory ${dirPath}: ${error instanceof Error ? error.message : String(error)}`);
50
+ if (verbose)
51
+ console.error(
52
+ `Error reading directory ${dirPath}: ${error instanceof Error ? error.message : String(error)}`
53
+ );
48
54
  }
49
55
  return arrayOfFiles;
50
56
  }
@@ -54,7 +60,7 @@ function minimatch(filePath, pattern) {
54
60
  const regex = new RegExp(`^${regExpPattern}$`, "i");
55
61
  const result = regex.test(filePath);
56
62
  return result;
57
- } catch (error) {
63
+ } catch (_error) {
58
64
  console.warn(`Invalid pattern: ${pattern}`);
59
65
  return false;
60
66
  }
@@ -82,7 +88,9 @@ async function processFilesInBatches(items, batchSize, processor, onProgress) {
82
88
  }
83
89
  return result;
84
90
  } catch (error) {
85
- console.warn(`Error processing item: ${error instanceof Error ? error.message : String(error)}`);
91
+ console.warn(
92
+ `Error processing item: ${error instanceof Error ? error.message : String(error)}`
93
+ );
86
94
  completed++;
87
95
  if (onProgress) {
88
96
  onProgress(completed, total);
@@ -105,7 +113,7 @@ function extractImportsFromFile(filePath, targetLib) {
105
113
  plugins: ["typescript", "jsx"],
106
114
  errorRecovery: true
107
115
  });
108
- } catch (err) {
116
+ } catch (_err) {
109
117
  try {
110
118
  ast = parser.parse(code, {
111
119
  sourceType: "module",
@@ -118,7 +126,6 @@ function extractImportsFromFile(filePath, targetLib) {
118
126
  }
119
127
  }
120
128
  const matches = [];
121
- const lines = code.split("\n");
122
129
  traverse(ast, {
123
130
  ImportDeclaration(path3) {
124
131
  const node = path3.node;
@@ -149,7 +156,9 @@ function extractImportsFromFile(filePath, targetLib) {
149
156
  });
150
157
  return matches;
151
158
  } catch (error) {
152
- console.warn(`Error reading file ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
159
+ console.warn(
160
+ `Error reading file ${filePath}: ${error instanceof Error ? error.message : String(error)}`
161
+ );
153
162
  return [];
154
163
  }
155
164
  }
@@ -176,7 +185,8 @@ async function analyzeImports(options2) {
176
185
  };
177
186
  }
178
187
  const batchSize = Math.max(1, Math.ceil(allFiles.length / concurrency));
179
- if (verbose) console.log(`Processing ${allFiles.length} files with ${concurrency} concurrent processes`);
188
+ if (verbose)
189
+ console.log(`Processing ${allFiles.length} files with ${concurrency} concurrent processes`);
180
190
  let processedCount = 0;
181
191
  const results = await processFilesInBatches(
182
192
  allFiles,
@@ -211,7 +221,9 @@ async function analyzeImports(options2) {
211
221
  const totalImports = Object.values(output).reduce((sum, files) => sum + files.length, 0);
212
222
  const totalComponents = Object.keys(output).length;
213
223
  if (verbose) {
214
- console.log(`Analysis complete - Found ${totalComponents} components with ${totalImports} total imports across ${allFiles.length} files`);
224
+ console.log(
225
+ `Analysis complete - Found ${totalComponents} components with ${totalImports} total imports across ${allFiles.length} files`
226
+ );
215
227
  }
216
228
  return {
217
229
  summary: {
@@ -225,6 +237,15 @@ async function analyzeImports(options2) {
225
237
  }
226
238
 
227
239
  // src/index.ts
240
+ var REQUIRED_NODE_VERSION = 18;
241
+ var currentNodeVersion = Number.parseInt(process.version.slice(1).split(".")[0], 10);
242
+ if (currentNodeVersion < REQUIRED_NODE_VERSION) {
243
+ console.error(
244
+ `\u274C Error: Node.js ${REQUIRED_NODE_VERSION}+ is required. You are running Node.js ${process.version}`
245
+ );
246
+ console.error("Please upgrade your Node.js version: https://nodejs.org/");
247
+ process.exit(1);
248
+ }
228
249
  var __filename = fileURLToPath(import.meta.url);
229
250
  var __dirname = dirname(__filename);
230
251
  var packageJson;
@@ -232,20 +253,11 @@ try {
232
253
  const packagePath = path2.resolve(__dirname, "../package.json");
233
254
  const packageData = fs2.readFileSync(packagePath, "utf8");
234
255
  packageJson = JSON.parse(packageData);
235
- } catch (error) {
256
+ } catch (_error) {
236
257
  packageJson = { version: "0.0.0", name: "importy" };
237
258
  console.warn("Could not load package.json, using default version");
238
259
  }
239
- program.version(packageJson.version).description("Analyze JavaScript/TypeScript imports from a specific library").requiredOption("-d, --dir <directory>", "Directory to scan").requiredOption("-l, --lib <library>", "Library name to match").option(
240
- "-o, --output <file>",
241
- "Output results to a JSON file instead of stdout"
242
- ).option("-v, --verbose", "Enable verbose logging").option(
243
- "-i, --include <pattern>",
244
- "Only include files matching pattern (glob)"
245
- ).option("-e, --exclude <pattern>", "Exclude files matching pattern (glob)").option(
246
- "-c, --concurrency <number>",
247
- "Number of worker threads (defaults to CPU count - 1)"
248
- ).parse(process.argv);
260
+ program.version(packageJson.version).description("Analyze JavaScript/TypeScript imports from a specific library").requiredOption("-d, --dir <directory>", "Directory to scan").requiredOption("-l, --lib <library>", "Library name to match").option("-o, --output <file>", "Output results to a JSON file instead of stdout").option("-v, --verbose", "Enable verbose logging").option("-i, --include <pattern>", "Only include files matching pattern (glob)").option("-e, --exclude <pattern>", "Exclude files matching pattern (glob)").option("-c, --concurrency <number>", "Number of worker threads (defaults to CPU count - 1)").parse(process.argv);
249
261
  var options = program.opts();
250
262
  async function main() {
251
263
  try {
@@ -255,7 +267,7 @@ async function main() {
255
267
  include: options.include,
256
268
  exclude: options.exclude,
257
269
  verbose: options.verbose || false,
258
- concurrency: options.concurrency ? parseInt(options.concurrency, 10) : void 0
270
+ concurrency: options.concurrency ? Number.parseInt(options.concurrency, 10) : void 0
259
271
  });
260
272
  if (options.output) {
261
273
  try {
@@ -271,9 +283,7 @@ async function main() {
271
283
  console.log(JSON.stringify(result, null, 2));
272
284
  }
273
285
  if (Object.keys(result.components).length === 0) {
274
- console.warn(
275
- `No imports from '${options.lib}' were found in the specified directory.`
276
- );
286
+ console.warn(`No imports from '${options.lib}' were found in the specified directory.`);
277
287
  process.exit(0);
278
288
  }
279
289
  return result;
@@ -285,8 +295,6 @@ async function main() {
285
295
  }
286
296
  }
287
297
  main().catch((error) => {
288
- console.error(
289
- `Unhandled error: ${error instanceof Error ? error.message : String(error)}`
290
- );
298
+ console.error(`Unhandled error: ${error instanceof Error ? error.message : String(error)}`);
291
299
  process.exit(1);
292
300
  });
package/package.json CHANGED
@@ -1,15 +1,22 @@
1
1
  {
2
2
  "name": "importy",
3
- "version": "0.0.10",
3
+ "version": "0.1.1",
4
4
  "description": "A CLI tool for analyzing JavaScript/TypeScript imports from libraries",
5
+ "homepage": "https://github.com/tvshevchuk/Importy#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/tvshevchuk/Importy/issues"
8
+ },
5
9
  "repository": {
6
10
  "type": "git",
7
11
  "url": "https://github.com/tvshevchuk/Importy"
8
12
  },
13
+ "engines": {
14
+ "node": ">=18.0.0"
15
+ },
9
16
  "type": "module",
10
17
  "main": "./dist/index.js",
11
18
  "bin": {
12
- "inspect-imports": "./dist/index.js"
19
+ "importy": "./dist/index.js"
13
20
  },
14
21
  "author": "Taras Shevchuk",
15
22
  "license": "MIT",
@@ -21,6 +28,7 @@
21
28
  ],
22
29
  "devDependencies": {
23
30
  "@babel/types": "7.27.3",
31
+ "@biomejs/biome": "1.9.4",
24
32
  "@types/babel__traverse": "7.20.7",
25
33
  "@types/node": "22.15.29",
26
34
  "ts-node": "10.9.2",
@@ -81,6 +89,22 @@
81
89
  "start": "node dist/index.js",
82
90
  "dev": "ts-node src/index.ts",
83
91
  "test": "vitest run",
84
- "test:watch": "vitest"
92
+ "test:watch": "vitest",
93
+ "lint": "biome lint src/",
94
+ "lint:fix": "biome lint --write src/",
95
+ "format": "biome format src/",
96
+ "format:fix": "biome format --write src/",
97
+ "check": "biome check src/",
98
+ "check:fix": "biome check --write src/",
99
+ "prebuild": "npm run check",
100
+ "version": "npm run check:fix && git add -A src",
101
+ "postversion": "git push && git push --tags",
102
+ "release": "./scripts/release.sh",
103
+ "release:patch": "./scripts/release.sh patch",
104
+ "release:minor": "./scripts/release.sh minor",
105
+ "release:major": "./scripts/release.sh major",
106
+ "release:check": "./scripts/release.sh --check",
107
+ "release:manual": "./scripts/release.sh --manual",
108
+ "prerelease": "npm run test && npm run check"
85
109
  }
86
110
  }