create-luff-app 1.0.0 → 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/bin/cli.js +72 -41
- package/package.json +6 -5
package/bin/cli.js
CHANGED
|
@@ -1,64 +1,95 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
const degit = require("degit");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const { execSync } = require("child_process");
|
|
7
|
+
|
|
8
|
+
const projectName = process.argv[2];
|
|
9
|
+
|
|
10
|
+
if (!projectName) {
|
|
11
|
+
console.log("\x1b[31m%s\x1b[0m", "❌ Error: You must provide a project name.");
|
|
12
|
+
console.log("Example:");
|
|
13
|
+
console.log(" npx create-luff-app my-new-startup");
|
|
11
14
|
process.exit(1);
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
const projectName = process.argv[2];
|
|
15
17
|
const currentPath = process.cwd();
|
|
16
18
|
const projectPath = path.join(currentPath, projectName);
|
|
17
|
-
const GIT_REPO = 'https://github.com/Luff-Org/Luff-Boilerplate.git';
|
|
18
19
|
|
|
19
20
|
if (fs.existsSync(projectPath)) {
|
|
20
|
-
console.log(
|
|
21
|
+
console.log(
|
|
22
|
+
"\x1b[31m%s\x1b[0m",
|
|
23
|
+
`❌ Error: Folder '${projectName}' already exists in this directory.`
|
|
24
|
+
);
|
|
21
25
|
process.exit(1);
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
async function main() {
|
|
25
29
|
try {
|
|
26
|
-
console.log(
|
|
27
|
-
|
|
30
|
+
console.log("\x1b[36m%s\x1b[0m", "🚀 Downloading Luff Boilerplate...");
|
|
31
|
+
|
|
32
|
+
const emitter = degit("Luff-Org/Luff-Boilerplate", {
|
|
33
|
+
cache: false,
|
|
34
|
+
force: true,
|
|
35
|
+
verbose: true
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await emitter.clone(projectPath);
|
|
28
39
|
|
|
29
40
|
process.chdir(projectPath);
|
|
30
41
|
|
|
31
|
-
console.log(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.log(
|
|
55
|
-
|
|
42
|
+
console.log("\x1b[36m%s\x1b[0m", "🧹 Cleaning up repository history...");
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
fs.rmSync(path.join(projectPath, ".git"), {
|
|
46
|
+
recursive: true,
|
|
47
|
+
force: true
|
|
48
|
+
});
|
|
49
|
+
} catch {}
|
|
50
|
+
|
|
51
|
+
console.log("\x1b[36m%s\x1b[0m", "📝 Updating package.json...");
|
|
52
|
+
|
|
53
|
+
const packageJsonPath = path.join(projectPath, "package.json");
|
|
54
|
+
const packageJson = JSON.parse(
|
|
55
|
+
fs.readFileSync(packageJsonPath, "utf8")
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
packageJson.name = projectName;
|
|
59
|
+
|
|
60
|
+
fs.writeFileSync(
|
|
61
|
+
packageJsonPath,
|
|
62
|
+
JSON.stringify(packageJson, null, 2)
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
console.log("\x1b[36m%s\x1b[0m", "📦 Installing dependencies...");
|
|
66
|
+
|
|
67
|
+
execSync("npm install", { stdio: "inherit" });
|
|
68
|
+
|
|
69
|
+
console.log("\x1b[36m%s\x1b[0m", "🌱 Initializing Git repository...");
|
|
70
|
+
|
|
71
|
+
execSync("git init -b main", { stdio: "inherit" });
|
|
72
|
+
execSync("git add .", { stdio: "inherit" });
|
|
73
|
+
execSync(
|
|
74
|
+
'git commit -m "chore: initial commit from create-luff-app" --no-verify',
|
|
75
|
+
{ stdio: "inherit" }
|
|
76
|
+
);
|
|
56
77
|
|
|
78
|
+
console.log("");
|
|
79
|
+
console.log("\x1b[32m%s\x1b[0m", "✅ Installation Complete!");
|
|
80
|
+
console.log("");
|
|
81
|
+
console.log("Next steps:");
|
|
82
|
+
console.log(` cd ${projectName}`);
|
|
83
|
+
console.log(
|
|
84
|
+
" docker compose -f docker/docker-compose.yml up auth-db posts-db -d"
|
|
85
|
+
);
|
|
86
|
+
console.log(" npm run dev");
|
|
87
|
+
console.log("");
|
|
57
88
|
} catch (error) {
|
|
58
|
-
console.
|
|
59
|
-
console.
|
|
89
|
+
console.error("\x1b[31m%s\x1b[0m", "❌ Installation Failed!");
|
|
90
|
+
console.error(error.message);
|
|
60
91
|
process.exit(1);
|
|
61
92
|
}
|
|
62
93
|
}
|
|
63
94
|
|
|
64
|
-
main();
|
|
95
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-luff-app",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "bin/cli.js",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "CLI to scaffold the Luff Microservices Boilerplate",
|
|
6
5
|
"bin": {
|
|
7
6
|
"create-luff-app": "bin/cli.js"
|
|
8
7
|
},
|
|
9
8
|
"scripts": {
|
|
10
9
|
"publish-cli": "npm publish --access public"
|
|
11
10
|
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"degit": "^2.8.4"
|
|
13
|
+
},
|
|
12
14
|
"repository": {
|
|
13
15
|
"type": "git",
|
|
14
16
|
"url": "https://github.com/Luff-Org/Luff-Boilerplate"
|
|
15
17
|
},
|
|
16
|
-
"author": "",
|
|
17
18
|
"license": "MIT"
|
|
18
|
-
}
|
|
19
|
+
}
|