diff --git a/build/publish.ts b/build/publish.ts index 9b5aef04..bb49008e 100644 --- a/build/publish.ts +++ b/build/publish.ts @@ -35,7 +35,7 @@ if (CI && (GITHUB_REF !== 'refs/heads/master' || GITHUB_EVENT_NAME !== 'push')) await Promise.all(folders.map(async (name) => { let meta: PackageJson; try { - meta = require(`../${name}/package`); + meta = require(`../${name}/package.json`); if (!meta.private) { const version = await latest(meta.name); if (gt(meta.version, version)) { diff --git a/packages/geoip/lib.ts b/packages/geoip/lib.ts index 0ceecc87..aa6c1827 100644 --- a/packages/geoip/lib.ts +++ b/packages/geoip/lib.ts @@ -1,4 +1,5 @@ import 'hydrooj'; +import 'hydrooj/src/lib/i18n'; import fs from 'fs'; import path from 'path'; import { Reader } from 'maxmind'; @@ -14,9 +15,9 @@ export interface Result { display: string } -export function lookup(ip: string, locale: string) { +export function lookup(ip: string, locale: string): Result { const res: any = reader.get(ip); - if (!res) return {}; + if (!res) return { display: 'Unknown address'.translate(locale) }; const ret: Result = { display: '' }; if (res.location) ret.location = res.location; if (res.continent) ret.continent = res.continent.names[locale] || res.continent.names.en; diff --git a/packages/geoip/package.json b/packages/geoip/package.json index f33b6c06..f550de68 100644 --- a/packages/geoip/package.json +++ b/packages/geoip/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/geoip", - "version": "1.1.12", + "version": "1.1.13", "main": "package.json", "repository": "git@github.com:hydro-dev/Hydro.git", "author": "undefined ", diff --git a/packages/geoip/prepublish.sh b/packages/geoip/prepublish.sh old mode 100644 new mode 100755 index e32fa085..d4ebec29 --- a/packages/geoip/prepublish.sh +++ b/packages/geoip/prepublish.sh @@ -1,4 +1,6 @@ -wget -O ./GeoLite2-City.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${LICENSE_KEY}&suffix=tar.gz" +#!/bin/bash + +get -O ./GeoLite2-City.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${LICENSE_KEY}&suffix=tar.gz" tar zxvf ./GeoLite2-City.tar.gz -C . mv ./GeoLite2-City_*/GeoLite2-City.mmdb ./GeoLite2-City.mmdb -rm -r ./GeoLite2-City_* ./GeoLite2-City.tar.gz \ No newline at end of file +rm -r ./GeoLite2-City_* ./GeoLite2-City.tar.gz diff --git a/packages/geoip/test/lib.spec.ts b/packages/geoip/test/lib.spec.ts index 57b94b55..398b373a 100644 --- a/packages/geoip/test/lib.spec.ts +++ b/packages/geoip/test/lib.spec.ts @@ -3,7 +3,7 @@ import * as lib from '@hydrooj/geoip/lib'; describe('geoip', () => { test('MD5', () => { - expect(lib.lookup('127.0.0.1', 'zh_CN')).toStrictEqual({}); + expect(lib.lookup('127.0.0.1', 'zh_CN').display).toStrictEqual('Unknown address'); expect(lib.lookup('1.1.1.1', 'zh-CN').display).toStrictEqual('大洋洲 澳大利亚'); expect(lib.provider.includes('MaxMind')).toBeTruthy(); });