unictive-angular 1.0.6 → 1.0.8

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 (52) hide show
  1. package/bin/index.js +2 -77
  2. package/bin/utils/createStructure.js +72 -0
  3. package/bin/utils/updatePackageJson.js +73 -11
  4. package/package.json +2 -2
  5. package/test/.editorconfig +0 -17
  6. package/test/.vscode/extensions.json +0 -4
  7. package/test/.vscode/launch.json +0 -20
  8. package/test/.vscode/tasks.json +0 -42
  9. package/test/README.md +0 -59
  10. package/test/angular.json +0 -92
  11. package/test/package-lock.json +0 -9930
  12. package/test/package.json +0 -40
  13. package/test/package.json.backup +0 -35
  14. package/test/public/favicon.ico +0 -0
  15. package/test/src/app/app.config.ts +0 -12
  16. package/test/src/app/app.html +0 -336
  17. package/test/src/app/app.routes.ts +0 -3
  18. package/test/src/app/app.scss +0 -0
  19. package/test/src/app/app.spec.ts +0 -25
  20. package/test/src/app/app.ts +0 -12
  21. package/test/src/app/core/README.md +0 -10
  22. package/test/src/app/core/config/README.md +0 -10
  23. package/test/src/app/core/guards/README.md +0 -10
  24. package/test/src/app/core/interceptors/README.md +0 -10
  25. package/test/src/app/core/models/README.md +0 -10
  26. package/test/src/app/core/services/README.md +0 -10
  27. package/test/src/app/features/dashboard/application/README.md +0 -10
  28. package/test/src/app/features/dashboard/domain/README.md +0 -10
  29. package/test/src/app/features/dashboard/infrastructure/README.md +0 -10
  30. package/test/src/app/features/dashboard/presentation/README.md +0 -10
  31. package/test/src/app/features/profile/application/README.md +0 -10
  32. package/test/src/app/features/profile/domain/README.md +0 -10
  33. package/test/src/app/features/profile/infrastructure/README.md +0 -10
  34. package/test/src/app/features/profile/presentation/README.md +0 -10
  35. package/test/src/app/features/settings/application/README.md +0 -10
  36. package/test/src/app/features/settings/domain/README.md +0 -10
  37. package/test/src/app/features/settings/infrastructure/README.md +0 -10
  38. package/test/src/app/features/settings/presentation/README.md +0 -10
  39. package/test/src/app/shared/README.md +0 -10
  40. package/test/src/app/shared/directives/README.md +0 -10
  41. package/test/src/app/shared/pipes/README.md +0 -10
  42. package/test/src/app/shared/ui/README.md +0 -10
  43. package/test/src/app/shared/utils/README.md +0 -10
  44. package/test/src/environments/environment.prod.ts +0 -5
  45. package/test/src/environments/environment.staging.ts +0 -5
  46. package/test/src/environments/environment.ts +0 -5
  47. package/test/src/index.html +0 -13
  48. package/test/src/main.ts +0 -6
  49. package/test/src/styles.scss +0 -1
  50. package/test/tsconfig.app.json +0 -15
  51. package/test/tsconfig.json +0 -34
  52. package/test/tsconfig.spec.json +0 -14
package/bin/index.js CHANGED
@@ -15,7 +15,7 @@ const { show_status, run_with_spinner } = require('./utils/showStatus');
15
15
  const { setupAssets } = require('./utils/setupAssets');
16
16
  const { create_project } = require('./utils/createProject');
17
17
  const { update_package_json } = require('./utils/updatePackageJson');
18
- const updateNotifier = require("update-notifier");
18
+ const updateNotifier = require('update-notifier');
19
19
  const chalk = require('chalk');
20
20
 
21
21
 
@@ -29,7 +29,7 @@ if (process.argv.includes("-v") || process.argv.includes("--version")) {
29
29
  }
30
30
 
31
31
  // ===================== Notifikasi Update =====================
32
- const notifier = updateNotifier({ pkg, updateCheckInterval: 1000 * 60 * 60 * 24 });
32
+ const notifier = updateNotifier({ pkg, updateCheckInterval: 1000 * 60 * 60 * 6 });
33
33
 
