create-flow-os 0.0.1-dev.1771668141 → 0.0.1-dev.1771668924

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.
Files changed (2) hide show
  1. package/bin/index.js +87 -22
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -873,13 +873,21 @@ var nameArg = argv.find((a3) => !a3.startsWith("--"));
873
873
  var DIR = basename(import.meta.dir) === "dist" || basename(import.meta.dir) === "bin" ? join2(import.meta.dir, "..") : import.meta.dir;
874
874
  var REPO_ROOT = (process.env.FLOW_FRAMEWORK_ROOT ?? join2(DIR, "..", "..")).replace(/\\/g, "/");
875
875
  var c2 = {
876
- brand: (s) => import_picocolors3.default.cyan(s),
876
+ brand: (s) => import_picocolors3.default.bold(import_picocolors3.default.cyan(s)),
877
+ cyan: (s) => import_picocolors3.default.cyan(s),
877
878
  dim: (s) => import_picocolors3.default.dim(s),
878
879
  bold: (s) => import_picocolors3.default.bold(s),
879
- muted: (s) => import_picocolors3.default.dim(import_picocolors3.default.cyan(s)),
880
+ muted: (s) => import_picocolors3.default.cyan(s),
880
881
  bright: (s) => import_picocolors3.default.white(s)
881
882
  };
882
883
  var W2 = 50;
