-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·54 lines (46 loc) · 1.91 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env node
import fs from 'fs-extra';
import path from 'path';
import { fileURLToPath } from 'url';
import ora from 'ora';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Function to copy the contents of the seed directory to the target directory
async function copySeedContents(targetDir) {
const seedDir = path.join(__dirname, 'app');
const spinner = ora('Spinning up your project, hold tight...').start();
try {
await fs.ensureDir(targetDir); // Ensure the target directory exists
const files = await fs.readdir(seedDir); // Get the list of files and directories in the seed directory
for (const file of files) {
const srcPath = path.join(seedDir, file);
const destPath = path.join(targetDir, file);
await fs.copy(srcPath, destPath);
}
spinner.succeed('Project created successfully.');
console.log(`\n🔥 Welcome to your new Z.js project!`);
console.log(`🤗 Navigate to your project directory: cd ${targetDir}`);
console.log(`💡 Install dependencies: npm install`);
console.log(`💡 Start the project: npm run dev`);
console.log(`\n`);
console.log(`💡 Also Recommended:`);
console.log(`\n*) Get The Inline Html Vscode Extension`);
console.log(`\nA) Launch VS Code If Not Already Open`);
console.log(`\nB) Press: Ctrl+P`);
console.log(`\nC) Type In Or Paste: ext install pushqrdx.inline-html`);
console.log(`\nD) Press: enter`);
console.log(`\n👍 Confirm its installed...`);
console.log(`\n🤖 Happy Hacking!`);
} catch (err) {
spinner.fail('Error creating project, try again!.');
console.error(`Error: ${err}`);
}
}
// Parse command-line arguments
const args = process.argv.slice(2);
if (args.length < 1) {
console.error('Please provide a target directory.');
process.exit(1);
}
const targetDir = path.resolve(process.cwd(), args[0]);
copySeedContents(targetDir);