Skip to content

Commit

Permalink
Merge pull request #4 from steve-lebleu/feature/extract-templates
Browse files Browse the repository at this point in the history
Feature: extract templates
  • Loading branch information
steve-lebleu committed Feb 16, 2024
2 parents 3ff5b66 + f86c6f9 commit bdbf71e
Show file tree
Hide file tree
Showing 20 changed files with 20 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
with:
node-version: '18.19.0'
- name: Create release
uses: konfer-be/action-create-release-from-tag@v1.0.2
uses: konfer-be/action-create-release-from-tag@v1.0.12
with:
token: ${{ secrets.GITHUB_TOKEN }}
publish:
Expand Down
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
*-debug.log
*-error.log
.nyc_output/
.vscode/
node_modules/
dist/
lib/
bin/
tmp/
reports/
.nyc_output
.vscode
node_modules
dist
lib
bin
tmp
reports
yarn.lock
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
![Github action workflow status](https://github.com/steve-lebleu/rsgen/actions/workflows/build.yml/badge.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/konfer-be/rsgen/badge.svg?branch=master)](https://coveralls.io/github/konfer-be/rsgen?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/steve-lebleu/rsgen/badge.svg?branch=master)](https://coveralls.io/github/steve-lebleu/rsgen?branch=master)
![Known Vulnerabilities](https://snyk.io/test/github/steve-lebleu/rsgen/badge.svg)
![GitHub Release](https://img.shields.io/github/v/release/steve-lebleu/rsgen?logo=Github)
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)

Naive modular resource generation for :point_right: [Typeplate](https://github.com/steve-lebleu/ts-express-typeorm) project.

## > Why ?

Obviously to improve the time passed on low value-added tasks . :clock1: :muscle:
Naive modular resource generation for :point_right: [Typeplate](https://github.com/steve-lebleu/typeplate) project.

## > How to ?

Expand All @@ -20,15 +16,15 @@ $ npm install -g rsgen

### Generate

Go to the project folder:
Go to project folder:

```bash
$ cd path-to-the-root-of-your-typeplate-project
```

Generate your resource module or core member:
Generate resource module or core member:

#### CLI short way
#### Short way

```bash
$ rsgen <name> [<target>] [<permissions>]
Expand All @@ -38,7 +34,7 @@ $ rsgen <name> [<target>] [<permissions>]
- **target** : -c (core) or -r (resource). Default: -r
- **permissions** : -p=[a,u,g]|[admin,user,ghost]. Default: admin

#### CLI interactive way
#### Interactive way

```bash
$ rsgen
Expand Down
2 changes: 0 additions & 2 deletions ROADMAP.md

This file was deleted.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
"node": ">=18.19.0",
"npm": ">=10.2.3"
},
"directories": {
"lib": "lib"
},
"publishConfig": {
"access": "public"
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/utils/file.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const write = async ({...args}) => {

const { isModule, template, patterns, lowerCase } = args;

const tpl = fs.readFileSync(`${__dirname}/../../templates/${template.name}.txt`, 'utf-8');
const tpl = fs.readFileSync(`${process.cwd()}/src/templates/${template.name}.txt`, 'utf-8');

const output = patterns.reduce( (acc, current) => {
return acc.replace(current.regex, current.value);
Expand Down
6 changes: 0 additions & 6 deletions test/01-package.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ describe('Package', () => {
expect(fs.existsSync(`${process.cwd()}/bin/rsgen.js`)).to.be.true;
});

['controller', 'model', 'repository', 'route', 'test', 'validation', 'business.service', 'data-layer.service', 'query-string.interface', 'request.interface', 'subscriber'].forEach(pattern => {
it(`should expose a template ${pattern}`, () => {
expect(fs.existsSync(`${process.cwd()}/templates/${pattern}.txt`)).to.be.true;
});
});

});

});

0 comments on commit bdbf71e

Please sign in to comment.