Skip to content

Commit 5de7582

Browse files
committed
chore: generator for make new rescript project
@Usage ```console hygen rescript-lib new --name rescript-new-libs --description "use hygen" ``` @see http://www.hygen.io/docs/generators
1 parent 9929beb commit 5de7582

File tree

9 files changed

+108
-0
lines changed

9 files changed

+108
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- test
88
paths-ignore:
99
- "**/*.md"
10+
- "_templates"
1011
pull_request:
1112
branches:
1213
- main

.hygen.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const moduleName = (str) => {
2+
const [firstName, ...moduleName] = str.toLowerCase().split("-");
3+
if (firstName === "rescript") {
4+
return moduleName.join("");
5+
}
6+
return str;
7+
};
8+
9+
const testModuleName = (str) => `dev__${moduleName(str).toLowerCase()}`;
10+
11+
const helpers = {
12+
testModuleName,
13+
moduleName,
14+
};
15+
16+
module.exports = {
17+
helpers,
18+
};

_templates/rescript-lib/.DS_Store

6 KB
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
to: <%= name %>/bsconfig.json
3+
---
4+
{
5+
"name": "<%= name %>",
6+
"sources": {
7+
"dir": "src",
8+
"subdirs": true
9+
},
10+
"package-specs": {
11+
"module": "es6",
12+
"in-source": true
13+
}
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
to: <%= name %>/CHANGELOG.md
3+
---

_templates/rescript-lib/new/dev.ejs.t

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
to: examples/dev/<%= h.testModuleName(name) %>.res
3+
---
4+
/**
5+
Write Test for <%= h.inflection.camelize(h.moduleName(name)) %>
6+
**/

_templates/rescript-lib/new/lib.ejs.t

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
to: <%= name %>/src/<%= h.inflection.camelize(h.moduleName(name)) %>.res
3+
---
4+
"<%= name %>"->Js.log;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
to: <%= name %>/package.json
3+
---
4+
{
5+
"name": "<%= locals.scope ? `@${scope}/${name}` : name %>",
6+
"version": "0.0.0",
7+
"description": "<%= locals.description ? description : "" %>",
8+
"author": "ri7nz <hi@rin.rocks>",
9+
"license": "MIT",
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/ri7nz/rescript-libs.git",
13+
"directory": "<%= name %>"
14+
},
15+
"bugs": "https://github.com/ri7nz/rescript-libs/issues",
16+
"scripts": {
17+
"start": "rescript build -w",
18+
"build": "rescript build -with-deps",
19+
"clean": "rescript clean"
20+
},
21+
"publishConfig": {
22+
"access": "public"
23+
},
24+
"devDependencies": {
25+
"rescript": "9.1.1"
26+
}
27+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
to: <%= name %>/README.md
3+
---
4+
# <%= name %>
5+
> <%= locals.description ? description : "write description" %>
6+
7+
## Installation
8+
9+
Run the following in your favorit console:
10+
```console
11+
> yarn add <%= locals.scope ? `@${scope}/${name}` : name %>
12+
```
13+
14+
**OR**
15+
16+
```console
17+
> npm install --save <%= locals.scope ? `@${scope}/${name}` : name %>
18+
```
19+
20+
Then, add `<%= locals.scope ? `@${scope}/${name}` : name %>` in your `bsconfig.json`:
21+
```diff
22+
-- "bs-dependencies": [],
23+
++ "bs-dependencies": [<%= locals.scope ? `@${scope}/${name}` : name %>],
24+
```
25+
26+
## Usage
27+
28+
```rescript
29+
30+
```
31+
32+
Or you can check this [**Example: <%= h.testModuleName(name) %>**](https://github.com/ri7nz/rescript-libs/tree/main/examples/dev/<%= h.testModuleName(name) %>.res).
33+
34+
## API
35+
> (WIP): docs

0 commit comments

Comments
 (0)