mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
fix: geoip模块dts异常及prepublish.sh不调用的问题
This commit is contained in:
1 parent
a1aeb521fe
commit
02c1866963
5 files changed
+10
-7
No files matched your search
+1
-1
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 <masnn0@outlook.com>",
|
||||
|
||||
Regular → Executable
+4
-2
@@ -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
|
||||
rm -r ./GeoLite2-City_* ./GeoLite2-City.tar.gz
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user