@makano/rew 1.2.43 → 1.2.46
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/rew/cli/cli.js +6 -1
- package/lib/rew/cli/run.js +2 -2
- package/lib/rew/cli/utils.js +1 -1
- package/lib/rew/modules/compiler.js +17 -1
- package/lib/rew/pkgs/rune.js +8 -1
- package/package.json +1 -1
package/lib/rew/cli/cli.js
CHANGED
|
@@ -48,6 +48,11 @@ yargs(hideBin(process.argv))
|
|
|
48
48
|
alias: 'w',
|
|
49
49
|
describe: 'Watch the file for changes',
|
|
50
50
|
type: 'boolean',
|
|
51
|
+
})
|
|
52
|
+
.option('compile', {
|
|
53
|
+
alias: 'c',
|
|
54
|
+
describe: 'Compile and output the javascript',
|
|
55
|
+
type: 'boolean',
|
|
51
56
|
});
|
|
52
57
|
},
|
|
53
58
|
(argv) => {
|
|
@@ -56,7 +61,7 @@ yargs(hideBin(process.argv))
|
|
|
56
61
|
log('File not found:'.red.bold, argv.file, ':end');
|
|
57
62
|
return;
|
|
58
63
|
}
|
|
59
|
-
utils.runFileWithArgv(filePath, { watch: argv.watch });
|
|
64
|
+
utils.runFileWithArgv(filePath, { onlyCompile: argv.compile, watch: argv.watch });
|
|
60
65
|
},
|
|
61
66
|
)
|
|
62
67
|
.command(
|
package/lib/rew/cli/run.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// run.js
|
|
2
2
|
const { run } = require('../main');
|
|
3
3
|
|
|
4
|
-
function exec(filePath, argv) {
|
|
5
|
-
return run(filePath, { argv })?.context?.module?.imports || [];
|
|
4
|
+
function exec(filePath, argv, options = {}) {
|
|
5
|
+
return run(filePath, { argv, ...options })?.context?.module?.imports || [];
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
module.exports = { execRewFile: exec };
|
package/lib/rew/cli/utils.js
CHANGED
|
@@ -35,7 +35,7 @@ module.exports = {
|
|
|
35
35
|
|
|
36
36
|
const runIt = () => {
|
|
37
37
|
if (options.watch) console.clear();
|
|
38
|
-
const imports = execRewFile(filePath, [filePath, ...(argv || [])]);
|
|
38
|
+
const imports = execRewFile(filePath, [filePath, ...(argv || [])], { onlyCompile: options?.onlyCompile });
|
|
39
39
|
if (options.watch) {
|
|
40
40
|
imports.forEach((file) => {
|
|
41
41
|
watchIt(file);
|
|
@@ -145,6 +145,15 @@ function compileRewStuff(content, options) {
|
|
|
145
145
|
continue;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
|
|
149
|
+
if (token.type === 'IDENTIFIER' && token.value === 'let') {
|
|
150
|
+
result += '`'
|
|
151
|
+
hooks.push({
|
|
152
|
+
index: fnextToken(i, tokens, 'OTHER', ';').ti,
|
|
153
|
+
value: `\``,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
148
157
|
if (token.type === 'IDENTIFIER' && token.value === 'import') {
|
|
149
158
|
// console.log(nextToken.type);
|
|
150
159
|
let ind = i + n + 2;
|
|
@@ -254,13 +263,20 @@ const cpl = (module.exports.compile = function (file, options = {}) {
|
|
|
254
263
|
|
|
255
264
|
module.exports.compileFile = function (filepath, options = {}) {
|
|
256
265
|
const f = getFile(filepath);
|
|
266
|
+
let qrew = false;
|
|
257
267
|
|
|
258
268
|
if(options.qrew || path.extname(filepath) == '.qrew') {
|
|
269
|
+
qrew = true
|
|
259
270
|
f.content = from_qrew(readFileSync(f.path), options.package || findAppInfo(filepath)?.config.manifest.package || path.basename(filepath).split('.').slice(0, -1).join('.')).toString();
|
|
260
|
-
}
|
|
271
|
+
}
|
|
261
272
|
|
|
262
273
|
let compiled_code = cpl(f, { ...options });
|
|
263
274
|
|
|
275
|
+
if(options.onlyCompile && !qrew){
|
|
276
|
+
console.log(compiled_code);
|
|
277
|
+
process.exit();
|
|
278
|
+
}
|
|
279
|
+
|
|
264
280
|
return {
|
|
265
281
|
compiled_code,
|
|
266
282
|
file: f,
|
package/lib/rew/pkgs/rune.js
CHANGED
|
@@ -169,6 +169,7 @@ const createDB = (dbName, dirname, dbData = {}, encryptionKey) => {
|
|
|
169
169
|
};
|
|
170
170
|
|
|
171
171
|
const update = (caseRecord, newRecord) => {
|
|
172
|
+
|
|
172
173
|
let id;
|
|
173
174
|
if (typeof caseRecord === 'string') {
|
|
174
175
|
id = caseRecord;
|
|
@@ -224,6 +225,9 @@ const createDB = (dbName, dirname, dbData = {}, encryptionKey) => {
|
|
|
224
225
|
if (typeof criteria == 'string') return read(criteria);
|
|
225
226
|
if (!criteria || typeof criteria !== 'object') return null;
|
|
226
227
|
|
|
228
|
+
|
|
229
|
+
if (!fs.existsSync(collectionFilePath)) writeDataFile(collectionFilePath, []);
|
|
230
|
+
|
|
227
231
|
const data = readDataFile(collectionFilePath);
|
|
228
232
|
const record =
|
|
229
233
|
data.find((record) => {
|
|
@@ -240,7 +244,6 @@ const createDB = (dbName, dirname, dbData = {}, encryptionKey) => {
|
|
|
240
244
|
|
|
241
245
|
const remove = (id) => {
|
|
242
246
|
if ('@rune.id' in id) id = id['@rune.id'];
|
|
243
|
-
if (!fs.existsSync(collectionFilePath)) return false;
|
|
244
247
|
let data = readDataFile(collectionFilePath);
|
|
245
248
|
const index = data.findIndex((record) => record['@rune.id'] === id);
|
|
246
249
|
if (index !== -1) {
|
|
@@ -293,6 +296,8 @@ const createDB = (dbName, dirname, dbData = {}, encryptionKey) => {
|
|
|
293
296
|
return sortedData;
|
|
294
297
|
};
|
|
295
298
|
|
|
299
|
+
if (!fs.existsSync(collectionFilePath)) writeDataFile(collectionFilePath, []);
|
|
300
|
+
|
|
296
301
|
return {
|
|
297
302
|
insert,
|
|
298
303
|
read,
|
|
@@ -377,6 +382,8 @@ const createDB = (dbName, dirname, dbData = {}, encryptionKey) => {
|
|
|
377
382
|
return data;
|
|
378
383
|
};
|
|
379
384
|
|
|
385
|
+
if (!fs.existsSync(mapFilePath)) writeDataFile(mapFilePath, {});
|
|
386
|
+
|
|
380
387
|
return { set, get, remove, list, transform };
|
|
381
388
|
};
|
|
382
389
|
|