create-luff-app 1.0.0
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 +64 -0
- package/package.json +18 -0
package/bin/cli.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
if (process.argv.length < 3) {
|
|
8
|
+
console.log('\x1b[31m%s\x1b[0m', 'โ Error: You must provide a name for your project.');
|
|
9
|
+
console.log('For example:');
|
|
10
|
+
console.log(' npx create-luff-app my-new-startup');
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const projectName = process.argv[2];
|
|
15
|
+
const currentPath = process.cwd();
|
|
16
|
+
const projectPath = path.join(currentPath, projectName);
|
|
17
|
+
const GIT_REPO = 'https://github.com/Luff-Org/Luff-Boilerplate.git';
|
|
18
|
+
|
|
19
|
+
if (fs.existsSync(projectPath)) {
|
|
20
|
+
console.log('\x1b[31m%s\x1b[0m', `โ Error: The folder '${projectName}' already exists in the current directory.`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function main() {
|
|
25
|
+
try {
|
|
26
|
+
console.log('\x1b[36m%s\x1b[0m', '๐ Downloading the Luff Microservices Boilerplate...');
|
|
27
|
+
execSync(`git clone --depth 1 ${GIT_REPO} ${projectPath}`, { stdio: 'inherit' });
|
|
28
|
+
|
|
29
|
+
process.chdir(projectPath);
|
|
30
|
+
|
|
31
|
+
console.log('\x1b[36m%s\x1b[0m', '๐งน Cleaning up boilerplate histories...');
|
|
32
|
+
// Delete .git history so the user starts fresh
|
|
33
|
+
fs.rmSync(path.join(projectPath, '.git'), { recursive: true, force: true });
|
|
34
|
+
|
|
35
|
+
// Delete the CLI tool itself from the downloaded project
|
|
36
|
+
fs.rmSync(path.join(projectPath, 'cli'), { recursive: true, force: true });
|
|
37
|
+
|
|
38
|
+
console.log('\x1b[36m%s\x1b[0m', '๐ฆ Installing dependencies (this may take a minute)...');
|
|
39
|
+
execSync('npm install', { stdio: 'inherit' });
|
|
40
|
+
|
|
41
|
+
console.log('\x1b[36m%s\x1b[0m', 'โ๏ธ Setting up environment variables...');
|
|
42
|
+
execSync('bash scripts/setup.sh', { stdio: 'inherit' });
|
|
43
|
+
|
|
44
|
+
console.log('\x1b[32m%s\x1b[0m', 'โ
Installation Complete!');
|
|
45
|
+
console.log('');
|
|
46
|
+
console.log('Inside that directory, you can run several commands:');
|
|
47
|
+
console.log(' npm run dev');
|
|
48
|
+
console.log(' Starts the Turborepo development server.');
|
|
49
|
+
console.log(' npm run build');
|
|
50
|
+
console.log(' Builds the apps for production.');
|
|
51
|
+
console.log('');
|
|
52
|
+
console.log('We suggest that you begin by typing:');
|
|
53
|
+
console.log('\x1b[36m%s\x1b[0m', ` cd ${projectName}`);
|
|
54
|
+
console.log('\x1b[36m%s\x1b[0m', ' docker compose -f docker/docker-compose.yml up auth-db posts-db -d');
|
|
55
|
+
console.log('\x1b[36m%s\x1b[0m', ' npm run dev');
|
|
56
|
+
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.log('\x1b[31m%s\x1b[0m', 'โ Installation Failed!');
|
|
59
|
+
console.log(error);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-luff-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The official CLI to scaffold the Luff Microservices Boilerplate",
|
|
5
|
+
"main": "bin/cli.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-luff-app": "bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"publish-cli": "npm publish --access public"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/Luff-Org/Luff-Boilerplate"
|
|
15
|
+
},
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "MIT"
|
|
18
|
+
}
|