@nanoforge-dev/schematics 2.1.3 → 2.1.4-beta.3ea7d5f

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 (47) hide show
  1. package/README.md +3 -0
  2. package/dist/index.cjs +15 -46
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +3 -1
  5. package/dist/index.d.cts.map +1 -0
  6. package/dist/index.d.ts +3 -1
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +10 -15
  9. package/dist/index.js.map +1 -1
  10. package/dist/libs/application/application.factory.d.ts +10 -13
  11. package/dist/libs/application/application.factory.d.ts.map +1 -0
  12. package/dist/libs/application/application.factory.js +52 -68
  13. package/dist/libs/application/application.factory.js.map +1 -1
  14. package/dist/libs/application/files/js/README.md +165 -0
  15. package/dist/libs/application/files/js/__dot__env +6 -0
  16. package/dist/libs/application/files/js/__dot__gitignore +134 -0
  17. package/dist/libs/application/files/ts/README.md +165 -0
  18. package/dist/libs/application/files/ts/__dot__env +6 -0
  19. package/dist/libs/application/files/ts/__dot__gitignore +134 -0
  20. package/dist/libs/application/schema.json +5 -0
  21. package/dist/libs/component/component.factory.d.ts +6 -6
  22. package/dist/libs/component/component.factory.d.ts.map +1 -0
  23. package/dist/libs/component/component.factory.js +32 -47
  24. package/dist/libs/component/component.factory.js.map +1 -1
  25. package/dist/libs/component/files/js/__fileName__.component.js +21 -27
  26. package/dist/libs/component/files/ts/__fileName__.component.ts +21 -27
  27. package/dist/libs/configuration/configuration.factory.d.ts +6 -7
  28. package/dist/libs/configuration/configuration.factory.d.ts.map +1 -0
  29. package/dist/libs/configuration/configuration.factory.js +91 -133
  30. package/dist/libs/configuration/configuration.factory.js.map +1 -1
  31. package/dist/libs/docker/docker.factory.d.ts +6 -4
  32. package/dist/libs/docker/docker.factory.d.ts.map +1 -0
  33. package/dist/libs/docker/docker.factory.js +17 -36
  34. package/dist/libs/docker/docker.factory.js.map +1 -1
  35. package/dist/libs/part-base/part-base.factory.d.ts +6 -7
  36. package/dist/libs/part-base/part-base.factory.d.ts.map +1 -0
  37. package/dist/libs/part-base/part-base.factory.js +30 -41
  38. package/dist/libs/part-base/part-base.factory.js.map +1 -1
  39. package/dist/libs/part-main/part-main.factory.d.ts +6 -9
  40. package/dist/libs/part-main/part-main.factory.d.ts.map +1 -0
  41. package/dist/libs/part-main/part-main.factory.js +228 -260
  42. package/dist/libs/part-main/part-main.factory.js.map +1 -1
  43. package/dist/libs/system/system.factory.d.ts +6 -6
  44. package/dist/libs/system/system.factory.d.ts.map +1 -0
  45. package/dist/libs/system/system.factory.js +32 -50
  46. package/dist/libs/system/system.factory.js.map +1 -1
  47. package/package.json +18 -18
