Skip to content

Commit

Permalink
Merge pull request #1 from cristopher1/development
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
cristopher1 committed Apr 7, 2024
2 parents 83e3eb5 + 1fdf0f1 commit 444233c
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 12 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Workflow to use continuos delivery

name: CD

on:
push:
tags:
- v*

jobs:
test_and_build:
name: Test and build the distributable generator-koa2-simple-api-generator
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Install dependencies
run: npm ci

- name: audit
run: npm audit

- name: run quality check
run: npm run quality-check

- name: build the dist folder
run: npm run build

- name: save artifact
uses: actions/upload-artifact@v4
with:
name: distributable-generator-koa2-simple-api-generator
path: |
dist
LICENSE
README.md
package.json
retention-days: 1

release:
name: Create new release
runs-on: ubuntu-latest
needs: test_and_build
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x

- name: create a new release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
body_path: RELEASE_NOTES.md

publish:
name: publish generator-koa2-simple-api-generator package
runs-on: ubuntu-latest
needs: release
environment: publish
steps:
- name: download generator-koa2-simple-api-generator distribuible
uses: actions/download-artifact@v4
with:
name: distributable-generator-koa2-simple-api-generator

- uses: actions/setup-node@v4
with:
node-version: 20.x

- name: publish generator-koa2-simple-api-generator en npm
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Workflow to use continuous integration

name: CI

on:
push:
branches:
- development
- main
pull_request:
branches:
- development

jobs:
test_and_build:
name: Test the source code and build the generator-koa2-simple-api-generator generator
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x

- name: install dependencies using package-lock.json
run: npm ci

- name: audit
run: npm audit

- name: run linter, formatter and unit tests
run: |
npm run lint
npm run format
npm run test
- name: build the dist folder
run: npm run build

- name: save artifact
uses: actions/upload-artifact@v4
with:
name: dist-generator-koa2-simple-api-generator
path: |
dist
LICENSE
README.md
package.json
retention-days: 1

create_generator:
name: Test a generator created by generator-koa2-simple-api-generator generator
needs: test_and_build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['>=18.17.0', '20.x']
steps:
- name: download dist generator-koa2-simple-api-generator generator
uses: actions/download-artifact@v4
with:
name: dist-generator-koa2-simple-api-generator

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: print node-version
run: echo ${{ matrix.node-version }}

- name: install yeoman
run: npm install -g yo

- name: install dependencies, it does not use the package-lock.json file
run: npm install

- name: link the generator
run: npm link

- name: create a new folder
working-directory: ../
run: mkdir -p generator_test

- name: create a new generator
working-directory: ../generator_test
run: yo koa2-simple-api-generator new_api postgresql --runGitInit --runPackageScripts --useDocker --nodeVersion=21 --projectFolderName=api --useDockerCompose --databaseName=postgresql

- name: audit
run: npm audit

- name: run linter and formatter
working-directory: ../generator_test/api
run: |
npm run lint
npm run format
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">Welcome to generator-koa2-simple-api-generator 👋</h1>
<p>
<img alt="Version" src="https://img.shields.io/badge/version-0.1.0-blue.svg?cacheSeconds=2592000" />
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
<a href="https://github.com/cristopher1/generator-koa2-simple-api-generator#readme" target="_blank">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
</a>
Expand Down Expand Up @@ -82,14 +82,14 @@ yo koa2-simple-api-generator koa2_api_project

The generator-koa2-simple-api-generator include various options, these are:

| option | value | default | description | example |
| :---------------- | :-----: | :-----: | :------------------------------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------- |
| runGitInit | Boolean | false | Run git init automatically, then installing the dependencies | `yo koa2-simple-api-generator project_name --runGitInit` |
| runPackageScripts | Boolean | false | Run the scripts that configure the package, then installing the dependencies | `yo koa2-simple-api-generator project_name --runPackageScripts` |
| useDocker | Boolean | false | Add docker support using DockerFile, .dockerignore and others | `yo koa2-simple-api-generator project_name --useDocker` |
| nodeVersion | Number | 16 | Node version used in DockerFile. (FROM nodeVersion). Recommended to use node 16, 18, 20 or 21 | `yo koa2-simple-api-generator project_name --nodeVersion=21` |
| projectFolderName | String | api | Project folder name used in DockerFile. (WORKDIR /usr/src/projectFolderName) | `yo koa2-simple-api-generator project_name --projectFolderName=project_folder_name` |
| useDockerCompose | String | false | Add Docker Compose support. | `yo koa2-simple-api-generator project_name --useDockerCompose` |
| option | value | default | description | example |
| :---------------- | :-----: | :-----: | :--------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------- |
| runGitInit | Boolean | false | Run git init automatically, then installing the dependencies | `yo koa2-simple-api-generator project_name --runGitInit` |
| runPackageScripts | Boolean | false | Run the scripts that configure the package, then installing the dependencies | `yo koa2-simple-api-generator project_name --runPackageScripts` |
| useDocker | Boolean | false | Add docker support using DockerFile, .dockerignore and others | `yo koa2-simple-api-generator project_name --useDocker` |
| nodeVersion | Number | 16 | Node version used in DockerFile. (FROM nodeVersion). Recommended to use node 16, 18, 20 or 21 | `yo koa2-simple-api-generator project_name --nodeVersion=21` |
| projectFolderName | String | api | Project folder name used in DockerFile. (WORKDIR /usr/src/projectFolderName) | `yo koa2-simple-api-generator project_name --projectFolderName=project_folder_name` |
| useDockerCompose | String | false | Add Docker Compose support. | `yo koa2-simple-api-generator project_name --useDockerCompose` |
| databaseName | String | null | Select the database to which the application will connect. Accepts the values: postgresql, mysql, mariadb and mongodb. | `yo koa2-simple-api-generator project_name --databaseName=postgresql` |

## <a id="structure"></a> Project structure
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-koa2-simple-api-generator",
"version": "0.1.0",
"version": "1.0.0",
"description": "Yeoman generator to create a simple base structure for api rest based in koa2 framework.",
"homepage": "https://github.com/cristopher1/generator-koa2-simple-api-generator",
"type": "module",
Expand All @@ -14,6 +14,14 @@
"./app": {
"types": "./dist/types/generators/app/index.d.ts",
"import": "./dist/generators/app/index.js"
},
"./docker": {
"types": "./dist/types/generators/docker/index.d.ts",
"import": "./dist/generators/docker/index.js"
},
"./docker_compose": {
"types": "./dist/types/generators/docker_compose/index.d.ts",
"import": "./dist/generators/docker_compose/index.js"
}
},
"keywords": [
Expand Down

0 comments on commit 444233c

Please sign in to comment.