diff --git a/README.md b/README.md index 3dec21a..b109ada 100644 --- a/README.md +++ b/README.md @@ -27,25 +27,25 @@ A few of the actions or workflows used in this repository are forks of `sapphire #### Workflows: -* [Node Package Publish](#.github/workflows/Package-Publish.yml) -* [README.md Updater](#.github/workflows/Repository-Update.yml) -* [Build Rojo Project](#.github/workflows/Rojo-Build.yml) -* [Package.json Version Check](#.github/workflows/Version-Check.yml) -* [Cancel Workflow](#.github/workflows/Workflow-Cancel.yml) +* [Node Package Publish](#node-package-publish) +* [README.md Updater](#readme-md-updater) +* [Build Rojo Project](#build-rojo-project) +* [Package.json Version Check](#package-json-version-check) +* [Cancel Workflow](#cancel-workflow) #### Actions: -* [Install dependencies with Yarn](#actions/add-yarn-dependencies/action.yml) -* [Configure Git CLI](#actions/git-configure/action.yml) -* [Install Aftman](#actions/install-aftman/action.yml) -* [Install dependencies with NPM](#actions/install-npm-dependencies/action.yml) -* [Configure Git CLI](#actions/install-rokit/action.yml) -* [Generate Self-hosted Runner Token](#actions/make-runner/action.yml) -* [Set Memory Swap Space](#actions/set-swap-space/action.yml) +* [Install dependencies with Yarn](#install-dependencies-with-yarn) +* [Configure Git CLI](#configure-git-cli) +* [Install Aftman](#install-aftman) +* [Install dependencies with NPM](#install-dependencies-with-npm) +* [Configure Git CLI](#configure-git-cli) +* [Generate Self-hosted Runner Token](#generate-self-hosted-runner-token) +* [Set Memory Swap Space](#set-memory-swap-space) ## Workflows: -#### [Node Package Publish](#.github/workflows/Package-Publish.yml) +#### [Node Package Publish](#node-package-publish) -* Component link: `Bracketed/Workflows/.github/workflows/Package-Publish.yml@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/.github/workflows/Package-Publish.yml) +* Component link: `Bracketed/Workflows/.github/workflows/Package-Publish.yml@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/.github/workflows/Package-Publish.yml) * Description: Publish a node package to the NPM registry **Inputs:** @@ -89,13 +89,39 @@ A few of the actions or workflows used in this repository are forks of `sapphire * Required: `false` * Default: `main` * Type: `string` -#### [README.md Updater](#.github/workflows/Repository-Update.yml) -* Component link: `Bracketed/Workflows/.github/workflows/Repository-Update.yml@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/.github/workflows/Repository-Update.yml) +**Example Usage:** + + name: Example Workflow + on: + push: + branches: [main] + + jobs: + example: + uses: Bracketed/Workflows/.github/workflows/Package-Publish.yml@copilot/fix-anchor-links-readme-builder + with: + project-name: @${{ github.repository }} + repository-owner: bracketed + node-version: 23 +#### [README.md Updater](#readme-md-updater) + +* Component link: `Bracketed/Workflows/.github/workflows/Repository-Update.yml@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/.github/workflows/Repository-Update.yml) * Description: Automatically updates the README.md file of this repository, this is NOT a reusable workflow -#### [Build Rojo Project](#.github/workflows/Rojo-Build.yml) -* Component link: `Bracketed/Workflows/.github/workflows/Rojo-Build.yml@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/.github/workflows/Rojo-Build.yml) +**Example Usage:** + + name: Example Workflow + on: + push: + branches: [main] + + jobs: + example: + uses: Bracketed/Workflows/.github/workflows/Repository-Update.yml@copilot/fix-anchor-links-readme-builder +#### [Build Rojo Project](#build-rojo-project) + +* Component link: `Bracketed/Workflows/.github/workflows/Rojo-Build.yml@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/.github/workflows/Rojo-Build.yml) * Description: Build a Rojo Project with Aftman **Inputs:** @@ -165,9 +191,24 @@ A few of the actions or workflows used in this repository are forks of `sapphire * Required: `false` * Default: `true` * Type: `boolean` -#### [Package.json Version Check](#.github/workflows/Version-Check.yml) -* Component link: `Bracketed/Workflows/.github/workflows/Version-Check.yml@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/.github/workflows/Version-Check.yml) +**Example Usage:** + + name: Example Workflow + on: + push: + branches: [main] + + jobs: + example: + uses: Bracketed/Workflows/.github/workflows/Rojo-Build.yml@copilot/fix-anchor-links-readme-builder + with: + project-name: @${{ github.repository }} + project-context: . + project-output: ${{ github.repository_owner }}~${{ github.event.repository.name }}~${GITHUB_SHA:0:7} +#### [Package.json Version Check](#package-json-version-check) + +* Component link: `Bracketed/Workflows/.github/workflows/Version-Check.yml@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/.github/workflows/Version-Check.yml) * Description: Check the package.json version for a new version or same version **Inputs:** @@ -202,9 +243,24 @@ A few of the actions or workflows used in this repository are forks of `sapphire * Required: `false` * Default: `${{ github.ref }}` * Type: `string` -#### [Cancel Workflow](#.github/workflows/Workflow-Cancel.yml) -* Component link: `Bracketed/Workflows/.github/workflows/Workflow-Cancel.yml@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/.github/workflows/Workflow-Cancel.yml) +**Example Usage:** + + name: Example Workflow + on: + push: + branches: [main] + + jobs: + example: + uses: Bracketed/Workflows/.github/workflows/Version-Check.yml@copilot/fix-anchor-links-readme-builder + with: + cancel-on-same: false + project-name: @${{ github.repository }} + repository-owner: bracketed +#### [Cancel Workflow](#cancel-workflow) + +* Component link: `Bracketed/Workflows/.github/workflows/Workflow-Cancel.yml@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/.github/workflows/Workflow-Cancel.yml) * Description: Cancel a Github Actions Workflow with the gh CLI **Inputs:** @@ -217,10 +273,24 @@ A few of the actions or workflows used in this repository are forks of `sapphire * Required: `false` * Default: `ubuntu-latest` * Type: `string` + +**Example Usage:** + + name: Example Workflow + on: + push: + branches: [main] + + jobs: + example: + uses: Bracketed/Workflows/.github/workflows/Workflow-Cancel.yml@copilot/fix-anchor-links-readme-builder + with: + repository-owner: bracketed + operating-system: ubuntu-latest ## Actions: -#### [Install dependencies with Yarn](#actions/add-yarn-dependencies/action.yml) +#### [Install dependencies with Yarn](#install-dependencies-with-yarn) -* Component link: `Bracketed/Workflows/actions/add-yarn-dependencies@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/actions/add-yarn-dependencies/action.yml) +* Component link: `Bracketed/Workflows/actions/add-yarn-dependencies@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/actions/add-yarn-dependencies/action.yml) * Description: Setup Node and install dependencies using Yarn. **Inputs:** @@ -236,9 +306,19 @@ A few of the actions or workflows used in this repository are forks of `sapphire * Required: `false` * Default: `23` * Type: `string` -#### [Configure Git CLI](#actions/git-configure/action.yml) -* Component link: `Bracketed/Workflows/actions/git-configure@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/actions/git-configure/action.yml) +**Example Usage:** + + steps: + - name: Install dependencies with Yarn + uses: Bracketed/Workflows/actions/add-yarn-dependencies@copilot/fix-anchor-links-readme-builder + with: + immutable: false + flags: + node-version: 23 +#### [Configure Git CLI](#configure-git-cli) + +* Component link: `Bracketed/Workflows/actions/git-configure@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/actions/git-configure/action.yml) * Description: Configure the Git CLI with the correct values and objects for usage in a command line environment **Inputs:** @@ -246,9 +326,17 @@ A few of the actions or workflows used in this repository are forks of `sapphire * **GITHUB_TOKEN**: The Github Token to utilise when running this action * Required: `true` * Type: `string` -#### [Install Aftman](#actions/install-aftman/action.yml) -* Component link: `Bracketed/Workflows/actions/install-aftman@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/actions/install-aftman/action.yml) +**Example Usage:** + + steps: + - name: Configure Git CLI + uses: Bracketed/Workflows/actions/git-configure@copilot/fix-anchor-links-readme-builder + with: + GITHUB_TOKEN: ${{ secrets.EXAMPLE_GITHUB_TOKEN }} +#### [Install Aftman](#install-aftman) + +* Component link: `Bracketed/Workflows/actions/install-aftman@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/actions/install-aftman/action.yml) * Description: Github action to install the Aftman toolchain manager - A fork of ok-nic/setup-aftman **Inputs:** @@ -268,9 +356,19 @@ A few of the actions or workflows used in this repository are forks of `sapphire * Required: `false` * Default: `${{ github.token }}` * Type: `string` -#### [Install dependencies with NPM](#actions/install-npm-dependencies/action.yml) -* Component link: `Bracketed/Workflows/actions/install-npm-dependencies@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/actions/install-npm-dependencies/action.yml) +**Example Usage:** + + steps: + - name: Install Aftman + uses: Bracketed/Workflows/actions/install-aftman@copilot/fix-anchor-links-readme-builder + with: + version: ${{ secrets.EXAMPLE_VERSION }} + context: . + cache: false +#### [Install dependencies with NPM](#install-dependencies-with-npm) + +* Component link: `Bracketed/Workflows/actions/install-npm-dependencies@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/actions/install-npm-dependencies/action.yml) * Description: Setup Node and install dependencies using NPM. **Inputs:** @@ -286,9 +384,19 @@ A few of the actions or workflows used in this repository are forks of `sapphire * Required: `false` * Default: `23` * Type: `string` -#### [Configure Git CLI](#actions/install-rokit/action.yml) -* Component link: `Bracketed/Workflows/actions/install-rokit@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/actions/install-rokit/action.yml) +**Example Usage:** + + steps: + - name: Install dependencies with NPM + uses: Bracketed/Workflows/actions/install-npm-dependencies@copilot/fix-anchor-links-readme-builder + with: + frozen: false + flags: + node-version: 23 +#### [Configure Git CLI](#configure-git-cli) + +* Component link: `Bracketed/Workflows/actions/install-rokit@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/actions/install-rokit/action.yml) * Description: Configure the Git CLI with the correct values and objects for usage in a command line environment **Inputs:** @@ -309,9 +417,19 @@ A few of the actions or workflows used in this repository are forks of `sapphire * Required: `false` * Default: `.` * Type: `string` -#### [Generate Self-hosted Runner Token](#actions/make-runner/action.yml) -* Component link: `Bracketed/Workflows/actions/make-runner@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/actions/make-runner/action.yml) +**Example Usage:** + + steps: + - name: Configure Git CLI + uses: Bracketed/Workflows/actions/install-rokit@copilot/fix-anchor-links-readme-builder + with: + toolchain-version: stable + rokit-version: latest + self-install: true +#### [Generate Self-hosted Runner Token](#generate-self-hosted-runner-token) + +* Component link: `Bracketed/Workflows/actions/make-runner@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/actions/make-runner/action.yml) * Description: Generate a token for a self-hosted GitHub Actions runner. **Inputs:** @@ -323,9 +441,18 @@ A few of the actions or workflows used in this repository are forks of `sapphire * **org**: Optional override for the organization name. Defaults to the repository owner. * Required: `false` * Type: `string` -#### [Set Memory Swap Space](#actions/set-swap-space/action.yml) -* Component link: `Bracketed/Workflows/actions/set-swap-space@main` [[Source]](https://github.com/Bracketed/Workflows/blob/main/actions/set-swap-space/action.yml) +**Example Usage:** + + steps: + - name: Generate Self-hosted Runner Token + uses: Bracketed/Workflows/actions/make-runner@copilot/fix-anchor-links-readme-builder + with: + token: ${{ github.token }} + org: +#### [Set Memory Swap Space](#set-memory-swap-space) + +* Component link: `Bracketed/Workflows/actions/set-swap-space@copilot/fix-anchor-links-readme-builder` [[Source]](https://github.com/Bracketed/Workflows/blob/copilot/fix-anchor-links-readme-builder/actions/set-swap-space/action.yml) * Description: Add more swap space for memory in Gigabytes - By `pierotofy/set-swap-space` **Inputs:** @@ -334,9 +461,17 @@ A few of the actions or workflows used in this repository are forks of `sapphire * Required: `false` * Default: `10` * Type: `string` + +**Example Usage:** + + steps: + - name: Set Memory Swap Space + uses: Bracketed/Workflows/actions/set-swap-space@copilot/fix-anchor-links-readme-builder + with: + swap-size: 10 * * * -_Last Edited by ninjaninja140 at 21/11/2025 in **[09495f2](Bracketed/Workflows.git/commit/09495f2059e51156f48037ee56c159d055d2f0a7)**_ +_Last Edited by copilot-swe-agent[bot] at 21/11/2025 in **[024b626](Bracketed/Workflows/commit/024b62683472c13b65cf4a250a0c09ebbfa813e5)**_ - This repo automatically generates its README.md file, feel free to take a look or use the code in this repo! * * * diff --git a/src/components/base.tsx b/src/components/base.tsx index 8c81cb0..4272226 100644 --- a/src/components/base.tsx +++ b/src/components/base.tsx @@ -1,44 +1,44 @@ -import { Logger } from '@bracketed/logger'; -import * as cheerio from 'cheerio'; -import React from 'react'; -import ReactDOMServer from 'react-dom/server'; -import TurndownService from 'turndown'; - -const Component: React.FC = () => ( -
-

