-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add hygen and create a generator for core module
- Loading branch information
1 parent
c79f34a
commit ea5e591
Showing
18 changed files
with
513 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/core/_templates/core-module/with-prompt/datasource.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
to: src/internal/<%= moduleName %>/data/<%= h.capitalize(moduleName) %>DataSource.ts | ||
--- | ||
export interface <%= h.capitalize(moduleName) %>DataSource {} | ||
|
||
|
10 changes: 10 additions & 0 deletions
10
packages/core/_templates/core-module/with-prompt/default-service.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
to: src/internal/<%= moduleName %>/service/Default<%= h.capitalize(moduleName) %>Service.ts | ||
--- | ||
import { injectable } from "inversify"; | ||
import { <%= h.capitalize(moduleName) %>Service } from "./<%= h.capitalize(moduleName) %>Service"; | ||
|
||
@injectable() | ||
export class Default<%= h.capitalize(moduleName) %>Service implements <%= h.capitalize(moduleName) %>Service { | ||
constructor() {} | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/core/_templates/core-module/with-prompt/default-service.test.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
to: src/internal/<%= moduleName %>/service/Default<%= h.capitalize(moduleName) %>Service.test.ts | ||
--- | ||
import { <%= h.capitalize(moduleName) %>Service } from "./<%= h.capitalize(moduleName) %>Service"; | ||
import { Default<%= h.capitalize(moduleName) %>Service } from "./Default<%= h.capitalize(moduleName) %>Service"; | ||
|
||
let service: <%= h.capitalize(moduleName) %>Service; | ||
describe("<%= h.capitalize(moduleName) %>Service", () => { | ||
beforeEach(() => { | ||
service = new Default<%= h.capitalize(moduleName) %>Service(); | ||
}); | ||
|
||
it("should be defined", () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
packages/core/_templates/core-module/with-prompt/di-module.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
to: src/internal/<%= moduleName %>/di/<%= moduleName %>Module.ts | ||
--- | ||
import { ContainerModule } from "inversify"; | ||
import { Default<%= h.capitalize(moduleName) %>Service } from "../service/Default<%= h.capitalize(moduleName) %>Service"; | ||
import { types } from "./<%= moduleName %>Types"; | ||
|
||
type FactoryProps = {}; | ||
|
||
const <%= moduleName %>ModuleFactory = ({}: Partial<FactoryProps> = {}) => | ||
new ContainerModule((bind, _unbind, _isBound, _rebind, _unbindAsync, _onActivation, _onDeactivation) => { | ||
bind(types.<%= h.capitalize(moduleName) %>Service).to(Default<%= h.capitalize(moduleName) %>Service); | ||
}); | ||
|
||
export default <%= moduleName %>ModuleFactory; |
22 changes: 22 additions & 0 deletions
22
packages/core/_templates/core-module/with-prompt/di-module.test.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
to: src/internal/<%= moduleName %>/di/<%= moduleName %>Module.test.ts | ||
--- | ||
import { Container } from "inversify"; | ||
import <%= moduleName %>ModuleFactory from "./<%= moduleName %>Module"; | ||
import { types } from "./<%= moduleName %>Types"; | ||
|
||
describe("<%= moduleName %>ModuleFactory", () => { | ||
describe("Default", () => { | ||
let container: Container; | ||
let mod: ReturnType<typeof <%= moduleName %>ModuleFactory>; | ||
beforeEach(() => { | ||
mod = <%= moduleName %>ModuleFactory(); | ||
container = new Container(); | ||
container.load(mod); | ||
}); | ||
|
||
it("should return the config module", () => { | ||
expect(mod).toBeDefined(); | ||
}); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
packages/core/_templates/core-module/with-prompt/di-types.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
to: src/internal/<%= moduleName %>/di/<%= moduleName %>Types.ts | ||
--- | ||
export const types = { | ||
<%= h.capitalize(moduleName) %>Service: Symbol.for("<%= h.capitalize(moduleName) %>Service"), | ||
}; |
3 changes: 3 additions & 0 deletions
3
packages/core/_templates/core-module/with-prompt/gitkeep-model.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
to: src/internal/<%= moduleName %>/model/.gitkeep | ||
--- |
3 changes: 3 additions & 0 deletions
3
packages/core/_templates/core-module/with-prompt/gitkeep-usecase.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
to: src/internal/<%= moduleName %>/usecase/.gitkeep | ||
--- |
10 changes: 10 additions & 0 deletions
10
packages/core/_templates/core-module/with-prompt/prompt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// see types of prompts: | ||
// https://github.com/enquirer/enquirer/tree/master/examples | ||
// | ||
module.exports = [ | ||
{ | ||
type: "input", | ||
name: "moduleName", | ||
message: "What's the name of the module?", | ||
}, | ||
]; |
4 changes: 4 additions & 0 deletions
4
packages/core/_templates/core-module/with-prompt/service.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
to: src/internal/<%= moduleName %>/service/<%= h.capitalize(moduleName) %>Service.ts | ||
--- | ||
export interface <%= h.capitalize(moduleName) %>Service {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
message: | | ||
hygen {bold generator new} --name [NAME] --action [ACTION] | ||
hygen {bold generator with-prompt} --name [NAME] --action [ACTION] | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t | ||
--- | ||
--- | ||
to: app/hello.js | ||
--- | ||
const hello = ``` | ||
Hello! | ||
This is your first hygen template. | ||
|
||
Learn what it can do here: | ||
|
||
https://github.com/jondot/hygen | ||
``` | ||
|
||
console.log(hello) | ||
|
||
|
18 changes: 18 additions & 0 deletions
18
packages/core/_templates/generator/with-prompt/hello.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t | ||
--- | ||
--- | ||
to: app/hello.js | ||
--- | ||
const hello = ``` | ||
Hello! | ||
This is your first prompt based hygen template. | ||
|
||
Learn what it can do here: | ||
|
||
https://github.com/jondot/hygen | ||
``` | ||
|
||
console.log(hello) | ||
|
||
|
14 changes: 14 additions & 0 deletions
14
packages/core/_templates/generator/with-prompt/prompt.ejs.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
to: _templates/<%= name %>/<%= action || 'new' %>/prompt.js | ||
--- | ||
|
||
// see types of prompts: | ||
// https://github.com/enquirer/enquirer/tree/master/examples | ||
// | ||
module.exports = [ | ||
{ | ||
type: 'input', | ||
name: 'message', | ||
message: "What's your message?" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
setup: <%= name %> | ||
force: true # this is because mostly, people init into existing folders is safe | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.