1
0
Fork 0

Remove helpers package

pull/1562/head
Nikolai Laevskii 2023-10-12 11:32:17 +02:00
parent d15c09b836
commit 61f54e28ca
7 changed files with 0 additions and 291 deletions

View File

@ -1,9 +0,0 @@
The MIT License (MIT)
Copyright 2023 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,83 +0,0 @@
import CommandHelper from '../src/exec-command-wrapper'
import * as io from '@actions/io'
const IS_WINDOWS = process.platform === 'win32'
describe('Command', () => {
it('creates a command object', async () => {
let toolpath: string
let args: string[]
if (IS_WINDOWS) {
toolpath = await io.which('cmd', true)
args = ['/c', 'echo', 'hello']
} else {
toolpath = await io.which('echo', true)
args = ['hello']
}
const command = new CommandHelper(`"${toolpath}"`, args)
expect(command).toBeDefined()
expect(command).toBeInstanceOf(CommandHelper)
})
it('runs a command with non-zero exit code', async () => {
let toolpath: string
let args: string[]
if (IS_WINDOWS) {
toolpath = await io.which('cmd', true)
args = ['/c', 'dir', 'non-existent-dir']
} else {
toolpath = await io.which('ls', true)
args = ['-l', 'non-existent-dir']
}
const command = new CommandHelper(`"${toolpath}"`, args, undefined, {
throwOnEmptyOutput: true
})
try {
const result = await command.execute()
expect(result.exitCode).not.toEqual(0)
} catch (err) {
expect(err.message).toContain(
`The process '${toolpath}' failed with exit code `
)
}
})
it('runs a command with zero exit code', async () => {
let toolpath: string
let args: string[]
if (IS_WINDOWS) {
toolpath = await io.which('cmd', true)
args = ['/c', 'echo', 'hello']
} else {
toolpath = await io.which('echo', true)
args = ['hello']
}
const command = new CommandHelper(`"${toolpath}"`, args)
const result = await command.execute()
expect(result.stdout).toContain('hello')
expect(result.exitCode).toEqual(0)
})
it('runs a command with empty output', async () => {
let toolpath: string
let args: string[]
if (IS_WINDOWS) {
toolpath = await io.which('cmd', true)
args = ['/c', 'echo.']
} else {
toolpath = await io.which('echo', true)
args = ['']
}
const command = new CommandHelper(`"${toolpath}"`, args, undefined, {
throwOnEmptyOutput: true
})
try {
const result = await command.execute()
expect(result.stdout).toBe('')
} catch (err) {
expect(err.message).toContain('The command produced an empty output.')
}
})
})

View File

@ -1,72 +0,0 @@
{
"name": "@actions/helpers",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@actions/helpers",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1"
},
"devDependencies": {
"@types/node": "^20.5.0"
}
},
"node_modules/@actions/core": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
"dependencies": {
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
}
},
"node_modules/@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"dependencies": {
"@actions/io": "^1.0.1"
}
},
"node_modules/@actions/http-client": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.1.tgz",
"integrity": "sha512-qhrkRMB40bbbLo7gF+0vu+X+UawOvQQqNAA/5Unx774RS8poaOhThDOG6BGmxvAnxhQnDp2BG/ZUm65xZILTpw==",
"dependencies": {
"tunnel": "^0.0.6"
}
},
"node_modules/@actions/io": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz",
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
},
"node_modules/@types/node": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.0.tgz",
"integrity": "sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q==",
"dev": true
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
"engines": {
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
}
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"bin": {
"uuid": "dist/bin/uuid"
}
}
}
}

View File

@ -1,46 +0,0 @@
{
"name": "@actions/helpers",
"version": "1.0.0",
"description": "Helpers for creating actions",
"main": "lib/helpers.js",
"types": "lib/helpers.d.ts",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib",
"!.DS_Store"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json",
"test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc -p tsconfig.json"
},
"repository": {
"type": "git",
"url": "git+https://github.com/actions/toolkit.git",
"directory": "packages/helpers"
},
"keywords": [
"github",
"actions",
"helpers"
],
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
},
"homepage": "https://github.com/actions/toolkit#readme",
"devDependencies": {
"@types/node": "^20.5.0"
},
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1"
}
}

View File

@ -1,68 +0,0 @@
import * as exec from '@actions/exec'
import * as core from '@actions/core'
export default class CommandHelper {
constructor(
private commandText: string,
private args: string[] = [],
private options: exec.ExecOptions | undefined = {},
private config: {
throwOnError?: boolean
throwOnEmptyOutput?: boolean
failOnError?: boolean
failOnEmptyOutput?: boolean
} = {}
) {
this.commandText = commandText
this.args = args
this.options = options
this.config.throwOnError = config.throwOnError ?? false
this.config.throwOnEmptyOutput = config.throwOnEmptyOutput ?? false
this.config.failOnError = config.failOnError ?? false
this.config.failOnEmptyOutput = config.failOnEmptyOutput ?? false
}
async execute(): Promise<exec.ExecOutput> {
try {
const output = await exec.getExecOutput(
this.commandText,
this.args,
this.options
)
if (this.config.throwOnError && output.stderr) {
this.onError(output.stderr).throw()
}
if (this.config.throwOnEmptyOutput && output.stdout.trim() === '') {
this.onError(`The command produced an empty output.`).throw()
}
if (this.config.failOnError && output.stderr) {
this.onError(output.stderr).fail()
}
if (this.config.failOnEmptyOutput && output.stdout.trim() === '') {
this.onError(`The command produced an empty output.`).fail()
}
return output
} catch (error) {
throw new Error((error as Error).message)
}
}
private onError(errorMessage: string): {
throw: () => never
fail: () => void
} {
return {
throw: () => {
throw new Error(errorMessage)
},
fail: () => {
core.setFailed(errorMessage)
}
}
}
}

View File

@ -1 +0,0 @@
export * from './command-runner'

View File

@ -1,12 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"outDir": "./lib",
"declaration": true,
"rootDir": "./src"
},
"include": [
"./src"
]
}