fabrica-e-commerce 0.2.6 → 0.2.7
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/package.json +1 -1
- package/src/bridge.js +4 -2
- package/src/prompt.js +3 -2
- package/src/ui.js +6 -0
package/package.json
CHANGED
package/src/bridge.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BRIDGE_API_KEY, BRIDGE_ORIGIN, POLL_INTERVAL_MS, POLL_TIMEOUT_MS } from './config.js';
|
|
2
2
|
import { FULL_SQL } from './sql.js';
|
|
3
3
|
import { openUrl } from './system.js';
|
|
4
|
-
import { spinner, log } from './ui.js';
|
|
4
|
+
import { spinner, log, logLive, cyan } from './ui.js';
|
|
5
5
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
6
6
|
export async function connectSupabase() {
|
|
7
7
|
const spin = spinner('Posting secure schema job to Fabrica Connect');
|
|
@@ -9,8 +9,10 @@ export async function connectSupabase() {
|
|
|
9
9
|
if (!response.ok) throw new Error(`Bridge rejected job: ${response.status} ${await response.text()}`);
|
|
10
10
|
const job = await response.json();
|
|
11
11
|
spin.succeed('Bridge job created');
|
|
12
|
-
|
|
12
|
+
logLive(`Opening browser for Supabase authorization: ${cyan(job.connectUrl)}`);
|
|
13
|
+
log(`Opened browser for Supabase authorization: ${job.connectUrl}`);
|
|
13
14
|
await openUrl(job.connectUrl);
|
|
15
|
+
logLive(`If the browser did not open automatically, open this URL: ${cyan(job.connectUrl)}`);
|
|
14
16
|
const started = Date.now();
|
|
15
17
|
const poll = spinner('Waiting for Supabase authorization and project selection');
|
|
16
18
|
while (Date.now() - started < POLL_TIMEOUT_MS) {
|
package/src/prompt.js
CHANGED
|
@@ -74,7 +74,7 @@ export async function choose(message, choices) {
|
|
|
74
74
|
|
|
75
75
|
function render(first) {
|
|
76
76
|
if (!first) process.stdout.write(`\x1b[${choices.length + 1}A`);
|
|
77
|
-
console.log(
|
|
77
|
+
console.log(` ${orange('◆')} ${bold(message)}`);
|
|
78
78
|
choices.forEach((choice, i) => {
|
|
79
79
|
const cursor = i === selected ? orange('▶ ') : ' ';
|
|
80
80
|
const label = i === selected ? bold(orange(choice.name)) : dimOrange(choice.name);
|
|
@@ -82,6 +82,7 @@ export async function choose(message, choices) {
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
console.log('');
|
|
85
86
|
render(true);
|
|
86
87
|
process.stdin.setRawMode(true);
|
|
87
88
|
process.stdin.resume();
|
|
@@ -99,7 +100,7 @@ export async function choose(message, choices) {
|
|
|
99
100
|
process.stdin.pause();
|
|
100
101
|
process.stdin.removeListener('data', onKey);
|
|
101
102
|
process.stdout.write(`\x1b[${choices.length + 1}A`);
|
|
102
|
-
console.log(
|
|
103
|
+
console.log(` ${orange('◆')} ${bold(message)}`);
|
|
103
104
|
choices.forEach((choice, i) => {
|
|
104
105
|
if (i === selected) console.log(` ${green('▶ ')}${bold(green(choice.name))}`);
|
|
105
106
|
else console.log(` ${dimOrange(' ' + choice.name)}`);
|
package/src/ui.js
CHANGED
|
@@ -95,6 +95,12 @@ export function logInfo(text) { addLine(` ${cyan(figures.info)} ${cyan(text)}`
|
|
|
95
95
|
export function logWarn(text) { addLine(` ${yellow(figures.warning)} ${yellow(text)}`); }
|
|
96
96
|
export function logSuccess(text) { addLine(` ${green(figures.tick)} ${green(text)}`); }
|
|
97
97
|
|
|
98
|
+
// Prints immediately to the terminal instead of buffering into the current
|
|
99
|
+
// section box. Use for time-sensitive messages (e.g. a URL the user needs to
|
|
100
|
+
// see right now, before a long-running wait) that would otherwise stay
|
|
101
|
+
// invisible until the section flushes.
|
|
102
|
+
export function logLive(text) { console.log(` ${cyan(figures.line)} ${text}`); }
|
|
103
|
+
|
|
98
104
|
export function divider() { addLine(` ${dimOrange('─'.repeat(50))}`); }
|
|
99
105
|
|
|
100
106
|
// sub-step block
|