jyn 0.0.1-beta.2 → 0.0.1-beta.3
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/dist/index.cjs +70 -0
- package/dist/index.js +70 -0
- package/index.ts +32 -3
- package/package.json +6 -4
- package/src/password.ts +55 -0
package/dist/index.cjs
CHANGED
|
@@ -29,11 +29,81 @@ var import_chalk_animation = __toESM(require("chalk-animation"), 1);
|
|
|
29
29
|
// utils/timers.ts
|
|
30
30
|
var sleep = (ms = 1e3) => new Promise((res) => setTimeout(res, ms));
|
|
31
31
|
|
|
32
|
+
// index.ts
|
|
33
|
+
var import_prompts2 = require("@inquirer/prompts");
|
|
34
|
+
|
|
35
|
+
// src/password.ts
|
|
36
|
+
var import_prompts = require("@inquirer/prompts");
|
|
37
|
+
var LOWERCASE_CHAR_CODES = arrayFromLowToHigh(97, 122);
|
|
38
|
+
var UPPERCASE_CHAR_CODES = arrayFromLowToHigh(65, 90);
|
|
39
|
+
var NUMBER_CHAR_CODES = arrayFromLowToHigh(48, 57);
|
|
40
|
+
var SYMBOL_CHAR_CODES = arrayFromLowToHigh(33, 47).concat(
|
|
41
|
+
arrayFromLowToHigh(58, 64)
|
|
42
|
+
).concat(
|
|
43
|
+
arrayFromLowToHigh(91, 96)
|
|
44
|
+
).concat(
|
|
45
|
+
arrayFromLowToHigh(123, 126)
|
|
46
|
+
);
|
|
47
|
+
function arrayFromLowToHigh(low, high) {
|
|
48
|
+
const array = [];
|
|
49
|
+
for (let i = low; i <= high; i++) {
|
|
50
|
+
array.push(i);
|
|
51
|
+
}
|
|
52
|
+
return array;
|
|
53
|
+
}
|
|
54
|
+
async function passwordGenerator() {
|
|
55
|
+
const charsCount = await (0, import_prompts.number)({ message: "Enter number of characters" });
|
|
56
|
+
const configs = await (0, import_prompts.checkbox)({
|
|
57
|
+
message: "Select a package manager",
|
|
58
|
+
choices: [
|
|
59
|
+
{ name: "Include Uppercase", value: "uppercase" },
|
|
60
|
+
{ name: "Include Numbers", value: "numbers" },
|
|
61
|
+
{ name: "Include Symbols", value: "symbols" }
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
const output = generatePassword(charsCount ?? 0, configs.includes("uppercase"), configs.includes("numbers"), configs.includes("symbols"));
|
|
65
|
+
return output;
|
|
66
|
+
}
|
|
67
|
+
function generatePassword(charCount, includeUppercase, includeNumbers, includeSymbols) {
|
|
68
|
+
let charCodes = LOWERCASE_CHAR_CODES;
|
|
69
|
+
if (includeUppercase) charCodes = charCodes.concat(UPPERCASE_CHAR_CODES);
|
|
70
|
+
if (includeSymbols) charCodes = charCodes.concat(SYMBOL_CHAR_CODES);
|
|
71
|
+
if (includeNumbers) charCodes = charCodes.concat(NUMBER_CHAR_CODES);
|
|
72
|
+
const passwordChars = [];
|
|
73
|
+
for (let i = 0; i < charCount; i++) {
|
|
74
|
+
const characterCode = charCodes[Math.floor(Math.random() * charCodes.length)];
|
|
75
|
+
if (characterCode) {
|
|
76
|
+
passwordChars.push(String.fromCharCode(characterCode));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return passwordChars.join("");
|
|
80
|
+
}
|
|
81
|
+
|
|
32
82
|
// index.ts
|
|
33
83
|
async function welcome() {
|
|
34
84
|
const title = import_chalk_animation.default.rainbow("I'm Gyn - a random generator toolbelt");
|
|
35
85
|
await sleep();
|
|
36
86
|
title.stop();
|
|
87
|
+
await askBaseSelection();
|
|
88
|
+
}
|
|
89
|
+
async function askBaseSelection() {
|
|
90
|
+
const answer = await (0, import_prompts2.select)({
|
|
91
|
+
message: "Select your choice",
|
|
92
|
+
choices: [
|
|
93
|
+
{
|
|
94
|
+
name: "Password generation",
|
|
95
|
+
value: "password_gen"
|
|
96
|
+
},
|
|
97
|
+
new import_prompts2.Separator()
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
let output;
|
|
101
|
+
switch (answer) {
|
|
102
|
+
case "password_gen": {
|
|
103
|
+
output = await passwordGenerator();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
console.log({ output });
|
|
37
107
|
}
|
|
38
108
|
async function start() {
|
|
39
109
|
await welcome();
|
package/dist/index.js
CHANGED
|
@@ -6,11 +6,81 @@ import chalkAnimation from "chalk-animation";
|
|
|
6
6
|
// utils/timers.ts
|
|
7
7
|
var sleep = (ms = 1e3) => new Promise((res) => setTimeout(res, ms));
|
|
8
8
|
|
|
9
|
+
// index.ts
|
|
10
|
+
import { select, Separator } from "@inquirer/prompts";
|
|
11
|
+
|
|
12
|
+
// src/password.ts
|
|
13
|
+
import { number, checkbox } from "@inquirer/prompts";
|
|
14
|
+
var LOWERCASE_CHAR_CODES = arrayFromLowToHigh(97, 122);
|
|
15
|
+
var UPPERCASE_CHAR_CODES = arrayFromLowToHigh(65, 90);
|
|
16
|
+
var NUMBER_CHAR_CODES = arrayFromLowToHigh(48, 57);
|
|
17
|
+
var SYMBOL_CHAR_CODES = arrayFromLowToHigh(33, 47).concat(
|
|
18
|
+
arrayFromLowToHigh(58, 64)
|
|
19
|
+
).concat(
|
|
20
|
+
arrayFromLowToHigh(91, 96)
|
|
21
|
+
).concat(
|
|
22
|
+
arrayFromLowToHigh(123, 126)
|
|
23
|
+
);
|
|
24
|
+
function arrayFromLowToHigh(low, high) {
|
|
25
|
+
const array = [];
|
|
26
|
+
for (let i = low; i <= high; i++) {
|
|
27
|
+
array.push(i);
|
|
28
|
+
}
|
|
29
|
+
return array;
|
|
30
|
+
}
|
|
31
|
+
async function passwordGenerator() {
|
|
32
|
+
const charsCount = await number({ message: "Enter number of characters" });
|
|
33
|
+
const configs = await checkbox({
|
|
34
|
+
message: "Select a package manager",
|
|
35
|
+
choices: [
|
|
36
|
+
{ name: "Include Uppercase", value: "uppercase" },
|
|
37
|
+
{ name: "Include Numbers", value: "numbers" },
|
|
38
|
+
{ name: "Include Symbols", value: "symbols" }
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
const output = generatePassword(charsCount ?? 0, configs.includes("uppercase"), configs.includes("numbers"), configs.includes("symbols"));
|
|
42
|
+
return output;
|
|
43
|
+
}
|
|
44
|
+
function generatePassword(charCount, includeUppercase, includeNumbers, includeSymbols) {
|
|
45
|
+
let charCodes = LOWERCASE_CHAR_CODES;
|
|
46
|
+
if (includeUppercase) charCodes = charCodes.concat(UPPERCASE_CHAR_CODES);
|
|
47
|
+
if (includeSymbols) charCodes = charCodes.concat(SYMBOL_CHAR_CODES);
|
|
48
|
+
if (includeNumbers) charCodes = charCodes.concat(NUMBER_CHAR_CODES);
|
|
49
|
+
const passwordChars = [];
|
|
50
|
+
for (let i = 0; i < charCount; i++) {
|
|
51
|
+
const characterCode = charCodes[Math.floor(Math.random() * charCodes.length)];
|
|
52
|
+
if (characterCode) {
|
|
53
|
+
passwordChars.push(String.fromCharCode(characterCode));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return passwordChars.join("");
|
|
57
|
+
}
|
|
58
|
+
|
|
9
59
|
// index.ts
|
|
10
60
|
async function welcome() {
|
|
11
61
|
const title = chalkAnimation.rainbow("I'm Gyn - a random generator toolbelt");
|
|
12
62
|
await sleep();
|
|
13
63
|
title.stop();
|
|
64
|
+
await askBaseSelection();
|
|
65
|
+
}
|
|
66
|
+
async function askBaseSelection() {
|
|
67
|
+
const answer = await select({
|
|
68
|
+
message: "Select your choice",
|
|
69
|
+
choices: [
|
|
70
|
+
{
|
|
71
|
+
name: "Password generation",
|
|
72
|
+
value: "password_gen"
|
|
73
|
+
},
|
|
74
|
+
new Separator()
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
let output;
|
|
78
|
+
switch (answer) {
|
|
79
|
+
case "password_gen": {
|
|
80
|
+
output = await passwordGenerator();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
console.log({ output });
|
|
14
84
|
}
|
|
15
85
|
async function start() {
|
|
16
86
|
await welcome();
|
package/index.ts
CHANGED
|
@@ -1,14 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import chalkAnimation from 'chalk-animation';
|
|
3
3
|
import { sleep } from './utils/timers';
|
|
4
|
+
import { select, Separator } from '@inquirer/prompts';
|
|
5
|
+
import passwordGenerator from './src/password';
|
|
4
6
|
|
|
5
7
|
async function welcome(){
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const title = chalkAnimation.rainbow("I'm Gyn - a random generator toolbelt");
|
|
9
|
+
await sleep();
|
|
10
|
+
title.stop();
|
|
11
|
+
await askBaseSelection();
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
|
|
15
|
+
async function askBaseSelection(){
|
|
16
|
+
const answer = await select({
|
|
17
|
+
message:'Select your choice',
|
|
18
|
+
choices:[
|
|
19
|
+
{
|
|
20
|
+
name:'Password generation',
|
|
21
|
+
value:'password_gen',
|
|
22
|
+
},
|
|
23
|
+
new Separator(),
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
let output;
|
|
29
|
+
switch(answer){
|
|
30
|
+
case 'password_gen':{
|
|
31
|
+
output = await passwordGenerator();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
console.log({output});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
12
41
|
async function start(){
|
|
13
42
|
await welcome();
|
|
14
43
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jyn",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.0.1-beta.
|
|
4
|
+
"version": "0.0.1-beta.3",
|
|
5
5
|
"description": "Toolkit for random generation",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -11,15 +11,17 @@
|
|
|
11
11
|
"build": "tsup index.ts --format cjs,esm --dts",
|
|
12
12
|
"lint": "tsc"
|
|
13
13
|
},
|
|
14
|
-
"bin":{
|
|
15
|
-
|
|
14
|
+
"bin": {
|
|
15
|
+
"gyn": "index.js"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/chalk-animation": "^1.6.3",
|
|
19
|
+
"@types/node": "^25.0.10",
|
|
19
20
|
"tsup": "^8.5.1",
|
|
20
21
|
"typescript": "^5.9.3"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
24
|
+
"@inquirer/prompts": "^8.2.0",
|
|
23
25
|
"chalk-animation": "^2.0.3"
|
|
24
26
|
}
|
|
25
|
-
}
|
|
27
|
+
}
|
package/src/password.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { number,checkbox } from '@inquirer/prompts';
|
|
2
|
+
|
|
3
|
+
const LOWERCASE_CHAR_CODES = arrayFromLowToHigh(97, 122);
|
|
4
|
+
const UPPERCASE_CHAR_CODES = arrayFromLowToHigh(65, 90);
|
|
5
|
+
const NUMBER_CHAR_CODES = arrayFromLowToHigh(48, 57);
|
|
6
|
+
const SYMBOL_CHAR_CODES = arrayFromLowToHigh(33, 47).concat(
|
|
7
|
+
arrayFromLowToHigh(58, 64)
|
|
8
|
+
).concat(
|
|
9
|
+
arrayFromLowToHigh(91, 96)
|
|
10
|
+
).concat(
|
|
11
|
+
arrayFromLowToHigh(123, 126)
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
function arrayFromLowToHigh(low:number, high:number) {
|
|
15
|
+
const array = []
|
|
16
|
+
for (let i = low; i <= high; i++) {
|
|
17
|
+
array.push(i)
|
|
18
|
+
}
|
|
19
|
+
return array
|
|
20
|
+
}
|
|
21
|
+
export default async function passwordGenerator(){
|
|
22
|
+
const charsCount = await number({message:'Enter number of characters'});
|
|
23
|
+
|
|
24
|
+
const configs = await checkbox({
|
|
25
|
+
message: 'Select a package manager',
|
|
26
|
+
choices: [
|
|
27
|
+
{ name: 'Include Uppercase', value: 'uppercase' },
|
|
28
|
+
{ name: 'Include Numbers', value: 'numbers' },
|
|
29
|
+
{ name: 'Include Symbols', value: 'symbols' },
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const output = generatePassword(charsCount ?? 0, configs.includes('uppercase'), configs.includes('numbers'), configs.includes('symbols'));
|
|
34
|
+
|
|
35
|
+
return output;
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
function generatePassword(charCount: number, includeUppercase:boolean, includeNumbers:boolean, includeSymbols:boolean){
|
|
41
|
+
let charCodes = LOWERCASE_CHAR_CODES;
|
|
42
|
+
if (includeUppercase) charCodes = charCodes.concat(UPPERCASE_CHAR_CODES)
|
|
43
|
+
if (includeSymbols) charCodes = charCodes.concat(SYMBOL_CHAR_CODES)
|
|
44
|
+
if (includeNumbers) charCodes = charCodes.concat(NUMBER_CHAR_CODES)
|
|
45
|
+
|
|
46
|
+
const passwordChars = [];
|
|
47
|
+
for(let i=0;i<charCount;i++){
|
|
48
|
+
const characterCode = charCodes[Math.floor(Math.random()*charCodes.length)];
|
|
49
|
+
if(characterCode){
|
|
50
|
+
passwordChars.push(String.fromCharCode(characterCode));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return passwordChars.join('');
|
|
55
|
+
}
|