eureka-init 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/README.md +55 -0
- package/bin/eureka-init.js +88 -0
- package/package.json +29 -0
- package/templates/.eslintrc.js +19 -0
- package/templates/.prettierrc +8 -0
- package/templates/commitlint.config.js +14 -0
- package/templates/husky/commit-msg +4 -0
- package/templates/husky/pre-commit +4 -0
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# eureka-init
|
|
2
|
+
|
|
3
|
+
Modul untuk menyeragamkan format commit, linting, dan formatting di seluruh project frontend Eureka Group.
|
|
4
|
+
|
|
5
|
+
## šÆ Tujuan
|
|
6
|
+
- Menyeragamkan format commit (Conventional Commits).
|
|
7
|
+
- Konsistensi antar tim (15+ developer).
|
|
8
|
+
- Memudahkan tracking bug & fitur.
|
|
9
|
+
- Siap untuk CI/CD dan audit sistem.
|
|
10
|
+
|
|
11
|
+
## š Cara Penggunaan
|
|
12
|
+
|
|
13
|
+
### 1. Install Dependency
|
|
14
|
+
Jalankan di root project Anda:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install --save-dev eureka-init
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 2. Inisialisasi Konfigurasi
|
|
21
|
+
Jalankan perintah berikut untuk mengcopy file konfigurasi dan setup husky:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx eureka-init
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Perintah ini akan:
|
|
28
|
+
1. Membuat file `commitlint.config.js`.
|
|
29
|
+
2. Membuat file `.prettierrc`.
|
|
30
|
+
3. Membuat file `.eslintrc.js`.
|
|
31
|
+
4. Menjalankan `npx husky install`.
|
|
32
|
+
5. Membuat hook `.husky/commit-msg` dan `.husky/pre-commit`.
|
|
33
|
+
6. Menambahkan script `prepare`, `lint`, dan `format` di `package.json`.
|
|
34
|
+
|
|
35
|
+
## š§± Format Commit
|
|
36
|
+
Gunakan format: `<type>: <subject>`
|
|
37
|
+
|
|
38
|
+
**Allowed Types:**
|
|
39
|
+
- `feat`: Fitur baru
|
|
40
|
+
- `fix`: Perbaikan bug
|
|
41
|
+
- `refactor`: Perbaikan struktur kode tanpa ubah fungsi
|
|
42
|
+
- `chore`: Maintenance (dependency, config, cleanup)
|
|
43
|
+
- `docs`: Dokumentasi
|
|
44
|
+
- `test`: Testing
|
|
45
|
+
|
|
46
|
+
**Rules:**
|
|
47
|
+
- Huruf kecil semua.
|
|
48
|
+
- Maksimal 100 karakter.
|
|
49
|
+
- Minimal 10 karakter untuk subject.
|
|
50
|
+
- Tidak boleh ada titik di akhir.
|
|
51
|
+
|
|
52
|
+
## š ļø Script yang Tersedia
|
|
53
|
+
Setelah instalasi, Anda bisa menggunakan:
|
|
54
|
+
- `npm run lint`: Menjalankan eslint.
|
|
55
|
+
- `npm run format`: Menjalankan prettier untuk merapikan kode.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
const templateDir = path.join(__dirname, '..', 'templates');
|
|
9
|
+
|
|
10
|
+
function copyFile(src, dest) {
|
|
11
|
+
const content = fs.readFileSync(src, 'utf8');
|
|
12
|
+
fs.writeFileSync(dest, content);
|
|
13
|
+
console.log(`ā
Created ${path.relative(cwd, dest)}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function setup() {
|
|
17
|
+
console.log('š Initializing Eureka Group frontend configuration...');
|
|
18
|
+
|
|
19
|
+
// 1. Copy config files
|
|
20
|
+
copyFile(
|
|
21
|
+
path.join(templateDir, 'commitlint.config.js'),
|
|
22
|
+
path.join(cwd, 'commitlint.config.js')
|
|
23
|
+
);
|
|
24
|
+
copyFile(
|
|
25
|
+
path.join(templateDir, '.prettierrc'),
|
|
26
|
+
path.join(cwd, '.prettierrc')
|
|
27
|
+
);
|
|
28
|
+
copyFile(
|
|
29
|
+
path.join(templateDir, '.eslintrc.js'),
|
|
30
|
+
path.join(cwd, '.eslintrc.js')
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// 2. Initialize Husky
|
|
34
|
+
try {
|
|
35
|
+
console.log('š¦ Setting up Husky...');
|
|
36
|
+
execSync('npx husky install', { stdio: 'inherit' });
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error('ā Failed to install Husky. Make sure you are in a git repository.');
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 3. Copy Husky hooks
|
|
43
|
+
const huskyDir = path.join(cwd, '.husky');
|
|
44
|
+
if (!fs.existsSync(huskyDir)) {
|
|
45
|
+
fs.mkdirSync(huskyDir);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
copyFile(
|
|
49
|
+
path.join(templateDir, 'husky', 'commit-msg'),
|
|
50
|
+
path.join(huskyDir, 'commit-msg')
|
|
51
|
+
);
|
|
52
|
+
copyFile(
|
|
53
|
+
path.join(templateDir, 'husky', 'pre-commit'),
|
|
54
|
+
path.join(huskyDir, 'pre-commit')
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// Set executable permissions for hooks (Linux/Mac)
|
|
58
|
+
if (process.platform !== 'win32') {
|
|
59
|
+
fs.chmodSync(path.join(huskyDir, 'commit-msg'), '755');
|
|
60
|
+
fs.chmodSync(path.join(huskyDir, 'pre-commit'), '755');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 4. Update package.json scripts
|
|
64
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
65
|
+
if (fs.existsSync(pkgPath)) {
|
|
66
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
67
|
+
pkg.scripts = pkg.scripts || {};
|
|
68
|
+
|
|
69
|
+
// Add scripts if they don't exist
|
|
70
|
+
if (!pkg.scripts.prepare) {
|
|
71
|
+
pkg.scripts.prepare = 'husky install';
|
|
72
|
+
}
|
|
73
|
+
if (!pkg.scripts.lint) {
|
|
74
|
+
pkg.scripts.lint = 'eslint .';
|
|
75
|
+
}
|
|
76
|
+
if (!pkg.scripts.format) {
|
|
77
|
+
pkg.scripts.format = 'prettier --write .';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
|
81
|
+
console.log('ā
Updated package.json scripts');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log('\n⨠Eureka Group configuration setup complete!');
|
|
85
|
+
console.log('You can now run: git commit -m "feat: add login page" to test.');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setup();
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eureka-init",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared configuration for Husky, Commitlint, and Prettier for Eureka Group",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"eureka-init": "bin/eureka-init.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"husky",
|
|
14
|
+
"commitlint",
|
|
15
|
+
"prettier",
|
|
16
|
+
"eureka"
|
|
17
|
+
],
|
|
18
|
+
"author": "Eureka Group",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@commitlint/cli": "^19.3.0",
|
|
22
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
23
|
+
"eslint": "^8.57.0",
|
|
24
|
+
"eslint-config-prettier": "^9.1.0",
|
|
25
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
26
|
+
"husky": "^9.0.11",
|
|
27
|
+
"prettier": "^3.2.5"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
browser: true,
|
|
4
|
+
es2021: true,
|
|
5
|
+
node: true,
|
|
6
|
+
},
|
|
7
|
+
extends: [
|
|
8
|
+
'eslint:recommended',
|
|
9
|
+
'plugin:prettier/recommended',
|
|
10
|
+
],
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaVersion: 'latest',
|
|
13
|
+
sourceType: 'module',
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
'no-console': 'warn',
|
|
17
|
+
'prettier/prettier': 'error',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['@commitlint/config-conventional'],
|
|
3
|
+
rules: {
|
|
4
|
+
'type-enum': [
|
|
5
|
+
2,
|
|
6
|
+
'always',
|
|
7
|
+
['feat', 'fix', 'refactor', 'chore', 'docs', 'test']
|
|
8
|
+
],
|
|
9
|
+
'subject-case': [2, 'always', 'lower-case'],
|
|
10
|
+
'subject-min-length': [2, 'always', 10],
|
|
11
|
+
'subject-max-length': [2, 'always', 100],
|
|
12
|
+
'subject-full-stop': [2, 'never', '.']
|
|
13
|
+
}
|
|
14
|
+
};
|