@@ -0,0 +1,134 @@
1
+ ### VisualStudioCode template
2
+ .vscode/*
3
+ !.vscode/settings.json
4
+ !.vscode/tasks.json
5
+ !.vscode/launch.json
6
+ !.vscode/extensions.json
7
+ !.vscode/*.code-snippets
8
+
9
+ # Local History for Visual Studio Code
10
+ .history/
11
+
12
+ # Built Visual Studio Code Extensions
13
+ *.vsix
14
+
15
+ ### JetBrains template
16
+
17
+ # User-specific stuff
18
+ .idea/**/workspace.xml
19
+ .idea/**/tasks.xml
20
+ .idea/**/usage.statistics.xml
21
+ .idea/**/dictionaries
22
+ .idea/**/shelf
23
+
24
+ # Generated files
25
+ .idea/**/contentModel.xml
26
+
27
+ # Sensitive or high-churn files
28
+ .idea/**/dataSources/
29
+ .idea/**/dataSources.ids
30
+ .idea/**/dataSources.local.xml
31
+ .idea/**/sqlDataSources.xml
32
+ .idea/**/dynamic.xml
33
+ .idea/**/uiDesigner.xml
34
+ .idea/**/dbnavigator.xml
35
+
36
+ # File-based project format
37
+ *.iws
38
+
39
+ # Editor-based Rest Client
40
+ .idea/httpRequests
41
+
42
+ ### Node template
43
+ # Logs
44
+ logs
45
+ *.log
46
+ npm-debug.log*
47
+ yarn-debug.log*
48
+ yarn-error.log*
49
+ lerna-debug.log*
50
+ .pnpm-debug.log*
51
+
52
+ # Diagnostic reports (https://nodejs.org/api/report.html)
53
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
54
+
55
+ # Runtime data
56
+ pids
57
+ *.pid
58
+ *.seed
59
+ *.pid.lock
60
+
61
+ # Directory for instrumented libs generated by jscoverage/JSCover
62
+ lib-cov
63
+
64
+ # Coverage directory used by tools like istanbul
65
+ coverage
66
+ *.lcov
67
+
68
+ # nyc test coverage
69
+ .nyc_output
70
+
71
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
72
+ .grunt
73
+
74
+ # Bower dependency directory (https://bower.io/)
75
+ bower_components
76
+
77
+ # node-waf configuration
78
+ .lock-wscript
79
+
80
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
81
+ build/Release
82
+
83
+ # Dependency directories
84
+ node_modules/
85
+ jspm_packages/
86
+
87
+ # Snowpack dependency directory (https://snowpack.dev/)
88
+ web_modules/
89
+
90
+ # TypeScript cache
91
+ *.tsbuildinfo
92
+
93
+ # Optional npm cache directory
94
+ .npm
95
+
96
+ # Optional eslint cache
97
+ .eslintcache
98
+
99
+ # Optional stylelint cache
100
+ .stylelintcache
101
+
102
+ # Microbundle cache
103
+ .rpt2_cache/
104
+ .rts2_cache_cjs/
105
+ .rts2_cache_es/
106
+ .rts2_cache_umd/
107
+
108
+ # Optional REPL history
109
+ .node_repl_history
110
+
111
+ # Output of 'npm pack'
112
+ *.tgz
113
+
114
+ # Yarn Integrity file
115
+ .yarn-integrity
116
+
117
+ # dotenv environment variable files
118
+ .env
119
+ .env.development.local
120
+ .env.test.local
121
+ .env.production.local
122
+ .env.local
123
+
124
+ # yarn v2
125
+ .yarn/cache
126
+ .yarn/unplugged
127
+ .yarn/build-state.yml
128
+ .yarn/install-state.gz
129
+ .pnp.*
130
+
131
+ ### NanoForge template
132
+ # Compilation directories
133
+ .nanoforge/client
134
+ .nanoforge/server
@@ -1 +1,166 @@
1
1
  # <%= name %>
2
+
3
+ ---
4
+
5
+ ## Prerequisites
6
+
7
+ - [Node.js](https://nodejs.org/) 18+
8
+ - Package manager: **<%= packageManager %>**
9
+ - [NanoForge CLI](https://www.npmjs.com/package/@nanoforge-dev/cli): `<%= packageManager %> install -g @nanoforge-dev/cli`
10
+
11
+ ---
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ <%= packageManager %> install
17
+ ```
18
+
19
+ ---
20
+
21
+ ## Development
22
+
23
+ Start the game in watch mode with hot reload:
24
+
25
+ ```bash
26
+ nf dev
27
+ ```
28
+
29
+ <% if (editor) { %>Open the visual editor (optional — lets you edit entities, components and systems without touching code):
30
+ ```bash
31
+ nf editor
32
+ ```
33
+
34
+ <% } %>---
35
+
36
+ ## Project structure
37
+
38
+ ```
39
+ <%= name %>/
40
+ ├── .nanoforge/ # NanoForge internal save files (do not edit manually)
41
+ ├── client/ # Client-side code (runs in the browser)
42
+ │ ├── static/ # Static assets
43
+ │ ├── components/ # ECS components
44
+ │ ├── systems/ # ECS systems<% if (initFunctions) { %>
45
+ │ └── init/ # Lifecycle hooks (before-init, after-run, …)<% } %><% if (server) { %>
46
+ ├── server/ # Server-side code
47
+ │ ├── static/
48
+ │ ├── components/
49
+ │ ├── systems/<% if (initFunctions) { %>
50
+ │ └── init/<% } %><% } %>
51
+ ├── package.json
52
+ ├── tsconfig.json
53
+ └── nanoforge.config.json # Game configuration
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Modifying the game
59
+
60
+ ### Add a component
61
+
62
+ ```bash
63
+ nf generate component <name> --part client
64
+ ```
65
+
66
+ A component is a plain class that holds data for an entity. Edit the generated file in `client/components/`:
67
+
68
+ ```ts
69
+ export class MyComponent {
70
+ constructor(public speed: number) {}
71
+ }
72
+
73
+ export default MyComponent.name;
74
+ ```
75
+
76
+ ### Add a system
77
+
78
+ ```bash
79
+ nf generate system <name> --part client
80
+ ```
81
+
82
+ A system is a function that runs every tick and operates on entities that have specific components. Edit the generated file in `client/systems/`:
83
+
84
+ ```ts
85
+ import { type Context } from "@nanoforge-dev/common";
86
+ import { type Registry } from "@nanoforge-dev/ecs-client";
87
+ import { MyComponent } from "../components/my.component";
88
+
89
+ export const mySystem = (registry: Registry, ctx: Context) => {
90
+ const entities = registry.getZipper([MyComponent]);
91
+
92
+ entities.forEach((entity) => {
93
+ entity.MyComponent.speed += 1;
94
+ });
95
+ };
96
+
97
+ export default mySystem.name;
98
+ ```
99
+
100
+ <% if (server) { %>
101
+ ### Server-side code
102
+
103
+ Server components and systems live in `server/` and are imported from `@nanoforge-dev/ecs-server`. They follow the same pattern as the client side.
104
+
105
+ Configure the server connection in `.env`:
106
+
107
+ | Variable | Default | Description |
108
+ |---------------------------------------|-------------|---------------------------------|
109
+ | `NANOFORGE_CLIENT_SERVER_ADDRESS` | `127.0.0.1` | Server address (client-side) |
110
+ | `NANOFORGE_CLIENT_SERVER_TCP_PORT` | `4444` | TCP port the client connects to |
111
+ | `NANOFORGE_CLIENT_SERVER_UDP_PORT` | `4445` | UDP port the client connects to |
112
+ | `NANOFORGE_SERVER_LISTENING_TCP_PORT` | `4444` | TCP port the server listens on |
113
+ | `NANOFORGE_SERVER_LISTENING_UDP_PORT` | `4445` | UDP port the server listens on |
114
+
115
+ <% } %>---
116
+
117
+ ## Build
118
+
119
+ Compile the game for production:
120
+
121
+ ```bash
122
+ <%= packageManager %> run build
123
+ # or
124
+ nf build
125
+ ```
126
+
127
+ Output is written to the `.nanoforge/` directory.
128
+
129
+ ---
130
+
131
+ ## Run
132
+
133
+ Start the game server and open it in a browser:
134
+
135
+ ```bash
136
+ <%= packageManager %> run start
137
+ # or
138
+ nf start
139
+ ```
140
+
141
+ <% if (lint) { %>---
142
+
143
+ ## Code quality
144
+
145
+ ```bash
146
+ # Check formatting and linting
147
+ <%= packageManager %> run lint
148
+
149
+ # Auto-fix formatting and linting
150
+ <%= packageManager %> run format
151
+ ```
152
+
153
+ <% } %>---
154
+
155
+ ## CLI reference
156
+
157
+ | Command | Description |
158
+ |--------------------------------|-------------------------------------------|
159
+ | `nf dev` | Start in development mode with hot reload |
160
+ | `nf build` | Build for production |
161
+ | `nf start` | Run the built game |
162
+ | `nf generate component <name>` | Scaffold a new component |
163
+ | `nf generate system <name>` | Scaffold a new system |<% if (editor) { %>
164
+ | `nf editor` | Open the visual editor |<% } %>
165
+
166
+ Full CLI documentation: <https://docs.nanoforge.eu>
@@ -0,0 +1,6 @@
1
+ NANOFORGE_CLIENT_SERVER_TCP_PORT=4444
2
+ NANOFORGE_CLIENT_SERVER_UDP_PORT=4445
3
+ NANOFORGE_CLIENT_SERVER_ADDRESS=127.0.0.1
4
+
5
+ NANOFORGE_SERVER_LISTENING_TCP_PORT=4444
6
+ NANOFORGE_SERVER_LISTENING_UDP_PORT=4445
@@ -0,0 +1,134 @@
1
+ ### VisualStudioCode template
2
+ .vscode/*
3
+ !.vscode/settings.json
4
+ !.vscode/tasks.json
5
+ !.vscode/launch.json
6
+ !.vscode/extensions.json
7
+ !.vscode/*.code-snippets
8
+
9
+ # Local History for Visual Studio Code
10
+ .history/
11
+
12
+ # Built Visual Studio Code Extensions
13
+ *.vsix
14
+
15
+ ### JetBrains template
16
+
17
+ # User-specific stuff
18
+ .idea/**/workspace.xml
19
+ .idea/**/tasks.xml
20
+ .idea/**/usage.statistics.xml
21
+ .idea/**/dictionaries
22
+ .idea/**/shelf
23
+
24
+ # Generated files
25
+ .idea/**/contentModel.xml
26
+
27
+ # Sensitive or high-churn files
28
+ .idea/**/dataSources/
29
+ .idea/**/dataSources.ids
30
+ .idea/**/dataSources.local.xml
31
+ .idea/**/sqlDataSources.xml
32
+ .idea/**/dynamic.xml
33
+ .idea/**/uiDesigner.xml
34
+ .idea/**/dbnavigator.xml
35
+
36
+ # File-based project format
37
+ *.iws
38
+
39
+ # Editor-based Rest Client
40
+ .idea/httpRequests
41
+
42
+ ### Node template
43
+ # Logs
44
+ logs
45
+ *.log
46
+ npm-debug.log*
47
+ yarn-debug.log*
48
+ yarn-error.log*
49
+ lerna-debug.log*
50
+ .pnpm-debug.log*
51
+
52
+ # Diagnostic reports (https://nodejs.org/api/report.html)
53
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
54
+
55
+ # Runtime data
56
+ pids
57
+ *.pid
58
+ *.seed
59
+ *.pid.lock
60
+
61
+ # Directory for instrumented libs generated by jscoverage/JSCover
62
+ lib-cov
63
+
64
+ # Coverage directory used by tools like istanbul
65
+ coverage
66
+ *.lcov
67
+
68
+ # nyc test coverage
69
+ .nyc_output
70
+
71
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
72
+ .grunt
73
+
74
+ # Bower dependency directory (https://bower.io/)
75
+ bower_components
76
+
77
+ # node-waf configuration
78
+ .lock-wscript
79
+
80
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
81
+ build/Release
82
+
83
+ # Dependency directories
84
+ node_modules/
85
+ jspm_packages/
86
+
87
+ # Snowpack dependency directory (https://snowpack.dev/)
88
+ web_modules/
89
+
90
+ # TypeScript cache
91
+ *.tsbuildinfo
92
+
93
+ # Optional npm cache directory
94
+ .npm
95
+
96
+ # Optional eslint cache
97
+ .eslintcache
98
+
99
+ # Optional stylelint cache
100
+ .stylelintcache
101
+
102
+ # Microbundle cache
103
+ .rpt2_cache/
104
+ .rts2_cache_cjs/
105
+ .rts2_cache_es/
106
+ .rts2_cache_umd/
107
+
108
+ # Optional REPL history
109
+ .node_repl_history
110
+
111
+ # Output of 'npm pack'
112
+ *.tgz
113
+
114
+ # Yarn Integrity file
115
+ .yarn-integrity
116
+
117
+ # dotenv environment variable files
118
+ .env
119
+ .env.development.local
120
+ .env.test.local
121
+ .env.production.local
122
+ .env.local
123
+
124
+ # yarn v2
125
+ .yarn/cache
126
+ .yarn/unplugged
127
+ .yarn/build-state.yml
128
+ .yarn/install-state.gz
129
+ .pnp.*
130
+
131
+ ### NanoForge template
132
+ # Compilation directories
133
+ .nanoforge/client
134
+ .nanoforge/server
@@ -59,6 +59,11 @@
59
59
  "type": "boolean",
60
60
  "description": "Add editor dependencies",
61
61
  "default": false
62
+ },
63
+ "initFunctions": {
64
+ "type": "boolean",
65
+ "description": "Add init functions to the application",
66
+ "default": false
62
67
  }
