@nanoforge-dev/schematics 1.2.2 → 2.1.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.
Files changed (51) hide show
  1. package/dist/collection.json +10 -0
  2. package/dist/index.cjs +2 -34
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +1 -26
  5. package/dist/index.d.ts +1 -26
  6. package/dist/index.js +1 -30
  7. package/dist/index.js.map +1 -1
  8. package/dist/libs/application/application.factory.d.ts +5 -0
  9. package/dist/libs/application/application.factory.js +6 -2
  10. package/dist/libs/application/application.factory.js.map +1 -1
  11. package/dist/libs/application/files/js/package.json.template +2 -1
  12. package/dist/libs/application/files/ts/package.json.template +2 -1
  13. package/dist/libs/application/schema.json +6 -5
  14. package/dist/libs/component/component.factory.d.ts +27 -0
  15. package/dist/libs/component/component.factory.js +50 -0
  16. package/dist/libs/component/component.factory.js.map +1 -0
  17. package/dist/libs/component/files/js/__fileName__.component.js +78 -0
  18. package/dist/libs/component/files/ts/__fileName__.component.ts +61 -0
  19. package/dist/libs/component/schema.json +30 -0
  20. package/dist/libs/configuration/configuration.factory.d.ts +8 -3
  21. package/dist/libs/configuration/configuration.factory.js +32 -49
  22. package/dist/libs/configuration/configuration.factory.js.map +1 -1
  23. package/dist/libs/configuration/schema.json +9 -8
  24. package/dist/libs/docker/docker.factory.d.ts +2 -7
  25. package/dist/libs/docker/docker.factory.js +2 -24
  26. package/dist/libs/docker/docker.factory.js.map +1 -1
  27. package/dist/libs/docker/files/.dockerignore +1 -1
  28. package/dist/libs/docker/files/Dockerfile +10 -24
  29. package/dist/libs/docker/schema.json +4 -13
  30. package/dist/libs/part-base/files/js/__nanoforgeFolder__/client.save.json +1 -1
  31. package/dist/libs/part-base/files/js/__nanoforgeFolder__/server.save.json +1 -1
  32. package/dist/libs/part-base/files/js/__part__/components/example.component.js +29 -23
  33. package/dist/libs/part-base/files/js/__part__/systems/example.system.js +1 -1
  34. package/dist/libs/part-base/files/ts/__nanoforgeFolder__/client.save.json +1 -1
  35. package/dist/libs/part-base/files/ts/__nanoforgeFolder__/server.save.json +1 -1
  36. package/dist/libs/part-base/files/ts/__part__/components/example.component.ts +29 -23
  37. package/dist/libs/part-base/part-base.factory.d.ts +5 -10
  38. package/dist/libs/part-base/part-base.factory.js +6 -34
  39. package/dist/libs/part-base/part-base.factory.js.map +1 -1
  40. package/dist/libs/part-base/schema.json +4 -12
  41. package/dist/libs/part-main/part-main.factory.d.ts +14 -9
  42. package/dist/libs/part-main/part-main.factory.js +106 -63
  43. package/dist/libs/part-main/part-main.factory.js.map +1 -1
  44. package/dist/libs/part-main/schema.json +13 -12
  45. package/dist/libs/system/files/js/__fileName__.system.js +44 -0
  46. package/dist/libs/system/files/ts/__fileName__.system.ts +31 -0
  47. package/dist/libs/system/schema.json +30 -0
  48. package/dist/libs/system/system.factory.d.ts +27 -0
  49. package/dist/libs/system/system.factory.js +53 -0
  50. package/dist/libs/system/system.factory.js.map +1 -0
  51. package/package.json +1 -1
@@ -25,6 +25,16 @@
25
25
  "factory": "./libs/docker/docker.factory#main",
26
26
  "description": "Create a Dockerfile for the application.",
27
27
  "schema": "./libs/docker/schema.json"
28
+ },
29
+ "component": {
30
+ "factory": "./libs/component/component.factory#main",
31
+ "description": "Create a NanoForge component.",
32
+ "schema": "./libs/component/schema.json"
33
+ },
34
+ "system": {
35
+ "factory": "./libs/system/system.factory#main",
36
+ "description": "Create a NanoForge system.",
37
+ "schema": "./libs/system/schema.json"
28
38
  }
29
39
  }
30
40
  }
package/dist/index.cjs CHANGED
@@ -22,19 +22,13 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  DEFAULT_APP_NAME: () => DEFAULT_APP_NAME,
24
24
  DEFAULT_AUTHOR: () => DEFAULT_AUTHOR,
25
- DEFAULT_CONFIG: () => DEFAULT_CONFIG,
26
25
  DEFAULT_DESCRIPTION: () => DEFAULT_DESCRIPTION,
27
26
  DEFAULT_LANGUAGE: () => DEFAULT_LANGUAGE,
28
27
  DEFAULT_PACKAGE_MANAGER: () => DEFAULT_PACKAGE_MANAGER,
29
- DEFAULT_SERVER_CONFIG: () => DEFAULT_SERVER_CONFIG,
30
- DEFAULT_VERSION: () => DEFAULT_VERSION,
31
- test: () => test
28
+ DEFAULT_VERSION: () => DEFAULT_VERSION
32
29
  });
