Skip to content

Commit d4d84d6

Browse files
committed
feat: Add template sub-list to all frameworks
1 parent 328b020 commit d4d84d6

File tree

72 files changed

+55
-48
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+55
-48
lines changed

README.md

Lines changed: 2 additions & 2 deletions

app/index.js

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,45 +41,52 @@ class SecGenerator extends Generator {
4141
name: 'framework',
4242
message: 'Select your framework:',
4343
choices: [
44-
{ name: 'Laravel', value: 'laravel' },
45-
{ name: 'NestJS TypeORM', value: 'nestjsTypeOrm' },
46-
{ name: 'NestJS Mongoose', value: 'nestjsMongoose' },
47-
{ name: 'NestJS PrismaORM', value: 'nestjsPrismaOrm' },
44+
{ name: 'NestJS', value: 'nestjs' },
4845
{ name: 'ReactJS', value: 'reactjs' },
46+
{ name: 'Laravel', value: 'laravel' },
4947
],
5048
},
5149
{
5250
when: answers => answers.framework === 'reactjs',
5351
type: 'list',
54-
name: 'reactjs',
55-
message: 'Select your component type:',
52+
name: 'template',
53+
message: 'Select your template:',
5654
choices: [
55+
{ name: 'ReactJS Hook', value: 'reactjsHook' },
5756
{ name: 'ReactJS Component', value: 'reactjsComponent' },
57+
{ name: 'ReactJS ContextAPI', value: 'reactjsContext' },
5858
{ name: 'ReactJS Material-UI', value: 'reactjsMui' },
5959
{ name: 'ReactJS StyledComponents', value: 'reactjsStyled' },
60-
{ name: 'ReactJS ContextAPI', value: 'reactjsContext' },
61-
{ name: 'ReactJS Hook', value: 'reactjsHook' },
6260
],
6361
},
62+
{
63+
when: answers => answers.framework === 'nestjs',
64+
type: 'list',
65+
name: 'template',
66+
message: 'Select your template:',
67+
choices: [
68+
{ name: 'NestJS TypeOrm', value: 'nestjsTypeOrm' },
69+
{ name: 'NestJS Mongoose', value: 'nestjsMongoose' },
70+
{ name: 'NestJS PrismaOrm', value: 'nestjsPrismaOrm' },
71+
],
72+
},
73+
{
74+
when: answers => answers.framework === 'laravel',
75+
type: 'list',
76+
name: 'template',
77+
message: 'Select your template:',
78+
choices: [{ name: 'Default', value: 'default' }],
79+
},
6480
])
6581
}
6682

