New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

action-docs

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

action-docs - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

13

CHANGELOG.md
# Changelog
## [2.3.0](https://github.com/npalm/action-docs/compare/v2.2.0...v2.3.0) (2024-03-09)
### Features
* add 'all' option to add all the documentation to the readme in one go ([#537](https://github.com/npalm/action-docs/issues/537)) ([dc70838](https://github.com/npalm/action-docs/commit/dc708388c4bf58c9c15c4135702a4a9f0eabc897))
### Bug Fixes
* -a option was ingored ([#561](https://github.com/npalm/action-docs/issues/561)) ([8dbd40e](https://github.com/npalm/action-docs/commit/8dbd40eb476605d90f9a0d94848015097c02198f))
* **deps:** bump yaml from 2.4.0 to 2.4.1 ([#557](https://github.com/npalm/action-docs/issues/557)) ([8c2dc15](https://github.com/npalm/action-docs/commit/8c2dc15d9f90772c93c66133ef5d4948705b3e56))
## [2.2.0](https://github.com/npalm/action-docs/compare/v2.1.0...v2.2.0) (2024-03-06)

@@ -4,0 +17,0 @@

55

lib/action-docs.js

@@ -127,2 +127,5 @@ import { getLineBreak } from "./linebreak.js";

}
if (options.updateReadme) {
await updateReadme(options, outputString, "all", options.sourceFile);
}
return outputString;

@@ -189,35 +192,21 @@ }

const sourceOrAction = sourceOrActionMatches[1];
if (section === "usage") {
const match = readmeFileText.match(new RegExp(`<!-- action-docs-usage ${sourceOrAction}="${escapeRegExp(sourceFile)}" project="(.*)" version="(.*)" -->.?`));
if (match) {
const commentExpression = `<!-- action-docs-usage ${sourceOrAction}="${sourceFile}" project="${match[1]}" version="${match[2]}" -->`;
const regexp = new RegExp(`${escapeRegExp(commentExpression)}(?:(?:\r\n|\r|\n.*)+${escapeRegExp(commentExpression)})?`);
const processedText = text
.trim()
.replace("***PROJECT***", match[1])
.replace("***VERSION***", match[2]);
await replaceInFile.replaceInFile({
files: options.readmeFile,
from: regexp,
to: commentExpression +
lineBreak +
processedText +
lineBreak +
commentExpression,
});
}
}
else {
const commentExpression = `<!-- action-docs-${section} ${sourceOrAction}="${sourceFile}" -->`;
const regexp = new RegExp(`${escapeRegExp(commentExpression)}(?:(?:\r\n|\r|\n.*)+${escapeRegExp(commentExpression)})?`);
await replaceInFile.replaceInFile({
files: options.readmeFile,
from: regexp,
to: commentExpression +
lineBreak +
text.trim() +
lineBreak +
commentExpression,
});
}
const matchProjectVersion = readmeFileText.match(new RegExp(`<!-- action-docs-${section} ${sourceOrAction}="${escapeRegExp(sourceFile)}" project="(.*)" version="(.*)" -->.?`));
let commentExpression = `<!-- action-docs-${section} ${sourceOrAction}="${sourceFile}" PROJECT_VERSION-->`;
commentExpression = commentExpression.replace("PROJECT_VERSION", matchProjectVersion
? `project="${matchProjectVersion[1]}" version="${matchProjectVersion[2]}" `
: "");
const regexp = new RegExp(`${escapeRegExp(commentExpression)}(?:(?:\r\n|\r|\n.*)+${escapeRegExp(commentExpression)})?`);
const processedText = text
.trim()
.replace("***PROJECT***", matchProjectVersion ? matchProjectVersion[1] : "")
.replace("***VERSION***", matchProjectVersion ? matchProjectVersion[2] : "");
await replaceInFile.replaceInFile({
files: options.readmeFile,
from: regexp,
to: commentExpression +
lineBreak +
processedText +
lineBreak +
commentExpression,
});
}

@@ -224,0 +213,0 @@ }

3

lib/cli.js

@@ -59,4 +59,5 @@ #!/usr/bin/env node

const updateReadme = args["update-readme"] !== undefined;
const sourceFile = args.source === defaultOptions.sourceFile ? args.action : args.source;
const options = {
sourceFile: args.source ?? args.action,
sourceFile,
tocLevel: args["toc-level"],

@@ -63,0 +64,0 @@ updateReadme,

{
"name": "action-docs",
"version": "2.2.0",
"version": "2.3.0",
"description": "Generate GitHub action docs based on action.yml",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -76,3 +76,3 @@ <!-- BADGES/ -->

Action-docs can update your README based on the `action.yml`. The following sections can be updated: description, inputs, outputs and runs. Add the following tags to your README and run `action-docs -u`.
Action-docs can update your README based on the `action.yml`. The following sections can be updated: name header, description, inputs, outputs, usage, and runs. Add the following tags to your README and run `action-docs -u`.

@@ -88,5 +88,13 @@ ```md

<!-- action-docs-runs source="action.yml" -->
<!-- action-docs-runs action="action.yml" -->
<!-- action-docs-usage action="action.yml" project="<project>" version="<version>" -->
```
Or to include all of the above, use:
```md
<!-- action-docs-all source="action.yml" project="<project>" version="<version>" -->
```
For updating other Markdown files add the name of the file to the command `action-docs -u <file>`.

@@ -93,0 +101,0 @@

@@ -212,2 +212,6 @@ import { LineBreakType, getLineBreak } from "./linebreak.js";

if (options.updateReadme) {
await updateReadme(options, outputString, "all", options.sourceFile);
}
return outputString;

@@ -321,49 +325,41 @@ }

const sourceOrAction = sourceOrActionMatches[1];
const matchProjectVersion = readmeFileText.match(
new RegExp(
`<!-- action-docs-${section} ${sourceOrAction}="${escapeRegExp(sourceFile)}" project="(.*)" version="(.*)" -->.?`,
),
) as string[];
if (section === "usage") {
const match = readmeFileText.match(
new RegExp(
`<!-- action-docs-usage ${sourceOrAction}="${escapeRegExp(sourceFile)}" project="(.*)" version="(.*)" -->.?`,
),
) as string[];
let commentExpression = `<!-- action-docs-${section} ${sourceOrAction}="${sourceFile}" PROJECT_VERSION-->`;
commentExpression = commentExpression.replace(
"PROJECT_VERSION",
matchProjectVersion
? `project="${matchProjectVersion[1]}" version="${matchProjectVersion[2]}" `
: "",
);
if (match) {
const commentExpression = `<!-- action-docs-usage ${sourceOrAction}="${sourceFile}" project="${match[1]}" version="${match[2]}" -->`;
const regexp = new RegExp(
`${escapeRegExp(commentExpression)}(?:(?:\r\n|\r|\n.*)+${escapeRegExp(commentExpression)})?`,
);
const regexp = new RegExp(
`${escapeRegExp(commentExpression)}(?:(?:\r\n|\r|\n.*)+${escapeRegExp(commentExpression)})?`,
);
const processedText = text
.trim()
.replace("***PROJECT***", match[1])
.replace("***VERSION***", match[2]);
await replaceInFile.replaceInFile({
files: options.readmeFile,
from: regexp,
to:
commentExpression +
lineBreak +
processedText +
lineBreak +
commentExpression,
});
}
} else {
const commentExpression = `<!-- action-docs-${section} ${sourceOrAction}="${sourceFile}" -->`;
const regexp = new RegExp(
`${escapeRegExp(commentExpression)}(?:(?:\r\n|\r|\n.*)+${escapeRegExp(commentExpression)})?`,
const processedText = text
.trim()
.replace(
"***PROJECT***",
matchProjectVersion ? matchProjectVersion[1] : "",
)
.replace(
"***VERSION***",
matchProjectVersion ? matchProjectVersion[2] : "",
);
await replaceInFile.replaceInFile({
files: options.readmeFile,
from: regexp,
to:
commentExpression +
lineBreak +
text.trim() +
lineBreak +
commentExpression,
});
}
await replaceInFile.replaceInFile({
files: options.readmeFile,
from: regexp,
to:
commentExpression +
lineBreak +
processedText +
lineBreak +
commentExpression,
});
}

@@ -370,0 +366,0 @@ }

@@ -66,4 +66,7 @@ #!/usr/bin/env node

const sourceFile =
args.source === defaultOptions.sourceFile ? args.action : args.source;
const options = {
sourceFile: args.source ?? args.action,
sourceFile,
tocLevel: args["toc-level"],

@@ -70,0 +73,0 @@ updateReadme,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc