Open txsoura opened 2 years ago
Hey @meerhamzadev, this issue will add some questions to the CLI after choosing a framework to add an attribute to the CRUD.
Example:
Add attribute ? yes/no
-> yes
Attribute name:
-> email
Attribute type:
-> string
Attribute length:
-> 100
Attribute is required ? yes/no
-> yes
Attribute is unique ? yes/no
-> yes
Attribute "email" add successfully!
Add attribute ? yes/no
-> no
// Generate the files...
So, I was supposed to provide the interface right? or functionality as well?
You can help however you can. Count on me to help you with anything you need, I can help you with functionality and the CLI too.
To facilitate this, we can make a brainstorm for what we will need to finalize this issue
// NestJS TypeORM Model example
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm'
export class <%= namePascal %> {
@PrimaryGeneratedColumn()
id: string
<% for (attribute of attributes) { %>
@Column({
unique: <%= attribute.unique %>,
length: <%= attribute.length %>,
nullable: <%= !attribute.required %>,
})
<%= attribute.name %>: <%= attribute.type %>;
<% } %>
@CreateDateColumn({ name: 'created_at' })
createdAt: Date
@UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date
@Column({ name: 'deleted_at' })
deletedAt?: Date
@Column({ enum: ['pendent', 'active'] })
status: string
/**
* Relations
*/
}
// NestJS TypeORM Validator example
import { Injectable } from '@nestjs/common'
import { Validator } from '@secjs/validator'
@Injectable()
export class <%= namePascal %>Validator extends Validator {
get schema() {
return {
<% for (attribute of attributes) { %>
<%= attribute.name %>: '<%= attribute.required ? 'required' : '' %>|<%= attribute.unique ? 'unique:<%= namePlural %>' : '' %>';
<% } %>
}
}
}
Ok, I would give it a try, this weekend 🙌
hey, @jlenon7 how to run CLI locally?
Hey @meerhamzadev, sorry about that, I will document how to run locally later.
First install
yo
globally usingnpm
.
npm install -g yo
Then in the project root, install the dependencies
npm install
Then link the project using
npm
npm link
Now every time that you run
yo secjs ...
, it will use the local project because ofnpm link
.
yo secjs Foo --path=./Bar
hey, can you explain this a bit more? I'm interested