frgen 0.2.7 → 0.2.9
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.
- package/README.md +64 -2
- package/lib/make_model.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
### Generator
|
|
2
|
+
|
|
3
|
+
#### Resource
|
|
4
|
+
- make:resource "className" "tableName"
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npx frgen make:resource UserResource users
|
|
8
|
+
```
|
|
9
|
+
- shema --schema=schemaName
|
|
10
|
+
```bash
|
|
11
|
+
npx frgen make:resource UserResource users --schema=other_schema
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
#### Controller
|
|
15
|
+
- make:controller "className" "tableName"
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx frgen make:controller UserController users --prisma
|
|
19
|
+
```
|
|
20
|
+
- shema --schema=schemaName
|
|
21
|
+
```bash
|
|
22
|
+
npx frgen make:controller UserController users --schema=other_schema --prisma
|
|
23
|
+
```
|
|
24
|
+
- path --path=/directory/.../target
|
|
25
|
+
```bash
|
|
26
|
+
npx frgen make:controller UserController users --path=/directory/.../target --prisma
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### Service
|
|
30
|
+
- make:service "ServiceName" "tableName"
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx frgen make:service UserService users --prisma
|
|
34
|
+
```
|
|
35
|
+
- shema --schema=schemaName
|
|
36
|
+
```bash
|
|
37
|
+
npx frgen make:service UserService users --schema=other_schema --prisma
|
|
38
|
+
```
|
|
39
|
+
- path --path=/directory/.../target
|
|
40
|
+
```bash
|
|
41
|
+
npx frgen make:service UserService users --path=/directory/.../target --prisma
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### Validation
|
|
45
|
+
- make:validation "ValidationName" "tableName"
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx frgen make:validation UserValidation users
|
|
49
|
+
```
|
|
50
|
+
- shema --schema=schemaName
|
|
51
|
+
```bash
|
|
52
|
+
npx frgen make:validation UserValidation users --schema=other_schema
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### ALL
|
|
56
|
+
- make:crud "className" "tableName"
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx frgen make:crud --prisma
|
|
60
|
+
```
|
|
61
|
+
- shema --schema=schemaName
|
|
62
|
+
```bash
|
|
63
|
+
npx frgen make:crud --schema=other_schema --prisma
|
|
64
|
+
```
|
|
2
65
|
|
|
3
|
-
Generator CRUD
|
package/lib/make_model.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),n=require("fs"),t=require("path"),r=require("./utils.js");function a(n){return Array.from(new Set(Object.entries(n).map((function(n){var t=e.slicedToArray(n,2);t[0];var a=t[1].relatedTable;return"import ".concat(r.capitalize(r.toCamelCase(r.removePluralSuffix(a)))," from './").concat(r.capitalize(r.toCamelCase(r.removePluralSuffix(a))),"';")})))).join("\n")}function o(n,t){var a=Object.entries(n).map((function(n){var a=e.slicedToArray(n,2),o=a[0],c=a[1],i=c.relation,l=c.relatedTable,s=c.foreignKey,u=c.localKey;return"\n ".concat(o,": {\n relation: Model.").concat(i,",\n modelClass: ").concat(r.capitalize(r.toCamelCase(r.removePluralSuffix(l))),",\n join: {\n ").concat("ManyToManyRelation"===i?"\n from: '".concat(u,"',\n through: {\n from: '").concat(s,"',\n to: '").concat(s,"'\n },\n to: '").concat(u,"'"):"\n from: '".concat(t,".").concat(s,"',\n to: '").concat(l,".").concat(u,"'"),"\n }\n }")})).join(",");return"\nstatic get relationMappings() {\nreturn {".concat(a,"\n};\n}")}var c=function(){var c=e.asyncToGenerator(e.regeneratorRuntime().mark((function c(i,l,s){var u,m,p,d,f,b,g,v,y,h,x,C,j=arguments;return e.regeneratorRuntime().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return u=j.length>3&&void 0!==j[3]?j[3]:"public",c.prev=1,i||(console.error("class name undefined"),process.exit(1)),l||(console.error("table name undefined"),process.exit(1)),m="".concat(i,".ts"),p=t.join(process.cwd(),"src","app","model",m),c.next=8,r.getTableColumns(s,null!=l?l:i.toLowerCase()+"s",u);case 8:return d=c.sent,f=Object.fromEntries(d.map((function(e){return[e.column_name,{defaultValue:e.column_default,type:e.data_type,maxLength:e.character_maximum_length,nullable:"YES"===e.is_nullable}]}))),c.next=12,r.getTableRelations(l,
|
|
2
|
+
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),n=require("fs"),t=require("path"),r=require("./utils.js");function a(n){return Array.from(new Set(Object.entries(n).map((function(n){var t=e.slicedToArray(n,2);t[0];var a=t[1].relatedTable;return"import ".concat(r.capitalize(r.toCamelCase(r.removePluralSuffix(a)))," from './").concat(r.capitalize(r.toCamelCase(r.removePluralSuffix(a))),"';")})))).join("\n")}function o(n,t){var a=Object.entries(n).map((function(n){var a=e.slicedToArray(n,2),o=a[0],c=a[1],i=c.relation,l=c.relatedTable,s=c.foreignKey,u=c.localKey;return"\n ".concat(o,": {\n relation: Model.").concat(i,",\n modelClass: ").concat(r.capitalize(r.toCamelCase(r.removePluralSuffix(l))),",\n join: {\n ").concat("ManyToManyRelation"===i?"\n from: '".concat(u,"',\n through: {\n from: '").concat(s,"',\n to: '").concat(s,"'\n },\n to: '").concat(u,"'"):"\n from: '".concat(t,".").concat(s,"',\n to: '").concat(l,".").concat(u,"'"),"\n }\n }")})).join(",");return"\nstatic get relationMappings() {\nreturn {".concat(a,"\n};\n}")}var c=function(){var c=e.asyncToGenerator(e.regeneratorRuntime().mark((function c(i,l,s){var u,m,p,d,f,b,g,v,y,h,x,C,j=arguments;return e.regeneratorRuntime().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return u=j.length>3&&void 0!==j[3]?j[3]:"public",c.prev=1,i||(console.error("class name undefined"),process.exit(1)),l||(console.error("table name undefined"),process.exit(1)),m="".concat(i,".ts"),p=t.join(process.cwd(),"src","app","model",m),c.next=8,r.getTableColumns(s,null!=l?l:i.toLowerCase()+"s",u);case 8:return d=c.sent,f=Object.fromEntries(d.map((function(e){return[e.column_name,{defaultValue:e.column_default,type:e.data_type,maxLength:e.character_maximum_length,nullable:"YES"===e.is_nullable}]}))),c.next=12,r.getTableRelations(s,l,u);case 12:b=c.sent,g=Object.entries(f).map((function(n){var t,a=e.slicedToArray(n,2),o=a[0],c=a[1],i=r.toCamelCase(o),l=(t=c.type,["integer","bigint","smallint","tinyint","numeric","decimal","float"].includes(t)?"number":["varchar","text","string","char","character varying","uuid"].includes(t)?"string":["boolean"].includes(t)?"boolean":["date","datetime","timestamp","timestamp with time zone"].includes(t)?"Date":"any");return" public ".concat(i,": ").concat(l,";")})).join("\n"),v='\n static get tableName() {\n return "'.concat(i.toLowerCase(),'s";\n }\n '),l&&(v='\n static get tableName() {\n return "'.concat(l,'";\n }\n ')),y=b?a(b):"",h=b?o(b,l):"",x='\n import Model from "@lib/Model";\n import { snakeCaseMappers } from "objection";\n '.concat(y,"\n \n export default class ").concat(i," extends Model {\n \n ").concat(g,"\n \n ").concat(v,'\n \n static get idColumn() {\n return "id";\n }\n \n static get columnNameMappers() {\n return snakeCaseMappers();\n }\n \n ').concat(h,"\n }"),C=t.dirname(p),n.existsSync(C)||n.mkdirSync(C,{recursive:!0}),n.writeFile(p,x,(function(e){e?console.error("err::",e):console.log("File ".concat(m," has been created"))})),c.next=27;break;case 24:c.prev=24,c.t0=c.catch(1),console.error("err::",c.t0);case 27:return c.prev=27,c.finish(27);case 29:case"end":return c.stop()}}),c,null,[[1,24,27,29]])})));return function(e,n,t){return c.apply(this,arguments)}}();module.exports=c;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frgen",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "helper generator",
|
|
5
5
|
"main": "lib/",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/fajarrh
|
|
17
|
+
"url": "git+https://github.com/fajarrh/EPP-Starter.git"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"express",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"author": "fajarrizkyhidayat",
|
|
29
29
|
"license": "ISC",
|
|
30
30
|
"bugs": {
|
|
31
|
-
"url": "https://github.com/fajarrh
|
|
31
|
+
"url": "https://github.com/fajarrh/EPP-Starter/issues"
|
|
32
32
|
},
|
|
33
|
-
"homepage": "https://
|
|
33
|
+
"homepage": "https://github.com/fajarrh/EPP-Starter",
|
|
34
34
|
"files": [
|
|
35
35
|
"lib/**/*"
|
|
36
36
|
],
|