diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 660d416..960cd03 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,5 +34,7 @@ jobs: run: bun install - name: Format run: bun fmt:ci + - name: typos-action + uses: crate-ci/typos@v1.17.2 - name: Lint run: bun lint diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cebf71f..6aa77cf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,7 @@ To create a new module, clone this repository and run: ```shell -./new.sh MOUDLE_NAME +./new.sh MODULE_NAME ``` ## Testing a Module diff --git a/exoscale-instance-type/README.md b/exoscale-instance-type/README.md index 2795062..4b493f9 100644 --- a/exoscale-instance-type/README.md +++ b/exoscale-instance-type/README.md @@ -10,7 +10,7 @@ tags: [helper, parameter, instances, exoscale] # exoscale-instance-type A parameter with all Exoscale instance types. This allows developers to select -their desired virtuell machine for the workspace. +their desired virtual machine for the workspace. Customize the preselected parameter value: @@ -72,7 +72,7 @@ resource "coder_metadata" "workspace_info" { ![Exoscale instance types Custom](../.images/exoscale-instance-custom.png) -### Use category and exlude type +### Use category and exclude type Show only gpu1 types diff --git a/filebrowser/main.test.ts b/filebrowser/main.test.ts index 7541e65..79dd99d 100644 --- a/filebrowser/main.test.ts +++ b/filebrowser/main.test.ts @@ -33,7 +33,7 @@ describe("filebrowser", async () => { expect(output.stdout).toEqual([ "\u001b[0;1mInstalling filebrowser ", "", - "🥳 Installation comlete! ", + "🥳 Installation complete! ", "", "👷 Starting filebrowser in background... ", "", @@ -55,7 +55,7 @@ describe("filebrowser", async () => { expect(output.stdout).toEqual([ "\u001b[0;1mInstalling filebrowser ", "", - "🥳 Installation comlete! ", + "🥳 Installation complete! ", "", "👷 Starting filebrowser in background... ", "", @@ -77,7 +77,7 @@ describe("filebrowser", async () => { expect(output.stdout).toEqual([ "\u001B[0;1mInstalling filebrowser ", "", - "🥳 Installation comlete! ", + "🥳 Installation complete! ", "", "👷 Starting filebrowser in background... ", "", diff --git a/filebrowser/run.sh b/filebrowser/run.sh index 0cbf8f4..8744edb 100644 --- a/filebrowser/run.sh +++ b/filebrowser/run.sh @@ -5,7 +5,7 @@ printf "$${BOLD}Installing filebrowser \n\n" curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash -printf "🥳 Installation comlete! \n\n" +printf "🥳 Installation complete! \n\n" printf "👷 Starting filebrowser in background... \n\n" diff --git a/lint.ts b/lint.ts index 01c2afd..db1ee9a 100644 --- a/lint.ts +++ b/lint.ts @@ -13,9 +13,39 @@ let badExit = false; // error reports an error to the console and sets badExit to true // so that the process will exit with a non-zero exit code. const error = (...data: any[]) => { - console.error(...data); - badExit = true; -} + console.error(...data); + badExit = true; +}; + +const verifyCodeBlocks = ( + tokens: marked.Token[], + res = { + codeIsTF: false, + codeIsHCL: false, + } +) => { + for (const token of tokens) { + // Check in-depth. + if (token.type === "list") { + verifyCodeBlocks(token.items, res); + continue; + } + if (token.type === "list_item") { + verifyCodeBlocks(token.tokens, res); + continue; + } + + if (token.type === "code") { + if (token.lang === "tf") { + res.codeIsTF = true; + } + if (token.lang === "hcl") { + res.codeIsHCL = true; + } + } + } + return res; +}; // Ensures that each README has the proper format. // Exits with 0 if all is good! @@ -82,9 +112,6 @@ for (const dir of dirs) { version = false; error(dir.name, "missing version in tf code block"); } - if (token.lang === "hcl") { - error(dir.name, "HCL code blocks are not allowed, use tf"); - } continue; } } @@ -97,8 +124,13 @@ for (const dir of dirs) { if (!code) { error(dir.name, "missing example code block after paragraph"); } - if (!version) { - error(dir.name, "missing version in tf code block"); + + const { codeIsTF, codeIsHCL } = verifyCodeBlocks(tokens); + if (!codeIsTF) { + error(dir.name, "missing example tf code block"); + } + if (codeIsHCL) { + error(dir.name, "hcl code block should be tf"); } } diff --git a/new.sh b/new.sh index e35e860..514ce4d 100755 --- a/new.sh +++ b/new.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This scripts creates a new sample moduledir with requried files +# This scripts creates a new sample moduledir with required files # Run it like : ./new.sh my-module MODULE_NAME=$1 @@ -11,7 +11,7 @@ if [ -z "$MODULE_NAME" ]; then exit 1 fi -# Create module directory and exit if it alredy exists +# Create module directory and exit if it already exists if [ -d "$MODULE_NAME" ]; then echo "Module with name $MODULE_NAME already exists" echo "Please choose a different name"