@adamlui/geolocate 2.1.0 โ†’ 2.2.1

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 CHANGED
@@ -8,12 +8,12 @@
8
8
  <img height=31 src="https://img.shields.io/npm/dm/@adamlui/geolocate?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
9
9
  <a href="#%EF%B8%8F-mit-license">
10
10
  <img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
11
- <a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.1.0">
12
- <img height=31 src="https://img.shields.io/badge/Latest_Build-2.1.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
11
+ <a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.2.1">
12
+ <img height=31 src="https://img.shields.io/badge/Latest_Build-2.2.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
13
13
  <a href="https://www.npmjs.com/package/@adamlui/geolocate?activeTab=code">
14
14
  <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>
15
- <a href="https://github.com/adamlui/js-utils/blob/geolocate-2.1.0/geolocate/dist/geolocate.min.js">
16
- <img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-2.1.0&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
15
+ <a href="https://github.com/adamlui/js-utils/blob/geolocate-2.2.1/geolocate/dist/geolocate.min.js">
16
+ <img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-2.2.1&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
17
17
  <a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:geolocate/src/geolocate.js">
18
18
  <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>
19
19
  <a href="https://github.com/toolleeo/cli-apps#networking">
@@ -67,6 +67,7 @@ Sample output:
67
67
 
68
68
  ```
69
69
  Parameter options:
70
+ --ui-lang="code" ISO 639-1 code of language to display UI in.
70
71
  --config="path/to/file" Load custom config file.
71
72
 
72
73
  Boolean options:
@@ -123,14 +124,14 @@ const geo = require('@adamlui/geolocate')
123
124
  #### <> HTML script tag:
124
125
 
125
126
  ```html
126
- <script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.1.0/dist/geolocate.min.js"></script>
127
+ <script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.2.1/dist/geolocate.min.js"></script>
127
128
  ```
128
129
 
129
130
  #### ES6:
130
131
 
131
132
  ```js
132
133
  (async () => {
133
- await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.1.0/dist/geolocate.min.js')
134
+ await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.2.1/dist/geolocate.min.js')
134
135
  // Your code here...
135
136
  })()
136
137
  ```
@@ -139,7 +140,7 @@ const geo = require('@adamlui/geolocate')
139
140
 
140
141
  ```js
141
142
  ...
142
- // @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.1.0/dist/geolocate.min.js
143
+ // @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.2.1/dist/geolocate.min.js
143
144
  // ==/UserScript==
144
145
 
145
146
  // Your code here...
@@ -147,7 +148,7 @@ const geo = require('@adamlui/geolocate')
147
148
 
148
149
  <br>
149
150
 
150
- **๐Ÿ“ Note:** To always import the latest version (not recommended in production!) remove the `@2.1.0` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
151
+ **๐Ÿ“ Note:** To always import the latest version (not recommended in production!) remove the `@2.2.1` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
151
152
 
152
153
  <br>
153
154
 
@@ -4,5 +4,5 @@
4
4
  * Source: https://github.com/adamlui/js-utils/tree/main/geolocate/src
5
5
  * Documentation: https://github.com/adamlui/js-utils/tree/main/geolocate/docs
6
6
  */
7
- (async()=>{var e,i=process.argv.slice(2),o=(globalThis.env={debugMode:i.some(e=>/^--?debug(?:-?mode)?$/.test(e)),devMode:/[\\/]src(?:[\\/]|$)/i.test(__dirname)},require("node-clipboardy")),s=require(`../geolocate${env.devMode?"":".min"}.js`),{generateRandomLang:n,getMsgs:r,getSysLang:t}=require(`./lib/language${env.devMode?"":".min"}.js`),a=require(`./lib/log${env.devMode?"":".min"}.js`),g=require(`./lib/settings${env.devMode?"":".min"}.js`),d=(Object.assign(globalThis.app??={},require(`../${env.devMode?"../":"./data/"}app.json`)),app.msgs=await r(env.debugMode?n({excludes:["en"]}):t()),app.urls.docs+="/#-command-line-usage",[]);for(e of i){var l=g.controls.init.regex.test(e);if(l)return g.initConfigFile();if(g.controls.help.regex.test(e))return a.help();if(g.controls.version.regex.test(e))return a.version();e.startsWith("-")||l||d.push(e.replace(/[[\]]/g,""))}g.load();r=await s.locate(d,{verbose:!app.config.quietMode});r||process.exit(1),app.config.quietMode||1!=r.length||a.geoData(r[0]),a.ifNotQuiet(`
8
- ${app.msgs.info_copyingToClip}...`),o.writeSync(JSON.stringify(r,void 0,2))})();
7
+ (async()=>{globalThis.env={args:process.argv.slice(2),devMode:/[\\/]src(?:[\\/]|$)/i.test(__dirname)},env.debugMode=env.args.some(e=>/^--?debug(?:-?mode)?$/.test(e)),env.modExt=`${env.devMode?"":".min"}.js`;var e=require("node-clipboardy"),i=require("../geolocate"+env.modExt),o=require("./lib/init"+env.modExt),r=require("./lib/log"+env.modExt);if(await o.cli(),cli.config.init)return o.configFile();if(cli.config.help)return r.help();if(cli.config.version)return r.version();var n,t=[];for(n of env.args)n.startsWith("-")||t.push(n.replace(/[[\]]/g,""));o=await i.locate(t,{verbose:!cli.config.quietMode});o||process.exit(1),cli.config.quietMode||1!=o.length||r.geoData(o[0]),r.ifNotQuiet(`
8
+ ${cli.msgs.info_copyingToClip}...`),e.writeSync(JSON.stringify(o,null,2))})();
@@ -3,4 +3,4 @@
3
3
  * Source: https://github.com/adamlui/js-utils/tree/main/geolocate/src
4
4
  * Documentation: https://github.com/adamlui/js-utils/tree/main/geolocate/docs
5
5
  */