33
30
  module.exports = __toCommonJS(index_exports);
34
31
 
35
- // src/utils/index.ts
36
- var test = 0;
37
-
38
32
  // src/defaults.ts
39
33
  var DEFAULT_APP_NAME = "nanoforge-app";
40
34
  var DEFAULT_VERSION = "0.0.0";
@@ -42,39 +36,13 @@ var DEFAULT_AUTHOR = "";
42
36
  var DEFAULT_DESCRIPTION = "";
43
37
  var DEFAULT_LANGUAGE = "ts";
44
38
  var DEFAULT_PACKAGE_MANAGER = "npm";
45
- var DEFAULT_CONFIG = {
46
- client: {
47
- build: {
48
- entryFile: "client/main.ts",
49
- outDir: ".nanoforge/client"
50
- },
51
- runtime: {
52
- dir: ".nanoforge/client"
53
- }
54
- }
55
- };
56
- var DEFAULT_SERVER_CONFIG = {
57
- server: {
58
- enable: true,
59
- build: {
60
- entryFile: "server/main.ts",
61
- outDir: ".nanoforge/server"
62
- },
63
- runtime: {
64
- dir: ".nanoforge/server"
65
- }
66
- }
67
- };
68
39
  // Annotate the CommonJS export names for ESM import in node:
69
40
  0 && (module.exports = {
70
41
  DEFAULT_APP_NAME,
71
42
  DEFAULT_AUTHOR,
72
- DEFAULT_CONFIG,
73
43
  DEFAULT_DESCRIPTION,
74
44
  DEFAULT_LANGUAGE,
75
45
  DEFAULT_PACKAGE_MANAGER,
76
- DEFAULT_SERVER_CONFIG,
77
- DEFAULT_VERSION,
78
- test
46
+ DEFAULT_VERSION
79
47
  });
80
48
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils/index.ts","../src/defaults.ts"],"sourcesContent":["export * from \"./utils\";\nexport * from \"./defaults\";\n","export const test = 0;\n","export const DEFAULT_APP_NAME = \"nanoforge-app\";\nexport const DEFAULT_VERSION = \"0.0.0\";\nexport const DEFAULT_AUTHOR = \"\";\nexport const DEFAULT_DESCRIPTION = \"\";\nexport const DEFAULT_LANGUAGE = \"ts\";\nexport const DEFAULT_PACKAGE_MANAGER = \"npm\";\nexport const DEFAULT_CONFIG = {\n client: {\n build: {\n entryFile: \"client/main.ts\",\n outDir: \".nanoforge/client\",\n },\n runtime: {\n dir: \".nanoforge/client\",\n },\n },\n};\nexport const DEFAULT_SERVER_CONFIG = {\n server: {\n enable: true,\n build: {\n entryFile: \"server/main.ts\",\n outDir: \".nanoforge/server\",\n },\n runtime: {\n dir: \".nanoforge/server\",\n },\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,OAAO;;;ACAb,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AACxB,IAAM,iBAAiB;AACvB,IAAM,sBAAsB;AAC5B,IAAM,mBAAmB;AACzB,IAAM,0BAA0B;AAChC,IAAM,iBAAiB;AAAA,EAC5B,QAAQ;AAAA,IACN,OAAO;AAAA,MACL,WAAW;AAAA,MACX,QAAQ;AAAA,IACV;AAAA,IACA,SAAS;AAAA,MACP,KAAK;AAAA,IACP;AAAA,EACF;AACF;AACO,IAAM,wBAAwB;AAAA,EACnC,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,MACL,WAAW;AAAA,MACX,QAAQ;AAAA,IACV;AAAA,IACA,SAAS;AAAA,MACP,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/defaults.ts"],"sourcesContent":["export * from \"./defaults\";\n","export const DEFAULT_APP_NAME = \"nanoforge-app\";\nexport const DEFAULT_VERSION = \"0.0.0\";\nexport const DEFAULT_AUTHOR = \"\";\nexport const DEFAULT_DESCRIPTION = \"\";\nexport const DEFAULT_LANGUAGE = \"ts\";\nexport const DEFAULT_PACKAGE_MANAGER = \"npm\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AACxB,IAAM,iBAAiB;AACvB,IAAM,sBAAsB;AAC5B,IAAM,mBAAmB;AACzB,IAAM,0BAA0B;","names":[]}
package/dist/index.d.cts CHANGED
@@ -1,33 +1,8 @@
1
- declare const test = 0;
2
-
3
1
  declare const DEFAULT_APP_NAME = "nanoforge-app";
4
2
  declare const DEFAULT_VERSION = "0.0.0";
5
3
  declare const DEFAULT_AUTHOR = "";
6
4
  declare const DEFAULT_DESCRIPTION = "";
7
5
  declare const DEFAULT_LANGUAGE = "ts";
8
6
  declare const DEFAULT_PACKAGE_MANAGER = "npm";
9
- declare const DEFAULT_CONFIG: {
10
- client: {
11
- build: {
12
- entryFile: string;
13
- outDir: string;
14
- };
15
- runtime: {
16
- dir: string;
17
- };
18
- };
19
- };
20
- declare const DEFAULT_SERVER_CONFIG: {
21
- server: {
22
- enable: boolean;
23
- build: {
24
- entryFile: string;
25
- outDir: string;
26
- };
27
- runtime: {
28
- dir: string;
29
- };
30
- };
31
- };
32
7
 
