-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·344 lines (306 loc) · 8.9 KB
/
Copy pathindex.js
File metadata and controls
executable file
·344 lines (306 loc) · 8.9 KB
1
2
3
4
5
6
7
8
9
10
11
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
#!/usr/bin/env node
var readJson = require('read-package-json');
const inquirer = require("./lib/inq");
const chalk = require("chalk");
const clear = require("clear");
const figlet = require("figlet");
const files = require("./lib/files");
const Configstore = require("configstore");
const conf = new Configstore("ginit");
var cowsay = require("cowsay");
const lolcatjs = require('lolcatjs');
var Table = require('tty-table');
lolcatjs.options.seed = 160;
lolcatjs.options.colors = true;
lolcatjs.options.animate = true;
lolcatjs.options.force = true;
lolcatjs.options.duration = 6;
lolcatjs.options.speed = 32;
lolcatjs.options.spread = 12;
lolcatjs.options.frequency = 0.4;
const options = {};
clear();
const runYarn = function (args) {
const spawn = require("child_process").spawn;
var child = spawn("yarn", [args], options);
// child.stdout.on("data", function(data) {
// console.log(data + "");
// });
// child.stderr.on("data", function(data) {
// console.log("stderr: " + data);
// });
child.on("close", function (code) {
// clear();
console.log(`
`);
lolcatjs.fromString(cowsay.say({
text: "Will miss you horridly!",
e: "oO",
T: "U "
}));
process.exit(code);
});
process.on("SIGTERM", () => {
child.kill("SIGTERM");
});
process.on("SIGINT", () => {
child.kill("SIGINT");
});
};
const deploy = function () {
const spawn = require("child_process").spawn;
var child = spawn("surge", [""], {
cwd: process.cwd(),
detached: true,
stdio: "inherit"
});
// child.stdout.on("data", function(data) {
// console.log(data + "");
// });
// child.stderr.on("data", function(data) {
// console.log("stderr: " + data);
// });
child.on("close", function (code) {
// clear();
console.log(`
`);
lolcatjs.fromString(cowsay.say({
text: "Enjoy your new website!!",
e: "oO",
T: "U "
}));
process.exit(code);
});
process.on("SIGTERM", () => {
child.kill("SIGTERM");
});
process.on("SIGINT", () => {
child.kill("SIGINT");
});
};
const howdoi = function (param) {
const spawn = require("child_process").spawn;
var child = spawn("howdoi", [param], options);
lolcatjs.fromString(cowsay.say({
text: "Hope that answer works fo you!!",
e: "oO",
T: "U "
}));
console.log(`
`);
child.stdout.on("data", function (data) {
lolcatjs.fromString(data + "");
});
// child.stderr.on("data", function(data) {
// console.log("stderr: " + data);
// });
child.on("close", function (code) {
// clear();
process.exit(code);
});
process.on("SIGTERM", () => {
child.kill("SIGTERM");
});
process.on("SIGINT", () => {
child.kill("SIGINT");
});
};
const command = function (param) {
const spawn = require("child_process").spawn;
var child = spawn("tldr", [param], options);//lib/tldr.sh
lolcatjs.fromString(cowsay.say({
text: "Hope that answer works fo you!!",
e: "oO",
T: "U "
}));
console.log(`
`);
child.stdout.on("data", function (data) {
console.log(chalk.magentaBright(data + " "));
});
// child.stderr.on("data", function(data) {
// console.log("stderr: " + data);
// });
child.on("close", function (code) {
// clear();
process.exit(code);
});
process.on("SIGTERM", () => {
child.kill("SIGTERM");
});
process.on("SIGINT", () => {
child.kill("SIGINT");
});
};
const startRead = () => readJson('./package.json', console.error, false, async function (er, data) {
if (er) {
console.error("There was an error reading the file");
return;
}
let scripts = Object.keys(data.scripts).map(sc => {
return [sc, data.scripts[sc]];
//"§¬ ¯ ··· ˠˡˢˣˤ˥˦˧˨˩˪˫ˬ˭ˮ˯02F0˰˱˲˳˴˵˶˷˸˺˻˼˽˾˿Ͱ ͱ ͻ ͼͽ " +
data.scripts[sc];
});
scripts = evenOut(scripts); // console.log(scripts); // clear(); clear();
let ans = await inquirer.whichScript(scripts);
let runme = ans.run.split("˼")[0];
runme =
runme.replace("˻", "");
runYarn(runme);
});
const evenOut = (items) => {
let leftMax = items[0][0].length;
items.forEach(it => {
if (leftMax < it[0].length) {
leftMax = it[0].length;
}
});
leftMax += 10;
let newArr = [];
items.forEach(it => {
let needed = leftMax - it[0].length;
it[0] = "˻" + it[0] + "˼" + new Array(needed).join(' ');
newArr.push(it[0] + "˧ " + it[1] + ' Ͱ');
});
return newArr;
};
const help = () => {
var header = [
{
value: "",
headerColor: "cyan",
color: "magenta",
align: "left",
paddingLeft: 1,
width: 11
},
{
value: "description",
color: "blue",
width: 45
},
{
alias: "example",
value: "organic",
width: 30
}
];
//Example with arrays as rows
var rows = [
["command", "Get extra useful info about commands", "hvn command find lists how to" +
" find stuff"],
["how2", "Quickly ask any development question and get a perfect answer", "hvn howdoi" +
" start react server"],
["deploy", "Literally deploys the current directory to a website for you in 3 seconds", "hvn deploy"],
["task", "An easy way to run any of your npm scripts with yarn", "hvn command // will" +
" run command promp"],
["hvn", "Can be used to replace package.json with JSON5, meaning COMMENTS!", "hvn add" +
" fkit"]
];
var t1 = Table(header, rows, {
borderStyle: 1,
borderColor: "blue",
paddingBottom: 0,
headerAlign: "center",
align: "left",
color: "white",
truncate: false
});
let str1 = t1.render();
console.log(str1);
//
//
// var t2 = Table(header, rows, {
// borderStyle: 1,
// paddingBottom: 0,
// headerAlign: "center",
// align: "center",
// color: "white"
// });
//
// var str2 = t2.render();
// console.log(str2);
//
//
// //template literals
// let header3 = [
// {value: 'name', width: 30, headerAlign: 'left'},
// {value: 'price', width: 30, headerAlign: 'left'}
// ];
//
// const opts = {
// align: 'left'
// };
//
// const data = [
// [`apple ${chalk.red("mac")}`, 92.50],
// ["ibm", 120.15]
// ];
//
// let t3 = Table(header3, data, opts);
// console.log(t3.render());
};
figlet.text('hvn', {
font: "ANSI Shadow",// Three Point // Ogre
horizontalLayout: 'full',
verticalLayout: 'full'
}, function (err, data) {
if (err) {
console.log('Something went wrong...');
console.dir(err);
return;
}
console.log(" ");
console.log(" ");
// console.log(chalk.magentaBright(data));
lolcatjs.fromString(data);
setTimeout(function () {
clear();
// startRead();
//
// howdoi("Start a react server");
var param = process.argv.slice(3, 50).join(" ");
if (process.argv[2] === "how2") {
howdoi(param);
// process.exit(-1);
} else if (process.argv[2] === "task") {
startRead();
} else if (process.argv[2] === "deploy") {
deploy();
} else if (process.argv[2] === "command") {
command(param);
} else if (process.argv[2] === "help" || process.argv[2] === "-h" || process.argv[2] === "--help") {
help();
} else {
runYarn(param);
}
}, 500);
});
/***
* EXEV
*/
// const run = async () => {
// try {
// // Retrieve & Set Authentication Token
// const token = await getGithubToken();
// github.githubAuth(token);
//
// // Create remote repository
// const url = await repo.createRemoteRepo();
//
// // Create .gitignore file
// await repo.createGitignore();
//
// // Setup local repository and push to remote
// const done = await repo.setupRepo(url);
// if (done) {
// console.log(chalk.green("All done!"));
// }
// } catch (err) {
// if (err) {
// switch (err.code) {
// case 401:
// console.log(chalk.red("Couldn't log you in. Please provide correct
// credentials/token.")); break; case 422: console.log(chalk.red("There already exists a remote
// repository with the same name")); break; default: console.log(err); } } } }; run();