Merge pull request #52 from eskatos/dd/update-versions

Update dependency versions
This commit is contained in:
Paul Merlin 2021-07-06 11:47:55 +02:00 committed by GitHub
commit 13d33a88ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 792 additions and 877 deletions

2
dist/main/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/post/index.js vendored

File diff suppressed because one or more lines are too long

1537
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -24,30 +24,28 @@
"author": "Paul Merlin <paul@nosphere.org>", "author": "Paul Merlin <paul@nosphere.org>",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "1.0.5", "@actions/cache": "1.0.7",
"@actions/core": "1.2.6", "@actions/core": "1.4.0",
"@actions/exec": "1.0.4", "@actions/exec": "1.1.0",
"@actions/glob": "0.1.1", "@actions/glob": "0.2.0",
"@actions/http-client": "1.0.9", "@actions/http-client": "1.0.11",
"@actions/io": "1.0.2", "@actions/tool-cache": "1.7.1",
"@actions/tool-cache": "1.6.1", "string-argv": "0.3.1"
"string-argv": "0.3.1",
"unzipper": "0.10.11"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "26.0.19", "@types/jest": "26.0.23",
"@types/node": "12.12.6", "@types/node": "14.17.3",
"@types/unzipper": "0.10.3", "@types/unzipper": "0.10.4",
"@typescript-eslint/parser": "4.11.0", "@typescript-eslint/parser": "4.28.2",
"@zeit/ncc": "0.22.3", "@zeit/ncc": "0.22.3",
"eslint": "7.16.0", "eslint": "7.30.0",
"eslint-plugin-github": "4.1.1", "eslint-plugin-github": "4.1.3",
"eslint-plugin-jest": "24.1.3", "eslint-plugin-jest": "24.3.6",
"jest": "26.6.3", "jest": "26.6.3",
"jest-circus": "26.6.3", "jest-circus": "26.6.3",
"js-yaml": "3.14.1", "js-yaml": "3.14.1",
"prettier": "2.2.1", "prettier": "2.3.2",
"ts-jest": "26.4.4", "ts-jest": "26.5.6",
"typescript": "4.0.2" "typescript": "4.3.5"
} }
} }

View file

@ -1,44 +1,13 @@
import * as crypto from 'crypto'
import * as fs from 'fs'
import * as path from 'path' import * as path from 'path'
import * as stream from 'stream'
import * as util from 'util'
import * as glob from '@actions/glob' import * as glob from '@actions/glob'
export async function hashFiles( export async function hashFiles(
baseDir: string, baseDir: string,
globs: string[] = ['**'], patterns: string[] = ['**'],
followSymbolicLinks = false followSymbolicLinks = false
): Promise<string | null> { ): Promise<string | null> {
let hasMatch = false const combinedPatterns = patterns
type FileHashes = Record<string, Buffer> .map(pattern => `${baseDir}${path.sep}${pattern}`)
const hashes: FileHashes = {} .join('\n')
for await (const globPattern of globs) { return glob.hashFiles(combinedPatterns, {followSymbolicLinks})
const globMatch = `${baseDir}${path.sep}${globPattern}`
const globber = await glob.create(globMatch, {followSymbolicLinks})
for await (const file of globber.globGenerator()) {
// console.log(file)
if (!file.startsWith(`${baseDir}${path.sep}`)) {
// console.log(`Ignore '${file}' since it is not under '${baseDir}'.`)
continue
}
if (fs.statSync(file).isDirectory()) {
// console.log(`Skip directory '${file}'.`)
continue
}
const hash = crypto.createHash('sha256')
const pipeline = util.promisify(stream.pipeline)
await pipeline(fs.createReadStream(file), hash)
hashes[path.relative(baseDir, file)] = hash.digest()
hasMatch = true
}
}
if (!hasMatch) return null
const result = crypto.createHash('sha256')
for (const file of Object.keys(hashes).sort()) {
result.update(hashes[file])
}
result.end()
return result.digest('hex')
} }

View file

@ -2,14 +2,11 @@ import * as fs from 'fs'
import * as os from 'os' import * as os from 'os'
import * as path from 'path' import * as path from 'path'
import * as httpm from '@actions/http-client' import * as httpm from '@actions/http-client'
import * as unzip from 'unzipper'
import * as core from '@actions/core' import * as core from '@actions/core'
import * as io from '@actions/io'
import * as toolCache from '@actions/tool-cache' import * as toolCache from '@actions/tool-cache'
import * as gradlew from './gradlew' import * as gradlew from './gradlew'
const httpc = new httpm.HttpClient('eskatos/gradle-command-action')
const gradleVersionsBaseUrl = 'https://services.gradle.org/versions' const gradleVersionsBaseUrl = 'https://services.gradle.org/versions'
/** /**
@ -95,22 +92,21 @@ async function provisionGradle(version: string, url: string): Promise<string> {
return cachedExecutable return cachedExecutable
} }
const home = os.homedir() const tmpdir = path.join(os.homedir(), 'gradle-provision-tmpdir')
const tmpdir = path.join(home, 'gradle-provision-tmpdir')
const downloadsDir = path.join(tmpdir, 'downloads')
const installsDir = path.join(tmpdir, 'installs')
await io.mkdirP(downloadsDir)
await io.mkdirP(installsDir)
core.info(`Downloading ${url}`) core.info(`Downloading ${url}`)
const downloadPath = path.join(downloadsDir, `gradle-${version}-bin.zip`) const downloadPath = path.join(
await httpDownload(url, downloadPath) tmpdir,
`downloads/gradle-${version}-bin.zip`
)
await toolCache.downloadTool(url, downloadPath)
core.info( core.info(
`Downloaded at ${downloadPath}, size ${fs.statSync(downloadPath).size}` `Downloaded at ${downloadPath}, size ${fs.statSync(downloadPath).size}`
) )
await extractZip(downloadPath, installsDir) const installsDir = path.join(tmpdir, 'installs')
await toolCache.extractZip(downloadPath, installsDir)
const installDir = path.join(installsDir, `gradle-${version}`) const installDir = path.join(installsDir, `gradle-${version}`)
core.info(`Extracted in ${installDir}`) core.info(`Extracted in ${installDir}`)
@ -138,38 +134,11 @@ async function httpGetGradleVersions(
} }
async function httpGetString(url: string): Promise<string> { async function httpGetString(url: string): Promise<string> {
const response = await httpc.get(url) const httpClient = new httpm.HttpClient('eskatos/gradle-command-action')
const response = await httpClient.get(url)
return response.readBody() return response.readBody()
} }
async function httpDownload(url: string, localPath: string): Promise<void> {
const response = await httpc.get(url)
return new Promise<void>(function (resolve, reject) {
const writeStream = fs.createWriteStream(localPath)
response.message
.pipe(writeStream)
.on('close', () => {
resolve()
})
.on('error', err => {
reject(err)
})
})
}
async function extractZip(zip: string, destination: string): Promise<void> {
return new Promise<void>(function (resolve, reject) {
fs.createReadStream(zip)
.pipe(unzip.Extract({path: destination}))
.on('close', () => {
resolve()
})
.on('error', err => {
reject(err)
})
})
}
interface GradleVersionInfo { interface GradleVersionInfo {
version: string version: string
downloadUrl: string downloadUrl: string