34
34
  if (notifier.update) {
35
35
  console.log(`
@@ -106,71 +106,6 @@ async function check_dependencies() {
106
106
 
107
107
 
108
108
 
109
- // ===================== Structure =====================
110
- function create_structure() {
111
- show_status("Membuat struktur folder arsitektur...", "info");
112
- const folders = [
113
- // Core Layer
114
- "src/app/core",
115
- "src/app/core/config",
116
- "src/app/core/guards",
117
- "src/app/core/interceptors",
118
- "src/app/core/models",
119
- "src/app/core/services",
120
-
121
- // Shared Layer
122
- "src/app/shared",
123
- "src/app/shared/ui",
124
- "src/app/shared/pipes",
125
- "src/app/shared/directives",
126
- "src/app/shared/utils",
127
-
128
- // Features Layer - contoh fitur awal
129
- "src/app/features/dashboard/domain",
130
- "src/app/features/dashboard/application",
131
- "src/app/features/dashboard/infrastructure",
132
- "src/app/features/dashboard/presentation",
133
-
134
- "src/app/features/profile/domain",
135
- "src/app/features/profile/application",
136
- "src/app/features/profile/infrastructure",
137
- "src/app/features/profile/presentation",
138
-
139
- "src/app/features/settings/domain",
140
- "src/app/features/settings/application",
141
- "src/app/features/settings/infrastructure",
142
- "src/app/features/settings/presentation",
143
- ];
144
-
145
- // Fungsi menulis README di tiap folder
146
- function writeReadme(folder) {
147
- const layer = folder.split("/").pop();
148
- const content = `# ${layer.toUpperCase()}
149
-
150
- Folder ini untuk layer **${layer}**.
151
-
152
- - **domain** → berisi entity, interface, dan aturan bisnis murni
153
- - **application** → berisi use case, service koordinasi domain
154
- - **infrastructure** → berisi API call, repository, integrasi eksternal
155
- - **presentation** → berisi komponen Angular, routing, dan UI
156
-
157
- > Bagian ini adalah bagian dari arsitektur **Clean Architecture** untuk fitur ini.
158
- `;
159
-
160
- fs.writeFileSync(path.join(folder, "README.md"), content);
161
- }
162
-
163
- // Buat folder dan isi README
164
- folders.forEach((folder) => {
165
- fs.mkdirSync(folder, { recursive: true });
166
- writeReadme(folder);
167
- console.log(`Created: ${folder}`);
168
- });
169
-
170
- show_status("Struktur folder berhasil dibuat!", "success");
171
-
172
- }
173
-
174
109
 
175
110
 
176
111
 
@@ -208,16 +143,6 @@ function copyRecursiveSync(src, dest) {
208
143
  }
209
144
  }
210
145
 
211
- async function copy_template() {
212
- show_status("Menyalin folder app dari template ke src/app...", "info");
213
-
214
- const srcFolder = path.join(__dirname, "templates", "app");
215
- const destFolder = path.join(process.cwd(), "src", "app");
216
-
217
- copyRecursiveSync(srcFolder, destFolder);
218
-
219
- show_status("Folder src/app berhasil disalin!", "success");
220
- }
221
146
 
222
147
 
223
148
  // ===================== MARK:Main =====================
@@ -0,0 +1,72 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { show_status } = require('./showStatus');
4
+
5
+ const path_template = path.join(__dirname, "templates", "app");
6
+
7
+ 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");
12
+
13
+ copyRecursiveSync(srcFolder, destFolder);
14
+
15
+ show_status("Folder src/app berhasil disalin!", "success");
16
+ }
17
+
18
+
19
+
20
+ // ===================== Structure =====================
21
+ function create_structure() {
22
+ show_status("Membuat struktur folder arsitektur...", "info");
23
+ const folders = [
24
+ // Core Layer
25
+ "src/app/core",
26
+ "src/app/core/config",
27
+ "src/app/core/guards",
28
+ "src/app/core/interceptors",
29
+ "src/app/core/models",
30
+ "src/app/core/services",
31
+
32
+ // Shared Layer
33
+ "src/app/shared",
34
+ "src/app/shared/ui",
35
+ "src/app/shared/pipes",
36
+ "src/app/shared/directives",
37
+ "src/app/shared/utils",
38
+
39
+ // Modules Layer - contoh fitur awal
40
+ 'src/app/MODULES/auth',
41
+ 'src/app/MODULES/dashboard',
42
+ 'src/app/MODULES/home',
43
+ ];
44
+
45
+ // Fungsi menulis README di tiap folder
46
+ function writeReadme(folder) {
47
+ const layer = folder.split("/").pop();
48
+ const content = `# ${layer.toUpperCase()}
49
+
50
+ Folder ini untuk layer **${layer}**.
51
+
52
+ - **domain** → berisi entity, interface, dan aturan bisnis murni
53
+ - **application** → berisi use case, service koordinasi domain
54
+ - **infrastructure** → berisi API call, repository, integrasi eksternal
55
+ - **presentation** → berisi komponen Angular, routing, dan UI
56
+
57
+ > Bagian ini adalah bagian dari arsitektur **Clean Architecture** untuk fitur ini.
58
+ `;
59
+
60
+ fs.writeFileSync(path.join(folder, "README.md"), content);
61
+ }
62
+
63
+ // Buat folder dan isi README
64
+ folders.forEach((folder) => {
65
+ fs.mkdirSync(folder, { recursive: true });
66
+ writeReadme(folder);
67
+ console.log(`Created: ${folder}`);
68
+ });
69
+
70
+ show_status("Struktur folder berhasil dibuat!", "success");
71
+
72
+ }
@@ -6,21 +6,83 @@ const { show_status } = require('./showStatus');
6
6
  function update_package_json() {
7
7
  show_status("Memperbarui package.json...", "info");
8
8
 
9
- const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));
10
- fs.copyFileSync("package.json", "package.json.backup");
11
-
12
- // Tambahkan/Update scripts
13
- pkg.scripts["start:dev"] = "ng serve --port 4200 --open";
14
- pkg.scripts["build:dev"] = "cp src/env/config.dev.json src/assets/config.json && ng build";
15
- pkg.scripts["build:staging"] = "cp src/env/config.staging.json src/assets/config.json && ng build";
16
- pkg.scripts["build:prod"] = "cp src/env/config.prod.json src/assets/config.json && ng build --configuration production";
9
+ const pkgPath = "package.json";
10
+ const angularJsonPath = "angular.json";
11
+
12
+ // ------------------- Backup -------------------
13
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
14
+ fs.copyFileSync(pkgPath, "package.json.backup");
15
+
16
+ // ------------------- Scripts -------------------
17
+ pkg.scripts = pkg.scripts || {};
18
+ pkg.scripts["start:dev"] = "ng serve --configuration=dev --port 4200 --open";
19
+ pkg.scripts["start:staging"] = "ng serve --configuration=staging --port 4200 --open";
20
+ pkg.scripts["start:prod"] = "ng serve --configuration=production --port 4200 --open";
21
+
22
+ pkg.scripts["build:dev"] = "ng build --configuration=dev";
23
+ pkg.scripts["build:staging"] = "ng build --configuration=staging";
24
+ pkg.scripts["build:prod"] = "ng build --configuration=production";
25
+
17
26
  pkg.scripts["lint"] = "ng lint";
18
27
  pkg.scripts["test"] = "ng test --watch=false";
19
28
 
20
- fs.writeFileSync("package.json", JSON.stringify(pkg, null, 2));
21
-
29
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
22
30
  show_status("package.json berhasil diperbarui dengan script build multi-env!", "success");
23
- }
24
31
 
32
+ // ------------------- 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");
86
+ }
25
87
 
26
88
  module.exports = {update_package_json };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unictive-angular",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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"
@@ -18,6 +18,6 @@
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
20
  "chalk": "^5.6.0",
21
- "update-notifier": "^6.0.2"
21
+ "update-notifier": "^5.1.0"
22
22
  }
23
23
  }
@@ -1,17 +0,0 @@
1
- # Editor configuration, see https://editorconfig.org
2
- root = true
3
-
4
- [*]
5
- charset = utf-8
6
- indent_style = space
7
- indent_size = 2
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
10
-
11
- [*.ts]
12
- quote_type = single
13
- ij_typescript_use_double_quotes = false
14
-
15
- [*.md]
16
- max_line_length = off
17
- trim_trailing_whitespace = false
@@ -1,4 +0,0 @@
1
- {
2
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3
- "recommendations": ["angular.ng-template"]
4
- }
@@ -1,20 +0,0 @@
1
- {
2
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3
- "version": "0.2.0",
4
- "configurations": [
5
- {
6
- "name": "ng serve",
7
- "type": "chrome",
8
- "request": "launch",
9
- "preLaunchTask": "npm: start",
10
- "url": "http://localhost:4200/"
11
- },
12
- {
13
- "name": "ng test",
14
- "type": "chrome",
15
- "request": "launch",
16
- "preLaunchTask": "npm: test",
17
- "url": "http://localhost:9876/debug.html"
18
- }
19
- ]
20
- }
@@ -1,42 +0,0 @@
1
- {
2
- // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3
- "version": "2.0.0",
4
- "tasks": [
5
- {
6
- "type": "npm",
7
- "script": "start",
8
- "isBackground": true,
9
- "problemMatcher": {
10
- "owner": "typescript",
11
- "pattern": "$tsc",
12
- "background": {
13
- "activeOnStart": true,
14
- "beginsPattern": {
15
- "regexp": "(.*?)"
16
- },
17
- "endsPattern": {
18
- "regexp": "bundle generation complete"
19
- }
20
- }
21
- }
22
- },
23
- {
24
- "type": "npm",
25
- "script": "test",
26
- "isBackground": true,
27
- "problemMatcher": {
28
- "owner": "typescript",
29
- "pattern": "$tsc",
30
- "background": {
31
- "activeOnStart": true,
32
- "beginsPattern": {
33
- "regexp": "(.*?)"
34
- },
35
- "endsPattern": {
36
- "regexp": "bundle generation complete"
37
- }
38
- }
39
- }
40
- }
41
- ]
42
- }
package/test/README.md DELETED
@@ -1,59 +0,0 @@
1
- # Test
2
-
3
- This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.0.3.
4
-
5
- ## Development server
6
-
7
- To start a local development server, run:
8
-
9
- ```bash
10
- ng serve
11
- ```
12
-
13
- Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
14
-
15
- ## Code scaffolding
16
-
17
- Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
18
-
19
- ```bash
20
- ng generate component component-name
21
- ```
22
-
23
- For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
24
-
25
- ```bash
26
- ng generate --help
27
- ```
28
-
29
- ## Building
30
-
31
- To build the project run:
32
-
33
- ```bash
34
- ng build
35
- ```
36
-
37
- This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
38
-
39
- ## Running unit tests
40
-
41
- To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
42
-
43
- ```bash
44
- ng test
45
- ```
46
-
47
- ## Running end-to-end tests
48
-
49
- For end-to-end (e2e) testing, run:
50
-
51
- ```bash
52
- ng e2e
53
- ```
54
-
55
- Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
56
-
57
- ## Additional Resources
58
-
59
- For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
package/test/angular.json DELETED
@@ -1,92 +0,0 @@
1
- {
2
- "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
- "version": 1,
4
- "newProjectRoot": "projects",
5
- "projects": {
6
- "test": {
7
- "projectType": "application",
8
- "schematics": {
9
- "@schematics/angular:component": {
10
- "style": "scss"
11
- }
12
- },
13
- "root": "",
14
- "sourceRoot": "src",
15
- "prefix": "app",
16
- "architect": {
17
- "build": {
18
- "builder": "@angular/build:application",
19
- "options": {
20
- "browser": "src/main.ts",
21
- "tsConfig": "tsconfig.app.json",
22
- "inlineStyleLanguage": "scss",
23
- "assets": [
24
- {
25
- "glob": "**/*",
26
- "input": "public"
27
- },
28
- "src/assets"
29
- ],
30
- "styles": [
31
- "src/styles.scss"
32
- ]
33
- },
34
- "configurations": {
35
- "production": {
36
- "budgets": [
37
- {
38
- "type": "initial",
39
- "maximumWarning": "500kB",
40
- "maximumError": "1MB"
41
- },
42
- {
43
- "type": "anyComponentStyle",
44
- "maximumWarning": "4kB",
45
- "maximumError": "8kB"
46
- }
47
- ],
48
- "outputHashing": "all"
49
- },
50
- "development": {
51
- "optimization": false,
52
- "extractLicenses": false,
53
- "sourceMap": true
54
- }
55
- },
56
- "defaultConfiguration": "production"
57
- },
58
- "serve": {
59
- "builder": "@angular/build:dev-server",
60
- "configurations": {
61
- "production": {
62
- "buildTarget": "test:build:production"
63
- },
64
- "development": {
65
- "buildTarget": "test:build:development"
66
- }
67
- },
68
- "defaultConfiguration": "development"
69
- },
70
- "extract-i18n": {
71
- "builder": "@angular/build:extract-i18n"
72
- },
73
- "test": {
74
- "builder": "@angular/build:karma",
75
- "options": {
76
- "tsConfig": "tsconfig.spec.json",
77
- "inlineStyleLanguage": "scss",
78
- "assets": [
79
- {
80
- "glob": "**/*",
81
- "input": "public"
82
- }
83
- ],
84
- "styles": [
85
- "src/styles.scss"
86
- ]
87
- }
88
- }
89
- }
90
- }
91
- }
92
- }