63
68
  },
64
69
  "required": ["name"]
@@ -1,27 +1,27 @@
1
- import { Rule } from '@angular-devkit/schematics';
1
+ import { Rule } from "@angular-devkit/schematics";
2
2
 
3
+ //#region src/libs/component/component.schema.d.ts
3
4
  interface ComponentSchema {
4
5
  /**
5
6
  * Component destination directory
6
7
  */
7
8
  name: string;
8
-
9
9
  /**
10
10
  * Component destination directory
11
11
  */
12
12
  directory: string;
13
-
14
13
  /**
15
14
  * The part of the application to generate
16
15
  */
17
16
  part: "client" | "server";
18
-
19
17
  /**
20
18
  * NanoForge Application language
21
19
  */
22
20
  language: "js" | "ts";
23
21
  }
24
-
22
+ //#endregion
23
+ //#region src/libs/component/component.factory.d.ts
25
24
  declare const main: (schema: ComponentSchema) => Rule;
26
-
25
+ //#endregion
27
26
  export { main };
27
+ //# sourceMappingURL=component.factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.factory.d.ts","names":["name","directory","part","language"],"sources":["../../../src/libs/component/component.schema.d.ts","../../../src/libs/component/component.factory.ts"],"mappings":";;;UAAiB,eAAA;;;AAAjB;EAIEA,IAAAA;EAJ8B;;;EAS9BC,SAAAA;EAUQ;AAAA;;EALRC,IAAAA;ECsBF;;;EDjBEC,QAAAA;AAAAA;;;cCiBW,IAAA,GAAQ,MAAA,EAAQ,eAAA,KAAkB,IAI9C"}
@@ -1,50 +1,35 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // src/libs/component/component.factory.ts
5
1
  import { join, normalize, strings } from "@angular-devkit/core";
