unictive-angular 1.0.37 → 1.0.40

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 (55) hide show
  1. package/bin/utils/createStructure.js +6 -0
  2. package/bin/utils/resource/.postcssrc.json +1 -2
  3. package/bin/utils/resource/bitbucket-pipelines.yml +31 -0
  4. package/bin/utils/resource/src/app/API/auth/auth.service.ts +160 -0
  5. package/bin/utils/resource/src/app/PAGES/authentication/login/login.component.spec.ts +28 -0
  6. package/bin/utils/resource/src/app/{MODULES → PAGES}/authentication/login/login.component.ts +9 -3
  7. package/bin/utils/resource/src/app/PAGES/authentication/page404/page404.component.spec.ts +28 -0
  8. package/bin/utils/resource/src/app/{MODULES → PAGES}/authentication/page404/page404.component.ts +1 -2
  9. package/bin/utils/resource/src/app/PAGES/home/home.component.html +5 -0
  10. package/bin/utils/resource/src/app/PAGES/home/home.component.spec.ts +28 -0
  11. package/bin/utils/resource/src/app/{MODULES → PAGES}/home/home.component.ts +3 -3
  12. package/bin/utils/resource/src/app/app.config.ts +30 -0
  13. package/bin/utils/resource/src/app/app.routes.ts +4 -7
  14. package/bin/utils/resource/src/app/app.ts +6 -5
  15. package/bin/utils/resource/src/app/core/config/entity-store.ts +44 -15
  16. package/bin/utils/resource/src/app/core/config/single-store.ts +2 -0
  17. package/bin/utils/resource/src/app/core/guards/auth.guard.ts +43 -0
  18. package/bin/utils/resource/src/app/core/guards/login.guard.ts +37 -0
  19. package/bin/utils/resource/src/app/core/models/entities/user.entity.ts +36 -7
  20. package/bin/utils/resource/src/app/core/services/helper.service.ts +41 -28
  21. package/bin/utils/resource/src/app/core/services/listener.service.ts +25 -0
  22. package/bin/utils/resource/src/app/shared/ui/button/button.component.ts +96 -0
  23. package/bin/utils/resource/tsconfig.json +2 -2
  24. package/bin/utils/resource/workers-site/.cargo-ok +0 -0
  25. package/bin/utils/resource/workers-site/.genignore +1 -0
  26. package/bin/utils/resource/workers-site/.github/workflows/semgrep.yml +25 -0
  27. package/bin/utils/resource/workers-site/LICENSE_APACHE +176 -0
  28. package/bin/utils/resource/workers-site/LICENSE_MIT +25 -0
  29. package/bin/utils/resource/workers-site/index.js +66 -0
  30. package/bin/utils/resource/workers-site/package.json +12 -0
  31. package/bin/utils/updatePackageJson.js +78 -54
  32. package/index.js +34 -2
  33. package/package.json +1 -1
  34. package/bin/utils/resource/src/app/MODULES/auth/README.md +0 -10
  35. package/bin/utils/resource/src/app/MODULES/authentication/login/login.module.ts +0 -19
  36. package/bin/utils/resource/src/app/MODULES/authentication/page404/page404.module.ts +0 -17
  37. package/bin/utils/resource/src/app/MODULES/authentication/register/register.component.html +0 -3
  38. package/bin/utils/resource/src/app/MODULES/authentication/register/register.component.ts +0 -16
  39. package/bin/utils/resource/src/app/MODULES/authentication/register/register.module.ts +0 -18
  40. package/bin/utils/resource/src/app/MODULES/dashboard/README.md +0 -10
  41. package/bin/utils/resource/src/app/MODULES/home/README.md +0 -10
  42. package/bin/utils/resource/src/app/MODULES/home/home.component.html +0 -4
  43. package/bin/utils/resource/src/app/MODULES/home/home.module.ts +0 -19
  44. package/bin/utils/resource/src/app/core/models/entities/screen.entity.spec.ts +0 -41
  45. package/bin/utils/resource/src/app/core/models/entities/screen.entity.ts +0 -16
  46. package/bin/utils/resource/src/app/core/respositories/screen_repo/screen.repo.ts +0 -19
  47. package/bin/utils/resource/src/app/core/respository/screen_repo/screen.repo.ts +0 -27
  48. package/bin/utils/resource/src/app/core/respository/user/user_repo.ts +0 -26
  49. package/bin/utils/resource/src/styles.scss +0 -2
  50. /package/bin/utils/resource/src/app/{MODULES/authentication/login/login.component.scss → PAGES/authentication/login/login.component.css} +0 -0
  51. /package/bin/utils/resource/src/app/{MODULES → PAGES}/authentication/login/login.component.html +0 -0
  52. /package/bin/utils/resource/src/app/{MODULES/authentication/page404/page404.component.scss → PAGES/authentication/page404/page404.component.css} +0 -0
  53. /package/bin/utils/resource/src/app/{MODULES → PAGES}/authentication/page404/page404.component.html +0 -0
  54. /package/bin/utils/resource/src/app/{MODULES/authentication/register/register.component.scss → PAGES/home/home.component.css} +0 -0
  55. /package/bin/utils/resource/src/{app/MODULES/home/home.component.scss → styles.css} +0 -0
