@taj-special/dravix-code 1.4.1 → 1.4.3
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/cli/index.js +26 -36
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -34,39 +34,34 @@ function markProjectVisited(hash) {
|
|
|
34
34
|
}
|
|
35
35
|
async function showFirstTimeDialog(projectName) {
|
|
36
36
|
const cols = process.stdout.columns ?? 80;
|
|
37
|
-
const W = Math.min(cols -
|
|
38
|
-
const inner = W + 2;
|
|
37
|
+
const W = Math.min(cols - 6, 56);
|
|
39
38
|
const BC = chalk.hex('#6366f1');
|
|
40
39
|
const Wt = chalk.hex('#e2e8f0');
|
|
41
40
|
const Dim = chalk.hex('#6b7280');
|
|
42
41
|
const G = chalk.hex('#34d399');
|
|
43
42
|
const R = chalk.hex('#f87171');
|
|
44
|
-
const head = chalk.hex('#a78bfa').bold('Dravix Code') + Dim(' - first time in this project');
|
|
45
|
-
const projText = chalk.hex('#c4b5fd').bold(' ' + projectName);
|
|
46
43
|
function row(text) {
|
|
47
44
|
const visible = text.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
48
|
-
const pad = Math.max(
|
|
49
|
-
return ' ' + BC('│') +
|
|
45
|
+
const pad = Math.max(W - visible, 0);
|
|
46
|
+
return ' ' + BC('│ ') + text + ' '.repeat(pad) + BC(' │');
|
|
50
47
|
}
|
|
51
|
-
function
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
return left + right + ' '.repeat(pad);
|
|
48
|
+
function btnRow(leftBtn, rightText) {
|
|
49
|
+
const lv = leftBtn.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
50
|
+
const rv = rightText.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
51
|
+
return ' ' + BC('│ ') + leftBtn + rightText + ' '.repeat(Math.max(W - lv - rv, 0)) + BC(' │');
|
|
56
52
|
}
|
|
57
53
|
console.clear();
|
|
58
|
-
console.log('');
|
|
59
|
-
console.log('
|
|
60
|
-
console.log(
|
|
61
|
-
console.log(' ' + BC('├' + '─'.repeat(inner) + '┤'));
|
|
54
|
+
console.log(' ' + BC('╭' + '─'.repeat(W + 2) + '╮'));
|
|
55
|
+
console.log(row(chalk.hex('#a78bfa').bold('Dravix Code') + Dim(' - first time in this project')));
|
|
56
|
+
console.log(' ' + BC('├' + '─'.repeat(W + 2) + '┤'));
|
|
62
57
|
console.log(row(Wt('Open Dravix Code in:')));
|
|
63
|
-
console.log(row(
|
|
64
|
-
console.log(' ' + BC('├' + '─'.repeat(
|
|
58
|
+
console.log(row(' ' + chalk.hex('#c4b5fd').bold(projectName)));
|
|
59
|
+
console.log(' ' + BC('├' + '─'.repeat(W + 2) + '┤'));
|
|
65
60
|
console.log(row(''));
|
|
66
|
-
console.log(
|
|
67
|
-
console.log(
|
|
61
|
+
console.log(btnRow(G.bold(' [ Enter ] '), Wt(' Yes, open here')));
|
|
62
|
+
console.log(btnRow(R.bold(' [ Esc ] '), Wt(' No, exit')));
|
|
68
63
|
console.log(row(''));
|
|
69
|
-
console.log(' ' + BC('╰' + '─'.repeat(
|
|
64
|
+
console.log(' ' + BC('╰' + '─'.repeat(W + 2) + '╯'));
|
|
70
65
|
console.log('');
|
|
71
66
|
return new Promise((resolve) => {
|
|
72
67
|
process.stdin.setRawMode(true);
|
|
@@ -266,6 +261,17 @@ async function main() {
|
|
|
266
261
|
const planBadge = plan === 'Plus'
|
|
267
262
|
? colors.accent.bold('Plus')
|
|
268
263
|
: colors.muted('Free');
|
|
264
|
+
// ── First-time project check ──────────────────────────────
|
|
265
|
+
const pHash = projectHash(cwd);
|
|
266
|
+
const visited = getVisitedProjects();
|
|
267
|
+
if (!visited.includes(pHash)) {
|
|
268
|
+
const open = await showFirstTimeDialog(path.basename(cwd));
|
|
269
|
+
if (!open) {
|
|
270
|
+
console.log(chalk.hex('#6b7280')('\n Exited.\n'));
|
|
271
|
+
process.exit(0);
|
|
272
|
+
}
|
|
273
|
+
markProjectVisited(pHash);
|
|
274
|
+
}
|
|
269
275
|
const rows = process.stdout.rows ?? 24;
|
|
270
276
|
const cols = process.stdout.columns ?? 80;
|
|
271
277
|
// FULL-SCREEN: clear everything, set scroll region to entire terminal
|
|
@@ -302,22 +308,6 @@ async function main() {
|
|
|
302
308
|
process.on('exit', cleanup);
|
|
303
309
|
process.on('SIGINT', () => { cleanup(); process.exit(0); });
|
|
304
310
|
process.on('SIGTERM', () => { cleanup(); process.exit(0); });
|
|
305
|
-
// ── First-time project check ──────────────────────────────
|
|
306
|
-
const pHash = projectHash(cwd);
|
|
307
|
-
const visited = getVisitedProjects();
|
|
308
|
-
if (!visited.includes(pHash)) {
|
|
309
|
-
process.stdin.setRawMode(false);
|
|
310
|
-
process.stdin.pause();
|
|
311
|
-
const open = await showFirstTimeDialog(path.basename(cwd));
|
|
312
|
-
if (!open) {
|
|
313
|
-
console.log(chalk.hex('#6b7280')('\n Exited.\n'));
|
|
314
|
-
process.exit(0);
|
|
315
|
-
}
|
|
316
|
-
markProjectVisited(pHash);
|
|
317
|
-
// Restore terminal for upcoming banner + REPL
|
|
318
|
-
process.stdin.setRawMode(true);
|
|
319
|
-
process.stdin.resume();
|
|
320
|
-
}
|
|
321
311
|
await startRepl(cwd);
|
|
322
312
|
}
|
|
323
313
|
main().catch((err) => {
|