6
- import {
7
- apply,
8
- mergeWith,
9
- move,
10
- template,
11
- url
12
- } from "@angular-devkit/schematics";
13
-
14
- // src/utils/formatting.ts
15
- var toWords = /* @__PURE__ */ __name((str) => {
16
- return str.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/[-_]+/g, " ").trim().split(/\s+/).filter(Boolean);
17
- }, "toWords");
18
- var toKebabCase = /* @__PURE__ */ __name((str) => {
19
- return toWords(str).map((word) => word.toLowerCase()).join("-");
20
- }, "toKebabCase");
21
- var toPascalCase = /* @__PURE__ */ __name((str) => {
22
- return toWords(str).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
23
- }, "toPascalCase");
24
-
25
- // src/libs/component/component.factory.ts
26
- var transform = /* @__PURE__ */ __name((schema) => {
27
- return {
28
- part: schema.part,
29
- className: toPascalCase(schema.name),
30
- fileName: toKebabCase(schema.name)
31
- };
32
- }, "transform");
33
- var generate = /* @__PURE__ */ __name((options, path, language) => {
34
- const rules = [
35
- template({
36
- ...strings,
37
- ...options
38
- }),
39
- move(normalize(path))
40
- ];
41
- return apply(url(join("./files", language)), rules);
42
- }, "generate");
43
- var main = /* @__PURE__ */ __name((schema) => {
44
- const options = transform(schema);
45
- return mergeWith(generate(options, schema.directory, schema.language));
46
- }, "main");
47
- export {
48
- main
2
+ import { apply, mergeWith, move, template, url } from "@angular-devkit/schematics";
3
+ //#region src/utils/formatting.ts
4
+ const toWords = (str) => {
5
+ return str.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/[-_]+/g, " ").trim().split(/\s+/).filter(Boolean);
6
+ };
7
+ const toKebabCase = (str) => {
8
+ return toWords(str).map((word) => word.toLowerCase()).join("-");
9
+ };
10
+ const toPascalCase = (str) => {
11
+ return toWords(str).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
49
12
  };
