unictive-angular 1.0.12 → 1.0.14

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.
Files changed (95) hide show
  1. package/README.md +27 -2
  2. package/bin/index.js +25 -21
  3. package/bin/utils/auth.js +1 -2
  4. package/bin/utils/createStructure.js +36 -7
  5. package/bin/utils/{setupAssets.js → refactorAngularJson.js} +63 -3
  6. package/bin/utils/resource/.postcssrc.json +12 -0
  7. package/bin/utils/resource/package.json +48 -0
  8. package/bin/utils/resource/src/app/MODULES/auth/README.md +10 -0
  9. package/bin/utils/resource/src/app/MODULES/dashboard/README.md +10 -0
  10. package/bin/utils/resource/src/app/MODULES/home/README.md +10 -0
  11. package/bin/utils/resource/src/app/app.config.ts +20 -0
  12. package/bin/utils/resource/src/app/app.html +263 -0
  13. package/bin/utils/resource/src/app/app.routes.ts +3 -0
  14. package/bin/utils/resource/src/app/app.scss +6 -0
  15. package/bin/utils/resource/src/app/app.spec.ts +25 -0
  16. package/bin/utils/resource/src/app/app.ts +32 -0
  17. package/bin/utils/resource/src/app/core/README.md +10 -0
  18. package/bin/utils/resource/src/app/core/config/README.md +10 -0
  19. package/bin/utils/resource/src/app/core/guards/README.md +10 -0
  20. package/bin/utils/resource/src/app/core/interceptors/README.md +10 -0
  21. package/bin/utils/resource/src/app/core/interceptors/error.interceptor.ts +47 -0
  22. package/bin/utils/resource/src/app/core/interceptors/jsonrpc.ts +440 -0
  23. package/bin/utils/resource/src/app/core/interceptors/jwt.interceptor.ts +36 -0
  24. package/bin/utils/resource/src/app/core/models/README.md +10 -0
  25. package/bin/utils/resource/src/app/core/services/README.md +10 -0
  26. package/bin/utils/resource/src/app/shared/README.md +10 -0
  27. package/bin/utils/resource/src/app/shared/directives/README.md +10 -0
  28. package/bin/utils/resource/src/app/shared/pipes/README.md +10 -0
  29. package/bin/utils/resource/src/app/shared/ui/README.md +10 -0
  30. package/bin/utils/resource/src/app/shared/utils/README.md +10 -0
  31. package/bin/utils/resource/src/app/shared/utils/logger.ts +40 -0
  32. package/bin/utils/resource/src/app/shared/widgets/test/test.component.css +0 -0
  33. package/bin/utils/resource/src/app/shared/widgets/test/test.component.html +20 -0
  34. package/bin/utils/resource/src/app/shared/widgets/test/test.component.ts +56 -0
  35. package/bin/utils/resource/src/app/shared/widgets/test/test.module.ts +10 -0
  36. package/bin/utils/resource/src/environments/environment.prod.ts +6 -0
  37. package/bin/utils/resource/src/environments/environment.staging.ts +6 -0
  38. package/bin/utils/resource/src/environments/environment.ts +6 -0
  39. package/bin/utils/resource/src/index.html +16 -0
  40. package/bin/utils/resource/src/main.ts +6 -0
  41. package/bin/utils/resource/src/styles.scss +2 -0
  42. package/bin/utils/resource/src/tailwind.css +11 -0
  43. package/bin/utils/resource/tailwind.config.js +19 -0
  44. package/bin/utils/resource/tsconfig.json +46 -0
  45. package/coba/.editorconfig +17 -0
  46. package/coba/.postcssrc.json +12 -0
  47. package/coba/.vscode/extensions.json +4 -0
  48. package/coba/.vscode/launch.json +20 -0
  49. package/coba/.vscode/tasks.json +42 -0
  50. package/coba/README.md +59 -0
  51. package/coba/angular.json +102 -0
  52. package/coba/package-lock.json +10696 -0
  53. package/coba/package.json +48 -0
  54. package/coba/public/favicon.ico +0 -0
  55. package/coba/src/app/MODULES/auth/README.md +10 -0
  56. package/coba/src/app/MODULES/dashboard/README.md +10 -0
  57. package/coba/src/app/MODULES/home/README.md +10 -0
  58. package/coba/src/app/app.config.ts +20 -0
  59. package/coba/src/app/app.html +263 -0
  60. package/coba/src/app/app.routes.ts +3 -0
  61. package/coba/src/app/app.scss +6 -0
  62. package/coba/src/app/app.spec.ts +25 -0
  63. package/coba/src/app/app.ts +32 -0
  64. package/coba/src/app/core/README.md +10 -0
  65. package/coba/src/app/core/config/README.md +10 -0
  66. package/coba/src/app/core/guards/README.md +10 -0
  67. package/coba/src/app/core/interceptors/README.md +10 -0
  68. package/coba/src/app/core/interceptors/error.interceptor.ts +47 -0
  69. package/coba/src/app/core/interceptors/jsonrpc.ts +440 -0
  70. package/coba/src/app/core/interceptors/jwt.interceptor.ts +36 -0
  71. package/coba/src/app/core/models/README.md +10 -0
  72. package/coba/src/app/core/services/README.md +10 -0
  73. package/coba/src/app/shared/README.md +10 -0
  74. package/coba/src/app/shared/directives/README.md +10 -0
  75. package/coba/src/app/shared/pipes/README.md +10 -0
  76. package/coba/src/app/shared/ui/README.md +10 -0
  77. package/coba/src/app/shared/utils/README.md +10 -0
  78. package/coba/src/app/shared/utils/logger.ts +40 -0
  79. package/coba/src/app/shared/widgets/test/test.component.css +0 -0
  80. package/coba/src/app/shared/widgets/test/test.component.html +20 -0
  81. package/coba/src/app/shared/widgets/test/test.component.ts +56 -0
  82. package/coba/src/app/shared/widgets/test/test.module.ts +10 -0
  83. package/coba/src/environments/environment.prod.ts +6 -0
  84. package/coba/src/environments/environment.staging.ts +6 -0
  85. package/coba/src/environments/environment.ts +6 -0
  86. package/coba/src/index.html +16 -0
  87. package/coba/src/main.ts +6 -0
  88. package/coba/src/styles.scss +2 -0
  89. package/coba/src/tailwind.css +11 -0
  90. package/coba/tailwind.config.js +19 -0
  91. package/coba/tsconfig.app.json +15 -0
  92. package/coba/tsconfig.json +46 -0
  93. package/coba/tsconfig.spec.json +14 -0
  94. package/package.json +1 -1
  95. package/test/node_modules/@tailwindcss/oxide-win32-x64-msvc/tailwindcss-oxide.win32-x64-msvc.node +0 -0
package/README.md CHANGED
@@ -20,6 +20,8 @@
20
20
 
21
21
  ---
22
22
 
23
+
24
+
23
25
  ## 📦 Instalasi
24
26
 
25
27
  ### Global Install via NPM
@@ -74,6 +76,29 @@ src/app/
74
76
 
75
77
  ---
76
78
 
79
+ > ⚠️ **Perhatian:**
80
+ > Proyek yang dihasilkan secara default menggunakan **zoneless Angular**. Pastikan untuk menyesuaikan kode Anda jika membutuhkan fitur yang bergantung pada `zone.js`.
81
+
82
+ ## ➕ Cara Menambahkan `zone.js`
83
+
84
+ Jika Anda membutuhkan fitur Angular yang bergantung pada `zone.js`, Anda dapat menambahkannya secara manual:
85
+
86
+ 1. Install `zone.js`:
87
+ ```bash
88
+ npm install zone.js
89
+ ```
90
+
91
+ 2. Import `zone.js` di file utama aplikasi Anda (biasanya `src/polyfills.ts`):
92
+ ```typescript
93
+ import 'zone.js';
94
+ ```
95
+
96
+ 3. Pastikan konfigurasi Angular Anda tidak menggunakan mode zoneless.
97
+
98
+ Setelah langkah di atas, fitur Angular yang memerlukan `zone.js` akan berfungsi seperti biasa.
99
+
100
+ ---
101
+
77
102
  ## 🛠 Script tambahan di `package.json`
78
103
 