67-
frameworkChoice(framework) {
68-
switch (framework) {
69-
case 'reactjs':
70-
return this.answers.reactjs
71-
default:
72-
return this.answers.framework
73-
}
74-
}
75-
7683
async writing() {
77-
const framework = this.frameworkChoice(this.answers.framework)
78-
const dir = path.join(__dirname, `templates/${framework}/`)
84+
const template = `${this.answers.framework}/${this.answers.template}`
85+
const dir = path.join(__dirname, `templates/${template}/`)
7986

8087
for await (const f of makeFileTemplate(dir, this.variables.name)) {
8188
this.fs.copyTpl(
82-
this.templatePath(`${framework}/${f.src}`),
89+
this.templatePath(`${template}/${f.src}`),
8390
this.destinationPath(`${this.variables.path}/${f.dist}`),
8491
this.variables,
8592
)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generator-secjs",
3-
"version": "1.2.9",
3+
"version": "1.3.0",
44
"description": "🧬 Generator for any NodeJS Project or Framework",
55
"main": "app/index.js",
66
"scripts": {

tests/laravel.spec.js renamed to tests/laravel/default.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ const assert = require('yeoman-assert')
77
describe('\n Laravel 😸', () => {
88
beforeAll(() => {
99
return helpers
10-
.run(path.join(__dirname, '../app'))
10+
.run(path.join(__dirname, '../../app'))
1111
.withOptions({ path: './Foo' })
1212
.withArguments('Bar')
13-
.withPrompts({ framework: 'laravel' })
13+
.withPrompts({ framework: 'laravel', template: 'default' })
1414
})
1515

1616
it('should create all files from resource Bar in folder Foo', () => {

tests/nestjsMongoose.spec.js renamed to tests/nestjs/nestjsMongoose.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ const assert = require('yeoman-assert')
77
describe('\n NestJS Mongoose 😸', () => {
88
beforeAll(() => {
99
return helpers
10-
.run(path.join(__dirname, '../app'))
10+
.run(path.join(__dirname, '../../app'))
1111
.withOptions({ path: './Foo' })
1212
.withArguments('Bar')
13-
.withPrompts({ framework: 'nestjsMongoose' })
13+
.withPrompts({ framework: 'nestjs', template: 'nestjsMongoose' })
1414
})
1515

1616
it('should create all files from resource Bar in folder Foo', () => {

tests/nestjsPrismaOrm.spec.js renamed to tests/nestjs/nestjsPrismaOrm.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ const assert = require('yeoman-assert')
77
describe('\n NestJS PrismaORM 😸', () => {
88
beforeAll(() => {
99
return helpers
10-
.run(path.join(__dirname, '../app'))
10+
.run(path.join(__dirname, '../../app'))
1111
.withOptions({ path: './Foo' })
1212
.withArguments('Bar')
13-
.withPrompts({ framework: 'nestjsPrismaOrm' })
13+
.withPrompts({ framework: 'nestjs', template: 'nestjsPrismaOrm' })
1414
})
1515

1616
it('should create all files from resource Bar in folder Foo', () => {

tests/nestjsTypeOrm.spec.js renamed to tests/nestjs/nestjsTypeOrm.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ const assert = require('yeoman-assert')
77
describe('\n NestJS TypeORM 😸', () => {
88
beforeAll(() => {
99
return helpers
10-
.run(path.join(__dirname, '../app'))
10+
.run(path.join(__dirname, '../../app'))
1111
.withOptions({ path: './Foo' })
1212
.withArguments('Bar')
13-
.withPrompts({ framework: 'nestjsTypeOrm' })
13+
.withPrompts({ framework: 'nestjs', template: 'nestjsTypeOrm' })
1414
})
1515

1616
it('should create all files from resource Bar in folder Foo', () => {

tests/reactjsComponent.spec.js renamed to tests/reactjs/reactjsComponent.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const path = require('path')
44
const helpers = require('yeoman-test')
55
const assert = require('yeoman-assert')
66

7-
describe('\n ReactJS 😸', () => {
7+
describe('\n ReactJS Component ⚛️', () => {
88
beforeAll(() => {
99
return helpers
10-
.run(path.join(__dirname, '../app'))
10+
.run(path.join(__dirname, '../../app'))
1111
.withOptions({ path: './Foo' })
1212
.withArguments('Bar')
13-
.withPrompts({ framework: 'reactjsComponent' })
13+
.withPrompts({ framework: 'reactjs', template: 'reactjsComponent' })
1414
})
1515

1616
it('should create all files from resource Bar in folder Foo', () => {

tests/reactjsContext.spec.js renamed to tests/reactjs/reactjsContext.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const path = require('path')
44
const helpers = require('yeoman-test')
55
const assert = require('yeoman-assert')
66

7-
describe('\n ReactJS 😸', () => {
7+
describe('\n ReactJS Context ⚛️', () => {
88
beforeAll(() => {
99
return helpers
10-
.run(path.join(__dirname, '../app'))
10+
.run(path.join(__dirname, '../../app'))
1111
.withOptions({ path: './Foo' })
1212
.withArguments('Bar')
13-
.withPrompts({ framework: 'reactjsContext' })
13+
.withPrompts({ framework: 'reactjs', template: 'reactjsContext' })
1414
})
1515

1616
it('should create all files from resource Bar in folder Foo', () => {

tests/reactjsHook.spec.js renamed to tests/reactjs/reactjsHook.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const path = require('path')
44
const helpers = require('yeoman-test')
55
const assert = require('yeoman-assert')
66

7-
describe('\n ReactJS 😸', () => {
7+
describe('\n ReactJS Hook ⚛️', () => {
88
beforeAll(() => {
99
return helpers
10-
.run(path.join(__dirname, '../app'))
10+
.run(path.join(__dirname, '../../app'))
1111
.withOptions({ path: './Foo' })
1212
.withArguments('Bar')
13-
.withPrompts({ framework: 'reactjsHook' })
13+
.withPrompts({ framework: 'reactjs', template: 'reactjsHook' })
1414
})
1515

1616
it('should create all files from resource Bar in folder Foo', () => {

tests/reactjsMui.spec.js renamed to tests/reactjs/reactjsMui.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const path = require('path')
44
const helpers = require('yeoman-test')
55
const assert = require('yeoman-assert')
66

7-
describe('\n ReactJS 😸', () => {
7+
describe('\n ReactJS Mui ⚛️', () => {
88
beforeAll(() => {
99
return helpers
10-
.run(path.join(__dirname, '../app'))
10+
.run(path.join(__dirname, '../../app'))
1111
.withOptions({ path: './Foo' })
1212
.withArguments('Bar')
13-
.withPrompts({ framework: 'reactjsMui' })
13+
.withPrompts({ framework: 'reactjs', template: 'reactjsMui' })
1414
})
1515

1616
it('should create all files from resource Bar in folder Foo', () => {

tests/reactjsStyled.spec.js renamed to tests/reactjs/reactjsStyled.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const path = require('path')
44
const helpers = require('yeoman-test')
55
const assert = require('yeoman-assert')
66

7-
describe('\n ReactJS 😸', () => {
7+
describe('\n ReactJS Styled ⚛️', () => {
88
beforeAll(() => {
99
return helpers
10-
.run(path.join(__dirname, '../app'))
10+
.run(path.join(__dirname, '../../app'))
1111
.withOptions({ path: './Foo' })
1212
.withArguments('Bar')
13-
.withPrompts({ framework: 'reactjsStyled' })
13+
.withPrompts({ framework: 'reactjs', template: 'reactjsStyled' })
1414
})
1515

1616
it('should create all files from resource Bar in folder Foo', () => {

0 commit comments

Comments
 (0)