create-zerra-app 1.0.1 ā 1.0.2
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/index.js +38 -4
- package/package.json +3 -2
- package/templates/js-base/api/hello.js +3 -0
- package/templates/js-base/package.json +3 -0
- package/templates/js-base/server.js +2 -8
- package/templates/js-firebase/api/hello.js +3 -0
- package/templates/js-firebase/package.json +10 -0
- package/templates/js-firebase/server.js +3 -0
- package/templates/js-mongo/api/hello.js +3 -0
- package/templates/js-mongo/config/db.js +14 -0
- package/templates/js-mongo/package.json +10 -0
- package/templates/js-mongo/server.js +3 -0
- package/templates/js-sql/api/hello.js +3 -0
- package/templates/js-sql/package.json +10 -0
- package/templates/js-sql/server.js +3 -0
- package/templates/js-supabase/api/hello.js +3 -0
- package/templates/js-supabase/config/supabase.js +10 -0
- package/templates/js-supabase/package.json +10 -0
- package/templates/js-supabase/server.js +3 -0
package/index.js
CHANGED
|
@@ -3,18 +3,52 @@
|
|
|
3
3
|
const { Command } = require("commander");
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
5
|
const path = require("path");
|
|
6
|
+
const inquirer = require("inquirer");
|
|
6
7
|
|
|
7
8
|
const program = new Command();
|
|
8
9
|
|
|
9
10
|
program
|
|
10
11
|
.argument("<project-name>")
|
|
11
|
-
.action((projectName) => {
|
|
12
|
+
.action(async (projectName) => {
|
|
12
13
|
const targetPath = path.join(process.cwd(), projectName);
|
|
13
|
-
const templatePath = path.join(__dirname, "templates/js-base");
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
// 1. Ask for Database Preference
|
|
16
|
+
const answers = await inquirer.prompt([
|
|
17
|
+
{
|
|
18
|
+
type: "list",
|
|
19
|
+
name: "database",
|
|
20
|
+
message: "Which database would you like to use?",
|
|
21
|
+
choices: [
|
|
22
|
+
{ name: "None (Simple API)", value: "js-base" },
|
|
23
|
+
{ name: "SQL (PostgreSQL/MySQL)", value: "js-sql" },
|
|
24
|
+
{ name: "MongoDB", value: "js-mongo" },
|
|
25
|
+
{ name: "Supabase", value: "js-supabase" },
|
|
26
|
+
{ name: "Firebase", value: "js-firebase" },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
16
30
|
|
|
17
|
-
|
|
31
|
+
const templatePath = path.join(__dirname, "templates", answers.database);
|
|
32
|
+
|
|
33
|
+
console.log(`\nšļø Generating Zerra project: ${projectName}...`);
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
if (!fs.existsSync(templatePath)) {
|
|
37
|
+
// Fallback to base if specific template isn't ready yet
|
|
38
|
+
console.warn(`ā ļø Template ${answers.database} not found, falling back to base.`);
|
|
39
|
+
await fs.copy(path.join(__dirname, "templates", "js-base"), targetPath);
|
|
40
|
+
} else {
|
|
41
|
+
await fs.copy(templatePath, targetPath);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.log(`š Zerra project created at ${targetPath}`);
|
|
45
|
+
console.log(`\nNext steps:`);
|
|
46
|
+
console.log(` cd ${projectName}`);
|
|
47
|
+
console.log(` npm install`);
|
|
48
|
+
console.log(` npm run dev\n`);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
console.error("ā Error creating project:", err);
|
|
51
|
+
}
|
|
18
52
|
});
|
|
19
53
|
|
|
20
54
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-zerra-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"type": "commonjs",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"commander": "^14.0.3",
|
|
18
|
-
"fs-extra": "^11.3.4"
|
|
18
|
+
"fs-extra": "^11.3.4",
|
|
19
|
+
"inquirer": "^8.2.7"
|
|
19
20
|
}
|
|
20
21
|
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { startServer } = require("zerra-core");
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
res.end("Zerra server running š");
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
server.listen(3000, () => {
|
|
8
|
-
console.log("Server running on http://localhost:3000");
|
|
9
|
-
});
|
|
3
|
+
startServer(3000);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Simple MongoDB connection boilerplate (using mongoose)
|
|
2
|
+
const mongoose = require("mongoose");
|
|
3
|
+
|
|
4
|
+
const connectDB = async () => {
|
|
5
|
+
try {
|
|
6
|
+
const conn = await mongoose.connect(process.env.MONGO_URI || "mongodb://localhost:27017/zerra_db");
|
|
7
|
+
console.log(`šæ MongoDB Connected: ${conn.connection.host}`);
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error(`Error: ${error.message}`);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports = connectDB;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { createClient } = require("@supabase/supabase-js");
|
|
2
|
+
|
|
3
|
+
const supabaseUrl = process.env.SUPABASE_URL || "https://your-project.supabase.co";
|
|
4
|
+
const supabaseKey = process.env.SUPABASE_KEY || "your-anon-key";
|
|
5
|
+
|
|
6
|
+
const supabase = createClient(supabaseUrl, supabaseKey);
|
|
7
|
+
|
|
8
|
+
console.log("ā” Supabase Client Initialized");
|
|
9
|
+
|
|
10
|
+
module.exports = supabase;
|