@@ -1,9 +1,19 @@
1
1
  const fs = require('fs');
2
2
  const { show_status } = require('./showStatus');
3
+ const { execSync} = require("child_process");
4
+
5
+
6
+ const listPackagesToInstall = [
7
+ "npm i tailwindcss @tailwindcss/postcss postcss --force",
8
+ "npm i @ngx-pwa/local-storage --legacy-peer-deps",
9
+ "npm i primeng --legacy-peer-deps",
10
+ "npm i primeicons @primeuix/themes quill --legacy-peer-deps",
11
+ "npm i sweetalert2 --legacy-peer-deps"
12
+ ];
3
13
 
4
14
 
5
15
  // ===================== Update package.json =====================
6
- function update_package_json() {
16
+ async function update_package_json() {
7
17
  show_status("Memperbarui package.json...", "info");
8
18
 
9
19
  const pkgPath = "package.json";
@@ -29,60 +39,74 @@ function update_package_json() {
29
39
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
30
40
  show_status("package.json berhasil diperbarui dengan script build multi-env!", "success");
31
41
 
42
+
43
+
44
+ listPackagesToInstall.forEach(command => {
45
+ console.log(`Menjalankan: ${command}`);
46
+ try {
47
+ execSync(command, { stdio: 'inherit' });
48
+ show_status(`Berhasil menjalankan: ${command}`, "success");
49
+ } catch (error) {
50
+ show_status(`Gagal menjalankan: ${command}`, "error");
51
+ }
52
+ });
53
+
54
+
55
+
32
56
  // ------------------- Angular file replacements -------------------
33
- if (!fs.existsSync(angularJsonPath)) {
34
- show_status("⚠ angular.json tidak ditemukan! Lewati file replacement.", "warning");
35
- return;
36
- }
37
-
38
- const angularJson = JSON.parse(fs.readFileSync(angularJsonPath, "utf8"));
39
-
40
- // Pilih project
41
- const projectNames = Object.keys(angularJson.projects);
42
- const projectName = angularJson.defaultProject || projectNames[0];
43
-
44
- const project = angularJson.projects[projectName];
45
- const buildTarget = project.architect?.build || project.targets?.build;
46
-
47
- if (!buildTarget) {
48
- show_status("⚠ Build target tidak ditemukan di angular.json!", "error");
49
- return;
50
- }
51
-
52
- const buildConfig = buildTarget.configurations || {};
53
-
54
- // ------------------- Tambahkan environment config -------------------
55
- buildConfig["dev"] = {
56
- fileReplacements: [
57
- {
58
- replace: "src/environments/environment.ts",
59
- with: "src/environments/environment.dev.ts"
60
- }
61
- ]
62
- };
63
-
64
- buildConfig["staging"] = {
65
- fileReplacements: [
66
- {
67
- replace: "src/environments/environment.ts",
68
- with: "src/environments/environment.staging.ts"
69
- }
70
- ]
71
- };
72
-
73
- buildConfig["production"] = {
74
- fileReplacements: [
75
- {
76
- replace: "src/environments/environment.ts",
77
- with: "src/environments/environment.prod.ts"
78
- }
79
- ]
80
- };
81
-
82
- buildTarget.configurations = buildConfig;
83
-
84
- fs.writeFileSync(angularJsonPath, JSON.stringify(angularJson, null, 2));
85
- show_status("angular.json berhasil diperbarui dengan file replacement multi-env!", "success");
57
+ // if (!fs.existsSync(angularJsonPath)) {
58
+ // show_status("⚠ angular.json tidak ditemukan! Lewati file replacement.", "warning");
59
+ // return;
60
+ // }
61
+
62
+ // const angularJson = JSON.parse(fs.readFileSync(angularJsonPath, "utf8"));
63
+
64
+ // // Pilih project
65
+ // const projectNames = Object.keys(angularJson.projects);
66
+ // const projectName = angularJson.defaultProject || projectNames[0];
67
+
68
+ // const project = angularJson.projects[projectName];
69
+ // const buildTarget = project.architect?.build || project.targets?.build;
70
+
71
+ // if (!buildTarget) {
72
+ // show_status("⚠ Build target tidak ditemukan di angular.json!", "error");
73
+ // return;
74
+ // }
75
+
76
+ // const buildConfig = buildTarget.configurations || {};
77
+
78
+ // // ------------------- Tambahkan environment config -------------------
79
+ // buildConfig["dev"] = {
80
+ // fileReplacements: [
81
+ // {
82
+ // replace: "src/environments/environment.ts",
83
+ // with: "src/environments/environment.dev.ts"
84
+ // }
85
+ // ]
86
+ // };
87
+
88
+ // buildConfig["staging"] = {
89
+ // fileReplacements: [
90
+ // {
91
+ // replace: "src/environments/environment.ts",
92
+ // with: "src/environments/environment.staging.ts"
93
+ // }
94
+ // ]
95
+ // };
96
+
97
+ // buildConfig["production"] = {
98
+ // fileReplacements: [
99
+ // {
100
+ // replace: "src/environments/environment.ts",
101
+ // with: "src/environments/environment.prod.ts"
102
+ // }
103
+ // ]
104
+ // };
105
+
106
+ // buildTarget.configurations = buildConfig;
107
+
108
+ // fs.writeFileSync(angularJsonPath, JSON.stringify(angularJson, null, 2));
109
+ // show_status("angular.json berhasil diperbarui dengan file replacement multi-env!", "success");
86
110
  }
87
111
 
88
112
  module.exports = {update_package_json };
package/index.js CHANGED
@@ -25,6 +25,7 @@ const chalk = require('chalk');
25
25
  require('@dotenvx/dotenvx').config({ path: path.resolve(__dirname, ".env"), silent: true });
26
26
 
27
27
  const { login, logout } = require("./bin/utils/auth");
28
+ const { update_package_json } = require("./bin/utils/updatePackageJson");
28
29
 
29
30
 
30
31
  // Baca versi dari package.json
@@ -166,6 +167,35 @@ function copyRecursiveSync(src, dest) {
166
167
  }
167
168
 
168
169
 
170
+ function createWranglerToml(projectName) {
171
+
172
+ show_status("Membuat file wrangler.toml...", "info");
173
+ const content = `
174
+ name = "${projectName}"
175
+ type = "webpack"
176
+ account_id = "8b7c5266052d4c4df67071db2f22692f"
177
+ workers_dev = true
178
+ compatibility_date = "2024-11-04"
179
+
180
+ usage_model = "bundled"
181
+
182
+ site = { bucket = "./dist/${projectName}/browser", entry_point = "workers-site" }
183
+
184
+ route = ""
185
+
186
+ compatibility_flags = []
187
+ `.trim();
188
+
189
+ fs.writeFileSync(
190
+ path.join(process.cwd(), "wrangler.toml"),
191
+ content,
192
+ { encoding: "utf8" }
193
+ );
194
+
195
+ show_status("File wrangler.toml berhasil dibuat!", "success");
196
+ }
197
+
198
+
169
199
 
170
200
  // ===================== MARK:Main =====================
171
201
  async function main() {
@@ -192,8 +222,10 @@ async function main() {
192
222
  await sleep(1000);
193
223
  refactorAngularJson();
194
224
  await sleep(1000);
195
- // update_package_json();
196
- await run_with_spinner("npm install", "Menginstall dependencies...", "Dependencies berhasil diinstall!", "Gagal install dependencies");
225
+ await update_package_json();
226
+ await sleep(1000);
227
+ createWranglerToml(projectName);
228
+ // await run_with_spinner("npm install", "Menginstall dependencies...", "Dependencies berhasil diinstall!", "Gagal install dependencies");
197
229
  await sleep(1000);
198
230
  show_completion(projectName, OS);
199
231
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unictive-angular",
3
- "version": "1.0.37",
3
+ "version": "1.0.40",
4
4
  "description": "CLI untuk membuat project Angular dengan struktur kustom (Modules, Core, API, Shared).",
5
5
  "scripts": {
6
6
  "build": "npm version patch && npm publish --access public"
@@ -1,10 +0,0 @@
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.
@@ -1,19 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { LoginComponent } from './login.component';
4
- import { RouterModule, Routes } from '@angular/router';
5
- import { LibraryModule } from '@shared/libs/library.module';
6
-
7
- const routes: Routes = [
8
- { path: '', component: LoginComponent }
9
- ]
10
-
11
- @NgModule({
12
- imports: [
13
- CommonModule,
14
- LibraryModule,
15
- RouterModule.forChild(routes)
16
- ],
17
- declarations: [LoginComponent]
18
- })
19
- export class LoginModule { }
@@ -1,17 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { Page404Component } from './page404.component';
4
- import { RouterModule, Routes } from '@angular/router';
5
-
6
- const routes: Routes = [
7
- { path: '', component: Page404Component }
8
- ]
9
-
10
- @NgModule({
11
- imports: [
12
- CommonModule,
13
- RouterModule.forChild(routes)
14
- ],
15
- declarations: [Page404Component]
16
- })
17
- export class Page404Module { }
@@ -1,16 +0,0 @@
1
- import { Component, OnInit } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'app-register',
5
- templateUrl: './register.component.html',
6
- styleUrls: ['./register.component.scss'],
7
- standalone: false
8
- })
9
- export class RegisterComponent implements OnInit {
10
-
11
- constructor() { }
12
-
13
- ngOnInit() {
14
- }
15
-
16
- }
@@ -1,18 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { RegisterComponent } from './register.component';
4
- import { RouterModule, Routes } from '@angular/router';
5
-
6
-
7
- const routes: Routes = [
8
- { path: '', component: RegisterComponent }
9
- ]
10
-
11
- @NgModule({
12
- imports: [
13
- CommonModule,
14
- RouterModule.forChild(routes)
15
- ],
16
- declarations: [RegisterComponent]
17
- })
18
- export class RegisterModule { }
@@ -1,10 +0,0 @@
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.
@@ -1,10 +0,0 @@
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.
@@ -1,4 +0,0 @@
1
- <p>
2
- home works!
3
- </p>
4
- <app-widget_game></app-widget_game>
@@ -1,19 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { HomeComponent } from './home.component';
4
- import { RouterModule, Routes } from '@angular/router';
5
- import { Widget_gameModule } from '@shared/widgets/widget_game/widget_game.module';
6
-
7
- const routes: Routes = [
8
- { path: '', component: HomeComponent }
9
- ]
10
-
11
- @NgModule({
12
- imports: [
13
- CommonModule,
14
- Widget_gameModule,
15
- RouterModule.forChild(routes)
16
- ],
17
- declarations: [HomeComponent]
18
- })
19
- export class HomeModule { }
@@ -1,41 +0,0 @@
1
- import { RepoScreen } from '@core/respository/screen_repo/screen.repo';
2
- import { ScreenEntity, Screen_m } from './screen.entity';
3
- import { provideZonelessChangeDetection } from '@angular/core';
4
- import { TestBed } from '@angular/core/testing';
5
- import { HttpClientTestingModule } from '@angular/common/http/testing';
6
-
7
-
8
- describe('ScreenEntity', () => {
9
- let repo: RepoScreen;
10
-
11
- const mockScreen: Screen_m = {
12
- timestamp: Date.now(),
13
- type: 'test',
14
- id: 123,
15
- name: 'Mock Screen',
16
- mode: 'demo',
17
- time: 60000
18
-
19
- };
20
-
21
- beforeEach(async () => {
22
- await TestBed.configureTestingModule({
23
- imports: [HttpClientTestingModule],
24
- providers: [provideZonelessChangeDetection()]
25
- }).compileComponents();
26
-
27
- repo = TestBed.inject(RepoScreen);
28
- });
29
-
30
- it('should set and get screen', () => {
31
- repo.setData(mockScreen);
32
- expect(repo.getData.value).toEqual(mockScreen);
33
- });
34
-
35
- it('should update state when entity is set again', () => {
36
- const newMock: Screen_m = { ...mockScreen, id: 456, name: 'New Mock' };
37
- repo.setData(newMock);
38
- expect(repo.getData.value?.id).toBe(456);
39
- expect(repo.getData.value?.name).toBe('New Mock');
40
- });
41
- });
@@ -1,16 +0,0 @@
1
- // import { entityStoreFactory } from "@core/config/entity-store";
2
- import { singleStoreFactory } from "@core/config/single-store";
3
-
4
-
5
-
6
- export interface Screen_m {
7
- timestamp: number;
8
- type: string;
9
- id: number;
10
- name: string;
11
- mode: string;
12
- time: number;
13
- }
14
-
15
-
16
- export const ScreenEntity = singleStoreFactory<Screen_m>();
@@ -1,19 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { HttpClient } from '@angular/common/http';
3
- import { ScreenEntity } from '@core/models/entities/screen.entity';
4
- import { logger } from '@shared/utils/logger';
5
-
6
- @Injectable({ providedIn: 'root' })
7
- export class RepoScreen {
8
-
9
-
10
- constructor() { }
11
-
12
- setData(screen: any) {
13
- ScreenEntity.set(screen);
14
- }
15
-
16
- get getData() {
17
- return ScreenEntity.state();
18
- }
19
- }
@@ -1,27 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { HttpClient } from '@angular/common/http';
3
- import { ScreenEntity } from '@core/models/entities/screen.entity';
4
- import { logger } from '@shared/utils/logger';
5
- import { Entity_User } from '@core/models/entities/user.entity';
6
- import { UserService } from '@api/user.service';
7
-
8
- @Injectable({ providedIn: 'root' })
9
- export class RepoScreen {
10
-
11
-
12
- constructor(
13
- private api: UserService
14
- ) { }
15
-
16
- load_user() {
17
- Entity_User.load(async () => {
18
- const res = await this.api.get_user();
19
- const response = res?.data ?? [];
20
- return response; // hanya return user
21
- });
22
- }
23
-
24
- get getData() {
25
- return ScreenEntity.state();
26
- }
27
- }
@@ -1,26 +0,0 @@
1
- import { Injectable } from "@angular/core";
2
- import { UserService } from "@api/user.service";
3
- import { Entity_User } from "@core/models/entities/user.entity";
4
-
5
- @Injectable({ providedIn: 'root' })
6
- export class Repo_User {
7
-
8
-
9
- constructor(
10
- private api: UserService
11
- ) { }
12
-
13
- load_user() {
14
- Entity_User.load(async () => {
15
- const res = await this.api.get_user();
16
- const response = res?.data ?? null;
17
- return response; // hanya return user
18
- });
19
- }
20
-
21
-
22
- get getData() {
23
- return Entity_User.state();
24
- }
25
-
26
- }
@@ -1,2 +0,0 @@
1
- // @import "tailwindcss";
2
-