create-duoo 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/index.js +45 -0
- package/package.json +21 -0
package/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execSync } from 'node:child_process';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
|
|
7
|
+
// Replace with your actual GitHub repository URL
|
|
8
|
+
const REPO_URL = 'https://github.com/ThePratikSah/duo.git';
|
|
9
|
+
|
|
10
|
+
const targetDir = process.argv[2];
|
|
11
|
+
|
|
12
|
+
if (!targetDir) {
|
|
13
|
+
console.error('\x1b[31m%s\x1b[0m', 'Please specify the project directory:');
|
|
14
|
+
console.log('➜ npx create-duoo <project-directory>\n');
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const targetPath = path.resolve(process.cwd(), targetDir);
|
|
19
|
+
|
|
20
|
+
if (fs.existsSync(targetPath)) {
|
|
21
|
+
console.error('\x1b[31m%s\x1b[0m', `Error: Target directory "${targetDir}" already exists.`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
console.log(`\nSetting up a new duoo project...`);
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
// 1. Shallow clone repository
|
|
29
|
+
execSync(`git clone --depth 1 ${REPO_URL} "${targetPath}"`, { stdio: 'inherit' });
|
|
30
|
+
|
|
31
|
+
// 2. Remove the existing .git history
|
|
32
|
+
const gitFolder = path.join(targetPath, '.git');
|
|
33
|
+
fs.rmSync(gitFolder, { recursive: true, force: true });
|
|
34
|
+
|
|
35
|
+
// 3. Initialize fresh git repo
|
|
36
|
+
execSync('git init', { cwd: targetPath, stdio: 'ignore' });
|
|
37
|
+
|
|
38
|
+
console.log('\n\x1b[32m%s\x1b[0m', 'Done! Now run:\n');
|
|
39
|
+
console.log(` cd ${targetDir}`);
|
|
40
|
+
console.log(' npm install');
|
|
41
|
+
console.log(' npm run dev\n');
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('\x1b[31m%s\x1b[0m', '\nFailed to clone repository.');
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-duoo",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Scaffold a duo starter project",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-duoo": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"create-duo",
|
|
14
|
+
"create-duoo",
|
|
15
|
+
"starter",
|
|
16
|
+
"express",
|
|
17
|
+
"react",
|
|
18
|
+
"scaffold"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT"
|
|
21
|
+
}
|