@adamlui/geolocate 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +194 -193
  2. package/package.json +8 -2
package/README.md CHANGED
@@ -1,193 +1,194 @@
1
- # <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.com/adamlui/js-utils/blob/main/geolocate/media/images/icons/wire-globe/white/icon32.png"><img height=28 src="https://github.com/adamlui/js-utils/blob/main/geolocate/media/images/icons/wire-globe/black/icon32.png"></picture> geolocate
2
-
3
- ### Fetch IP geolocation data from the CLI.
4
-
5
- <a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-1.0.0"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.0.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
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://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>
8
-
9
- <br>
10
-
11
- <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
12
-
13
- ## ⚡ Installation
14
-
15
- As a **global utility**:
16
-
17
- ```
18
- $ npm install -g @adamlui/geolocate
19
- ```
20
-
21
- As a **dev dependency**, from your project root:
22
-
23
- ```
24
- $ npm install -D @adamlui/geolocate
25
- ```
26
-
27
- As a **runtime dependency**, from your project root:
28
-
29
- ```
30
- $ npm install @adamlui/geolocate
31
- ```
32
-
33
- <br>
34
-
35
- <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
36
-
37
- ## 💻 Command line usage
38
-
39
- The basic **global command** is:
40
-
41
- ```
42
- $ geolocate
43
- ```
44
-
45
- Sample output:
46
-
47
- <img src="https://github.com/adamlui/js-utils/blob/main/geolocate/media/images/screenshots/cli-geolocate-8.8.8.8.jpg">
48
-
49
- **💡 Note:** If no IPv4 address is passed, your own one will be used.
50
-
51
- ### Command line options
52
-
53
- ```
54
- Boolean options:
55
- -q, --quiet Suppress all logging except errors.
56
-
57
- Info commands:
58
- -h, --help Display help screen.
59
- -v, --version Show version number.
60
- ```
61
-
62
- <br>
63
-
64
- <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
65
-
66
- ## 🔌 Importing the API
67
-
68
- You can also import **geolocate** into your app to use its API methods.
69
-
70
- ### <img height=18 src="https://i.imgur.com/JIeAdsr.png"> Node.js
71
-
72
- #### ES module*:
73
-
74
- ```js
75
- import * as geo from '@adamlui/geolocate';
76
- ```
77
-
78
- #### CommonJS:
79
-
80
- ```js
81
- const geo = require('@adamlui/geolocate');
82
- ```
83
-
84
- ###### _*Node.js version 14 or higher required_
85
-
86
- ### <picture><source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/JSEb19A.png"><img width=16 src="https://i.imgur.com/5VPxf9y.png"></picture> Web
87
-
88
- #### <> HTML script tag:
89
-
90
- ```html
91
- <script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.0/dist/generate-ip.min.js"></script>
92
- ```
93
-
94
- #### ES6:
95
-
96
- ```js
97
- (async () => {
98
- await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.0/dist/generate-ip.min.js');
99
- // Your code here...
100
- })();
101
- ```
102
-
103
- ### <img height=17 src="https://raw.githubusercontent.com/KudoAI/chatgpt.js/main/starters/media/images/icons/tampermonkey-icon28.png"><img height=17.5 src="https://raw.githubusercontent.com/KudoAI/chatgpt.js/main/starters/media/images/icons/violentmonkey-icon100.png"> Greasemonkey
104
-
105
- ```js
106
- ...
107
- // @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.0/dist/geolocate.min.js
108
- // ==/UserScript==
109
-
110
- // Your code here...
111
- ```
112
-
113
- <br>
114
-
115
- 📝 **Note:** To always import the latest version (not recommended in production!) remove the `@1.0.0` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
116
-
117
- <br>
118
-
119
- <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
120
-
121
- ## 📋 API usage
122
-
123
- ### `locate([ip])`
124
-
125
- Asynchronous method to fetch geolocation data for the `ip` passed, returned as an object.
126
-
127
- **💡 Note:** If no `ip` is supplied, your own one will be used.
128
-
129
- ```js
130
- // Using await syntax
131
- const location = await geo.locate('192.12.85.186');
132
- console.log(location);
133
-
134
- // Using .then() syntax
135
- geo.locate('192.12.85.186').then(location => {
136
- console.log(location);
137
- });
138
-
139
- /* outputs:
140
- {
141
- ip: '8.8.8.8',
142
- country: 'United States',
143
- countryCode: 'US',
144
- region: 'VA',
145
- regionName: 'Virginia',
146
- city: 'Ashburn',
147
- zip: '20149',
148
- lat: 39.03,
149
- lon: -77.5,
150
- timezone: 'America/New_York',
151
- isp: 'Google LLC'
152
- }
153
- */
154
- ```
155
-
156
- #
157
-
158
- ### `getOwnIP()`
159
-
160
- Asynchronous method to fetch/return your own IP as a string:
161
-
162
- ```js
163
- // Using await syntax
164
- const ip = await geo.getOwnIP();
165
- console.log(ip); // outputs your IP
166
-
167
- // Using .then() syntax
168
- geo.getOwnIP().then(ip => {
169
- console.log(ip); // outputs your IP
170
- });
171
- ```
172
-
173
- <br>
174
-
175
- <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
176
-
177
- ## 🏛️ MIT License
178
-
179
- **Copyright © 2023 [Adam Lui](https://github.com/adamlui)**
180
-
181
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
182
-
183
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
184
-
185
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
186
-
187
- <br>
188
-
189
- <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
190
-
191
- <a href="https://github.com/adamlui/js-utils">**JavaScript utilities**</a> /
192
- <a href="https://github.com/adamlui/js-utils/discussions">Discuss</a> /
193
- <a href="#-geolocate">Back to top ↑</a>
1
+ # <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.com/adamlui/js-utils/blob/main/geolocate/media/images/icons/wire-globe/white/icon32.png"><img height=28 src="https://github.com/adamlui/js-utils/blob/main/geolocate/media/images/icons/wire-globe/black/icon32.png"></picture> geolocate
2
+
3
+ ### Fetch IP geolocation data from the CLI.
4
+
5
+ <a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-1.0.1"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.0.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
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-1.0.1/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-1.0.1&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
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
+
10
+ <br>
11
+
12
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
13
+
14
+ ## ⚡ Installation
15
+
16
+ As a **global utility**:
17
+
18
+ ```
19
+ $ npm install -g @adamlui/geolocate
20
+ ```
21
+
22
+ As a **dev dependency**, from your project root:
23
+
24
+ ```
25
+ $ npm install -D @adamlui/geolocate
26
+ ```
27
+
28
+ As a **runtime dependency**, from your project root:
29
+
30
+ ```
31
+ $ npm install @adamlui/geolocate
32
+ ```
33
+
34
+ <br>
35
+
36
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
37
+
38
+ ## 💻 Command line usage
39
+
40
+ The basic **global command** is:
41
+
42
+ ```
43
+ $ geolocate
44
+ ```
45
+
46
+ Sample output:
47
+
48
+ <img src="https://github.com/adamlui/js-utils/blob/main/geolocate/media/images/screenshots/cli-geolocate-8.8.8.8.jpg">
49
+
50
+ **💡 Note:** If no IPv4 address is passed, your own one will be used.
51
+
52
+ ### Command line options
53
+
54
+ ```
55
+ Boolean options:
56
+ -q, --quiet Suppress all logging except errors.
57
+
58
+ Info commands:
59
+ -h, --help Display help screen.
60
+ -v, --version Show version number.
61
+ ```
62
+
63
+ <br>
64
+
65
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
66
+
67
+ ## 🔌 Importing the API
68
+
69
+ You can also import **geolocate** into your app to use its API methods.
70
+
71
+ ### <img height=18 src="https://i.imgur.com/JIeAdsr.png"> Node.js
72
+
73
+ #### ES module*:
74
+
75
+ ```js
76
+ import * as geo from '@adamlui/geolocate';
77
+ ```
78
+
79
+ #### CommonJS:
80
+
81
+ ```js
82
+ const geo = require('@adamlui/geolocate');
83
+ ```
84
+
85
+ ###### _*Node.js version 14 or higher required_
86
+
87
+ ### <picture><source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/JSEb19A.png"><img width=16 src="https://i.imgur.com/5VPxf9y.png"></picture> Web
88
+
89
+ #### <> HTML script tag:
90
+
91
+ ```html
92
+ <script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.1/dist/geolocate.min.js"></script>
93
+ ```
94
+
95
+ #### ES6:
96
+
97
+ ```js
98
+ (async () => {
99
+ await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.1/dist/geolocate.min.js');
100
+ // Your code here...
101
+ })();
102
+ ```
103
+
104
+ ### <img height=17 src="https://raw.githubusercontent.com/KudoAI/chatgpt.js/main/starters/media/images/icons/tampermonkey-icon28.png"><img height=17.5 src="https://raw.githubusercontent.com/KudoAI/chatgpt.js/main/starters/media/images/icons/violentmonkey-icon100.png"> Greasemonkey
105
+
106
+ ```js
107
+ ...
108
+ // @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@1.0.1/dist/geolocate.min.js
109
+ // ==/UserScript==
110
+
111
+ // Your code here...
112
+ ```
113
+
114
+ <br>
115
+
116
+ 📝 **Note:** To always import the latest version (not recommended in production!) remove the `@1.0.1` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
117
+
118
+ <br>
119
+
120
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
121
+
122
+ ## 📋 API usage
123
+
124
+ ### `locate([ip])`
125
+
126
+ Asynchronous method to fetch geolocation data for the `ip` passed, returned as an object.
127
+
128
+ **💡 Note:** If no `ip` is supplied, your own one will be used.
129
+
130
+ ```js
131
+ // Using await syntax
132
+ const location = await geo.locate('192.12.85.186');
133
+ console.log(location);
134
+
135
+ // Using .then() syntax
136
+ geo.locate('192.12.85.186').then(location => {
137
+ console.log(location);
138
+ });
139
+
140
+ /* outputs:
141
+ {
142
+ ip: '8.8.8.8',
143
+ country: 'United States',
144
+ countryCode: 'US',
145
+ region: 'VA',
146
+ regionName: 'Virginia',
147
+ city: 'Ashburn',
148
+ zip: '20149',
149
+ lat: 39.03,
150
+ lon: -77.5,
151
+ timezone: 'America/New_York',
152
+ isp: 'Google LLC'
153
+ }
154
+ */
155
+ ```
156
+
157
+ #
158
+
159
+ ### `getOwnIP()`
160
+
161
+ Asynchronous method to fetch/return your own IP as a string:
162
+
163
+ ```js
164
+ // Using await syntax
165
+ const ip = await geo.getOwnIP();
166
+ console.log(ip); // outputs your IP
167
+
168
+ // Using .then() syntax
169
+ geo.getOwnIP().then(ip => {
170
+ console.log(ip); // outputs your IP
171
+ });
172
+ ```
173
+
174
+ <br>
175
+
176
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
177
+
178
+ ## 🏛️ MIT License
179
+
180
+ **Copyright © 2023 [Adam Lui](https://github.com/adamlui)**
181
+
182
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
183
+
184
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
185
+
186
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
187
+
188
+ <br>
189
+
190
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
191
+
192
+ <a href="https://github.com/adamlui/js-utils">**JavaScript utilities**</a> /
193
+ <a href="https://github.com/adamlui/js-utils/discussions">Discuss</a> /
194
+ <a href="#-geolocate">Back to top ↑</a>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamlui/geolocate",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Fetch IP geolocation data from the CLI.",
5
5
  "author": {
6
6
  "name": "Adam Lui",
@@ -19,7 +19,13 @@
19
19
  },
20
20
  "scripts": {
21
21
  "test": "echo \"Error: no test specified\" && exit 1",
22
- "build": "minify-js src dist"
22
+ "build": "minify-js src dist",
23
+ "bump:patch": "bash utils/bump.sh patch",
24
+ "bump:minor": "bash utils/bump.sh minor",
25
+ "bump:major": "bash utils/bump.sh major",
26
+ "publish:patch": "bash utils/bump.sh patch --publish",
27
+ "publish:minor": "bash utils/bump.sh minor --publish",
28
+ "publish:major": "bash utils/bump.sh major --publish"
23
29
  },
24
30
  "repository": {
25
31
  "type": "git",