79
104
  ```json
@@ -91,11 +116,11 @@ src/app/
91
116
 
92
117
  - **Node.js** (>= 16)
93
118
  - **npm** (>= 8)
94
- - **Angular CLI** (jika belum ada, akan otomatis diinstall)
119
+ - **Angular CLI** (>=18 jika belum ada, akan otomatis diinstall)
95
120
 
96
121
  ---
97
122
 
98
- ## 💡 Jalankan Proyek
123
+ ## 💡 Jalankan Project yang sudah di generate
99
124
 
100
125
  ```bash
101
126
  cd nama-project && ng serve
package/bin/index.js CHANGED
@@ -12,12 +12,14 @@ const fs = require("fs");
12
12
  const os = require("os");
13
13
  const path = require("path");
14
14
  const { show_status, run_with_spinner } = require('./utils/showStatus');
15
- const { setupAssets } = require('./utils/setupAssets');
15
+ const { refactorAngularJson } = require('./utils/refactorAngularJson');
16
16
  const { create_project } = require('./utils/createProject');
17
- const { create_structure } = require('./utils/createStructure');
18
- const { update_package_json } = require('./utils/updatePackageJson');
17
+ const { copy_template } = require('./utils/createStructure');
18
+ // const { update_package_json } = require('./utils/updatePackageJson');
19
19
  const updateNotifier = require('update-notifier');
20
20
  const chalk = require('chalk');
21
+ require("dotenv").config();
22
+
21
23
  const { login, logout } = require("./utils/auth");
22
24
 
23
25
 