33
- export { DEFAULT_APP_NAME, DEFAULT_AUTHOR, DEFAULT_CONFIG, DEFAULT_DESCRIPTION, DEFAULT_LANGUAGE, DEFAULT_PACKAGE_MANAGER, DEFAULT_SERVER_CONFIG, DEFAULT_VERSION, test };
8
+ export { DEFAULT_APP_NAME, DEFAULT_AUTHOR, DEFAULT_DESCRIPTION, DEFAULT_LANGUAGE, DEFAULT_PACKAGE_MANAGER, DEFAULT_VERSION };
package/dist/index.d.ts CHANGED
@@ -1,33 +1,8 @@
1
- declare const test = 0;
2
-
3
1
  declare const DEFAULT_APP_NAME = "nanoforge-app";
4
2
  declare const DEFAULT_VERSION = "0.0.0";
5
3
  declare const DEFAULT_AUTHOR = "";
6
4
  declare const DEFAULT_DESCRIPTION = "";
7
5
  declare const DEFAULT_LANGUAGE = "ts";
8
6
  declare const DEFAULT_PACKAGE_MANAGER = "npm";
9
- declare const DEFAULT_CONFIG: {
10
- client: {
11
- build: {
12
- entryFile: string;
13
- outDir: string;
14
- };
15
- runtime: {
16
- dir: string;
17
- };
18
- };
19
- };
20
- declare const DEFAULT_SERVER_CONFIG: {
21
- server: {
22
- enable: boolean;
23
- build: {
24
- entryFile: string;
25
- outDir: string;
26
- };
27
- runtime: {
28
- dir: string;
29
- };
30
- };
31
- };
32
7
 
33
- export { DEFAULT_APP_NAME, DEFAULT_AUTHOR, DEFAULT_CONFIG, DEFAULT_DESCRIPTION, DEFAULT_LANGUAGE, DEFAULT_PACKAGE_MANAGER, DEFAULT_SERVER_CONFIG, DEFAULT_VERSION, test };
8
+ export { DEFAULT_APP_NAME, DEFAULT_AUTHOR, DEFAULT_DESCRIPTION, DEFAULT_LANGUAGE, DEFAULT_PACKAGE_MANAGER, DEFAULT_VERSION };
package/dist/index.js CHANGED
@@ -1,6 +1,3 @@
1
- // src/utils/index.ts
2
- var test = 0;
3
-
4
1
  // src/defaults.ts
5
2
  var DEFAULT_APP_NAME = "nanoforge-app";
6
3
  var DEFAULT_VERSION = "0.0.0";
@@ -8,38 +5,12 @@ var DEFAULT_AUTHOR = "";
8
5
  var DEFAULT_DESCRIPTION = "";
9
6
  var DEFAULT_LANGUAGE = "ts";
10
7
  var DEFAULT_PACKAGE_MANAGER = "npm";
11
- var DEFAULT_CONFIG = {
12
- client: {
13
- build: {
14
- entryFile: "client/main.ts",
15
- outDir: ".nanoforge/client"
16
- },
17
- runtime: {
18
- dir: ".nanoforge/client"
19
- }
20
- }
21
- };
22
- var DEFAULT_SERVER_CONFIG = {
23
- server: {
24
- enable: true,
25
- build: {
26
- entryFile: "server/main.ts",
27
- outDir: ".nanoforge/server"
28
- },
29
- runtime: {
30
- dir: ".nanoforge/server"
31
- }
32
- }
33
- };
34
8
  export {
35
9
  DEFAULT_APP_NAME,
36
10
  DEFAULT_AUTHOR,
37
- DEFAULT_CONFIG,
38
11
  DEFAULT_DESCRIPTION,
39
12
  DEFAULT_LANGUAGE,
40
13
  DEFAULT_PACKAGE_MANAGER,
41
- DEFAULT_SERVER_CONFIG,
42
- DEFAULT_VERSION,
43
- test
14
+ DEFAULT_VERSION
44
15
  };
