@makano/rew 1.1.73 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/coffeescript/browser.js +144 -139
- package/lib/coffeescript/cake.js +132 -133
- package/lib/coffeescript/coffeescript.js +437 -381
- package/lib/coffeescript/command.js +806 -724
- package/lib/coffeescript/grammar.js +1908 -2474
- package/lib/coffeescript/helpers.js +509 -473
- package/lib/coffeescript/index.js +228 -215
- package/lib/coffeescript/lexer.js +2282 -1909
- package/lib/coffeescript/nodes.js +9782 -9202
- package/lib/coffeescript/optparse.js +255 -227
- package/lib/coffeescript/parser.js +20305 -1265
- package/lib/coffeescript/register.js +107 -87
- package/lib/coffeescript/repl.js +307 -284
- package/lib/coffeescript/rewriter.js +1389 -1079
- package/lib/coffeescript/scope.js +176 -172
- package/lib/coffeescript/sourcemap.js +242 -227
- package/lib/rew/cli/cli.js +288 -186
- package/lib/rew/cli/log.js +31 -32
- package/lib/rew/cli/run.js +10 -12
- package/lib/rew/cli/utils.js +344 -176
- package/lib/rew/const/config_path.js +4 -0
- package/lib/rew/const/default.js +38 -35
- package/lib/rew/const/files.js +9 -9
- package/lib/rew/const/opt.js +8 -8
- package/lib/rew/css/theme.css +2 -2
- package/lib/rew/functions/core.js +55 -57
- package/lib/rew/functions/curl.js +23 -0
- package/lib/rew/functions/emitter.js +52 -55
- package/lib/rew/functions/exec.js +25 -21
- package/lib/rew/functions/export.js +18 -20
- package/lib/rew/functions/fs.js +55 -54
- package/lib/rew/functions/future.js +29 -21
- package/lib/rew/functions/id.js +8 -9
- package/lib/rew/functions/import.js +107 -93
- package/lib/rew/functions/map.js +13 -16
- package/lib/rew/functions/match.js +35 -26
- package/lib/rew/functions/path.js +8 -8
- package/lib/rew/functions/require.js +32 -33
- package/lib/rew/functions/sleep.js +2 -2
- package/lib/rew/functions/stdout.js +20 -20
- package/lib/rew/functions/types.js +96 -95
- package/lib/rew/html/ui.html +12 -13
- package/lib/rew/html/ui.js +205 -168
- package/lib/rew/main.js +14 -14
- package/lib/rew/misc/bin.js +37 -0
- package/lib/rew/misc/findAppInfo.js +16 -0
- package/lib/rew/misc/findAppPath.js +21 -0
- package/lib/rew/misc/req.js +7 -0
- package/lib/rew/misc/seededid.js +13 -0
- package/lib/rew/models/enum.js +12 -12
- package/lib/rew/models/struct.js +30 -32
- package/lib/rew/modules/compiler.js +237 -177
- package/lib/rew/modules/context.js +35 -22
- package/lib/rew/modules/fs.js +10 -10
- package/lib/rew/modules/runtime.js +17 -21
- package/lib/rew/modules/yaml.js +27 -30
- package/lib/rew/pkgs/conf.js +82 -75
- package/lib/rew/pkgs/data.js +12 -7
- package/lib/rew/pkgs/date.js +27 -28
- package/lib/rew/pkgs/env.js +6 -8
- package/lib/rew/pkgs/modules/data/bintree.js +52 -52
- package/lib/rew/pkgs/modules/data/doublylinked.js +85 -85
- package/lib/rew/pkgs/modules/data/linkedList.js +73 -73
- package/lib/rew/pkgs/modules/data/queue.js +19 -20
- package/lib/rew/pkgs/modules/data/stack.js +19 -19
- package/lib/rew/pkgs/modules/threads/worker.js +36 -26
- package/lib/rew/pkgs/modules/ui/classes.js +182 -178
- package/lib/rew/pkgs/pkgs.js +9 -10
- package/lib/rew/pkgs/rune.js +400 -0
- package/lib/rew/pkgs/threads.js +57 -53
- package/lib/rew/pkgs/ui.js +148 -136
- package/lib/rew/qrew/compile.js +12 -0
- package/package.json +11 -4
package/lib/rew/cli/utils.js
CHANGED
@@ -7,186 +7,354 @@ const { log, logget } = require('./log');
|
|
7
7
|
const { execSync, exec } = require('child_process');
|
8
8
|
const { run } = require('../main');
|
9
9
|
const { generateRandomID } = require('../functions/id');
|
10
|
+
const { compile } = require('../modules/compiler');
|
11
|
+
const { to_qrew } = require('../qrew/compile');
|
12
|
+
const { findAppInfo } = require('../misc/findAppInfo');
|
13
|
+
const { req } = require('../misc/req');
|
10
14
|
|
11
15
|
const npm_package_name = '@makano/rew';
|
12
16
|
|
13
17
|
module.exports = {
|
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
|
-
const appConfpath = path.join(apppath, 'app.yaml');
|
18
|
+
conf(command, fullPath, key, value) {
|
19
|
+
const con = conf({});
|
20
|
+
if (command == 'get') {
|
21
|
+
if (!fullPath || fullPath == 'list') {
|
22
|
+
return fs.readdirSync(con.CONFIG_PATH).join('\n');
|
23
|
+
} else {
|
24
|
+
const name = fullPath.indexOf('/') ? fullPath.split('/')[0] : fullPath;
|
25
|
+
const dpath = fullPath.indexOf('/') ? fullPath.split('/').slice(1).join('/') : '';
|
26
|
+
const root = con.create(name);
|
27
|
+
if (dpath) {
|
28
|
+
const fp = path.join(root.root, dpath);
|
29
|
+
if (fs.existsSync(fp) && fs.statSync(fp).isDirectory()) {
|
30
|
+
return fs.readdirSync(fp).join('\n');
|
31
|
+
} else {
|
32
|
+
const o = con.create(name).optionCenter(dpath);
|
33
|
+
return key ? o.get(key) : o.getAll(true);
|
34
|
+
}
|
35
|
+
} else {
|
36
|
+
return fs.readdirSync(root.root).join('\n');
|
37
|
+
}
|
38
|
+
}
|
39
|
+
} else {
|
40
|
+
const name = fullPath.indexOf('/') ? fullPath.split('/')[0] : fullPath;
|
41
|
+
const dpath = fullPath.indexOf('/') ? fullPath.split('/')[1] : '';
|
42
|
+
if (name && key) {
|
43
|
+
const root = con.create(name);
|
44
|
+
const o = dpath ? root.optionCenter(dpath) : root;
|
45
|
+
if (command == 'set') {
|
46
|
+
if (value) {
|
47
|
+
o.set(key, value);
|
48
|
+
} else {
|
49
|
+
log('Value not specified', ':end');
|
50
|
+
}
|
51
|
+
} else {
|
52
|
+
o.remove(key);
|
53
|
+
}
|
54
|
+
} else {
|
55
|
+
log(!name ? 'Path not specified' : 'Key not specified', ':end');
|
56
|
+
}
|
57
|
+
}
|
58
|
+
},
|
59
|
+
createProject: (ppath) => {
|
60
|
+
const projectPath = path.join(process.cwd(), ppath);
|
61
|
+
log(''.cyan, 'Creating at'.blue, ppath.yellow);
|
62
|
+
const rl = readline.createInterface({
|
63
|
+
input: process.stdin,
|
64
|
+
output: process.stdout,
|
65
|
+
});
|
66
|
+
const project = {};
|
67
|
+
const create = () => {
|
68
|
+
fs.mkdirSync(projectPath, { recursive: true });
|
69
|
+
const confPath = path.join(projectPath, 'app.yaml');
|
70
|
+
const entryFile = path.join(projectPath, 'main.coffee');
|
71
|
+
fs.writeFileSync(confPath, jsYaml.dump({ package: project.package, entry: 'main.coffee' }));
|
72
|
+
fs.writeFileSync(entryFile, `print("Hello World!")`);
|
73
|
+
if (project.git) {
|
74
|
+
fs.writeFileSync(path.join(projectPath, '.gitignore'), `node_modules/\npackage-lock.json`);
|
75
|
+
execSync('cd ' + projectPath + ' && git init . && git branch -m main', { stdio: 'ignore' });
|
76
|
+
}
|
77
|
+
execSync('cd ' + projectPath + ' && npm init -y', { stdio: 'ignore' });
|
78
|
+
// log('Installing '+npm_package_name);
|
79
|
+
// exec('cd '+projectPath+' && npm i '+npm_package_name, (err) => {
|
80
|
+
// if(err){
|
81
|
+
// console.error(err);
|
82
|
+
// process.exit(0);
|
83
|
+
// } else {
|
84
|
+
// rl.close();
|
85
|
+
// }
|
86
|
+
// });
|
87
|
+
log('Done.'.blue.bold, ':end');
|
88
|
+
rl.close();
|
89
|
+
};
|
90
|
+
if (!fs.existsSync(projectPath)) {
|
91
|
+
rl.question(logget(' Package Name: '.blue), (pkg) => {
|
92
|
+
if (pkg.trim()) {
|
93
|
+
project.package = pkg.trim();
|
94
|
+
rl.question(logget(' Use git(y/N): '.yellow.bold), (use_git) => {
|
95
|
+
project.git = use_git.toLowerCase() == 'y' || use_git.toLowerCase() == 'yes';
|
96
|
+
create();
|
97
|
+
});
|
98
|
+
} else {
|
99
|
+
rl.close();
|
100
|
+
}
|
101
|
+
});
|
102
|
+
} else {
|
103
|
+
log(` Project ${ppath} already exists at ${projectPath}`.red.bold, ':end');
|
104
|
+
rl.close();
|
105
|
+
}
|
106
|
+
},
|
107
|
+
runApp(pathOrPackage, options) {
|
108
|
+
const apppath = path.resolve(process.cwd(), pathOrPackage);
|
109
|
+
const appConfpath = path.join(apppath, 'app.yaml');
|
107
110
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
111
|
+
const runAppRoot = (root, confPath, byPath) => {
|
112
|
+
const c = jsYaml.load(fs.readFileSync(confPath, { encoding: 'utf-8' }));
|
113
|
+
if (c.entry) {
|
114
|
+
if(byPath && options.dev) c.entry = c.entry.endsWith('.qrew') ? c.entry.replace(/\.qrew$/, '.coffee') : c.entry;
|
115
|
+
let r = path.resolve(root, c.entry);
|
116
|
+
if(options.build) {
|
117
|
+
this.build({
|
118
|
+
file: r,
|
119
|
+
translate: options.translate || false
|
120
|
+
});
|
121
|
+
r = path.resolve(root, c.entry.replace(new RegExp(path.extname(c.entry).replace('.', '\\.') + '$'), options.translate ? '.js' : '.qrew'));
|
122
|
+
}
|
123
|
+
const mod_path = path.resolve(root, 'snode_moduless/@makano/rew');
|
124
|
+
const mod_path_lib = path.join(mod_path, 'lib/rew/cli');
|
125
|
+
if (fs.existsSync(mod_path) && __dirname !== mod_path_lib) {
|
126
|
+
const mod_path_utilsjs = path.join(mod_path_lib, '../main.js');
|
127
|
+
require(mod_path_utilsjs).run(r);
|
128
|
+
} else run(r);
|
129
|
+
}
|
130
|
+
};
|
121
131
|
|
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
|
-
|
132
|
+
if (fs.existsSync(apppath) && fs.existsSync(appConfpath)) {
|
133
|
+
runAppRoot(apppath, appConfpath, true);
|
134
|
+
} else {
|
135
|
+
const con = conf({});
|
136
|
+
const apppath = path.resolve(con.CONFIG_PATH, pathOrPackage, 'app');
|
137
|
+
const appConfpath = path.join(apppath, 'app.yaml');
|
138
|
+
if (fs.existsSync(apppath) && fs.existsSync(appConfpath)) {
|
139
|
+
runAppRoot(apppath, appConfpath);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
},
|
143
|
+
installApp(pathname, rmidir, rmidiri) {
|
144
|
+
if (!pathname) {
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
const apppath = path.resolve(process.cwd(), pathname);
|
148
|
+
const appConfpath = path.join(apppath, 'app.yaml');
|
149
|
+
const appPackagepath = path.join(apppath, 'package.json');
|
150
|
+
if (fs.existsSync(apppath) && fs.existsSync(appConfpath)) {
|
151
|
+
const c = jsYaml.load(fs.readFileSync(appConfpath, { encoding: 'utf-8' }));
|
152
|
+
const p = JSON.parse(fs.readFileSync(appPackagepath, { encoding: 'utf-8' }));
|
153
|
+
const pname = c.package;
|
154
|
+
const installPath = path.join(conf({}).create(pname).root, 'app');
|
155
|
+
const rl = readline.createInterface({
|
156
|
+
input: process.stdin,
|
157
|
+
output: process.stdout,
|
158
|
+
});
|
159
|
+
log(' Installing '.blue + pname.green.bold);
|
160
|
+
log(' Package'.blue + ': ' + p.name.green + '@' + p.version.yellow);
|
161
|
+
if (p.description) {
|
162
|
+
log(' Description'.blue + ': ' + p.description);
|
163
|
+
}
|
164
|
+
rl.question(logget('Install '.blue + pname.green.bold + '? (y/N) '), (f) => {
|
165
|
+
if (f.toLowerCase() == 'y') {
|
166
|
+
if (fs.existsSync(installPath)) {
|
167
|
+
execSync(`rm -r ${installPath}`);
|
168
|
+
}
|
169
|
+
execSync(`cp -r ${apppath} ${installPath}`);
|
170
|
+
execSync(`chmod 444 ${installPath}/app.yaml`);
|
171
|
+
if (rmidir) {
|
172
|
+
execSync(`rm -r ${apppath}`);
|
173
|
+
}
|
174
|
+
log(' Installed '.green + pname.cyan.bold, c.install ? '' : ':end');
|
175
|
+
if(c.install){
|
176
|
+
if(c.install.build){
|
177
|
+
log(' Building'.blue);
|
178
|
+
this.build({
|
179
|
+
...c.install.build,
|
180
|
+
file: path.join(installPath, c.install.build.file)
|
181
|
+
});
|
182
|
+
}
|
183
|
+
}
|
184
|
+
rl.close();
|
185
|
+
} else {
|
186
|
+
if (rmidiri) {
|
187
|
+
execSync(`rm -r ${apppath}`);
|
188
|
+
}
|
189
|
+
log(' Canceled install'.red.bold, ':end');
|
190
|
+
rl.close();
|
191
|
+
}
|
192
|
+
});
|
193
|
+
} else {
|
194
|
+
log(' Path is not a rew app'.red.bold, ':end');
|
195
|
+
}
|
196
|
+
},
|
197
|
+
build(argv){
|
198
|
+
function readFile(filePath) {
|
199
|
+
return fs.readFileSync(filePath, { encoding: 'utf-8' });
|
200
|
+
}
|
201
|
+
|
202
|
+
function extractImports(content) {
|
203
|
+
const customImportRegex = /(\w+)\s*=\s*(imp|inc)\s*['"](.+?)['"]/g;
|
204
|
+
const jsImportRegex = /import\s+((?:\w+\s*,?\s*)?{?[^{]*}?)\s*from\s*['"](.+?)['"]/g;
|
205
|
+
const imports = [];
|
206
|
+
let match;
|
207
|
+
|
208
|
+
while ((match = customImportRegex.exec(content)) !== null) {
|
209
|
+
imports.push({ variable: match[1], url: match[3] });
|
210
|
+
}
|
211
|
+
|
212
|
+
while ((match = jsImportRegex.exec(content)) !== null) {
|
213
|
+
const variables = match[1].trim().replace(/[{}]/g, '').split(',').map(v => v.trim()).filter(v => v);
|
214
|
+
const url = match[2];
|
215
|
+
variables.forEach(variable => {
|
216
|
+
imports.push({ variable, url });
|
217
|
+
});
|
218
|
+
}
|
219
|
+
|
220
|
+
return imports;
|
221
|
+
}
|
222
|
+
|
223
|
+
function writeCompiledFile(filePath, compiledCode) {
|
224
|
+
const dirName = outputDir ? outputDir : path.dirname(filePath);
|
225
|
+
if (!fs.existsSync(dirName)) fs.mkdirSync(dirName, { recursive: true });
|
226
|
+
const baseName = path.basename(filePath, path.extname(filePath));
|
227
|
+
const newFilePath = path.join(dirName, `${baseName}.${argv.translate ? 'js' : 'qrew'}`);
|
228
|
+
fs.writeFileSync(newFilePath, compiledCode);
|
229
|
+
log(`${'Compiled'.green.bold}: ${newFilePath.yellow}`);
|
230
|
+
if(argv.remove){
|
231
|
+
fs.unlinkSync(filePath);
|
232
|
+
log(`${'Removed'.red.bold}: ${filePath.yellow}`);
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
236
|
+
function processFile(filePath, importsArray) {
|
237
|
+
const content = readFile(filePath);
|
238
|
+
const imports = extractImports(content);
|
239
|
+
|
240
|
+
imports.forEach((importStatement) => {
|
241
|
+
const importedFilePath = path.resolve(path.dirname(filePath), importStatement.url);
|
242
|
+
if (!importsArray.some((importObj) => importObj.url === importStatement.url)) {
|
243
|
+
if (fs.existsSync(importedFilePath)) {
|
244
|
+
importsArray.push(importStatement);
|
245
|
+
processFile(importedFilePath, importsArray);
|
246
|
+
} else if (fs.existsSync(importedFilePath + '.coffee')) {
|
247
|
+
importsArray.push(importStatement);
|
248
|
+
processFile(importedFilePath + '.coffee', importsArray);
|
249
|
+
} else if (fs.existsSync(importedFilePath + '.js')) {
|
250
|
+
importsArray.push(importStatement);
|
251
|
+
processFile(importedFilePath + '.js', importsArray);
|
252
|
+
}
|
253
|
+
}
|
254
|
+
});
|
255
|
+
|
256
|
+
const appPath = findAppInfo(filePath);
|
257
|
+
|
258
|
+
const compiled = argv.translate ? compile({ content }, {}) : to_qrew(content, appPath?.config?.package || path.basename(filePath).split('.').slice(0, -1).join('.'));
|
259
|
+
writeCompiledFile(filePath, compiled);
|
260
|
+
}
|
261
|
+
|
262
|
+
const filePath = path.resolve(process.cwd(), argv.file);
|
263
|
+
const importsArray = [];
|
264
|
+
const outputDir = argv.output ? path.resolve(process.cwd(), argv.output) : null;
|
265
|
+
log(' Start compile at'.yellow, (outputDir || 'default path').green);
|
266
|
+
processFile(filePath, importsArray);
|
267
|
+
log(' Compiled'.yellow, (importsArray.length + 1 + '').blue, `file${importsArray.length ? 's' : ''}.`.yellow, ':end');
|
268
|
+
},
|
269
|
+
async cloneGit(gitpath) {
|
270
|
+
const p = gitpath.split('github:')[1];
|
271
|
+
const url = `https://github.com/${p}`;
|
272
|
+
const apiurl = `https://api.github.com/repos/${p}`;
|
273
|
+
try{
|
274
|
+
const response = await req(apiurl);
|
275
|
+
if (response.status !== 200) return log(' Repo not found'.red.bold, ':end');
|
276
|
+
log(''.blue, 'Cloning from github'.yellow);
|
277
|
+
const tempPath = '/tmp/rew-git-clone-' + p.replace(/\//g, '_') + '-' + generateRandomID();
|
278
|
+
execSync(`git clone ${url} ${tempPath}`, { stdio: 'ignore' });
|
279
|
+
log(''.blue, 'Installing deps...'.yellow);
|
280
|
+
execSync(`cd ${tempPath} && npm i`);
|
281
|
+
return tempPath;
|
282
|
+
} catch(e){
|
283
|
+
log(' Repo not found'.red.bold, ':end');
|
284
|
+
}
|
285
|
+
},
|
286
|
+
findRepo(repo){
|
287
|
+
const repos = conf({}).create('').optionCenter('repos');
|
288
|
+
return repos.get(repo);
|
289
|
+
},
|
290
|
+
async installAppFrom(path){
|
291
|
+
if (path.startsWith('github:')) this.installApp(await this.cloneGit(path), true, true);
|
292
|
+
else if(path.startsWith('@')) this.fromRepo(path);
|
293
|
+
else this.installApp(path);
|
294
|
+
},
|
295
|
+
async getRepoJson(repoUrl){
|
296
|
+
try{
|
297
|
+
const text = (await req(repoUrl.startsWith('//.') ? 'http://'+repoUrl.slice(3) : repoUrl.startsWith('//') ? 'https://'+repoUrl : repoUrl)).data;
|
298
|
+
const json = text.startsWith('---') || text.startsWith('%YAML') ? jsYaml.loadAll(text)[0] : JSON.parse(text);
|
299
|
+
if(Array.isArray(json.include)){
|
300
|
+
for(let i of json.include){
|
301
|
+
json.packages = {
|
302
|
+
...json.packages,
|
303
|
+
...((await this.getRepoJson(i.startsWith('.') ? path.join(path.dirname(repoUrl), i) : i)).packages || {})
|
304
|
+
};
|
305
|
+
}
|
306
|
+
}
|
307
|
+
return json;
|
308
|
+
} catch(e){
|
309
|
+
log(` Fetch Error. Check your connection.`.red.bold);
|
310
|
+
return {};
|
311
|
+
}
|
312
|
+
},
|
313
|
+
async fromRepo(repoAndPkg){
|
314
|
+
const [repo, pkg] = repoAndPkg.slice(1).split('/');
|
315
|
+
const repoUrl = this.findRepo(repo);
|
316
|
+
if(!repoUrl){
|
317
|
+
log(` Repository "${repo.green}"`.red.bold, `not found.`.red.bold);
|
318
|
+
return log(`Add with:`.yellow, '\n\t$'.green, `rew repo add ${repo} URL`.cyan.bold, ':end');
|
319
|
+
} else {
|
320
|
+
const repoJson = await this.getRepoJson(repoUrl);
|
321
|
+
if(repoJson?.packages?.[pkg]){
|
322
|
+
await this.installAppFrom(repoJson.packages[pkg]);
|
323
|
+
} else {
|
324
|
+
log(` Package "${pkg}" is not in repo "${repo.green}"`.red.bold, ":end");
|
325
|
+
}
|
326
|
+
}
|
176
327
|
},
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
328
|
+
async repo(command, key, value) {
|
329
|
+
const confInstance = conf({}).create('').optionCenter('repos') || {};
|
330
|
+
|
331
|
+
if (command === 'add' || command === 'set') {
|
332
|
+
confInstance.set(key, value.replace('https://', '//').replace('http://', '//.'));
|
333
|
+
} else if (command === 'get') {
|
334
|
+
if (key) {
|
335
|
+
console.log(confInstance.get(key) || 'Not found');
|
336
|
+
} else {
|
337
|
+
console.log(Object.keys(confInstance.getAll()).join('\n'));
|
338
|
+
}
|
339
|
+
} else if (command === 'view') {
|
340
|
+
if (key) {
|
341
|
+
const url = confInstance.get(key);
|
342
|
+
if(!url) return log(' Repo not found'.red.bold, ':end');
|
343
|
+
const json = await this.getRepoJson(url);
|
344
|
+
if(json.name) log(json.name);
|
345
|
+
log('Packages:'.yellow)
|
346
|
+
if(json.packages) Object.keys(json.packages).forEach(name => log(name)) || log(`${Object.keys(json.packages).length} Packages in ${key}`, ':end');
|
347
|
+
else log('None'.blue, ':end')
|
348
|
+
} else {
|
349
|
+
console.log(Object.keys(repos).join('\n'));
|
350
|
+
}
|
351
|
+
} else if (command === 'delete') {
|
352
|
+
confInstance.remove('repos');
|
353
|
+
} else {
|
354
|
+
log(' Invalid command'.red.bold, ':end');
|
355
|
+
}
|
356
|
+
},
|
357
|
+
initFirst(){
|
358
|
+
conf({}).create('').optionCenter('repos').set('rewpkgs', '//raw.githubusercontent.com/kevinJ045/rewpkgs/main/main.yaml');
|
359
|
+
}
|
360
|
+
};
|
package/lib/rew/const/default.js
CHANGED
@@ -1,42 +1,45 @@
|
|
1
|
-
const { cenum } = require(
|
2
|
-
const { struct } = require(
|
3
|
-
const emitter = require(
|
4
|
-
const future = require(
|
5
|
-
const sleep = require(
|
6
|
-
const { match } = require(
|
7
|
-
const { map } = require(
|
8
|
-
const { typex, typeis, typedef, typei, int, float, num, str, bool } = require(
|
9
|
-
const { isEmpty, clone, deepClone, merge, uniqueId, compose, curry } = require(
|
10
|
-
const { print, input } = require(
|
1
|
+
const { cenum } = require('../models/enum');
|
2
|
+
const { struct } = require('../models/struct');
|
3
|
+
const emitter = require('../functions/emitter');
|
4
|
+
const future = require('../functions/future');
|
5
|
+
const sleep = require('../functions/sleep');
|
6
|
+
const { match } = require('../functions/match');
|
7
|
+
const { map } = require('../functions/map');
|
8
|
+
const { typex, typeis, typedef, typei, int, float, num, str, bool } = require('../functions/types');
|
9
|
+
const { isEmpty, clone, deepClone, merge, uniqueId, compose, curry } = require('../functions/core');
|
10
|
+
const { print, input } = require('../functions/stdout');
|
11
|
+
const { curl } = require('../functions/curl');
|
11
12
|
|
12
13
|
module.exports = {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
cenum,
|
15
|
+
struct,
|
16
|
+
future,
|
17
|
+
emitter,
|
18
|
+
sleep,
|
19
|
+
match,
|
20
|
+
map,
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
typex,
|
23
|
+
typei,
|
24
|
+
typeis,
|
25
|
+
typedef,
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
int,
|
28
|
+
float,
|
29
|
+
num,
|
30
|
+
str,
|
31
|
+
bool,
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
isEmpty,
|
34
|
+
clone,
|
35
|
+
deepClone,
|
36
|
+
merge,
|
37
|
+
uniqueId,
|
38
|
+
compose,
|
39
|
+
curry,
|
39
40
|
|
40
|
-
|
41
|
-
|
41
|
+
curl,
|
42
|
+
|
43
|
+
print,
|
44
|
+
input,
|
42
45
|
};
|
package/lib/rew/const/files.js
CHANGED
@@ -2,14 +2,14 @@ const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
3
3
|
|
4
4
|
const HOME_PATH = path.resolve(process.env.HOME, '.config/rew/default');
|
5
|
-
const THEME_PATH = module.exports.THEME_PATH = path.resolve(HOME_PATH, 'theme.css');
|
5
|
+
const THEME_PATH = (module.exports.THEME_PATH = path.resolve(HOME_PATH, 'theme.css'));
|
6
6
|
|
7
7
|
module.exports.FILES = [
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
]
|
8
|
+
{
|
9
|
+
path: HOME_PATH,
|
10
|
+
},
|
11
|
+
{
|
12
|
+
path: THEME_PATH,
|
13
|
+
content: fs.readFileSync(path.resolve(__dirname, '../css/theme.css')),
|
14
|
+
},
|
15
|
+
];
|