@@ -34,25 +36,26 @@ if (process.argv.includes("-v") || process.argv.includes("--version")) {
34
36
 
35
37
 
36
38
  // ===================== Notifikasi Update =====================
37
- // const notifier = updateNotifier({ pkg, updateCheckInterval: 1000 * 60 * 60 * 6 });
38
- const notifier = updateNotifier({ pkg, updateCheckInterval: 0 });
39
+ const notifier = updateNotifier({ pkg, updateCheckInterval: 1000 * 60 * 60 * 24 });
40
+ // const notifier = updateNotifier({ pkg, updateCheckInterval: 0 });
39
41
 
40
42
  if (notifier.update) {
41
- console.log(`
42
- ${chalk.yellow('⚠ Update tersedia untuk unictive-angular CLI ini!')}
43
- ${chalk.gray('Versi lokal ')} : ${chalk.red(notifier.update.current)}
44
- ${chalk.gray('Versi terbaru')} : ${chalk.green(notifier.update.latest)}
45
-
46
- ${chalk.gray('Jalankan perintah berikut untuk update:')}
47
- ${chalk.cyan(`npm i -g ${pkg.name}`)}
48
-
49
- ${chalk.gray('Catatan: Versi terbaru ini mungkin berisi fitur tambahan dan perbaikan bug.')}
50
- `);
43
+ console.log(chalk.yellow(`
44
+ ┌───────────────────────────────────────────────────────────────┐
45
+ │ ⚠ Update tersedia untuk unictive-angular CLI ini! │
46
+ ├───────────────────────────────────────────────────────────────┤
47
+ │ Versi lokal : ${chalk.red(notifier.update.current)} │
48
+ │ Versi terbaru : ${chalk.green(notifier.update.latest)} │
49
+ │ │
50
+ │ Jalankan perintah berikut untuk update: │
51
+ │ ${chalk.cyan(`npm i -g ${pkg.name}`)} │
52
+ │ │
53
+ │ Catatan: Versi terbaru mungkin berisi fitur baru │
54
+ │ dan perbaikan bug. │
55
+ └───────────────────────────────────────────────────────────────┘
56
+ `));
51
57
  }
52
58
 
53
- // console.log(`${chalk.yellow('⚠ Update tersedia untuk unictive-angular CLI ini!')}
54
- // ${chalk.red(notifier.update)}
55
- // `);
56
59
 
57
60
  // ===================== Utility =====================
58
61
  const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
@@ -175,11 +178,12 @@ async function main() {
175
178
  const OS = check_os();
176
179
  await check_dependencies();
177
180
  const projectName = await create_project();
178
- create_structure();
179
181
  await sleep(1000);
180
- setupAssets();
182
+ copy_template();
183
+ await sleep(1000);
184
+ refactorAngularJson();
181
185
  await sleep(1000);
182
- update_package_json();
186
+ // update_package_json();
183
187
  await run_with_spinner("npm install", "Menginstall dependencies...", "Dependencies berhasil diinstall!", "Gagal install dependencies");
184
188
  await sleep(1000);
185
189
  show_completion(projectName, OS);
package/bin/utils/auth.js CHANGED
@@ -3,7 +3,6 @@ const path = require("path");
3
3
  const os = require("os");
4
4
  const readline = require("readline");
5
5
  process.env.DOTENV_CONFIG_SILENT = 'true';
6
- require("dotenv").config();
7
6
 
8
7
  // Lokasi file cache (disimpan di HOME user)
9
8
  const CACHE_FILE = path.join(os.homedir(), ".my-cli-auth");
@@ -69,7 +68,7 @@ async function login() {
69
68
  process.exit(1);
70
69
  }
71
70
 
72
- const input = await askPassword("Masukkan password: ");
71
+ const input = await askPassword("Harap login terlebih dahulu. (Masukkan password): ");
73
72
  if (input !== correctPassword) {
74
73
  console.error("❌ Password salah. Akses ditolak!");
75
74
  process.exit(1);
@@ -2,17 +2,46 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { show_status } = require('./showStatus');
4
4
 
5
- const path_template = path.join(__dirname, "templates", "app");
5
+ const path_template = path.join(__dirname, "resource");
6
+
7
+ // Bisa, Anda dapat menambahkan nama file ke dalam array folders_to_copy.
8
+ // Misal:
9
+ const folders_to_copy = [
10
+ "src",
11
+ ".postcssrc.json",
12
+ "package.json",
13
+ "tailwind.config.js",
14
+ "tsconfig.json",
15
+ ];
6
16
 
7
17
  async function copy_template() {
8
- show_status("Menyalin folder app dari template ke src/app...", "info");
9
-
10
- const srcFolder = path_template;
11
- const destFolder = path.join(process.cwd(), "src", "app");
18
+ show_status("Proses membuat file dari template...", "info");
19
+
20
+ const destFolder = process.cwd();
21
+
22
+ // Fungsi untuk copy dan replace folder/file
23
+ function copyAndReplace(src, dest) {
24
+ if (fs.existsSync(dest)) {
25
+ fs.rmSync(dest, { recursive: true, force: true });
26
+ }
27
+ if (fs.lstatSync(src).isDirectory()) {
28
+ fs.mkdirSync(dest, { recursive: true });
29
+ fs.readdirSync(src).forEach((item) => {
30
+ copyAndReplace(path.join(src, item), path.join(dest, item));
31
+ });
32
+ } else {
33
+ fs.copyFileSync(src, dest);
34
+ }
35
+ }
12
36
 
13
- copyRecursiveSync(srcFolder, destFolder);
37
+ folders_to_copy.forEach((folder) => {
38
+ const srcFolder = path.join(path_template, folder);
39
+ const targetFolder = path.join(destFolder, folder);
40
+ copyAndReplace(srcFolder, targetFolder);
41
+ // console.log(`Copied & replaced: ${folder}`);
42
+ });
14
43
 
15
- show_status("Folder src/app berhasil disalin!", "success");
44
+ show_status("Folder dan file berhasil dibuat!", "success");
16
45
  }
17
46
 
18
47
 
@@ -2,7 +2,7 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { show_status } = require('./showStatus');
4
4
 
5
- function setupAssets() {
5
+ function refactorAngularJson() {
6
6
  show_status("Generate environment files...", "info");
7
7
  const angularJsonPath = path.join(process.cwd(), 'angular.json');
8
8
  const assetsPath = path.join(process.cwd(), 'src', 'assets');
@@ -14,19 +14,26 @@ function setupAssets() {
14
14
  process.exit(1);
15
15
  }
16
16
 
17
- // 1. Update angular.json untuk menambahkan src/assets
17
+ // 1. Update angular.json untuk menambahkan src/assets && src/tailwind.css
18
18
  const angularJson = JSON.parse(fs.readFileSync(angularJsonPath, 'utf8'));
19
19
  const projectName = Object.keys(angularJson.projects)[0];
20
20
  const buildOptions = angularJson.projects[projectName].architect.build.options;
21
+
21
22
 
22
23
  if (!buildOptions.assets.includes('src/assets')) {
23
24
  buildOptions.assets.push('src/assets');
24
25
  fs.writeFileSync(angularJsonPath, JSON.stringify(angularJson, null, 2));
25
26
  console.log('✔ Added "src/assets" to angular.json');
27
+
28
+
26
29
  } else {
27
30
  console.log('ℹ "src/assets" already exists in angular.json');
28
31
  }
29
32
 
33
+ buildOptions.styles.push('src/tailwind.css');
34
+ fs.writeFileSync(angularJsonPath, JSON.stringify(angularJson, null, 2));
35
+ console.log('✔ Added "src/tailwind.css" to angular.json');
36
+
30
37
  // 2. Buat folder assets jika belum ada
31
38
  if (!fs.existsSync(assetsPath)) {
32
39
  fs.mkdirSync(assetsPath, { recursive: true });
@@ -98,6 +105,59 @@ function setupAssets() {
98
105
  });
99
106
 
100
107
  console.log('🎉 environments setup complete!');
108
+
109
+
110
+
111
+ // ------------------- Angular file replacements -------------------
112
+ if (!fs.existsSync(angularJsonPath)) {
113
+ show_status("⚠ angular.json tidak ditemukan! Lewati file replacement.", "warning");
114
+ return;
115
+ }
116
+
117
+
118
+
119
+ const project = angularJson.projects[projectName];
120
+ const buildTarget = project.architect?.build || project.targets?.build;
121
+
122
+ if (!buildTarget) {
123
+ show_status("⚠ Build target tidak ditemukan di angular.json!", "error");
124
+ return;
125
+ }
126
+
127
+ const buildConfig = buildTarget.configurations || {};
128
+
129
+ // ------------------- Tambahkan environment config -------------------
130
+ buildConfig["dev"] = {
131
+ fileReplacements: [
132
+ {
133
+ replace: "src/environments/environment.ts",
134
+ with: "src/environments/environment.dev.ts"
135
+ }
136
+ ]
137
+ };
138
+
139
+ buildConfig["staging"] = {
140
+ fileReplacements: [
141
+ {
142
+ replace: "src/environments/environment.ts",
143
+ with: "src/environments/environment.staging.ts"
144
+ }
145
+ ]
146
+ };
147
+
148
+ buildConfig["production"] = {
149
+ fileReplacements: [
150
+ {
151
+ replace: "src/environments/environment.ts",
152
+ with: "src/environments/environment.prod.ts"
153
+ }
154
+ ]
155
+ };
156
+
157
+ buildTarget.configurations = buildConfig;
158
+
159
+ fs.writeFileSync(angularJsonPath, JSON.stringify(angularJson, null, 2));
160
+ show_status("angular.json berhasil diperbarui dengan file replacement multi-env!", "success");
101
161
  }
102
162
 
103
- module.exports = { setupAssets };
163
+ module.exports = { refactorAngularJson };
@@ -0,0 +1,12 @@
1
+ {
2
+ "plugins": {
3
+ "@tailwindcss/postcss": {
4
+ "config": "./tailwind.config.js"
5
+
6
+
7
+ },
8
+ "autoprefixer": {}
9
+ }
10
+
11
+ }
12
+
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "boilerplate-angular",
3
+ "version": "0.0.0",
4
+ "scripts": {
5
+ "ng": "ng",
6
+ "start": "ng serve",
7
+ "build": "ng build",
8
+ "watch": "ng build --watch --configuration development",
9
+ "test": "ng test --watch=false",
10
+ "start:dev": "ng serve --configuration=dev --port 4200 --open",
11
+ "start:staging": "ng serve --configuration=staging --port 4200 --open",
12
+ "start:prod": "ng serve --configuration=production --port 4200 --open",
13
+ "build:dev": "ng build --configuration=dev",
14
+ "build:staging": "ng build --configuration=staging",
15
+ "build:prod": "ng build --configuration=production",
16
+ "lint": "ng lint"
17
+ },
18
+ "private": true,
19
+ "dependencies": {
20
+ "@angular/common": "^20.0.0",
21
+ "@angular/compiler": "^20.0.0",
22
+ "@angular/core": "^20.0.0",
23
+ "@angular/forms": "^20.0.0",
24
+ "@angular/platform-browser": "^20.0.0",
25
+ "@angular/router": "^20.0.0",
26
+ "@ngx-pwa/local-storage": "^20.0.0",
27
+ "postcss": "^8.5.6",
28
+ "rxjs": "~7.8.0",
29
+ "tslib": "^2.3.0"
30
+ },
31
+ "devDependencies": {
32
+ "@angular/build": "^20.0.3",
33
+ "@angular/cli": "^20.0.3",
34
+ "@angular/compiler-cli": "^20.0.0",
35
+ "@tailwindcss/cli": "^4.1.12",
36
+ "@tailwindcss/postcss": "^4.1.12",
37
+ "@types/jasmine": "~5.1.0",
38
+ "autoprefixer": "^10.4.21",
39
+ "jasmine-core": "~5.7.0",
40
+ "karma": "~6.4.0",
41
+ "karma-chrome-launcher": "~3.2.0",
42
+ "karma-coverage": "~2.2.0",
43
+ "karma-jasmine": "~5.1.0",
44
+ "karma-jasmine-html-reporter": "~2.1.0",
45
+ "tailwindcss": "^4.1.12",
46
+ "typescript": "~5.8.2"
47
+ }
48
+ }
@@ -0,0 +1,10 @@
1
+ # AUTH
2
+
3
+ Folder ini untuk layer **auth**.
4
+
5
+ - **domain** → berisi entity, interface, dan aturan bisnis murni
6
+ - **application** → berisi use case, service koordinasi domain
7
+ - **infrastructure** → berisi API call, repository, integrasi eksternal
8
+ - **presentation** → berisi komponen Angular, routing, dan UI
9
+
10
+ > Bagian ini adalah bagian dari arsitektur **Clean Architecture** untuk fitur ini.
@@ -0,0 +1,10 @@
1
+ # DASHBOARD
2
+
3
+ Folder ini untuk layer **dashboard**.
4
+
5
+ - **domain** → berisi entity, interface, dan aturan bisnis murni
6
+ - **application** → berisi use case, service koordinasi domain
7
+ - **infrastructure** → berisi API call, repository, integrasi eksternal
8
+ - **presentation** → berisi komponen Angular, routing, dan UI
9
+
10
+ > Bagian ini adalah bagian dari arsitektur **Clean Architecture** untuk fitur ini.
@@ -0,0 +1,10 @@
1
+ # HOME
2
+
3
+ Folder ini untuk layer **home**.
4
+
5
+ - **domain** → berisi entity, interface, dan aturan bisnis murni
6
+ - **application** → berisi use case, service koordinasi domain
7
+ - **infrastructure** → berisi API call, repository, integrasi eksternal
8
+ - **presentation** → berisi komponen Angular, routing, dan UI
9
+
10
+ > Bagian ini adalah bagian dari arsitektur **Clean Architecture** untuk fitur ini.
@@ -0,0 +1,20 @@
1
+ import {
2
+ ApplicationConfig,
3
+ provideBrowserGlobalErrorListeners,
4
+ provideZonelessChangeDetection,
5
+ } from '@angular/core';
6
+ import { provideRouter } from '@angular/router';
7
+
8
+ import { routes } from './app.routes';
9
+ import { provideHttpClient, withInterceptors } from '@angular/common/http';
10
+ import { jwtInterceptor } from '@core/interceptors/jwt.interceptor';
11
+ import { errorInterceptor } from '@core/interceptors/error.interceptor';
12
+
13
+ export const appConfig: ApplicationConfig = {
14
+ providers: [
15
+ provideBrowserGlobalErrorListeners(),
16
+ provideZonelessChangeDetection(),
17
+ provideRouter(routes),
18
+ provideHttpClient(withInterceptors([jwtInterceptor, errorInterceptor])),
19
+ ],
20
+ };