A simple node.js module for dynamic updating packages list in the markdown file.
- Node.js >= 10.0.0
# With NPM
npm install --save dynamic-package-update
# With Yarn
yarn add dynamic-package-update
// Available options
const dpu = require("dynamic-package-update");
const option = {
outPutFileName: 'docs.md', // Default is README.md
packageJsonFile: 'your json file', // Default your root package.json file no need to set this option.
showNpmLinkColumn: true, // Default is true.
showTypeColumn: true, // Default is true.
showDependencies: true, // Default is true.
showDevDependencies: true // Default is true.
}
// Note: By default option is an optional parameter.
dpu.generateTableMarkDown(readmefile, option);
Create a readme.js file for updating README.md file.
Folder structure with readme.js:
+-- node_modules
+-- src
| +-- index.js
| +-- file1.js
| +-- file1.js
+-- package.json
+-- package-lock.json
+-- readme.js
+-- README.md
// readme.js
const dpu = require("dynamic-package-update");
const fs = require('fs');
const path = require('path');
const readmefile = fs.readFileSync(path.join(__dirname, "README.md"), "utf8");
dpu.generateTableMarkDown(readmefile);
Notes:
- Add this below html code in anywhere in your README.md file.
- Don't add anything inside this content div.
- It will automatically inject package list from your package.json file.
- Along with package list, It will automatically add Package List as a title tag. Don't add it explicitely.
<!--README.md-->
<div id="content">
</div>
// package.json
"scripts": {
"start": "node src/index.js",
"readme:dpu": "node readme.js"
},
npm run readme:dpu #This will automatically update package list in the README.md file
npm install #For installing dependencies
npm build #For making build
Package Name | Version | Type | Npm Link |
---|---|---|---|
@types/node | ^20.8.7 | devDependencies | @types/node |
lint-staged | ^15.0.2 | devDependencies | lint-staged |
prettier | ^3.0.3 | devDependencies | prettier |
typescript | ^5.2.2 | devDependencies | typescript |
husky | ^8.0.0 | devDependencies | husky |
Note: The build artifacts will be stored in the `dist/` directory.
Free Software