create-flow-os 0.0.1-dev.1771667897 → 0.0.1-dev.1771668141
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 +60 -27
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -872,10 +872,32 @@ var useDevTag = argv.includes("--dev");
|
|
|
872
872
|
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
|
-
var
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
875
|
+
var c2 = {
|
|
876
|
+
brand: (s) => import_picocolors3.default.cyan(s),
|
|
877
|
+
dim: (s) => import_picocolors3.default.dim(s),
|
|
878
|
+
bold: (s) => import_picocolors3.default.bold(s),
|
|
879
|
+
muted: (s) => import_picocolors3.default.dim(import_picocolors3.default.cyan(s)),
|
|
880
|
+
bright: (s) => import_picocolors3.default.white(s)
|
|
881
|
+
};
|
|
882
|
+
var W2 = 50;
|
|
883
|
+
function stripAnsi(s) {
|
|
884
|
+
return s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
885
|
+
}
|
|
886
|
+
function box(lines) {
|
|
887
|
+
const top = c2.dim("\u256D" + "\u2500".repeat(W2 - 2) + "\u256E");
|
|
888
|
+
const bottom = c2.dim("\u2570" + "\u2500".repeat(W2 - 2) + "\u256F");
|
|
889
|
+
const body = lines.map((l2) => {
|
|
890
|
+
const plain = stripAnsi(l2);
|
|
891
|
+
const pad = Math.max(0, W2 - 4 - plain.length);
|
|
892
|
+
return c2.dim("\u2502 ") + l2 + " ".repeat(pad) + c2.dim(" \u2502");
|
|
893
|
+
}).join(`
|
|
894
|
+
`);
|
|
895
|
+
return `
|
|
896
|
+
` + top + `
|
|
897
|
+
` + body + `
|
|
898
|
+
` + bottom + `
|
|
899
|
+
`;
|
|
900
|
+
}
|
|
879
901
|
function optsForProfile(config, profileId) {
|
|
880
902
|
return Object.entries(config.packages).filter(([, e2]) => {
|
|
881
903
|
const inc = e2.includeIn ?? [];
|
|
@@ -887,20 +909,24 @@ function optsForProfile(config, profileId) {
|
|
|
887
909
|
});
|
|
888
910
|
}
|
|
889
911
|
async function main() {
|
|
890
|
-
const devBadge = useDevTag ?
|
|
891
|
-
|
|
892
|
-
|
|
912
|
+
const devBadge = useDevTag ? c2.brand(" \xB7 dev") : "";
|
|
913
|
+
const introLines = [
|
|
914
|
+
c2.bold("Flow") + devBadge,
|
|
915
|
+
"",
|
|
916
|
+
c2.dim("We're creating your Flow application.")
|
|
917
|
+
];
|
|
918
|
+
pe(box(introLines));
|
|
893
919
|
const config = await Bun.file(join2(DIR, "config.json")).json();
|
|
894
920
|
const hasDeps = Object.values(config.packages).every((e2) => Array.isArray(e2.deps));
|
|
895
921
|
if (!hasDeps) {
|
|
896
|
-
he(dim("Run ") +
|
|
922
|
+
he(c2.dim("Run ") + c2.brand("bun run gen") + c2.dim(" from create-flow first."));
|
|
897
923
|
process.exit(1);
|
|
898
924
|
}
|
|
899
925
|
const projectName = nameArg?.trim() || (yes ? "my-flow-app" : null);
|
|
900
926
|
let name = projectName;
|
|
901
927
|
if (!name && !yes) {
|
|
902
928
|
const r2 = await ae({
|
|
903
|
-
message:
|
|
929
|
+
message: c2.muted("Project name"),
|
|
904
930
|
initialValue: "my-flow-app",
|
|
905
931
|
validate: (v3) => !v3?.trim() ? "Required" : undefined
|
|
906
932
|
});
|
|
@@ -918,9 +944,9 @@ async function main() {
|
|
|
918
944
|
selected = optsFull.map(([id]) => id);
|
|
919
945
|
} else {
|
|
920
946
|
const choice = await le({
|
|
921
|
-
message:
|
|
947
|
+
message: c2.muted("Template"),
|
|
922
948
|
options: [
|
|
923
|
-
{ value: "full", label: "Full stack " + dim("(client + server)") },
|
|
949
|
+
{ value: "full", label: "Full stack " + c2.dim("(client + server)") },
|
|
924
950
|
{ value: "client", label: "Client only" },
|
|
925
951
|
{ value: "server", label: "Server only" }
|
|
926
952
|
]
|
|
@@ -938,7 +964,7 @@ async function main() {
|
|
|
938
964
|
const optionalIds = optIds.filter((id) => !defaultIds.includes(id));
|
|
939
965
|
if (optionalIds.length > 0) {
|
|
940
966
|
const r2 = await $e({
|
|
941
|
-
message:
|
|
967
|
+
message: c2.muted("Add-ons"),
|
|
942
968
|
options: optionalIds.map((id) => ({ value: id, label: id })),
|
|
943
969
|
required: false
|
|
944
970
|
});
|
|
@@ -956,17 +982,17 @@ async function main() {
|
|
|
956
982
|
stat(projectPath).then(() => true).catch(() => false)
|
|
957
983
|
]);
|
|
958
984
|
if (!profileExists) {
|
|
959
|
-
he(dim("Profile not found. Run ") +
|
|
985
|
+
he(c2.dim("Profile not found. Run ") + c2.brand("bun run gen") + c2.dim("."));
|
|
960
986
|
process.exit(1);
|
|
961
987
|
}
|
|
962
988
|
if (pathExists && !force) {
|
|
963
|
-
he(dim("Folder ") + name + dim(" exists. Use ") +
|
|
989
|
+
he(c2.dim("Folder ") + name + c2.dim(" exists. Use ") + c2.brand("--force") + c2.dim("."));
|
|
964
990
|
process.exit(1);
|
|
965
991
|
}
|
|
966
992
|
const isDevFromRepoPromise = useDevTag ? findPackageDir(REPO_ROOT, "@flow.os/client").then((d2) => !!d2) : Promise.resolve(false);
|
|
967
993
|
await rm(projectPathNew, { recursive: true, force: true });
|
|
968
994
|
const createSpinner = _2();
|
|
969
|
-
createSpinner.start(
|
|
995
|
+
createSpinner.start(c2.brand("Creating project\u2026"));
|
|
970
996
|
await copyWithExclude(profileDir, projectPathNew, ["node_modules", ".git"]);
|
|
971
997
|
for (const id of selected) {
|
|
972
998
|
const pkgDir = join2(DIR, "packages", id);
|
|
@@ -974,7 +1000,7 @@ async function main() {
|
|
|
974
1000
|
await copyWithExclude(pkgDir, projectPathNew, []);
|
|
975
1001
|
} catch {}
|
|
976
1002
|
}
|
|
977
|
-
createSpinner.stop(
|
|
1003
|
+
createSpinner.stop(c2.brand("Project created"));
|
|
978
1004
|
const extraDeps = {};
|
|
979
1005
|
for (const id of selected) {
|
|
980
1006
|
const deps = config.packages[id]?.deps;
|
|
@@ -1028,10 +1054,10 @@ async function main() {
|
|
|
1028
1054
|
}
|
|
1029
1055
|
if (!noInstall) {
|
|
1030
1056
|
const s = _2();
|
|
1031
|
-
s.start(
|
|
1057
|
+
s.start(c2.brand("Installing dependencies\u2026"));
|
|
1032
1058
|
const proc = Bun.spawn(["bun", "install"], { cwd: projectPathNew, stdout: "pipe", stderr: "pipe" });
|
|
1033
1059
|
const code = await proc.exited;
|
|
1034
|
-
s.stop(code === 0 ?
|
|
1060
|
+
s.stop(code === 0 ? c2.brand("Dependencies installed") : "Failed");
|
|
1035
1061
|
if (code !== 0) {
|
|
1036
1062
|
const err = await new Response(proc.stderr).text();
|
|
1037
1063
|
v2.error(err || "bun install exit " + code);
|
|
@@ -1044,20 +1070,27 @@ async function main() {
|
|
|
1044
1070
|
await rename(projectPathNew, projectPath);
|
|
1045
1071
|
const startDev = !noStart && !noInstall;
|
|
1046
1072
|
if (startDev) {
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
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));
|
|
1050
1080
|
const devProc = Bun.spawn(["bun", "run", "dev"], {
|
|
1051
1081
|
cwd: projectPath,
|
|
1052
|
-
stdio: "inherit"
|
|
1082
|
+
stdio: ["inherit", "inherit", "inherit"]
|
|
1053
1083
|
});
|
|
1054
1084
|
await devProc.exited;
|
|
1055
1085
|
} else {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1086
|
+
const outroLines = [
|
|
1087
|
+
c2.bold("Done"),
|
|
1088
|
+
"",
|
|
1089
|
+
c2.dim("Next steps:"),
|
|
1090
|
+
" " + c2.brand("cd " + name),
|
|
1091
|
+
" " + c2.brand("bun run dev")
|
|
1092
|
+
];
|
|
1093
|
+
ge(box(outroLines));
|
|
1061
1094
|
}
|
|
1062
1095
|
}
|
|
1063
1096
|
main().catch((e2) => {
|