@nitronjs/framework 0.1.2 → 0.1.21
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/create.js +30 -11
- package/package.json +1 -1
package/cli/create.js
CHANGED
|
@@ -133,6 +133,11 @@ function updatePackageJson(projectPath, projectName) {
|
|
|
133
133
|
|
|
134
134
|
function updateEnvFile(projectPath) {
|
|
135
135
|
const envPath = path.join(projectPath, ".env");
|
|
136
|
+
const envExamplePath = path.join(projectPath, ".env.example");
|
|
137
|
+
|
|
138
|
+
if (!fs.existsSync(envPath) && fs.existsSync(envExamplePath)) {
|
|
139
|
+
fs.copyFileSync(envExamplePath, envPath);
|
|
140
|
+
}
|
|
136
141
|
|
|
137
142
|
if (fs.existsSync(envPath)) {
|
|
138
143
|
let content = fs.readFileSync(envPath, "utf-8");
|
|
@@ -149,15 +154,26 @@ function runNpmInstall(projectPath) {
|
|
|
149
154
|
|
|
150
155
|
const child = spawn(npm, ["install"], {
|
|
151
156
|
cwd: projectPath,
|
|
152
|
-
stdio: "
|
|
157
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
153
158
|
shell: isWindows
|
|
154
159
|
});
|
|
155
160
|
|
|
161
|
+
let output = "";
|
|
162
|
+
child.stdout.on("data", (data) => {
|
|
163
|
+
output += data.toString();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
child.stderr.on("data", (data) => {
|
|
167
|
+
output += data.toString();
|
|
168
|
+
});
|
|
169
|
+
|
|
156
170
|
child.on("close", (code) => {
|
|
157
171
|
if (code === 0) {
|
|
158
172
|
resolve();
|
|
159
173
|
} else {
|
|
160
|
-
|
|
174
|
+
const error = new Error(`npm install failed with code ${code}`);
|
|
175
|
+
error.output = output.trim();
|
|
176
|
+
reject(error);
|
|
161
177
|
}
|
|
162
178
|
});
|
|
163
179
|
|
|
@@ -180,19 +196,19 @@ function printSuccess(projectName) {
|
|
|
180
196
|
console.log();
|
|
181
197
|
log(` ${COLORS.dim}1.${COLORS.reset} ${COLORS.cyan}cd ${projectName}${COLORS.reset}`);
|
|
182
198
|
log(` ${COLORS.dim}2.${COLORS.reset} Configure your ${COLORS.yellow}.env${COLORS.reset} file`);
|
|
183
|
-
log(` ${COLORS.dim}3.${COLORS.reset} ${COLORS.cyan}
|
|
184
|
-
log(` ${COLORS.dim}4.${COLORS.reset} ${COLORS.cyan}
|
|
199
|
+
log(` ${COLORS.dim}3.${COLORS.reset} ${COLORS.cyan}npm run migrate${COLORS.reset}`);
|
|
200
|
+
log(` ${COLORS.dim}4.${COLORS.reset} ${COLORS.cyan}npm run dev${COLORS.reset}`);
|
|
185
201
|
console.log();
|
|
186
202
|
|
|
187
203
|
log(`${COLORS.bold}Useful commands:${COLORS.reset}`);
|
|
188
204
|
console.log();
|
|
189
|
-
log(` ${COLORS.cyan}
|
|
190
|
-
log(` ${COLORS.cyan}
|
|
191
|
-
log(` ${COLORS.cyan}
|
|
192
|
-
log(` ${COLORS.cyan}
|
|
193
|
-
log(` ${COLORS.cyan}
|
|
194
|
-
log(` ${COLORS.cyan}
|
|
195
|
-
log(` ${COLORS.cyan}
|
|
205
|
+
log(` ${COLORS.cyan}npm run dev${COLORS.reset} ${COLORS.dim}Start development server${COLORS.reset}`);
|
|
206
|
+
log(` ${COLORS.cyan}npm run build${COLORS.reset} ${COLORS.dim}Build for production${COLORS.reset}`);
|
|
207
|
+
log(` ${COLORS.cyan}npm run start${COLORS.reset} ${COLORS.dim}Start production server${COLORS.reset}`);
|
|
208
|
+
log(` ${COLORS.cyan}npm run migrate${COLORS.reset} ${COLORS.dim}Run database migrations${COLORS.reset}`);
|
|
209
|
+
log(` ${COLORS.cyan}npm run seed${COLORS.reset} ${COLORS.dim}Run database seeders${COLORS.reset}`);
|
|
210
|
+
log(` ${COLORS.cyan}npm run make:controller${COLORS.reset} ${COLORS.dim}Create a new controller${COLORS.reset}`);
|
|
211
|
+
log(` ${COLORS.cyan}npm run make:model${COLORS.reset} ${COLORS.dim}Create a new model${COLORS.reset}`);
|
|
196
212
|
console.log();
|
|
197
213
|
|
|
198
214
|
log(`${COLORS.dim}Documentation: https://nitronjs.dev/docs${COLORS.reset}`);
|
|
@@ -251,6 +267,9 @@ export default async function create(projectName, options = {}) {
|
|
|
251
267
|
logStep("Dependencies installed", "success");
|
|
252
268
|
} catch (error) {
|
|
253
269
|
logStep("Failed to install dependencies", "error");
|
|
270
|
+
if (error.output) {
|
|
271
|
+
log(`${COLORS.dim}${error.output}${COLORS.reset}`);
|
|
272
|
+
}
|
|
254
273
|
log(`${COLORS.yellow}Please run 'npm install' manually in the project directory${COLORS.reset}`);
|
|
255
274
|
}
|
|
256
275
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitronjs/framework",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "NitronJS is a modern and extensible Node.js MVC framework built on Fastify. It focuses on clean architecture, modular structure, and developer productivity, offering built-in routing, middleware, configuration management, CLI tooling, and native React integration for scalable full-stack applications.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"njs": "./cli/njs.js"
|