6
- module.exports={atomicWrite(e,r,t="utf8"){var n=require("path"),a=require("fs"),n=n.join(n.dirname(e),`.${n.basename(e)}.tmp`);a.writeFileSync(n,r,t),a.renameSync(n,e)},fetch(n){return"undefined"==typeof fetch?new Promise((t,e)=>{var r=n.match(/^([^:]+):\/\//)[1];/^https?$/.test(r)||e(new Error(app.msgs.error_invalidURL+".")),require(r).get(n,e=>{let r="";e.on("data",e=>r+=e),e.on("end",()=>t({json:()=>JSON.parse(r)}))}).on("error",e)}):fetch(n)},flatten(e,{key:r="message"}={}){var t,n={};for(t in e)n[t]="object"==typeof e[t]&&r in e[t]?e[t][r]:e[t];return n}};
6
+ module.exports={atomicWrite(e,r,t="utf8"){var n=require("fs"),a=require("path"),a=a.join(a.dirname(e),`.${a.basename(e)}.tmp`);n.writeFileSync(a,r,t),n.renameSync(a,e)},fetch(n){return"undefined"==typeof fetch?new Promise((t,e)=>{var r=n.match(/^([^:]+):\/\//)[1];/^https?$/.test(r)||e(new Error(cli.msgs.error_invalidURL+".")),require(r).get(n,e=>{let r="";e.on("data",e=>r+=e),e.on("end",()=>t({json:()=>JSON.parse(r)}))}).on("error",e)}):fetch(n)},flatten(e,{key:r="message"}={}){var t,n={};for(t in e)n[t]="object"==typeof e[t]&&r in e[t]?e[t][r]:e[t];return n}};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * ยฉ 2024โ€“2026 Adam Lui & contributors under the MIT license.
3
+ * Source: https://github.com/adamlui/js-utils/tree/main/geolocate/src
4
+ * Documentation: https://github.com/adamlui/js-utils/tree/main/geolocate/docs
5
+ */
6
+ let language=require("./language"+env.modExt),log=require("./log"+env.modExt),settings=require("./settings"+env.modExt),dataPath="../../"+(env.devMode?"../":"data/");module.exports={async cli(){Object.assign(globalThis.cli??={},require(dataPath+"package-data.json")),cli.lang=settings.load("uiLang")||(env.debugMode?language.generateRandomLang({excludes:["en"]}):language.getSysLang()),cli.msgs=await language.getMsgs(cli.lang),cli.urls.cliDocs||=cli.urls.docs+"/#-command-line-usage",settings.load()},async configFile(e=settings.configFilename){var t=require("fs"),a=require("path"),i={target:a.resolve(process.cwd(),e)};if(t.existsSync(i.target))return log.warn(cli.msgs.warn_configFileExists+":",i.target);if(t.existsSync(i.src=a.resolve(__dirname,""+dataPath+e)))t.copyFileSync(i.src,i.target);else{a=require("./jsdelivr"+env.modExt).pkgVerURL+`/${e}/`;log.data(cli.msgs.info_fetchingRemoteConfigFrom+` ${a}...`);try{var s=require("./data"+env.modExt),g=await s.fetch(a);if(!g.ok)return log.warn(`${cli.msgs.warn_remoteConfigNotFound}: ${a} (${g.status})`);s.atomicWrite(i.target,await g.text())}catch(e){return log.warn(cli.msgs.warn_remoteConfigFailed+`: ${a} `+e.message)}}log.success(`${cli.msgs.info_configFileCreated}: ${i.target}\n`),log.tip(cli.msgs.tip_editToSetDefaults+"."),log.tip(cli.msgs.tip_cliArgsPrioritized+".")}};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * ยฉ 2024โ€“2026 Adam Lui & contributors under the MIT license.
3
+ * Source: https://github.com/adamlui/js-utils/tree/main/geolocate/src
4
+ * Documentation: https://github.com/adamlui/js-utils/tree/main/geolocate/docs
5
+ */
6
+ module.exports={pkgVerURL(e){e||=cli.version||=require("./pkg"+env.modExt).getVer("local")||"none";var l=cli.name.split("/")[1],e=/^\d+\.\d+\.\d+$/.test(e)?l+"-"+e:"latest";return cli.urls.jsdelivr+`@${e}/`+l},commitURL(e="latest"){return cli.urls.jsdelivr+`@${e}/`+cli.name.split("/")[1]}};
@@ -3,6 +3,5 @@
3
3
  * Source: https://github.com/adamlui/js-utils/tree/main/geolocate/src
4
4
  * Documentation: https://github.com/adamlui/js-utils/tree/main/geolocate/docs
5
5
  */
6
- let data=require(`./data${env.devMode?"":".min"}.js`),log=require(`./log${env.devMode?"":".min"}.js`);module.exports={generateRandomLang({includes:e=[],excludes:a=[]}={}){let t=require("fs"),s=require("path"),r=e.length?e:(()=>{var e=s.join(__dirname,"..",".cache"),a=s.join(e,"locales.json");if(t.existsSync(a))try{return JSON.parse(t.readFileSync(a,"utf8"))}catch(e){}var r=s.resolve(process.cwd(),"_locales");return t.existsSync(r)?(r=t.readdirSync(r,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).filter(e=>/^[a-z]{2}(?:_[A-Z]{2})?$/.test(e)),t.mkdirSync(e,{recursive:!0}),data.atomicWrite(a,JSON.stringify(r,null,2)),r):["en"]})(),n=new Set(a),l="en";return(r=r.filter(e=>!n.has(e))).length&&(l=r[Math.floor(Math.random()*r.length)]),log.debug(`
7
- Random language: ${l}
8
- `),l},async getMsgs(t="en"){let e=data.flatten(require(`../../${env.devMode?"../_locales/en/":"data/"}messages.json`),{key:"message"});if(!t.startsWith("en")){var s=`${app.urls.jsdelivr}@${app.commitHashes.locales}/${app.name.split("/")[1]}/_locales/`;let a=s+t.replace("-","_")+"/messages.json",r=0;for(;r<3;)try{log.debug(e=data.flatten(await(await data.fetch(a)).json(),{key:"message"}));break}catch(e){if(2<++r)break;a=t.includes("-")&&1==r?a.replace(/([^_]*)_[^/]*(\/.*)/,"$1$2"):s+"en/messages.json"}}return e},getSysLang(){var e;if("win32"!=process.platform)return((e=process.env).LANG||e.LANGUAGE||e.LC_ALL||e.LC_MESSAGES||e.LC_NAME||"en").split(".")[0];try{return require("child_process").execSync("(Get-Culture).TwoLetterISOLanguageName",{shell:"powershell",encoding:"utf-8"}).trim()}catch(e){return log.error("ERROR loading system language:",e.message),"en"}}};
6
+ let data=require("./data"+env.modExt),log=require("./log"+env.modExt);module.exports={formatCode(e){return e.replace(/([a-z]{2,8})[-_]([a-z]{2})/i,(e,r,t)=>r.toLowerCase()+"_"+t.toUpperCase())},generateRandomLang({includes:e=[],excludes:r=[]}={}){let a=require("fs"),s=require("path"),t=e.length?e:(()=>{var e=s.join(__dirname,"..",".cache"),r=s.join(e,"locales.json");if(a.existsSync(r))try{return JSON.parse(a.readFileSync(r,"utf8"))}catch(e){}var t=s.resolve(process.cwd(),"_locales");return a.existsSync(t)?(t=a.readdirSync(t,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).filter(e=>/^\w{2}[-_]?\w{0,2}$/.test(e)),a.mkdirSync(e,{recursive:!0}),data.atomicWrite(r,JSON.stringify(t,null,2)),t):["en"]})(),n=new Set(r),l="en";return(t=t.filter(e=>!n.has(e))).length&&(l=t[Math.floor(Math.random()*t.length)]),log.debug(`Random language: ${l}
7
+ `),l},async getMsgs(a="en"){if(a=module.exports.formatCode(a),env.msgs&&a==cli.lang)return env.msgs;let e=data.flatten(require(`../../${env.devMode?"../_locales/en/":"data/"}messages.json`));if(!a.startsWith("en")){var s=require("./jsdelivr"+env.modExt).commitURL(cli.commitHashes.locales)+"/_locales/";let r=s+a+"/messages.json",t=0;for(;t<3;)try{e=data.flatten(await(await data.fetch(r)).json());break}catch(e){if(3<=++t)break;log.debug(r=a.includes("-")&&1==t?r.replace(/([^_]*)_[^/]*(\/.*)/,"$1$2"):s+"en/messages.json")}}return e},getSysLang(){try{var e;return"win32"==process.platform?require("child_process").execSync("(Get-Culture).TwoLetterISOLanguageName",{shell:"powershell",encoding:"utf-8"}).trim():((e=process.env).LANG||e.LANGUAGE||e.LC_ALL||e.LC_MESSAGES||e.LC_NAME).split(".")[0]}catch(e){return log.error(cli.msgs.error_failedToFetchSysLang+":",e.message),"en"}},validateLangCode(e){return"string"==typeof e&&/^[a-z]{2,8}(?:[-_][a-z]{2,3})?$/i.test(e)}};
@@ -3,21 +3,21 @@
3
3
  * Source: https://github.com/adamlui/js-utils/tree/main/geolocate/src
4
4
  * Documentation: https://github.com/adamlui/js-utils/tree/main/geolocate/docs
5
5
  */
6
- module.exports={colors:{nc:"",br:"",by:"",bo:"",bg:"",bw:"",blk:"",tlBG:""},configURL(){this.info(`
7
- ${app.msgs.info_exampleValidConfigFile}: `+app.urls.config)},configURLandExit(...s){this.error(...s),this.configURL(),process.exit(1)},data(s){console.log(`
8
- `+this.colors.bw+s+this.colors.nc)},debug(s){env.debugMode&&console.log(s)},error(...s){console.error(`
9
- ${this.colors.br}${app.msgs.prefix_error}:`,...s,this.colors.nc)},errorAndExit(...s){this.error(...s),this.helpCmdAndDocURL(),process.exit(1)},ifNotQuiet(s){app.config.quietMode||console.info(s)},info(s){console.info(`
10
- `+this.colors.by+s+this.colors.nc)},tip(s){console.info(""+this.colors.by+app.msgs.prefix_tip+": "+s+this.colors.nc)},success(s){console.log(`
11
- `+this.colors.bg+s+this.colors.nc)},warn(...s){console.warn(`
12
- ${this.colors.bo}${app.msgs.prefix_warning}:`,...s,this.colors.nc)},geoData(s){console.info([`
13
- IP: `+this.colors.bw+s.ip+this.colors.nc,app.msgs.geoLabel_country+": "+this.colors.bw+s.country+this.colors.nc,app.msgs.geoLabel_region+": "+this.colors.bw+s.regionName+this.colors.nc,app.msgs.geoLabel_city+": "+this.colors.bw+s.city+this.colors.nc,app.msgs.geoLabel_zip+": "+this.colors.bw+s.zip+this.colors.nc,app.msgs.geoLabel_lat+": "+this.colors.bw+s.lat+this.colors.nc,app.msgs.geoLabel_lon+": "+this.colors.bw+s.lon+this.colors.nc,app.msgs.geoLabel_timeZone+": "+this.colors.bw+s.timezone.replace(/_/g," ").replace(/\//g," / ")+this.colors.nc,"ISP: "+this.colors.bw+s.isp+this.colors.nc].join("\n"))},help(s=["header","usage","params","flags","cmds"]){app.prefix=""+this.colors.tlBG+this.colors.blk+` ${app.name.replace(/^@[^/]+\//,"")} ${this.colors.nc} `;let o={header:[`
14
- โ”œ ${app.prefix}${app.msgs.appCopyright}.`,""+app.prefix+app.msgs.prefix_source+": "+app.urls.src],usage:[`
15
- ${this.colors.bw}o ${app.msgs.helpSection_usage}:`+this.colors.nc,` ${this.colors.bw}ยป `+this.colors.bg+app.cmdFormat+this.colors.nc],params:[`
16
- ${this.colors.bw}o ${app.msgs.helpSection_params}:`+this.colors.nc,` --config="path/to/file" ${app.msgs.optionDesc_config}.`],flags:[`
17
- ${this.colors.bw}o ${app.msgs.helpSection_flags}:`+this.colors.nc,` -q, --quiet ${app.msgs.optionDesc_quiet}.`],cmds:[`
18
- ${this.colors.bw}o ${app.msgs.helpSection_cmds}:`+this.colors.nc,` -i, --init ${app.msgs.optionDesc_init}.`,` -h, --help ${app.msgs.optionDesc_help}.`,` -v, --version ${app.msgs.optionDesc_version}.`]};s.forEach(c=>o[c]?.forEach(o=>{{var p=/header|usage/.test(c)?1:29;let e=process.stdout.columns||80,s=o.match(/\S+|\s+/g),i=[],r="";s.forEach(s=>{var o=e-(i.length?p:0);r.length+"| ".length+s.length>o&&(i.push(i.length?r.trimStart():r),r=""),r+=s}),i.push(i.length?r.trimStart():r),i.forEach((s,o)=>console.info("| "+(0==o?s:" ".repeat(p)+s)))}})),console.info(`
19
- ${app.msgs.info_moreHelp}, ${app.msgs.info_visit}: `+this.colors.bw+app.urls.docs+this.colors.nc)},helpCmdAndDocURL(){console.info(`
20
- ${app.msgs.info_moreHelp}, ${app.msgs.info_type} ${app.name.split("/")[1]} --help' ${app.msgs.info_or} ${app.msgs.info_visit}
21
- `+this.colors.bw+app.urls.docs+this.colors.nc)},version(){var s=require("child_process").execSync(`npm view ${JSON.stringify(app.name)} version`).toString().trim()||"none";let o="none";try{var e=require("path").resolve(process.cwd(),"node_modules",app.name,"package.json");require("fs").existsSync(e)&&(o=require(e).version||"none")}catch(s){this.error(app.msgs.error_readingLocalPkgVer+":",s.message)}console.info(`
22
- ${app.msgs.prefix_globalVer}: ${s}
23
- ${app.msgs.prefix_localVer}: `+o)}};
6
+ module.exports={colors:{nc:"",br:"",by:"",bo:"",bg:"",bw:"",gry:"",blk:"",tlBG:""},configURL(){this.info(`
7
+ ${cli.msgs.info_exampleValidConfigFile}: `+cli.urls.config)},configURLandExit(...o){this.error(...o),this.configURL(),process.exit(1)},data(o){console.log(`
8
+ `+this.colors.bw+o+this.colors.nc)},debug(o){env.debugMode&&console.debug(`
9
+ ${this.colors.bo}DEBUG:`,o,this.colors.nc,"\n")},dim(o){console.log(""+this.colors.gry+o+this.colors.nc)},error(...o){console.error(`
10
+ ${this.colors.br}ERROR:`,...o,this.colors.nc)},errorAndExit(...o){this.error(...o),this.helpCmdAndDocURL(),process.exit(1)},ifNotQuiet(o){cli.config.quietMode||console.info(o)},info(o){console.info(`
11
+ `+this.colors.by+o+this.colors.nc)},tip(o){console.info(this.colors.by+"TIP: "+o+this.colors.nc)},success(o){console.log(`
12
+ `+this.colors.bg+o+this.colors.nc)},warn(...o){console.warn(`
13
+ ${this.colors.bo}WARNING:`,...o,this.colors.nc)},geoData(o){console.info([`
14
+ IP: `+this.colors.bw+o.ip+this.colors.nc,cli.msgs.geoLabel_country+": "+this.colors.bw+o.country+this.colors.nc,cli.msgs.geoLabel_region+": "+this.colors.bw+o.regionName+this.colors.nc,cli.msgs.geoLabel_city+": "+this.colors.bw+o.city+this.colors.nc,cli.msgs.geoLabel_zip+": "+this.colors.bw+o.zip+this.colors.nc,cli.msgs.geoLabel_lat+": "+this.colors.bw+o.lat+this.colors.nc,cli.msgs.geoLabel_lon+": "+this.colors.bw+o.lon+this.colors.nc,cli.msgs.geoLabel_timeZone+": "+this.colors.bw+o.timezone.replace(/_/g," ").replace(/\//g," / ")+this.colors.nc,"ISP: "+this.colors.bw+o.isp+this.colors.nc].join("\n"))},help(o=["header","usage","params","flags","cmds"]){cli.prefix=""+this.colors.tlBG+this.colors.blk+` ${cli.name.replace(/^@[^/]+\//,"")} ${this.colors.nc} `;let s={header:[`
15
+ โ”œ ${cli.prefix}${cli.msgs.appCopyright}.`,""+cli.prefix+cli.msgs.prefix_source+": "+cli.urls.src],usage:[`
16
+ ${this.colors.bw}o ${cli.msgs.helpSection_usage}:`+this.colors.nc,` ${this.colors.bw}ยป `+this.colors.bg+cli.cmdFormat+this.colors.nc],params:[`
17
+ ${this.colors.bw}o ${cli.msgs.helpSection_params}:`+this.colors.nc,` --ui-lang="code" ${cli.msgs.optionDesc_uiLang}.`,` --config="path/to/file" ${cli.msgs.optionDesc_config}.`],flags:[`
18
+ ${this.colors.bw}o ${cli.msgs.helpSection_flags}:`+this.colors.nc,` -q, --quiet ${cli.msgs.optionDesc_quiet}.`],cmds:[`
19
+ ${this.colors.bw}o ${cli.msgs.helpSection_cmds}:`+this.colors.nc,` -i, --init ${cli.msgs.optionDesc_init}.`,` -h, --help ${cli.msgs.optionDesc_help}.`,` -v, --version ${cli.msgs.optionDesc_version}.`]};o.forEach(r=>s[r]?.forEach(s=>{{var e=/header|usage/.test(r)?1:29;let i=process.stdout.columns||80,o=s.match(/\S+|\s+/g),c=[],l="";o.forEach(o=>{var s=i-(c.length?e:0);l.length+"| ".length+o.length>s&&(c.push(c.length?l.trimStart():l),l=""),l+=o}),c.push(c.length?l.trimStart():l),c.forEach((o,s)=>console.info("| "+(0==s?o:" ".repeat(e)+o)))}})),console.info(`
20
+ ${cli.msgs.info_moreHelp}, ${cli.msgs.info_visit}: `+this.colors.bw+cli.urls.cliDocs+this.colors.nc)},helpCmdAndDocURL(){console.info(`
21
+ ${cli.msgs.info_moreHelp}, ${cli.msgs.info_type} ${cli.name.split("/")[1]} --help' ${cli.msgs.info_or} ${cli.msgs.info_visit}
22
+ `+this.colors.bw+cli.urls.docs+this.colors.nc)},version(){var o=require("./pkg"+env.modExt).getVer;this.info(cli.name),this.data(`${cli.msgs.prefix_globalVer}: ${o("global")||"none"}
23
+ ${cli.msgs.prefix_localVer}: `+(o("local")||"none"))}};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * ยฉ 2024โ€“2026 Adam Lui & contributors under the MIT license.
3
+ * Source: https://github.com/adamlui/js-utils/tree/main/geolocate/src
4
+ * Documentation: https://github.com/adamlui/js-utils/tree/main/geolocate/docs
5
+ */
6
+ let log=require("./log"+env.modExt);module.exports={getVer(e="any"){let r;if("global"!=e)try{var l=require("path").resolve(process.cwd(),"node_modules",cli.name,"package.json");r=require(l).version}catch(e){log.debug(cli.msgs.error_readingLocalPkgVer+": "+e.message)}if("global"==e||"all"==e&&!r)try{r=require("child_process").execSync(`npm view ${JSON.stringify(cli.name)} version`).toString().trim()}catch(e){log.debug(cli.msgs.error_failedToFetchGlobalVer+": "+e.message)}return r}};
@@ -3,6 +3,5 @@
3
3
  * Source: https://github.com/adamlui/js-utils/tree/main/geolocate/src
4
4
  * Documentation: https://github.com/adamlui/js-utils/tree/main/geolocate/docs
5
5
  */
6
- let fs=require("fs"),log=require(`./log${env.devMode?"":".min"}.js`),path=require("path");(globalThis.app??={}).config={},module.exports={configFilename:"geolocate.config.mjs",controls:{config:{type:"param",regex:/^--?config(?:=.*|$)/},quietMode:{type:"flag",regex:/^--?q(?:uiet)?(?:-?mode)?$/},init:{type:"cmd",regex:/^-{0,2}i(?:nit)?$/},help:{type:"cmd",regex:/^--?h(?:elp)?$/},version:{type:"cmd",regex:/^--?ve?r?s?i?o?n?$/}},async initConfigFile(o=this.configFilename){var e=path.resolve(process.cwd(),o);if(fs.existsSync(e))return log.warn(app.msgs.warn_configFileExists+":",e);var i=path.resolve(__dirname,"../../"+(env.devMode?"../":"./data/")+o);if(fs.existsSync(i))fs.copyFileSync(i,e);else{i=require(`./data${env.devMode?"":".min"}.js`),o=app.urls.jsdelivr+"/geolocate/"+o;log.data(app.msgs.info_fetchingRemoteConfigFrom+` ${o}...`);try{var s=await i.fetch(o);if(!s.ok)return log.warn(`${app.msgs.warn_remoteConfigNotFound}: ${o} (${s.status})`);i.atomicWrite(e,await s.text())}catch(e){return log.warn(app.msgs.warn_remoteConfigFailed+`: ${o} `+e.message)}}log.success(app.msgs.info_configFileCreated+`: ${e}
7
- `),log.tip(app.msgs.tip_editToSetDefaults+"."),log.tip(app.msgs.tip_cliArgsPrioritized+".")},load({args:e=process.argv.slice(2),ctrlKeys:r=Object.keys(this.controls)}={}){r.forEach(e=>{var o=this.controls[e];o.mode||"cmd"==o.type||(app.config[e]??=o.defaultVal??("flag"!=o.type&&""))});let o;var i=e.find(e=>this.controls.config.regex.test(e));if(i){/=/.test(i)||log.errorAndExit(`[${i}] `+app.msgs.error_mustIncludePath);i=i.split("=")[1];o=path.isAbsolute(i)?i:path.resolve(process.cwd(),i),fs.existsSync(o)||log.configURLandExit(app.msgs.error_configFileNotFound+":",o)}else for(var s of["mjs","cjs","js"]){s=path.resolve(process.cwd(),this.configFilename.replace(/\.[^.]+$/,"."+s));if(fs.existsSync(s)){o=s;break}}if(o)try{var t=require(o),a=t?.default??t;a&&"object"==typeof a||log.configURLandExit(app.msgs.error_invalidConfigFile+"."),Object.assign(app.config,a)}catch(e){log.configURLandExit(app.msgs.error_failedToLoadConfigFile+":",o,`
8
- `+e.message)}return e.forEach(o=>{if(!/^[^-]|--?(?:config|debug)/.test(o)){var i=r.find(e=>this.controls[e]?.regex?.test(o)),s=(i||log.errorAndExit(`[${o}] ${app.msgs.error_notRecognized}.`),this.controls[i]);if("cmd"!=s.type){let e="param"!=s.type||o.split("=")[1]?.trim();s.mode?app.config.mode=i.replace(/mode$/i,"").toLowerCase():((s=s.parser)&&(e=s(e),isNaN(e)||e<1)&&log.errorAndExit(`[${i}] ${app.msgs.error_nonPositiveNum}.`),app.config[i]=e)}}}),app.config}};
6
+ let fs=require("fs"),log=require("./log"+env.modExt),path=require("path");(globalThis.cli??={}).config={},module.exports={configFilename:"geolocate.config.mjs",controls:{uiLang:{type:"param",valType:"langCode",regex:/^--?ui-?lang(?:=.*|$)/},config:{type:"param",valType:"filepath",regex:/^--?config(?:=.*|$)/},quietMode:{type:"flag",regex:/^--?q(?:uiet)?(?:-?mode)?$/},init:{type:"cmd",regex:/^-{0,2}i(?:nit)?$/},help:{type:"cmd",regex:/^--?h(?:elp)?$/},version:{type:"cmd",regex:/^--?ve?r?s?i?o?n?$/}},load(e=Object.keys(this.controls)){let t=[].concat(e);if(cli.defaultsSet||arguments.length||(t.forEach(e=>{var i=this.controls[e];i.mode||(cli.config[e]??=i.defaultVal??("param"==i.type&&""))}),cli.defaultsSet=!0),!cli.configPathTried){e=env.args.find(e=>this.controls.config.regex.test(e));if(e){/=/.test(e)||log.errorAndExit(`[${e}] `+cli.msgs.error_mustIncludePath);e=e.split("=")[1];cli.configPath=path.isAbsolute(e)?e:path.resolve(process.cwd(),e),fs.existsSync(cli.configPath)||log.configURLandExit(cli.msgs.error_configFileNotFound+":",cli.configPath)}else for(var i of[".mjs",".cjs",".js"]){i=path.resolve(process.cwd(),this.configFilename.replace(/\.[^.]+$/,i));if(fs.existsSync(i)){cli.configPath=i;break}}cli.configPathTried=!0}if(cli.configPath)try{let e=require(cli.configPath),o=e?.default??e;o&&"object"==typeof o||log.configURLandExit(cli.msgs.error_invalidConfigFile+"."),Object.assign(cli.config,arguments.length?t.reduce((e,i)=>o[i]?{...e,[i]:o[i]}:e,{}):o)}catch(e){log.configURLandExit(cli.msgs.error_failedToLoadConfigFile+":",cli.configPath,`
7
+ `+e.message)}return env.args.forEach(i=>{var e,o;/^[^-]|--?(?:config|debug)/.test(i)&&"init"!=i||(!(e=Object.keys(this.controls).find(e=>this.controls[e]?.regex?.test(i)))&&cli.msgs&&log.errorAndExit(`[${i}] ${cli.msgs.error_notRecognized}.`),t.includes(e)&&((o=this.controls[e]).mode?cli.config.mode=e.replace(/mode$/i,"").toLowerCase():cli.config[e]="param"!=o.type||(i.split("=")[1]?.trim()??"")))}),this.parseValidateConfig(t),1==t.length?cli.config[t[0]]:cli.config},parseValidateConfig(e=Object.keys(this.controls)){let t=require("./language"+env.modExt);for(let o of[].concat(e)){let e=this.controls[o],i=cli.config[o];e.parser&&!e.parsed&&(cli.config[o]=e.parser(i),e.parsed=!0),e.valType&&{positiveInt(){var e=parseInt(i,10);(isNaN(e)||e<1)&&log.errorAndExit(`[${o}] ${cli.msgs.error_nonPositiveNum}: `+i),cli.config[o]=e},filepath(){i&&!fs.existsSync(i)&&log.errorAndExit(`[${o}] ${cli.msgs.error_invalidFilepath}: `+i)},langCode(){i&&!t.validateLangCode(i)&&log.errorAndExit(`[${o}] ${cli.msgs.error_invalidLangCode}: `+i)}}[e.valType]()}}};
@@ -9,5 +9,6 @@
9
9
  */
10
10
 
11
11
  export default {
12
+ uiLang: '', // ISO 639-1 code of language to display UI in
12
13
  quietMode: false // suppress all logging except errors
13
14
  }
@@ -1,31 +1,32 @@
1
1
  {
2
2
  "appName": { "message": "geolocate" },
3
3
  "appCopyright": { "message": "ยฉ 2024โ€“2026 Adam Lui under the MIT license" },
4
- "prefix_error": { "message": "ERROR" },
5
- "prefix_tip": { "message": "TIP" },
6
- "prefix_warning": { "message": "WARNING" },
7
4
  "prefix_globalVer": { "message": "Global version" },
8
5
  "prefix_localVer": { "message": "Local version" },
9
6
  "prefix_source": { "message": "Source" },
10
7
  "error_readingLocalPkgVer": { "message": "Error reading local package version" },
11
8
  "error_notRecognized": { "message": "not recognized" },
12
9
  "error_nonPositiveNum": { "message": "argument can only be > 0" },
10
+ "error_invalidFilepath": { "message": "must be a valid existing file path. Got" },
11
+ "error_invalidLangCode": { "message": "is an invalid language code" },
13
12
  "error_invalidURL": { "message": "Invalid URL" },
14
13
  "error_invalidConfigFile": { "message": "Config file must export an object" },
15
14
  "error_configFileNotFound": { "message": "Config file not found" },
16
15
  "error_failedToLoadConfigFile": { "message": "Failed to load config file" },
16
+ "error_failedToFetchGlobalVer": { "message": "Failed to fetch global version" },
17
+ "error_failedToFetchSysLang": { "message": "Failed to fetch system language" },
17
18
  "error_mustIncludePath": { "message": "must include =path" },
18
19
  "warn_configFileExists": { "message": "Config file already exists" },
19
- "info_exampleValidConfigFile": { "message": "Example valid config file" },
20
- "info_copyingToClip": { "message": "Copying to clipboard" },
21
- "info_moreHelp": { "message": "For more help" },
20
+ "warn_remoteConfigNotFound": { "message": "Remote config file not found" },
21
+ "warn_remoteConfigFailed": { "message": "Failed to fetch remote config file" },
22
+ "info_exampleValidConfigFile": { "message": "Example valid config file" },
23
+ "info_copyingToClip": { "message": "Copying to clipboard" },
24
+ "info_moreHelp": { "message": "For more help" },
22
25
  "info_type": { "message": "type" },
23
26
  "info_or": { "message": "or" },
24
27
  "info_visit": { "message": "visit" },
25
28
  "info_configFileCreated": { "message": "Config file created" },
26
29
  "info_fetchingRemoteConfigFrom": { "message": "Fetching remote config file from" },
27
- "warn_remoteConfigNotFound": { "message": "Remote config file not found" },
28
- "warn_remoteConfigFailed": { "message": "Failed to fetch remote config file" },
29
30
  "tip_editToSetDefaults": { "message": "Edit this file to customize defaults" },
30
31
  "tip_cliArgsPrioritized": { "message": "CLI arguments always override these values" },
31
32
  "geoLabel_country": { "message": "Country" },
@@ -39,6 +40,7 @@
39
40
  "helpSection_params": { "message": "Parameter options" },
40
41
  "helpSection_flags": { "message": "Config options" },
41
42
  "helpSection_cmds": { "message": "Commands" },
43
+ "optionDesc_uiLang": { "message": "ISO 639-1 code of language to display UI in" },
42
44
  "optionDesc_config": { "message": "Load custom config file" },
43
45
  "optionDesc_quiet": { "message": "Suppress all logging except errors" },
44
46
  "optionDesc_init": { "message": "Create config file (in project root)" },
@@ -13,6 +13,6 @@
13
13
  "src": "https://github.com/adamlui/js-utils/tree/main/geolocate/src"
14
14
  },
15
15
  "commitHashes": {
16
- "locales": "171f054"
16
+ "locales": "69618f8"
17
17
  }
18
18
  }
@@ -3,4 +3,4 @@
3
3
  * Source: https://github.com/adamlui/js-utils/tree/main/geolocate/src
4
4
  * Documentation: https://github.com/adamlui/js-utils/tree/main/geolocate/docs
5
5
  */
6
- async function geolocate(e,n={}){var t,o={verbose:!0};log.prefix="geolocate()",(e=[].concat(e))[0]||=await getOwnIP();for(t of e){n.verbose&&log.info(`Validating ${t}...`);let o;try{o=require("generate-ip").ipv4.validate}catch(e){await import("https://cdn.jsdelivr.net/npm/generate-ip/dist/generate-ip.min.js"),o=window.ipv4.validate}if(o&&!o(t,{verbose:!1}))return log.error(t+" is not a valid IPv4 address.")}if(validateOptions({options:n,defaultOptions:o,helpURL:"https://github.com/adamlui/js-utils/tree/main/geolocate/docs/#locateips-options",exampleCall:"geolocate('8.8.8.8', { verbose: false })"})){n={...o,...n};try{var l,s=[];for(l of e){n.verbose&&log.info(`Fetching geolocation data for ${l}...`);let e=await fetchData("http://ip-api.com/json/"+l),{status:o,org:t,as:r,query:a,...i}=await e.json();s.push({ip:l,...i})}return n.verbose&&"undefined"!=typeof window&&log.info("Success!","Check returned array."),s}catch(e){log.error(e.message)}}}function fetchData(r){return"undefined"==typeof fetch?new Promise((t,o)=>{try{var e=r.match(/^([^:]+):\/\//)[1];/^https?$/.test(e)||o(new Error("Invalid fetchData() URL.")),require(e).get(r,e=>{let o="";e.on("data",e=>o+=e),e.on("end",()=>t({json:()=>JSON.parse(o)}))}).on("error",e=>o(new Error(e.message)))}catch(e){o(new Error("Environment not supported."))}}):fetch(r)}async function getOwnIP(){return fetchData("https://ifconfig.me/ip").then(e=>e.text()).catch(()=>fetchData("http://ip-api.com/json/").then(e=>e.json()).then(e=>e.query)).catch(async()=>{try{var e=require("child_process").exec,o=require("util").promisify,{stdout:t,stderr:r}=await o(e)("curl -s ifconfig.me");return r?log.error(r):t.trim()}catch(e){log.error(e.message)}})}function validateOptions({options:e,defaultOptions:o,helpURL:t,exampleCall:r}){var a,i,n=Object.keys(o).filter(e=>"boolean"==typeof o[e]),l=Object.keys(o).filter(e=>Number.isInteger(o[e]));if("object"!=typeof e)return a=r.split(",").findIndex(e=>e.trim().startsWith("{"))+1,a+=["st","nd","rd"][a-1]||"th",log.error(`${"0th"==a?"[O":a+" arg [o"}ptions] can only be an object of key/vals.`),log.info("Example valid call:",r),log.validOptions(o),log.helpURL(t),!1;for(i in e){if(!Object.prototype.hasOwnProperty.call(o,i))return log.error(`\`${i}\` is an invalid option.`),log.validOptions(o),log.helpURL(t),!1;if(n.includes(i)&&"boolean"!=typeof e[i])return log.error(`[${i}] option can only be \`true\` or \`false\`.`),log.helpURL(t),!1;if(l.includes(i)&&(e[i]=parseInt(e[i],10),isNaN(e[i])||e[i]<1))return log.error(`[${i}] option can only be an integer > 0.`),log.helpURL(t),!1}return!0}Object.assign(globalThis.app??={},{name:"geolocate",aliases:{geolocate:["Geolocate","geoLocate","GeoLocate","locate","Locate"]}});let log={prefix:app.name,error(...e){console.error(this.prefix+" ยป ERROR:",...e)},helpURL(e=app.urls?.docs){this.info("For more help, please visit",e)},info(...e){console.info(this.prefix+" ยป",...e)},validOptions(e){var o=Object.keys(e).join(", "),e=JSON.stringify(e,void 0,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," ");this.info(`Valid options: [${o}]`),this.info("If omitted, default settings are: "+e)}};try{module.exports={geolocate:geolocate}}catch(e){}try{window.geo={geolocate:geolocate}}catch(e){}for(let o in app.aliases){try{app.aliases[o].forEach(e=>module.exports[e]??=module.exports[o])}catch(e){}try{app.aliases[o].forEach(e=>window.geo[e]??=window.geo[o])}catch(e){}}
6
+ async function geolocate(e,n={}){var t,o={verbose:!0};log.prefix="geolocate()",(e=[].concat(e))[0]||=await getOwnIP();for(t of e){n.verbose&&log.info(`Validating ${t}...`);let o;try{o=require("generate-ip").ipv4.validate}catch(e){await import("https://cdn.jsdelivr.net/npm/generate-ip/dist/generate-ip.min.js"),o=window.ipv4.validate}if(o&&!o(t,{verbose:!1}))return log.error(t+" is not a valid IPv4 address.")}if(validateOptions({options:n,defaultOptions:o,helpURL:"https://github.com/adamlui/js-utils/tree/main/geolocate/docs/#locateips-options",exampleCall:"geolocate('8.8.8.8', { verbose: false })"})){n={...o,...n};try{var l,s=[];for(l of e){n.verbose&&log.info(`Fetching geolocation data for ${l}...`);let e=await fetchData("http://ip-api.com/json/"+l),{status:o,org:t,as:r,query:a,...i}=await e.json();s.push({ip:l,...i})}return n.verbose&&"undefined"!=typeof window&&log.info("Success!","Check returned array."),s}catch(e){log.error(e.message)}}}function fetchData(r){return"undefined"==typeof fetch?new Promise((t,o)=>{try{var e=r.match(/^([^:]+):\/\//)[1];/^https?$/.test(e)||o(new Error("Invalid fetchData() URL.")),require(e).get(r,e=>{let o="";e.on("data",e=>o+=e),e.on("end",()=>t({json:()=>JSON.parse(o)}))}).on("error",e=>o(new Error(e.message)))}catch(e){o(new Error("Environment not supported."))}}):fetch(r)}async function getOwnIP(){return fetchData("https://ifconfig.me/ip").then(e=>e.text()).catch(()=>fetchData("http://ip-api.com/json/").then(e=>e.json()).then(e=>e.query)).catch(async()=>{try{var e=require("child_process").exec,o=require("util").promisify,{stdout:t,stderr:r}=await o(e)("curl -s ifconfig.me");return r?log.error(r):t.trim()}catch(e){log.error(e.message)}})}function validateOptions({options:e,defaultOptions:o,helpURL:t,exampleCall:r}){var a,i,n=Object.keys(o).filter(e=>"boolean"==typeof o[e]),l=Object.keys(o).filter(e=>Number.isInteger(o[e]));if("object"!=typeof e)return a=r.split(",").findIndex(e=>e.trim().startsWith("{"))+1,a+=["st","nd","rd"][a-1]||"th",log.error(`${"0th"==a?"[O":a+" arg [o"}ptions] can only be an object of key/vals.`),log.info("Example valid call:",r),log.validOptions(o),log.helpURL(t),!1;for(i in e){if(!Object.prototype.hasOwnProperty.call(o,i))return log.error(`\`${i}\` is an invalid option.`),log.validOptions(o),log.helpURL(t),!1;if(n.includes(i)&&"boolean"!=typeof e[i])return log.error(`[${i}] option can only be \`true\` or \`false\`.`),log.helpURL(t),!1;if(l.includes(i)&&(e[i]=parseInt(e[i],10),isNaN(e[i])||e[i]<1))return log.error(`[${i}] option can only be an integer > 0.`),log.helpURL(t),!1}return!0}Object.assign(globalThis.api??={},{name:"geolocate",aliases:{geolocate:["Geolocate","geoLocate","GeoLocate","locate","Locate"]}});let log={prefix:api.name,error(...e){console.error(this.prefix+" ยป ERROR:",...e)},helpURL(e=api.urls?.docs){this.info("For more help, please visit",e)},info(...e){console.info(this.prefix+" ยป",...e)},validOptions(e){var o=Object.keys(e).join(", "),e=JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," ");this.info(`Valid options: [${o}]`),this.info("If omitted, default settings are: "+e)}};try{module.exports={geolocate:geolocate}}catch(e){}try{window.geo={geolocate:geolocate}}catch(e){}for(let o in api.aliases){try{api.aliases[o].forEach(e=>module.exports[e]??=module.exports[o])}catch(e){}try{api.aliases[o].forEach(e=>window.geo[e]??=window.geo[o])}catch(e){}}
package/docs/README.md CHANGED
@@ -8,12 +8,12 @@
8
8
  <img height=31 src="https://img.shields.io/npm/dm/@adamlui/geolocate?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
9
9
  <a href="#%EF%B8%8F-mit-license">
10
10
  <img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
11
- <a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.1.0">
12
- <img height=31 src="https://img.shields.io/badge/Latest_Build-2.1.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
11
+ <a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.2.1">
12
+ <img height=31 src="https://img.shields.io/badge/Latest_Build-2.2.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
13
13
  <a href="https://www.npmjs.com/package/@adamlui/geolocate?activeTab=code">
14
14
  <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>
15
- <a href="https://github.com/adamlui/js-utils/blob/geolocate-2.1.0/geolocate/dist/geolocate.min.js">
16
- <img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-2.1.0&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
15
+ <a href="https://github.com/adamlui/js-utils/blob/geolocate-2.2.1/geolocate/dist/geolocate.min.js">
16
+ <img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-2.2.1&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
17
17
  <a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:geolocate/src/geolocate.js">
18
18
  <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>
19
19
  <a href="https://github.com/toolleeo/cli-apps#networking">
@@ -67,6 +67,7 @@ Sample output:
67
67
 
68
68
  ```
69
69
  Parameter options:
70
+ --ui-lang="code" ISO 639-1 code of language to display UI in.
70
71
  --config="path/to/file" Load custom config file.
71
72
 
72
73
  Boolean options:
@@ -123,14 +124,14 @@ const geo = require('@adamlui/geolocate')
123
124
  #### <> HTML script tag:
124
125
 
125
126
  ```html
126
- <script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.1.0/dist/geolocate.min.js"></script>
127
+ <script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.2.1/dist/geolocate.min.js"></script>
127
128
  ```
128
129
 
129
130
  #### ES6:
130
131
 
131
132
  ```js
132
133
  (async () => {
133
- await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.1.0/dist/geolocate.min.js')
134
+ await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.2.1/dist/geolocate.min.js')
134
135
  // Your code here...
135
136
  })()
136
137
  ```
@@ -139,7 +140,7 @@ const geo = require('@adamlui/geolocate')
139
140
 
140
141
  ```js
141
142
  ...
142
- // @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.1.0/dist/geolocate.min.js
143
+ // @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.2.1/dist/geolocate.min.js
143
144
  // ==/UserScript==
144
145
 
145
146
  // Your code here...
@@ -147,7 +148,7 @@ const geo = require('@adamlui/geolocate')
147
148
 
148
149
  <br>
149
150
 
150
- **๐Ÿ“ Note:** To always import the latest version (not recommended in production!) remove the `@2.1.0` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
151
+ **๐Ÿ“ Note:** To always import the latest version (not recommended in production!) remove the `@2.2.1` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
151
152
 
152
153
  <br>
153
154
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamlui/geolocate",
3
- "version": "2.1.0",
3
+ "version": "2.2.1",
4
4
  "description": "Fetch IP geolocation data from the CLI.",
5
5
  "author": {
6
6
  "name": "Adam Lui",
@@ -45,7 +45,7 @@
45
45
  "build:data": "node utils/build --data",
46
46
  "build:json": "node utils/build --json",
47
47
  "debug": "node src/cli --debug",
48
- "translate": "py utils/translate-en-messages.py",
48
+ "translate": "translate-messages",
49
49
  "bump:patch": "bash utils/bump.sh patch",
50
50
  "bump:minor": "bash utils/bump.sh minor",
51
51
  "bump:major": "bash utils/bump.sh major"
@@ -55,12 +55,15 @@
55
55
  "url": "git+https://github.com/adamlui/js-utils.git"
56
56
  },
57
57
  "keywords": [
58
+ "api",
59
+ "cli",
60
+ "data",
58
61
  "geolocate",
59
62
  "geolocation",
60
63
  "ip",
61
64
  "networking",
62
- "api",
63
- "cli"
65
+ "sluething",
66
+ "utility"
64
67
  ],
65
68
  "bugs": {
66
69
  "url": "https://github.com/adamlui/js-utils/issues"
@@ -69,7 +72,7 @@
69
72
  "node-clipboardy": "^1.0.3"
70
73
  },
71
74
  "devDependencies": {
72
- "@adamlui/minify.js": "^2.2.0",
73
- "generate-ip": "^2.5.0"
75
+ "@adamlui/minify.js": "^2.3.0",
76
+ "generate-ip": "^2.6.0"
74
77
  }
75
78
  }