generate-ip 2.8.2 → 2.9.0
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 +16 -14
- package/bin/gen-ip +6 -0
- package/bin/gen-ipv4 +6 -0
- package/bin/gen-ipv6 +6 -0
- package/bin/gen-mac +6 -0
- package/bin/genip +6 -0
- package/bin/genipv4 +6 -0
- package/bin/genipv6 +6 -0
- package/bin/genmac +6 -0
- package/dist/cli/index.js +8 -9
- package/dist/cli/lib/color.js +31 -0
- package/dist/cli/lib/data.js +1 -1
- package/dist/cli/lib/init.js +51 -44
- package/dist/cli/lib/jsdelivr.js +10 -10
- package/dist/cli/lib/language.js +21 -15
- package/dist/cli/lib/log.js +85 -29
- package/dist/cli/lib/pkg.js +78 -20
- package/dist/cli/lib/settings.js +43 -16
- package/dist/cli/lib/string.js +3 -0
- package/dist/data/messages.json +17 -7
- package/dist/data/package-data.json +2 -1
- package/dist/generate-ip.min.js +1 -1
- package/docs/README.md +16 -14
- package/package.json +6 -3
- package/dist/cli/.cache/locales.json +0 -102
package/README.md
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
<picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
5
|
+
<picture><source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/adamlui/js-utils@0d3424a/generate-ip/assets/images/logos/generate-ip/white-logo.png"><img width=700 src="https://cdn.jsdelivr.net/gh/adamlui/js-utils@0d3424a/generate-ip/assets/images/logos/generate-ip/black-logo.png"></picture>
|
|
6
6
|
|
|
7
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
7
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/adamlui/js-utils@5c34563/generate-ip/assets/images/icons/node-graph/white/icon55x49.png"><img width=23 src="https://cdn.jsdelivr.net/gh/adamlui/js-utils@5c34563/generate-ip/assets/images/icons/node-graph/black/icon55x49.png"></picture> Randomly generate, format, and validate IPv4 + IPv6 + MAC addresses.
|
|
8
8
|
|
|
9
9
|
<br>
|
|
10
10
|
|
|
11
|
+
<a href="https://npmstar.com/compare/generate-ip">
|
|
12
|
+
<img height=31 src="https://img.shields.io/npm/dm/generate-ip?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
11
13
|
<a href="#%EF%B8%8F-mit-license">
|
|
12
14
|
<img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
13
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/generate-ip-2.
|
|
14
|
-
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.
|
|
15
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/generate-ip-2.9.0">
|
|
16
|
+
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.9.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
15
17
|
<a href="https://www.npmjs.com/package/generate-ip?activeTab=code">
|
|
16
18
|
<img height=31 src="https://img.shields.io/npm/unpacked-size/generate-ip?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
17
|
-
<a href="https://github.com/adamlui/js-utils/blob/generate-ip-2.8.2/generate-ip/dist/generate-ip.min.js">
|
|
18
|
-
<img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/generate-ip/dist/generate-ip.min.js?branch=generate-ip-2.8.2&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
|
|
19
19
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:generate-ip/src/generate-ip.js">
|
|
20
20
|
<img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Agenerate-ip%2Fsrc%2Fgenerate-ip.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
21
21
|
<a href="https://github.com/toolleeo/cli-apps#networking">
|
|
@@ -87,14 +87,14 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
87
87
|
#### <> HTML script tag:
|
|
88
88
|
|
|
89
89
|
```html
|
|
90
|
-
<script src="https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
90
|
+
<script src="https://cdn.jsdelivr.net/npm/generate-ip@2.9.0/dist/generate-ip.min.js"></script>
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
#### ES6:
|
|
94
94
|
|
|
95
95
|
```js
|
|
96
96
|
(async () => {
|
|
97
|
-
await import('https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
97
|
+
await import('https://cdn.jsdelivr.net/npm/generate-ip@2.9.0/dist/generate-ip.min.js')
|
|
98
98
|
// Your code here...
|
|
99
99
|
})()
|
|
100
100
|
```
|
|
@@ -103,7 +103,7 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
103
103
|
|
|
104
104
|
```js
|
|
105
105
|
...
|
|
106
|
-
// @require https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
106
|
+
// @require https://cdn.jsdelivr.net/npm/generate-ip@2.9.0/dist/generate-ip.min.js
|
|
107
107
|
// ==/UserScript==
|
|
108
108
|
|
|
109
109
|
// Your code here...
|
|
@@ -111,7 +111,7 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
111
111
|
|
|
112
112
|
<br>
|
|
113
113
|
|
|
114
|
-
📝 **Note:** To always import the latest version (not recommended in production!) remove the `@2.
|
|
114
|
+
📝 **Note:** To always import the latest version (not recommended in production!) remove the `@2.9.0` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/generate-ip/dist/generate-ip.min.js`
|
|
115
115
|
|
|
116
116
|
<br>
|
|
117
117
|
|
|
@@ -156,7 +156,7 @@ Name | Type | Description
|
|
|
156
156
|
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
157
157
|
`qty` | Integer | Number of IP addresses to generate. | `1`
|
|
158
158
|
`sequential` | Boolean | Generate addresses in sequence. | `false`
|
|
159
|
-
`network` | String |
|
|
159
|
+
`network` | String | Starting network address (required for sequential mode). | `null`
|
|
160
160
|
|
|
161
161
|
#
|
|
162
162
|
|
|
@@ -356,7 +356,7 @@ Name | Type | Description | Default Value
|
|
|
356
356
|
|
|
357
357
|
## 💻 Command line usage
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
**generate-ip** can also be used directly from the command line. The basic command is:
|
|
360
360
|
|
|
361
361
|
```
|
|
362
362
|
$ generate-ip
|
|
@@ -364,7 +364,7 @@ $ generate-ip
|
|
|
364
364
|
|
|
365
365
|
Sample output:
|
|
366
366
|
|
|
367
|
-
<img src="https://
|
|
367
|
+
<img src="https://cdn.jsdelivr.net/gh/adamlui/js-utils@5c34563/generate-ip/assets/images/screenshots/cli/generate-ip-cmd-output.png">
|
|
368
368
|
|
|
369
369
|
📝 **Note:** To generate other address types, type `generate-ipv6` or `generate-mac`
|
|
370
370
|
|
|
@@ -389,6 +389,8 @@ Commands:
|
|
|
389
389
|
-i, --init Create config file (in project root).
|
|
390
390
|
-h, --help Display help screen.
|
|
391
391
|
-v, --version Show version number.
|
|
392
|
+
--stats Show npm stats.
|
|
393
|
+
--debug [targetKey] Show debug logs.
|
|
392
394
|
```
|
|
393
395
|
|
|
394
396
|
#
|
|
@@ -439,7 +441,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
439
441
|
[CLI usage](https://docs.generatepw.org/#-command-line-usage) /
|
|
440
442
|
[Discuss](https://github.com/adamlui/js-utils/discussions)
|
|
441
443
|
|
|
442
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
444
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/adamlui/js-utils@0d3424a/geolocate/assets/images/icons/wire-globe/white/icon32.png"><img height=22 src="https://cdn.jsdelivr.net/gh/adamlui/js-utils@0d3424a/geolocate/assets/images/icons/wire-globe/black/icon32.png"></picture> [geolocate](https://js-utils.org/geolocate) <a href="https://github.com/toolleeo/cli-apps#networking"><img height=18 src="https://assets.js-utils.org/images/badges/awesome/badge.svg?v=0d36e26"></a>
|
|
443
445
|
|
|
444
446
|
> Fetch IP geolocation data from the CLI.
|
|
445
447
|
<br>[Install](https://docs.geolocatejs.org/#-installation) /
|
package/bin/gen-ip
ADDED
package/bin/gen-ipv4
ADDED
package/bin/gen-ipv6
ADDED
package/bin/gen-mac
ADDED
package/bin/genip
ADDED
package/bin/genipv4
ADDED
package/bin/genipv6
ADDED
package/bin/genmac
ADDED
package/dist/cli/index.js
CHANGED
|
@@ -3,17 +3,14 @@
|
|
|
3
3
|
(async () => {
|
|
4
4
|
'use strict'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
env.debugMode = env.args.some(arg => /^--?debug(?:-?mode)?$/.test(arg))
|
|
6
|
+
// Init ENV
|
|
7
|
+
const init = require('./lib/init')
|
|
8
|
+
init.env()
|
|
11
9
|
|
|
12
10
|
// Import LIBS
|
|
11
|
+
globalThis.log = require('./lib/log')
|
|
13
12
|
const clipboardy = require('node-clipboardy'),
|
|
14
|
-
generateIP = require(`../generate-ip${ env.
|
|
15
|
-
init = require('./lib/init'),
|
|
16
|
-
log = require('./lib/log')
|
|
13
|
+
generateIP = require(`../generate-ip${ env.modes.dev ? '' : '.min' }.js`)
|
|
17
14
|
|
|
18
15
|
await init.cli()
|
|
19
16
|
|
|
@@ -21,6 +18,7 @@
|
|
|
21
18
|
if (cli.config.init) return init.configFile()
|
|
22
19
|
else if (cli.config.help) return log.help()
|
|
23
20
|
else if (cli.config.version) return log.version()
|
|
21
|
+
else if (cli.config.stats) return log.stats()
|
|
24
22
|
|
|
25
23
|
// Log/copy random IP(s)
|
|
26
24
|
const genOptions = {
|
|
@@ -29,7 +27,8 @@
|
|
|
29
27
|
network: cli.config.network,
|
|
30
28
|
verbose: !cli.config.quietMode
|
|
31
29
|
}
|
|
30
|
+
log.break()
|
|
32
31
|
clipboardy.writeSync([].concat(generateIP[cli.config.mode || 'ipv4'].generate(genOptions)).join('\n'))
|
|
33
|
-
log.ifNotQuiet(
|
|
32
|
+
log.ifNotQuiet(`${cli.msgs.info_copyingToClip}...`)
|
|
34
33
|
|
|
35
34
|
})()
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const color = module.exports = {
|
|
2
|
+
nc: '\x1b[0m',
|
|
3
|
+
hex: {
|
|
4
|
+
br: '#ff0000', by: '#ffff00', bo: '#ffa500', bg: '#00ff00',
|
|
5
|
+
bw: '#ffffff', gry: '#808080', blk: '#000000', tlBG: '#008080'
|
|
6
|
+
},
|
|
7
|
+
schemes: {
|
|
8
|
+
get default() {
|
|
9
|
+
return [
|
|
10
|
+
'#00e5bc', '#18c8ae', '#30ac9f', '#488f91', '#607383',
|
|
11
|
+
'#775674', '#8f3966', '#a71d57', '#bf0049', '#9a1b5e'
|
|
12
|
+
].map(color.hexToANSI)
|
|
13
|
+
},
|
|
14
|
+
get rainbow() {
|
|
15
|
+
return [
|
|
16
|
+
'#e41a1c', '#ff7f00', '#ffff33', '#4daf4a', '#377eb8',
|
|
17
|
+
'#984ea3', '#f781bf', '#999999', '#a65628', '#d95f02'
|
|
18
|
+
].map(color.hexToANSI)
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
hexToANSI(hex) {
|
|
23
|
+
const r = parseInt(hex.slice(1,3), 16),
|
|
24
|
+
g = parseInt(hex.slice(3,5), 16),
|
|
25
|
+
b = parseInt(hex.slice(5,7), 16)
|
|
26
|
+
return `\x1b[38;2;${r};${g};${b}m`
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
for (const hexKey of Object.keys(color.hex)) // add color[hexKey] getters that return ANSI
|
|
31
|
+
Object.defineProperty(color, hexKey, { get: () => color.hexToANSI(color.hex[hexKey]) })
|
package/dist/cli/lib/data.js
CHANGED
|
@@ -15,7 +15,7 @@ module.exports = {
|
|
|
15
15
|
require(protocol).get(url, resp => {
|
|
16
16
|
let rawData = ''
|
|
17
17
|
resp.on('data', chunk => rawData += chunk)
|
|
18
|
-
resp.on('end', () => resolve({ json: () => JSON.parse(rawData) }))
|
|
18
|
+
resp.on('end', () => resolve({ json: () => JSON.parse(rawData), text: () => rawData }))
|
|
19
19
|
}).on('error', reject)
|
|
20
20
|
}) : fetch(url) // using Node.js fetch()
|
|
21
21
|
},
|
package/dist/cli/lib/init.js
CHANGED
|
@@ -1,44 +1,51 @@
|
|
|
1
|
-
const language = require('./language'),
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
cli.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
const language = require('./language'),
|
|
2
|
+
settings = require('./settings')
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
|
|
6
|
+
async cli() {
|
|
7
|
+
Object.assign(globalThis.cli ??= {}, require(`${env.paths.libData}/package-data.json`))
|
|
8
|
+
cli.msgs = await language.getMsgs('en')
|
|
9
|
+
cli.msgs = await language.getMsgs(cli.lang = settings.load('uiLang') || (
|
|
10
|
+
env.modes.debug ? language.generateRandomLang({ excludes: ['en'] }) : language.getSysLang() ))
|
|
11
|
+
cli.urls.cliDocs ||= `${cli.urls.docs}/#-command-line-usage`
|
|
12
|
+
settings.load() // all keys to cli.config
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
async configFile(filename = settings.configFilename) {
|
|
16
|
+
const fs = require('fs'),
|
|
17
|
+
path = require('path'),
|
|
18
|
+
paths = { target: path.resolve(process.cwd(), filename) }
|
|
19
|
+
|
|
20
|
+
if (fs.existsSync(paths.target)) // use existing config file
|
|
21
|
+
return log.warn(`${cli.msgs.warn_configFileExists}:`, paths.target)
|
|
22
|
+
if (fs.existsSync(paths.src = path.resolve(__dirname, `${env.paths.libData}/${filename}`)))
|
|
23
|
+
fs.copyFileSync(paths.src, paths.target) // use found template
|
|
24
|
+
|
|
25
|
+
else { // use jsDelivr copy
|
|
26
|
+
const jsdURL = `${require('./jsdelivr').getPkgVerURL()}/${filename}`
|
|
27
|
+
log.data(`${cli.msgs.info_fetchingRemoteConfigFrom} ${jsdURL}...`)
|
|
28
|
+
try {
|
|
29
|
+
const data = require('./data'),
|
|
30
|
+
resp = await data.fetch(jsdURL)
|
|
31
|
+
if (resp.ok) data.atomicWrite(paths.target, await resp.text())
|
|
32
|
+
else return log.warn(`${cli.msgs.warn_remoteConfigNotFound}: ${jsdURL} (${resp.status})`)
|
|
33
|
+
} catch (err) {
|
|
34
|
+
return log.warn(`${cli.msgs.warn_remoteConfigFailed}: ${jsdURL} ${err.message}`) }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
log.success(`${cli.msgs.info_configFileCreated}: ${paths.target}\n`)
|
|
38
|
+
log.tip(`${cli.msgs.tip_editToSetDefaults}.`)
|
|
39
|
+
log.tip(`${cli.msgs.tip_cliArgsPrioritized}.`)
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
env() {
|
|
43
|
+
Object.assign(globalThis.env ??= {}, {
|
|
44
|
+
args: process.argv.slice(2),
|
|
45
|
+
modes: { dev: /[\\/]src(?:[\\/]|$)/i.test(__dirname) },
|
|
46
|
+
supports: { unicode: require('is-unicode-supported').default() }
|
|
47
|
+
})
|
|
48
|
+
env.modes.debug = env.args.some(arg => /^--?(?:V|debug(?:[-_]?mode)?)$/.test(arg))
|
|
49
|
+
env.paths = { libData: `../../${ env.modes.dev ? '..' : 'data' }` }
|
|
50
|
+
}
|
|
51
|
+
}
|
package/dist/cli/lib/jsdelivr.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
version ||= cli.version ||= require('./pkg').getVer('local') || 'none'
|
|
5
|
-
const verTag = !/^\d+\.\d+\.\d+$/.test(version) ? 'latest' : `${cli.name}-${version}`
|
|
6
|
-
return `${cli.urls.jsdelivr}@${verTag}/${cli.name}`
|
|
7
|
-
},
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
|
|
3
|
+
getPkgVerURL(version) {
|
|
4
|
+
version ||= cli.version ||= require('./pkg').getVer('local') || 'none'
|
|
5
|
+
const verTag = !/^\d+\.\d+\.\d+$/.test(version) ? 'latest' : `${cli.name}-${version}`
|
|
6
|
+
return `${cli.urls.jsdelivr}@${verTag}/${cli.name}`
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
getCommitURL(hash = 'latest') { return `${cli.urls.jsdelivr}@${hash}/${cli.name}` }
|
|
10
|
+
}
|
package/dist/cli/lib/language.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const data = require('./data')
|
|
2
|
-
log = require('./log')
|
|
1
|
+
const data = require('./data')
|
|
3
2
|
|
|
4
3
|
module.exports = {
|
|
5
4
|
|
|
@@ -14,13 +13,13 @@ module.exports = {
|
|
|
14
13
|
let locales = includes.length ? includes : (() => {
|
|
15
14
|
|
|
16
15
|
// Read cache if found
|
|
17
|
-
const cacheDir = path.join(__dirname, '
|
|
16
|
+
const cacheDir = path.join(__dirname, '../../.cache'),
|
|
18
17
|
localeCache = path.join(cacheDir, 'locales.json')
|
|
19
18
|
if (fs.existsSync(localeCache))
|
|
20
19
|
try { return JSON.parse(fs.readFileSync(localeCache, 'utf8')) } catch (err) {}
|
|
21
20
|
|
|
22
21
|
// Discover pkg _locales
|
|
23
|
-
const localesDir = path.resolve(
|
|
22
|
+
const localesDir = path.resolve(__dirname, '../../../_locales')
|
|
24
23
|
if (!fs.existsSync(localesDir)) return ['en']
|
|
25
24
|
const locales = fs.readdirSync(localesDir, { withFileTypes: true })
|
|
26
25
|
.filter(entry => entry.isDirectory()).map(entry => entry.name)
|
|
@@ -38,10 +37,8 @@ module.exports = {
|
|
|
38
37
|
locales = locales.filter(locale => !excludeSet.has(locale))
|
|
39
38
|
|
|
40
39
|
// Get random language
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
randomLang = locales[Math.floor(Math.random() * locales.length)]
|
|
44
|
-
log.debug(`Random language: ${randomLang}\n`)
|
|
40
|
+
const randomLang = locales.length ? locales[Math.floor(Math.random() * locales.length)] : 'en'
|
|
41
|
+
log.debug(`Random language: ${randomLang}`)
|
|
45
42
|
|
|
46
43
|
return randomLang
|
|
47
44
|
},
|
|
@@ -51,20 +48,29 @@ module.exports = {
|
|
|
51
48
|
if (env.msgs && langCode == cli.lang) return env.msgs // don't re-fetch same msgs
|
|
52
49
|
|
|
53
50
|
let msgs = data.flatten( // local ones
|
|
54
|
-
require(`../../${ env.
|
|
51
|
+
require(`../../${ env.modes.dev ? '../_locales/en' : 'data' }/messages.json`))
|
|
55
52
|
|
|
56
53
|
if (!langCode.startsWith('en')) { // fetch non-English msgs from jsDelivr
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
try { // check if terminal supports non-Latin scripts
|
|
55
|
+
const nonLatinLocales = await (await data.fetch(
|
|
56
|
+
`${cli.urls.jsdelivr}@${cli.commitHashes.data}/assets/data/non-latin-locales.json`
|
|
57
|
+
)).json()
|
|
58
|
+
if (nonLatinLocales.includes(langCode.split('-')[0]) && !env.supports.unicode)
|
|
59
|
+
return msgs // en ones
|
|
60
|
+
} catch (err) {
|
|
61
|
+
log.debug(`Failed to fetch non-Latin locales: ${err}`)
|
|
62
|
+
}
|
|
63
|
+
const msgBaseURL = `${require('./jsdelivr').getCommitURL(cli.commitHashes.locales)}/_locales`
|
|
64
|
+
let msgURL = `${msgBaseURL}/${langCode}/messages.json`, msgFetchesTried = 0
|
|
59
65
|
while (msgFetchesTried < 3)
|
|
60
66
|
try { // fetch remote msgs
|
|
61
|
-
msgs = data.flatten(await (await data.fetch(
|
|
67
|
+
msgs = data.flatten(await (await data.fetch(msgURL)).json())
|
|
62
68
|
break
|
|
63
69
|
} catch (err) { // retry up to 2X (region-stripped + EN)
|
|
64
70
|
msgFetchesTried++ ; if (msgFetchesTried >= 3) break
|
|
65
|
-
log.debug(
|
|
66
|
-
|
|
67
|
-
: `${
|
|
71
|
+
log.debug(msgURL = langCode.includes('-') && msgFetchesTried == 1 ?
|
|
72
|
+
msgURL.replace(/([^_]*)_[^/]*(\/.*)/, '$1$2') // strip region before retrying
|
|
73
|
+
: `${msgBaseURL}/en/messages.json` // else use EN msgs
|
|
68
74
|
)
|
|
69
75
|
}
|
|
70
76
|
}
|
package/dist/cli/lib/log.js
CHANGED
|
@@ -1,35 +1,61 @@
|
|
|
1
|
+
const colors = require('./color'),
|
|
2
|
+
{ getDownloads, getVer } = require('./pkg'),
|
|
3
|
+
settings = require('./settings'),
|
|
4
|
+
string = require('./string')
|
|
5
|
+
|
|
6
|
+
const nextMajVer = require('../../../package.json').version.replace(/^(\d+)\..*/, (_, major) => `${ +major +1 }.0.0`)
|
|
7
|
+
|
|
1
8
|
module.exports = {
|
|
9
|
+
colors,
|
|
2
10
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
break() { console.log() },
|
|
12
|
+
configURL() { this.info(`${cli.msgs.info_exampleValidConfigFile}: ${cli.urls.config}`) },
|
|
13
|
+
configURLandExit(...args) { this.error(...args); this.configURL(); process.exit(1) },
|
|
14
|
+
data(msg) { console.log(`\n${colors.bw}${msg}${colors.nc}`) },
|
|
15
|
+
dim(msg) { console.log(`${colors.gry}${msg}${colors.nc}`) },
|
|
16
|
+
error(...args) { console.error(`\n${colors.br}ERROR:`, ...args, colors.nc) },
|
|
17
|
+
errorAndExit(...args) { this.error(...args); this.helpDocsCmdsDocsURL(); process.exit(1) },
|
|
18
|
+
ifNotQuiet(msg) { if (!cli.config.quietMode) this.info(msg) },
|
|
19
|
+
info(msg) { console.info(`\n${colors.schemes.default[0]}${msg}${colors.nc}`) },
|
|
20
|
+
success(msg) { console.log(`\n${colors.bg}${msg}${colors.nc}`) },
|
|
21
|
+
tip(msg) { console.info(`${colors.by}TIP: ${msg}${colors.nc}`) },
|
|
22
|
+
warn(...args) { console.warn(`\n${colors.bo}WARNING:`, ...args, colors.nc) },
|
|
23
|
+
|
|
24
|
+
argDoesNothing(arg) {
|
|
25
|
+
this.warn(`${cli.msgs.warn_option} ${arg} ${cli.msgs.warn_noLongerHasAnyEffect} ${
|
|
26
|
+
cli.msgs.warn_andWillBeRemoved} @ v${nextMajVer}`)
|
|
13
27
|
},
|
|
14
28
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
configKeyReplacedBy(oldKey, newKey, oldVal) {
|
|
30
|
+
if (!this[`${oldKey}Warned`]) {
|
|
31
|
+
this.warn(
|
|
32
|
+
`${cli.msgs.info_configFile} ${cli.msgs.warn_option.toLowerCase()} '${oldKey}: ${oldVal}' ${
|
|
33
|
+
cli.msgs.warn_hasBeenReplacedBy} '${
|
|
34
|
+
newKey}: ${ settings.isNegKey(oldKey) != settings.isNegKey(newKey) ? !oldVal : oldVal }' ${
|
|
35
|
+
cli.msgs.warn_andWillBeRemoved} @ v${nextMajVer}`
|
|
36
|
+
)
|
|
37
|
+
this[`${oldKey}Warned`] = true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
debug(msg) {
|
|
42
|
+
if (!env.modes.debug) return
|
|
43
|
+
this.argIdx ??= env.args.findIndex(arg => /^--?(?:V|debug(?:[-_]?mode)?)$/.test(arg))
|
|
44
|
+
if (this.argIdx +1 < env.args.length && !env.args[this.argIdx +1].startsWith('-')) // use --debug [targetKey]
|
|
45
|
+
this.key ??= env.args[this.argIdx +1].replace('-', '_')
|
|
46
|
+
if (this.key)
|
|
47
|
+
this.val = cli.config[this.key] || `cli.config key "${this.key}" ${cli.msgs.warn_notFound.toLowerCase()}`
|
|
48
|
+
else
|
|
49
|
+
this.val = cli.config
|
|
50
|
+
msg += `\n${colors.gry}${JSON.stringify(this.val)}${colors.nc}`
|
|
51
|
+
console.debug(`\n${colors.by}DEBUG:`, msg, colors.nc)
|
|
52
|
+
},
|
|
27
53
|
|
|
28
54
|
help(includeSections = ['header', 'usage', 'params', 'flags', 'cmds']) {
|
|
29
55
|
cli.prefix = `${this.colors.tlBG}${this.colors.blk}\x1b[30m ${cli.name} ${this.colors.nc} `
|
|
30
56
|
const helpSections = {
|
|
31
57
|
header: [
|
|
32
|
-
`\n├ ${cli.prefix}${cli.msgs.
|
|
58
|
+
`\n├ ${cli.prefix}${cli.msgs.pkg_copyright}.`,
|
|
33
59
|
`${cli.prefix}${cli.msgs.prefix_source}: ${cli.urls.src}`
|
|
34
60
|
],
|
|
35
61
|
usage: [
|
|
@@ -54,7 +80,9 @@ module.exports = {
|
|
|
54
80
|
`\n${this.colors.bw}o ${cli.msgs.helpSection_cmds}:${this.colors.nc}`,
|
|
55
81
|
` -i, --init ${cli.msgs.optionDesc_init}.`,
|
|
56
82
|
` -h, --help ${cli.msgs.optionDesc_help}.`,
|
|
57
|
-
` -v, --version ${cli.msgs.optionDesc_version}
|
|
83
|
+
` -v, --version ${cli.msgs.optionDesc_version}.`,
|
|
84
|
+
` -v, --stats ${cli.msgs.optionDesc_stats}.`,
|
|
85
|
+
` -V, --debug ${cli.msgs.optionDesc_debug}.`
|
|
58
86
|
]
|
|
59
87
|
}
|
|
60
88
|
includeSections.forEach(section => // print valid arg elems
|
|
@@ -87,16 +115,44 @@ module.exports = {
|
|
|
87
115
|
}
|
|
88
116
|
},
|
|
89
117
|
|
|
90
|
-
|
|
118
|
+
helpDocsCmdsDocsURL() {
|
|
91
119
|
console.info(`\n${
|
|
92
|
-
cli.msgs.info_moreHelp}, ${cli.msgs.info_type} ${
|
|
93
|
-
|
|
94
|
-
|
|
120
|
+
cli.msgs.info_moreHelp}, ${cli.msgs.info_type} ${
|
|
121
|
+
colors.bw}${cli.name} --<docs|help>${colors.nc} ${
|
|
122
|
+
cli.msgs.info_or} ${cli.msgs.info_visit}\n${colors.by}${cli.urls.docs}${colors.nc}`
|
|
95
123
|
)
|
|
96
124
|
},
|
|
97
125
|
|
|
126
|
+
initCmd(invalidKey) {
|
|
127
|
+
if (invalidKey)
|
|
128
|
+
this.warn(
|
|
129
|
+
`${cli.msgs.error_invalidKey} '${invalidKey}' ${cli.msgs.error_foundIn}\n`
|
|
130
|
+
+ `${log.colors.gry}${cli.configPath}`
|
|
131
|
+
)
|
|
132
|
+
if (!this.initTipped) {
|
|
133
|
+
this.break()
|
|
134
|
+
this.tip(`${
|
|
135
|
+
string.toTitleCase(cli.msgs.info_type)} '${cli.name} init' ${
|
|
136
|
+
cli.msgs.info_toCreateDefaultConfig}`
|
|
137
|
+
)
|
|
138
|
+
this.initTipped = true
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
invalidConfigKey(key) { if (!this[`${key}Tipped`]) { this.initCmd(key) ; this[`${key}Tipped`] = true } },
|
|
143
|
+
|
|
144
|
+
async stats(pkgName = cli.name, options = { ecosystem: 'npm', maxDays: 8, maxVers: 5, scheme: 'default' }) {
|
|
145
|
+
const pkgStats = await getDownloads(pkgName, options),
|
|
146
|
+
schemeData = colors.schemes[options.scheme]
|
|
147
|
+
if (!schemeData) return this.error(`Scheme '${options.scheme}' not found!`)
|
|
148
|
+
const colorMap = Object.fromEntries(schemeData.map((hex, idx) => [`c${idx}`, hex])),
|
|
149
|
+
statsTable = new (require('console-table-printer').Table)({ colorMap })
|
|
150
|
+
pkgStats.forEach((row, idx) => // build colored rows
|
|
151
|
+
statsTable.addRow(row, { color: `c${Math.floor(idx / pkgStats.length * schemeData.length)}` }))
|
|
152
|
+
statsTable.printTable()
|
|
153
|
+
},
|
|
154
|
+
|
|
98
155
|
version() {
|
|
99
|
-
const { getVer } = require('./pkg')
|
|
100
156
|
this.info(cli.name)
|
|
101
157
|
this.data(`${
|
|
102
158
|
cli.msgs.prefix_globalVer}: ${ getVer('global') || 'none' }\n${
|
package/dist/cli/lib/pkg.js
CHANGED
|
@@ -1,20 +1,78 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
1
|
+
const data = require('./data')
|
|
2
|
+
|
|
3
|
+
const endpoints = {
|
|
4
|
+
npmjsDLs: 'https://api.npmjs.org/downloads',
|
|
5
|
+
pepyProjects: 'https://pepy.tech/projects'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
|
|
10
|
+
async getDownloads(
|
|
11
|
+
pkgName, // e.g. some-npm-pkg, npm:@adamlui/minify.js, pypi:translate-messages
|
|
12
|
+
{ ecosystem = 'npm', maxDays = 10, maxVers = 10 } = {}
|
|
13
|
+
) {
|
|
14
|
+
if (pkgName.includes(':')) [ecosystem, pkgName] = pkgName.split(':')
|
|
15
|
+
|
|
16
|
+
if (/npm|node/i.test(ecosystem)) { // fetch from endpoints.npmjsDLs
|
|
17
|
+
function formatDate(date) { return date.toISOString().split('T')[0] }
|
|
18
|
+
const dates = { end: new Date(), start: new Date() }
|
|
19
|
+
dates.start.setMonth(dates.end.getMonth() -3)
|
|
20
|
+
const npmjsURL = `${endpoints.npmjsDLs}/range/${formatDate(dates.start)}:${formatDate(dates.end)}/${pkgName}`
|
|
21
|
+
log.info(`Fetching npm stats for ${pkgName}${
|
|
22
|
+
env.modes.debug ? ` from\n${log.colors.bw}${npmjsURL}` : '' }...\n`)
|
|
23
|
+
return (await (await data.fetch(npmjsURL)).json()).downloads // { downloads: [{ day, downloads }] }
|
|
24
|
+
.sort((a, b) => new Date(b.day) - new Date(a.day)) // new ⇅ old
|
|
25
|
+
.slice(0, maxDays) // cap rows
|
|
26
|
+
.map(({ day: date, downloads }) => ({ date, downloads }))
|
|
27
|
+
|
|
28
|
+
} else if (/^py/i.test(ecosystem)) { // fetch from endpoints.pepyProjects
|
|
29
|
+
let rows = []
|
|
30
|
+
const pepyURL = `${endpoints.pepyProjects}/${pkgName}`
|
|
31
|
+
log.info(`Fetching PyPI/mirror stats for ${pkgName}${
|
|
32
|
+
env.modes.debug ? ` from\n${log.colors.bw}${pepyURL}` : '' }...\n`)
|
|
33
|
+
const respText = await (await data.fetch(pepyURL)).text(),
|
|
34
|
+
rePush = /self\.__next_f\.push\(\[\d+,\s*"((?:\\.|[^"\\])*)"\]\)/g
|
|
35
|
+
let downloads = {}, match
|
|
36
|
+
while ((match = rePush.exec(respText))) {
|
|
37
|
+
try { // extract project.downloads
|
|
38
|
+
const inner = JSON.parse(`"${match[1]}"`),
|
|
39
|
+
data = JSON.parse(inner.substring(inner.indexOf(':') +1))
|
|
40
|
+
if (data[3]?.project) downloads = data[3].project.downloads
|
|
41
|
+
} catch (err) {}
|
|
42
|
+
}
|
|
43
|
+
rows = Object.entries(downloads)
|
|
44
|
+
.sort(([a], [b]) => new Date(b) - new Date(a)) // new ⇅ old
|
|
45
|
+
.slice(0, maxDays) // cap rows
|
|
46
|
+
.map(([date, data]) => ({ date, ...data }))
|
|
47
|
+
const activeVers = new Set()
|
|
48
|
+
rows.forEach(row => Object.keys(row).forEach(key => {
|
|
49
|
+
if (key != 'date' && row[key] > 0) activeVers.add(key) }))
|
|
50
|
+
const finalVers = [...activeVers]
|
|
51
|
+
.sort((a, b) => b.localeCompare(a, undefined, { numeric: true })) // new ⇆ old
|
|
52
|
+
.slice(0, maxVers) // cap columns
|
|
53
|
+
return rows.map(row => {
|
|
54
|
+
const result = { date: row.date }
|
|
55
|
+
finalVers.forEach(ver => result[ver] = row[ver] || 0)
|
|
56
|
+
return result
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
} else return log.debug(`${ecosystem} not supported.`)
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
getVer(type = 'any') { // or <'global'|'local'>
|
|
63
|
+
let pkgVer
|
|
64
|
+
if (type != 'global')
|
|
65
|
+
try { // get local ver
|
|
66
|
+
const localManifestPath = require('path').resolve(
|
|
67
|
+
process.cwd(), 'node_modules', cli.name, 'package.json')
|
|
68
|
+
pkgVer = require(localManifestPath).version
|
|
69
|
+
} catch (err) { log.debug(`${cli.msgs.error_readingLocalPkgVer}: ${err.message}`) }
|
|
70
|
+
if (type == 'global' || type == 'all' && !pkgVer)
|
|
71
|
+
try { // get global ver
|
|
72
|
+
pkgVer = require('child_process').execSync(
|
|
73
|
+
`npm view ${JSON.stringify(cli.name)} version`
|
|
74
|
+
).toString().trim()
|
|
75
|
+
} catch (err) { log.debug(`${cli.msgs.error_failedToFetchGlobalVer}: ${err.message}`) }
|
|
76
|
+
return pkgVer
|
|
77
|
+
}
|
|
78
|
+
}
|
package/dist/cli/lib/settings.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const fs = require('fs'),
|
|
2
|
-
log = require('./log'),
|
|
3
2
|
path = require('path')
|
|
4
3
|
|
|
5
4
|
;(globalThis.cli ??= {}).config = {}
|
|
@@ -8,28 +7,32 @@ module.exports = {
|
|
|
8
7
|
configFilename: 'generate-ip.config.mjs',
|
|
9
8
|
|
|
10
9
|
controls: {
|
|
11
|
-
qty: { type: 'param', valType: 'positiveInt', defaultVal: 1, regex: /^--?qu?a?n?ti?t?y(
|
|
12
|
-
network: { type: 'param', regex: /^--network(
|
|
13
|
-
uiLang: { type: 'param', valType: 'langCode', regex: /^--?ui[-_]?lang(
|
|
14
|
-
config: { type: 'param', valType: 'filepath', regex: /^--?config(
|
|
10
|
+
qty: { type: 'param', valType: 'positiveInt', defaultVal: 1, regex: /^--?qu?a?n?ti?t?y(?:[=\s].*|$)/ },
|
|
11
|
+
network: { type: 'param', regex: /^--network(?:[=\s].*|$)/ },
|
|
12
|
+
uiLang: { type: 'param', valType: 'langCode', regex: /^--?ui[-_]?lang(?:[=\s].*|$)/ },
|
|
13
|
+
config: { type: 'param', valType: 'filepath', regex: /^--?config(?:[=\s].*|$)/ },
|
|
15
14
|
ipv6mode: { type: 'flag', mode: true, regex: /^--?(?:ip)?v?6(?:[-_]?mode)?$/ },
|
|
16
15
|
macMode: { type: 'flag', mode: true, regex: /^--?m(?:ac)?(?:[-_]?mode)?$/ },
|
|
17
16
|
quietMode: { type: 'flag', regex: /^--?q(?:uiet)?(?:[-_]?mode)?$/ },
|
|
18
17
|
sequential: { type: 'flag', regex: /^--(?:s|equen(?:tial|ce))$/ },
|
|
19
18
|
init: { type: 'cmd', regex: /^-{0,2}i(?:nit)?$/ },
|
|
20
19
|
help: { type: 'cmd', regex: /^--?h(?:elp)?$/ },
|
|
21
|
-
version: { type: 'cmd', regex: /^--?ve?r?s?i?o?n?$/ }
|
|
20
|
+
version: { type: 'cmd', regex: /^--?ve?r?s?i?o?n?$/ },
|
|
21
|
+
stats: { type: 'cmd', regex: /^--?stats?$/ }
|
|
22
22
|
},
|
|
23
23
|
|
|
24
|
+
isNegKey(key) { return /^(?:no|disable|exclude)[A-Z]/.test(key) },
|
|
25
|
+
|
|
24
26
|
load(ctrlKeys = Object.keys(this.controls)) {
|
|
25
27
|
const inputCtrlKeys = [].concat(ctrlKeys) // force array
|
|
26
28
|
|
|
27
29
|
if (!cli.defaultsSet && !arguments.length) { // init all defaults on arg-less load()
|
|
28
30
|
inputCtrlKeys.forEach(key => {
|
|
29
|
-
const ctrl = this.controls[key] ; if (ctrl.mode) return
|
|
31
|
+
const ctrl = this.controls[key] ; if (ctrl.mode || key.startsWith('legacy_')) return
|
|
30
32
|
cli.config[key] ??= ctrl.defaultVal ?? ( ctrl.type == 'param' ? '' : false )
|
|
31
33
|
})
|
|
32
34
|
cli.defaultsSet = true
|
|
35
|
+
log.debug('All cli.config default vals set!')
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
if (!cli.configPathTried) { // init config file path
|
|
@@ -57,26 +60,50 @@ module.exports = {
|
|
|
57
60
|
const mod = require(cli.configPath), fileConfig = mod?.default ?? mod
|
|
58
61
|
if (!fileConfig || typeof fileConfig != 'object')
|
|
59
62
|
log.configURLandExit(`${cli.msgs.error_invalidConfigFile}.`)
|
|
60
|
-
Object.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
;(arguments.length ? inputCtrlKeys : Object.keys(fileConfig)).forEach(key => {
|
|
64
|
+
if (!(key in fileConfig)) return
|
|
65
|
+
const val = fileConfig[key], ctrl = this.controls[key]
|
|
66
|
+
if (!ctrl) {
|
|
67
|
+
if (this.configFileKeyWhitelist && !this.configFileKeyWhitelist.includes(key))
|
|
68
|
+
log.invalidConfigKey(key)
|
|
69
|
+
return
|
|
70
|
+
} else if (key.startsWith('legacy_') && ctrl.replacedBy) {
|
|
71
|
+
if (this.isNegKey(key) != this.isNegKey(ctrl.replacedBy))
|
|
72
|
+
cli.config[ctrl.replacedBy] = !val // assign opposite val to current key
|
|
73
|
+
else // assign direct val to current key
|
|
74
|
+
cli.config[ctrl.replacedBy] = val
|
|
75
|
+
return log.configKeyReplacedBy(key, ctrl.replacedBy, val)
|
|
76
|
+
}
|
|
77
|
+
cli.config[key] = val
|
|
78
|
+
})
|
|
79
|
+
if (!arguments.length) log.debug('Config file loaded!')
|
|
64
80
|
} catch (err) {
|
|
65
81
|
log.configURLandExit(`${cli.msgs.error_failedToLoadConfigFile}:`, cli.configPath, `\n${err.message}`) }
|
|
66
82
|
|
|
67
|
-
env.args.
|
|
68
|
-
|
|
83
|
+
for (let i = 0 ; i < env.args.length ; i++) { // load from CLI arg (overriding config file loads)
|
|
84
|
+
const arg = env.args[i]
|
|
85
|
+
if (/^[^-]|--?(?:config|debug)/.test(arg) && arg != 'init') continue
|
|
69
86
|
const ctrlKey = Object.keys(this.controls).find(key => this.controls[key]?.regex?.test(arg))
|
|
70
87
|
if (!ctrlKey && cli.msgs) log.errorAndExit(`[${arg}] ${cli.msgs.error_notRecognized}.`)
|
|
71
88
|
if (!inputCtrlKeys.includes(ctrlKey)) return // don't process env.args when load() specific keys
|
|
89
|
+
if (ctrlKey.startsWith('legacy_')) { log.argDoesNothing(arg) ; continue }
|
|
72
90
|
const ctrl = this.controls[ctrlKey]
|
|
73
91
|
if (ctrl.mode) // set cli.config.mode to mode name
|
|
74
92
|
cli.config.mode = ctrlKey.replace(/mode$/i, '').toLowerCase()
|
|
75
|
-
else // init flag/param/cmd cli.config[ctrlKey] val
|
|
76
|
-
|
|
77
|
-
|
|
93
|
+
else { // init flag/param/cmd cli.config[ctrlKey] val
|
|
94
|
+
if (ctrl.type == 'param')
|
|
95
|
+
cli.config[ctrlKey] =
|
|
96
|
+
arg.includes('=') ? arg.split('=')[1]?.trim() || '' // =val
|
|
97
|
+
: (i +1 < env.args.length && !env.args[i +1].startsWith('-')) ? env.args[++i] // dashless val
|
|
98
|
+
: '' // val-less --param passed
|
|
99
|
+
else // flag/cmd
|
|
100
|
+
cli.config[ctrlKey] = true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!arguments.length) log.debug('Args parsed!')
|
|
78
104
|
|
|
79
105
|
this.parseValidateConfig(inputCtrlKeys)
|
|
106
|
+
if (!arguments.length) log.debug('All cli.config vals parsed/validated!')
|
|
80
107
|
|
|
81
108
|
return inputCtrlKeys.length == 1 ? cli.config[inputCtrlKeys[0]] : cli.config
|
|
82
109
|
},
|
package/dist/data/messages.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"appCopyright": { "message": "© 2024–2026 Adam Lui & contributors under the MIT license" },
|
|
2
|
+
"pkg_copyright": { "message": "© 2024–2026 Adam Lui & contributors under the MIT license" },
|
|
4
3
|
"prefix_globalVer": { "message": "Global version" },
|
|
5
4
|
"prefix_localVer": { "message": "Local version" },
|
|
6
5
|
"prefix_source": { "message": "Source" },
|
|
@@ -11,6 +10,8 @@
|
|
|
11
10
|
"error_invalidLangCode": { "message": "is an invalid language code" },
|
|
12
11
|
"error_invalidURL": { "message": "Invalid URL" },
|
|
13
12
|
"error_invalidConfigFile": { "message": "Config file must export an object" },
|
|
13
|
+
"error_invalidKey": { "message": "Invalid key" },
|
|
14
|
+
"error_foundIn": { "message": "found in" },
|
|
14
15
|
"error_configFileNotFound": { "message": "Config file not found" },
|
|
15
16
|
"error_failedToLoadConfigFile": { "message": "Failed to load config file" },
|
|
16
17
|
"error_failedToFetchGlobalVer": { "message": "Failed to fetch global version" },
|
|
@@ -21,13 +22,20 @@
|
|
|
21
22
|
"error_mustBeGreaterThanOne": { "message": "must be > 1" },
|
|
22
23
|
"warn_configFileExists": { "message": "Config file already exists" },
|
|
23
24
|
"warn_remoteConfigNotFound": { "message": "Remote config file not found" },
|
|
24
|
-
"warn_remoteConfigFailed": { "message": "Failed to fetch remote config file" },
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
25
|
+
"warn_remoteConfigFailed": { "message": "Failed to fetch remote config file" },
|
|
26
|
+
"warn_option": { "message": "Option" },
|
|
27
|
+
"warn_noLongerHasAnyEffect": { "message": "no longer has any effect" },
|
|
28
|
+
"warn_hasBeenReplacedBy": { "message": "has been replaced by" },
|
|
29
|
+
"warn_andWillBeRemoved": { "message": "and will be removed" },
|
|
30
|
+
"warn_notFound": { "message": "Not found" },
|
|
31
|
+
"info_configFile": { "message": "Config file" },
|
|
32
|
+
"info_exampleValidConfigFile": { "message": "Example valid config file" },
|
|
33
|
+
"info_copyingToClip": { "message": "Copying to clipboard" },
|
|
34
|
+
"info_moreHelp": { "message": "For more help" },
|
|
28
35
|
"info_type": { "message": "type" },
|
|
29
36
|
"info_or": { "message": "or" },
|
|
30
37
|
"info_visit": { "message": "visit" },
|
|
38
|
+
"info_toCreateDefaultConfig": { "message": "to create default config file" },
|
|
31
39
|
"info_configFileCreated": { "message": "Config file created" },
|
|
32
40
|
"info_fetchingRemoteConfigFrom": { "message": "Fetching remote config file from" },
|
|
33
41
|
"tip_editToSetDefaults": { "message": "Edit this file to customize defaults" },
|
|
@@ -46,5 +54,7 @@
|
|
|
46
54
|
"optionDesc_quiet": { "message": "Suppress all logging except errors" },
|
|
47
55
|
"optionDesc_init": { "message": "Create config file (in project root)" },
|
|
48
56
|
"optionDesc_help": { "message": "Display help screen" },
|
|
49
|
-
"optionDesc_version": { "message": "Show version number" }
|
|
57
|
+
"optionDesc_version": { "message": "Show version number" },
|
|
58
|
+
"optionDesc_stats": { "message": "Show npm stats" },
|
|
59
|
+
"optionDesc_debug": { "message": "Show debug logs" }
|
|
50
60
|
}
|
package/dist/generate-ip.min.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Source: https://github.com/adamlui/js-utils/tree/main/generate-ip/src
|
|
4
4
|
* Documentation: https://github.com/adamlui/js-utils/tree/main/generate-ip/docs
|
|
5
5
|
*/
|
|
6
|
-
Object.assign(globalThis.api??={},{name:"generate-ip",
|
|
6
|
+
Object.assign(globalThis.api??={},{name:"generate-ip",regex:{ipv4:/^ip$|v4/i,ipv6:/v6/i,mac:/^(?:mac|ethernet)$/i}});let ipv4={generate(t={}){var e="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#ipv4generateoptions",r={verbose:!0,qty:1,sequential:!1,network:null};if(_log.prefix="ipv4.generate()",_validateOptions({options:t,defaultOptions:r,helpURL:e,exampleCall:"ipv4.generate({ verbose: false, qty: 3 })"})){(t={...r,...t}).verbose&&_log.info(`Generating IPv4 address${1<t.qty?"es":""}...`);var o=[];if(t.sequential){t.network&&this.validate(t.network)?(!t.qty||t.qty<=1)&&_log.errHelpURLandThrow({helpURL:e,errMsg:"options.qty must be > 1 when options.sequential is `true`."}):_log.errHelpURLandThrow({helpURL:e,errMsg:"options.network must be a valid IP when options.sequential is `true`."});var[i,a,s,l]=t.network.split(".").map(Number);for(let e=0;e<t.qty;e++)o.push(i+`.${a}.${s}.`+(l+e))}else if(1<t.qty)for(let e=0;e<t.qty;e++)o.push(this.generate({...t,qty:1,verbose:!1}));else{var n=[];for(let e=0;e<4;e++)n.push(_random.int(0,256));o.push(n.join("."))}r=1<t.qty?o:o[0];return t.verbose&&(_log.info(`IPv4 address${1<t.qty?"es":""} generated!`),_log.info(1==t.qty?r:r.join(", "))),r}},validate(e,t={}){var r="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#ipv4validateaddress-options",o={verbose:!0};if(_log.prefix="ipv4.validate()","string"!=typeof e&&_log.errHelpURLandThrow({errMsg:"1st arg <address> must be a string.",helpURL:r}),_validateOptions({options:t,defaultOptions:o,helpURL:r,exampleCall:"ipv4.validate('0.0.255.255', { verbose: false })"}))return(t={...o,...t}).verbose&&_log.info(`Validating ${e}...`),o=!(4!=(r=e.split(".")).length||r.some(e=>!/^\d+$/.test(e)||parseInt(e,10)<0||255<parseInt(e,10))),t.verbose&&_log.info(`IP is ${o?"":"in"}valid IPv4 address!`),o}},ipv6={generate(a={}){var e="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#ipv6generateoptions",t={verbose:!0,qty:1,leadingZeros:!1,doubleColon:!0,sequential:!1,network:null};if(_log.prefix="ipv6.generate()",_validateOptions({options:a,defaultOptions:t,helpURL:e,exampleCall:"ipv6.generate({ leadingZeros: true, qty: 5 })"})){(a={...t,...a}).verbose&&_log.info(`Generating IPv6 address${1<a.qty?"es":""}...`);var s=[];if(a.sequential){a.network&&this.validate(a.network)?(!a.qty||a.qty<=1)&&_log.errHelpURLandThrow({helpURL:e,errMsg:"options.qty must be > 1 when options.sequential is `true`."}):_log.errHelpURLandThrow({helpURL:e,errMsg:"options.network must be a valid IP when options.sequential is `true`."});var r=a.network.split(":").map(e=>parseInt(e,16)||0);for(let e=0;e<a.qty;e++){var o=r[7];r[7]=o+e,r[7]>o+1&&(r[7]=o+1),s.push(r.map(e=>e.toString(16).padStart(4,"0")).join(":"))}}else if(1<a.qty)for(let e=0;e<a.qty;e++)s.push(this.generate({...a,qty:1,verbose:!1}));else{let t=[],{qty:e,sequential:r,network:o,...i}=a;for(let e=0;e<8;e++)t.push(_random.hex(4));s.push(this.format(t.join(":"),{...i,verbose:!1}))}t=1<a.qty?s:s[0];return a.verbose&&(_log.info(`IPv6 address${1<a.qty?"es":""} generated!`),_log.info(1==a.qty?t:t.join(", "))),t}},format(t,r={}){var o="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#ipv6formatipv6address-options",i={verbose:!0,leadingZeros:!1,doubleColon:!0};if(_log.prefix="ipv6.format()","string"!=typeof t&&_log.errHelpURLandThrow({errMsg:"1st arg <ipv6address> must be a string.",helpURL:o}),this.validate(t,{verbose:!1})||_log.errHelpURLandThrow({errMsg:t+" is not a valid IPv6 address.",helpURL:o}),_validateOptions({options:r,defaultOptions:i,helpURL:o,exampleCall:"ipv6.format('0d::ffff:192.1.56.10/96', { leadingZeros: true, doubleColon: false })"})){r={...i,...r};let e=t;if(e=r.doubleColon?(r.verbose&&_log.info("Replacing zero series w/ '::'..."),e.replace(/:(?:0+:)+/,"::")):(r.verbose&&_log.info("Expanding '::' into zero series..."),o=e.split(":").filter(Boolean).length,i=r.leadingZeros?"0000":"0",o=Array(8-o).fill(i).join(":"),e.replace("::",`:${o}:`)),r.leadingZeros){r.verbose&&_log.info("Adding leading zeros...");var a=e.split(":");for(let e=0;e<a.length;e++)for(;a[e].length<4;)a[e]="0"+a[e];e=a.join(":")}else r.verbose&&_log.info("Stripping leading zeros..."),e=t.replace(/(^|(?<=:))0+(?!:)/g,"$1");return r.verbose&&(e!=t?_log.info("IP formatted successfully!"):_log.info("IP already formatted to specs."),_log.info(e)),e}},validate(r,o={}){var i="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#ipv6validateaddress-options",a={verbose:!0};if(_log.prefix="ipv6.validate()","string"!=typeof r&&_log.errHelpURLandThrow({errMsg:"1st arg <address> must be a string.",helpURL:i}),_validateOptions({options:o,defaultOptions:a,helpURL:i,exampleCall:"ipv6.validate('0:0:0:0:0:ffff:192.1.56.10/96', { verbose: false })"})){(o={...a,...o}).verbose&&_log.info(`Validating ${r}...`);let e=r.split(/::?/),t=e[e.length-1];i=!(r.includes("::")&&2<r.split("::").length||/:{3,}/.test(r)||e.length<2||8<e.length||e.some(e=>!(/^[\da-f]{1,4}$/i.test(e)||e==t&&ipv4.validate(t.replace(/\/(?:12[0-8]|[1-9]?\d)$/,""),{verbose:!1}))));return o.verbose&&_log.info(`IP is ${i?"":"in"}valid IPv6 address!`),i}}},mac={generate(t={}){var e="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#macgenerateoptions",r={verbose:!0,qty:1,sequential:!1,network:null};if(_log.prefix="mac.generate()",_validateOptions({options:t,defaultOptions:r,helpURL:e,exampleCall:"mac.generate({ verbose: false, qty: 2 })"})){(t={...r,...t}).verbose&&_log.info(`Generating MAC address${1<t.qty?"es":""}...`);var o=[];if(t.sequential){t.network&&this.validate(t.network)?(!t.qty||t.qty<=1)&&_log.errHelpURLandThrow({helpURL:e,errMsg:"options.qty must be > 1 when options.sequential is `true`."}):_log.errHelpURLandThrow({helpURL:e,errMsg:"options.network must be a valid MAC when options.sequential is `true`."});var i=t.network.split(":").map(e=>parseInt(e,16)||0);for(let e=0;e<t.qty;e++){var a=i[5];i[5]=a+e,i[5]>a+1&&(i[5]=a+1),o.push(i.map(e=>e.toString(16).padStart(2,"0")).join(":"))}}else if(1<t.qty)for(let e=0;e<t.qty;e++)o.push(this.generate({...t,qty:1,verbose:!1}));else{var[r,e]=Array.from({length:2},()=>{var t=[];for(let e=0;e<3;e++)t.push(_random.hex(2));return t.join(":")});o.push(r+":"+e)}r=1<t.qty?o:o[0];return t.verbose&&(_log.info(`MAC address${1<t.qty?"es":""} generated!`),_log.info(1==t.qty?r:r.join(", "))),r}},validate(e,t={}){var r="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#macvalidateaddress-options",o={verbose:!0};if(_log.prefix="mac.validate()","string"!=typeof e&&_log.errHelpURLandThrow({errMsg:"1st arg <address> must be a string.",helpURL:r}),_validateOptions({options:t,defaultOptions:o,helpURL:r,exampleCall:"mac.validate('00:1A:2B:3C:4D:5E', { verbose: false })"}))return(t={...o,...t}).verbose&&_log.info(`Validating ${e}...`),r=/^(?:[\da-f]{2}[:-]){5}[\da-f]{2}$/i.test(e),t.verbose&&_log.info(`Address is ${r?"":"in"}valid MAC address!`),r}};function _validateOptions({options:e,defaultOptions:t,helpURL:r,exampleCall:o}){var i,a,s=Object.keys(t).filter(e=>"boolean"==typeof t[e]),l=Object.keys(t).filter(e=>Number.isInteger(t[e]));if("object"!=typeof e)return i=o.split(",").findIndex(e=>e.trim().startsWith("{"))+1,i+=["st","nd","rd"][i-1]||"th",_log.error(`${"0th"==i?"[O":i+" arg [o"}ptions] can only be an object of key/vals.`),_log.info("Example valid call:",o),_log.validOptions(t),_log.helpURL(r),!1;for(a in e){if(!Object.prototype.hasOwnProperty.call(t,a))return _log.error(`\`${a}\` is an invalid option.`),_log.validOptions(t),_log.helpURL(r),!1;if(s.includes(a)&&"boolean"!=typeof e[a])return _log.error(`[${a}] option can only be \`true\` or \`false\`.`),_log.helpURL(r),!1;if(l.includes(a)&&(e[a]=parseInt(e[a],10),isNaN(e[a])||e[a]<1))return _log.error(`[${a}] option can only be an integer > 0.`),_log.helpURL(r),!1}return!0}let _random={int(e,t){var r;return"undefined"==typeof require?(r=(window.crypto||window.msCrypto)?.getRandomValues(new Uint32Array(1))[0]/4294967295||Math.random(),Math.floor(r*(t-e))+e):require("crypto").randomInt(e,t)},hex(t){let r="";for(let e=0;e<t;e++)r+=_random.int(0,16).toString(16);return r}},_log={prefix:api.name,errHelpURLandThrow({errMsg:e,helpURL:t}){throw this.error(e),this.helpURL(t),new Error(e)},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 t=Object.keys(e).join(", "),e=JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," ");this.info(`Valid options: [${t}]`),this.info("If omitted, default settings are: "+e)}};api.exports=new Proxy({ipv4:ipv4,ipv6:ipv6,mac:mac},{get(e,t){for(var[r,o]of Object.entries(api.regex))if(o.test(t))return e[r]}});try{module.exports=api.exports}catch(e){}try{Object.assign(window,api.exports)}catch(e){}
|
package/docs/README.md
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
<picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
5
|
+
<picture><source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/adamlui/js-utils@0d3424a/generate-ip/assets/images/logos/generate-ip/white-logo.png"><img width=700 src="https://cdn.jsdelivr.net/gh/adamlui/js-utils@0d3424a/generate-ip/assets/images/logos/generate-ip/black-logo.png"></picture>
|
|
6
6
|
|
|
7
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
7
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/adamlui/js-utils@5c34563/generate-ip/assets/images/icons/node-graph/white/icon55x49.png"><img width=23 src="https://cdn.jsdelivr.net/gh/adamlui/js-utils@5c34563/generate-ip/assets/images/icons/node-graph/black/icon55x49.png"></picture> Randomly generate, format, and validate IPv4 + IPv6 + MAC addresses.
|
|
8
8
|
|
|
9
9
|
<br>
|
|
10
10
|
|
|
11
|
+
<a href="https://npmstar.com/compare/generate-ip">
|
|
12
|
+
<img height=31 src="https://img.shields.io/npm/dm/generate-ip?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
11
13
|
<a href="#%EF%B8%8F-mit-license">
|
|
12
14
|
<img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
13
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/generate-ip-2.
|
|
14
|
-
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.
|
|
15
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/generate-ip-2.9.0">
|
|
16
|
+
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.9.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
15
17
|
<a href="https://www.npmjs.com/package/generate-ip?activeTab=code">
|
|
16
18
|
<img height=31 src="https://img.shields.io/npm/unpacked-size/generate-ip?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
17
|
-
<a href="https://github.com/adamlui/js-utils/blob/generate-ip-2.8.2/generate-ip/dist/generate-ip.min.js">
|
|
18
|
-
<img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/generate-ip/dist/generate-ip.min.js?branch=generate-ip-2.8.2&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
|
|
19
19
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:generate-ip/src/generate-ip.js">
|
|
20
20
|
<img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Agenerate-ip%2Fsrc%2Fgenerate-ip.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
21
21
|
<a href="https://github.com/toolleeo/cli-apps#networking">
|
|
@@ -87,14 +87,14 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
87
87
|
#### <> HTML script tag:
|
|
88
88
|
|
|
89
89
|
```html
|
|
90
|
-
<script src="https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
90
|
+
<script src="https://cdn.jsdelivr.net/npm/generate-ip@2.9.0/dist/generate-ip.min.js"></script>
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
#### ES6:
|
|
94
94
|
|
|
95
95
|
```js
|
|
96
96
|
(async () => {
|
|
97
|
-
await import('https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
97
|
+
await import('https://cdn.jsdelivr.net/npm/generate-ip@2.9.0/dist/generate-ip.min.js')
|
|
98
98
|
// Your code here...
|
|
99
99
|
})()
|
|
100
100
|
```
|
|
@@ -103,7 +103,7 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
103
103
|
|
|
104
104
|
```js
|
|
105
105
|
...
|
|
106
|
-
// @require https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
106
|
+
// @require https://cdn.jsdelivr.net/npm/generate-ip@2.9.0/dist/generate-ip.min.js
|
|
107
107
|
// ==/UserScript==
|
|
108
108
|
|
|
109
109
|
// Your code here...
|
|
@@ -111,7 +111,7 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
111
111
|
|
|
112
112
|
<br>
|
|
113
113
|
|
|
114
|
-
📝 **Note:** To always import the latest version (not recommended in production!) remove the `@2.
|
|
114
|
+
📝 **Note:** To always import the latest version (not recommended in production!) remove the `@2.9.0` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/generate-ip/dist/generate-ip.min.js`
|
|
115
115
|
|
|
116
116
|
<br>
|
|
117
117
|
|
|
@@ -156,7 +156,7 @@ Name | Type | Description
|
|
|
156
156
|
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
157
157
|
`qty` | Integer | Number of IP addresses to generate. | `1`
|
|
158
158
|
`sequential` | Boolean | Generate addresses in sequence. | `false`
|
|
159
|
-
`network` | String |
|
|
159
|
+
`network` | String | Starting network address (required for sequential mode). | `null`
|
|
160
160
|
|
|
161
161
|
#
|
|
162
162
|
|
|
@@ -356,7 +356,7 @@ Name | Type | Description | Default Value
|
|
|
356
356
|
|
|
357
357
|
## 💻 Command line usage
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
**generate-ip** can also be used directly from the command line. The basic command is:
|
|
360
360
|
|
|
361
361
|
```
|
|
362
362
|
$ generate-ip
|
|
@@ -364,7 +364,7 @@ $ generate-ip
|
|
|
364
364
|
|
|
365
365
|
Sample output:
|
|
366
366
|
|
|
367
|
-
<img src="https://
|
|
367
|
+
<img src="https://cdn.jsdelivr.net/gh/adamlui/js-utils@5c34563/generate-ip/assets/images/screenshots/cli/generate-ip-cmd-output.png">
|
|
368
368
|
|
|
369
369
|
📝 **Note:** To generate other address types, type `generate-ipv6` or `generate-mac`
|
|
370
370
|
|
|
@@ -389,6 +389,8 @@ Commands:
|
|
|
389
389
|
-i, --init Create config file (in project root).
|
|
390
390
|
-h, --help Display help screen.
|
|
391
391
|
-v, --version Show version number.
|
|
392
|
+
--stats Show npm stats.
|
|
393
|
+
--debug [targetKey] Show debug logs.
|
|
392
394
|
```
|
|
393
395
|
|
|
394
396
|
#
|
|
@@ -439,7 +441,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
439
441
|
[CLI usage](https://docs.generatepw.org/#-command-line-usage) /
|
|
440
442
|
[Discuss](https://github.com/adamlui/js-utils/discussions)
|
|
441
443
|
|
|
442
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
444
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/adamlui/js-utils@0d3424a/geolocate/assets/images/icons/wire-globe/white/icon32.png"><img height=22 src="https://cdn.jsdelivr.net/gh/adamlui/js-utils@0d3424a/geolocate/assets/images/icons/wire-globe/black/icon32.png"></picture> [geolocate](https://js-utils.org/geolocate) <a href="https://github.com/toolleeo/cli-apps#networking"><img height=18 src="https://assets.js-utils.org/images/badges/awesome/badge.svg?v=0d36e26"></a>
|
|
443
445
|
|
|
444
446
|
> Fetch IP geolocation data from the CLI.
|
|
445
447
|
<br>[Install](https://docs.geolocatejs.org/#-installation) /
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generate-ip",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Randomly generate, format, and validate IPv4 + IPv6 + MAC addresses.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Adam Lui",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"doc": "./docs"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
-
"dev": "npm run build && npm i -g",
|
|
41
|
+
"dev": "npm run build && npm i -g && generate-ip --help",
|
|
42
42
|
"build": "node utils/build",
|
|
43
43
|
"build:js": "node utils/build --js",
|
|
44
44
|
"build:data": "node utils/build --data",
|
|
@@ -74,9 +74,12 @@
|
|
|
74
74
|
"url": "https://github.com/adamlui/js-utils/issues"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
+
"is-unicode-supported": "^2.1.0",
|
|
77
78
|
"node-clipboardy": "^1.0.3"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
|
-
"@adamlui/minify.js": "^2.
|
|
81
|
+
"@adamlui/minify.js": "^2.4.1",
|
|
82
|
+
"console-table-printer": "^2.15.0",
|
|
83
|
+
"copyfiles": "^2.4.1"
|
|
81
84
|
}
|
|
82
85
|
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
"af",
|
|
3
|
-
"am",
|
|
4
|
-
"ar",
|
|
5
|
-
"az",
|
|
6
|
-
"be",
|
|
7
|
-
"bg",
|
|
8
|
-
"bn",
|
|
9
|
-
"bo",
|
|
10
|
-
"bs",
|
|
11
|
-
"ca",
|
|
12
|
-
"cs",
|
|
13
|
-
"cy",
|
|
14
|
-
"da",
|
|
15
|
-
"de",
|
|
16
|
-
"dv",
|
|
17
|
-
"dz",
|
|
18
|
-
"el",
|
|
19
|
-
"en",
|
|
20
|
-
"eo",
|
|
21
|
-
"es",
|
|
22
|
-
"et",
|
|
23
|
-
"eu",
|
|
24
|
-
"fa",
|
|
25
|
-
"fi",
|
|
26
|
-
"fo",
|
|
27
|
-
"fr",
|
|
28
|
-
"gd",
|
|
29
|
-
"gl",
|
|
30
|
-
"gu",
|
|
31
|
-
"he",
|
|
32
|
-
"hi",
|
|
33
|
-
"hr",
|
|
34
|
-
"ht",
|
|
35
|
-
"hu",
|
|
36
|
-
"hy",
|
|
37
|
-
"id",
|
|
38
|
-
"is",
|
|
39
|
-
"it",
|
|
40
|
-
"ja",
|
|
41
|
-
"ka",
|
|
42
|
-
"kk",
|
|
43
|
-
"km",
|
|
44
|
-
"kn",
|
|
45
|
-
"ko",
|
|
46
|
-
"ku",
|
|
47
|
-
"ky",
|
|
48
|
-
"la",
|
|
49
|
-
"lb",
|
|
50
|
-
"lo",
|
|
51
|
-
"lt",
|
|
52
|
-
"lv",
|
|
53
|
-
"mg",
|
|
54
|
-
"mi",
|
|
55
|
-
"mk",
|
|
56
|
-
"ml",
|
|
57
|
-
"mn",
|
|
58
|
-
"ms",
|
|
59
|
-
"mt",
|
|
60
|
-
"my",
|
|
61
|
-
"ne",
|
|
62
|
-
"nl",
|
|
63
|
-
"no",
|
|
64
|
-
"ny",
|
|
65
|
-
"pa",
|
|
66
|
-
"pl",
|
|
67
|
-
"ps",
|
|
68
|
-
"pt",
|
|
69
|
-
"ro",
|
|
70
|
-
"ru",
|
|
71
|
-
"rw",
|
|
72
|
-
"sg",
|
|
73
|
-
"si",
|
|
74
|
-
"sk",
|
|
75
|
-
"sl",
|
|
76
|
-
"sm",
|
|
77
|
-
"sn",
|
|
78
|
-
"so",
|
|
79
|
-
"sr",
|
|
80
|
-
"sv",
|
|
81
|
-
"sw",
|
|
82
|
-
"ta",
|
|
83
|
-
"te",
|
|
84
|
-
"tg",
|
|
85
|
-
"th",
|
|
86
|
-
"ti",
|
|
87
|
-
"tk",
|
|
88
|
-
"tn",
|
|
89
|
-
"tr",
|
|
90
|
-
"uk",
|
|
91
|
-
"ur",
|
|
92
|
-
"uz",
|
|
93
|
-
"vi",
|
|
94
|
-
"xh",
|
|
95
|
-
"yi",
|
|
96
|
-
"zh",
|
|
97
|
-
"zh_CN",
|
|
98
|
-
"zh_HK",
|
|
99
|
-
"zh_SG",
|
|
100
|
-
"zh_TW",
|
|
101
|
-
"zu"
|
|
102
|
-
]
|