13
+ //#endregion
14
+ //#region src/libs/component/component.factory.ts
15
+ const transform = (schema) => {
16
+ return {
17
+ part: schema.part,
18
+ className: toPascalCase(schema.name),
19
+ fileName: toKebabCase(schema.name)
20
+ };
21
+ };
22
+ const generate = (options, path, language) => {
23
+ const rules = [template({
24
+ ...strings,
25
+ ...options
26
+ }), move(normalize(path))];
27
+ return apply(url(join("./files", language)), rules);
28
+ };
29
+ const main = (schema) => {
30
+ return mergeWith(generate(transform(schema), schema.directory, schema.language));
31
+ };
32
+ //#endregion
33
+ export { main };
34
+
50
35
  //# sourceMappingURL=component.factory.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/libs/component/component.factory.ts","../../../src/utils/formatting.ts"],"sourcesContent":["import { type Path, join, normalize, strings } from \"@angular-devkit/core\";\nimport {\n type Rule,\n type Source,\n apply,\n mergeWith,\n move,\n template,\n url,\n} from \"@angular-devkit/schematics\";\n\nimport { toKebabCase, toPascalCase } from \"@utils/formatting\";\n\nimport { type ComponentOptions } from \"./component.options\";\nimport { type ComponentSchema } from \"./component.schema\";\n\nconst transform = (schema: ComponentSchema): ComponentOptions => {\n return {\n part: schema.part,\n className: toPascalCase(schema.name),\n fileName: toKebabCase(schema.name),\n };\n};\n\nconst generate = (options: ComponentOptions, path: string, language: \"ts\" | \"js\"): Source => {\n const rules = [\n template({\n ...strings,\n ...options,\n }),\n move(normalize(path)),\n ];\n\n return apply(url(join(\"./files\" as Path, language)), rules);\n};\n\nexport const main = (schema: ComponentSchema): Rule => {\n const options = transform(schema);\n\n return mergeWith(generate(options, schema.directory, schema.language));\n};\n","const toWords = (str: string): string[] => {\n return str\n .replace(/([a-z])([A-Z])/g, \"$1 $2\")\n .replace(/([A-Z]+)([A-Z][a-z])/g, \"$1 $2\")\n .replace(/[-_]+/g, \" \")\n .trim()\n .split(/\\s+/)\n .filter(Boolean);\n};\n\nexport const toKebabCase = (str: string): string => {\n return toWords(str)\n .map((word) => word.toLowerCase())\n .join(\"-\");\n};\n\nexport const toPascalCase = (str: string): string => {\n return toWords(str)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\"\");\n};\n\nexport const toCamelCase = (str: string): string => {\n const words = toWords(str);\n return words\n .map((word, i) =>\n i === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(),\n )\n .join(\"\");\n};\n"],"mappings":";;;;AAAA,SAAoB,MAAM,WAAW,eAAe;AACpD;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACTP,IAAM,UAAU,wBAAC,QAA0B;AACzC,SAAO,IACJ,QAAQ,mBAAmB,OAAO,EAClC,QAAQ,yBAAyB,OAAO,EACxC,QAAQ,UAAU,GAAG,EACrB,KAAK,EACL,MAAM,KAAK,EACX,OAAO,OAAO;AACnB,GARgB;AAUT,IAAM,cAAc,wBAAC,QAAwB;AAClD,SAAO,QAAQ,GAAG,EACf,IAAI,CAAC,SAAS,KAAK,YAAY,CAAC,EAChC,KAAK,GAAG;AACb,GAJ2B;AAMpB,IAAM,eAAe,wBAAC,QAAwB;AACnD,SAAO,QAAQ,GAAG,EACf,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY,CAAC,EACxE,KAAK,EAAE;AACZ,GAJ4B;;;ADA5B,IAAM,YAAY,wBAAC,WAA8C;AAC/D,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,WAAW,aAAa,OAAO,IAAI;AAAA,IACnC,UAAU,YAAY,OAAO,IAAI;AAAA,EACnC;AACF,GANkB;AAQlB,IAAM,WAAW,wBAAC,SAA2B,MAAc,aAAkC;AAC3F,QAAM,QAAQ;AAAA,IACZ,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,IACL,CAAC;AAAA,IACD,KAAK,UAAU,IAAI,CAAC;AAAA,EACtB;AAEA,SAAO,MAAM,IAAI,KAAK,WAAmB,QAAQ,CAAC,GAAG,KAAK;AAC5D,GAViB;AAYV,IAAM,OAAO,wBAAC,WAAkC;AACrD,QAAM,UAAU,UAAU,MAAM;AAEhC,SAAO,UAAU,SAAS,SAAS,OAAO,WAAW,OAAO,QAAQ,CAAC;AACvE,GAJoB;","names":[]}
