create-luff-app 1.0.1 → 1.0.3
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 +73 -49
- package/package.json +6 -5
package/bin/cli.js
CHANGED
|
@@ -1,74 +1,98 @@
|
|
|
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
|
-
|
|
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
|
+
);
|
|
37
57
|
|
|
38
|
-
console.log('\x1b[36m%s\x1b[0m', '📝 Updating package.json...');
|
|
39
|
-
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
40
|
-
const packageJson = require(packageJsonPath);
|
|
41
58
|
packageJson.name = projectName;
|
|
42
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
43
|
-
|
|
44
|
-
console.log('\x1b[36m%s\x1b[0m', '🌱 Initializing new Git repository...');
|
|
45
|
-
execSync('git init -b main', { stdio: 'inherit' });
|
|
46
|
-
|
|
47
|
-
console.log('\x1b[36m%s\x1b[0m', '⚙️ Setting up environment variables & installing dependencies...');
|
|
48
|
-
execSync('bash scripts/setup.sh', { stdio: 'inherit' });
|
|
49
|
-
|
|
50
|
-
console.log('\x1b[36m%s\x1b[0m', '💾 Committing initial project state...');
|
|
51
|
-
execSync('git add .', { stdio: 'inherit' });
|
|
52
|
-
execSync('git commit -m "chore: initial commit from create-luff-app" --no-verify', { stdio: 'inherit' });
|
|
53
|
-
|
|
54
|
-
console.log('\x1b[32m%s\x1b[0m', '✅ Installation Complete!');
|
|
55
|
-
console.log('');
|
|
56
|
-
console.log('Inside that directory, you can run several commands:');
|
|
57
|
-
console.log(' npm run dev');
|
|
58
|
-
console.log(' Starts the Turborepo development server.');
|
|
59
|
-
console.log(' npm run build');
|
|
60
|
-
console.log(' Builds the apps for production.');
|
|
61
|
-
console.log('');
|
|
62
|
-
console.log('We suggest that you begin by typing:');
|
|
63
|
-
console.log('\x1b[36m%s\x1b[0m', ` cd ${projectName}`);
|
|
64
|
-
console.log('\x1b[36m%s\x1b[0m', ' docker compose -f docker/docker-compose.yml up auth-db posts-db -d');
|
|
65
|
-
console.log('\x1b[36m%s\x1b[0m', ' npm run dev');
|
|
66
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
|
+
);
|
|
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(
|
|
87
|
+
" set up .env files from .env.example files, can also use script > npm run setup"
|
|
88
|
+
);
|
|
89
|
+
console.log(" npm run dev");
|
|
90
|
+
console.log("");
|
|
67
91
|
} catch (error) {
|
|
68
|
-
console.
|
|
69
|
-
console.
|
|
92
|
+
console.error("\x1b[31m%s\x1b[0m", "❌ Installation Failed!");
|
|
93
|
+
console.error(error.message);
|
|
70
94
|
process.exit(1);
|
|
71
95
|
}
|
|
72
96
|
}
|
|
73
97
|
|
|
74
|
-
main();
|
|
98
|
+
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.3",
|
|
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
|
+
}
|