884
+ var ICON = {
885
+ full: "\u25C9",
886
+ client: "\u25C6",
887
+ server: "\u25CF",
888
+ deps: "\uD83D\uDCE6",
889
+ rocket: "\u25B6"
890
+ };
883
891
  function stripAnsi(s) {
884
892
  return s.replace(/\x1b\[[0-9;]*m/g, "");
885
893
  }
@@ -898,6 +906,73 @@ function box(lines) {
898
906
  ` + bottom + `
899
907
  `;
900
908
  }
909
+ var LOCAL_URL_RE = /https?:\/\/localhost(:\d+)?(?:\/[^\s]*)?/i;
910
+ function flowBanner(url) {
911
+ const link = c2.brand(url);
912
+ return [
913
+ "",
914
+ c2.cyan(" \u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E"),
915
+ c2.cyan(" \u2502 ") + c2.bold("Flow OS") + c2.cyan(" is running \u2502"),
916
+ c2.cyan(" \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F"),
917
+ "",
918
+ " Open: " + link,
919
+ ""
920
+ ].join(`
921
+ `);
922
+ }
923
+ async function runDevWithBanner(cwd) {
924
+ const devProc = Bun.spawn(["bun", "run", "dev"], {
925
+ cwd,
926
+ stdout: "pipe",
927
+ stderr: "pipe",
928
+ stdio: ["inherit", "pipe", "pipe"]
929
+ });
930
+ let bannerShown = false;
931
+ const decoder = new TextDecoder;
932
+ let outBuf = "";
933
+ const drain = (stream, isErr) => {
934
+ const target = isErr ? process.stderr : process.stdout;
935
+ const reader = stream.getReader();
936
+ function read() {
937
+ return reader.read().then(({ done, value }) => {
938
+ const text = value ? decoder.decode(value, { stream: !done }) : "";
939
+ if (isErr) {
940
+ if (text)
941
+ target.write(text);
942
+ return done ? undefined : read();
943
+ }
944
+ if (text)
945
+ outBuf += text;
946
+ const lines = outBuf.split(/\r?\n/);
947
+ outBuf = done ? "" : lines.pop() ?? "";
948
+ for (const line of lines) {
949
+ const urlMatch = line.match(LOCAL_URL_RE);
950
+ if (!bannerShown && urlMatch) {
951
+ bannerShown = true;
952
+ process.stdout.write(flowBanner(urlMatch[0]));
953
+ }
954
+ target.write(line + `
955
+ `);
956
+ }
957
+ if (done && outBuf) {
958
+ const urlMatch = outBuf.match(LOCAL_URL_RE);
959
+ if (!bannerShown && urlMatch) {
960
+ bannerShown = true;
961
+ process.stdout.write(flowBanner(urlMatch[0]));
962
+ }
963
+ target.write(outBuf);
964
+ }
965
+ return done ? undefined : read();
966
+ });
967
+ }
968
+ return read();
969
+ };
970
+ await Promise.all([
971
+ drain(devProc.stdout, false),
972
+ drain(devProc.stderr, true)
973
+ ]).catch(() => {});
974
+ await devProc.exited;
975
+ }
901
976
  function optsForProfile(config, profileId) {
902
977
  return Object.entries(config.packages).filter(([, e2]) => {
903
978
  const inc = e2.includeIn ?? [];
@@ -913,7 +988,7 @@ async function main() {
913
988
  const introLines = [
914
989
  c2.bold("Flow") + devBadge,
915
990
  "",
916
- c2.dim("We're creating your Flow application.")
991
+ c2.cyan("We're creating your Flow application.")
917
992
  ];
918
993
  pe(box(introLines));
919
994
  const config = await Bun.file(join2(DIR, "config.json")).json();
@@ -946,9 +1021,9 @@ async function main() {
946
1021
  const choice = await le({
947
1022
  message: c2.muted("Template"),
948
1023
  options: [
949
- { value: "full", label: "Full stack " + c2.dim("(client + server)") },
950
- { value: "client", label: "Client only" },
951
- { value: "server", label: "Server only" }
1024
+ { value: "full", label: `${ICON.full} Full stack ${c2.dim("(client + server)")}` },
1025
+ { value: "client", label: `${ICON.client} Client only` },
1026
+ { value: "server", label: `${ICON.server} Server only` }
952
1027
  ]
953
1028
  });
954
1029
  if (lD(choice))
@@ -992,7 +1067,7 @@ async function main() {
992
1067
  const isDevFromRepoPromise = useDevTag ? findPackageDir(REPO_ROOT, "@flow.os/client").then((d2) => !!d2) : Promise.resolve(false);
993
1068
  await rm(projectPathNew, { recursive: true, force: true });
994
1069
  const createSpinner = _2();
995
- createSpinner.start(c2.brand("Creating project\u2026"));
1070
+ createSpinner.start(c2.cyan(ICON.rocket + " Creating project\u2026"));
996
1071
  await copyWithExclude(profileDir, projectPathNew, ["node_modules", ".git"]);
997
1072
  for (const id of selected) {
998
1073
  const pkgDir = join2(DIR, "packages", id);
@@ -1000,7 +1075,7 @@ async function main() {
1000
1075
  await copyWithExclude(pkgDir, projectPathNew, []);
1001
1076
  } catch {}
1002
1077
  }
1003
- createSpinner.stop(c2.brand("Project created"));
1078
+ createSpinner.stop(c2.cyan(ICON.rocket + " Project created"));
1004
1079
  const extraDeps = {};
1005
1080
  for (const id of selected) {
1006
1081
  const deps = config.packages[id]?.deps;
@@ -1054,10 +1129,10 @@ async function main() {
1054
1129
  }
1055
1130
  if (!noInstall) {
1056
1131
  const s = _2();
1057
- s.start(c2.brand("Installing dependencies\u2026"));
1132
+ s.start(c2.cyan(ICON.deps + " Installing dependencies\u2026"));
1058
1133
  const proc = Bun.spawn(["bun", "install"], { cwd: projectPathNew, stdout: "pipe", stderr: "pipe" });
1059
1134
  const code = await proc.exited;
1060
- s.stop(code === 0 ? c2.brand("Dependencies installed") : "Failed");
1135
+ s.stop(code === 0 ? c2.cyan(ICON.deps + " Dependencies installed") : "Failed");
1061
1136
  if (code !== 0) {
1062
1137
  const err = await new Response(proc.stderr).text();
1063
1138
  v2.error(err || "bun install exit " + code);
@@ -1070,18 +1145,8 @@ async function main() {
1070
1145
  await rename(projectPathNew, projectPath);
1071
1146
  const startDev = !noStart && !noInstall;
1072
1147
  if (startDev) {
1073
- const outroLines = [
1074
- c2.bold("Ready"),
1075
- "",
1076
- c2.dim("Project ") + c2.brand(name) + c2.dim(" is ready."),
1077
- c2.dim("Starting dev server\u2026")
1078
- ];
1079
- ge(box(outroLines));
1080
- const devProc = Bun.spawn(["bun", "run", "dev"], {
1081
- cwd: projectPath,
1082
- stdio: ["inherit", "inherit", "inherit"]
1083
- });
1084
- await devProc.exited;
1148
+ ge(c2.cyan(ICON.rocket + " Starting dev server\u2026"));
1149
+ await runDevWithBanner(projectPath);
1085
1150
  } else {
1086
1151
  const outroLines = [
1087
1152
  c2.bold("Done"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-flow-os",
3
- "version": "0.0.1-dev.1771668141",
3
+ "version": "0.0.1-dev.1771668924",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "create-flow-os": "bin/index.js"