45
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/index.ts","../src/defaults.ts"],"sourcesContent":["export const test = 0;\n","export const DEFAULT_APP_NAME = \"nanoforge-app\";\nexport const DEFAULT_VERSION = \"0.0.0\";\nexport const DEFAULT_AUTHOR = \"\";\nexport const DEFAULT_DESCRIPTION = \"\";\nexport const DEFAULT_LANGUAGE = \"ts\";\nexport const DEFAULT_PACKAGE_MANAGER = \"npm\";\nexport const DEFAULT_CONFIG = {\n client: {\n build: {\n entryFile: \"client/main.ts\",\n outDir: \".nanoforge/client\",\n },\n runtime: {\n dir: \".nanoforge/client\",\n },\n },\n};\nexport const DEFAULT_SERVER_CONFIG = {\n server: {\n enable: true,\n build: {\n entryFile: \"server/main.ts\",\n outDir: \".nanoforge/server\",\n },\n runtime: {\n dir: \".nanoforge/server\",\n },\n },\n};\n"],"mappings":";AAAO,IAAM,OAAO;;;ACAb,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AACxB,IAAM,iBAAiB;AACvB,IAAM,sBAAsB;AAC5B,IAAM,mBAAmB;AACzB,IAAM,0BAA0B;AAChC,IAAM,iBAAiB;AAAA,EAC5B,QAAQ;AAAA,IACN,OAAO;AAAA,MACL,WAAW;AAAA,MACX,QAAQ;AAAA,IACV;AAAA,IACA,SAAS;AAAA,MACP,KAAK;AAAA,IACP;AAAA,EACF;AACF;AACO,IAAM,wBAAwB;AAAA,EACnC,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,MACL,WAAW;AAAA,MACX,QAAQ;AAAA,IACV;AAAA,IACA,SAAS;AAAA,MACP,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const DEFAULT_APP_NAME = \"nanoforge-app\";\nexport const DEFAULT_VERSION = \"0.0.0\";\nexport const DEFAULT_AUTHOR = \"\";\nexport const DEFAULT_DESCRIPTION = \"\";\nexport const DEFAULT_LANGUAGE = \"ts\";\nexport const DEFAULT_PACKAGE_MANAGER = \"npm\";\n"],"mappings":";AAAO,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AACxB,IAAM,iBAAiB;AACvB,IAAM,sBAAsB;AAC5B,IAAM,mBAAmB;AACzB,IAAM,0BAA0B;","names":[]}
@@ -50,6 +50,11 @@ interface ApplicationSchema {
50
50
  * Configure a server for the application
51
51
  */
52
52
  server?: boolean;
53
+
54
+ /**
55
+ * Add editor dependencies
56
+ */
57
+ editor: boolean;
53
58
  }
54
59
 
55
60
  declare const main: (schema: ApplicationSchema) => Rule;
@@ -14,8 +14,11 @@ import {
14
14
  import { firstValueFrom } from "rxjs";
15
15
 
16
16
  // src/utils/formatting.ts
17
+ var toWords = /* @__PURE__ */ __name((str) => {
18
+ 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);
19
+ }, "toWords");
17
20
  var toKebabCase = /* @__PURE__ */ __name((str) => {
18
- return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
21
+ return toWords(str).map((word) => word.toLowerCase()).join("-");
19
22
  }, "toKebabCase");
20
23
 
21
24
  // src/utils/name.ts
@@ -51,7 +54,8 @@ var transform = /* @__PURE__ */ __name((schema) => {
51
54
  strict: schema.strict ?? true,
52
55
  lint: schema.lint ?? true,
53
56
  packageManager: schema.packageManager ?? DEFAULT_PACKAGE_MANAGER,
54
- server: schema.server ?? false
57
+ server: schema.server ?? false,
58
+ editor: schema.editor ?? false
55
59
  };
56
60
  }, "transform");
