@adamlui/geolocate 2.0.4 โ 2.0.6
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/README.md +6 -6
- package/dist/cli.min.js +10 -9
- package/docs/README.md +6 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
### Fetch IP geolocation data from the CLI.
|
|
4
4
|
|
|
5
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.0.
|
|
5
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.0.6"><img height=31 src="https://img.shields.io/badge/Latest_Build-2.0.6-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
6
6
|
<a href="https://www.npmjs.com/package/@adamlui/geolocate?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fgeolocate?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
7
|
-
<a href="https://github.com/adamlui/js-utils/blob/geolocate-2.0.
|
|
7
|
+
<a href="https://github.com/adamlui/js-utils/blob/geolocate-2.0.6/geolocate/dist/geolocate.min.js"><img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-2.0.6&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
|
|
8
8
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:geolocate/src/geolocate.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Ageolocate%2Fsrc%2Fgeolocate.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
9
9
|
|
|
10
10
|
<br>
|
|
@@ -89,14 +89,14 @@ const geo = require('@adamlui/geolocate');
|
|
|
89
89
|
#### <> HTML script tag:
|
|
90
90
|
|
|
91
91
|
```html
|
|
92
|
-
<script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
92
|
+
<script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.6/dist/geolocate.min.js"></script>
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
#### ES6:
|
|
96
96
|
|
|
97
97
|
```js
|
|
98
98
|
(async () => {
|
|
99
|
-
await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
99
|
+
await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.6/dist/geolocate.min.js');
|
|
100
100
|
// Your code here...
|
|
101
101
|
})();
|
|
102
102
|
```
|
|
@@ -105,7 +105,7 @@ const geo = require('@adamlui/geolocate');
|
|
|
105
105
|
|
|
106
106
|
```js
|
|
107
107
|
...
|
|
108
|
-
// @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
108
|
+
// @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.6/dist/geolocate.min.js
|
|
109
109
|
// ==/UserScript==
|
|
110
110
|
|
|
111
111
|
// Your code here...
|
|
@@ -113,7 +113,7 @@ const geo = require('@adamlui/geolocate');
|
|
|
113
113
|
|
|
114
114
|
<br>
|
|
115
115
|
|
|
116
|
-
**๐ Note:** To always import the latest version (not recommended in production!) remove the `@2.0.
|
|
116
|
+
**๐ Note:** To always import the latest version (not recommended in production!) remove the `@2.0.6` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
|
|
117
117
|
|
|
118
118
|
<br>
|
|
119
119
|
|
package/dist/cli.min.js
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* Source: https://code.js-utils.com/geolocate
|
|
5
5
|
* Documentation: https://docs.js-utils.com/geolocate
|
|
6
6
|
*/
|
|
7
|
-
const pkgName="@adamlui/geolocate",copyright="ยฉ 2024 Adam Lui under the MIT license.",cmdFormat="geolocate [ip1] [ip2] [...] [options|commands]",srcURL="https://code.js-utils.com/geolocate",docURL="https://docs.js-utils.com/geolocate/#-command-line-usage";(async()=>{const e=require(__dirname.match(/src/)?"./geolocate":"./geolocate.min"),
|
|
8
|
-
[1;
|
|
9
|
-
[1;
|
|
10
|
-
Global version: `+
|
|
11
|
-
IP: `+
|
|
12
|
-
โ
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${
|
|
7
|
+
const pkgName="@adamlui/geolocate",copyright="ยฉ 2024 Adam Lui under the MIT license.",cmdFormat="geolocate [ip1] [ip2] [...] [options|commands]",srcURL="https://code.js-utils.com/geolocate",docURL="https://docs.js-utils.com/geolocate/#-command-line-usage";(async()=>{const e=require(__dirname.match(/src/)?"./geolocate":"./geolocate.min"),n=require("fs"),s=require("path"),i=require("child_process")["execSync"],t="[0m",r="[1;97m";let p="en";if("win32"==process.platform)try{p=i("(Get-Culture).TwoLetterISOLanguageName",{shell:"powershell",encoding:"utf-8"}).trim()}catch(e){}else{var c=process.env;p=(c.LANG||c.LANGUAGE||c.LC_ALL||c.LC_MESSAGES||c.LC_NAME||"en").split(".")[0]}let a={};var o,c=new Promise((t,r)=>{const c="https://cdn.jsdelivr.net/gh/adamlui/js-utils/geolocate/_locales/",e=(p?p.replace("-","_"):"en")+"/";let a=c+e+"messages.json",l=0;h(a).then(async function o(e){try{const n=await e.json(),s={};for(const i in n)"object"==typeof n[i]&&"message"in n[i]&&(s[i]=n[i].message);t(s)}catch(e){if(3==++l)return t({});h(a=p.includes("-")&&1==l?a.replace(/([^_]*)_[^/]*(\/.*)/,"$1$2"):c+"en/messages.json").then(o).catch(r)}}).catch(r)});try{a=await c}catch(e){}const l={},g={flags:{quietMode:/^--?q(?:uiet)?(?:-?mode)?$/},infoCmds:{help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/}};if(process.argv.forEach(o=>{var e,n;o.startsWith("-")&&(e=Object.keys(g.flags).find(e=>g.flags[e].test(o)),n=Object.keys(g.infoCmds).find(e=>g.infoCmds[e].test(o)),e?l[e]=!0:n||(console.error(`
|
|
8
|
+
${"[1;91m"+(a.prefix_error||"ERROR")}: `+`Arg [${o}] ${a.error_notRecognized||"not recognized"}.[0m`),console.info(`
|
|
9
|
+
${"[1;33m"+(a.info_validArgs||"Valid arguments are below")}.[0m`),u(["configOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>g.infoCmds.help.test(e)))u();else if(process.argv.some(e=>g.infoCmds.version.test(e))){c=i(`npm view ${pkgName} version`).toString().trim()||"none";let e,o=process.cwd();for(;"/"!=o;){var m=s.join(o,"package.json");if(n.existsSync(m)){m=require(m);e=(m.dependencies?.[pkgName]||m.devDependencies?.[pkgName])?.match(/(\d+\.\d+\.\d+)/)[0]||"none";break}o=s.dirname(o)}console.info(`
|
|
10
|
+
${a.prefix_globalVer||"Global version"}: `+c),console.info(`${a.prefix_localVer||"Local version"}: `+e)}else{var f,d=[];for(const $ of process.argv.slice(2))$.startsWith("-")||(f=$.replace(/[[\]]/g,""),d.push(f));c=await e.locate(d,{verbose:!l.quietMode});c||process.exit(1),l.quietMode||1!=c.length||(console.info(`
|
|
11
|
+
IP: `+r+c[0].ip+t),console.info(`${a.geoLabel_country||"Country"}: `+r+c[0].country+t),console.info(`${a.geoLabel_region||"Region"}: `+r+c[0].regionName+t),console.info(`${a.geoLabel_city||"City"}: `+r+c[0].city+t),console.info(`${a.geoLabel_zip||"Zip"}: `+r+c[0].zip+t),console.info(`${a.geoLabel_lat||"Latitude"}: `+r+c[0].lat+t),console.info(`${a.geoLabel_lon||"Longitude"}: `+r+c[0].lon+t),console.info(`${a.geoLabel_timeZone||"Time zone"}: `+r+c[0].timezone.replace(/_/g," ").replace(/\//g," / ")+t),console.info("ISP: "+r+c[0].isp+t)),o=`
|
|
12
|
+
${a.info_copying||"Copying to clipboard"}...`,l.quietMode||console.info(o),o=(o=JSON.stringify(c,null,2)).replace(/"/g,'""'),"darwin"==process.platform?i(`printf "${o}" | pbcopy`):"linux"==process.platform?i(`printf "${o}" | xclip -selection clipboard`):"win32"==process.platform&&i(`Set-Clipboard -Value "${o}"`,{shell:"powershell"})}function h(s){return new Promise((n,e)=>{var o=s.match(/^([^:]+):\/\//)[1];/^https?$/.test(o)||e(new Error(`${a.error_invalidURL||"Invalid URL"}.`)),require(o).get(s,e=>{let o="";e.on("data",e=>o+=e),e.on("end",()=>n({json:()=>JSON.parse(o)}))}).on("error",e)})}function u(e=["header","usage","configOptions","infoCmds"]){var o=`[106m[30m ${pkgName.replace(/^@[^/]+\//,"")} [0m `;const n={header:["\nโ "+o+(a.appCopyright||copyright),o+(a.prefix_source||"Source")+": "+srcURL],usage:[`
|
|
13
|
+
${r}o ${a.helpSection_usage||"Usage"}:[0m`," [1;97mยป [1;92m"+cmdFormat+t],configOptions:[`
|
|
14
|
+
${r}o ${a.helpSection_configOptions||"Config options"}:[0m`,` -q, --quiet ${a.optionDesc_quiet||"Suppress all logging except errors"}.`],infoCmds:[`
|
|
15
|
+
${r}o ${a.helpSection_infoCmds||"Info commands"}:[0m`," -h, --help "+(a.optionDesc_help||"Display help screen."),` -v, --version ${a.optionDesc_version||"Show version number"}.`]};e.forEach(r=>{n[r]?.forEach(e=>{{var s=/header|usage/.test(r)?1:29;const i=process.stdout.columns||80,t=[],o=e.match(/\S+|\s+/g);let n="";o.forEach(e=>{var o=i-(0==t.length?0:s);n.length+"| ".length+e.length>o&&(t.push(0==t.length?n:n.trimStart()),n=""),n+=e}),t.push(0==t.length?n:n.trimStart()),t.forEach((e,o)=>console.info("| "+(0==o?e:" ".repeat(s)+e)))}})}),console.info(`
|
|
16
|
+
${a.info_moreHelp||"For more help"}, ${a.info_visit||"visit"}: `+r+docURL+t)}})();
|
package/docs/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
### Fetch IP geolocation data from the CLI.
|
|
4
4
|
|
|
5
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.0.
|
|
5
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.0.6"><img height=31 src="https://img.shields.io/badge/Latest_Build-2.0.6-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
6
6
|
<a href="https://www.npmjs.com/package/@adamlui/geolocate?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fgeolocate?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
7
|
-
<a href="https://github.com/adamlui/js-utils/blob/geolocate-2.0.
|
|
7
|
+
<a href="https://github.com/adamlui/js-utils/blob/geolocate-2.0.6/geolocate/dist/geolocate.min.js"><img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-2.0.6&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
|
|
8
8
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:geolocate/src/geolocate.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Ageolocate%2Fsrc%2Fgeolocate.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
9
9
|
|
|
10
10
|
<br>
|
|
@@ -89,14 +89,14 @@ const geo = require('@adamlui/geolocate');
|
|
|
89
89
|
#### <> HTML script tag:
|
|
90
90
|
|
|
91
91
|
```html
|
|
92
|
-
<script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
92
|
+
<script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.6/dist/geolocate.min.js"></script>
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
#### ES6:
|
|
96
96
|
|
|
97
97
|
```js
|
|
98
98
|
(async () => {
|
|
99
|
-
await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
99
|
+
await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.6/dist/geolocate.min.js');
|
|
100
100
|
// Your code here...
|
|
101
101
|
})();
|
|
102
102
|
```
|
|
@@ -105,7 +105,7 @@ const geo = require('@adamlui/geolocate');
|
|
|
105
105
|
|
|
106
106
|
```js
|
|
107
107
|
...
|
|
108
|
-
// @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
108
|
+
// @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.6/dist/geolocate.min.js
|
|
109
109
|
// ==/UserScript==
|
|
110
110
|
|
|
111
111
|
// Your code here...
|
|
@@ -113,7 +113,7 @@ const geo = require('@adamlui/geolocate');
|
|
|
113
113
|
|
|
114
114
|
<br>
|
|
115
115
|
|
|
116
|
-
**๐ Note:** To always import the latest version (not recommended in production!) remove the `@2.0.
|
|
116
|
+
**๐ Note:** To always import the latest version (not recommended in production!) remove the `@2.0.6` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
|
|
117
117
|
|
|
118
118
|
<br>
|
|
119
119
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamlui/geolocate",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Fetch IP geolocation data from the CLI.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Adam Lui",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"url": "https://github.com/adamlui/js-utils/issues"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"generate-ip": "^2.2.
|
|
50
|
+
"generate-ip": "^2.2.12"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@adamlui/minify.js": "^1.5.
|
|
53
|
+
"@adamlui/minify.js": "^1.5.8"
|
|
54
54
|
}
|
|
55
55
|
}
|