umpordez 0.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.
- package/cli.mjs +90 -0
- package/package.json +33 -0
package/cli.mjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import figlet from 'figlet';
|
|
4
|
+
|
|
5
|
+
// everything that has a beginning has an end
|
|
6
|
+
console.log(chalk.green(figlet.textSync('umpordez')));
|
|
7
|
+
console.log('');
|
|
8
|
+
|
|
9
|
+
function sample(arr) {
|
|
10
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function getUser() {
|
|
14
|
+
// try get from process.env
|
|
15
|
+
// try get from json file
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const user = await getUser();
|
|
19
|
+
|
|
20
|
+
if (user) {
|
|
21
|
+
console.log(`Logged in as /${user.login} \o/`);
|
|
22
|
+
console.log('');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const choices = {
|
|
26
|
+
'I want to authenticate myself': async () => {
|
|
27
|
+
await inquirer.prompt([
|
|
28
|
+
{
|
|
29
|
+
type: 'password',
|
|
30
|
+
name: 'key',
|
|
31
|
+
message: `So, please tell me... what's your key?`
|
|
32
|
+
}
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
console.log('');
|
|
36
|
+
console.log(chalk.green('Cool!! 😎 trying to login'));
|
|
37
|
+
console.log(chalk.green('...'));
|
|
38
|
+
console.log(chalk.green('You are in! /Deividy ;)'));
|
|
39
|
+
console.log('');
|
|
40
|
+
|
|
41
|
+
const opt = await inquirer.prompt([
|
|
42
|
+
{
|
|
43
|
+
type: 'rawlist',
|
|
44
|
+
name: 'task',
|
|
45
|
+
message: `What's next?`,
|
|
46
|
+
choices: Object.keys(choices).slice(1)
|
|
47
|
+
}
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
console.log('');
|
|
51
|
+
console.log('You have choose:');
|
|
52
|
+
console.log(chalk.cyan(opt.task));
|
|
53
|
+
console.log('');
|
|
54
|
+
|
|
55
|
+
await choices[opt.task]();
|
|
56
|
+
},
|
|
57
|
+
'I want to logout': () => {
|
|
58
|
+
|
|
59
|
+
},
|
|
60
|
+
'I want to leave': () => {
|
|
61
|
+
console.log(chalk.green('So, my friend...'));
|
|
62
|
+
console.log(chalk.green('farewell o/'));
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const welcomeMessages = [
|
|
67
|
+
'hello, my young padawan',
|
|
68
|
+
'how you doin?',
|
|
69
|
+
'whats up?',
|
|
70
|
+
'heeeey yooo'
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const option = await inquirer.prompt([
|
|
74
|
+
{
|
|
75
|
+
type: 'rawlist',
|
|
76
|
+
name: 'task',
|
|
77
|
+
message: `${sample(welcomeMessages)}\n Please, choose one:`,
|
|
78
|
+
choices: Object.keys(choices)
|
|
79
|
+
}
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
console.log('');
|
|
84
|
+
console.log('You have choose:');
|
|
85
|
+
console.log(chalk.cyan(option.task));
|
|
86
|
+
console.log('');
|
|
87
|
+
|
|
88
|
+
await choices[option.task]();
|
|
89
|
+
|
|
90
|
+
process.exit(0);
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "umpordez",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "umpordez cli, interact, create, build your own meme",
|
|
6
|
+
"main": "cli.mjs",
|
|
7
|
+
"imports": {
|
|
8
|
+
"#root/*": "./*",
|
|
9
|
+
"#tests/*": "./tests/*",
|
|
10
|
+
"#core/*": "./core/*"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "test"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/umpordez/cli.git"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"umpordez"
|
|
21
|
+
],
|
|
22
|
+
"author": "umpordez",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/umpordez/cli/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/umpordez/cli#readme",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"chalk": "^5.4.1",
|
|
30
|
+
"figlet": "^1.8.2",
|
|
31
|
+
"inquirer": "^12.7.0"
|
|
32
|
+
}
|
|
33
|
+
}
|