@k03mad/ip2geo 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +6 -2
- package/app/cli.js +3 -2
- package/package.json +3 -2
- package/app/helpers/array.js +0 -5
- package/app/helpers/logging.js +0 -26
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# GeoIP lookup
|
|
2
2
|
|
|
3
3
|
— Using [ipwhois.io](https://ipwhois.io/documentation) \
|
|
4
|
-
— Runtime
|
|
5
|
-
— Filesystem infinity cache
|
|
4
|
+
— Runtime + filesystem caching
|
|
6
5
|
|
|
7
6
|
## Global
|
|
8
7
|
|
|
8
|
+
Cache directory = `os.tmpDir() / .ip2geo`
|
|
9
|
+
|
|
9
10
|
```bash
|
|
10
11
|
npm i @k03mad/ip2geo -g
|
|
11
12
|
|
|
@@ -38,7 +39,10 @@ import {ip2geo} from '@k03mad/ip2geo';
|
|
|
38
39
|
|
|
39
40
|
const info = await ip2geo('1.1.1.1', {
|
|
40
41
|
// defaults
|
|
42
|
+
|
|
43
|
+
// current app root
|
|
41
44
|
cacheDir: '.geoip',
|
|
45
|
+
// will be prefixed with the first IP octet
|
|
42
46
|
cacheFileName: 'ips.log',
|
|
43
47
|
cacheFileSeparator: ';;',
|
|
44
48
|
cacheFileNewline: '\n',
|
package/app/cli.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
|
|
6
|
+
import {log, logErrorExit} from '@k03mad/simple-log';
|
|
7
|
+
|
|
6
8
|
import {codeText, errorText, nameText} from './helpers/colors.js';
|
|
7
|
-
import {log, throwError} from './helpers/logging.js';
|
|
8
9
|
|
|
9
10
|
import {ip2geo} from './index.js';
|
|
10
11
|
|
|
@@ -16,7 +17,7 @@ if (args.length === 0) {
|
|
|
16
17
|
const prefix = codeText('$');
|
|
17
18
|
const name = nameText('ip2geo');
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
logErrorExit([
|
|
20
21
|
errorText('IP(s) should be passed as args'),
|
|
21
22
|
'',
|
|
22
23
|
`${prefix} ${name} 1.1.1.1`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k03mad/ip2geo",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "GeoIP library",
|
|
5
5
|
"maintainers": [
|
|
6
6
|
"Kirill Molchanov <k03.mad@gmail.com"
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@k03mad/request": "5.4.1",
|
|
23
|
+
"@k03mad/simple-log": "2.0.0",
|
|
23
24
|
"chalk": "5.3.0",
|
|
24
25
|
"debug": "4.3.4"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@k03mad/eslint-config": "19.
|
|
28
|
+
"@k03mad/eslint-config": "19.3.0",
|
|
28
29
|
"eslint": "8.56.0",
|
|
29
30
|
"husky": "8.0.3",
|
|
30
31
|
"mocha": "10.2.0"
|
package/app/helpers/array.js
DELETED
package/app/helpers/logging.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
import {convertToArray} from './array.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {any|any[]} msg
|
|
7
|
-
* @returns {void}
|
|
8
|
-
*/
|
|
9
|
-
export const log = msg => convertToArray(msg)
|
|
10
|
-
.forEach(elem => console.log(elem));
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param {any|any[]} msg
|
|
14
|
-
* @returns {void}
|
|
15
|
-
*/
|
|
16
|
-
export const logError = msg => convertToArray(msg)
|
|
17
|
-
.forEach(elem => console.error(elem));
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @param {any|any[]} msg
|
|
21
|
-
* @returns {void}
|
|
22
|
-
*/
|
|
23
|
-
export const throwError = msg => {
|
|
24
|
-
logError(msg);
|
|
25
|
-
process.exit(1);
|
|
26
|
-
};
|