wogiflow 1.0.9 → 1.0.11
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/unified-wizard.js +83 -1
- package/package.json +1 -1
- package/scripts/postinstall.js +14 -4
package/lib/unified-wizard.js
CHANGED
|
@@ -233,6 +233,88 @@ class UnifiedWizard {
|
|
|
233
233
|
return defaultKey || keys[0];
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Ask with inline placeholder (gray text that disappears when typing)
|
|
238
|
+
* Shows default value in dim/gray after the prompt, user can:
|
|
239
|
+
* - Press Enter to accept the default
|
|
240
|
+
* - Start typing to clear the default and enter custom value
|
|
241
|
+
*/
|
|
242
|
+
askWithPlaceholder(question, defaultValue = '') {
|
|
243
|
+
return new Promise((resolve) => {
|
|
244
|
+
// Fallback to regular prompt if no default, no TTY, or readline not available
|
|
245
|
+
if (!defaultValue || !process.stdin.isTTY || !process.stdin.setRawMode) {
|
|
246
|
+
return this.ask(question, defaultValue).then(resolve);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const prompt = `${question}: `;
|
|
250
|
+
const dim = '\x1b[2m'; // Dim/gray
|
|
251
|
+
const reset = '\x1b[0m'; // Reset
|
|
252
|
+
const clearLine = '\x1b[K'; // Clear to end of line
|
|
253
|
+
|
|
254
|
+
// Print prompt with dim default
|
|
255
|
+
process.stdout.write(prompt + dim + defaultValue + reset);
|
|
256
|
+
|
|
257
|
+
// Move cursor back to start of default value
|
|
258
|
+
process.stdout.write(`\x1b[${defaultValue.length}D`);
|
|
259
|
+
|
|
260
|
+
let userInput = '';
|
|
261
|
+
let usingDefault = true;
|
|
262
|
+
|
|
263
|
+
// Pause readline to take over stdin
|
|
264
|
+
this.rl.pause();
|
|
265
|
+
process.stdin.setRawMode(true);
|
|
266
|
+
process.stdin.resume();
|
|
267
|
+
|
|
268
|
+
const cleanup = () => {
|
|
269
|
+
process.stdin.setRawMode(false);
|
|
270
|
+
process.stdin.removeListener('data', onKeypress);
|
|
271
|
+
this.rl.resume();
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
const onKeypress = (key) => {
|
|
275
|
+
const char = key.toString();
|
|
276
|
+
|
|
277
|
+
// Enter key - accept current value
|
|
278
|
+
if (char === '\r' || char === '\n') {
|
|
279
|
+
cleanup();
|
|
280
|
+
process.stdout.write('\n');
|
|
281
|
+
resolve(usingDefault ? defaultValue : userInput);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Ctrl+C - exit
|
|
286
|
+
if (char === '\x03') {
|
|
287
|
+
cleanup();
|
|
288
|
+
process.stdout.write('\n');
|
|
289
|
+
process.exit();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Backspace
|
|
293
|
+
if (char === '\x7f' || char === '\b') {
|
|
294
|
+
if (userInput.length > 0) {
|
|
295
|
+
userInput = userInput.slice(0, -1);
|
|
296
|
+
process.stdout.write('\b \b');
|
|
297
|
+
}
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// First printable character typed - clear the dim default
|
|
302
|
+
if (usingDefault && char.length === 1 && char >= ' ') {
|
|
303
|
+
usingDefault = false;
|
|
304
|
+
process.stdout.write(clearLine); // Clear the dim default text
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Regular printable character
|
|
308
|
+
if (char.length === 1 && char >= ' ') {
|
|
309
|
+
userInput += char;
|
|
310
|
+
process.stdout.write(char);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
process.stdin.on('data', onKeypress);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
236
318
|
// ============================================
|
|
237
319
|
// STEP IMPLEMENTATIONS
|
|
238
320
|
// ============================================
|
|
@@ -256,7 +338,7 @@ class UnifiedWizard {
|
|
|
256
338
|
}
|
|
257
339
|
}
|
|
258
340
|
|
|
259
|
-
this.config.projectName = await this.
|
|
341
|
+
this.config.projectName = await this.askWithPlaceholder('Project name', detectedName);
|
|
260
342
|
}
|
|
261
343
|
|
|
262
344
|
async askProjectType() {
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -79,14 +79,24 @@ async function main() {
|
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
// Try to write directly to terminal (bypasses npm output capture)
|
|
83
|
+
let output = process.stderr; // Default fallback
|
|
84
|
+
try {
|
|
85
|
+
// Check if /dev/tty exists and is writable
|
|
86
|
+
fs.accessSync('/dev/tty', fs.constants.W_OK);
|
|
87
|
+
const fd = fs.openSync('/dev/tty', 'w');
|
|
88
|
+
output = { write: (msg) => fs.writeSync(fd, msg) };
|
|
89
|
+
} catch {
|
|
90
|
+
// Fallback to stderr if /dev/tty not available (Windows, CI, non-interactive)
|
|
91
|
+
}
|
|
92
|
+
|
|
82
93
|
// Already initialized - short message
|
|
83
94
|
if (isAlreadyInitialized()) {
|
|
84
|
-
|
|
85
|
-
process.stderr.write('\x1b[36mWogiFlow:\x1b[0m Already initialized. Run \x1b[33mnpx flow status\x1b[0m to see project state.\n');
|
|
95
|
+
output.write('\x1b[36mWogiFlow:\x1b[0m Already initialized. Run \x1b[33mnpx flow status\x1b[0m to see project state.\n');
|
|
86
96
|
return;
|
|
87
97
|
}
|
|
88
98
|
|
|
89
|
-
// Show setup instructions
|
|
99
|
+
// Show setup instructions
|
|
90
100
|
const msg = `
|
|
91
101
|
\x1b[36m╔════════════════════════════════════════════════════════════╗\x1b[0m
|
|
92
102
|
\x1b[36m║\x1b[0m \x1b[1mWogiFlow installed successfully!\x1b[0m \x1b[36m║\x1b[0m
|
|
@@ -98,7 +108,7 @@ async function main() {
|
|
|
98
108
|
\x1b[36mnpx flow init\x1b[0m \x1b[2m# For new projects\x1b[0m
|
|
99
109
|
|
|
100
110
|
`;
|
|
101
|
-
|
|
111
|
+
output.write(msg);
|
|
102
112
|
}
|
|
103
113
|
|
|
104
114
|
// Run
|