create-flow-os 0.0.1-dev.1771667671 → 0.0.1-dev.1771667897
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 +35 -20
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -865,6 +865,7 @@ 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");
|
|
@@ -872,7 +873,9 @@ 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
875
|
var aqua = import_picocolors3.default.cyan;
|
|
876
|
+
var teal = (s) => import_picocolors3.default.cyan(s);
|
|
875
877
|
var dim = import_picocolors3.default.dim;
|
|
878
|
+
var subtle = (s) => import_picocolors3.default.dim(import_picocolors3.default.cyan(s));
|
|
876
879
|
function optsForProfile(config, profileId) {
|
|
877
880
|
return Object.entries(config.packages).filter(([, e2]) => {
|
|
878
881
|
const inc = e2.includeIn ?? [];
|
|
@@ -884,21 +887,20 @@ function optsForProfile(config, profileId) {
|
|
|
884
887
|
});
|
|
885
888
|
}
|
|
886
889
|
async function main() {
|
|
887
|
-
const devBadge = useDevTag ?
|
|
888
|
-
pe(import_picocolors3.default.bold("
|
|
889
|
-
Create a new
|
|
890
|
-
`));
|
|
890
|
+
const devBadge = useDevTag ? teal(" \xB7 dev") : "";
|
|
891
|
+
pe(teal("\u25B8 ") + import_picocolors3.default.bold("Flow") + devBadge + `
|
|
892
|
+
` + dim(" Create a new application"));
|
|
891
893
|
const config = await Bun.file(join2(DIR, "config.json")).json();
|
|
892
894
|
const hasDeps = Object.values(config.packages).every((e2) => Array.isArray(e2.deps));
|
|
893
895
|
if (!hasDeps) {
|
|
894
|
-
he(dim("Run ") +
|
|
896
|
+
he(dim("Run ") + teal("bun run gen") + dim(" from create-flow first."));
|
|
895
897
|
process.exit(1);
|
|
896
898
|
}
|
|
897
899
|
const projectName = nameArg?.trim() || (yes ? "my-flow-app" : null);
|
|
898
900
|
let name = projectName;
|
|
899
901
|
if (!name && !yes) {
|
|
900
902
|
const r2 = await ae({
|
|
901
|
-
message: "Project name",
|
|
903
|
+
message: subtle("Project name"),
|
|
902
904
|
initialValue: "my-flow-app",
|
|
903
905
|
validate: (v3) => !v3?.trim() ? "Required" : undefined
|
|
904
906
|
});
|
|
@@ -916,9 +918,9 @@ async function main() {
|
|
|
916
918
|
selected = optsFull.map(([id]) => id);
|
|
917
919
|
} else {
|
|
918
920
|
const choice = await le({
|
|
919
|
-
message: "Template",
|
|
921
|
+
message: subtle("Template"),
|
|
920
922
|
options: [
|
|
921
|
-
{ value: "full", label: "Full stack (client + server)" },
|
|
923
|
+
{ value: "full", label: "Full stack " + dim("(client + server)") },
|
|
922
924
|
{ value: "client", label: "Client only" },
|
|
923
925
|
{ value: "server", label: "Server only" }
|
|
924
926
|
]
|
|
@@ -936,7 +938,7 @@ async function main() {
|
|
|
936
938
|
const optionalIds = optIds.filter((id) => !defaultIds.includes(id));
|
|
937
939
|
if (optionalIds.length > 0) {
|
|
938
940
|
const r2 = await $e({
|
|
939
|
-
message: "Add-ons",
|
|
941
|
+
message: subtle("Add-ons"),
|
|
940
942
|
options: optionalIds.map((id) => ({ value: id, label: id })),
|
|
941
943
|
required: false
|
|
942
944
|
});
|
|
@@ -954,17 +956,17 @@ async function main() {
|
|
|
954
956
|
stat(projectPath).then(() => true).catch(() => false)
|
|
955
957
|
]);
|
|
956
958
|
if (!profileExists) {
|
|
957
|
-
he(dim("Profile not found. Run ") +
|
|
959
|
+
he(dim("Profile not found. Run ") + teal("bun run gen") + dim("."));
|
|
958
960
|
process.exit(1);
|
|
959
961
|
}
|
|
960
962
|
if (pathExists && !force) {
|
|
961
|
-
he(dim("Folder ") + name + dim(" exists. Use ") +
|
|
963
|
+
he(dim("Folder ") + name + dim(" exists. Use ") + teal("--force") + dim("."));
|
|
962
964
|
process.exit(1);
|
|
963
965
|
}
|
|
964
966
|
const isDevFromRepoPromise = useDevTag ? findPackageDir(REPO_ROOT, "@flow.os/client").then((d2) => !!d2) : Promise.resolve(false);
|
|
965
967
|
await rm(projectPathNew, { recursive: true, force: true });
|
|
966
|
-
const
|
|
967
|
-
|
|
968
|
+
const createSpinner = _2();
|
|
969
|
+
createSpinner.start(teal("Creating project\u2026"));
|
|
968
970
|
await copyWithExclude(profileDir, projectPathNew, ["node_modules", ".git"]);
|
|
969
971
|
for (const id of selected) {
|
|
970
972
|
const pkgDir = join2(DIR, "packages", id);
|
|
@@ -972,7 +974,7 @@ async function main() {
|
|
|
972
974
|
await copyWithExclude(pkgDir, projectPathNew, []);
|
|
973
975
|
} catch {}
|
|
974
976
|
}
|
|
975
|
-
|
|
977
|
+
createSpinner.stop(teal("Project created"));
|
|
976
978
|
const extraDeps = {};
|
|
977
979
|
for (const id of selected) {
|
|
978
980
|
const deps = config.packages[id]?.deps;
|
|
@@ -1026,10 +1028,10 @@ async function main() {
|
|
|
1026
1028
|
}
|
|
1027
1029
|
if (!noInstall) {
|
|
1028
1030
|
const s = _2();
|
|
1029
|
-
s.start("Installing");
|
|
1031
|
+
s.start(teal("Installing dependencies\u2026"));
|
|
1030
1032
|
const proc = Bun.spawn(["bun", "install"], { cwd: projectPathNew, stdout: "pipe", stderr: "pipe" });
|
|
1031
1033
|
const code = await proc.exited;
|
|
1032
|
-
s.stop(code === 0 ? "
|
|
1034
|
+
s.stop(code === 0 ? teal("Dependencies installed") : "Failed");
|
|
1033
1035
|
if (code !== 0) {
|
|
1034
1036
|
const err = await new Response(proc.stderr).text();
|
|
1035
1037
|
v2.error(err || "bun install exit " + code);
|
|
@@ -1040,10 +1042,23 @@ async function main() {
|
|
|
1040
1042
|
if (pathExists)
|
|
1041
1043
|
await rm(projectPath, { recursive: true, force: true });
|
|
1042
1044
|
await rename(projectPathNew, projectPath);
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1045
|
+
const startDev = !noStart && !noInstall;
|
|
1046
|
+
if (startDev) {
|
|
1047
|
+
ge(teal(`\u25B8 Ready
|
|
1048
|
+
`) + dim(" ") + teal(name) + dim(` is ready. Starting dev server\u2026
|
|
1049
|
+
`));
|
|
1050
|
+
const devProc = Bun.spawn(["bun", "run", "dev"], {
|
|
1051
|
+
cwd: projectPath,
|
|
1052
|
+
stdio: "inherit"
|
|
1053
|
+
});
|
|
1054
|
+
await devProc.exited;
|
|
1055
|
+
} else {
|
|
1056
|
+
ge(teal(`\u25B8 Done
|
|
1057
|
+
`) + dim(` Next steps:
|
|
1058
|
+
`) + " " + teal("cd " + name) + `
|
|
1059
|
+
` + " " + teal("bun run dev") + `
|
|
1060
|
+
`);
|
|
1061
|
+
}
|
|
1047
1062
|
}
|
|
1048
1063
|
main().catch((e2) => {
|
|
1049
1064
|
v2.error(String(e2));
|