dependency-docs-generator 1.0.0

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 (2) hide show
  1. package/index.js +44 -0
  2. package/package.json +22 -0
package/index.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const axios = require('axios');
4
+
5
+ async function generateDocs() {
6
+ try {
7
+ // 1. Read the local package.json
8
+ const packageData = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
9
+ const dependencies = packageData.dependencies || {};
10
+ const depNames = Object.keys(dependencies);
11
+
12
+ if (depNames.length === 0) {
13
+ console.log("No dependencies found!");
14
+ return;
15
+ }
16
+
17
+ let markdownContent = "# Project Dependency Guide\n\n";
18
+ markdownContent += "| Package | Description | Version |\n| --- | --- | --- |\n";
19
+
20
+ console.log(`Found ${depNames.length} packages. Fetching data...`);
21
+
22
+ // 2. Fetch data for each package
23
+ for (const name of depNames) {
24
+ try {
25
+ const response = await axios.get(`https://registry.npmjs.org/${name}`);
26
+ const description = response.data.description || "No description available.";
27
+ const version = dependencies[name];
28
+
29
+ markdownContent += `| **${name}** | ${description} | \`${version}\` |\n`;
30
+ } catch (error) {
31
+ console.error(`Could not fetch data for ${name}`);
32
+ }
33
+ }
34
+
35
+ // 3. Write to DEPENDENCIES.md
36
+ fs.writeFileSync('DEPENDENCIES.md', markdownContent);
37
+ console.log("✅ DEPENDENCIES.md has been generated!");
38
+
39
+ } catch (err) {
40
+ console.error("Error reading package.json:", err.message);
41
+ }
42
+ }
43
+
44
+ generateDocs();
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "dependency-docs-generator",
3
+ "version": "1.0.0",
4
+ "description": "Automatically generates a README guide for your project dependencies",
5
+ "license": "ISC",
6
+ "author": "purushothaman",
7
+ "type": "commonjs",
8
+ "main": "index.js",
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "start": "node index.js"
12
+ },
13
+ "dependencies": {
14
+ "axios": "^1.13.5",
15
+ "dotenv": "^17.3.1",
16
+ "express": "^5.2.1",
17
+ "lodash": "^4.17.23"
18
+ },
19
+ "bin": {
20
+ "gen-docs": "index.js"
21
+ }
22
+ }