57
61
  var generate = /* @__PURE__ */ __name((options, path) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/libs/application/application.factory.ts","../../../src/utils/formatting.ts","../../../src/utils/name.ts","../../../src/defaults.ts"],"sourcesContent":["import { type Path, join, normalize, strings } from \"@angular-devkit/core\";\nimport {\n type Rule,\n type SchematicContext,\n type Source,\n type Tree,\n apply,\n mergeWith,\n move,\n renameTemplateFiles,\n template,\n url,\n} from \"@angular-devkit/schematics\";\nimport { firstValueFrom } from \"rxjs\";\n\nimport { toKebabCase } from \"@utils/formatting\";\nimport { resolvePackageName } from \"@utils/name\";\n\nimport {\n DEFAULT_APP_NAME,\n DEFAULT_AUTHOR,\n DEFAULT_DESCRIPTION,\n DEFAULT_LANGUAGE,\n DEFAULT_PACKAGE_MANAGER,\n DEFAULT_VERSION,\n} from \"~/defaults\";\n\nimport { type ApplicationOptions } from \"./application.options\";\nimport { type ApplicationSchema } from \"./application.schema\";\n\nconst transform = (schema: ApplicationSchema): ApplicationOptions => {\n const name = resolvePackageName(toKebabCase(schema.name?.toString() ?? DEFAULT_APP_NAME));\n\n return {\n name,\n version: schema.version ?? DEFAULT_VERSION,\n author: schema.author ?? DEFAULT_AUTHOR,\n description: schema.description ?? DEFAULT_DESCRIPTION,\n language: schema.language ?? DEFAULT_LANGUAGE,\n strict: schema.strict ?? true,\n lint: schema.lint ?? true,\n packageManager: schema.packageManager ?? DEFAULT_PACKAGE_MANAGER,\n server: schema.server ?? false,\n };\n};\n\nconst generate = (options: ApplicationOptions, path: string): Source => {\n return apply(url(join(\"./files\" as Path, options.language)), [\n template({\n ...strings,\n ...options,\n }),\n renameTemplateFiles(),\n move(normalize(path)),\n ]);\n};\n\nexport const main = (schema: ApplicationSchema): Rule => {\n const options = transform(schema);\n const path = schema.directory ?? options.name;\n\n return async (baseTree: Tree, context: SchematicContext) => {\n let tree = await mergeWith(generate(options, path))(baseTree, context);\n if (!tree) return tree;\n if (!(\"delete\" in tree)) {\n if (typeof tree === \"function\") return tree;\n tree = await firstValueFrom(tree);\n }\n\n if (!options.lint) {\n const basePath = join(\"/\" as Path, path);\n tree.delete(join(basePath, \"eslint.config.js\"));\n tree.delete(join(basePath, \"prettier.config.js\"));\n tree.delete(join(basePath, \".prettierignore\"));\n if (options.language === \"js\") tree.delete(join(basePath, \"jsconfig.json\"));\n }\n\n return tree;\n };\n};\n","export const toKebabCase = (str: string): string => {\n return str\n .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, \"$1-$2\")\n .replace(/[\\s_]+/g, \"-\")\n .toLowerCase();\n};\n","import { basename, parse } from \"path\";\n\nexport const resolvePackageName = (path: string): string => {\n const { base: baseFilename, dir: dirname } = parse(path);\n if (baseFilename === \".\") {\n return basename(process.cwd());\n }\n if (dirname.match(/^@[^\\s]/)) {\n return `${dirname}/${baseFilename}`;\n }\n return baseFilename;\n};\n","export const DEFAULT_APP_NAME = \"nanoforge-app\";\nexport const DEFAULT_VERSION = \"0.0.0\";\nexport const DEFAULT_AUTHOR = \"\";\nexport const DEFAULT_DESCRIPTION = \"\";\nexport const DEFAULT_LANGUAGE = \"ts\";\nexport const DEFAULT_PACKAGE_MANAGER = \"npm\";\nexport const DEFAULT_CONFIG = {\n client: {\n build: {\n entryFile: \"client/main.ts\",\n outDir: \".nanoforge/client\",\n },\n runtime: {\n dir: \".nanoforge/client\",\n },\n },\n};\nexport const DEFAULT_SERVER_CONFIG = {\n server: {\n enable: true,\n build: {\n entryFile: \"server/main.ts\",\n outDir: \".nanoforge/server\",\n },\n runtime: {\n dir: \".nanoforge/server\",\n },\n },\n};\n"],"mappings":";;;;AAAA,SAAoB,MAAM,WAAW,eAAe;AACpD;AAAA,EAKE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;;;ACbxB,IAAM,cAAc,wBAAC,QAAwB;AAClD,SAAO,IACJ,QAAQ,gCAAgC,OAAO,EAC/C,QAAQ,WAAW,GAAG,EACtB,YAAY;AACjB,GAL2B;;;ACA3B,SAAS,UAAU,aAAa;AAEzB,IAAM,qBAAqB,wBAAC,SAAyB;AAC1D,QAAM,EAAE,MAAM,cAAc,KAAK,QAAQ,IAAI,MAAM,IAAI;AACvD,MAAI,iBAAiB,KAAK;AACxB,WAAO,SAAS,QAAQ,IAAI,CAAC;AAAA,EAC/B;AACA,MAAI,QAAQ,MAAM,SAAS,GAAG;AAC5B,WAAO,GAAG,OAAO,IAAI,YAAY;AAAA,EACnC;AACA,SAAO;AACT,GATkC;;;ACF3B,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AACxB,IAAM,iBAAiB;AACvB,IAAM,sBAAsB;AAC5B,IAAM,mBAAmB;AACzB,IAAM,0BAA0B;;;AHyBvC,IAAM,YAAY,wBAAC,WAAkD;AACnE,QAAM,OAAO,mBAAmB,YAAY,OAAO,MAAM,SAAS,KAAK,gBAAgB,CAAC;AAExF,SAAO;AAAA,IACL;AAAA,IACA,SAAS,OAAO,WAAW;AAAA,IAC3B,QAAQ,OAAO,UAAU;AAAA,IACzB,aAAa,OAAO,eAAe;AAAA,IACnC,UAAU,OAAO,YAAY;AAAA,IAC7B,QAAQ,OAAO,UAAU;AAAA,IACzB,MAAM,OAAO,QAAQ;AAAA,IACrB,gBAAgB,OAAO,kBAAkB;AAAA,IACzC,QAAQ,OAAO,UAAU;AAAA,EAC3B;AACF,GAdkB;AAgBlB,IAAM,WAAW,wBAAC,SAA6B,SAAyB;AACtE,SAAO,MAAM,IAAI,KAAK,WAAmB,QAAQ,QAAQ,CAAC,GAAG;AAAA,IAC3D,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,IACL,CAAC;AAAA,IACD,oBAAoB;AAAA,IACpB,KAAK,UAAU,IAAI,CAAC;AAAA,EACtB,CAAC;AACH,GATiB;AAWV,IAAM,OAAO,wBAAC,WAAoC;AACvD,QAAM,UAAU,UAAU,MAAM;AAChC,QAAM,OAAO,OAAO,aAAa,QAAQ;AAEzC,SAAO,OAAO,UAAgB,YAA8B;AAC1D,QAAI,OAAO,MAAM,UAAU,SAAS,SAAS,IAAI,CAAC,EAAE,UAAU,OAAO;AACrE,QAAI,CAAC,KAAM,QAAO;AAClB,QAAI,EAAE,YAAY,OAAO;AACvB,UAAI,OAAO,SAAS,WAAY,QAAO;AACvC,aAAO,MAAM,eAAe,IAAI;AAAA,IAClC;AAEA,QAAI,CAAC,QAAQ,MAAM;AACjB,YAAM,WAAW,KAAK,KAAa,IAAI;AACvC,WAAK,OAAO,KAAK,UAAU,kBAAkB,CAAC;AAC9C,WAAK,OAAO,KAAK,UAAU,oBAAoB,CAAC;AAChD,WAAK,OAAO,KAAK,UAAU,iBAAiB,CAAC;AAC7C,UAAI,QAAQ,aAAa,KAAM,MAAK,OAAO,KAAK,UAAU,eAAe,CAAC;AAAA,IAC5E;AAEA,WAAO;AAAA,EACT;AACF,GAtBoB;","names":[]}