@Workflows

- - README.md Updater - -
-

Utilities by Bracketed Softworks

-
-

Bracketed/Workflows

-
-

- Reusable workflows and actions for use by Bracketed Softworks to Build, publish, create, lint, document and - more across our various products, projects and services we provide, as well as fast, reusable workflows for - anyone who'd like to use them! ⚡🎉 -
- We permit usage of these by users outside of the Bracketed Softworks Organisation, these are free to use, - copy and edit! -

-
-

A few of the actions or workflows used in this repository are forks of `sapphiredev`'s reusables.

-
-
-
-); - -export const buildBaseMarkdown = () => { - const Console = new Logger({ prefix: 'React' }); - - Console.info(`Building React for ${import.meta.filename}...`); - const Turndown = new TurndownService(); - const CheerioComponent = cheerio.load(ReactDOMServer.renderToStaticMarkup()); - - return Turndown.turndown(CheerioComponent.html()); -}; +import { Logger } from '@bracketed/logger'; +import * as cheerio from 'cheerio'; +import type React from 'react'; +import ReactDOMServer from 'react-dom/server'; +import TurndownService from 'turndown'; + +const Component: React.FC = () => ( +
+

@Workflows

+ + README.md Updater + +
+

Utilities by Bracketed Softworks

+
+

Bracketed/Workflows

+
+

+ Reusable workflows and actions for use by Bracketed Softworks to Build, publish, create, lint, document and + more across our various products, projects and services we provide, as well as fast, reusable workflows for + anyone who'd like to use them! ⚡🎉 +
+ We permit usage of these by users outside of the Bracketed Softworks Organisation, these are free to use, + copy and edit! +

+
+

A few of the actions or workflows used in this repository are forks of `sapphiredev`'s reusables.

+
+
+
+); + +export const buildBaseMarkdown = () => { + const Console = new Logger({ prefix: 'React' }); + + Console.info(`Building React for ${import.meta.filename}...`); + const Turndown = new TurndownService(); + const CheerioComponent = cheerio.load(ReactDOMServer.renderToStaticMarkup()); + + return Turndown.turndown(CheerioComponent.html()); +}; diff --git a/src/components/date-footer.tsx b/src/components/date-footer.tsx index 4300031..ae56c9f 100644 --- a/src/components/date-footer.tsx +++ b/src/components/date-footer.tsx @@ -1,33 +1,33 @@ -import { getGitRepo, getLatestCommitFullHash, getLatestCommitHash, getLatestCommitUser } from '@/utils/index'; -import { Logger } from '@bracketed/logger'; -import * as cheerio from 'cheerio'; -import React from 'react'; -import ReactDOMServer from 'react-dom/server'; -import TurndownService from 'turndown'; - -const Component: React.FC = () => ( -
-
- - Last Edited by {getLatestCommitUser()} at {new Date().toLocaleDateString('en-GB')} in{' '} - - {getLatestCommitHash()} - - -
-

- - This repo automatically generates its README.md file, feel free to take a look or use the code in this - repo! -

-
-); - -export const buildDateFooterMarkdown = () => { - const Console = new Logger({ prefix: 'React' }); - - Console.info(`Building React for ${import.meta.filename}...`); - const Turndown = new TurndownService(); - const CheerioComponent = cheerio.load(ReactDOMServer.renderToStaticMarkup()); - - return Turndown.turndown(CheerioComponent.html()); -}; +import { getGitRepo, getLatestCommitFullHash, getLatestCommitHash, getLatestCommitUser } from '@/utils/index'; +import { Logger } from '@bracketed/logger'; +import * as cheerio from 'cheerio'; +import type React from 'react'; +import ReactDOMServer from 'react-dom/server'; +import TurndownService from 'turndown'; + +const Component: React.FC = () => ( +
+
+ + Last Edited by {getLatestCommitUser()} at {new Date().toLocaleDateString('en-GB')} in{' '} + + {getLatestCommitHash()} + + +
+

+ - This repo automatically generates its README.md file, feel free to take a look or use the code in this + repo! +

+
+); + +export const buildDateFooterMarkdown = () => { + const Console = new Logger({ prefix: 'React' }); + + Console.info(`Building React for ${import.meta.filename}...`); + const Turndown = new TurndownService(); + const CheerioComponent = cheerio.load(ReactDOMServer.renderToStaticMarkup()); + + return Turndown.turndown(CheerioComponent.html()); +}; diff --git a/src/components/footer.tsx b/src/components/footer.tsx index 8bdb27f..4baf7fa 100644 --- a/src/components/footer.tsx +++ b/src/components/footer.tsx @@ -1,44 +1,44 @@ -import { Logger } from '@bracketed/logger'; -import * as cheerio from 'cheerio'; -import React from 'react'; -import ReactDOMServer from 'react-dom/server'; -import TurndownService from 'turndown'; - -const Component: React.FC = () => ( -
-
-

Contribution & Help

- Feel free to contribute to this project, join our discord{' '} - and help us with future developments of Project Bracketed & Packages by Bracketed Softworks. Please also notify - us of errors within our projects as we may not be aware of them at the time. -
-
-

Thanks for using our content!

- Bracketed logo - Bracketed Softworks - Website |{' '} - Discord |{' '} - Github | Twitter |{' '} -
-
- Discord Banner -
-
-); - -export const buildFooterMarkdown = () => { - const Console = new Logger({ prefix: 'React' }); - - Console.info(`Building React for ${import.meta.filename}...`); - const Turndown = new TurndownService(); - const CheerioComponent = cheerio.load(ReactDOMServer.renderToStaticMarkup()); - - return Turndown.turndown(CheerioComponent.html()); -}; +import { Logger } from '@bracketed/logger'; +import * as cheerio from 'cheerio'; +import type React from 'react'; +import ReactDOMServer from 'react-dom/server'; +import TurndownService from 'turndown'; + +const Component: React.FC = () => ( +
+
+

Contribution & Help

+ Feel free to contribute to this project, join our discord{' '} + and help us with future developments of Project Bracketed & Packages by Bracketed Softworks. Please also notify + us of errors within our projects as we may not be aware of them at the time. +
+
+

Thanks for using our content!

+ Bracketed logo + Bracketed Softworks - Website |{' '} + Discord |{' '} + Github | Twitter |{' '} +
+
+ Discord Banner +
+
+); + +export const buildFooterMarkdown = () => { + const Console = new Logger({ prefix: 'React' }); + + Console.info(`Building React for ${import.meta.filename}...`); + const Turndown = new TurndownService(); + const CheerioComponent = cheerio.load(ReactDOMServer.renderToStaticMarkup()); + + return Turndown.turndown(CheerioComponent.html()); +}; diff --git a/src/components/glossary.tsx b/src/components/glossary.tsx index 38d6a42..c105191 100644 --- a/src/components/glossary.tsx +++ b/src/components/glossary.tsx @@ -1,36 +1,37 @@ -import type { FileDataMap } from '@/types/index'; -import { Logger } from '@bracketed/logger'; -import * as cheerio from 'cheerio'; -import React from 'react'; -import ReactDOMServer from 'react-dom/server'; -import TurndownService from 'turndown'; - -const Component: React.FC<{ data: Array<{ name: string; data: Array }> }> = (props: { - data: Array<{ name: string; data: Array }>; -}) => ( -
-

Glossary:

- {props.data.map((d, ind) => ( -
-

{d.name}:

- -
- ))} -
-); - -export const buildGlossaryMarkdown = (...data: Array<{ name: string; data: Array }>) => { - const Console = new Logger({ prefix: 'React' }); - - Console.info(`Building React Component for Workflow/Actions with ${import.meta.filename}`); - const Turndown = new TurndownService(); - const CheerioComponent = cheerio.load(ReactDOMServer.renderToStaticMarkup()); - - return Turndown.turndown(CheerioComponent.html()); -}; +import type { FileDataMap } from '@/types/index'; +import { toAnchorId } from '@/utils/index'; +import { Logger } from '@bracketed/logger'; +import * as cheerio from 'cheerio'; +import type React from 'react'; +import ReactDOMServer from 'react-dom/server'; +import TurndownService from 'turndown'; + +const Component: React.FC<{ data: Array<{ name: string; data: Array }> }> = (props: { + data: Array<{ name: string; data: Array }>; +}) => ( +
+

Glossary:

+ {props.data.map((d, ind) => ( +
+

{d.name}:

+ +
+ ))} +
+); + +export const buildGlossaryMarkdown = (...data: Array<{ name: string; data: Array }>) => { + const Console = new Logger({ prefix: 'React' }); + + Console.info(`Building React Component for Workflow/Actions with ${import.meta.filename}`); + const Turndown = new TurndownService(); + const CheerioComponent = cheerio.load(ReactDOMServer.renderToStaticMarkup()); + + return Turndown.turndown(CheerioComponent.html()); +}; diff --git a/src/components/index.ts b/src/components/index.ts index 6cd27a0..170f50e 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,5 +1,5 @@ -export * from './base'; -export * from './date-footer'; -export * from './footer'; -export * from './glossary'; -export * from './item'; +export * from './base'; +export * from './date-footer'; +export * from './footer'; +export * from './glossary'; +export * from './item'; diff --git a/src/components/item.tsx b/src/components/item.tsx index a69368c..e151bc9 100644 --- a/src/components/item.tsx +++ b/src/components/item.tsx @@ -1,54 +1,119 @@ -import type { FinderItem } from '@/types/index'; -import { getGitBranch, getGitRepo } from '@/utils/index'; -import { Logger } from '@bracketed/logger'; -import * as cheerio from 'cheerio'; -import React from 'react'; -import ReactDOMServer from 'react-dom/server'; -import TurndownService from 'turndown'; - -const Component: React.FC = (props: FinderItem) => ( -
-

- {props.content.name} -

-
    -
  • - Component link: `{getGitRepo().replace('.git', '')}/{props.type === 'workflow' ? props.file : props.dir} - @{getGitBranch()}` [Source] -
  • -
  • Description: {props.content.description}
  • -
- {props.content.inputs.length !== 0 ? ( -
- Inputs: -
    - {props.content.inputs.map((i, ind) => ( -
  • - {i.name}: {i.values.description} -
      -
    • Required: `{i.values.required ? 'true' : 'false'}`
    • - {i.values.default ?
    • Default: `{String(i.values.default)}`
    • : undefined} -
    • Type: `{i.values.type ?? 'string'}`
    • -
    -
  • - ))} -
-
- ) : undefined} -
-); - -export const buildItemMarkdown = (item: FinderItem) => { - const Console = new Logger({ prefix: 'React' }); - - Console.info(`Building React Component for ${item.file} (${item.type}) with ${import.meta.filename}`); - Console.info(`Component info for ${item.file} (${item.type}):`, item); - const Turndown = new TurndownService(); - const CheerioComponent = cheerio.load( - ReactDOMServer.renderToStaticMarkup( - - ) - ); - - return Turndown.turndown(CheerioComponent.html()); -}; +import type { FinderItem } from '@/types/index'; +import { getGitBranch, getGitRepo, toAnchorId } from '@/utils/index'; +import { Logger } from '@bracketed/logger'; +import * as cheerio from 'cheerio'; +import type React from 'react'; +import ReactDOMServer from 'react-dom/server'; +import TurndownService from 'turndown'; + +const generateExampleValue = (input: { name: string; values: any }): string => { + if (input.values.default !== undefined) { + return String(input.values.default); + } + + const type = input.values.type ?? 'string'; + if (type === 'boolean') { + return 'true'; + } else if (type === 'number') { + return '1'; + } else { + // Use a GitHub Actions expression for dynamic values + const varName = input.name.toUpperCase().replace(/-/g, '_'); + return `$\{{ secrets.EXAMPLE_${varName} }}`; + } +}; + +const Component: React.FC = (props: FinderItem) => { + const repoPath = getGitRepo().replace('.git', ''); + const branch = getGitBranch(); + + // Generate workflow example + const workflowExample = `name: Example Workflow +on: + push: + branches: [main] + +jobs: + example: + uses: ${repoPath}/${props.file}@${branch}${ + props.content.inputs.length > 0 + ? ` + with:${props.content.inputs + .slice(0, 3) + .map( + (i) => ` + ${i.name}: ${generateExampleValue(i)}` + ) + .join('')}` + : '' + }`; + + // Generate action example + const actionExample = `steps: + - name: ${props.content.name} + uses: ${repoPath}/${props.dir}@${branch}${ + props.content.inputs.length > 0 + ? ` + with:${props.content.inputs + .slice(0, 3) + .map( + (i) => ` + ${i.name}: ${generateExampleValue(i)}` + ) + .join('')}` + : '' + }`; + + return ( +
+

+ {props.content.name} +

+
    +
  • + Component link: `{repoPath}/{props.type === 'workflow' ? props.file : props.dir}@{branch}`{' '} + [Source] +
  • +
  • Description: {props.content.description}
  • +
+ {props.content.inputs.length !== 0 ? ( +
+ Inputs: +
    + {props.content.inputs.map((i, ind) => ( +
  • + {i.name}: {i.values.description} +
      +
    • Required: `{i.values.required ? 'true' : 'false'}`
    • + {i.values.default ?
    • Default: `{String(i.values.default)}`
    • : undefined} +
    • Type: `{i.values.type ?? 'string'}`
    • +
    +
  • + ))} +
+
+ ) : undefined} +
+ Example Usage: +
+					{props.type === 'workflow' ? workflowExample : actionExample}
+				
+
+
+ ); +}; + +export const buildItemMarkdown = (item: FinderItem) => { + const Console = new Logger({ prefix: 'React' }); + + Console.info(`Building React Component for ${item.file} (${item.type}) with ${import.meta.filename}`); + Console.info(`Component info for ${item.file} (${item.type}):`, item); + const Turndown = new TurndownService(); + const CheerioComponent = cheerio.load( + ReactDOMServer.renderToStaticMarkup( + + ) + ); + + return Turndown.turndown(CheerioComponent.html()); +}; diff --git a/src/finder.ts b/src/finder.ts index 85748ca..2f8ec97 100644 --- a/src/finder.ts +++ b/src/finder.ts @@ -1,68 +1,68 @@ -import type { ActionWorkflow, HttpsJsonSchemastoreOrgGithubActionJson, Workflow } from '@/types/index'; -import { Logger } from '@bracketed/logger'; -import yaml from 'js-yaml'; -import fs from 'node:fs'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { stripFirst } from './utils'; - -export class ActionsFinder { - private readonly dir: string; - private readonly logger: Logger = new Logger({ prefix: 'Finder' }); - - constructor(dir: string) { - this.dir = dir; - } - - public async load(): Promise> { - const files = this.getFiles(path.resolve(import.meta.dirname, this.resolvePath(this.dir)), /\.ya?ml$/); - - const content = await Promise.all( - files.map(async (p) => { - const content = await yaml.load(fs.readFileSync(p, 'utf8')); - const fpath = path.relative(path.dirname(fileURLToPath(import.meta.url)), p); - this.logger.info(`Loaded Yaml content in ${stripFirst(fpath).replace(/\\/g, '/')}`); - - return { - content: content as HttpsJsonSchemastoreOrgGithubActionJson | Workflow, - relative: fpath.replace(/\\/g, '/'), - directory: path.parse(fpath).dir, - }; - }) - ); - - return content; - } - - private resolvePath(path: string | URL): string { - if (typeof path === 'string') return path; - return fileURLToPath(path); - } - - private getFiles(dir: string, regex: RegExp): Array { - const exemptions: { files: string[]; folders: string[] } = { - files: ['.yarnrc.yml'], - folders: ['node_modules', '.git', 'dist', '.yarn'], - }; - let results: Array = []; - - const list = fs.readdirSync(dir); - - list.forEach((file) => { - if (exemptions.folders.includes(file) || exemptions.files.includes(file)) return; - - const filePath = path.join(dir, file); - const stat = fs.statSync(filePath); - - if (stat && stat.isDirectory()) results = results.concat(this.getFiles(filePath, regex)); - else if (regex.test(file)) { - results.push(filePath); - this.logger.info( - `Got Action/Workflow ${stripFirst(path.relative(path.dirname(fileURLToPath(import.meta.url)), filePath)).replace(/\\/g, '/')}` - ); - } - }); - - return results; - } -} +import type { ActionWorkflow, HttpsJsonSchemastoreOrgGithubActionJson, Workflow } from '@/types/index'; +import { Logger } from '@bracketed/logger'; +import yaml from 'js-yaml'; +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { stripFirst } from './utils'; + +export class ActionsFinder { + private readonly dir: string; + private readonly logger: Logger = new Logger({ prefix: 'Finder' }); + + constructor(dir: string) { + this.dir = dir; + } + + public async load(): Promise> { + const files = this.getFiles(path.resolve(import.meta.dirname, this.resolvePath(this.dir)), /\.ya?ml$/); + + const content = await Promise.all( + files.map(async (p) => { + const content = await yaml.load(fs.readFileSync(p, 'utf8')); + const fpath = path.relative(path.dirname(fileURLToPath(import.meta.url)), p); + this.logger.info(`Loaded Yaml content in ${stripFirst(fpath).replace(/\\/g, '/')}`); + + return { + content: content as HttpsJsonSchemastoreOrgGithubActionJson | Workflow, + relative: fpath.replace(/\\/g, '/'), + directory: path.parse(fpath).dir, + }; + }) + ); + + return content; + } + + private resolvePath(path: string | URL): string { + if (typeof path === 'string') return path; + return fileURLToPath(path); + } + + private getFiles(dir: string, regex: RegExp): Array { + const exemptions: { files: string[]; folders: string[] } = { + files: ['.yarnrc.yml'], + folders: ['node_modules', '.git', 'dist', '.yarn'], + }; + let results: Array = []; + + const list = fs.readdirSync(dir); + + list.forEach((file) => { + if (exemptions.folders.includes(file) || exemptions.files.includes(file)) return; + + const filePath = path.join(dir, file); + const stat = fs.statSync(filePath); + + if (stat && stat.isDirectory()) results = results.concat(this.getFiles(filePath, regex)); + else if (regex.test(file)) { + results.push(filePath); + this.logger.info( + `Got Action/Workflow ${stripFirst(path.relative(path.dirname(fileURLToPath(import.meta.url)), filePath)).replace(/\\/g, '/')}` + ); + } + }); + + return results; + } +} diff --git a/src/index.ts b/src/index.ts index 3b8a105..d9006c1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,99 +1,99 @@ -/** - __/\\\______________/\\\__________________________________________________/\\\\\__/\\\\\\_________________________________________________ - _\/\\\_____________\/\\\______________________________/\\\______________/\\\///__\////\\\_________________________________________________ - _\/\\\_____________\/\\\_____________________________\/\\\_____________/\\\_________\/\\\_________________________________________________ - _\//\\\____/\\\____/\\\______/\\\\\_____/\\/\\\\\\\__\/\\\\\\\\_____/\\\\\\\\\______\/\\\________/\\\\\_____/\\____/\\___/\\__/\\\\\\\\\\_ - __\//\\\__/\\\\\__/\\\_____/\\\///\\\__\/\\\/////\\\_\/\\\////\\\__\////\\\//_______\/\\\______/\\\///\\\__\/\\\__/\\\\_/\\\_\/\\\//////__ - ___\//\\\/\\\/\\\/\\\_____/\\\__\//\\\_\/\\\___\///__\/\\\\\\\\/______\/\\\_________\/\\\_____/\\\__\//\\\_\//\\\/\\\\\/\\\__\/\\\\\\\\\\_ - ____\//\\\\\\//\\\\\_____\//\\\__/\\\__\/\\\_________\/\\\///\\\______\/\\\_________\/\\\____\//\\\__/\\\___\//\\\\\/\\\\\___\////////\\\_ - _____\//\\\__\//\\\_______\///\\\\\/___\/\\\_________\/\\\_\///\\\____\/\\\_______/\\\\\\\\\__\///\\\\\/_____\//\\\\//\\\_____/\\\\\\\\\\_ - ______\///____\///__________\/////_____\///__________\///____\///_____\///_______\/////////_____\/////________\///__\///_____\//////////__ - - A Reusable workflows repository by Bracketed Softworks! - @author ninjaninja140 - @name workflows-updater -*/ -import type { ActionCallInputs, ActionWorkflow, FileDataMap, WorkflowCall } from '@/types/index'; -import { buildURL, isGithubAction, isGithubWorkflow, stripFirst } from '@/utils/index'; -import { Logger } from '@bracketed/logger'; -import promised from 'node:fs/promises'; -import { - buildBaseMarkdown, - buildDateFooterMarkdown, - buildFooterMarkdown, - buildGlossaryMarkdown, - buildItemMarkdown, -} from './components'; -import { ActionsFinder } from './finder'; -console.clear(); - -async function main() { - const Console: Logger = new Logger({ depth: 6, prefix: 'Main' }); - const Finder: ActionsFinder = new ActionsFinder('../'); - const Files: Array = await Finder.load(); - - const Data: Array = Files.map((a) => { - let inputs; - let type; - - if (isGithubAction(a.content)) { - type = 'action'; - const Call: ActionCallInputs | undefined = a.content.inputs; - - if (!Call) inputs = {}; - else inputs = Call; - } - - if (isGithubWorkflow(a.content)) { - type = 'workflow'; - const Call: WorkflowCall | undefined = Object.values(a.content.on)[0] ?? undefined; - - if (!Call) inputs = {}; - else inputs = Call.inputs; - } - - inputs = Object.entries(inputs as object).map(([key, value]) => ({ - name: key, - values: value, - })); - - return { - type: type, - file: stripFirst(a.relative).replace(/\\/g, '/'), - dir: stripFirst(a.directory).replace(/\\/g, '/'), - content: { - name: a.content.name as string, - url: buildURL(stripFirst(a.relative).replace(/\\/g, '/')), - description: a.content.description, - inputs: inputs ?? [], - }, - }; - }).map((a) => ({ - ...a, - markdown: buildItemMarkdown(a), - })); - - const Workflows = Data.filter((a) => a.type === 'workflow'); - const Actions = Data.filter((a) => a.type === 'action'); - - Console.info('Building React & Markdown...'); - const Content: Array = [ - buildBaseMarkdown(), - buildGlossaryMarkdown({ name: 'Workflows', data: Workflows }, { name: 'Actions', data: Actions }), - '## Workflows:', - ...Workflows.map((w) => w.markdown), - '## Actions:', - ...Actions.map((w) => w.markdown), - buildDateFooterMarkdown(), - buildFooterMarkdown(), - ]; - - Console.info('Build & Organised React Components!'); - - await promised.writeFile('./README.md', Content.join('\n').replaceAll('\\', ''), { encoding: 'utf8' }); - Console.info('Saved new documentation data!'); - - process.exit(0); -} - -main(); +/** + __/\\\______________/\\\__________________________________________________/\\\\\__/\\\\\\_________________________________________________ + _\/\\\_____________\/\\\______________________________/\\\______________/\\\///__\////\\\_________________________________________________ + _\/\\\_____________\/\\\_____________________________\/\\\_____________/\\\_________\/\\\_________________________________________________ + _\//\\\____/\\\____/\\\______/\\\\\_____/\\/\\\\\\\__\/\\\\\\\\_____/\\\\\\\\\______\/\\\________/\\\\\_____/\\____/\\___/\\__/\\\\\\\\\\_ + __\//\\\__/\\\\\__/\\\_____/\\\///\\\__\/\\\/////\\\_\/\\\////\\\__\////\\\//_______\/\\\______/\\\///\\\__\/\\\__/\\\\_/\\\_\/\\\//////__ + ___\//\\\/\\\/\\\/\\\_____/\\\__\//\\\_\/\\\___\///__\/\\\\\\\\/______\/\\\_________\/\\\_____/\\\__\//\\\_\//\\\/\\\\\/\\\__\/\\\\\\\\\\_ + ____\//\\\\\\//\\\\\_____\//\\\__/\\\__\/\\\_________\/\\\///\\\______\/\\\_________\/\\\____\//\\\__/\\\___\//\\\\\/\\\\\___\////////\\\_ + _____\//\\\__\//\\\_______\///\\\\\/___\/\\\_________\/\\\_\///\\\____\/\\\_______/\\\\\\\\\__\///\\\\\/_____\//\\\\//\\\_____/\\\\\\\\\\_ + ______\///____\///__________\/////_____\///__________\///____\///_____\///_______\/////////_____\/////________\///__\///_____\//////////__ + + A Reusable workflows repository by Bracketed Softworks! + @author ninjaninja140 + @name workflows-updater +*/ +import type { ActionCallInputs, ActionWorkflow, FileDataMap, WorkflowCall } from '@/types/index'; +import { buildURL, isGithubAction, isGithubWorkflow, stripFirst } from '@/utils/index'; +import { Logger } from '@bracketed/logger'; +import promised from 'node:fs/promises'; +import { + buildBaseMarkdown, + buildDateFooterMarkdown, + buildFooterMarkdown, + buildGlossaryMarkdown, + buildItemMarkdown, +} from './components'; +import { ActionsFinder } from './finder'; +console.clear(); + +async function main() { + const Console: Logger = new Logger({ depth: 6, prefix: 'Main' }); + const Finder: ActionsFinder = new ActionsFinder('../'); + const Files: Array = await Finder.load(); + + const Data: Array = Files.map((a) => { + let inputs; + let type; + + if (isGithubAction(a.content)) { + type = 'action'; + const Call: ActionCallInputs | undefined = a.content.inputs; + + if (!Call) inputs = {}; + else inputs = Call; + } + + if (isGithubWorkflow(a.content)) { + type = 'workflow'; + const Call: WorkflowCall | undefined = Object.values(a.content.on)[0] ?? undefined; + + if (!Call) inputs = {}; + else inputs = Call.inputs; + } + + inputs = Object.entries(inputs as object).map(([key, value]) => ({ + name: key, + values: value, + })); + + return { + type: type, + file: stripFirst(a.relative).replace(/\\/g, '/'), + dir: stripFirst(a.directory).replace(/\\/g, '/'), + content: { + name: a.content.name as string, + url: buildURL(stripFirst(a.relative).replace(/\\/g, '/')), + description: a.content.description, + inputs: inputs ?? [], + }, + }; + }).map((a) => ({ + ...a, + markdown: buildItemMarkdown(a), + })); + + const Workflows = Data.filter((a) => a.type === 'workflow'); + const Actions = Data.filter((a) => a.type === 'action'); + + Console.info('Building React & Markdown...'); + const Content: Array = [ + buildBaseMarkdown(), + buildGlossaryMarkdown({ name: 'Workflows', data: Workflows }, { name: 'Actions', data: Actions }), + '## Workflows:', + ...Workflows.map((w) => w.markdown), + '## Actions:', + ...Actions.map((w) => w.markdown), + buildDateFooterMarkdown(), + buildFooterMarkdown(), + ]; + + Console.info('Build & Organised React Components!'); + + await promised.writeFile('./README.md', Content.join('\n').replaceAll('\\', ''), { encoding: 'utf8' }); + Console.info('Saved new documentation data!'); + + process.exit(0); +} + +main(); diff --git a/src/types/ac_input.d.ts b/src/types/ac_input.d.ts index 47b0b27..841e0c9 100644 --- a/src/types/ac_input.d.ts +++ b/src/types/ac_input.d.ts @@ -1,26 +1,26 @@ -export interface ActionCallInputs { - /** - * A string identifier to associate with the input. The value of `` is a map of the input's metadata. The `` must be a unique identifier within the inputs object. The `` must start with a letter or `_` and contain only alphanumeric characters, `-`, or `_`. - * - * This interface was referenced by `undefined`'s JSON-Schema definition - * via the `patternProperty` "^[_a-zA-Z][a-zA-Z0-9_-]*$". - */ - [k: string]: { - /** - * A string description of the input parameter. - */ - description: string; - /** - * A string shown to users using the deprecated input. - */ - deprecationMessage?: string; - /** - * A boolean to indicate whether the action requires the input parameter. Set to `true` when the parameter is required. - */ - required?: boolean; - /** - * A string representing the default value. The default value is used when an input parameter isn't specified in a workflow file. - */ - default?: string; - }; -} +export interface ActionCallInputs { + /** + * A string identifier to associate with the input. The value of `` is a map of the input's metadata. The `` must be a unique identifier within the inputs object. The `` must start with a letter or `_` and contain only alphanumeric characters, `-`, or `_`. + * + * This interface was referenced by `undefined`'s JSON-Schema definition + * via the `patternProperty` "^[_a-zA-Z][a-zA-Z0-9_-]*$". + */ + [k: string]: { + /** + * A string description of the input parameter. + */ + description: string; + /** + * A string shown to users using the deprecated input. + */ + deprecationMessage?: string; + /** + * A boolean to indicate whether the action requires the input parameter. Set to `true` when the parameter is required. + */ + required?: boolean; + /** + * A string representing the default value. The default value is used when an input parameter isn't specified in a workflow file. + */ + default?: string; + }; +} diff --git a/src/types/action-workflow.d.ts b/src/types/action-workflow.d.ts index 2305fb0..2c5f264 100644 --- a/src/types/action-workflow.d.ts +++ b/src/types/action-workflow.d.ts @@ -1,8 +1,8 @@ -import type { HttpsJsonSchemastoreOrgGithubActionJson } from './schemas'; -import type { Workflow } from './workflow'; - -export type ActionWorkflow = { - content: HttpsJsonSchemastoreOrgGithubActionJson | Workflow; - relative: string; - directory: string; -}; +import type { HttpsJsonSchemastoreOrgGithubActionJson } from './schemas'; +import type { Workflow } from './workflow'; + +export type ActionWorkflow = { + content: HttpsJsonSchemastoreOrgGithubActionJson | Workflow; + relative: string; + directory: string; +}; diff --git a/src/types/datamap.d.ts b/src/types/datamap.d.ts index 451ee60..6a46e85 100644 --- a/src/types/datamap.d.ts +++ b/src/types/datamap.d.ts @@ -1,15 +1,15 @@ -export interface FileDataMap { - markdown: string; - type?: string; - file: string; - dir: string; - content: { - name: string; - url: string; - description: string; - inputs: Array<{ - name: string; - values: any; - }>; - }; -} +export interface FileDataMap { + markdown: string; + type?: string; + file: string; + dir: string; + content: { + name: string; + url: string; + description: string; + inputs: Array<{ + name: string; + values: any; + }>; + }; +} diff --git a/src/types/index.d.ts b/src/types/index.d.ts index bfac96d..925e62a 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -1,9 +1,9 @@ -export * from './ac_input'; -export * from './action-workflow'; -export * from './datamap'; -export * from './input'; -export * from './item'; -export * from './schemas'; -export * from './wf_call'; -export * from './wf_input'; -export * from './workflow'; +export * from './ac_input'; +export * from './action-workflow'; +export * from './datamap'; +export * from './input'; +export * from './item'; +export * from './schemas'; +export * from './wf_call'; +export * from './wf_input'; +export * from './workflow'; diff --git a/src/types/input.d.ts b/src/types/input.d.ts index 756d33d..f6c7585 100644 --- a/src/types/input.d.ts +++ b/src/types/input.d.ts @@ -1,21 +1,21 @@ -export interface Input { - name: string | undefined; - values: { - /** - * A string description of the input parameter. - */ - description?: string; - /** - * A boolean to indicate whether the action requires the input parameter. Set to true when the parameter is required. - */ - required?: boolean; - /** - * Required if input is defined for the on.workflow_call keyword. The value of this parameter is a string specifying the data type of the input. This must be one of: boolean, number, or string. - */ - type?: 'boolean' | 'number' | 'string'; - /** - * The default value is used when an input parameter isn't specified in a workflow file. - */ - default?: boolean | number | string; - }; -} +export interface Input { + name: string | undefined; + values: { + /** + * A string description of the input parameter. + */ + description?: string; + /** + * A boolean to indicate whether the action requires the input parameter. Set to true when the parameter is required. + */ + required?: boolean; + /** + * Required if input is defined for the on.workflow_call keyword. The value of this parameter is a string specifying the data type of the input. This must be one of: boolean, number, or string. + */ + type?: 'boolean' | 'number' | 'string'; + /** + * The default value is used when an input parameter isn't specified in a workflow file. + */ + default?: boolean | number | string; + }; +} diff --git a/src/types/item.d.ts b/src/types/item.d.ts index f4e062a..33f9943 100644 --- a/src/types/item.d.ts +++ b/src/types/item.d.ts @@ -1,13 +1,13 @@ -import type { Input } from './input'; - -export interface FinderItem { - type?: string; - file: string; - dir: string; - content: { - name: string; - url: string; - description: string; - inputs: Array; - }; -} +import type { Input } from './input'; + +export interface FinderItem { + type?: string; + file: string; + dir: string; + content: { + name: string; + url: string; + description: string; + inputs: Array; + }; +} diff --git a/src/types/wf_call.d.ts b/src/types/wf_call.d.ts index 3d3770a..44bb46b 100644 --- a/src/types/wf_call.d.ts +++ b/src/types/wf_call.d.ts @@ -1,53 +1,53 @@ -export interface WorkflowCall { - /** - * When using the workflow_call keyword, you can optionally specify inputs that are passed to the called workflow from the caller workflow. - */ - inputs?: { - /** - * A string identifier to associate with the input. The value of is a map of the input's metadata. The must be a unique identifier within the inputs object. The must start with a letter or _ and contain only alphanumeric characters, -, or _. - * - * This interface was referenced by `undefined`'s JSON-Schema definition - * via the `patternProperty` "^[_a-zA-Z][a-zA-Z0-9_-]*$". - */ - [k: string]: { - /** - * A string description of the input parameter. - */ - description?: string; - /** - * A boolean to indicate whether the action requires the input parameter. Set to true when the parameter is required. - */ - required?: boolean; - /** - * Required if input is defined for the on.workflow_call keyword. The value of this parameter is a string specifying the data type of the input. This must be one of: boolean, number, or string. - */ - type: 'boolean' | 'number' | 'string'; - /** - * The default value is used when an input parameter isn't specified in a workflow file. - */ - default?: boolean | number | string; - }; - }; - /** - * A map of the secrets that can be used in the called workflow. Within the called workflow, you can use the secrets context to refer to a secret. - */ - secrets?: { - /** - * A string identifier to associate with the secret. - * - * This interface was referenced by `undefined`'s JSON-Schema definition - * via the `patternProperty` "^[_a-zA-Z][a-zA-Z0-9_-]*$". - */ - [k: string]: { - /** - * A string description of the secret parameter. - */ - description?: string; - /** - * A boolean specifying whether the secret must be supplied. - */ - required: boolean; - }; - }; - [k: string]: unknown; -} +export interface WorkflowCall { + /** + * When using the workflow_call keyword, you can optionally specify inputs that are passed to the called workflow from the caller workflow. + */ + inputs?: { + /** + * A string identifier to associate with the input. The value of is a map of the input's metadata. The must be a unique identifier within the inputs object. The must start with a letter or _ and contain only alphanumeric characters, -, or _. + * + * This interface was referenced by `undefined`'s JSON-Schema definition + * via the `patternProperty` "^[_a-zA-Z][a-zA-Z0-9_-]*$". + */ + [k: string]: { + /** + * A string description of the input parameter. + */ + description?: string; + /** + * A boolean to indicate whether the action requires the input parameter. Set to true when the parameter is required. + */ + required?: boolean; + /** + * Required if input is defined for the on.workflow_call keyword. The value of this parameter is a string specifying the data type of the input. This must be one of: boolean, number, or string. + */ + type: 'boolean' | 'number' | 'string'; + /** + * The default value is used when an input parameter isn't specified in a workflow file. + */ + default?: boolean | number | string; + }; + }; + /** + * A map of the secrets that can be used in the called workflow. Within the called workflow, you can use the secrets context to refer to a secret. + */ + secrets?: { + /** + * A string identifier to associate with the secret. + * + * This interface was referenced by `undefined`'s JSON-Schema definition + * via the `patternProperty` "^[_a-zA-Z][a-zA-Z0-9_-]*$". + */ + [k: string]: { + /** + * A string description of the secret parameter. + */ + description?: string; + /** + * A boolean specifying whether the secret must be supplied. + */ + required: boolean; + }; + }; + [k: string]: unknown; +} diff --git a/src/types/wf_input.d.ts b/src/types/wf_input.d.ts index 1e33640..19d7fe0 100644 --- a/src/types/wf_input.d.ts +++ b/src/types/wf_input.d.ts @@ -1,8 +1,8 @@ -export interface WorkflowCallInput { - [k: string]: { - description?: string; - required?: boolean; - type: 'boolean' | 'number' | 'string'; - default?: boolean | number | string; - }; -} +export interface WorkflowCallInput { + [k: string]: { + description?: string; + required?: boolean; + type: 'boolean' | 'number' | 'string'; + default?: boolean | number | string; + }; +} diff --git a/src/types/workflow.d.ts b/src/types/workflow.d.ts index 4ba5b40..500f7ee 100644 --- a/src/types/workflow.d.ts +++ b/src/types/workflow.d.ts @@ -1,5 +1,5 @@ -import type { HttpsJsonSchemastoreOrgGithubWorkflowJson } from './schemas/index'; - -export interface Workflow extends HttpsJsonSchemastoreOrgGithubWorkflowJson { - description: string; -} +import type { HttpsJsonSchemastoreOrgGithubWorkflowJson } from './schemas/index'; + +export interface Workflow extends HttpsJsonSchemastoreOrgGithubWorkflowJson { + description: string; +} diff --git a/src/utils/getBranch.ts b/src/utils/getBranch.ts index be39b5f..5bf8e97 100644 --- a/src/utils/getBranch.ts +++ b/src/utils/getBranch.ts @@ -1,15 +1,15 @@ -import { Logger } from '@bracketed/logger'; -import { execSync } from 'node:child_process'; -const Console = new Logger({ prefix: 'Terminal' }); - -export function getGitBranch(): string { - try { - Console.info('Getting current repository branch...'); - const output = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }); - Console.info('Retrieved repository branch:', output.trim()); - return output.trim(); - } catch (error) { - Console.error('Error fetching branch:', error); - return ''; - } -} +import { Logger } from '@bracketed/logger'; +import { execSync } from 'node:child_process'; +const Console = new Logger({ prefix: 'Terminal' }); + +export function getGitBranch(): string { + try { + Console.info('Getting current repository branch...'); + const output = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }); + Console.info('Retrieved repository branch:', output.trim()); + return output.trim(); + } catch (error) { + Console.error('Error fetching branch:', error); + return ''; + } +} diff --git a/src/utils/getLatestCommitFullHash.ts b/src/utils/getLatestCommitFullHash.ts index e969b6c..9c6af8b 100644 --- a/src/utils/getLatestCommitFullHash.ts +++ b/src/utils/getLatestCommitFullHash.ts @@ -1,15 +1,15 @@ -import { Logger } from '@bracketed/logger'; -import { execSync } from 'node:child_process'; -const Console = new Logger({ prefix: 'Terminal' }); - -export function getLatestCommitFullHash(): string { - try { - Console.info('Getting latest commit long hash...'); - const output = execSync('git log -1 --pretty=format:"%H"', { encoding: 'utf8' }); - Console.info('Retrieved latest commit hash:', output.trim()); - return output.trim(); - } catch (error) { - Console.error('Error fetching latest commit hash:', error); - return ''; - } -} +import { Logger } from '@bracketed/logger'; +import { execSync } from 'node:child_process'; +const Console = new Logger({ prefix: 'Terminal' }); + +export function getLatestCommitFullHash(): string { + try { + Console.info('Getting latest commit long hash...'); + const output = execSync('git log -1 --pretty=format:"%H"', { encoding: 'utf8' }); + Console.info('Retrieved latest commit hash:', output.trim()); + return output.trim(); + } catch (error) { + Console.error('Error fetching latest commit hash:', error); + return ''; + } +} diff --git a/src/utils/getLatestCommitHash.ts b/src/utils/getLatestCommitHash.ts index 7cd24cb..5296a2c 100644 --- a/src/utils/getLatestCommitHash.ts +++ b/src/utils/getLatestCommitHash.ts @@ -1,15 +1,15 @@ -import { Logger } from '@bracketed/logger'; -import { execSync } from 'node:child_process'; -const Console = new Logger({ prefix: 'Terminal' }); - -export function getLatestCommitHash(): string { - try { - Console.info('Getting latest commit short hash...'); - const output = execSync('git log -1 --pretty=format:"%h"', { encoding: 'utf8' }); - Console.info('Retrieved latest commit short hash:', output.trim()); - return output.trim(); - } catch (error) { - Console.error('Error fetching latest commit hash:', error); - return ''; - } -} +import { Logger } from '@bracketed/logger'; +import { execSync } from 'node:child_process'; +const Console = new Logger({ prefix: 'Terminal' }); + +export function getLatestCommitHash(): string { + try { + Console.info('Getting latest commit short hash...'); + const output = execSync('git log -1 --pretty=format:"%h"', { encoding: 'utf8' }); + Console.info('Retrieved latest commit short hash:', output.trim()); + return output.trim(); + } catch (error) { + Console.error('Error fetching latest commit hash:', error); + return ''; + } +} diff --git a/src/utils/getLatestCommitUser.ts b/src/utils/getLatestCommitUser.ts index d5ba5da..9b0a05a 100644 --- a/src/utils/getLatestCommitUser.ts +++ b/src/utils/getLatestCommitUser.ts @@ -1,15 +1,15 @@ -import { Logger } from '@bracketed/logger'; -import { execSync } from 'node:child_process'; -const Console = new Logger({ prefix: 'Terminal' }); - -export function getLatestCommitUser(): string { - try { - Console.info('Getting Github latest editor username...'); - const output = execSync('git log -1 --pretty=format:"%an"', { encoding: 'utf8' }); - Console.info('Detected', output.trim(), 'to be the latest editor!'); - return output.trim(); - } catch (error) { - Console.error('Error fetching latest commit user:', error); - return ''; - } -} +import { Logger } from '@bracketed/logger'; +import { execSync } from 'node:child_process'; +const Console = new Logger({ prefix: 'Terminal' }); + +export function getLatestCommitUser(): string { + try { + Console.info('Getting Github latest editor username...'); + const output = execSync('git log -1 --pretty=format:"%an"', { encoding: 'utf8' }); + Console.info('Detected', output.trim(), 'to be the latest editor!'); + return output.trim(); + } catch (error) { + Console.error('Error fetching latest commit user:', error); + return ''; + } +} diff --git a/src/utils/getRepository.ts b/src/utils/getRepository.ts index 99f67b1..6e3f7b9 100644 --- a/src/utils/getRepository.ts +++ b/src/utils/getRepository.ts @@ -1,19 +1,19 @@ -import { Logger } from '@bracketed/logger'; -import { execSync } from 'node:child_process'; -const Console = new Logger({ prefix: 'Terminal' }); - -export function getGitRepo(): string { - try { - Console.info('Getting Github Repository from git...'); - const output = execSync('git remote get-url origin', { encoding: 'utf8' }); - const match = output.trim().match(/(?:github\.com[:/])([^/]+)\/([^/]+)/); - - if (match && match[1] && match[2]) { - Console.info('Found Repository:', `${match[1]}/${match[2]}`); - return `${match[1]}/${match[2]}`; - } else return ''; - } catch (error) { - Console.error('Error fetching Github origin URL:', error); - return ''; - } -} +import { Logger } from '@bracketed/logger'; +import { execSync } from 'node:child_process'; +const Console = new Logger({ prefix: 'Terminal' }); + +export function getGitRepo(): string { + try { + Console.info('Getting Github Repository from git...'); + const output = execSync('git remote get-url origin', { encoding: 'utf8' }); + const match = output.trim().match(/(?:github\.com[:/])([^/]+)\/([^/]+)/); + + if (match && match[1] && match[2]) { + Console.info('Found Repository:', `${match[1]}/${match[2]}`); + return `${match[1]}/${match[2]}`; + } else return ''; + } catch (error) { + Console.error('Error fetching Github origin URL:', error); + return ''; + } +} diff --git a/src/utils/index.ts b/src/utils/index.ts index a42f81b..2992278 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,8 +1,9 @@ -export * from './getBranch'; -export * from './getLatestCommitFullHash'; -export * from './getLatestCommitHash'; -export * from './getLatestCommitUser'; -export * from './getRepository'; -export * from './isType'; -export * from './parseURL'; -export * from './strip-first'; +export * from './getBranch'; +export * from './getLatestCommitFullHash'; +export * from './getLatestCommitHash'; +export * from './getLatestCommitUser'; +export * from './getRepository'; +export * from './isType'; +export * from './parseURL'; +export * from './strip-first'; +export * from './toAnchorId'; diff --git a/src/utils/isType.ts b/src/utils/isType.ts index 4a48aaa..1ad47b6 100644 --- a/src/utils/isType.ts +++ b/src/utils/isType.ts @@ -1,21 +1,21 @@ -import type { HttpsJsonSchemastoreOrgGithubActionJson, Workflow } from '@/types/index'; - -export function isGithubAction(content: unknown): content is HttpsJsonSchemastoreOrgGithubActionJson { - return ( - typeof content === 'object' && - content !== null && - 'name' in content && - 'description' in content && - 'runs' in content - ); -} - -export function isGithubWorkflow(content: unknown): content is Workflow { - return ( - typeof content === 'object' && - content !== null && - 'name' in content && - 'description' in content && - 'jobs' in content - ); -} +import type { HttpsJsonSchemastoreOrgGithubActionJson, Workflow } from '@/types/index'; + +export function isGithubAction(content: unknown): content is HttpsJsonSchemastoreOrgGithubActionJson { + return ( + typeof content === 'object' && + content !== null && + 'name' in content && + 'description' in content && + 'runs' in content + ); +} + +export function isGithubWorkflow(content: unknown): content is Workflow { + return ( + typeof content === 'object' && + content !== null && + 'name' in content && + 'description' in content && + 'jobs' in content + ); +} diff --git a/src/utils/parseURL.ts b/src/utils/parseURL.ts index cce9351..699dd1f 100644 --- a/src/utils/parseURL.ts +++ b/src/utils/parseURL.ts @@ -1,9 +1,9 @@ -import { getGitBranch } from './getBranch'; -import { getGitRepo } from './getRepository'; - -export function buildURL(file: string) { - const branch = getGitBranch(); - const repo = getGitRepo().replace('.git', ''); - - return `https://github.com/${repo}/blob/${branch}/${file}`; -} +import { getGitBranch } from './getBranch'; +import { getGitRepo } from './getRepository'; + +export function buildURL(file: string) { + const branch = getGitBranch(); + const repo = getGitRepo().replace('.git', ''); + + return `https://github.com/${repo}/blob/${branch}/${file}`; +} diff --git a/src/utils/strip-first.ts b/src/utils/strip-first.ts index 3a130ed..2158abd 100644 --- a/src/utils/strip-first.ts +++ b/src/utils/strip-first.ts @@ -1,8 +1,8 @@ -import path from 'node:path'; - -export function stripFirst(fpath: string) { - const parts = path.normalize(fpath).split(path.sep); - parts.shift(); - - return path.join(...parts); -} +import path from 'node:path'; + +export function stripFirst(fpath: string) { + const parts = path.normalize(fpath).split(path.sep); + parts.shift(); + + return path.join(...parts); +} diff --git a/src/utils/toAnchorId.ts b/src/utils/toAnchorId.ts new file mode 100644 index 0000000..2674111 --- /dev/null +++ b/src/utils/toAnchorId.ts @@ -0,0 +1,16 @@ +/** + * Convert a string to a markdown-compatible anchor ID + * Follows GitHub's markdown anchor ID generation rules: + * - Lowercase the string + * - Replace spaces with hyphens + * - Remove special characters except hyphens + * - Remove leading/trailing hyphens + */ +export function toAnchorId(text: string): string { + return text + .toLowerCase() + .replace(/\s+/g, '-') // Replace spaces with hyphens + .replace(/[^\w-]+/g, '-') // Replace special chars with hyphens + .replace(/-+/g, '-') // Replace multiple hyphens with single hyphen + .replace(/^-+|-+$/g, ''); // Remove leading/trailing hyphens +}