mirror of https://github.com/aminya/setup-cpp
fix: use is-url-online to validate the download links
This commit is contained in:
parent
b38bf66f56
commit
232af3c141
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -60,6 +60,7 @@
|
|||
"exec-powershell": "workspace:*",
|
||||
"execa": "^5.1.1",
|
||||
"extension-tools": "workspace:*",
|
||||
"is-url-online": "^1.4.0",
|
||||
"mri": "^1.2.0",
|
||||
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
|
||||
"numerous": "1.0.3",
|
||||
|
|
|
@ -34,6 +34,7 @@ importers:
|
|||
execa: ^5.1.1
|
||||
extension-tools: workspace:*
|
||||
gen-readme: ^1.6.0
|
||||
is-url-online: ^1.4.0
|
||||
jest: ^28.1.3
|
||||
loose-ts-check: ^1.2.0
|
||||
mri: ^1.2.0
|
||||
|
@ -68,6 +69,7 @@ importers:
|
|||
exec-powershell: link:packages/exec-powershell
|
||||
execa: 5.1.1
|
||||
extension-tools: link:packages/extension-tools
|
||||
is-url-online: 1.4.0
|
||||
mri: 1.2.0
|
||||
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
|
||||
numerous: 1.0.3
|
||||
|
@ -3899,6 +3901,10 @@ packages:
|
|||
engines: {node: '>=6'}
|
||||
dev: true
|
||||
|
||||
/destr/1.1.1:
|
||||
resolution: {integrity: sha512-QqkneF8LrYmwATMdnuD2MLI3GHQIcBnG6qFC2q9bSH430VTCDAVjcspPmUaKhPGtAtPAftIUFqY1obQYQuwmbg==}
|
||||
dev: false
|
||||
|
||||
/detect-indent/6.1.0:
|
||||
resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==}
|
||||
engines: {node: '>=8'}
|
||||
|
@ -5748,6 +5754,12 @@ packages:
|
|||
resolution: {integrity: sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==}
|
||||
dev: true
|
||||
|
||||
/is-url-online/1.4.0:
|
||||
resolution: {integrity: sha512-p61eygpIlCshn3f4yOYwng4EkuQ+EAi5/B27p8Qp1BKkqfQMohnpMEx6LX8MG7QKHRppDQt5drwlqMOrRt5eBA==}
|
||||
dependencies:
|
||||
ohmyfetch: 0.4.18
|
||||
dev: false
|
||||
|
||||
/is-url/1.2.4:
|
||||
resolution: {integrity: sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==}
|
||||
dev: true
|
||||
|
@ -7060,6 +7072,10 @@ packages:
|
|||
resolution: {integrity: sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==}
|
||||
dev: true
|
||||
|
||||
/node-fetch-native/0.1.4:
|
||||
resolution: {integrity: sha512-10EKpOCQPXwZVFh3U1ptOMWBgKTbsN7Vvo6WVKt5pw4hp8zbv6ZVBZPlXw+5M6Tyi1oc1iD4/sNPd71KYA16tQ==}
|
||||
dev: false
|
||||
|
||||
/node-fetch/2.6.7:
|
||||
resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==}
|
||||
engines: {node: 4.x || >=6.0.0}
|
||||
|
@ -7354,6 +7370,15 @@ packages:
|
|||
es-abstract: 1.20.1
|
||||
dev: true
|
||||
|
||||
/ohmyfetch/0.4.18:
|
||||
resolution: {integrity: sha512-MslzNrQzBLtZHmiZBI8QMOcMpdNFlK61OJ34nFNFynZ4v+4BonfCQ7VIN4EGXvGGq5zhDzgdJoY3o9S1l2T7KQ==}
|
||||
dependencies:
|
||||
destr: 1.1.1
|
||||
node-fetch-native: 0.1.4
|
||||
ufo: 0.8.5
|
||||
undici: 5.8.1
|
||||
dev: false
|
||||
|
||||
/once/1.4.0:
|
||||
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
|
||||
dependencies:
|
||||
|
@ -8916,6 +8941,10 @@ packages:
|
|||
resolution: {integrity: sha512-/IZMqVoMJ0Wl+vRJBlsIhbkpFlXnO9GdOk6zAiy0s4CyDJqpB/qp5T/ah4eoH1OL7ctNJN65nITtRIcbPCoU/w==}
|
||||
dev: false
|
||||
|
||||
/ufo/0.8.5:
|
||||
resolution: {integrity: sha512-e4+UtA5IRO+ha6hYklwj6r7BjiGMxS0O+UaSg9HbaTefg4kMkzj4tXzEBajRR+wkxf+golgAWKzLbytCUDMJAA==}
|
||||
dev: false
|
||||
|
||||
/uglify-js/3.16.3:
|
||||
resolution: {integrity: sha512-uVbFqx9vvLhQg0iBaau9Z75AxWJ8tqM9AV890dIZCLApF4rTcyHwmAvLeEdYRs+BzYWu8Iw81F79ah0EfTXbaw==}
|
||||
engines: {node: '>=0.8.0'}
|
||||
|
@ -8933,6 +8962,11 @@ packages:
|
|||
which-boxed-primitive: 1.0.2
|
||||
dev: true
|
||||
|
||||
/undici/5.8.1:
|
||||
resolution: {integrity: sha512-iDRmWX4Zar/4A/t+1LrKQRm102zw2l9Wgat3LtTlTn8ykvMZmAmpq9tjyHEigx18FsY7IfATvyN3xSw9BDz0eA==}
|
||||
engines: {node: '>=12.18'}
|
||||
dev: false
|
||||
|
||||
/unique-filename/1.1.1:
|
||||
resolution: {integrity: sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ==}
|
||||
dependencies:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { setupLLVM, VERSIONS, getUrl, setupClangTools, getLinuxUrl } from "../llvm"
|
||||
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
|
||||
import { isValidUrl } from "../../utils/http/validate_url"
|
||||
import { isUrlOnline } from "is-url-online"
|
||||
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||
import ciDetect from "@npmcli/ci-detect"
|
||||
import execa from "execa"
|
||||
|
@ -14,7 +14,7 @@ jest.setTimeout(400000)
|
|||
async function testUrl(version: string) {
|
||||
const [specificVersion, url] = await getSpecificVersionAndUrl(VERSIONS, process.platform, version, getUrl)
|
||||
|
||||
if (!(await isValidUrl(url))) {
|
||||
if (!(await isUrlOnline(url))) {
|
||||
throw new Error(`Failed to install Version: ${version} => ${specificVersion} \n URL: ${url}`)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as path from "path"
|
||||
import semverLte from "semver/functions/lte"
|
||||
import semverMajor from "semver/functions/major"
|
||||
import { isValidUrl } from "../utils/http/validate_url"
|
||||
import { isUrlOnline } from "is-url-online"
|
||||
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
|
||||
import { extractExe, extractTarByExe } from "../utils/setup/extract"
|
||||
import {
|
||||
|
@ -231,7 +231,7 @@ async function getWin32Url(version: string): Promise<string | null> {
|
|||
let fallback = false
|
||||
if (olderThan9_1) {
|
||||
url = getReleaseUrl(version, prefix, suffix)
|
||||
if (!(await isValidUrl(url))) {
|
||||
if (!(await isUrlOnline(url))) {
|
||||
fallback = true // fallback to github
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
import * as https from "https"
|
||||
|
||||
export function isValidUrl(url: string) {
|
||||
return new Promise<boolean>((resolve) => {
|
||||
https.get(url, (res) => {
|
||||
if (res.statusCode !== undefined && res.statusCode >= 200 && res.statusCode <= 399) {
|
||||
resolve(true)
|
||||
} else {
|
||||
resolve(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import { isValidUrl } from "../http/validate_url"
|
||||
import { isUrlOnline } from "is-url-online"
|
||||
import semverCompare from "semver/functions/compare"
|
||||
import semverCoerce from "semver/functions/coerce"
|
||||
import semverValid from "semver/functions/valid"
|
||||
|
@ -42,7 +42,7 @@ export async function getSpecificVersionAndUrl(
|
|||
if (platform === "linux" && version.includes("ubuntu")) {
|
||||
const url = await getUrl(platform, version)
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
if (url !== null && (await isValidUrl(url))) {
|
||||
if (url !== null && (await isUrlOnline(url))) {
|
||||
return [version, url]
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ export async function getSpecificVersionAndUrl(
|
|||
// eslint-disable-next-line no-await-in-loop
|
||||
const url = await getUrl(platform, specificVersion)
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
if (url !== null && (await isValidUrl(url))) {
|
||||
if (url !== null && (await isUrlOnline(url))) {
|
||||
return [specificVersion, url]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue