starlight-cli 1.0.8 → 1.0.9
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/dist/index.js +36 -16
- package/package.json +1 -1
- package/src/starlight.js +28 -16
package/dist/index.js
CHANGED
|
@@ -2396,6 +2396,14 @@ module.exports = require("os");
|
|
|
2396
2396
|
"use strict";
|
|
2397
2397
|
module.exports = require("path");
|
|
2398
2398
|
|
|
2399
|
+
/***/ }),
|
|
2400
|
+
|
|
2401
|
+
/***/ 785:
|
|
2402
|
+
/***/ ((module) => {
|
|
2403
|
+
|
|
2404
|
+
"use strict";
|
|
2405
|
+
module.exports = require("readline");
|
|
2406
|
+
|
|
2399
2407
|
/***/ })
|
|
2400
2408
|
|
|
2401
2409
|
/******/ });
|
|
@@ -2446,7 +2454,7 @@ const Lexer = __nccwpck_require__(211);
|
|
|
2446
2454
|
const Parser = __nccwpck_require__(222);
|
|
2447
2455
|
const Evaluator = __nccwpck_require__(112);
|
|
2448
2456
|
|
|
2449
|
-
const VERSION = '1.0.
|
|
2457
|
+
const VERSION = '1.0.9';
|
|
2450
2458
|
|
|
2451
2459
|
const COLOR = {
|
|
2452
2460
|
reset: '\x1b[0m',
|
|
@@ -2526,31 +2534,43 @@ if (args[0] === '--learn') {
|
|
|
2526
2534
|
}
|
|
2527
2535
|
|
|
2528
2536
|
if (args[0] === '--writedirectly') {
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
let input = '';
|
|
2537
|
+
const readline = __nccwpck_require__(785);
|
|
2538
|
+
const tempFile = path.join(os.tmpdir(), `starlight-temp-${Date.now()}.sl`);
|
|
2533
2539
|
|
|
2534
|
-
|
|
2535
|
-
|
|
2540
|
+
console.log(COLOR.green + 'Interactive Starlight Editor' + COLOR.reset);
|
|
2541
|
+
console.log(COLOR.gray + 'Type your code. Enter ":run" on a new line to execute.\n' + COLOR.reset);
|
|
2536
2542
|
|
|
2537
|
-
|
|
2538
|
-
input
|
|
2543
|
+
const rl = readline.createInterface({
|
|
2544
|
+
input: process.stdin,
|
|
2545
|
+
output: process.stdout,
|
|
2546
|
+
prompt: COLOR.cyan + '> ' + COLOR.reset
|
|
2539
2547
|
});
|
|
2540
2548
|
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
`starlight-temp-${Date.now()}.sl`
|
|
2545
|
-
);
|
|
2549
|
+
let lines = [];
|
|
2550
|
+
|
|
2551
|
+
rl.prompt();
|
|
2546
2552
|
|
|
2547
|
-
|
|
2553
|
+
rl.on('line', (line) => {
|
|
2554
|
+
if (line.trim() === ':run') {
|
|
2555
|
+
rl.close();
|
|
2556
|
+
fs.writeFileSync(tempFile, lines.join('\n'), 'utf8');
|
|
2557
|
+
runFile(tempFile, true);
|
|
2558
|
+
return;
|
|
2559
|
+
}
|
|
2548
2560
|
|
|
2549
|
-
|
|
2561
|
+
let coloredLine = line
|
|
2562
|
+
.replace(/"(.*?)"/g, COLOR.yellow + '"$1"' + COLOR.reset)
|
|
2563
|
+
.replace(/\b(sldeploy|import|from|const|let|var|if|else|for|while)\b/g, COLOR.blue + '$1' + COLOR.reset);
|
|
2564
|
+
|
|
2565
|
+
console.log(coloredLine);
|
|
2566
|
+
|
|
2567
|
+
lines.push(line);
|
|
2568
|
+
rl.prompt();
|
|
2550
2569
|
});
|
|
2551
2570
|
|
|
2552
2571
|
return;
|
|
2553
2572
|
}
|
|
2573
|
+
|
|
2554
2574
|
function runFile(filePath, isTemp = false) {
|
|
2555
2575
|
if (!fs.existsSync(filePath)) {
|
|
2556
2576
|
return fatal(`File not found: ${filePath}`);
|
package/package.json
CHANGED
package/src/starlight.js
CHANGED
|
@@ -7,7 +7,7 @@ const Lexer = require('./lexer');
|
|
|
7
7
|
const Parser = require('./parser');
|
|
8
8
|
const Evaluator = require('./evaluator');
|
|
9
9
|
|
|
10
|
-
const VERSION = '1.0.
|
|
10
|
+
const VERSION = '1.0.9';
|
|
11
11
|
|
|
12
12
|
const COLOR = {
|
|
13
13
|
reset: '\x1b[0m',
|
|
@@ -87,31 +87,43 @@ if (args[0] === '--learn') {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
if (args[0] === '--writedirectly') {
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
const readline = require('readline');
|
|
91
|
+
const tempFile = path.join(os.tmpdir(), `starlight-temp-${Date.now()}.sl`);
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
console.log(COLOR.green + 'Interactive Starlight Editor' + COLOR.reset);
|
|
94
|
+
console.log(COLOR.gray + 'Type your code. Enter ":run" on a new line to execute.\n' + COLOR.reset);
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
input += chunk;
|
|
96
|
+
const rl = readline.createInterface({
|
|
97
|
+
input: process.stdin,
|
|
98
|
+
output: process.stdout,
|
|
99
|
+
prompt: COLOR.cyan + '> ' + COLOR.reset
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
const tempFile = path.join(
|
|
104
|
-
os.tmpdir(),
|
|
105
|
-
`starlight-temp-${Date.now()}.sl`
|
|
106
|
-
);
|
|
102
|
+
let lines = [];
|
|
107
103
|
|
|
108
|
-
|
|
104
|
+
rl.prompt();
|
|
105
|
+
|
|
106
|
+
rl.on('line', (line) => {
|
|
107
|
+
if (line.trim() === ':run') {
|
|
108
|
+
rl.close();
|
|
109
|
+
fs.writeFileSync(tempFile, lines.join('\n'), 'utf8');
|
|
110
|
+
runFile(tempFile, true);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
109
113
|
|
|
110
|
-
|
|
114
|
+
let coloredLine = line
|
|
115
|
+
.replace(/"(.*?)"/g, COLOR.yellow + '"$1"' + COLOR.reset)
|
|
116
|
+
.replace(/\b(sldeploy|import|from|const|let|var|if|else|for|while)\b/g, COLOR.blue + '$1' + COLOR.reset);
|
|
117
|
+
|
|
118
|
+
console.log(coloredLine);
|
|
119
|
+
|
|
120
|
+
lines.push(line);
|
|
121
|
+
rl.prompt();
|
|
111
122
|
});
|
|
112
123
|
|
|
113
124
|
return;
|
|
114
125
|
}
|
|
126
|
+
|
|
115
127
|
function runFile(filePath, isTemp = false) {
|
|
116
128
|
if (!fs.existsSync(filePath)) {
|
|
117
129
|
return fatal(`File not found: ${filePath}`);
|