@nanoforge-dev/schematics 2.1.0 → 2.1.2

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.
@@ -13,27 +13,6 @@ import {
13
13
  } from "@angular-devkit/schematics";
14
14
  import { firstValueFrom } from "rxjs";
15
15
 
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");
20
- var toKebabCase = /* @__PURE__ */ __name((str) => {
21
- return toWords(str).map((word) => word.toLowerCase()).join("-");
22
- }, "toKebabCase");
23
-
24
- // src/utils/name.ts
25
- import { basename, parse } from "path";
26
- var resolvePackageName = /* @__PURE__ */ __name((path) => {
27
- const { base: baseFilename, dir: dirname } = parse(path);
28
- if (baseFilename === ".") {
29
- return basename(process.cwd());
30
- }
31
- if (dirname.match(/^@[^\s]/)) {
32
- return `${dirname}/${baseFilename}`;
33
- }
34
- return baseFilename;
35
- }, "resolvePackageName");
36
-
37
16
  // src/defaults.ts
38
17
  var DEFAULT_APP_NAME = "nanoforge-app";
39
18
  var DEFAULT_VERSION = "0.0.0";
@@ -44,9 +23,8 @@ var DEFAULT_PACKAGE_MANAGER = "npm";
44
23
 
45
24
  // src/libs/application/application.factory.ts
46
25
  var transform = /* @__PURE__ */ __name((schema) => {
47
- const name = resolvePackageName(toKebabCase(schema.name?.toString() ?? DEFAULT_APP_NAME));
48
26
  return {
49
- name,
27
+ name: schema.name ?? DEFAULT_APP_NAME,
50
28
  version: schema.version ?? DEFAULT_VERSION,
51
29
  author: schema.author ?? DEFAULT_AUTHOR,
52
30
  description: schema.description ?? DEFAULT_DESCRIPTION,
@@ -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 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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AAG;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/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 {\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 return {\n name: schema.name ?? DEFAULT_APP_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","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;;;ACbxB,IAAM,mBAAmB;AACzB,IAAM,k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,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":[]}
@@ -26,7 +26,7 @@
26
26
  "isolatedModules": true,
27
27
 
28
28
  "experimentalDecorators": true,
29
- "lib": ["ESNext", "esnext.disposable"],
29
+ "lib": ["ESNext", "esnext.disposable", "DOM"],
30
30
  "target": "ESNext",
31
31
  "useDefineForClassFields": true
32
32
  },
@@ -32,7 +32,7 @@
32
32
 
33
33
  // Language and Environment
34
34
  "experimentalDecorators": true,
35
- "lib": ["ESNext", "esnext.disposable"],
35
+ "lib": ["ESNext", "esnext.disposable", "DOM"],
36
36
  "target": "ESNext",
37
37
  "useDefineForClassFields": true,
38
38
  },
@@ -53,7 +53,8 @@
53
53
  "components": [
54
54
  {
55
55
  "name": "ExampleComponent",
56
- "path": "./components/example.component"
56
+ "path": "./components/example.component",
57
+ "paramsNames": ["paramA", "paramB", "paramC"]
57
58
  }
58
59
  ],
59
60
  "systems": [
@@ -65,12 +66,12 @@
65
66
  "entities": [
66
67
  {
67
68
  "id": "exampleEntity",
68
- "components": [
69
- {
70
- "name": "ExampleComponent",
71
- "paramsValues": ["example", 10]
69
+ "components": {
70
+ "ExampleComponent": {
71
+ "paramA": "example",
72
+ "paramB": 10
72
73
  }
73
- ]
74
+ }
74
75
  }
75
76
  ]
76
77
  }
@@ -25,7 +25,8 @@
25
25
  "components": [
26
26
  {
27
27
  "name": "ExampleComponent",
28
- "path": "./components/example.component"
28
+ "path": "./components/example.component",
29
+ "paramsNames": ["paramA", "paramB", "paramC"]
29
30
  }
30
31
  ],
31
32
  "systems": [
@@ -37,12 +38,12 @@
37
38
  "entities": [
38
39
  {
39
40
  "id": "exampleEntity",
40
- "components": [
41
- {
42
- "name": "ExampleComponent",
43
- "paramsValues": ["example", 10]
41
+ "components": {
42
+ "ExampleComponent": {
43
+ "paramA": "example",
44
+ "paramB": 10
44
45
  }
45
- ]
46
+ }
46
47
  }
47
48
  ]
48
49
  }
@@ -53,7 +53,8 @@
53
53
  "components": [
54
54
  {
55
55
  "name": "ExampleComponent",
56
- "path": "./components/example.component"
56
+ "path": "./components/example.component",
57
+ "paramsNames": ["paramA", "paramB", "paramC"]
57
58
  }
58
59
  ],
59
60
  "systems": [
@@ -65,12 +66,12 @@
65
66
  "entities": [
66
67
  {
67
68
  "id": "exampleEntity",
68
- "components": [
69
- {
70
- "name": "ExampleComponent",
71
- "paramsValues": ["example", 10]
69
+ "components": {
70
+ "ExampleComponent": {
71
+ "paramA": "example",
72
+ "paramB": 10
72
73
  }
73
- ]
74
+ }
74
75
  }
75
76
  ]
76
77
  }
@@ -25,7 +25,8 @@
25
25
  "components": [
26
26
  {
27
27
  "name": "ExampleComponent",
28
- "path": "./components/example.component"
28
+ "path": "./components/example.component",
29
+ "paramsNames": ["paramA", "paramB", "paramC"]
29
30
  }
30
31
  ],
31
32
  "systems": [
@@ -37,12 +38,12 @@
37
38
  "entities": [
38
39
  {
39
40
  "id": "exampleEntity",
40
- "components": [
41
- {
42
- "name": "ExampleComponent",
43
- "paramsValues": ["example", 10]
41
+ "components": {
42
+ "ExampleComponent": {
43
+ "paramA": "example",
44
+ "paramB": 10
44
45
  }
45
- ]
46
+ }
46
47
  }
47
48
  ]
48
49
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@nanoforge-dev/schematics",
4
- "version": "2.1.0",
4
+ "version": "2.1.2",
5
5
  "description": "NanoForge Schematics",
6
6
  "keywords": [
7
7
  "nanoforge",