1
+ {"version":3,"sources":["../../../src/libs/application/application.factory.ts","../../../src/utils/formatting.ts","../../../src/utils/name.ts","../../../src/defaults.ts"],"sourcesContent":["import { type Path, join, normalize, strings } from \"@angular-devkit/core\";\nimport {\n type Rule,\n type SchematicContext,\n type Source,\n type Tree,\n apply,\n mergeWith,\n move,\n renameTemplateFiles,\n template,\n url,\n} from \"@angular-devkit/schematics\";\nimport { firstValueFrom } from \"rxjs\";\n\nimport { toKebabCase } from \"@utils/formatting\";\nimport { resolvePackageName } from \"@utils/name\";\n\nimport {\n DEFAULT_APP_NAME,\n DEFAULT_AUTHOR,\n DEFAULT_DESCRIPTION,\n DEFAULT_LANGUAGE,\n DEFAULT_PACKAGE_MANAGER,\n DEFAULT_VERSION,\n} from \"~/defaults\";\n\nimport { type ApplicationOptions } from \"./application.options\";\nimport { type ApplicationSchema } from \"./application.schema\";\n\nconst transform = (schema: ApplicationSchema): ApplicationOptions => {\n const name = resolvePackageName(toKebabCase(schema.name?.toString() ?? DEFAULT_APP_NAME));\n\n return {\n name,\n version: schema.version ?? DEFAULT_VERSION,\n author: schema.author ?? DEFAULT_AUTHOR,\n description: schema.description ?? DEFAULT_DESCRIPTION,\n language: schema.language ?? DEFAULT_LANGUAGE,\n strict: schema.strict ?? true,\n lint: schema.lint ?? true,\n packageManager: schema.packageManager ?? DEFAULT_PACKAGE_MANAGER,\n server: schema.server ?? false,\n editor: schema.editor ?? false,\n };\n};\n\nconst generate = (options: ApplicationOptions, path: string): Source => {\n return apply(url(join(\"./files\" as Path, options.language)), [\n template({\n ...strings,\n ...options,\n }),\n renameTemplateFiles(),\n move(normalize(path)),\n ]);\n};\n\nexport const main = (schema: ApplicationSchema): Rule => {\n const options = transform(schema);\n const path = schema.directory ?? options.name;\n\n return async (baseTree: Tree, context: SchematicContext) => {\n let tree = await mergeWith(generate(options, path))(baseTree, context);\n if (!tree) return tree;\n if (!(\"delete\" in tree)) {\n if (typeof tree === \"function\") return tree;\n tree = await firstValueFrom(tree);\n }\n\n if (!options.lint) {\n const basePath = join(\"/\" as Path, path);\n tree.delete(join(basePath, \"eslint.config.js\"));\n tree.delete(join(basePath, \"prettier.config.js\"));\n tree.delete(join(basePath, \".prettierignore\"));\n if (options.language === \"js\") tree.delete(join(basePath, \"jsconfig.json\"));\n }\n\n return tree;\n };\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","import { basename, parse } from \"path\";\n\nexport const resolvePackageName = (path: string): string => {\n const { base: baseFilename, dir: dirname } = parse(path);\n if (baseFilename === \".\") {\n return basename(process.cwd());\n }\n if (dirname.match(/^@[^\\s]/)) {\n return `${dirname}/${baseFilename}`;\n }\n return baseFilename;\n};\n","export const DEFAULT_APP_NAME = \"nanoforge-app\";\nexport const DEFAULT_VERSION = \"0.0.0\";\nexport const DEFAULT_AUTHOR = \"\";\nexport const DEFAULT_DESCRIPTION = \"\";\nexport const DEFAULT_LANGUAGE = \"ts\";\nexport const DEFAULT_PACKAGE_MANAGER = \"npm\";\n"],"mappings":";;;;AAAA,SAAoB,MAAM,WAAW,eAAe;AACpD;AAAA,EAKE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;;;ACb/B,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;;;ACV3B,SAAS,UAAU,aAAa;AAEzB,IAAM,qBAAqB,wBAAC,SAAyB;AAC1D,QAAM,EAAE,MAAM,cAAc,KAAK,QAAQ,IAAI,MAAM,IAAI;AACvD,MAAI,iBAAiB,KAAK;AACxB,WAAO,SAAS,QAAQ,IAAI,CAAC;AAAA,EAC/B;AACA,MAAI,QAAQ,MAAM,SAAS,GAAG;AAC5B,WAAO,GAAG,OAAO,IAAI,YAAY;AAAA,EACnC;AACA,SAAO;AACT,GATkC;;;ACF3B,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AACxB,IAAM,iBAAiB;AACvB,IAAM,sBAAsB;AAC5B,IAAM,mBAAmB;AACzB,IAAM,0BAA0B;;;AHyBvC,IAAM,YAAY,wBAAC,WAAkD;AACnE,QAAM,OAAO,mBAAmB,YAAY,OAAO,MAAM,SAAS,KAAK,gBAAgB,CAAC;AAExF,SAAO;AAAA,IACL;AAAA,IACA,SAAS,OAAO,WAAW;AAAA,IAC3B,QAAQ,OAAO,UAAU;AAAA,IACzB,aAAa,OAAO,eAAe;AAAA,IACnC,UAAU,OAAO,YAAY;AAAA,IAC7B,QAAQ,OAAO,UAAU;AAAA,IACzB,MAAM,OAAO,QAAQ;AAAA,IACrB,gBAAgB,OAAO,kBAAkB;AAAA,IACzC,QAAQ,OAAO,UAAU;AAAA,IACzB,QAAQ,OAAO,UAAU;AAAA,EAC3B;AACF,GAfkB;AAiBlB,IAAM,WAAW,wBAAC,SAA6B,SAAyB;AACtE,SAAO,MAAM,IAAI,KAAK,WAAmB,QAAQ,QAAQ,CAAC,GAAG;AAAA,IAC3D,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,IACL,CAAC;AAAA,IACD,oBAAoB;AAAA,IACpB,KAAK,UAAU,IAAI,CAAC;AAAA,EACtB,CAAC;AACH,GATiB;AAWV,IAAM,OAAO,wBAAC,WAAoC;AACvD,QAAM,UAAU,UAAU,MAAM;AAChC,QAAM,OAAO,OAAO,aAAa,QAAQ;AAEzC,SAAO,OAAO,UAAgB,YAA8B;AAC1D,QAAI,OAAO,MAAM,UAAU,SAAS,SAAS,IAAI,CAAC,EAAE,UAAU,OAAO;AACrE,QAAI,CAAC,KAAM,QAAO;AAClB,QAAI,EAAE,YAAY,OAAO;AACvB,UAAI,OAAO,SAAS,WAAY,QAAO;AACvC,aAAO,MAAM,eAAe,IAAI;AAAA,IAClC;AAEA,QAAI,CAAC,QAAQ,MAAM;AACjB,YAAM,WAAW,KAAK,KAAa,IAAI;AACvC,WAAK,OAAO,KAAK,UAAU,kBAAkB,CAAC;AAC9C,WAAK,OAAO,KAAK,UAAU,oBAAoB,CAAC;AAChD,WAAK,OAAO,KAAK,UAAU,iBAAiB,CAAC;AAC7C,UAAI,QAAQ,aAAa,KAAM,MAAK,OAAO,KAAK,UAAU,eAAe,CAAC;AAAA,IAC5E;AAEA,WAAO;AAAA,EACT;AACF,GAtBoB;","names":[]}
@@ -15,7 +15,8 @@
15
15
  "@nanoforge-dev/cli": "latest",
