mirror of https://github.com/aminya/setup-cpp
Merge pull request #116 from aminya/is-url-online [skip ci]
This commit is contained in:
commit
58016a1d28
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
|
@ -61,7 +61,7 @@
|
|||
"exec-powershell": "workspace:*",
|
||||
"execa": "^5.1.1",
|
||||
"extension-tools": "workspace:*",
|
||||
"get-works": "workspace:*",
|
||||
"is-url-online": "^1.5.0",
|
||||
"mri": "^1.2.0",
|
||||
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
|
||||
"numerous": "1.0.3",
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
<h1 align="center">get-works</h1>
|
||||
<p>
|
||||
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
|
||||
<a href="#" target="_blank">
|
||||
<img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
> Check if the GET request for the given URL works
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save get-works
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
<!-- INSERT GENERATED DOCS START -->
|
||||
|
||||
### `getWorks` (function)
|
||||
|
||||
Check if the GET request for the given URL works
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- url (`string`) - The given URL
|
||||
|
||||
**returns:** Promise<boolean>
|
||||
|
||||
<!-- INSERT GENERATED DOCS END -->
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
You can sponsor my work here:
|
||||
|
||||
https://github.com/sponsors/aminya
|
||||
|
||||
Pull requests, issues and feature requests are welcome.
|
||||
See the [Contributing guide](https://github.com/aminya/setup-cpp/blob/master/CONTRIBUTING.md).
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"name": "get-works",
|
||||
"version": "1.0.0",
|
||||
"description": "Check if the GET request for the given URL works",
|
||||
"homepage": "https://github.com/aminya/setup-cpp",
|
||||
"license": "Apache-2.0",
|
||||
"author": "Amin Yahyaabadi",
|
||||
"main": "./dist/index.js",
|
||||
"source": "./src/index.ts",
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"root-tools": "workspace:*"
|
||||
},
|
||||
"keywords": [
|
||||
"url",
|
||||
"link",
|
||||
"uri",
|
||||
"working",
|
||||
"check",
|
||||
"alive",
|
||||
"ok",
|
||||
"broken"
|
||||
]
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
import * as https from "https"
|
||||
|
||||
/**
|
||||
* Check if the GET request for the given URL works
|
||||
*
|
||||
* @param url The given URL
|
||||
* @returns A promise that resolves to a boolean indicating if the URL works
|
||||
*/
|
||||
export function getWorks(url: string): Promise<boolean> {
|
||||
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,7 +0,0 @@
|
|||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"include": ["./src"]
|
||||
}
|
|
@ -35,7 +35,7 @@ importers:
|
|||
execa: ^5.1.1
|
||||
extension-tools: workspace:*
|
||||
gen-readme: ^1.6.0
|
||||
get-works: workspace:*
|
||||
is-url-online: ^1.5.0
|
||||
jest: ^28.1.3
|
||||
loose-ts-check: ^1.2.0
|
||||
mri: ^1.2.0
|
||||
|
@ -71,7 +71,7 @@ importers:
|
|||
exec-powershell: link:packages/exec-powershell
|
||||
execa: 5.1.1
|
||||
extension-tools: link:packages/extension-tools
|
||||
get-works: link:packages/get-works
|
||||
is-url-online: 1.5.0
|
||||
mri: 1.2.0
|
||||
msvc-dev-cmd: github.com/aminya/msvc-dev-cmd/9f672c1
|
||||
numerous: 1.0.3
|
||||
|
@ -133,12 +133,6 @@ importers:
|
|||
packages/extension-tools:
|
||||
specifiers: {}
|
||||
|
||||
packages/get-works:
|
||||
specifiers:
|
||||
root-tools: workspace:*
|
||||
dependencies:
|
||||
root-tools: link:../root-tools
|
||||
|
||||
packages/root-tools:
|
||||
specifiers:
|
||||
'@types/which': ^2.0.1
|
||||
|
@ -5766,6 +5760,10 @@ packages:
|
|||
resolution: {integrity: sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==}
|
||||
dev: true
|
||||
|
||||
/is-url-online/1.5.0:
|
||||
resolution: {integrity: sha512-uN7eZhWzxuiJs0OeMIzzMcU5OqUrS0OBoLrorPi3gExjsIO1zkaT5kXfsSbai7FmPzLNg2j8NdbJqgr5l8S2xw==}
|
||||
dev: false
|
||||
|
||||
/is-url/1.2.4:
|
||||
resolution: {integrity: sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==}
|
||||
dev: true
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { setupLLVM, VERSIONS, getUrl, setupClangTools, getLinuxUrl } from "../llvm"
|
||||
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
|
||||
import { getWorks } from "get-works"
|
||||
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 getWorks(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 { getWorks } from "get-works"
|
||||
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 getWorks(url))) {
|
||||
if (!(await isUrlOnline(url))) {
|
||||
fallback = true // fallback to github
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { getWorks } from "get-works"
|
||||
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 getWorks(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 getWorks(url))) {
|
||||
if (url !== null && (await isUrlOnline(url))) {
|
||||
return [specificVersion, url]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue