Skip to content

Commit

Permalink
fix: Merge in alpha branch. Replace node v14 with node v18 for github…
Browse files Browse the repository at this point in the history
… actions tests (#191)

* Trial run of alpha and beta release of npm package. Remove husky and lint-staged

* node to 18

* remove husky prepare

* add missing package

* feat: Upgrade Mermaid dependency to v10.0.2 (#175)

* feat: Upgrade Mermaid dependency to v9

* fix tests and remove search from from/to many to many count array

* remove husky and lint staging tools

* Testing alpha/beta package releases

* feat: Option to specify mmdcPath (#188)

* fix actions on alpha

* fix branch names on alpha

* chore(release): 1.4.0

* tag format change

* remove ts files from package

* remove ts files from package

* fix: remove duplicate build step

* fix: Revert removal of ts files from npm package

* fix: Add back in prepublish script

* chore(release): 1.4.1

* chore(release): 1.4.2

* fix: Improve labeling of nullable and primary keys in table

* chore(release): 1.4.3

* fix: tarball and deployment setup for releaserc

* chore(release): 1.4.4

* fix: Add type definitions to package. remove markdown files from package output.

* chore(release): 1.4.5

* fix: Trim mmdc from mmdcPath. Added test and documentation for how to utilize new config ption. Resolve tests from nullable and primary key changes.

* feat: Support unique names (#190)

* chore: Upgrade semantic release and prettier

* moving generator helper to dev dependencies

* update ci jobs to drop node 14 and add 18
  • Loading branch information
keonik committed Mar 28, 2023
1 parent 562942d commit 1b1d618
Show file tree
Hide file tree
Showing 18 changed files with 1,443 additions and 777 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on:
push:
branches: [main]
pull_request:
branches: [main]
branches: [main, alpha, beta]

jobs:
smoke-test:
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
node: ['14', '16']
node: ['16', '18']

runs-on: ${{ matrix.os }}

Expand Down
23 changes: 10 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
name: Release

on:
push:
branches:
- main
- alpha
- beta

jobs:
release:
name: Release
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Install Dependencies
run: npm install

- name: Semantic Release
node-version: 'lts/*'
- name: Install dependencies
run: npm ci
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_ACTIONS_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules/
prisma/
.github/
.husky/
__tests__/
__tests__/
*.md
9 changes: 8 additions & 1 deletion .releaserc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"tagFormat": "${version}",
"branches": [
"main",
{
Expand All @@ -13,7 +14,13 @@
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
[
"@semantic-release/npm",
{
"tarballDir": "dist",
"npmPublish": true
}
],
[
"@semantic-release/git",
{
Expand Down
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,48 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.4.5](https://github.com/keonik/prisma-erd-generator/compare/v1.4.4...v1.4.5) (2023-03-25)


### Bug Fixes

* Add type definitions to package. remove markdown files from package output. ([561a98f](https://github.com/keonik/prisma-erd-generator/commit/561a98f75dbbde2e723b4e197542f845e0e9619f))

### [1.4.4](https://github.com/keonik/prisma-erd-generator/compare/v1.4.3...v1.4.4) (2023-03-25)


### Bug Fixes

* tarball and deployment setup for releaserc ([5f3ee76](https://github.com/keonik/prisma-erd-generator/commit/5f3ee762a25ed583a1db2c588a704ed3b4a61ad9))

### [1.4.3](https://github.com/keonik/prisma-erd-generator/compare/v1.4.2...v1.4.3) (2023-03-25)


### Bug Fixes

* Improve labeling of nullable and primary keys in table ([dbd9117](https://github.com/keonik/prisma-erd-generator/commit/dbd911776edf0992dd2879d20097ed2590037e8e))

### [1.4.4](https://github.com/keonik/prisma-erd-generator/compare/v1.4.2...v1.4.4) (2023-03-25)

### [1.4.2](https://github.com/keonik/prisma-erd-generator/compare/v1.4.1...v1.4.2) (2023-03-25)

### [1.4.1](https://github.com/keonik/prisma-erd-generator/compare/v1.4.0...v1.4.1) (2023-03-25)


### Bug Fixes

* Add back in prepublish script ([4ab1dd5](https://github.com/keonik/prisma-erd-generator/commit/4ab1dd5d6d6986b8c1cbab4870ed35bbb81f6bd7))
* remove duplicate build step ([23d86c3](https://github.com/keonik/prisma-erd-generator/commit/23d86c382ed3261bfdccfa27a66ec5a7f98aaf19))
* Revert removal of ts files from npm package ([a4628e7](https://github.com/keonik/prisma-erd-generator/commit/a4628e760a3cfaf8ede5f408ca2dbdbd978df6ac))

## [1.4.0](https://github.com/keonik/prisma-erd-generator/compare/v1.3.2...v1.4.0) (2023-03-25)


### Features

* Option to specify mmdcPath ([#188](https://github.com/keonik/prisma-erd-generator/issues/188)) ([39088ae](https://github.com/keonik/prisma-erd-generator/commit/39088aee8dbaaff079f4f1357d6999107bb0c333))
* Upgrade Mermaid dependency to v10.0.2 ([#175](https://github.com/keonik/prisma-erd-generator/issues/175)) ([efe5959](https://github.com/keonik/prisma-erd-generator/commit/efe5959567ffb095b20f7fb31a5f7ba3dea27908))

### [1.3.2](https://github.com/keonik/prisma-erd-generator/compare/v1.3.0...v1.3.2) (2023-03-22)


Expand Down
2 changes: 1 addition & 1 deletion ERD.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ Options
- dark
- neutral

### mmdcPath

In order for this generator to succeed you must have `mmdc` installed. This is the mermaid cli tool that is used to generate the ERD. By default the generator searches for an existing binary file at `/node_modules/.bin`. If it fails to find that binary it will run `find ../.. -name mmdc` to search through your folder for a `mmdc` binary. If you are using a different package manager or have a different location for your binary files, you can specify the path to the binary file.

```prisma
generator erd {
provider = "prisma-erd-generator"
theme = "forest"
mmcdPath = "node_modules/.bin"
}
```

### Disabled

You won't always need to generate a new ERD. For instance, when you are building your docker containers you often run `prisma generate` and if this generator is included, odds are you aren't relying on an updated ERD inside your docker container. It also adds additional space to the container because of dependencies such as puppeteer. To disabled running this generator just add an environment variable to the environment running `prisma generate`.
Expand Down
2 changes: 1 addition & 1 deletion __tests__/compositePk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('composite-pk.prisma', async () => {
.execSync(`cat ${folderName}/${fileName}`)
.toString();

const pks = svgAsString.match(/PK/g);
const pks = svgAsString.match(/🗝️/g);

// did it generate a file with the correct content
expect(svgAsString).toContain(`<svg`);
Expand Down
18 changes: 18 additions & 0 deletions __tests__/mmdcPath.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as child_process from 'child_process';

test('setting mmdcPath works', async () => {
const fileName = 'mmdcPath.svg';
const folderName = '__tests__';
child_process.execSync(`rm -f ${folderName}/${fileName}`);
child_process.execSync(`prisma generate --schema ./prisma/mmdcPath.prisma`);
const svgContent = child_process
.execSync(`cat ${folderName}/${fileName}`)
.toString();
// did the model get added
expect(svgContent).toContain('users');

// User has id
expect(svgContent).toMatch(
/id="text-entity-users([^\><]*)-attr-1-name"([^<\>]*)\>id<\/text\>/
);
});
2 changes: 1 addition & 1 deletion __tests__/nullables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('nullables.prisma', async () => {

// did it generate a file with the correct content
expect(svgAsString).toContain(`<svg`);
expect(svgAsString).toContain(`nullable`);
expect(svgAsString).toContain(``);
expect(svgAsString).toContain(`inviteeEmail`);
expect(svgAsString).toContain(`cancelCode`);
expect(svgAsString).toContain(`name`);
Expand Down
20 changes: 20 additions & 0 deletions __tests__/unique-names.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as child_process from 'child_process';

test('Support unique names. Starting issue https://github.com/keonik/prisma-erd-generator/issues/127', async () => {
const fileName = 'unique-names.svg';
const folderName = '__tests__';
child_process.execSync(`rm -f ${folderName}/${fileName}`);
child_process.execSync(
`prisma generate --schema ./prisma/unique-names.prisma`
);
const svgContent = child_process
.execSync(`cat ${folderName}/${fileName}`)
.toString();
// did the model get added
expect(svgContent).toContain('[Production$My Table]');

// User has id
expect(svgContent).toMatch(
/id="text-entity-ProductionMyTable([^\><]*)-attr-1-name"([^<\>]*)\>id<\/text\>/
);
});

0 comments on commit 1b1d618

Please sign in to comment.