Delete src directory

This commit is contained in:
removedporn 2021-09-16 23:30:50 +08:00 committed by GitHub
parent 877e3e0632
commit d23f55b619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 173 deletions

View File

@ -1,77 +0,0 @@
const os = require("os");
const path = require("path");
const process = require("process");
const core = require("@actions/core");
const tc = require("@actions/tool-cache");
/**
* @param {import("./version").Version} version
*/
async function install(version) {
const cachedPath = tc.find(
"deno",
version.isCanary ? `0.0.0-${version.version}` : version.version,
);
if (cachedPath) {
core.info(`Using cached Deno installation from ${cachedPath}.`);
core.addPath(cachedPath);
return;
}
const zip = zipName();
const url = version.isCanary
? `https://dl.deno.land/canary/${version.version}/${zip}`
: `https://github.com/denoland/deno/releases/download/v${version.version}/${zip}`;
core.info(`Downloading Deno from ${url}.`);
const zipPath = await tc.downloadTool(url);
const extractedFolder = await tc.extractZip(zipPath);
const newCachedPath = await tc.cacheDir(
extractedFolder,
"deno",
version.isCanary ? `0.0.0-${version.version}` : version.version,
);
core.info(`Cached Deno to ${newCachedPath}.`);
core.addPath(newCachedPath);
const denoInstallRoot = process.env.DENO_INSTALL_ROOT ||
path.join(os.homedir(), ".deno", "bin");
core.addPath(denoInstallRoot);
}
/** @returns {string} */
function zipName() {
let arch;
switch (process.arch) {
case "arm64":
arch = "aarch64";
break;
case "x64":
arch = "x86_64";
break;
default:
throw new Error(`Unsupported architechture ${process.arch}.`);
}
let platform;
switch (process.platform) {
case "linux":
platform = "unknown-linux-gnu";
break;
case "darwin":
platform = "apple-darwin";
break;
case "win32":
platform = "pc-windows-msvc";
break;
default:
throw new Error(`Unsupported platform ${process.platform}.`);
}
return `deno-${arch}-${platform}.zip`;
}
module.exports = {
install,
};

View File

@ -1,96 +0,0 @@
const semver = require("semver");
const fetch = require("node-fetch");
const GIT_HASH_RE = /^[0-9a-fA-F]{40}$/;
/**
* @typedef VersionRange
* @property {string} range
* @property {boolean} isCanary
*/
/**
* @typedef Version
* @property {string} version
* @property {boolean} isCanary
*/
/**
* Parses the version from the user into a structure.
*
* @param {string | undefined} version
* @returns {VersionRange | null}
*/
function parseVersionRange(version) {
version = String(version) || "1.x";
version = version.trim();
if (version == "canary") {
return { range: "latest", isCanary: true };
}
if (GIT_HASH_RE.test(version)) {
return { range: version, isCanary: true };
}
const range = semver.validRange(version);
if (range !== null) {
return { range, isCanary: false };
}
return null;
}
/**
* @param {VersionRange} range
* @returns {Promise<Version | null>}
*/
async function resolveVersion({ range, isCanary }) {
if (isCanary) {
if (range === "latest") {
const res = await fetch("https://dl.deno.land/canary-latest.txt");
if (res.status !== 200) {
throw new Error(
"Failed to fetch canary version info from dl.deno.land. Please try again later.",
);
}
const version = (await res.text()).trim();
return { version, isCanary: true };
}
return { version: range, isCanary: true };
}
const res = await fetch(
"https://raw.githubusercontent.com/denoland/deno_website2/main/versions.json",
);
if (res.status !== 200) {
throw new Error(
"Failed to fetch stable version info from raw.githubusercontent.com. Please try again later.",
);
}
const versionJson = await res.json();
if (!("cli" in versionJson)) {
throw new Error("Fetched stable version info is invalid.");
}
/** @type {string[]} */
const versions = versionJson.cli;
if (!Array.isArray(versions)) {
throw new Error("Fetched stable version info is invalid.");
}
let version = semver.maxSatisfying(versions, range);
if (version === null) {
return null;
}
version = semver.clean(version);
if (version === null) {
return null;
}
return { version, isCanary: false };
}
module.exports = {
parseVersionRange,
resolveVersion,
};