@makano/rew 1.1.81 → 1.2.0
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/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 +296 -239
- package/lib/rew/cli/log.js +27 -27
- package/lib/rew/cli/run.js +8 -8
- package/lib/rew/cli/utils.js +353 -199
- package/lib/rew/const/config_path.js +2 -2
- package/lib/rew/const/default.js +38 -53
- package/lib/rew/const/files.js +11 -14
- package/lib/rew/const/opt.js +6 -6
- package/lib/rew/css/theme.css +1 -1
- package/lib/rew/functions/core.js +55 -55
- package/lib/rew/functions/curl.js +23 -0
- package/lib/rew/functions/emitter.js +52 -55
- package/lib/rew/functions/exec.js +25 -25
- package/lib/rew/functions/export.js +17 -17
- package/lib/rew/functions/fs.js +57 -59
- package/lib/rew/functions/future.js +29 -21
- package/lib/rew/functions/id.js +8 -9
- package/lib/rew/functions/import.js +106 -122
- package/lib/rew/functions/map.js +10 -10
- package/lib/rew/functions/match.js +35 -42
- package/lib/rew/functions/path.js +8 -8
- package/lib/rew/functions/require.js +32 -36
- package/lib/rew/functions/sleep.js +2 -2
- package/lib/rew/functions/stdout.js +18 -18
- package/lib/rew/functions/types.js +82 -106
- package/lib/rew/html/ui.html +12 -12
- package/lib/rew/html/ui.js +196 -201
- package/lib/rew/main.js +14 -14
- package/lib/rew/misc/bin.js +37 -0
- package/lib/rew/misc/findAppInfo.js +13 -13
- package/lib/rew/misc/findAppPath.js +15 -15
- package/lib/rew/misc/req.js +7 -0
- package/lib/rew/misc/seededid.js +8 -8
- package/lib/rew/models/enum.js +12 -12
- package/lib/rew/models/struct.js +30 -32
- package/lib/rew/modules/compiler.js +237 -209
- 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 -92
- package/lib/rew/pkgs/data.js +10 -10
- package/lib/rew/pkgs/date.js +27 -27
- package/lib/rew/pkgs/env.js +5 -5
- package/lib/rew/pkgs/modules/data/bintree.js +51 -51
- package/lib/rew/pkgs/modules/data/doublylinked.js +84 -84
- package/lib/rew/pkgs/modules/data/linkedList.js +72 -72
- package/lib/rew/pkgs/modules/data/queue.js +18 -18
- package/lib/rew/pkgs/modules/data/stack.js +18 -18
- package/lib/rew/pkgs/modules/threads/worker.js +36 -36
- package/lib/rew/pkgs/modules/ui/classes.js +181 -184
- package/lib/rew/pkgs/pkgs.js +9 -9
- package/lib/rew/pkgs/rune.js +373 -410
- package/lib/rew/pkgs/threads.js +62 -66
- package/lib/rew/pkgs/ui.js +148 -160
- package/lib/rew/qrew/compile.js +12 -0
- package/package.json +4 -3
package/lib/rew/cli/cli.js
CHANGED
|
@@ -1,250 +1,307 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const yargs = require(
|
|
4
|
-
const path = require(
|
|
5
|
-
const { hideBin } = require(
|
|
6
|
-
const { fork, exec, execSync } = require(
|
|
7
|
-
const { watch } = require(
|
|
8
|
-
const utils = require(
|
|
9
|
-
const { existsSync, readFileSync, writeFileSync, mkdirSync } = require(
|
|
10
|
-
const { log } = require(
|
|
11
|
-
const
|
|
12
|
-
const crypto = require(
|
|
3
|
+
const yargs = require('yargs/yargs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { hideBin } = require('yargs/helpers');
|
|
6
|
+
const { fork, exec, execSync } = require('child_process');
|
|
7
|
+
const { watch } = require('chokidar');
|
|
8
|
+
const utils = require('./utils');
|
|
9
|
+
const { existsSync, readFileSync, writeFileSync, mkdirSync } = require('fs');
|
|
10
|
+
const { log } = require('./log');
|
|
11
|
+
const os = require('os');
|
|
12
|
+
const crypto = require('crypto');
|
|
13
|
+
const { CONFIG_PATH } = require('../const/config_path');
|
|
14
|
+
const rune = require('../pkgs/rune');
|
|
15
|
+
const { to_qrew, from_qrew } = require('../qrew/compile');
|
|
16
|
+
const { findAppInfo } = require('../misc/findAppInfo');
|
|
17
|
+
const { print, input } = require('../functions/stdout');
|
|
18
|
+
const colors = require('colors');
|
|
19
|
+
|
|
20
|
+
if (!existsSync(CONFIG_PATH)) {
|
|
21
|
+
mkdirSync(CONFIG_PATH, { recursive: true });
|
|
22
|
+
utils.initFirst();
|
|
23
|
+
}
|
|
13
24
|
|
|
14
25
|
yargs(hideBin(process.argv))
|
|
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
|
-
|
|
26
|
+
.command(
|
|
27
|
+
'$0 <file>',
|
|
28
|
+
'Run the specified file',
|
|
29
|
+
(yargs) => {
|
|
30
|
+
yargs
|
|
31
|
+
.positional('file', {
|
|
32
|
+
describe: 'File to run',
|
|
33
|
+
type: 'string',
|
|
34
|
+
})
|
|
35
|
+
.option('watch', {
|
|
36
|
+
alias: 'w',
|
|
37
|
+
describe: 'Watch the file for changes',
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
(argv) => {
|
|
42
|
+
const filePath = path.resolve(process.cwd(), argv.file);
|
|
43
|
+
if (!existsSync(filePath)) {
|
|
44
|
+
log('File not found:', argv.file, ':end');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const watching = [];
|
|
48
|
+
const watchIt = (file) => {
|
|
49
|
+
if (watching.includes(file)) return;
|
|
50
|
+
watch(file).on('change', () => runIt());
|
|
51
|
+
watching.push(file);
|
|
52
|
+
};
|
|
53
|
+
let prevFork;
|
|
54
|
+
const runIt = () => {
|
|
55
|
+
if (argv.watch) console.clear();
|
|
56
|
+
if (prevFork && !prevFork.killed) prevFork.kill?.();
|
|
57
|
+
prevFork = fork(path.resolve(__dirname, './run.js'))
|
|
58
|
+
.on('message', (data) => {
|
|
59
|
+
if (argv.watch) {
|
|
60
|
+
data.forEach((file) => {
|
|
61
|
+
watchIt(file);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
.send({ filePath, watch: argv.watch });
|
|
66
|
+
if (argv.watch) watchIt(filePath);
|
|
67
|
+
};
|
|
68
|
+
runIt();
|
|
69
|
+
},
|
|
70
|
+
)
|
|
71
|
+
.command(
|
|
72
|
+
'conf <command> [path] [key] [value]',
|
|
73
|
+
'Configuration management',
|
|
74
|
+
(yargs) => {
|
|
75
|
+
yargs
|
|
76
|
+
.positional('command', {
|
|
77
|
+
describe: 'Configuration command (get, set, remove)',
|
|
78
|
+
type: 'string',
|
|
79
|
+
choices: ['get', 'set', 'remove'],
|
|
80
|
+
})
|
|
81
|
+
.positional('path', {
|
|
82
|
+
describe: 'Configuration path',
|
|
83
|
+
type: 'string',
|
|
84
|
+
default: '',
|
|
85
|
+
})
|
|
86
|
+
.positional('key', {
|
|
87
|
+
describe: 'Key to get/set/remove',
|
|
88
|
+
type: 'string',
|
|
89
|
+
default: '',
|
|
90
|
+
})
|
|
91
|
+
.positional('value', {
|
|
92
|
+
describe: 'Value to set (only used with "set" command)',
|
|
93
|
+
type: 'string',
|
|
94
|
+
default: '',
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
(argv) => {
|
|
98
|
+
const { command, path, key, value } = argv;
|
|
99
|
+
const result = utils.conf(command, path, key, value);
|
|
100
|
+
if (result) console.log(result);
|
|
101
|
+
},
|
|
102
|
+
)
|
|
103
|
+
.command(
|
|
104
|
+
'create <path>',
|
|
105
|
+
'Create a new project',
|
|
106
|
+
(yargs) => {
|
|
107
|
+
yargs.positional('path', {
|
|
108
|
+
describe: 'Path of the project to create',
|
|
109
|
+
type: 'string',
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
(argv) => {
|
|
113
|
+
utils.createProject(argv.path);
|
|
114
|
+
},
|
|
115
|
+
)
|
|
116
|
+
.command(
|
|
117
|
+
'rune-keygen',
|
|
118
|
+
'Generate a rune encryption key',
|
|
119
|
+
(yargs) => {
|
|
120
|
+
},
|
|
121
|
+
(argv) => {
|
|
122
|
+
console.log('Encryption Key:', rune({}).genKey(input('Secret Value: ') || null));
|
|
123
|
+
},
|
|
124
|
+
)
|
|
125
|
+
.command(
|
|
126
|
+
'ui-bin <path>',
|
|
127
|
+
'Build the UI bin for your own app',
|
|
128
|
+
(yargs) => {
|
|
129
|
+
yargs.positional('path', {
|
|
130
|
+
describe: 'Path of the output bin',
|
|
131
|
+
type: 'string',
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
(argv) => {
|
|
135
|
+
execSync('sh ' + path.resolve(__dirname, '../../../build.sh') + ' ' + argv.path);
|
|
136
|
+
},
|
|
137
|
+
)
|
|
138
|
+
.command(
|
|
139
|
+
'run <path | package>',
|
|
140
|
+
'Run an app',
|
|
141
|
+
(yargs) => {
|
|
142
|
+
yargs.positional('path', {
|
|
143
|
+
describe: 'Path of the app to run',
|
|
144
|
+
type: 'string',
|
|
145
|
+
})
|
|
146
|
+
.option('dev', {
|
|
147
|
+
describe: 'If your entry file is a .qrew, then just use the .coffee instead',
|
|
148
|
+
type: 'boolean',
|
|
149
|
+
})
|
|
150
|
+
.option('build', {
|
|
151
|
+
alias: 'b',
|
|
152
|
+
describe: 'Builds to a .qrew before running',
|
|
153
|
+
type: 'boolean',
|
|
154
|
+
})
|
|
155
|
+
.option('translate', {
|
|
156
|
+
alias: 't',
|
|
157
|
+
describe: 'Builds to a .js before running, only used when --build is passed',
|
|
158
|
+
type: 'boolean',
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
(argv) => {
|
|
162
|
+
utils.runApp(argv.path, argv);
|
|
163
|
+
},
|
|
164
|
+
)
|
|
165
|
+
.command(
|
|
166
|
+
'secret <command> [key]',
|
|
167
|
+
'Add secrets to the current path',
|
|
168
|
+
(yargs) => {
|
|
169
|
+
yargs.positional('command', {
|
|
170
|
+
describe: 'Path of the app to run',
|
|
171
|
+
type: 'string',
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
(argv) => {
|
|
175
|
+
const appPath = findAppInfo(path.join(process.cwd(), 'app.yaml'));
|
|
176
|
+
|
|
177
|
+
if (!appPath) return log(''.red.bold, 'Secrets only available in apps'.red.bold, ':end');
|
|
178
|
+
|
|
179
|
+
const qrewPath = path.join(appPath.path, 'secrets.qrew');
|
|
180
|
+
|
|
181
|
+
const getHost = () => `${process.env.USER}@${os.platform()}.${os.hostname()}`;
|
|
182
|
+
|
|
183
|
+
const verifyUser = (content) => {
|
|
184
|
+
const owner = content.match(/^owner = "(.*)" # end$/m)?.[1];
|
|
185
|
+
if (owner == getHost()) return true;
|
|
186
|
+
return false;
|
|
187
|
+
};
|
|
122
188
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"ui-bin <path>",
|
|
129
|
-
"Build the UI bin for your own app",
|
|
130
|
-
(yargs) => {
|
|
131
|
-
yargs.positional("path", {
|
|
132
|
-
describe: "Path of the output bin",
|
|
133
|
-
type: "string",
|
|
134
|
-
});
|
|
135
|
-
},
|
|
136
|
-
(argv) => {
|
|
137
|
-
execSync(
|
|
138
|
-
"sh " + path.resolve(__dirname, "../../../build.sh") + " " + argv.path,
|
|
139
|
-
);
|
|
140
|
-
},
|
|
141
|
-
)
|
|
142
|
-
.command(
|
|
143
|
-
"run <path | package>",
|
|
144
|
-
"Run an app",
|
|
145
|
-
(yargs) => {
|
|
146
|
-
yargs.positional("path", {
|
|
147
|
-
describe: "Path of the app to run",
|
|
148
|
-
type: "string",
|
|
149
|
-
});
|
|
150
|
-
},
|
|
151
|
-
(argv) => {
|
|
152
|
-
utils.runApp(argv.path);
|
|
153
|
-
},
|
|
154
|
-
)
|
|
155
|
-
.command(
|
|
156
|
-
"install <path>",
|
|
157
|
-
"Install an app",
|
|
158
|
-
(yargs) => {
|
|
159
|
-
yargs.positional("path", {
|
|
160
|
-
describe: "Path of the app to install",
|
|
161
|
-
type: "string",
|
|
162
|
-
});
|
|
163
|
-
},
|
|
164
|
-
async (argv) => {
|
|
165
|
-
if (argv.path.startsWith("github:"))
|
|
166
|
-
utils.installApp(await utils.cloneGit(argv.path), true, true);
|
|
167
|
-
else utils.installApp(argv.path);
|
|
168
|
-
},
|
|
169
|
-
)
|
|
170
|
-
.command(
|
|
171
|
-
"build <file>",
|
|
172
|
-
"Build the specified file",
|
|
173
|
-
(yargs) => {
|
|
174
|
-
yargs
|
|
175
|
-
.positional("file", {
|
|
176
|
-
describe: "File to build",
|
|
177
|
-
type: "string",
|
|
178
|
-
})
|
|
179
|
-
.option("output", {
|
|
180
|
-
alias: "o",
|
|
181
|
-
describe: "Output directory",
|
|
182
|
-
type: "string",
|
|
183
|
-
});
|
|
184
|
-
},
|
|
185
|
-
(argv) => {
|
|
186
|
-
function readFile(filePath) {
|
|
187
|
-
return readFileSync(filePath, { encoding: "utf-8" });
|
|
188
|
-
}
|
|
189
|
+
if (argv.command == 'init') {
|
|
190
|
+
writeFileSync(qrewPath, to_qrew(`secrets = {} # end\n\nowner = "${getHost()}" # end\n \nexports { ...secrets }`, appPath.config.package))
|
|
191
|
+
} else {
|
|
192
|
+
const currentFileContent = from_qrew(readFileSync(qrewPath), appPath.config.package).toString();
|
|
193
|
+
if (!verifyUser(currentFileContent)) return log(''.red.bold, 'You are not allowed to change this data'.red.bold, ':end');
|
|
189
194
|
|
|
190
|
-
|
|
191
|
-
const importRegex = /(\w+)\s*=\s*imp\s*['"](.+?)['"]/g;
|
|
192
|
-
const imports = [];
|
|
193
|
-
let match;
|
|
194
|
-
while ((match = importRegex.exec(content)) !== null) {
|
|
195
|
-
imports.push({ variable: match[1], url: match[2] });
|
|
196
|
-
}
|
|
197
|
-
return imports;
|
|
198
|
-
}
|
|
195
|
+
const secrets = currentFileContent.match(/^secrets = (.*) # end$/m)?.[1];
|
|
199
196
|
|
|
200
|
-
|
|
201
|
-
const dirName = outputDir ? outputDir : path.dirname(filePath);
|
|
202
|
-
if (!existsSync(dirName)) mkdirSync(dirName, { recursive: true });
|
|
203
|
-
const baseName = path.basename(filePath, path.extname(filePath));
|
|
204
|
-
const newFilePath = path.join(dirName, `${baseName}.js`);
|
|
205
|
-
writeFileSync(newFilePath, compiledCode, { encoding: "utf-8" });
|
|
206
|
-
log(`Compiled: ${newFilePath}`);
|
|
207
|
-
}
|
|
197
|
+
let secretsJson = JSON.parse(secrets);
|
|
208
198
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
199
|
+
if (argv.command == 'set' || argv.command == 'remove') {
|
|
200
|
+
if (argv.command == 'set') {
|
|
201
|
+
let val = input('Secret Value: ');
|
|
212
202
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
);
|
|
218
|
-
if (
|
|
219
|
-
!importsArray.some(
|
|
220
|
-
(importObj) => importObj.url === importStatement.url,
|
|
221
|
-
)
|
|
222
|
-
) {
|
|
223
|
-
if (existsSync(importedFilePath)) {
|
|
224
|
-
importsArray.push(importStatement);
|
|
225
|
-
processFile(importedFilePath, importsArray);
|
|
226
|
-
} else if (existsSync(importedFilePath + ".coffee")) {
|
|
227
|
-
importsArray.push(importStatement);
|
|
228
|
-
processFile(importedFilePath + ".coffee", importsArray);
|
|
229
|
-
} else if (existsSync(importedFilePath + ".js")) {
|
|
230
|
-
importsArray.push(importStatement);
|
|
231
|
-
processFile(importedFilePath + ".js", importsArray);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
});
|
|
203
|
+
secretsJson[argv.key] = val;
|
|
204
|
+
} else {
|
|
205
|
+
delete secretsJson[argv.key];
|
|
206
|
+
}
|
|
235
207
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
208
|
+
const newSecrets = `secrets = ${JSON.stringify(secretsJson)} # end`;
|
|
209
|
+
const newFileContent = currentFileContent.replace(/^secrets = .* # end$/m, newSecrets);
|
|
239
210
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
211
|
+
writeFileSync(qrewPath, to_qrew(newFileContent, appPath.config.package))
|
|
212
|
+
} else if (argv.command == 'get') {
|
|
213
|
+
if (argv.key) {
|
|
214
|
+
console.log(argv.key.yellow, '=', secretsJson[argv.key].green);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
for (let key in secretsJson) {
|
|
218
|
+
console.log(key.yellow, '=', secretsJson[key].green);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
)
|
|
225
|
+
.command(
|
|
226
|
+
'install <path>',
|
|
227
|
+
'Install an app',
|
|
228
|
+
(yargs) => {
|
|
229
|
+
yargs.positional('path', {
|
|
230
|
+
describe: 'Path of the app to install',
|
|
231
|
+
type: 'string',
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
async (argv) => {
|
|
235
|
+
utils.installAppFrom(argv.path);
|
|
236
|
+
},
|
|
237
|
+
)
|
|
238
|
+
.command(
|
|
239
|
+
'version',
|
|
240
|
+
'Rew Version',
|
|
241
|
+
(yargs) => {
|
|
242
|
+
},
|
|
243
|
+
async (argv) => {
|
|
244
|
+
const pkg = JSON.parse(readFileSync(path.resolve(__dirname, '../../../package.json'), { encoding: 'utf-8' }));
|
|
245
|
+
const getLatest = async () => {
|
|
246
|
+
try{
|
|
247
|
+
return (await (await fetch(`https://registry.npmjs.org/${pkg.name}`)).json()).dist_tags.latest.yellow.bold
|
|
248
|
+
} catch(e) {
|
|
249
|
+
return `(${'!err'.blue.bgRed}, see ${`https://npmjs.com/package/${pkg.name}`.blue.underline})`;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
log(`${'Rew'.red.bold} ${'RUNTIME'.yellow}`);
|
|
253
|
+
log(`Version: ${pkg.name.green}@${pkg.version.yellow.bold}`);
|
|
254
|
+
log(`Latest: ${pkg.name}@${await getLatest()}`, ':end');
|
|
255
|
+
},
|
|
256
|
+
)
|
|
257
|
+
.command(
|
|
258
|
+
'repo <command> [name] [url]',
|
|
259
|
+
'Manage install repositories',
|
|
260
|
+
(yargs) => {
|
|
261
|
+
yargs.positional('command', {
|
|
262
|
+
describe: 'Command to add/remove/set/get/view',
|
|
263
|
+
type: 'string',
|
|
264
|
+
});
|
|
265
|
+
yargs.positional('name', {
|
|
266
|
+
describe: 'name of the repo',
|
|
267
|
+
type: 'string',
|
|
268
|
+
});
|
|
269
|
+
yargs.positional('url', {
|
|
270
|
+
describe: 'url of the repo',
|
|
271
|
+
type: 'string',
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
async (argv) => {
|
|
275
|
+
utils.repo(argv.command, argv.name, argv.url);
|
|
276
|
+
},
|
|
277
|
+
)
|
|
278
|
+
.command(
|
|
279
|
+
'build <file>',
|
|
280
|
+
'Build the specified file',
|
|
281
|
+
(yargs) => {
|
|
282
|
+
yargs
|
|
283
|
+
.positional('file', {
|
|
284
|
+
describe: 'File to build',
|
|
285
|
+
type: 'string',
|
|
286
|
+
})
|
|
287
|
+
.option('output', {
|
|
288
|
+
alias: 'o',
|
|
289
|
+
describe: 'Output directory',
|
|
290
|
+
type: 'string',
|
|
291
|
+
})
|
|
292
|
+
.option('translate', {
|
|
293
|
+
alias: 't',
|
|
294
|
+
describe: 'Translate to js',
|
|
295
|
+
type: 'boolean',
|
|
296
|
+
})
|
|
297
|
+
.option('remove', {
|
|
298
|
+
alias: 'r',
|
|
299
|
+
describe: 'Remove all coffee',
|
|
300
|
+
type: 'boolean',
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
(argv) => {
|
|
304
|
+
utils.build(argv);
|
|
305
|
+
},
|
|
306
|
+
)
|
|
307
|
+
.help().argv;
|
package/lib/rew/cli/log.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
let start = true;
|
|
2
|
-
const startPrefix =
|
|
3
|
-
const middlePrefix =
|
|
4
|
-
const separator =
|
|
5
|
-
const endPrefix =
|
|
2
|
+
const startPrefix = '╭';
|
|
3
|
+
const middlePrefix = '├';
|
|
4
|
+
const separator = '│';
|
|
5
|
+
const endPrefix = '╰';
|
|
6
6
|
|
|
7
7
|
const log = (module.exports.log = function (...toPrint) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
let prefix = start ? startPrefix : middlePrefix;
|
|
9
|
+
let returns = false;
|
|
10
|
+
if (toPrint[toPrint.length - 1] == ':end') {
|
|
11
|
+
prefix = endPrefix;
|
|
12
|
+
toPrint.pop();
|
|
13
|
+
}
|
|
14
|
+
if (toPrint[toPrint.length - 1] == ':returns') {
|
|
15
|
+
returns = true;
|
|
16
|
+
toPrint.pop();
|
|
17
|
+
}
|
|
18
|
+
if (prefix == endPrefix && start) prefix = separator;
|
|
19
|
+
if (!start) console.log(separator);
|
|
20
|
+
if (start) start = false;
|
|
21
|
+
if (returns) return [prefix, ...toPrint].join(' ');
|
|
22
|
+
else console.log(prefix, ...toPrint);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
module.exports.logget = function (...toPrint) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
let args = [...toPrint];
|
|
27
|
+
if (toPrint[toPrint.length - 1] == ':end') {
|
|
28
|
+
let l = args.pop();
|
|
29
|
+
args.push(':returns', l);
|
|
30
|
+
} else {
|
|
31
|
+
args.push(':returns');
|
|
32
|
+
}
|
|
33
|
+
return log(...args);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
log.startPrefix = startPrefix;
|
package/lib/rew/cli/run.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const { run } = require(
|
|
1
|
+
const { run } = require('../main');
|
|
2
2
|
|
|
3
3
|
function exec(filePath) {
|
|
4
|
-
|
|
4
|
+
return run(filePath).context.module.imports;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
const onmsg = ({ filePath, watch }) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const imports = exec(filePath);
|
|
9
|
+
if (watch) {
|
|
10
|
+
process.send(imports);
|
|
11
|
+
}
|
|
12
|
+
process.off('message', onmsg);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
process.on(
|
|
15
|
+
process.on('message', onmsg);
|