mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
Fix types
This commit is contained in:
parent
b742701f59
commit
824fde2fc0
@ -1,10 +1,12 @@
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
import fs from 'node:fs';
|
||||||
import { pipeline } from 'node:stream/promises';
|
import { pipeline } from 'node:stream/promises';
|
||||||
import { task } from './trace';
|
import { task } from './trace';
|
||||||
import { extract as tarExtract } from 'tar-fs';
|
import { extract as tarExtract } from 'tar-fs';
|
||||||
import type { Headers as TarEntryHeaders } from 'tar-fs';
|
import type { Headers as TarEntryHeaders } from 'tar-fs';
|
||||||
import zlib from 'node:zlib';
|
import zlib from 'node:zlib';
|
||||||
import undici from 'undici';
|
import undici from 'undici';
|
||||||
|
import picocolors from 'picocolors';
|
||||||
|
|
||||||
const GITHUB_CODELOAD_URL = 'https://codeload.github.com/sukkalab/ruleset.skk.moe/tar.gz/master';
|
const GITHUB_CODELOAD_URL = 'https://codeload.github.com/sukkalab/ruleset.skk.moe/tar.gz/master';
|
||||||
const GITLAB_CODELOAD_URL = 'https://gitlab.com/SukkaW/ruleset.skk.moe/-/archive/master/ruleset.skk.moe-master.tar.gz';
|
const GITLAB_CODELOAD_URL = 'https://gitlab.com/SukkaW/ruleset.skk.moe/-/archive/master/ruleset.skk.moe-master.tar.gz';
|
||||||
@ -12,10 +14,10 @@ const GITLAB_CODELOAD_URL = 'https://gitlab.com/SukkaW/ruleset.skk.moe/-/archive
|
|||||||
export const downloadPreviousBuild = task(require.main === module, __filename)(async (span) => {
|
export const downloadPreviousBuild = task(require.main === module, __filename)(async (span) => {
|
||||||
const publicDir = path.resolve(__dirname, '..', 'public');
|
const publicDir = path.resolve(__dirname, '..', 'public');
|
||||||
|
|
||||||
// if (fs.existsSync(publicDir)) {
|
if (fs.existsSync(publicDir)) {
|
||||||
// console.log(picocolors.blue('Public directory exists, skip downloading previous build'));
|
console.log(picocolors.blue('Public directory exists, skip downloading previous build'));
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
const tarGzUrl = await span.traceChildAsync('get tar.gz url', async () => {
|
const tarGzUrl = await span.traceChildAsync('get tar.gz url', async () => {
|
||||||
const resp = await undici.request(GITHUB_CODELOAD_URL, { method: 'HEAD' });
|
const resp = await undici.request(GITHUB_CODELOAD_URL, { method: 'HEAD' });
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import { stringHash } from './string-hash';
|
|||||||
import { defaultRequestInit, fetchWithLog } from './fetch-retry';
|
import { defaultRequestInit, fetchWithLog } from './fetch-retry';
|
||||||
import { Custom304NotModifiedError, CustomAbortError, CustomNoETagFallbackError, fetchAssets, sleepWithAbort } from './fetch-assets';
|
import { Custom304NotModifiedError, CustomAbortError, CustomNoETagFallbackError, fetchAssets, sleepWithAbort } from './fetch-assets';
|
||||||
|
|
||||||
import type { Response, RequestInit } from 'undici';
|
import type { Response, RequestInit, HeadersInit } from 'undici';
|
||||||
|
|
||||||
const enum CacheStatus {
|
const enum CacheStatus {
|
||||||
Hit = 'hit',
|
Hit = 'hit',
|
||||||
@ -329,9 +329,9 @@ export class Cache<S = string> {
|
|||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
...defaultRequestInit,
|
...defaultRequestInit,
|
||||||
headers: (typeof etag === 'string' && etag.length > 0)
|
headers: (typeof etag === 'string' && etag.length > 0)
|
||||||
? mergeHeaders(
|
? mergeHeaders<HeadersInit>(
|
||||||
defaultRequestInit.headers,
|
{ 'If-None-Match': etag },
|
||||||
{ 'If-None-Match': etag }
|
defaultRequestInit.headers
|
||||||
)
|
)
|
||||||
: defaultRequestInit.headers
|
: defaultRequestInit.headers
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,7 +133,7 @@ export class ResponseError extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultRequestInit: RequestInit = {
|
export const defaultRequestInit = {
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'curl/8.9.1 (https://github.com/SukkaW/Surge)'
|
'User-Agent': 'curl/8.9.1 (https://github.com/SukkaW/Surge)'
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user