create-flow-os 0.0.1-dev.1771667671 → 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 +70 -22
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -865,14 +865,39 @@ async function findPackageDir(repoRoot, packageName) {
|
|
|
865
865
|
var argv = process.argv.slice(2);
|
|
866
866
|
var noInstall = argv.includes("--no-install");
|
|
867
867
|
var noGit = argv.includes("--no-git");
|
|
868
|
+
var noStart = argv.includes("--no-start");
|
|
868
869
|
var force = argv.includes("--force");
|
|
869
870
|
var yes = argv.includes("--yes") || argv.includes("-y");
|
|
870
871
|
var useDevTag = argv.includes("--dev");
|
|
871
872
|
var nameArg = argv.find((a3) => !a3.startsWith("--"));
|
|
872
873
|
var DIR = basename(import.meta.dir) === "dist" || basename(import.meta.dir) === "bin" ? join2(import.meta.dir, "..") : import.meta.dir;
|
|
873
874
|
var REPO_ROOT = (process.env.FLOW_FRAMEWORK_ROOT ?? join2(DIR, "..", "..")).replace(/\\/g, "/");
|
|
874
|
-
var
|
|
875
|
-
|
|
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
|
+
}
|
|
876
901
|
function optsForProfile(config, profileId) {
|
|
877
902
|
return Object.entries(config.packages).filter(([, e2]) => {
|
|
878
903
|
const inc = e2.includeIn ?? [];
|
|
@@ -884,21 +909,24 @@ function optsForProfile(config, profileId) {
|
|
|
884
909
|
});
|
|
885
910
|
}
|
|
886
911
|
async function main() {
|
|
887
|
-
const devBadge = useDevTag ?
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
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));
|
|
891
919
|
const config = await Bun.file(join2(DIR, "config.json")).json();
|
|
892
920
|
const hasDeps = Object.values(config.packages).every((e2) => Array.isArray(e2.deps));
|
|
893
921
|
if (!hasDeps) {
|
|
894
|
-
he(dim("Run ") +
|
|
922
|
+
he(c2.dim("Run ") + c2.brand("bun run gen") + c2.dim(" from create-flow first."));
|
|
895
923
|
process.exit(1);
|
|
896
924
|
}
|
|
897
925
|
const projectName = nameArg?.trim() || (yes ? "my-flow-app" : null);
|
|
898
926
|
let name = projectName;
|
|
899
927
|
if (!name && !yes) {
|
|
900
928
|
const r2 = await ae({
|
|
901
|
-
message: "Project name",
|
|
929
|
+
message: c2.muted("Project name"),
|
|
902
930
|
initialValue: "my-flow-app",
|
|
903
931
|
validate: (v3) => !v3?.trim() ? "Required" : undefined
|
|
904
932
|
});
|
|
@@ -916,9 +944,9 @@ async function main() {
|
|
|
916
944
|
selected = optsFull.map(([id]) => id);
|
|
917
945
|
} else {
|
|
918
946
|
const choice = await le({
|
|
919
|
-
message: "Template",
|
|
947
|
+
message: c2.muted("Template"),
|
|
920
948
|
options: [
|
|
921
|
-
{ value: "full", label: "Full stack (client + server)" },
|
|
949
|
+
{ value: "full", label: "Full stack " + c2.dim("(client + server)") },
|
|
922
950
|
{ value: "client", label: "Client only" },
|
|
923
951
|
{ value: "server", label: "Server only" }
|
|
924
952
|
]
|
|
@@ -936,7 +964,7 @@ async function main() {
|
|
|
936
964
|
const optionalIds = optIds.filter((id) => !defaultIds.includes(id));
|
|
937
965
|
if (optionalIds.length > 0) {
|
|
938
966
|
const r2 = await $e({
|
|
939
|
-
message: "Add-ons",
|
|
967
|
+
message: c2.muted("Add-ons"),
|
|
940
968
|
options: optionalIds.map((id) => ({ value: id, label: id })),
|
|
941
969
|
required: false
|
|
942
970
|
});
|
|
@@ -954,17 +982,17 @@ async function main() {
|
|
|
954
982
|
stat(projectPath).then(() => true).catch(() => false)
|
|
955
983
|
]);
|
|
956
984
|
if (!profileExists) {
|
|
957
|
-
he(dim("Profile not found. Run ") +
|
|
985
|
+
he(c2.dim("Profile not found. Run ") + c2.brand("bun run gen") + c2.dim("."));
|
|
958
986
|
process.exit(1);
|
|
959
987
|
}
|
|
960
988
|
if (pathExists && !force) {
|
|
961
|
-
he(dim("Folder ") + name + dim(" exists. Use ") +
|
|
989
|
+
he(c2.dim("Folder ") + name + c2.dim(" exists. Use ") + c2.brand("--force") + c2.dim("."));
|
|
962
990
|
process.exit(1);
|
|
963
991
|
}
|
|
964
992
|
const isDevFromRepoPromise = useDevTag ? findPackageDir(REPO_ROOT, "@flow.os/client").then((d2) => !!d2) : Promise.resolve(false);
|
|
965
993
|
await rm(projectPathNew, { recursive: true, force: true });
|
|
966
|
-
const
|
|
967
|
-
|
|
994
|
+
const createSpinner = _2();
|
|
995
|
+
createSpinner.start(c2.brand("Creating project\u2026"));
|
|
968
996
|
await copyWithExclude(profileDir, projectPathNew, ["node_modules", ".git"]);
|
|
969
997
|
for (const id of selected) {
|
|
970
998
|
const pkgDir = join2(DIR, "packages", id);
|
|
@@ -972,7 +1000,7 @@ async function main() {
|
|
|
972
1000
|
await copyWithExclude(pkgDir, projectPathNew, []);
|
|
973
1001
|
} catch {}
|
|
974
1002
|
}
|
|
975
|
-
|
|
1003
|
+
createSpinner.stop(c2.brand("Project created"));
|
|
976
1004
|
const extraDeps = {};
|
|
977
1005
|
for (const id of selected) {
|
|
978
1006
|
const deps = config.packages[id]?.deps;
|
|
@@ -1026,10 +1054,10 @@ async function main() {
|
|
|
1026
1054
|
}
|
|
1027
1055
|
if (!noInstall) {
|
|
1028
1056
|
const s = _2();
|
|
1029
|
-
s.start("Installing");
|
|
1057
|
+
s.start(c2.brand("Installing dependencies\u2026"));
|
|
1030
1058
|
const proc = Bun.spawn(["bun", "install"], { cwd: projectPathNew, stdout: "pipe", stderr: "pipe" });
|
|
1031
1059
|
const code = await proc.exited;
|
|
1032
|
-
s.stop(code === 0 ? "
|
|
1060
|
+
s.stop(code === 0 ? c2.brand("Dependencies installed") : "Failed");
|
|
1033
1061
|
if (code !== 0) {
|
|
1034
1062
|
const err = await new Response(proc.stderr).text();
|
|
1035
1063
|
v2.error(err || "bun install exit " + code);
|
|
@@ -1040,10 +1068,30 @@ async function main() {
|
|
|
1040
1068
|
if (pathExists)
|
|
1041
1069
|
await rm(projectPath, { recursive: true, force: true });
|
|
1042
1070
|
await rename(projectPathNew, projectPath);
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1071
|
+
const startDev = !noStart && !noInstall;
|
|
1072
|
+
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;
|
|
1085
|
+
} else {
|
|
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));
|
|
1094
|
+
}
|
|
1047
1095
|
}
|
|
1048
1096
|
main().catch((e2) => {
|
|
1049
1097
|
v2.error(String(e2));
|