create-flow-os 0.0.1-dev.1771782345 → 0.0.1-dev.1771783145

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/bin/index.js CHANGED
@@ -463,6 +463,24 @@ class x {
463
463
  }
464
464
  }
465
465
  }
466
+
467
+ class BD extends x {
468
+ get cursor() {
469
+ return this.value ? 0 : 1;
470
+ }
471
+ get _value() {
472
+ return this.cursor === 0;
473
+ }
474
+ constructor(u) {
475
+ super(u, false), this.value = !!u.initialValue, this.on("value", () => {
476
+ this.value = this._value;
477
+ }), this.on("confirm", (F) => {
478
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = F, this.state = "submit", this.close();
479
+ }), this.on("cursor", () => {
480
+ this.value = !this.value;
481
+ });
482
+ }
483
+ }
466
484
  var fD = Object.defineProperty;
467
485
  var gD = (e, u, F) => (u in e) ? fD(e, u, { enumerable: true, configurable: true, writable: true, value: F }) : e[u] = F;
468
486
  var K = (e, u, F) => (gD(e, typeof u != "symbol" ? u + "" : u, F), F);
@@ -642,6 +660,25 @@ ${import_picocolors2.default.cyan($2)}
642
660
  `;
643
661
  }
644
662
  } }).prompt();
663
+ var ce = (s) => {
664
+ const n = s.active ?? "Yes", t = s.inactive ?? "No";
665
+ return new BD({ active: n, inactive: t, initialValue: s.initialValue ?? true, render() {
666
+ const i = `${import_picocolors2.default.gray(a2)}
667
+ ${y2(this.state)} ${s.message}
668
+ `, r2 = this.value ? n : t;
669
+ switch (this.state) {
670
+ case "submit":
671
+ return `${i}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.dim(r2)}`;
672
+ case "cancel":
673
+ return `${i}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(r2))}
674
+ ${import_picocolors2.default.gray(a2)}`;
675
+ default:
676
+ return `${i}${import_picocolors2.default.cyan(a2)} ${this.value ? `${import_picocolors2.default.green(I2)} ${n}` : `${import_picocolors2.default.dim(T2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(T2)} ${import_picocolors2.default.dim(t)}` : `${import_picocolors2.default.green(I2)} ${t}`}
677
+ ${import_picocolors2.default.cyan($2)}
678
+ `;
679
+ }
680
+ } }).prompt();
681
+ };
645
682
  var le = (s) => {
646
683
  const n = (t, i) => {
647
684
  const r2 = t.label ?? String(t.value);
@@ -923,10 +960,22 @@ async function runDev(cwd) {
923
960
  cwd,
924
961
  stdio: ["inherit", "inherit", "inherit"]
925
962
  });
926
- await devProc.exited;
963
+ const killChild = () => {
964
+ try {
965
+ devProc.kill();
966
+ } catch {}
967
+ process.exit(130);
968
+ };
969
+ process.on("SIGINT", killChild);
970
+ process.on("SIGTERM", killChild);
971
+ const code = await devProc.exited;
972
+ process.off("SIGINT", killChild);
973
+ process.off("SIGTERM", killChild);
974
+ if (code !== 0 && code !== null)
975
+ process.exit(code);
927
976
  }
928
977
  var PROFILE_LABELS = {
929
- full: "Full stack (client + server)",
978
+ full: "Full stack (client + server)",
930
979
  client: "Client only",
931
980
  server: "Server only"
932
981
  };
@@ -990,7 +1039,7 @@ async function main() {
990
1039
  const profileIds = Object.keys(config.profiles);
991
1040
  const hasDeps = Object.values(config.packages).every((e2) => Array.isArray(e2.deps));
992
1041
  if (!hasDeps) {
993
- he(c2.dim("Run ") + c2.brand("bun run gen") + c2.dim(" from create-flow first."));
1042
+ he(c2.dim("Run ") + c2.brand("bun run gen") + c2.dim(" in create-flow first."));
994
1043
  process.exit(1);
995
1044
  }
996
1045
  const projectName = nameArg?.trim() || (yes ? "my-flow-app" : null);
@@ -1009,6 +1058,7 @@ async function main() {
1009
1058
  name = "my-flow-app";
1010
1059
  const profileFlag = profileFromArgv(argv, profileIds);
1011
1060
  const optsFull = optsForProfile(config, "full");
1061
+ const allPackageIds = optsFull.map(([id]) => id);
1012
1062
  let profileId;
1013
1063
  let selected = [];
1014
1064
  if (profileFlag) {
@@ -1019,35 +1069,42 @@ async function main() {
1019
1069
  selected = [...defaultIds, ...addOns];
1020
1070
  } else if (yes) {
1021
1071
  profileId = "full";
1022
- selected = optsFull.map(([id]) => id);
1072
+ selected = allPackageIds;
1023
1073
  } else {
1024
- const options = profileIds.map((id) => ({
1025
- value: id,
1026
- label: `${ICON[id] ?? ""} ${PROFILE_LABELS[id] ?? id}`.trim() || id
1027
- }));
1028
- const choice = await le({
1029
- message: c2.muted("Template"),
1030
- options
1074
+ const withAll = await ce({
1075
+ message: c2.muted("Include all packages?"),
1076
+ initialValue: true
1031
1077
  });
1032
- if (lD(choice))
1078
+ if (lD(withAll))
1033
1079
  process.exit(0);
1034
- profileId = choice;
1035
- const opts = optsForProfile(config, profileId);
1036
- const optIds = opts.map(([id]) => id);
1037
- const defaultIds = config.profiles[profileId]?.defaultPackages ?? [];
1038
- selected = optIds.filter((id) => defaultIds.includes(id));
1039
- if (profileId === "full") {
1040
- selected = optIds;
1041
- } else if (opts.length > 0) {
1080
+ if (withAll) {
1081
+ profileId = "full";
1082
+ selected = allPackageIds;
1083
+ } else {
1084
+ const options = profileIds.map((id) => ({
1085
+ value: id,
1086
+ label: `${ICON[id] ?? ""} ${PROFILE_LABELS[id] ?? id}`.trim() || id
1087
+ }));
1088
+ const choice = await le({
1089
+ message: c2.muted("Template"),
1090
+ options
1091
+ });
1092
+ if (lD(choice))
1093
+ process.exit(0);
1094
+ profileId = choice;
1095
+ const opts = optsForProfile(config, profileId);
1096
+ const optIds = opts.map(([id]) => id);
1097
+ const defaultIds = config.profiles[profileId]?.defaultPackages ?? [];
1098
+ selected = optIds.filter((id) => defaultIds.includes(id));
1042
1099
  const optionalIds = optIds.filter((id) => !defaultIds.includes(id));
1043
1100
  if (optionalIds.length > 0) {
1044
- const r2 = await $e({
1101
+ const addOns = await $e({
1045
1102
  message: c2.muted("Add-ons"),
1046
1103
  options: optionalIds.map((id) => ({ value: id, label: id })),
1047
1104
  required: false
1048
1105
  });
1049
- if (!lD(r2))
1050
- selected = [...selected, ...r2 ?? []];
1106
+ if (!lD(addOns))
1107
+ selected = [...selected, ...addOns ?? []];
1051
1108
  }
1052
1109
  }
1053
1110
  }
@@ -1060,11 +1117,11 @@ async function main() {
1060
1117
  stat(projectPath).then(() => true).catch(() => false)
1061
1118
  ]);
1062
1119
  if (!profileExists) {
1063
- he(c2.dim("Profile not found. Run ") + c2.brand("bun run gen") + c2.dim("."));
1120
+ he(c2.dim("Profile missing. Run ") + c2.brand("bun run gen") + c2.dim(" in create-flow."));
1064
1121
  process.exit(1);
1065
1122
  }
1066
1123
  if (pathExists && !force) {
1067
- he(c2.dim("Folder ") + name + c2.dim(" exists. Use ") + c2.brand("--force") + c2.dim("."));
1124
+ he(c2.dim("Directory ") + name + c2.dim(" exists. Use ") + c2.brand("--force") + c2.dim(" to overwrite."));
1068
1125
  process.exit(1);
1069
1126
  }
1070
1127
  const isDevFromRepoPromise = useDevTag ? findPackageDir(REPO_ROOT, "@flow.os/client").then((d2) => !!d2) : Promise.resolve(false);
@@ -1072,7 +1129,7 @@ async function main() {
1072
1129
  const createSpinner = _2();
1073
1130
  createSpinner.start(c2.cyan(ICON.rocket + " Creating project\u2026"));
1074
1131
  await copyWithExclude(profileDir, projectPathNew, ["node_modules", ".git", "packages", "scripts", "LICENSE", "README.md"]);
1075
- createSpinner.stop(c2.cyan(ICON.rocket + " Project created"));
1132
+ createSpinner.stop(c2.cyan(ICON.rocket + " Done"));
1076
1133
  const extraDeps = {};
1077
1134
  for (const id of selected) {
1078
1135
  const deps = config.packages[id]?.deps;
@@ -1087,7 +1144,7 @@ async function main() {
1087
1144
  try {
1088
1145
  await Bun.$`git init ${projectPathNew}`.quiet();
1089
1146
  await Bun.$`git -C ${projectPathNew} add -A`.quiet();
1090
- await Bun.$`git -C ${projectPathNew} commit -m "Initial commit (Flow)"`.quiet();
1147
+ await Bun.$`git -C ${projectPathNew} commit -m "Initial commit"`.quiet();
1091
1148
  } catch {}
1092
1149
  }
1093
1150
  const finalPkg = await Bun.file(pkgPath).json();
@@ -1124,10 +1181,10 @@ async function main() {
1124
1181
  await Bun.write(pkgPath, JSON.stringify(finalPkg, null, 2));
1125
1182
  if (!noInstall) {
1126
1183
  const s = _2();
1127
- s.start(c2.cyan(ICON.deps + " Installing dependencies\u2026"));
1184
+ s.start(c2.cyan(ICON.deps + " Installing\u2026"));
1128
1185
  const proc = Bun.spawn(["bun", "install"], { cwd: projectPathNew, stdout: "pipe", stderr: "pipe" });
1129
1186
  const code = await proc.exited;
1130
- s.stop(code === 0 ? c2.cyan(ICON.deps + " Dependencies installed") : "Failed");
1187
+ s.stop(code === 0 ? c2.cyan(ICON.deps + " Installed") : "Failed");
1131
1188
  if (code !== 0) {
1132
1189
  const err = await new Response(proc.stderr).text();
1133
1190
  v2.error(err || "bun install exit " + code);
@@ -1143,14 +1200,13 @@ async function main() {
1143
1200
  ge(c2.cyan(ICON.rocket + " Starting dev server\u2026"));
1144
1201
  await runDev(projectPath);
1145
1202
  } else {
1146
- const outroLines = [
1147
- c2.bold("Done"),
1203
+ ge(box([
1204
+ c2.bold("All set"),
1148
1205
  "",
1149
- c2.dim("Next steps:"),
1206
+ c2.dim("Run:"),
1150
1207
  " " + c2.brand("cd " + name),
1151
1208
  " " + c2.brand("bun run dev")
1152
- ];
1153
- ge(box(outroLines));
1209
+ ]));
1154
1210
  }
1155
1211
  }
1156
1212
  main().catch((e2) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-flow-os",
3
- "version": "0.0.1-dev.1771782345",
3
+ "version": "0.0.1-dev.1771783145",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "create-flow-os": "bin/index.js"
@@ -1,4 +1,3 @@
1
- /* @flow: client */
2
1
  :root {
3
2
  --background: #rgb(34, 34, 34)
4
3
 
@@ -1,4 +1,3 @@
1
- // @flow: client
2
1
  import './root.css';
3
2
  import { App } from '@flow.os/router';
4
3
  import NotFound from './routes/404';
@@ -1,4 +1,3 @@
1
- // @flow: client
2
1
  /** Pagina 404 full-page (senza layout comune). Mostrata dal router per route inesistenti; raggiungibile anche da /404. */
3
2
  export default function NotFound(path: string) {
4
3
  return (
@@ -1,4 +1,3 @@
1
- // @flow: client
2
1
  import { state } from '@flow.os/core';
3
2
 
4
3
  export default function Home() {
@@ -39,4 +39,11 @@ const getConfig = mod.default;
39
39
  const config = typeof getConfig === 'function' ? await getConfig() : getConfig;
40
40
  const server = await createServer(config);
41
41
  await server.listen();
42
+
43
+ const shutdown = () => {
44
+ server.close().then(() => process.exit(0)).catch(() => process.exit(1));
45
+ };
46
+ process.on('SIGINT', shutdown);
47
+ process.on('SIGTERM', shutdown);
48
+
42
49
  server.watcher.on('change', () => {});
@@ -1,4 +1,3 @@
1
- /* @flow: client */
2
1
  :root {
3
2
  --background: #rgb(34, 34, 34)
4
3
 
@@ -1,4 +1,3 @@
1
- // @flow: client
2
1
  import './root.css';
3
2
  import { App } from '@flow.os/router';
4
3
  import NotFound from './routes/404';
@@ -1,4 +1,3 @@
1
- // @flow: client
2
1
  /** Pagina 404 full-page (senza layout comune). Mostrata dal router per route inesistenti; raggiungibile anche da /404. */
3
2
  export default function NotFound(path: string) {
4
3
  return (
@@ -1,4 +1,3 @@
1
- // @flow: client
2
1
  import { state } from '@flow.os/core';
3
2
 
4
3
  export default function Home() {
@@ -39,4 +39,11 @@ const getConfig = mod.default;
39
39
  const config = typeof getConfig === 'function' ? await getConfig() : getConfig;
40
40
  const server = await createServer(config);
41
41
  await server.listen();
42
+
43
+ const shutdown = () => {
44
+ server.close().then(() => process.exit(0)).catch(() => process.exit(1));
45
+ };
46
+ process.on('SIGINT', shutdown);
47
+ process.on('SIGTERM', shutdown);
48
+
42
49
  server.watcher.on('change', () => {});
@@ -1,4 +1,3 @@
1
- // @flow: server
2
1
  import { defineHandler } from '@flow.os/server';
3
2
 
4
3
  export default defineHandler(() => ({ hello: 'api' }));
@@ -1,4 +1,3 @@
1
- // @flow: server
2
1
  import { defineHandler } from '@flow.os/server';
3
2
 
4
3
  export default defineHandler(() => ({ hello: 'api' }));