blumenjs 0.1.4 → 0.1.6
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/cli/postinstall.cjs +74 -0
- package/dist/cli/blumen.js +449 -13
- package/dist/cli/commands/create.js +170 -9
- package/dist/cli/commands/deploy.js +346 -0
- package/dist/cli/commands/dev.js +120 -2
- package/dist/cli/utils.js +99 -0
- package/dist/templates/app/pages/templates/BlumenApi.tsx +489 -0
- package/dist/templates/app/pages/templates/BlumenDashboard.tsx +344 -0
- package/dist/templates/app/pages/templates/BlumenEmpty.tsx +128 -0
- package/package.json +3 -1
package/dist/cli/commands/dev.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// cli/commands/dev.ts
|
|
2
|
-
import { spawn, execSync } from "child_process";
|
|
2
|
+
import { spawn, execSync as execSync2 } from "child_process";
|
|
3
3
|
|
|
4
4
|
// cli/utils.ts
|
|
5
5
|
import * as fs from "fs";
|
|
6
6
|
import * as path from "path";
|
|
7
|
+
import * as os from "os";
|
|
7
8
|
import { fileURLToPath } from "url";
|
|
9
|
+
import { execSync } from "child_process";
|
|
8
10
|
var c = {
|
|
9
11
|
reset: "\x1B[0m",
|
|
10
12
|
bold: "\x1B[1m",
|
|
@@ -59,13 +61,129 @@ function banner() {
|
|
|
59
61
|
function divider() {
|
|
60
62
|
console.log(` ${c.dim}${"\u2500".repeat(48)}${c.reset}`);
|
|
61
63
|
}
|
|
64
|
+
async function confirm(question, defaultYes = true) {
|
|
65
|
+
const readline = await import("readline");
|
|
66
|
+
const rl = readline.createInterface({
|
|
67
|
+
input: process.stdin,
|
|
68
|
+
output: process.stdout
|
|
69
|
+
});
|
|
70
|
+
const hint = defaultYes ? "Y/n" : "y/N";
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
rl.question(` ${c.bold}${question}${c.reset} ${c.dim}(${hint})${c.reset} `, (answer) => {
|
|
73
|
+
rl.close();
|
|
74
|
+
const a = answer.trim().toLowerCase();
|
|
75
|
+
if (a === "")
|
|
76
|
+
resolve(defaultYes);
|
|
77
|
+
else
|
|
78
|
+
resolve(a === "y" || a === "yes");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function checkGoInstalled() {
|
|
83
|
+
try {
|
|
84
|
+
execSync("go version", { stdio: "pipe" });
|
|
85
|
+
return true;
|
|
86
|
+
} catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function getGoVersion() {
|
|
91
|
+
try {
|
|
92
|
+
const out = execSync("go version", { encoding: "utf-8" }).trim();
|
|
93
|
+
const match = out.match(/go(\d+\.\d+(\.\d+)?)/);
|
|
94
|
+
return match ? match[1] : out;
|
|
95
|
+
} catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async function ensureGo() {
|
|
100
|
+
if (checkGoInstalled()) {
|
|
101
|
+
const ver = getGoVersion();
|
|
102
|
+
log.success(`Go ${c.bold}${ver}${c.reset} detected`);
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
log.blank();
|
|
106
|
+
log.warn(`${c.bold}Go is not installed${c.reset}`);
|
|
107
|
+
log.info("Blumen uses Go for its high-performance HTTP server layer.");
|
|
108
|
+
log.blank();
|
|
109
|
+
const platform2 = os.platform();
|
|
110
|
+
if (platform2 === "darwin") {
|
|
111
|
+
let hasBrew = false;
|
|
112
|
+
try {
|
|
113
|
+
execSync("brew --version", { stdio: "pipe" });
|
|
114
|
+
hasBrew = true;
|
|
115
|
+
} catch {
|
|
116
|
+
}
|
|
117
|
+
if (hasBrew) {
|
|
118
|
+
const doInstall = await confirm("Install Go via Homebrew? (brew install go)");
|
|
119
|
+
if (doInstall) {
|
|
120
|
+
log.step("Installing Go via Homebrew...");
|
|
121
|
+
try {
|
|
122
|
+
execSync("brew install go", { stdio: "inherit" });
|
|
123
|
+
log.success("Go installed successfully!");
|
|
124
|
+
return true;
|
|
125
|
+
} catch {
|
|
126
|
+
log.error("Homebrew install failed. Please install manually.");
|
|
127
|
+
console.log(`
|
|
128
|
+
${c.cyan}https://go.dev/dl/${c.reset}
|
|
129
|
+
`);
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
console.log(` ${c.bold}Install Go manually:${c.reset}`);
|
|
135
|
+
console.log(` ${c.cyan}brew install go${c.reset} ${c.dim}(if you install Homebrew first)${c.reset}`);
|
|
136
|
+
console.log(` ${c.dim}or download from${c.reset} ${c.cyan}https://go.dev/dl/${c.reset}`);
|
|
137
|
+
} else if (platform2 === "linux") {
|
|
138
|
+
let hasApt = false;
|
|
139
|
+
try {
|
|
140
|
+
execSync("apt --version", { stdio: "pipe" });
|
|
141
|
+
hasApt = true;
|
|
142
|
+
} catch {
|
|
143
|
+
}
|
|
144
|
+
if (hasApt) {
|
|
145
|
+
const doInstall = await confirm("Install Go via apt? (sudo apt install golang-go)");
|
|
146
|
+
if (doInstall) {
|
|
147
|
+
log.step("Installing Go via apt...");
|
|
148
|
+
try {
|
|
149
|
+
execSync("sudo apt update && sudo apt install -y golang-go", { stdio: "inherit" });
|
|
150
|
+
log.success("Go installed successfully!");
|
|
151
|
+
return true;
|
|
152
|
+
} catch {
|
|
153
|
+
log.error("apt install failed. Please install manually.");
|
|
154
|
+
console.log(`
|
|
155
|
+
${c.cyan}https://go.dev/dl/${c.reset}
|
|
156
|
+
`);
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
console.log(` ${c.bold}Install Go:${c.reset}`);
|
|
162
|
+
console.log(` ${c.cyan}sudo apt install golang-go${c.reset} ${c.dim}(Debian/Ubuntu)${c.reset}`);
|
|
163
|
+
console.log(` ${c.cyan}sudo dnf install golang${c.reset} ${c.dim}(Fedora)${c.reset}`);
|
|
164
|
+
console.log(` ${c.dim}or download from${c.reset} ${c.cyan}https://go.dev/dl/${c.reset}`);
|
|
165
|
+
} else if (platform2 === "win32") {
|
|
166
|
+
console.log(` ${c.bold}Install Go (Windows):${c.reset}`);
|
|
167
|
+
console.log(` ${c.cyan}winget install GoLang.Go${c.reset}`);
|
|
168
|
+
console.log(` ${c.dim}or download from${c.reset} ${c.cyan}https://go.dev/dl/${c.reset}`);
|
|
169
|
+
} else {
|
|
170
|
+
console.log(` ${c.bold}Install Go:${c.reset} ${c.cyan}https://go.dev/dl/${c.reset}`);
|
|
171
|
+
}
|
|
172
|
+
log.blank();
|
|
173
|
+
log.info("After installing Go, restart your terminal and try again.");
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
62
176
|
|
|
63
177
|
// cli/commands/dev.ts
|
|
64
178
|
async function dev() {
|
|
65
179
|
banner();
|
|
180
|
+
const goReady = await ensureGo();
|
|
181
|
+
if (!goReady) {
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
66
184
|
log.step("Generating routes...");
|
|
67
185
|
try {
|
|
68
|
-
|
|
186
|
+
execSync2("npx tsx scripts/generate-routes.ts", {
|
|
69
187
|
stdio: "pipe",
|
|
70
188
|
cwd: process.cwd()
|
|
71
189
|
});
|
package/dist/cli/utils.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// cli/utils.ts
|
|
2
2
|
import * as fs from "fs";
|
|
3
3
|
import * as path from "path";
|
|
4
|
+
import * as os from "os";
|
|
4
5
|
import { fileURLToPath } from "url";
|
|
6
|
+
import { execSync } from "child_process";
|
|
5
7
|
var c = {
|
|
6
8
|
reset: "\x1B[0m",
|
|
7
9
|
bold: "\x1B[1m",
|
|
@@ -98,11 +100,108 @@ async function confirm(question, defaultYes = true) {
|
|
|
98
100
|
});
|
|
99
101
|
});
|
|
100
102
|
}
|
|
103
|
+
function checkGoInstalled() {
|
|
104
|
+
try {
|
|
105
|
+
execSync("go version", { stdio: "pipe" });
|
|
106
|
+
return true;
|
|
107
|
+
} catch {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function getGoVersion() {
|
|
112
|
+
try {
|
|
113
|
+
const out = execSync("go version", { encoding: "utf-8" }).trim();
|
|
114
|
+
const match = out.match(/go(\d+\.\d+(\.\d+)?)/);
|
|
115
|
+
return match ? match[1] : out;
|
|
116
|
+
} catch {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function ensureGo() {
|
|
121
|
+
if (checkGoInstalled()) {
|
|
122
|
+
const ver = getGoVersion();
|
|
123
|
+
log.success(`Go ${c.bold}${ver}${c.reset} detected`);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
log.blank();
|
|
127
|
+
log.warn(`${c.bold}Go is not installed${c.reset}`);
|
|
128
|
+
log.info("Blumen uses Go for its high-performance HTTP server layer.");
|
|
129
|
+
log.blank();
|
|
130
|
+
const platform2 = os.platform();
|
|
131
|
+
if (platform2 === "darwin") {
|
|
132
|
+
let hasBrew = false;
|
|
133
|
+
try {
|
|
134
|
+
execSync("brew --version", { stdio: "pipe" });
|
|
135
|
+
hasBrew = true;
|
|
136
|
+
} catch {
|
|
137
|
+
}
|
|
138
|
+
if (hasBrew) {
|
|
139
|
+
const doInstall = await confirm("Install Go via Homebrew? (brew install go)");
|
|
140
|
+
if (doInstall) {
|
|
141
|
+
log.step("Installing Go via Homebrew...");
|
|
142
|
+
try {
|
|
143
|
+
execSync("brew install go", { stdio: "inherit" });
|
|
144
|
+
log.success("Go installed successfully!");
|
|
145
|
+
return true;
|
|
146
|
+
} catch {
|
|
147
|
+
log.error("Homebrew install failed. Please install manually.");
|
|
148
|
+
console.log(`
|
|
149
|
+
${c.cyan}https://go.dev/dl/${c.reset}
|
|
150
|
+
`);
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
console.log(` ${c.bold}Install Go manually:${c.reset}`);
|
|
156
|
+
console.log(` ${c.cyan}brew install go${c.reset} ${c.dim}(if you install Homebrew first)${c.reset}`);
|
|
157
|
+
console.log(` ${c.dim}or download from${c.reset} ${c.cyan}https://go.dev/dl/${c.reset}`);
|
|
158
|
+
} else if (platform2 === "linux") {
|
|
159
|
+
let hasApt = false;
|
|
160
|
+
try {
|
|
161
|
+
execSync("apt --version", { stdio: "pipe" });
|
|
162
|
+
hasApt = true;
|
|
163
|
+
} catch {
|
|
164
|
+
}
|
|
165
|
+
if (hasApt) {
|
|
166
|
+
const doInstall = await confirm("Install Go via apt? (sudo apt install golang-go)");
|
|
167
|
+
if (doInstall) {
|
|
168
|
+
log.step("Installing Go via apt...");
|
|
169
|
+
try {
|
|
170
|
+
execSync("sudo apt update && sudo apt install -y golang-go", { stdio: "inherit" });
|
|
171
|
+
log.success("Go installed successfully!");
|
|
172
|
+
return true;
|
|
173
|
+
} catch {
|
|
174
|
+
log.error("apt install failed. Please install manually.");
|
|
175
|
+
console.log(`
|
|
176
|
+
${c.cyan}https://go.dev/dl/${c.reset}
|
|
177
|
+
`);
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
console.log(` ${c.bold}Install Go:${c.reset}`);
|
|
183
|
+
console.log(` ${c.cyan}sudo apt install golang-go${c.reset} ${c.dim}(Debian/Ubuntu)${c.reset}`);
|
|
184
|
+
console.log(` ${c.cyan}sudo dnf install golang${c.reset} ${c.dim}(Fedora)${c.reset}`);
|
|
185
|
+
console.log(` ${c.dim}or download from${c.reset} ${c.cyan}https://go.dev/dl/${c.reset}`);
|
|
186
|
+
} else if (platform2 === "win32") {
|
|
187
|
+
console.log(` ${c.bold}Install Go (Windows):${c.reset}`);
|
|
188
|
+
console.log(` ${c.cyan}winget install GoLang.Go${c.reset}`);
|
|
189
|
+
console.log(` ${c.dim}or download from${c.reset} ${c.cyan}https://go.dev/dl/${c.reset}`);
|
|
190
|
+
} else {
|
|
191
|
+
console.log(` ${c.bold}Install Go:${c.reset} ${c.cyan}https://go.dev/dl/${c.reset}`);
|
|
192
|
+
}
|
|
193
|
+
log.blank();
|
|
194
|
+
log.info("After installing Go, restart your terminal and try again.");
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
101
197
|
export {
|
|
102
198
|
banner,
|
|
103
199
|
c,
|
|
200
|
+
checkGoInstalled,
|
|
104
201
|
confirm,
|
|
105
202
|
divider,
|
|
203
|
+
ensureGo,
|
|
204
|
+
getGoVersion,
|
|
106
205
|
getVersion,
|
|
107
206
|
log,
|
|
108
207
|
select
|