From fbb6b9aa124e7452282db429008ac24de7131be1 Mon Sep 17 00:00:00 2001 From: George Lungley Date: Tue, 9 Jul 2024 17:48:35 +0100 Subject: [PATCH] fix: enable paths in usage --- __tests__/fixtures/action/action_deprecated.output | 2 +- __tests__/fixtures/action/action_usage_readme.output | 2 +- __tests__/fixtures/action/all_fields_action.output | 2 +- .../fixtures/action/all_fields_action_toc3_cli.output | 2 +- .../fixtures/action/all_fields_one_annotation.output | 2 +- __tests__/fixtures/action/all_fields_readme.output | 2 +- .../fixtures/action/all_fields_usage_readme.output | 2 +- __tests__/fixtures/action/default-with-header.output | 2 +- __tests__/fixtures/action/default.output | 2 +- __tests__/fixtures/action/minimal_action.output | 2 +- .../workflow/all_fields_one_annotation.output | 2 +- __tests__/fixtures/workflow/all_fields_readme.output | 2 +- .../fixtures/workflow/all_fields_usage_readme.output | 2 +- .../fixtures/workflow/all_fields_workflow.output | 2 +- __tests__/fixtures/workflow/default.output | 2 +- __tests__/fixtures/workflow/minimal_workflow.output | 2 +- .../fixtures/workflow/workflow_usage_readme.output | 2 +- src/action-docs.ts | 11 +++++++---- 18 files changed, 24 insertions(+), 21 deletions(-) diff --git a/__tests__/fixtures/action/action_deprecated.output b/__tests__/fixtures/action/action_deprecated.output index 6a1de0e6..29e65ac5 100644 --- a/__tests__/fixtures/action/action_deprecated.output +++ b/__tests__/fixtures/action/action_deprecated.output @@ -12,7 +12,7 @@ Default test ### Usage ```yaml -- uses: npalm/action-docs@v1 +- uses: npalm/action-docs/__tests__/fixtures/action/all_fields_action.yml@v1 with: inputA: # A description A diff --git a/__tests__/fixtures/action/action_usage_readme.output b/__tests__/fixtures/action/action_usage_readme.output index acceeb00..797942f1 100644 --- a/__tests__/fixtures/action/action_usage_readme.output +++ b/__tests__/fixtures/action/action_usage_readme.output @@ -2,7 +2,7 @@ ## Usage ```yaml -- uses: npalm/action-docs@v1 +- uses: npalm/action-docs/__tests__/fixtures/action/action.yml@v1 with: inputA: # - Item 1 diff --git a/__tests__/fixtures/action/all_fields_action.output b/__tests__/fixtures/action/all_fields_action.output index 85b5296a..a95a3a70 100644 --- a/__tests__/fixtures/action/all_fields_action.output +++ b/__tests__/fixtures/action/all_fields_action.output @@ -28,7 +28,7 @@ This action is a `node12` action. ## Usage ```yaml -- uses: ***PROJECT***@***VERSION*** +- uses: ***PROJECT******SOURCE_FILE***@***VERSION*** with: inputA: # A description A diff --git a/__tests__/fixtures/action/all_fields_action_toc3_cli.output b/__tests__/fixtures/action/all_fields_action_toc3_cli.output index 495be5fb..a16e1a12 100644 --- a/__tests__/fixtures/action/all_fields_action_toc3_cli.output +++ b/__tests__/fixtures/action/all_fields_action_toc3_cli.output @@ -28,7 +28,7 @@ This action is a `node12` action. ### Usage ```yaml -- uses: ***PROJECT***@***VERSION*** +- uses: ***PROJECT******SOURCE_FILE***@***VERSION*** with: inputA: # A description A diff --git a/__tests__/fixtures/action/all_fields_one_annotation.output b/__tests__/fixtures/action/all_fields_one_annotation.output index 4d5beed2..d2251657 100644 --- a/__tests__/fixtures/action/all_fields_one_annotation.output +++ b/__tests__/fixtures/action/all_fields_one_annotation.output @@ -29,7 +29,7 @@ This action is a `node12` action. ## Usage ```yaml -- uses: npalm/action-docs@v1 +- uses: npalm/action-docs/__tests__/fixtures/action/all_fields_action.yml@v1 with: inputA: # A description A diff --git a/__tests__/fixtures/action/all_fields_readme.output b/__tests__/fixtures/action/all_fields_readme.output index 1af27309..45f28798 100644 --- a/__tests__/fixtures/action/all_fields_readme.output +++ b/__tests__/fixtures/action/all_fields_readme.output @@ -12,7 +12,7 @@ Default test ### Usage ```yaml -- uses: npalm/action-docs@v1 +- uses: npalm/action-docs/__tests__/fixtures/action/all_fields_action.yml@v1 with: inputA: # A description A diff --git a/__tests__/fixtures/action/all_fields_usage_readme.output b/__tests__/fixtures/action/all_fields_usage_readme.output index 0bd7c8cc..5ba4573c 100644 --- a/__tests__/fixtures/action/all_fields_usage_readme.output +++ b/__tests__/fixtures/action/all_fields_usage_readme.output @@ -2,7 +2,7 @@ ## Usage ```yaml -- uses: npalm/action-docs@v1 +- uses: npalm/action-docs/__tests__/fixtures/action/all_fields_action.yml@v1 with: inputA: # A description A diff --git a/__tests__/fixtures/action/default-with-header.output b/__tests__/fixtures/action/default-with-header.output index e863447e..581f13d9 100644 --- a/__tests__/fixtures/action/default-with-header.output +++ b/__tests__/fixtures/action/default-with-header.output @@ -26,7 +26,7 @@ This action is a `node12` action. ### Usage ```yaml -- uses: ***PROJECT***@***VERSION*** +- uses: ***PROJECT******SOURCE_FILE***@***VERSION*** with: inputA: # - Item 1 diff --git a/__tests__/fixtures/action/default.output b/__tests__/fixtures/action/default.output index c6c42e36..39f4a514 100644 --- a/__tests__/fixtures/action/default.output +++ b/__tests__/fixtures/action/default.output @@ -24,7 +24,7 @@ This action is a `node12` action. ## Usage ```yaml -- uses: ***PROJECT***@***VERSION*** +- uses: ***PROJECT******SOURCE_FILE***@***VERSION*** with: inputA: # - Item 1 diff --git a/__tests__/fixtures/action/minimal_action.output b/__tests__/fixtures/action/minimal_action.output index a454489e..d09db61a 100644 --- a/__tests__/fixtures/action/minimal_action.output +++ b/__tests__/fixtures/action/minimal_action.output @@ -9,7 +9,7 @@ This action is a `docker` action. ## Usage ```yaml -- uses: ***PROJECT***@***VERSION*** +- uses: ***PROJECT******SOURCE_FILE***@***VERSION*** ``` diff --git a/__tests__/fixtures/workflow/all_fields_one_annotation.output b/__tests__/fixtures/workflow/all_fields_one_annotation.output index 9b5310e8..d6be8887 100644 --- a/__tests__/fixtures/workflow/all_fields_one_annotation.output +++ b/__tests__/fixtures/workflow/all_fields_one_annotation.output @@ -25,7 +25,7 @@ ```yaml jobs: job1: - uses: npalm/action-docs@v1 + uses: npalm/action-docs/__tests__/fixtures/workflow/all_fields_workflow.yml@v1 with: inputA: # A description A diff --git a/__tests__/fixtures/workflow/all_fields_readme.output b/__tests__/fixtures/workflow/all_fields_readme.output index b1d23544..c9d9ddf7 100644 --- a/__tests__/fixtures/workflow/all_fields_readme.output +++ b/__tests__/fixtures/workflow/all_fields_readme.output @@ -8,7 +8,7 @@ ```yaml jobs: job1: - uses: npalm/action-docs@v1 + uses: npalm/action-docs/__tests__/fixtures/workflow/all_fields_workflow.yml@v1 with: inputA: # A description A diff --git a/__tests__/fixtures/workflow/all_fields_usage_readme.output b/__tests__/fixtures/workflow/all_fields_usage_readme.output index 36345839..59ce62f3 100644 --- a/__tests__/fixtures/workflow/all_fields_usage_readme.output +++ b/__tests__/fixtures/workflow/all_fields_usage_readme.output @@ -4,7 +4,7 @@ ```yaml jobs: job1: - uses: npalm/action-docs@v1 + uses: npalm/action-docs/__tests__/fixtures/workflow/all_fields_workflow.yml@v1 with: inputA: # A description A diff --git a/__tests__/fixtures/workflow/all_fields_workflow.output b/__tests__/fixtures/workflow/all_fields_workflow.output index 3951facb..a7d60b5f 100644 --- a/__tests__/fixtures/workflow/all_fields_workflow.output +++ b/__tests__/fixtures/workflow/all_fields_workflow.output @@ -24,7 +24,7 @@ ```yaml jobs: job1: - uses: ***PROJECT***@***VERSION*** + uses: ***PROJECT******SOURCE_FILE***@***VERSION*** with: inputA: # A description A diff --git a/__tests__/fixtures/workflow/default.output b/__tests__/fixtures/workflow/default.output index 188e767e..ab9fc5f0 100644 --- a/__tests__/fixtures/workflow/default.output +++ b/__tests__/fixtures/workflow/default.output @@ -20,7 +20,7 @@ ```yaml jobs: job1: - uses: ***PROJECT***@***VERSION*** + uses: ***PROJECT******SOURCE_FILE***@***VERSION*** with: inputA: # - Item 1 diff --git a/__tests__/fixtures/workflow/minimal_workflow.output b/__tests__/fixtures/workflow/minimal_workflow.output index 18e802cb..af81ebca 100644 --- a/__tests__/fixtures/workflow/minimal_workflow.output +++ b/__tests__/fixtures/workflow/minimal_workflow.output @@ -5,7 +5,7 @@ ```yaml jobs: job1: - uses: ***PROJECT***@***VERSION*** + uses: ***PROJECT******SOURCE_FILE***@***VERSION*** ``` diff --git a/__tests__/fixtures/workflow/workflow_usage_readme.output b/__tests__/fixtures/workflow/workflow_usage_readme.output index e2b46d6b..d0352665 100644 --- a/__tests__/fixtures/workflow/workflow_usage_readme.output +++ b/__tests__/fixtures/workflow/workflow_usage_readme.output @@ -4,7 +4,7 @@ ```yaml jobs: job1: - uses: npalm/action-docs@v1 + uses: npalm/action-docs/__tests__/fixtures/workflow/workflow.yml@v1 with: inputA: # - Item 1 diff --git a/src/action-docs.ts b/src/action-docs.ts index 744ff61c..1de95f7c 100644 --- a/src/action-docs.ts +++ b/src/action-docs.ts @@ -125,14 +125,14 @@ function createMdCodeBlock( let indent = ""; if (isAction) { - codeBlockArray.push("- uses: ***PROJECT***@***VERSION***"); + codeBlockArray.push("- uses: ***PROJECT******SOURCE_FILE***@***VERSION***"); indent += " "; } else { codeBlockArray.push("jobs:"); indent += " "; codeBlockArray.push(`${indent}job1:`); indent += " "; - codeBlockArray.push(`${indent}uses: ***PROJECT***@***VERSION***`); + codeBlockArray.push(`${indent}uses: ***PROJECT******SOURCE_FILE***@***VERSION***`); } const inputs = getInputOutput( @@ -352,6 +352,9 @@ async function updateReadme( .replace( "***VERSION***", matchProjectVersion ? matchProjectVersion[2] : "", + ).replace( + "***SOURCE_FILE***", + sourceFile !== defaultOptions.sourceFile ? `/${sourceFile}` : "", ); await replaceInFile.replaceInFile({ @@ -377,8 +380,8 @@ function createMarkdownSection( return data === "" || data === undefined ? "" : `${createMarkdownHeader(options, header)}${data}` + - `${lineBreak}` + - `${lineBreak}`; + `${lineBreak}` + + `${lineBreak}`; } function createMarkdownHeader(options: DefaultOptions, header: string): string {