-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·124 lines (107 loc) · 3.44 KB
/
index.js
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
#!/usr/bin/env node
import { input } from '@inquirer/prompts';
import select from '@inquirer/select';
import { checkbox } from '@inquirer/prompts';
import confirm from '@inquirer/confirm';
import { parseArgs } from "node:util";
import * as jsApp from "./jsApp.js";
const args = parseArgs({
allowPositionals: true,
});
if (args.positionals.length > 1) {
console.error('Invalid arguments');
process.exit(1);
}
var target;
if (args.positionals.length == 0) {
target = process.cwd();
} else {
target = args.positionals[0];
}
const moduleType = "JS";
const appType = await select({
message: 'Select type of application',
choices: [
{
name: 'Process',
value: 'process',
description: 'A default program, use this if unsure of what to pick.',
},
{
name: "Library",
value: 'library',
description: 'A library for another module to use.',
},
],
});
const perm = await checkbox({
message: 'What permissions does your app need?',
choices: [
{ name: 'Start other applications', value: 'startPkg' },
{ name: 'Interface with other running processes', value: 'processList' },
{ name: 'Read installed programs', value: 'knownPackageList' },
{ name: 'Interact with system services', value: 'services' },
{ name: 'Full core access', value: 'full' }
],
});
let perms = []
for (const val of perm) {
switch (val) {
case 'startPkg':
perms.push({
privilege: "startPkg",
description: await input({ message: 'Reason for start access: ' })
})
break;
case 'processList':
perms.push({
privilege: "processList",
description: await input({ message: 'Reason for interacting with processes: ' })
})
break;
case 'knownPackageList':
perms.push({
privilege: "knownPackageList",
description: await input({ message: 'Reason for reading installed packages: ' })
})
break;
case 'services':
perms.push({
privilege: "services",
description: await input({ message: 'Reason for services access: ' })
})
break;
case 'full':
perms.push({
privilege: "full",
description: await input({ message: 'Reason for Core Access: ' })
})
break;
}
}
const name = await input({ message: 'Enter app name: ' });
const description = await input({ message: 'Enter app description: ' });
var entry, event;
if (await confirm({ message: 'Specify a custom main entry point?', default: false })) {
entry = await input({ message: 'Enter custom entry point function: ' });
}
else {
entry = 'main';
}
if (await confirm({ message: 'Recieve events?', default: false })) {
event = await input({ message: 'What function should recive events? ' });
}
else {
event = null;
}
if (!(await confirm({ message: 'Are these all correct?', default: true }))) {
console.warn("Aborted.")
process.exit(1);
}
if (moduleType == 'JS') {
jsApp.make(target, name, description, entry, event, appType, perms)
} else if (moduleType == 'TS') {
tsApp.make(target, name, description, entry, event, appType, perms)
} else if (moduleType == 'WASM') {
console.warn("WASM is not yet supported.")
}