download and extract actually just for downloading and extracting
This commit is contained in:
parent
c6cf564842
commit
1785916d32
@ -314,8 +314,7 @@ export async function generateResourcesForMainTheme(params: {
|
||||
}
|
||||
|
||||
const { extractedDirPath } = await downloadAndExtractArchive({
|
||||
urlOrPath:
|
||||
"https://repo1.maven.org/maven2/org/keycloak/keycloak-account-ui/25.0.1/keycloak-account-ui-25.0.1.jar",
|
||||
url: "https://repo1.maven.org/maven2/org/keycloak/keycloak-account-ui/25.0.1/keycloak-account-ui-25.0.1.jar",
|
||||
cacheDirPath: buildContext.cacheDirPath,
|
||||
fetchOptions: buildContext.fetchOptions,
|
||||
uniqueIdOfOnArchiveFile: "bring_in_account_v3_i18n_messages",
|
||||
|
@ -21,7 +21,7 @@ export async function downloadKeycloakDefaultTheme(params: {
|
||||
let kcNodeModulesKeepFilePaths_lastAccountV1: Set<string> | undefined = undefined;
|
||||
|
||||
const { extractedDirPath } = await downloadAndExtractArchive({
|
||||
urlOrPath: `https://repo1.maven.org/maven2/org/keycloak/keycloak-themes/${keycloakVersion}/keycloak-themes-${keycloakVersion}.jar`,
|
||||
url: `https://repo1.maven.org/maven2/org/keycloak/keycloak-themes/${keycloakVersion}/keycloak-themes-${keycloakVersion}.jar`,
|
||||
cacheDirPath: buildContext.cacheDirPath,
|
||||
fetchOptions: buildContext.fetchOptions,
|
||||
uniqueIdOfOnArchiveFile: "downloadKeycloakDefaultTheme",
|
||||
|
@ -200,7 +200,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
||||
const { archiveFilePath } = await downloadAndExtractArchive({
|
||||
cacheDirPath: buildContext.cacheDirPath,
|
||||
fetchOptions: buildContext.fetchOptions,
|
||||
urlOrPath: extensionJar.url,
|
||||
url: extensionJar.url,
|
||||
uniqueIdOfOnArchiveFile: "no extraction",
|
||||
onArchiveFile: async () => {}
|
||||
});
|
||||
|
@ -1,15 +1,14 @@
|
||||
import fetch, { type FetchOptions } from "make-fetch-happen";
|
||||
import { mkdir, unlink, writeFile, readdir, readFile } from "fs/promises";
|
||||
import { dirname as pathDirname, join as pathJoin, basename as pathBasename } from "path";
|
||||
import { dirname as pathDirname, join as pathJoin } from "path";
|
||||
import { assert } from "tsafe/assert";
|
||||
import { extractArchive } from "./extractArchive";
|
||||
import { existsAsync } from "./fs.existsAsync";
|
||||
import * as crypto from "crypto";
|
||||
import { rm } from "./fs.rm";
|
||||
import * as fsPr from "fs/promises";
|
||||
|
||||
export async function downloadAndExtractArchive(params: {
|
||||
urlOrPath: string;
|
||||
url: string;
|
||||
uniqueIdOfOnArchiveFile: string;
|
||||
onArchiveFile: (params: {
|
||||
fileRelativePath: string;
|
||||
@ -22,33 +21,16 @@ export async function downloadAndExtractArchive(params: {
|
||||
cacheDirPath: string;
|
||||
fetchOptions: FetchOptions | undefined;
|
||||
}): Promise<{ extractedDirPath: string; archiveFilePath: string }> {
|
||||
const {
|
||||
urlOrPath,
|
||||
uniqueIdOfOnArchiveFile,
|
||||
onArchiveFile,
|
||||
cacheDirPath,
|
||||
fetchOptions
|
||||
} = params;
|
||||
const { url, uniqueIdOfOnArchiveFile, onArchiveFile, cacheDirPath, fetchOptions } =
|
||||
params;
|
||||
|
||||
const isUrl = /^https?:\/\//.test(urlOrPath);
|
||||
|
||||
const archiveFileBasename = isUrl
|
||||
? urlOrPath.split("?")[0].split("/").reverse()[0]
|
||||
: pathBasename(urlOrPath);
|
||||
const archiveFileBasename = url.split("?")[0].split("/").reverse()[0];
|
||||
|
||||
const archiveFilePath = pathJoin(cacheDirPath, archiveFileBasename);
|
||||
|
||||
download: {
|
||||
await mkdir(pathDirname(archiveFilePath), { recursive: true });
|
||||
|
||||
if (!isUrl) {
|
||||
await fsPr.copyFile(urlOrPath, archiveFilePath);
|
||||
|
||||
break download;
|
||||
}
|
||||
|
||||
const url = urlOrPath;
|
||||
|
||||
if (await existsAsync(archiveFilePath)) {
|
||||
const isDownloaded = await SuccessTracker.getIsDownloaded({
|
||||
cacheDirPath,
|
||||
|
Loading…
x
Reference in New Issue
Block a user