mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
* Bump typescript from 4.3.5 to 4.4.3 Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.5 to 4.4.3. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.3.5...v4.4.3) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * (fix): extract error message * (fix): error is unknown on __tests__ * (fix): add cover Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
21e2299d80
commit
460c7b8081
@ -80,7 +80,7 @@ describe('git', () => {
|
|||||||
try {
|
try {
|
||||||
await init(action)
|
await init(action)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).toBe(
|
expect(error instanceof Error && error.message).toBe(
|
||||||
'There was an error initializing the repository: Mocked throw ❌'
|
'There was an error initializing the repository: Mocked throw ❌'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -419,7 +419,7 @@ describe('git', () => {
|
|||||||
try {
|
try {
|
||||||
await deploy(action)
|
await deploy(action)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).toBe(
|
expect(error instanceof Error && error.message).toBe(
|
||||||
'The deploy step encountered an error: Mocked throw ❌'
|
'The deploy step encountered an error: Mocked throw ❌'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ describe('configureSSH', () => {
|
|||||||
try {
|
try {
|
||||||
await configureSSH(action)
|
await configureSSH(action)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).toBe(
|
expect(error instanceof Error && error.message).toBe(
|
||||||
'The ssh client configuration encountered an error: Mocked throw ❌'
|
'The ssh client configuration encountered an error: Mocked throw ❌'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,8 @@ import {
|
|||||||
generateFolderPath,
|
generateFolderPath,
|
||||||
suppressSensitiveInformation,
|
suppressSensitiveInformation,
|
||||||
checkParameters,
|
checkParameters,
|
||||||
stripProtocolFromUrl
|
stripProtocolFromUrl,
|
||||||
|
extractErrorMessage
|
||||||
} from '../src/util'
|
} from '../src/util'
|
||||||
|
|
||||||
describe('util', () => {
|
describe('util', () => {
|
||||||
@ -222,7 +223,7 @@ describe('util', () => {
|
|||||||
try {
|
try {
|
||||||
checkParameters(action)
|
checkParameters(action)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.message).toMatch(
|
expect(e instanceof Error && e.message).toMatch(
|
||||||
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'
|
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -242,7 +243,7 @@ describe('util', () => {
|
|||||||
try {
|
try {
|
||||||
checkParameters(action)
|
checkParameters(action)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.message).toMatch(
|
expect(e instanceof Error && e.message).toMatch(
|
||||||
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'
|
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -262,7 +263,7 @@ describe('util', () => {
|
|||||||
try {
|
try {
|
||||||
checkParameters(action)
|
checkParameters(action)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.message).toMatch('Branch is required.')
|
expect(e instanceof Error && e.message).toMatch('Branch is required.')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -280,7 +281,7 @@ describe('util', () => {
|
|||||||
try {
|
try {
|
||||||
checkParameters(action)
|
checkParameters(action)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.message).toMatch(
|
expect(e instanceof Error && e.message).toMatch(
|
||||||
'You must provide the action with a folder to deploy.'
|
'You must provide the action with a folder to deploy.'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -301,7 +302,7 @@ describe('util', () => {
|
|||||||
action.folderPath = generateFolderPath(action)
|
action.folderPath = generateFolderPath(action)
|
||||||
checkParameters(action)
|
checkParameters(action)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.message).toMatch(
|
expect(e instanceof Error && e.message).toMatch(
|
||||||
`The directory you're trying to deploy named notARealFolder doesn't exist. Please double check the path and any prerequisite build scripts and try again. ❗`
|
`The directory you're trying to deploy named notARealFolder doesn't exist. Please double check the path and any prerequisite build scripts and try again. ❗`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -327,4 +328,22 @@ describe('util', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('extractErrorMessage', () => {
|
||||||
|
it('gets the message of a Error', () => {
|
||||||
|
expect(extractErrorMessage(new Error('a error message'))).toBe(
|
||||||
|
'a error message'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('gets the message of a string', () => {
|
||||||
|
expect(extractErrorMessage('a error message')).toBe('a error message')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('gets the message of a object', () => {
|
||||||
|
expect(extractErrorMessage({special: 'a error message'})).toBe(
|
||||||
|
`{"special":"a error message"}`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -28,7 +28,7 @@ describe('generateWorktree', () => {
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).toBe(
|
expect(error instanceof Error && error.message).toBe(
|
||||||
'There was an error creating the worktree: Mocked throw ❌'
|
'There was an error creating the worktree: Mocked throw ❌'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,6 @@
|
|||||||
"prettier": "2.4.1",
|
"prettier": "2.4.1",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"ts-jest": "26.5.6",
|
"ts-jest": "26.5.6",
|
||||||
"typescript": "4.3.5"
|
"typescript": "4.4.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
src/git.ts
10
src/git.ts
@ -4,7 +4,11 @@ import fs from 'fs'
|
|||||||
import {ActionInterface, Status, TestFlag} from './constants'
|
import {ActionInterface, Status, TestFlag} from './constants'
|
||||||
import {execute} from './execute'
|
import {execute} from './execute'
|
||||||
import {generateWorktree} from './worktree'
|
import {generateWorktree} from './worktree'
|
||||||
import {isNullOrUndefined, suppressSensitiveInformation} from './util'
|
import {
|
||||||
|
extractErrorMessage,
|
||||||
|
isNullOrUndefined,
|
||||||
|
suppressSensitiveInformation
|
||||||
|
} from './util'
|
||||||
|
|
||||||
/* Initializes git in the workspace. */
|
/* Initializes git in the workspace. */
|
||||||
export async function init(action: ActionInterface): Promise<void | Error> {
|
export async function init(action: ActionInterface): Promise<void | Error> {
|
||||||
@ -63,7 +67,7 @@ export async function init(action: ActionInterface): Promise<void | Error> {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`There was an error initializing the repository: ${suppressSensitiveInformation(
|
`There was an error initializing the repository: ${suppressSensitiveInformation(
|
||||||
error.message,
|
extractErrorMessage(error),
|
||||||
action
|
action
|
||||||
)} ❌`
|
)} ❌`
|
||||||
)
|
)
|
||||||
@ -208,7 +212,7 @@ export async function deploy(action: ActionInterface): Promise<Status> {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`The deploy step encountered an error: ${suppressSensitiveInformation(
|
`The deploy step encountered an error: ${suppressSensitiveInformation(
|
||||||
error.message,
|
extractErrorMessage(error),
|
||||||
action
|
action
|
||||||
)} ❌`
|
)} ❌`
|
||||||
)
|
)
|
||||||
|
@ -4,6 +4,7 @@ import {deploy, init} from './git'
|
|||||||
import {configureSSH} from './ssh'
|
import {configureSSH} from './ssh'
|
||||||
import {
|
import {
|
||||||
checkParameters,
|
checkParameters,
|
||||||
|
extractErrorMessage,
|
||||||
generateFolderPath,
|
generateFolderPath,
|
||||||
generateRepositoryPath,
|
generateRepositoryPath,
|
||||||
generateTokenType
|
generateTokenType
|
||||||
@ -52,7 +53,7 @@ export default async function run(
|
|||||||
status = await deploy(settings)
|
status = await deploy(settings)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
status = Status.FAILED
|
status = Status.FAILED
|
||||||
setFailed(error.message)
|
setFailed(extractErrorMessage(error))
|
||||||
} finally {
|
} finally {
|
||||||
info(
|
info(
|
||||||
`${
|
`${
|
||||||
|
@ -3,7 +3,7 @@ import {mkdirP} from '@actions/io'
|
|||||||
import {execFileSync, execSync} from 'child_process'
|
import {execFileSync, execSync} from 'child_process'
|
||||||
import {appendFileSync} from 'fs'
|
import {appendFileSync} from 'fs'
|
||||||
import {ActionInterface} from './constants'
|
import {ActionInterface} from './constants'
|
||||||
import {suppressSensitiveInformation} from './util'
|
import {extractErrorMessage, suppressSensitiveInformation} from './util'
|
||||||
|
|
||||||
export async function configureSSH(action: ActionInterface): Promise<void> {
|
export async function configureSSH(action: ActionInterface): Promise<void> {
|
||||||
try {
|
try {
|
||||||
@ -46,7 +46,7 @@ export async function configureSSH(action: ActionInterface): Promise<void> {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`The ssh client configuration encountered an error: ${suppressSensitiveInformation(
|
`The ssh client configuration encountered an error: ${suppressSensitiveInformation(
|
||||||
error.message,
|
extractErrorMessage(error),
|
||||||
action
|
action
|
||||||
)} ❌`
|
)} ❌`
|
||||||
)
|
)
|
||||||
|
@ -90,6 +90,13 @@ export const suppressSensitiveInformation = (
|
|||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const extractErrorMessage = (error: unknown): string =>
|
||||||
|
error instanceof Error
|
||||||
|
? error.message
|
||||||
|
: typeof error == 'string'
|
||||||
|
? error
|
||||||
|
: JSON.stringify(error)
|
||||||
|
|
||||||
/** Strips the protocol from a provided URL. */
|
/** Strips the protocol from a provided URL. */
|
||||||
export const stripProtocolFromUrl = (url: string): string =>
|
export const stripProtocolFromUrl = (url: string): string =>
|
||||||
url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '').split('/')[0]
|
url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '').split('/')[0]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {info} from '@actions/core'
|
import {info} from '@actions/core'
|
||||||
import {ActionInterface} from './constants'
|
import {ActionInterface} from './constants'
|
||||||
import {execute} from './execute'
|
import {execute} from './execute'
|
||||||
import {suppressSensitiveInformation} from './util'
|
import {extractErrorMessage, suppressSensitiveInformation} from './util'
|
||||||
|
|
||||||
export class GitCheckout {
|
export class GitCheckout {
|
||||||
orphan = false
|
orphan = false
|
||||||
@ -77,7 +77,7 @@ export async function generateWorktree(
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`There was an error creating the worktree: ${suppressSensitiveInformation(
|
`There was an error creating the worktree: ${suppressSensitiveInformation(
|
||||||
error.message,
|
extractErrorMessage(error),
|
||||||
action
|
action
|
||||||
)} ❌`
|
)} ❌`
|
||||||
)
|
)
|
||||||
|
@ -4538,10 +4538,10 @@ typedarray-to-buffer@^3.1.5:
|
|||||||
dependencies:
|
dependencies:
|
||||||
is-typedarray "^1.0.0"
|
is-typedarray "^1.0.0"
|
||||||
|
|
||||||
typescript@4.3.5:
|
typescript@4.4.3:
|
||||||
version "4.3.5"
|
version "4.4.3"
|
||||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.3.tgz#bdc5407caa2b109efd4f82fe130656f977a29324"
|
||||||
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==
|
integrity sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==
|
||||||
|
|
||||||
union-value@^1.0.0:
|
union-value@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
|
Loading…
Reference in New Issue
Block a user