mirror of
https://github.com/actions/checkout.git
synced 2025-03-28 11:00:05 +01:00
Fix eslint script and related code
This commit is contained in:
parent
72f2cec99f
commit
ed3e1da142
12 changed files with 40 additions and 38 deletions
|
@ -21,7 +21,7 @@
|
|||
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
||||
"@typescript-eslint/no-array-constructor": "error",
|
||||
"@typescript-eslint/no-empty-interface": "error",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-extraneous-class": "error",
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
"@typescript-eslint/no-for-in-array": "error",
|
||||
|
@ -43,7 +43,9 @@
|
|||
"semi": "off",
|
||||
"@typescript-eslint/semi": ["error", "never"],
|
||||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
"@typescript-eslint/unbound-method": "error"
|
||||
"@typescript-eslint/unbound-method": "error",
|
||||
"i18n-text/no-en": "off",
|
||||
"github/no-then": "off"
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
|
|
26
dist/index.js
vendored
26
dist/index.js
vendored
|
@ -305,7 +305,7 @@ class GitAuthHelper {
|
|||
this.sshKeyPath = path.join(runnerTemp, uniqueId);
|
||||
stateHelper.setSshKeyPath(this.sshKeyPath);
|
||||
yield fs.promises.mkdir(runnerTemp, { recursive: true });
|
||||
yield fs.promises.writeFile(this.sshKeyPath, this.settings.sshKey.trim() + '\n', { mode: 0o600 });
|
||||
yield fs.promises.writeFile(this.sshKeyPath, `${this.settings.sshKey.trim()}\n`, { mode: 0o600 });
|
||||
// Remove inherited permissions on Windows
|
||||
if (IS_WINDOWS) {
|
||||
const icacls = yield io.which('icacls.exe');
|
||||
|
@ -371,7 +371,7 @@ class GitAuthHelper {
|
|||
let content = (yield fs.promises.readFile(configPath)).toString();
|
||||
const placeholderIndex = content.indexOf(this.tokenPlaceholderConfigValue);
|
||||
if (placeholderIndex < 0 ||
|
||||
placeholderIndex != content.lastIndexOf(this.tokenPlaceholderConfigValue)) {
|
||||
placeholderIndex !== content.lastIndexOf(this.tokenPlaceholderConfigValue)) {
|
||||
throw new Error(`Unable to replace auth placeholder in ${configPath}`);
|
||||
}
|
||||
assert.ok(this.tokenConfigValue, 'tokenConfigValue is not defined');
|
||||
|
@ -1326,7 +1326,7 @@ function getSource(settings) {
|
|||
yield authHelper.removeAuth();
|
||||
core.endGroup();
|
||||
}
|
||||
authHelper.removeGlobalConfig();
|
||||
yield authHelper.removeGlobalConfig();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1514,8 +1514,8 @@ const io = __importStar(__nccwpck_require__(7436));
|
|||
const path = __importStar(__nccwpck_require__(1017));
|
||||
const retryHelper = __importStar(__nccwpck_require__(2155));
|
||||
const toolCache = __importStar(__nccwpck_require__(7784));
|
||||
const v4_1 = __importDefault(__nccwpck_require__(824));
|
||||
const url_helper_1 = __nccwpck_require__(9437);
|
||||
const v4_1 = __importDefault(__nccwpck_require__(824));
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
function downloadRepository(authToken, owner, repo, ref, commit, repositoryPath, baseUrl) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
|
@ -1549,7 +1549,7 @@ function downloadRepository(authToken, owner, repo, ref, commit, repositoryPath,
|
|||
// Determine the path of the repository content. The archive contains
|
||||
// a top-level folder and the repository content is inside.
|
||||
const archiveFileNames = yield fs.promises.readdir(extractPath);
|
||||
assert.ok(archiveFileNames.length == 1, 'Expected exactly one directory inside archive');
|
||||
assert.ok(archiveFileNames.length === 1, 'Expected exactly one directory inside archive');
|
||||
const archiveVersion = archiveFileNames[0]; // The top-level folder name includes the short SHA
|
||||
core.info(`Resolved version ${archiveVersion}`);
|
||||
const tempRepositoryPath = path.join(extractPath, archiveVersion);
|
||||
|
@ -1617,8 +1617,8 @@ function downloadArchive(authToken, owner, repo, ref, commit, baseUrl) {
|
|||
? octokit.rest.repos.downloadZipballArchive
|
||||
: octokit.rest.repos.downloadTarballArchive;
|
||||
const response = yield download({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
owner,
|
||||
repo,
|
||||
ref: commit || ref
|
||||
});
|
||||
return Buffer.from(response.data); // response.data is ArrayBuffer
|
||||
|
@ -1753,11 +1753,11 @@ function getInputs() {
|
|||
result.submodules = false;
|
||||
result.nestedSubmodules = false;
|
||||
const submodulesString = (core.getInput('submodules') || '').toUpperCase();
|
||||
if (submodulesString == 'RECURSIVE') {
|
||||
if (submodulesString === 'RECURSIVE') {
|
||||
result.submodules = true;
|
||||
result.nestedSubmodules = true;
|
||||
}
|
||||
else if (submodulesString == 'TRUE') {
|
||||
else if (submodulesString === 'TRUE') {
|
||||
result.submodules = true;
|
||||
}
|
||||
core.debug(`submodules = ${result.submodules}`);
|
||||
|
@ -1862,11 +1862,11 @@ function cleanup() {
|
|||
}
|
||||
// Main
|
||||
if (!stateHelper.IsPost) {
|
||||
run();
|
||||
void run();
|
||||
}
|
||||
// Post
|
||||
else {
|
||||
cleanup();
|
||||
void cleanup();
|
||||
}
|
||||
|
||||
|
||||
|
@ -2096,7 +2096,7 @@ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref
|
|||
}
|
||||
// Expected message?
|
||||
const expectedMessage = `Merge ${expectedHeadSha} into ${expectedBaseSha}`;
|
||||
if (commitInfo.indexOf(expectedMessage) >= 0) {
|
||||
if (commitInfo.includes(expectedMessage)) {
|
||||
return;
|
||||
}
|
||||
// Extract details from message
|
||||
|
@ -2378,7 +2378,7 @@ function getFetchUrl(settings) {
|
|||
}
|
||||
exports.getFetchUrl = getFetchUrl;
|
||||
function getServerUrl(url) {
|
||||
let urlValue = url && url.trim().length > 0
|
||||
const urlValue = url && url.trim().length > 0
|
||||
? url
|
||||
: process.env['GITHUB_SERVER_URL'] || 'https://github.com';
|
||||
return new url_1.URL(urlValue);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"build": "tsc && ncc build && node lib/misc/generate-docs.js",
|
||||
"format": "prettier --write '**/*.ts'",
|
||||
"format-check": "prettier --check '**/*.ts'",
|
||||
"lint": "eslint src/**/*.ts",
|
||||
"lint": "eslint 'src/**/*.ts'",
|
||||
"test": "jest",
|
||||
"licensed-check": "src/misc/licensed-check.sh",
|
||||
"licensed-generate": "src/misc/licensed-generate.sh"
|
||||
|
|
|
@ -8,9 +8,9 @@ import * as path from 'path'
|
|||
import * as regexpHelper from './regexp-helper'
|
||||
import * as stateHelper from './state-helper'
|
||||
import * as urlHelper from './url-helper'
|
||||
import {default as uuid} from 'uuid/v4'
|
||||
import {IGitCommandManager} from './git-command-manager'
|
||||
import {IGitSourceSettings} from './git-source-settings'
|
||||
import {default as uuid} from 'uuid/v4'
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
const SSH_COMMAND_KEY = 'core.sshCommand'
|
||||
|
@ -215,7 +215,7 @@ class GitAuthHelper {
|
|||
await fs.promises.mkdir(runnerTemp, {recursive: true})
|
||||
await fs.promises.writeFile(
|
||||
this.sshKeyPath,
|
||||
this.settings.sshKey.trim() + '\n',
|
||||
`${this.settings.sshKey.trim()}\n`,
|
||||
{mode: 0o600}
|
||||
)
|
||||
|
||||
|
@ -306,7 +306,7 @@ class GitAuthHelper {
|
|||
const placeholderIndex = content.indexOf(this.tokenPlaceholderConfigValue)
|
||||
if (
|
||||
placeholderIndex < 0 ||
|
||||
placeholderIndex != content.lastIndexOf(this.tokenPlaceholderConfigValue)
|
||||
placeholderIndex !== content.lastIndexOf(this.tokenPlaceholderConfigValue)
|
||||
) {
|
||||
throw new Error(`Unable to replace auth placeholder in ${configPath}`)
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ class GitAuthHelper {
|
|||
|
||||
private async removeGitConfig(
|
||||
configKey: string,
|
||||
submoduleOnly: boolean = false
|
||||
submoduleOnly = false
|
||||
): Promise<void> {
|
||||
if (!submoduleOnly) {
|
||||
if (
|
||||
|
|
|
@ -266,7 +266,7 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
await authHelper.removeAuth()
|
||||
core.endGroup()
|
||||
}
|
||||
authHelper.removeGlobalConfig()
|
||||
await authHelper.removeGlobalConfig()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import * as io from '@actions/io'
|
|||
import * as path from 'path'
|
||||
import * as retryHelper from './retry-helper'
|
||||
import * as toolCache from '@actions/tool-cache'
|
||||
import {default as uuid} from 'uuid/v4'
|
||||
import {getServerApiUrl} from './url-helper'
|
||||
import {default as uuid} from 'uuid/v4'
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
|
@ -54,7 +54,7 @@ export async function downloadRepository(
|
|||
// a top-level folder and the repository content is inside.
|
||||
const archiveFileNames = await fs.promises.readdir(extractPath)
|
||||
assert.ok(
|
||||
archiveFileNames.length == 1,
|
||||
archiveFileNames.length === 1,
|
||||
'Expected exactly one directory inside archive'
|
||||
)
|
||||
const archiveVersion = archiveFileNames[0] // The top-level folder name includes the short SHA
|
||||
|
@ -135,8 +135,8 @@ async function downloadArchive(
|
|||
? octokit.rest.repos.downloadZipballArchive
|
||||
: octokit.rest.repos.downloadTarballArchive
|
||||
const response = await download({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
owner,
|
||||
repo,
|
||||
ref: commit || ref
|
||||
})
|
||||
return Buffer.from(response.data as ArrayBuffer) // response.data is ArrayBuffer
|
||||
|
|
|
@ -118,10 +118,10 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||
result.submodules = false
|
||||
result.nestedSubmodules = false
|
||||
const submodulesString = (core.getInput('submodules') || '').toUpperCase()
|
||||
if (submodulesString == 'RECURSIVE') {
|
||||
if (submodulesString === 'RECURSIVE') {
|
||||
result.submodules = true
|
||||
result.nestedSubmodules = true
|
||||
} else if (submodulesString == 'TRUE') {
|
||||
} else if (submodulesString === 'TRUE') {
|
||||
result.submodules = true
|
||||
}
|
||||
core.debug(`submodules = ${result.submodules}`)
|
||||
|
|
|
@ -38,9 +38,9 @@ async function cleanup(): Promise<void> {
|
|||
|
||||
// Main
|
||||
if (!stateHelper.IsPost) {
|
||||
run()
|
||||
void run()
|
||||
}
|
||||
// Post
|
||||
else {
|
||||
cleanup()
|
||||
void cleanup()
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {IGitCommandManager} from './git-command-manager'
|
||||
import * as core from '@actions/core'
|
||||
import * as github from '@actions/github'
|
||||
import {getServerApiUrl, isGhes} from './url-helper'
|
||||
import {IGitCommandManager} from './git-command-manager'
|
||||
|
||||
export const tagsRefSpec = '+refs/tags/*:refs/tags/*'
|
||||
|
||||
|
@ -227,7 +227,7 @@ export async function checkCommitInfo(
|
|||
|
||||
// Expected message?
|
||||
const expectedMessage = `Merge ${expectedHeadSha} into ${expectedBaseSha}`
|
||||
if (commitInfo.indexOf(expectedMessage) >= 0) {
|
||||
if (commitInfo.includes(expectedMessage)) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -28,28 +28,28 @@ export const SshKnownHostsPath = core.getState('sshKnownHostsPath')
|
|||
/**
|
||||
* Save the repository path so the POST action can retrieve the value.
|
||||
*/
|
||||
export function setRepositoryPath(repositoryPath: string) {
|
||||
export function setRepositoryPath(repositoryPath: string): void {
|
||||
core.saveState('repositoryPath', repositoryPath)
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the SSH key path so the POST action can retrieve the value.
|
||||
*/
|
||||
export function setSshKeyPath(sshKeyPath: string) {
|
||||
export function setSshKeyPath(sshKeyPath: string): void {
|
||||
core.saveState('sshKeyPath', sshKeyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the SSH known hosts path so the POST action can retrieve the value.
|
||||
*/
|
||||
export function setSshKnownHostsPath(sshKnownHostsPath: string) {
|
||||
export function setSshKnownHostsPath(sshKnownHostsPath: string): void {
|
||||
core.saveState('sshKnownHostsPath', sshKnownHostsPath)
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the set-safe-directory input so the POST action can retrieve the value.
|
||||
*/
|
||||
export function setSafeDirectory() {
|
||||
export function setSafeDirectory(): void {
|
||||
core.saveState('setSafeDirectory', 'true')
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as assert from 'assert'
|
||||
import {URL} from 'url'
|
||||
import {IGitSourceSettings} from './git-source-settings'
|
||||
import {URL} from 'url'
|
||||
|
||||
export function getFetchUrl(settings: IGitSourceSettings): string {
|
||||
assert.ok(
|
||||
|
@ -20,7 +20,7 @@ export function getFetchUrl(settings: IGitSourceSettings): string {
|
|||
}
|
||||
|
||||
export function getServerUrl(url?: string): URL {
|
||||
let urlValue =
|
||||
const urlValue =
|
||||
url && url.trim().length > 0
|
||||
? url
|
||||
: process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||
|
|
|
@ -20,7 +20,7 @@ export async function getOrganizationId(): Promise<number | undefined> {
|
|||
return
|
||||
}
|
||||
|
||||
return id as number
|
||||
return id
|
||||
} catch (err) {
|
||||
core.debug(
|
||||
`Unable to load organization ID from GITHUB_EVENT_PATH: ${(err as any)
|
||||
|
|
Loading…
Add table
Reference in a new issue