Skip to content

Commit

Permalink
Chore: Template to generate packages (RocketChat#25174)
Browse files Browse the repository at this point in the history
Co-authored-by: Diego Sampaio <[email protected]>
  • Loading branch information
ggazzo and sampaiodiego authored Apr 14, 2022
1 parent 0d33e4f commit 2a83680
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/packages/core-typings/ @RocketChat/chat-engine
/.vscode/ @RocketChat/chat-engine
/.github/ @RocketChat/chat-engine
/_templates/ @RocketChat/chat-engine
5 changes: 5 additions & 0 deletions _templates/generator/help/index.ejs.t
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]
---
18 changes: 18 additions & 0 deletions _templates/generator/new/hello.ejs.t
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 _templates/generator/with-prompt/hello.ejs.t
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 _templates/generator/with-prompt/prompt.ejs.t
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?"
}
]
4 changes: 4 additions & 0 deletions _templates/init/repo/new-repo.ejs.t
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
---
4 changes: 4 additions & 0 deletions _templates/package/new/index.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
to: packages/<%= name %>/src/index.ts
---
export default () => "<%= h.capitalize(name) %>";
29 changes: 29 additions & 0 deletions _templates/package/new/package.json.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
to: packages/<%= name %>/package.json
---

{
"name": "@rocket.chat/<%= name.toLowerCase() %>",
"version": "0.0.1",
"private": true,
"devDependencies": {
"@types/jest": "^27.4.1",
"eslint": "^8.12.0",
"jest": "^27.5.1",
"ts-jest": "^27.1.4",
"typescript": "~4.3.5"
},
"scripts": {
"eslint": "eslint --ext .js,.jsx,.ts,.tsx .",
"eslint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix",
"jest": "jest",
"build": "tsc -p tsconfig.json"
},
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"files": [
"/dist"
],
"dependencies": {
}
}
11 changes: 11 additions & 0 deletions _templates/package/new/tsconfig.json.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
to: packages/<%= name %>/tsconfig.json
---
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
},
"include": ["./src/**/*"]
}

0 comments on commit 2a83680

Please sign in to comment.