mirror of
https://github.com/hexboy/maven-mirror-tool.git
synced 2025-04-25 16:09:08 +00:00
change SERVERS fields to REPOSITORIES
This commit is contained in:
parent
7031a36cf1
commit
525fc5f104
3 changed files with 5 additions and 5 deletions
|
@ -28,7 +28,7 @@ PROXIES:
|
|||
port: 1080
|
||||
protocol: socks5
|
||||
|
||||
SERVERS:
|
||||
REPOSITORIES:
|
||||
- name: iranrepo
|
||||
url: https://gradle.iranrepo.ir
|
||||
fileTypes:
|
||||
|
|
6
index.ts
6
index.ts
|
@ -14,7 +14,7 @@ const config = yaml.load(
|
|||
) as IConfig;
|
||||
const args = minimist(process.argv);
|
||||
|
||||
const { SERVERS, PROXIES, IGNORE_FILES = [], VALID_FILE_TYPES = [] } = config;
|
||||
const { REPOSITORIES, PROXIES, IGNORE_FILES = [], VALID_FILE_TYPES = [] } = config;
|
||||
|
||||
const port = args.port || config.PORT || 8008;
|
||||
const cacheDir = args['cache-dir'] || config.CACHE_DIR;
|
||||
|
@ -28,7 +28,7 @@ if (!fs.existsSync(path.resolve(cacheBaseDir, '_tmp_'))) {
|
|||
}
|
||||
|
||||
const getCachedPath = (filePath: string) => {
|
||||
const srv = SERVERS.find((s) => {
|
||||
const srv = REPOSITORIES.find((s) => {
|
||||
const fPath = path.join(cacheBaseDir, s.code, filePath);
|
||||
if (fs.existsSync(fPath) ? fs.statSync(fPath).size : 0) {
|
||||
console.log(`📦 [${s.code}]`, filePath);
|
||||
|
@ -76,7 +76,7 @@ const downloadFile = async (url: string, res: any) => {
|
|||
console.log('❌ [404]', url);
|
||||
return res.sendStatus(404);
|
||||
}
|
||||
for await (const srv of SERVERS) {
|
||||
for await (const srv of REPOSITORIES) {
|
||||
const fileName = url.split('/').pop() || '';
|
||||
const outputDir = path
|
||||
.join(cacheBaseDir, srv.code, url)
|
||||
|
|
2
types.ts
2
types.ts
|
@ -18,7 +18,7 @@ type TServer = {
|
|||
interface IConfig {
|
||||
PORT: number;
|
||||
CACHE_DIR: string;
|
||||
SERVERS: TServer[];
|
||||
REPOSITORIES: TServer[];
|
||||
DEFAULT_PATH: string;
|
||||
LOG_REQUESTS?: boolean;
|
||||
IGNORE_FILES?: string[];
|
||||
|
|
Loading…
Add table
Reference in a new issue