1
+ {"version":3,"file":"component.factory.js","names":[],"sources":["../../../src/utils/formatting.ts","../../../src/libs/component/component.factory.ts"],"sourcesContent":["const toWords = (str: string): string[] => {\n return str\n .replace(/([a-z])([A-Z])/g, \"$1 $2\")\n .replace(/([A-Z]+)([A-Z][a-z])/g, \"$1 $2\")\n .replace(/[-_]+/g, \" \")\n .trim()\n .split(/\\s+/)\n .filter(Boolean);\n};\n\nexport const toKebabCase = (str: string): string => {\n return toWords(str)\n .map((word) => word.toLowerCase())\n .join(\"-\");\n};\n\nexport const toPascalCase = (str: string): string => {\n return toWords(str)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\"\");\n};\n\nexport const toCamelCase = (str: string): string => {\n const words = toWords(str);\n return words\n .map((word, i) =>\n i === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(),\n )\n .join(\"\");\n};\n","import { type Path, join, normalize, strings } from \"@angular-devkit/core\";\nimport {\n type Rule,\n type Source,\n apply,\n mergeWith,\n move,\n template,\n url,\n} from \"@angular-devkit/schematics\";\n\nimport { toKebabCase, toPascalCase } from \"@utils/formatting\";\n\nimport { type ComponentOptions } from \"./component.options\";\nimport { type ComponentSchema } from \"./component.schema\";\n\nconst transform = (schema: ComponentSchema): ComponentOptions => {\n return {\n part: schema.part,\n className: toPascalCase(schema.name),\n fileName: toKebabCase(schema.name),\n };\n};\n\nconst generate = (options: ComponentOptions, path: string, language: \"ts\" | \"js\"): Source => {\n const rules = [\n template({\n ...strings,\n ...options,\n }),\n move(normalize(path)),\n ];\n\n return apply(url(join(\"./files\" as Path, language)), rules);\n};\n\nexport const main = (schema: ComponentSchema): Rule => {\n const options = transform(schema);\n\n return mergeWith(generate(options, schema.directory, schema.language));\n};\n"],"mappings":";;;AAAA,MAAM,WAAW,QAA0B;CACzC,OAAO,IACJ,QAAQ,mBAAmB,OAAO,EAClC,QAAQ,yBAAyB,OAAO,EACxC,QAAQ,UAAU,GAAG,EACrB,KAAK,EACL,MAAM,KAAK,EACX,OAAO,OAAO;AACnB;AAEA,MAAa,eAAe,QAAwB;CAClD,OAAO,QAAQ,GAAG,EACf,KAAK,SAAS,KAAK,YAAY,CAAC,EAChC,KAAK,GAAG;AACb;AAEA,MAAa,gBAAgB,QAAwB;CACnD,OAAO,QAAQ,GAAG,EACf,KAAK,SAAS,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY,CAAC,EACxE,KAAK,EAAE;AACZ;;;ACJA,MAAM,aAAa,WAA8C;CAC/D,OAAO;EACL,MAAM,OAAO;EACb,WAAW,aAAa,OAAO,IAAI;EACnC,UAAU,YAAY,OAAO,IAAI;CACnC;AACF;AAEA,MAAM,YAAY,SAA2B,MAAc,aAAkC;CAC3F,MAAM,QAAQ,CACZ,SAAS;EACP,GAAG;EACH,GAAG;CACL,CAAC,GACD,KAAK,UAAU,IAAI,CAAC,CACtB;CAEA,OAAO,MAAM,IAAI,KAAK,WAAmB,QAAQ,CAAC,GAAG,KAAK;AAC5D;AAEA,MAAa,QAAQ,WAAkC;CAGrD,OAAO,UAAU,SAFD,UAAU,MAEA,GAAS,OAAO,WAAW,OAAO,QAAQ,CAAC;AACvE"}
@@ -47,32 +47,26 @@ export const EDITOR_COMPONENT_MANIFEST = {
47
47
  name: "<%= className %>",
48
48
  description: "<%= className %> component description",
49
49
  params: [
50
- [
51
- {
52
- type: "string",
53
- name: "paramA",
54
- description: "Param A description",
55
- example: "Example value",
56
- },
57
- ],
58
- [
59
- {
60
- type: "number",
61
- name: "paramB",
62
- description: "Param B description",
63
- example: 3,
64
- },
65
- ],
66
- [
67
- {
68
- type: "boolean",
69
- name: "paramC",
70
- description: "Param C description",
71
- example: true,
72
- default: false,
73
- // Not required because it has a default value
74
- optional: true,
75
- },
76
- ],
50
+ {
51
+ type: "string",
52
+ name: "paramA",
53
+ description: "Param A description",
54
+ example: "Example value",
55
+ },
56
+ {
57
+ type: "number",
58
+ name: "paramB",
59
+ description: "Param B description",
60
+ example: 3,
61
+ },
62
+ {
63
+ type: "boolean",
64
+ name: "paramC",
65
+ description: "Param C description",
66
+ example: true,
67
+ default: false,
68
+ // Not required because it has a default value
69
+ optional: true,
70
+ },
77
71
  ],
78
72
  };