markdown-magic-scripts
Advanced tools
+8
-0
| # Changelog | ||
| ## [1.1.0](https://github.com/ioncakephper/markdown-magic-scripts/compare/v1.0.0...v1.1.0) (2025-10-14) | ||
| ### Features | ||
| * **transform:** Expose markdown-magic config to transform ([fb0cd95](https://github.com/ioncakephper/markdown-magic-scripts/commit/fb0cd95a8b16b5f986a84f4f88749fe85bbf3036)) | ||
| * **transform:** Expose markdown-magic config to transform ([ffc650e](https://github.com/ioncakephper/markdown-magic-scripts/commit/ffc650e566346f8e08ce6d9a14e9aa10a6de32b6)) | ||
| ## 1.0.0 (2025-10-12) | ||
@@ -4,0 +12,0 @@ |
+1
-1
@@ -31,3 +31,3 @@ const fs = require('fs'); | ||
| */ | ||
| module.exports = function scriptsTransform(content, options = {}, config) { | ||
| module.exports = function scriptsTransform(content, options = {}, _config) { | ||
| const pkgPath = path.join(process.cwd(), 'package.json'); | ||
@@ -34,0 +34,0 @@ const pkgRaw = fs.readFileSync(pkgPath, 'utf8'); |
+24
-20
| { | ||
| "name": "markdown-magic-scripts", | ||
| "version": "1.0.0", | ||
| "version": "1.1.0", | ||
| "description": "An extension to create a dashboard for scripts in package.json for markdown-magic", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "lint": "eslint . --ext .js,.json,.yaml,.md", | ||
| "lint:fix": "eslint . --ext .js,.json,.yaml,.md --fix", | ||
| "format": "prettier --write .", | ||
| "fix": "npm run lint:fix && npm run format", | ||
| "docs": "md-magic" | ||
| }, | ||
| "scriptsMeta": { | ||
| "docs": "Update automated documentation content in README.md", | ||
| "lint": "Lint all source files", | ||
| "lint:fix": "Fix linting issues", | ||
| "format": "Format all source files", | ||
| "fix": "Run lint:fix and format scripts", | ||
| "test": "Run tests" | ||
| }, | ||
| "keywords": [ | ||
@@ -29,4 +12,5 @@ "markdown-magic", | ||
| ], | ||
| "license": "MIT", | ||
| "author": "Ion Gireada", | ||
| "license": "MIT", | ||
| "main": "index.js", | ||
| "files": [ | ||
@@ -40,3 +24,13 @@ "index.js", | ||
| ], | ||
| "scripts": { | ||
| "docs": "md-magic", | ||
| "fix": "npm run lint:fix && npm run format && npm run format:package", | ||
| "format": "prettier --write .", | ||
| "format:package": "prettier --write package.json", | ||
| "lint": "eslint . --ext .js,.json,.yaml,.md", | ||
| "lint:fix": "eslint . --ext .js,.json,.yaml,.md --fix", | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.37.0", | ||
| "eslint": "^9.37.0", | ||
@@ -47,7 +41,17 @@ "eslint-plugin-json": "^4.0.1", | ||
| "markdown-eslint-parser": "^1.2.1", | ||
| "markdown-magic": "^2.6.1", | ||
| "markdown-magic": "2.6.1", | ||
| "markdown-magic-directory-tree": "^1.2.4", | ||
| "prettier": "^3.6.2", | ||
| "prettier-plugin-packagejson": "^2.4.0", | ||
| "yaml-eslint-parser": "^1.3.0" | ||
| }, | ||
| "scriptsMeta": { | ||
| "docs": "Update automated documentation content in README.md", | ||
| "lint": "Lint all source files", | ||
| "lint:fix": "Fix linting issues", | ||
| "format": "Format all source files", | ||
| "format:package": "Format package.json", | ||
| "fix": "Run lint:fix and format scripts", | ||
| "test": "Run tests" | ||
| } | ||
| } |
+25
-156
@@ -8,16 +8,8 @@ # π¦ markdownβmagicβscripts | ||
| <!-- AUTO-GENERATED-CONTENT:START (TOC) --> | ||
| - [π¦ markdownβmagicβscripts](#-markdownmagicscripts) | ||
| - [Table of Contents](#table-of-contents) | ||
| - [Installation](#installation) | ||
| - [Usage](#usage) | ||
| - [Example](#example) | ||
| - [`README.md` Snippet](#readmemd-snippet) | ||
| - [π Options](#-options) | ||
| - [Available Options](#available-options) | ||
| - [Available Options](#available-options) | ||
| - [π Examples](#-examples) | ||
| - [Default (table)](#default-table) | ||
| - [Grouped by Category (list with fenced blocks)](#grouped-by-category-list-with-fenced-blocks) | ||
| - [dev](#dev) | ||
| - [docs](#docs) | ||
| - [Compact List](#compact-list) | ||
@@ -34,101 +26,7 @@ - [π§© Metadata](#-metadata) | ||
| - [π License](#-license) | ||
| ## Installation | ||
| This package is intended to be used as a development dependency in your project. | ||
| ```bash | ||
| npm install --save-dev markdown-magic markdown-magic-scripts | ||
| ``` | ||
| ## Usage | ||
| To utilize this package, you need to configure it within your markdown-magic setup. It works by looking for a special comment block in your Markdown files (README.md recommended) and injecting a formatted table of scripts. The comment block looks like this: | ||
| ```markdown | ||
| <!-- AUTO-GENERATED-CONTENT:START (SCRIPTS) --> | ||
| | Script | Command | Description | Line | | ||
| | ---------- | ------------------------------------------- | --------------------------------------------------- | ------------------------ | | ||
| | `docs` | `md-magic` | Update automated documentation content in README.md | [15](./package.json#L15) | | ||
| | `fix` | `npm run lint:fix && npm run format` | Run lint:fix and format scripts | [19](./package.json#L19) | | ||
| | `format` | `prettier --write .` | Format all source files | [18](./package.json#L18) | | ||
| | `lint` | `eslint . --ext .js,.json,.yaml,.md` | Lint all source files | [16](./package.json#L16) | | ||
| | `lint:fix` | `eslint . --ext .js,.json,.yaml,.md --fix` | Fix linting issues | [17](./package.json#L17) | | ||
| | `test` | `echo "Error: no test specified" && exit 1` | Run tests | [20](./package.json#L20) | | ||
| <!-- AUTO-GENERATED-CONTENT:END --> | ||
| ``` | ||
| The content between these tags will be automatically replaced with a table of scripts defined in your `package.json` under the `"scripts"` field, using metadata from the optional `"scriptsMeta"` field for descriptions. | ||
| ## Example | ||
| ## Available Options | ||
| To automate the generation of your script dashboard, create a simple JavaScript file (e.g., `docs.js`) that runs markdown-magic with the configuration object set to use markdown-magic-scripts. | ||
| This example assumes your package.json contains a `"docs": "node docs.js"` script to run this file. | ||
| `docs.js` (or similar file) | ||
| ```js | ||
| const path = require('path'); | ||
| const markdownMagic = require('markdown-magic'); | ||
| const scriptsPlugin = require('markdown-magic-scripts'); | ||
| // The configuration object for markdown-magic | ||
| const config = { | ||
| transforms: { | ||
| // Register the scripts plugin with the key used in your markdown comment block | ||
| 'MARKDOWN-MAGIC-SCRIPTS': scriptsPlugin.scripts, | ||
| }, | ||
| // Set the source file(s) to process | ||
| // Adjust this path if your README is not in the root directory | ||
| file: path.join(__dirname, 'README.md'), | ||
| // Optional: You can pass a custom header for the generated table: | ||
| // header: '| Script Name | Description | Command |', | ||
| }; | ||
| // Execute markdown-magic | ||
| markdownMagic(config); | ||
| console.log('Documentation updated using markdown-magic-scripts!'); | ||
| ``` | ||
| ### `README.md` Snippet | ||
| Ensure your README.md includes the placeholder for the script dashboard:... [Your other content] | ||
| ```markdown | ||
| ## Available Scripts | ||
| <!-- AUTO-GENERATED-CONTENT:START (SCRIPTS) --> | ||
| <!-- AUTO-GENERATED-CONTENT:END --> | ||
| ... [Rest of your README.md] | ||
| ``` | ||
| When you run `npm run docs`, the `markdown-magic` tool will execute, find the placeholder, and insert a table summarizing your scripts (like `lint`, `format`, `fix`, `docs`, etc.) using the descriptions provided in your `package.json`'s `scriptsMeta` block. | ||
| ## π Options | ||
| You can pass options inside the marker, e.g.: | ||
| ```markdown | ||
| <!-- AUTO-GENERATED-CONTENT:START (SCRIPTS:format=list groupBy=category) --> | ||
| | Script | Command | Description | Line | | ||
| | ---------- | ------------------------------------------- | --------------------------------------------------- | ------------------------ | | ||
| | `docs` | `md-magic` | Update automated documentation content in README.md | [15](./package.json#L15) | | ||
| | `fix` | `npm run lint:fix && npm run format` | Run lint:fix and format scripts | [19](./package.json#L19) | | ||
| | `format` | `prettier --write .` | Format all source files | [18](./package.json#L18) | | ||
| | `lint` | `eslint . --ext .js,.json,.yaml,.md` | Lint all source files | [16](./package.json#L16) | | ||
| | `lint:fix` | `eslint . --ext .js,.json,.yaml,.md --fix` | Fix linting issues | [17](./package.json#L17) | | ||
| | `test` | `echo "Error: no test specified" && exit 1` | Run tests | [20](./package.json#L20) | | ||
| <!-- AUTO-GENERATED-CONTENT:END --> | ||
| ``` | ||
| ### Available Options | ||
| <!-- AUTO-GENERATED-CONTENT:START (OPTIONS-DOCS) --> | ||
@@ -150,5 +48,2 @@ <!-- prettier-ignore-start --> | ||
| <!-- prettier-ignore-end --> | ||
| <!-- prettier-ignore-end --> | ||
| <!-- prettier-ignore-end --> | ||
| <!-- prettier-ignore-end --> | ||
| <!-- AUTO-GENERATED-CONTENT:END --> | ||
@@ -162,16 +57,6 @@ | ||
| ```markdown | ||
| ````html | ||
| <!-- AUTO-GENERATED-CONTENT:START (SCRIPTS) --> | ||
| | Script | Command | Description | Line | | ||
| | ---------- | ------------------------------------------- | --------------------------------------------------- | ------------------------ | | ||
| | `docs` | `md-magic` | Update automated documentation content in README.md | [15](./package.json#L15) | | ||
| | `fix` | `npm run lint:fix && npm run format` | Run lint:fix and format scripts | [19](./package.json#L19) | | ||
| | `format` | `prettier --write .` | Format all source files | [18](./package.json#L18) | | ||
| | `lint` | `eslint . --ext .js,.json,.yaml,.md` | Lint all source files | [16](./package.json#L16) | | ||
| | `lint:fix` | `eslint . --ext .js,.json,.yaml,.md --fix` | Fix linting issues | [17](./package.json#L17) | | ||
| | `test` | `echo "Error: no test specified" && exit 1` | Run tests | [20](./package.json#L20) | | ||
| <!-- AUTO-GENERATED-CONTENT:END --> | ||
| ``` | ||
| ```` | ||
@@ -189,19 +74,10 @@ Produces: | ||
| ```markdown | ||
| ````html | ||
| <!-- AUTO-GENERATED-CONTENT:START (SCRIPTS:format=list groupBy=category) --> | ||
| | Script | Command | Description | Line | | ||
| | ---------- | ------------------------------------------- | --------------------------------------------------- | ------------------------ | | ||
| | `docs` | `md-magic` | Update automated documentation content in README.md | [15](./package.json#L15) | | ||
| | `fix` | `npm run lint:fix && npm run format` | Run lint:fix and format scripts | [19](./package.json#L19) | | ||
| | `format` | `prettier --write .` | Format all source files | [18](./package.json#L18) | | ||
| | `lint` | `eslint . --ext .js,.json,.yaml,.md` | Lint all source files | [16](./package.json#L16) | | ||
| | `lint:fix` | `eslint . --ext .js,.json,.yaml,.md --fix` | Fix linting issues | [17](./package.json#L17) | | ||
| | `test` | `echo "Error: no test specified" && exit 1` | Run tests | [20](./package.json#L20) | | ||
| <!-- AUTO-GENERATED-CONTENT:END --> | ||
| ``` | ||
| ```` | ||
| Produces: | ||
| ````markdown | ||
| ### dev | ||
@@ -222,24 +98,15 @@ | ||
| ``` | ||
| ```` | ||
| --- | ||
| ### Compact List | ||
| ```markdown | ||
| ````html | ||
| <!-- AUTO-GENERATED-CONTENT:START (SCRIPTS:format=list compact=true) --> | ||
| | Script | Command | Description | Line | | ||
| | ---------- | ------------------------------------------- | --------------------------------------------------- | ------------------------ | | ||
| | `docs` | `md-magic` | Update automated documentation content in README.md | [15](./package.json#L15) | | ||
| | `fix` | `npm run lint:fix && npm run format` | Run lint:fix and format scripts | [19](./package.json#L19) | | ||
| | `format` | `prettier --write .` | Format all source files | [18](./package.json#L18) | | ||
| | `lint` | `eslint . --ext .js,.json,.yaml,.md` | Lint all source files | [16](./package.json#L16) | | ||
| | `lint:fix` | `eslint . --ext .js,.json,.yaml,.md --fix` | Fix linting issues | [17](./package.json#L17) | | ||
| | `test` | `echo "Error: no test specified" && exit 1` | Run tests | [20](./package.json#L20) | | ||
| <!-- AUTO-GENERATED-CONTENT:END --> | ||
| ``` | ||
| ```` | ||
| Produces: | ||
| ````markdown | ||
| - `lint` | ||
@@ -250,2 +117,4 @@ - `docs` | ||
| ```` | ||
| --- | ||
@@ -281,3 +150,2 @@ | ||
| <!-- AUTO-GENERATED-CONTENT:START (DIR_TREE) --> | ||
| ``` | ||
@@ -291,3 +159,5 @@ markdown-magic-scripts/ | ||
| β βββ options-docs.js | ||
| βββ .npmcheckrc | ||
| βββ .prettierrc.json | ||
| βββ CHANGELOG.md | ||
| βββ eslint.config.js | ||
@@ -301,3 +171,2 @@ βββ index.js | ||
| ``` | ||
| <!-- AUTO-GENERATED-CONTENT:END --> | ||
@@ -308,12 +177,12 @@ | ||
| <!-- AUTO-GENERATED-CONTENT:START (SCRIPTS) --> | ||
| | Script | Command | Description | Line | | ||
| | -------- | -------- | -------- | -------- | | ||
| | `docs` | `md-magic` | Update automated documentation content in README.md | [46](./package.json#L46) | | ||
| | `fix` | `npm run lint:fix && npm run format && npm run format:package` | Run lint:fix and format scripts | [51](./package.json#L51) | | ||
| | `format` | `prettier --write .` | Format all source files | [49](./package.json#L49) | | ||
| | `format:package` | `prettier --write package.json` | Format package.json | [50](./package.json#L50) | | ||
| | `lint` | `eslint . --ext .js,.json,.yaml,.md` | Lint all source files | [47](./package.json#L47) | | ||
| | `lint:fix` | `eslint . --ext .js,.json,.yaml,.md --fix` | Fix linting issues | [48](./package.json#L48) | | ||
| | `test` | `echo "Error: no test specified" && exit 1` | Run tests | [52](./package.json#L52) | | ||
| | Script | Command | Description | Line | | ||
| | ---------- | ------------------------------------------- | --------------------------------------------------- | ------------------------ | | ||
| | `docs` | `md-magic` | Update automated documentation content in README.md | [15](./package.json#L15) | | ||
| | `fix` | `npm run lint:fix && npm run format` | Run lint:fix and format scripts | [19](./package.json#L19) | | ||
| | `format` | `prettier --write .` | Format all source files | [18](./package.json#L18) | | ||
| | `lint` | `eslint . --ext .js,.json,.yaml,.md` | Lint all source files | [16](./package.json#L16) | | ||
| | `lint:fix` | `eslint . --ext .js,.json,.yaml,.md --fix` | Fix linting issues | [17](./package.json#L17) | | ||
| | `test` | `echo "Error: no test specified" && exit 1` | Run tests | [20](./package.json#L20) | | ||
| <!-- AUTO-GENERATED-CONTENT:END --> | ||
@@ -320,0 +189,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
19858
-27.69%11
22.22%241
-35.22%