16
16
  "@nanoforge-dev/common": "^1",
17
17
  "@nanoforge-dev/config": "^1",
18
- "@nanoforge-dev/core": "^1",
18
+ "@nanoforge-dev/core": "^1",<% if (editor) { %>
19
+ "@nanoforge-dev/core-editor": "^1",<% } %>
19
20
  "@nanoforge-dev/ecs-client": "^1",<% if (server) { %>
20
21
  "@nanoforge-dev/ecs-server": "^1",<% } %>
21
22
  "@nanoforge-dev/graphics-2d": "^1",
@@ -15,7 +15,8 @@
15
15
  "@nanoforge-dev/cli": "latest",
16
16
  "@nanoforge-dev/common": "^1",
17
17
  "@nanoforge-dev/config": "^1",
18
- "@nanoforge-dev/core": "^1",
18
+ "@nanoforge-dev/core": "^1",<% if (editor) { %>
19
+ "@nanoforge-dev/core-editor": "^1",<% } %>
19
20
  "@nanoforge-dev/ecs-client": "^1",<% if (server) { %>
20
21
  "@nanoforge-dev/ecs-server": "^1",<% } %>
21
22
  "@nanoforge-dev/graphics-2d": "^1",
@@ -7,11 +7,7 @@
7
7
  "name": {
8
8
  "type": "string",
9
9
  "description": "The name of the application",
10
- "$default": {
11
- "$source": "argv",
12
- "index": 0
13
- },
14
- "x-prompt": "What name would you like to use for the new project ?"
10
+ "default": "nanoforge-app"
15
11
  },
16
12
  "version": {
17
13
  "type": "string",
@@ -58,6 +54,11 @@
58
54
  "type": "boolean",
59
55
  "description": "Configure a server for the application",
60
56
  "default": false
57
+ },
58
+ "editor": {
59
+ "type": "boolean",
60
+ "description": "Add editor dependencies",
61
+ "default": false
61
62
  }
62
63
  },
63
64
  "required": ["name"]
