create-letswhim 1.1.4 → 1.1.5
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 +19 -40
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,53 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import fs from 'fs';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
blue: (s) => `\x1b[34m${s}\x1b[0m`,
|
|
10
|
-
green: (s) => `\x1b[32m${s}\x1b[0m`,
|
|
11
|
-
dim: (s) => `\x1b[2m${s}\x1b[0m`,
|
|
12
|
-
bold: (s) => `\x1b[1m${s}\x1b[0m`,
|
|
13
|
-
cyan: (s) => `\x1b[36m${s}\x1b[0m`
|
|
14
|
-
};
|
|
7
|
+
const projectName = process.argv[2] || "my-whim-project";
|
|
8
|
+
const repoUrl = "https://github.com/ripkiiii/letswhim-starter.git";
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
const targetPath = path.join(process.cwd(), projectName);
|
|
18
|
-
|
|
19
|
-
console.log(`\n${pc.bold('LETSWHIM')} ${pc.dim('v1.1.0')}`);
|
|
20
|
-
console.log(`${pc.blue('“Let’s just start.”')}\n`);
|
|
10
|
+
console.log(`\n🚀 Preparing your Lightweight project: ${projectName}...`);
|
|
21
11
|
|
|
22
12
|
try {
|
|
23
|
-
// 1.
|
|
24
|
-
if (fs.existsSync(targetPath)) {
|
|
25
|
-
console.error(`\x1b[31m❌ Error:\x1b[0m Folder ${projectName} sudah ada.`);
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 2. Clone dari REPO STARTER BARU (Public)
|
|
30
|
-
console.log(`${pc.dim('📦 Fetching the minimalist engine...')}`);
|
|
31
|
-
|
|
32
|
-
// Ganti URL ini dengan URL Repo Starter Public lo yang baru
|
|
33
|
-
const repoUrl = "https://github.com/ripkiiii/letswhim-starter.git";
|
|
34
|
-
|
|
13
|
+
// 1. Clone dari repo Public yang baru
|
|
35
14
|
execSync(`git clone ${repoUrl} "${projectName}"`, { stdio: 'ignore' });
|
|
36
15
|
|
|
37
|
-
//
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
16
|
+
// 2. Hapus folder .git bawaan starter biar user bisa git init sendiri
|
|
17
|
+
const targetPath = path.join(process.cwd(), projectName);
|
|
18
|
+
const gitFolder = path.join(targetPath, '.git');
|
|
19
|
+
|
|
20
|
+
if (fs.existsSync(gitFolder)) {
|
|
21
|
+
fs.rmSync(gitFolder, { recursive: true, force: true });
|
|
41
22
|
}
|
|
42
23
|
|
|
43
|
-
|
|
44
|
-
console.log(`\
|
|
45
|
-
console.log(
|
|
46
|
-
console.log(`
|
|
47
|
-
console.log(`
|
|
48
|
-
console.log(` ${pc.cyan('npm run dev')}\n`);
|
|
24
|
+
console.log(`\n✅ Project created! Let's start whiming.`);
|
|
25
|
+
console.log(`\nNext steps:`);
|
|
26
|
+
console.log(` cd ${projectName}`);
|
|
27
|
+
console.log(` npm install`);
|
|
28
|
+
console.log(` npm run dev\n`);
|
|
49
29
|
|
|
50
30
|
} catch (error) {
|
|
51
|
-
console.error(`\
|
|
52
|
-
process.exit(1);
|
|
31
|
+
console.error(`\n❌ Bjir, ada error: ${error.message}`);
|
|
53
32
|
}
|