Skip to content

Commit 8da1ce7

Browse files
committed
Wait-on studio
1 parent a441c6b commit 8da1ce7

File tree

5 files changed

+238
-61
lines changed

5 files changed

+238
-61
lines changed

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
# Only install dev dependencies, for the binary. No need to install deps for the source code.
2929
- name: Install dependencies
30-
# Weird tsup quirck https://github.com/npm/cli/issues/4828#issuecomment-2404560937
30+
# Weird tsup quirk https://github.com/npm/cli/issues/4828#issuecomment-2404560937
3131
run: pnpm i @rollup/rollup-linux-x64-gnu && pnpm install --dev
3232
working-directory: ./examples/get-started
3333

examples/get-started/bin/get-started.mjs

Lines changed: 98 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
2525
mod
2626
));
2727

28-
// ../node_modules/sisteransi/src/index.js
28+
// node_modules/.pnpm/[email protected]/node_modules/sisteransi/src/index.js
2929
var require_src = __commonJS({
30-
"../node_modules/sisteransi/src/index.js"(exports, module) {
30+
"node_modules/.pnpm/[email protected]/node_modules/sisteransi/src/index.js"(exports, module) {
3131
"use strict";
3232
var ESC = "\x1B";
3333
var CSI = `${ESC}[`;
@@ -81,9 +81,9 @@ var require_src = __commonJS({
8181
}
8282
});
8383

84-
// ../node_modules/picocolors/picocolors.js
84+
// node_modules/.pnpm/[email protected]/node_modules/picocolors/picocolors.js
8585
var require_picocolors = __commonJS({
86-
"../node_modules/picocolors/picocolors.js"(exports, module) {
86+
"node_modules/.pnpm/[email protected]/node_modules/picocolors/picocolors.js"(exports, module) {
8787
var p = process || {};
8888
var argv = p.argv || [];
8989
var env = p.env || {};
@@ -102,61 +102,62 @@ var require_picocolors = __commonJS({
102102
return result + string.substring(cursor);
103103
};
104104
var createColors = (enabled = isColorSupported) => {
105-
let f = enabled ? formatter : () => String;
105+
let f2 = enabled ? formatter : () => String;
106106
return {
107107
isColorSupported: enabled,
108-
reset: f("\x1B[0m", "\x1B[0m"),
109-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
110-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
111-
italic: f("\x1B[3m", "\x1B[23m"),
112-
underline: f("\x1B[4m", "\x1B[24m"),
113-
inverse: f("\x1B[7m", "\x1B[27m"),
114-
hidden: f("\x1B[8m", "\x1B[28m"),
115-
strikethrough: f("\x1B[9m", "\x1B[29m"),
116-
black: f("\x1B[30m", "\x1B[39m"),
117-
red: f("\x1B[31m", "\x1B[39m"),
118-
green: f("\x1B[32m", "\x1B[39m"),
119-
yellow: f("\x1B[33m", "\x1B[39m"),
120-
blue: f("\x1B[34m", "\x1B[39m"),
121-
magenta: f("\x1B[35m", "\x1B[39m"),
122-
cyan: f("\x1B[36m", "\x1B[39m"),
123-
white: f("\x1B[37m", "\x1B[39m"),
124-
gray: f("\x1B[90m", "\x1B[39m"),
125-
bgBlack: f("\x1B[40m", "\x1B[49m"),
126-
bgRed: f("\x1B[41m", "\x1B[49m"),
127-
bgGreen: f("\x1B[42m", "\x1B[49m"),
128-
bgYellow: f("\x1B[43m", "\x1B[49m"),
129-
bgBlue: f("\x1B[44m", "\x1B[49m"),
130-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
131-
bgCyan: f("\x1B[46m", "\x1B[49m"),
132-
bgWhite: f("\x1B[47m", "\x1B[49m"),
133-
blackBright: f("\x1B[90m", "\x1B[39m"),
134-
redBright: f("\x1B[91m", "\x1B[39m"),
135-
greenBright: f("\x1B[92m", "\x1B[39m"),
136-
yellowBright: f("\x1B[93m", "\x1B[39m"),
137-
blueBright: f("\x1B[94m", "\x1B[39m"),
138-
magentaBright: f("\x1B[95m", "\x1B[39m"),
139-
cyanBright: f("\x1B[96m", "\x1B[39m"),
140-
whiteBright: f("\x1B[97m", "\x1B[39m"),
141-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
142-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
143-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
144-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
145-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
146-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
147-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
148-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
108+
reset: f2("\x1B[0m", "\x1B[0m"),
109+
bold: f2("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
110+
dim: f2("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
111+
italic: f2("\x1B[3m", "\x1B[23m"),
112+
underline: f2("\x1B[4m", "\x1B[24m"),
113+
inverse: f2("\x1B[7m", "\x1B[27m"),
114+
hidden: f2("\x1B[8m", "\x1B[28m"),
115+
strikethrough: f2("\x1B[9m", "\x1B[29m"),
116+
black: f2("\x1B[30m", "\x1B[39m"),
117+
red: f2("\x1B[31m", "\x1B[39m"),
118+
green: f2("\x1B[32m", "\x1B[39m"),
119+
yellow: f2("\x1B[33m", "\x1B[39m"),
120+
blue: f2("\x1B[34m", "\x1B[39m"),
121+
magenta: f2("\x1B[35m", "\x1B[39m"),
122+
cyan: f2("\x1B[36m", "\x1B[39m"),
123+
white: f2("\x1B[37m", "\x1B[39m"),
124+
gray: f2("\x1B[90m", "\x1B[39m"),
125+
bgBlack: f2("\x1B[40m", "\x1B[49m"),
126+
bgRed: f2("\x1B[41m", "\x1B[49m"),
127+
bgGreen: f2("\x1B[42m", "\x1B[49m"),
128+
bgYellow: f2("\x1B[43m", "\x1B[49m"),
129+
bgBlue: f2("\x1B[44m", "\x1B[49m"),
130+
bgMagenta: f2("\x1B[45m", "\x1B[49m"),
131+
bgCyan: f2("\x1B[46m", "\x1B[49m"),
132+
bgWhite: f2("\x1B[47m", "\x1B[49m"),
133+
blackBright: f2("\x1B[90m", "\x1B[39m"),
134+
redBright: f2("\x1B[91m", "\x1B[39m"),
135+
greenBright: f2("\x1B[92m", "\x1B[39m"),
136+
yellowBright: f2("\x1B[93m", "\x1B[39m"),
137+
blueBright: f2("\x1B[94m", "\x1B[39m"),
138+
magentaBright: f2("\x1B[95m", "\x1B[39m"),
139+
cyanBright: f2("\x1B[96m", "\x1B[39m"),
140+
whiteBright: f2("\x1B[97m", "\x1B[39m"),
141+
bgBlackBright: f2("\x1B[100m", "\x1B[49m"),
142+
bgRedBright: f2("\x1B[101m", "\x1B[49m"),
143+
bgGreenBright: f2("\x1B[102m", "\x1B[49m"),
144+
bgYellowBright: f2("\x1B[103m", "\x1B[49m"),
145+
bgBlueBright: f2("\x1B[104m", "\x1B[49m"),
146+
bgMagentaBright: f2("\x1B[105m", "\x1B[49m"),
147+
bgCyanBright: f2("\x1B[106m", "\x1B[49m"),
148+
bgWhiteBright: f2("\x1B[107m", "\x1B[49m")
149149
};
150150
};
151151
module.exports = createColors();
152152
module.exports.createColors = createColors;
153153
}
154154
});
155155

156-
// ../node_modules/@clack/core/dist/index.mjs
156+
// node_modules/.pnpm/@clack[email protected]/node_modules/@clack/core/dist/index.mjs
157157
var import_sisteransi = __toESM(require_src(), 1);
158-
import { stdin as $, stdout as k } from "node:process";
159158
var import_picocolors = __toESM(require_picocolors(), 1);
159+
import { stdin as $, stdout as k } from "node:process";
160+
import * as f from "node:readline";
160161
import _ from "node:readline";
161162
import { WriteStream as U } from "node:tty";
162163
function q({ onlyFirst: t = false } = {}) {
@@ -476,8 +477,24 @@ var TD = class extends x {
476477
}
477478
};
478479
var PD = globalThis.process.platform.startsWith("win");
480+
function WD({ input: t = $, output: u = k, overwrite: F = true, hideCursor: e2 = true } = {}) {
481+
const s = f.createInterface({ input: t, output: u, prompt: "", tabSize: 1 });
482+
f.emitKeypressEvents(t, s), t.isTTY && t.setRawMode(true);
483+
const C2 = (D, { name: i }) => {
484+
if (String(D) === "" && process.exit(0), !F) return;
485+
let n = i === "return" ? 0 : -1, E2 = i === "return" ? -1 : 0;
486+
f.moveCursor(u, n, E2, () => {
487+
f.clearLine(u, 1, () => {
488+
t.once("keypress", C2);
489+
});
490+
});
491+
};
492+
return e2 && process.stdout.write(import_sisteransi.cursor.hide), t.once("keypress", C2), () => {
493+
t.off("keypress", C2), e2 && process.stdout.write(import_sisteransi.cursor.show), t.isTTY && !PD && t.setRawMode(false), s.terminal = false, s.close();
494+
};
495+
}
479496

480-
// ../node_modules/@clack/prompts/dist/index.mjs
497+
// node_modules/.pnpm/@clack[email protected]/node_modules/@clack/prompts/dist/index.mjs
481498
var import_picocolors2 = __toESM(require_picocolors(), 1);
482499
var import_sisteransi2 = __toESM(require_src(), 1);
483500
import h from "node:process";
@@ -570,12 +587,37 @@ ${import_picocolors2.default.gray(d2)} ${r2}
570587
571588
`);
572589
};
590+
var de = () => {
591+
const r2 = _2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], n = _2 ? 80 : 120;
592+
let i, t, s = false, c2 = "";
593+
const l2 = (v2 = "") => {
594+
s = true, i = WD(), c2 = v2.replace(/\.+$/, ""), process.stdout.write(`${import_picocolors2.default.gray(a2)}
595+
`);
596+
let g2 = 0, p = 0;
597+
t = setInterval(() => {
598+
const O2 = import_picocolors2.default.magenta(r2[g2]), P2 = ".".repeat(Math.floor(p)).slice(0, 3);
599+
process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${O2} ${c2}${P2}`), g2 = g2 + 1 < r2.length ? g2 + 1 : 0, p = p < r2.length ? p + 0.125 : 0;
600+
}, n);
601+
}, u = (v2 = "", g2 = 0) => {
602+
c2 = v2 ?? c2, s = false, clearInterval(t);
603+
const p = g2 === 0 ? import_picocolors2.default.green(S2) : g2 === 1 ? import_picocolors2.default.red(I2) : import_picocolors2.default.red(x2);
604+
process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${p} ${c2}
605+
`), i();
606+
}, m2 = (v2 = "") => {
607+
c2 = v2 ?? c2;
608+
}, $2 = (v2) => {
609+
const g2 = v2 > 1 ? "Something went wrong" : "Canceled";
610+
s && u(g2, v2);
611+
};
612+
return process.on("uncaughtExceptionMonitor", () => $2(2)), process.on("unhandledRejection", () => $2(2)), process.on("SIGINT", () => $2(1)), process.on("SIGTERM", () => $2(1)), process.on("exit", $2), { start: l2, stop: u, message: m2 };
613+
};
573614

574615
// bin/get-started.ts
575616
import fs from "fs";
576617
import { execSync } from "child_process";
577618
import path from "path";
578619
import { fileURLToPath } from "url";
620+
import waitOn from "wait-on";
579621

580622
// package.json
581623
var package_default = {
@@ -603,14 +645,16 @@ var package_default = {
603645
"@temporalio/workflow": "^1.11.2",
604646
nodemon: "^2.0.22",
605647
"ts-node": "^10.9.2",
606-
typescript: "^5.6.2"
648+
typescript: "^5.6.2",
649+
"wait-on": "^8.0.1"
607650
},
608651
scripts: {
609652
"build-bin": "pnpm tsup --outDir bin --format esm bin/get-started.ts",
610653
service: "ts-node src/services.ts",
611654
schedule: "ts-node scheduleWorkflow.ts"
612655
},
613656
devDependencies: {
657+
"@clack/prompts": "^0.7.0",
614658
tsup: "8.3.0"
615659
}
616660
};
@@ -625,7 +669,6 @@ async function main() {
625669
let targetDir;
626670
const projectName = await te({
627671
message: "Enter the project folder name:",
628-
placeholder: "./restack-get-started",
629672
defaultValue: "restack-get-started",
630673
initialValue: "restack-get-started",
631674
validate(value) {
@@ -665,6 +708,10 @@ async function main() {
665708
initialValue: true
666709
});
667710
if (openRestack) {
711+
const s = de();
712+
s.start("Waiting for Restack Engine Studio to start");
713+
await waitOn({ resources: ["http://localhost:5233"] });
714+
s.stop();
668715
execSync("open http://localhost:5233", { stdio: "inherit", cwd: targetDir });
669716
}
670717
const blue = "\x1B[34m";

examples/get-started/bin/get-started.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import fs from 'fs';
44
import { execSync } from 'child_process';
55
import path from 'path';
66
import { fileURLToPath } from 'url';
7+
import waitOn from 'wait-on';
8+
79
// @ts-ignore
810
import packageJson from '../package.json';
911

@@ -21,7 +23,6 @@ async function main() {
2123
// Copy files
2224
const projectName = (await clack.text({
2325
message: 'Enter the project folder name:',
24-
placeholder: './restack-get-started',
2526
defaultValue: 'restack-get-started',
2627
initialValue: 'restack-get-started',
2728
validate(value) {
@@ -70,6 +71,10 @@ async function main() {
7071
})) as boolean;
7172

7273
if (openRestack) {
74+
const s = clack.spinner();
75+
s.start('Waiting for Restack Engine Studio to start');
76+
await waitOn({ resources: ['http://localhost:5233'] });
77+
s.stop();
7378
execSync('open http://localhost:5233', { stdio: 'inherit', cwd: targetDir });
7479
}
7580

examples/get-started/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@
1919
],
2020
"license": "MIT",
2121
"dependencies": {
22-
"@restackio/ai": "^0.0.75",
23-
"@temporalio/workflow": "^1.11.2",
24-
"nodemon": "^2.0.22",
22+
"@restackio/ai": "^0.0.75",
23+
"@temporalio/workflow": "^1.11.2",
24+
"nodemon": "^2.0.22",
2525
"ts-node": "^10.9.2",
26-
"typescript": "^5.6.2"
27-
},
28-
"scripts": {
26+
"typescript": "^5.6.2",
27+
"wait-on": "^8.0.1"
28+
},
29+
"scripts": {
2930
"build-bin": "pnpm tsup --outDir bin --format esm bin/get-started.ts",
3031
"service": "ts-node src/services.ts",
3132
"schedule": "ts-node scheduleWorkflow.ts"
32-
},
33-
"devDependencies": {
33+
},
34+
"devDependencies": {
3435
"@clack/prompts": "^0.7.0",
3536
"tsup": "8.3.0"
3637
}

0 commit comments

Comments
 (0)