diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d0557a5..cbd8c32 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,12 +17,12 @@ jobs: - ubuntu-latest - windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js ${{matrix.node-version}} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} @@ -37,13 +37,13 @@ jobs: - Test if: ${{ github.ref == 'refs/heads/main' }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: 18.x registry-url: https://registry.npmjs.org - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} diff --git a/.github/workflows/CI_template.yml b/.github/workflows/CI_template.yml new file mode 100644 index 0000000..5fcc656 --- /dev/null +++ b/.github/workflows/CI_template.yml @@ -0,0 +1,56 @@ +name: Template CI +on: + push: + branches: + - main + pull_request: + branches: + - '*' +jobs: + Test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + node-version: + - 18.x + os: + - ubuntu-latest + - windows-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{matrix.node-version}} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: Install dependencies + run: npm ci + - name: Run Tests ๐Ÿงช + working-directory: ./packages/generator + run: npm run test + Publish: + runs-on: ubuntu-latest + needs: + - Test + if: ${{ github.ref == 'refs/heads/main' }} + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 18.x + registry-url: https://registry.npmjs.org + - uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: Install dependencies + run: npm ci + - name: Semantic release ๐Ÿš€ + working-directory: ./ + run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/README.md b/README.md index b1d16c5..3c0429c 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,28 @@ # Prisma Generator Template +[![Template CI](https://github.com/cloudservice-io/prisma-generator-template/actions/workflows/CI_template.yml/badge.svg)](https://github.com/cloudservice-io/prisma-generator-template/actions/workflows/CI_template.yml) + This repository is a template for creating custom Prisma generators. The initial code was generated by [create-prisma-generator](https://github.com/YassinEldeeb/create-prisma-generator). ## Getting Started -**Name Your Generator**: Replace the example name with the name of your custom generator +1. **Clone this template** + +2. **Name your generator**: Replace the example name with the name of your custom generator ![Screenshot 2023-07-27 at 19 44 25](https://github.com/cloudservice-io/prisma-generator-template/assets/904124/4ce1d57a-373b-44a2-adb4-0e5e5fc032ed) -**Implement Your Generator**: Replace the example code in `packages/generator` with your custom generator logic. +2. **Implement logic**: Replace the example code in `packages/generator` with your custom generator logic. + +3. **Test**: Test your generator code + +``` +$ cd packages/generator; +$ npm t + +``` -**Test**: TBD. +4. **CI**: Make sure to disable CI_template workflow and that CI is activated (if you want CI for publishing your generator package). ## Contribution diff --git a/packages/generator/src/__tests__/__snapshots__/genEnum.test.ts.snap b/packages/generator/src/__tests__/__snapshots__/genCustomLogic.test.ts.snap similarity index 97% rename from packages/generator/src/__tests__/__snapshots__/genEnum.test.ts.snap rename to packages/generator/src/__tests__/__snapshots__/genCustomLogic.test.ts.snap index 7a09f7a..fc71dca 100644 --- a/packages/generator/src/__tests__/__snapshots__/genEnum.test.ts.snap +++ b/packages/generator/src/__tests__/__snapshots__/genCustomLogic.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`enum generation 1`] = ` +exports[`check output 1`] = ` { "enums": { "Language": [ diff --git a/packages/generator/src/__tests__/genEnum.test.ts b/packages/generator/src/__tests__/genCustomLogic.test.ts similarity index 100% rename from packages/generator/src/__tests__/genEnum.test.ts rename to packages/generator/src/__tests__/genCustomLogic.test.ts