@@ -0,0 +1,27 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+
3
+ interface ComponentSchema {
4
+ /**
5
+ * Component destination directory
6
+ */
7
+ name: string;
8
+
9
+ /**
10
+ * Component destination directory
11
+ */
12
+ directory: string;
13
+
14
+ /**
15
+ * The part of the application to generate
16
+ */
17
+ part: "client" | "server";
18
+
19
+ /**
20
+ * NanoForge Application language
21
+ */
22
+ language: "js" | "ts";
23
+ }
24
+
25
+ declare const main: (schema: ComponentSchema) => Rule;
26
+
27
+ export { main };
@@ -0,0 +1,50 @@
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
+ 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
49
+ };
50
+ //# sourceMappingURL=component.factory.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @typedef {import("@nanoforge-dev/ecs-<%= part %>").EditorComponentManifest} EditorComponentManifest
3
+ */
4
+
5
+ export class <%= className %>Component {
6
+ static name = "<%= className %>Component";
7
+ name = this.constructor.name;
8
+
9
+ paramA;
10
+ paramB;
11
+ paramC;
12
+
13
+ /**
14
+ * <%= className %> component constructor
15
+ * @param {string} paramA
16
+ * @param {number} paramB
17
+ * @param {boolean} [paramC = false]
18
+ */
19
+ constructor(paramA, paramB, paramC = false) {
20
+ this.paramA = paramA;
21
+ this.paramB = paramB;
22
+ this.paramC = paramC;
23
+ }
24
+
25
+ get foo() {
26
+ return "bar";
27
+ }
28
+
29
+ get paramAOrDefault() {
30
+ return this.paramC ? this.paramA : "default";
31
+ }
32
+
33
+ addOne() {
34
+ this.paramB += 1;
35
+ }
36
+ }
37
+
38
+ // * Required to generate code
39
+ export default <%= className %>Component.name;
40
+
41
+ /**
42
+ * Editor component manifest
43
+ * * Required for the editor to display the component and generate code
44
+ * @type {EditorComponentManifest}
45
+ */
46
+ export const EDITOR_COMPONENT_MANIFEST = {
47
+ name: "<%= className %>",
48
+ description: "<%= className %> component description",
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
+ ],
77
+ ],
78
+ };
@@ -0,0 +1,61 @@
1
+ import { type EditorComponentManifest } from "@nanoforge-dev/ecs-<%= part %>";
2
+
3
+ export class <%= className %>Component {
4
+ name = this.constructor.name;
5
+
6
+ constructor(
7
+ public paramA: string,
8
+ public paramB: number,
9
+ public paramC: boolean = false,
10
+ ) {}
11
+
12
+ get foo() {
13
+ return "bar";
14
+ }
15
+
16
+ get paramAOrDefault() {
17
+ return this.paramC ? this.paramA : "default";
18
+ }
19
+
20
+ addOne() {
21
+ this.paramB += 1;
22
+ }
23
+ }
24
+
25
+ // * Required to generate code
26
+ export default <%= className %>Component.name;
27
+
28
+ // * Required for the editor to display the component and generate code
29
+ export const EDITOR_COMPONENT_MANIFEST: EditorComponentManifest = {
30
+ name: "<%= className %>",
31
+ description: "<%= className %> component description",
32
+ params: [
33
+ [
34
+ {
35
+ type: "string",
36
+ name: "paramA",
37
+ description: "Param A description",
38
+ example: "Example value",
39
+ },
40
+ ],
41
+ [
42
+ {
43
+ type: "number",
44
+ name: "paramB",
45
+ description: "Param B description",
46
+ example: 3,
47
+ },
48
+ ],
49
+ [
50
+ {
51
+ type: "boolean",
52
+ name: "paramC",
53
+ description: "Param C description",
54
+ example: true,
55
+ default: false,
56
+ // Not required because it has a default value
57
+ optional: true,
58
+ },
59
+ ],
60
+ ],
61
+ };
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "SchematicsNanoForgeComponent",
4
+ "title": "NanoForge Component Options Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "Component name",
10
+ "default": "example"
11
+ },
12
+ "directory": {
13
+ "type": "string",
14
+ "description": "Component destination directory",
15
+ "default": "."
16
+ },
17
+ "part": {
18
+ "type": "string",
19
+ "enum": ["client", "server"],
20
+ "description": "The part of the application to generate"
21
+ },
22
+ "language": {
23
+ "type": "string",
24
+ "enum": ["ts", "js"],
25
+ "description": "NanoForge application language",
26
+ "default": "ts"
27
+ }
28
+ },
29
+ "required": ["part"]
30
+ }
@@ -9,17 +9,22 @@ interface ConfigurationSchema {
9
9
  /**
10
10
  * NanoForge application destination directory
11
11
  */
12
- directory?: string;
12
+ directory: string;
13
13
 
14
14
  /**
15
15
  * Configure a server for the application
16
16
  */
17
- server?: boolean;
17
+ server: boolean;
18
18
 
19
19
  /**
20
20
  * NanoForge Application language
21
21
  */
22
- language?: "js" | "ts";
22
+ language: "js" | "ts";
23
+
24
+ /**
25
+ * Add init functions to the application
26
+ */
27
+ initFunctions: boolean;
23
28
  }
24
29
 
25
30
  declare const main: (schema: ConfigurationSchema) => Rule;