Skip to content

Commit

Permalink
Add prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuschko committed Nov 9, 2023
1 parent c335706 commit 5ff4506
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 22 deletions.
18 changes: 17 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Sets up the Kubeconform CLI in your GitHub Actions workflow.",
"main": "dist/index.js",
"scripts": {
"format": "echo \"unimplemented for bmuschko/setup-kubeconform\"",
"format-check": "echo \"unimplemented for bmuschko/setup-kubeconform\"",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"lint": "echo \"unimplemented for bmuschko/setup-kubeconform\"",
"compile": "ncc build src/main.ts --out dist",
"build": "npm run check && npm run compile",
Expand Down Expand Up @@ -35,6 +35,7 @@
"devDependencies": {
"@types/node": "20.9.0",
"@vercel/ncc": "0.38.1",
"prettier": "3.0.3",
"typescript": "5.2.2"
}
}
16 changes: 11 additions & 5 deletions src/distribution.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as util from "util";
import * as util from 'util'

export interface ToolDistribution {
getDownloadURL(): string
Expand All @@ -19,7 +19,7 @@ export class KubeconformDistribution implements ToolDistribution {

// See https://nodejs.org/api/os.html#os_os_platform
private mapOS(os: string): string {
switch(os) {
switch (os) {
case 'win32':
return 'windows'
default:
Expand All @@ -29,7 +29,7 @@ export class KubeconformDistribution implements ToolDistribution {

// See https://nodejs.org/api/os.html#osarch
private mapArch(arch: string): string {
switch(arch) {
switch (arch) {
case 'x32':
return '386'
case 'x64':
Expand All @@ -44,6 +44,12 @@ export class KubeconformDistribution implements ToolDistribution {
}

getDownloadURL(): string {
return util.format('https://github.com/yannh/kubeconform/releases/download/v%s/kubeconform-%s-%s.%s', this.version, this.os, this.arch, this.fileExt)
return util.format(
'https://github.com/yannh/kubeconform/releases/download/v%s/kubeconform-%s-%s.%s',
this.version,
this.os,
this.arch,
this.fileExt
)
}
}
}
18 changes: 9 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import * as os from "os"
import * as os from 'os'

import * as core from "@actions/core"
import * as core from '@actions/core'

import * as dist from "./distribution"
import * as setup from "./setup"
import * as dist from './distribution'
import * as setup from './setup'

export async function run(): Promise<void> {
try {
// Get version of tool to be installed
const version = core.getInput('kubeconform-version');
const version = core.getInput('kubeconform-version')
console.log(`Setting up kubeconform with version '${version}'`)

// Set up kubeconform
const distribution = new dist.KubeconformDistribution(version, os.platform(), os.arch())
setup.setupTool(distribution)
} catch(error) {
core.setFailed(String(error))
}
} catch (error) {
core.setFailed(String(error))
}
}

run()
run()
10 changes: 5 additions & 5 deletions src/setup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as os from "os"
import * as os from 'os'

import * as core from "@actions/core"
import * as tc from "@actions/tool-cache"
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'

import * as dist from "./distribution"
import * as dist from './distribution'

export async function setupTool(distribution: dist.ToolDistribution): Promise<void> {
// Determine download URL considering the OS and architecture
Expand All @@ -29,4 +29,4 @@ function extractDownloadedBinary(pathToArchive: string): Promise<string> {
}

return tc.extractTar(pathToArchive)
}
}

0 comments on commit 5ff4506

Please sign in to comment.