Skip to content

Commit

Permalink
refactor: ⚡ rename package to @admin-bro/typeorm
Browse files Browse the repository at this point in the history
BREAKING CHANGE: users should now rename package to @admin-bro/typeorm
  • Loading branch information
wojtek-krysiak committed Jul 27, 2020
1 parent 107f0ea commit d7b0f4f
Show file tree
Hide file tree
Showing 14 changed files with 9,330 additions and 937 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: CI/CD
on: push
jobs:
setup:
name: setup
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Checkout
uses: actions/checkout@v2
- name: Setup
uses: actions/setup-node@v1
with:
node-version: '12.x'
- uses: actions/cache@v1
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-
- name: Install
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install

test:
name: Test
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup
uses: actions/setup-node@v1
with:
node-version: '12.x'
- uses: actions/cache@v1
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-
- name: Install
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install
- name: Lint
run: yarn lint
- name: Test
run: yarn test

publish:
name: Publish
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup
uses: actions/setup-node@v1
with:
node-version: '12.x'
- uses: actions/cache@v1
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-
- name: Install
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install
- name: build
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn build
- name: Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn release
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
access=public
19 changes: 19 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"master",
"next",
"next-major",
{
"name": "beta",
"prerelease": true
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github",
"@semantic-release/git"
]
}
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
## admin-bro-typeorm

This is an inofficial [admin-bro](https://github.com/SoftwareBrothers/admin-bro) adapter which integrates [TypeORM](https://typeorm.io/) into admin-bro.
This is an official [admin-bro](https://github.com/SoftwareBrothers/admin-bro) adapter which integrates [TypeORM](https://typeorm.io/) into admin-bro. (originally forked from [Arteha/admin-bro-typeorm](https://github.com/Arteha/admin-bro-typeorm))

Installation: `npm install admin-bro-typeorm`
Installation: `npm install @admin-bro/typeorm`

## Usage

The plugin can be registered using standard `AdminBro.registerAdapter` method.

```typescript
import { Database, Resource } from "admin-bro-typeorm";
import AdminBro from 'admin-bro'
import { Database, Resource } from "@admin-bro/typeorm";
import AdminBro from '@admin-bro/core'

AdminBro.registerAdapter({ Database, Resource });

Expand All @@ -30,11 +30,11 @@ import {
RelationId
} from "typeorm";
import * as express from "express";
import { Database, Resource } from "admin-bro-typeorm";
import { Database, Resource } from "@admin-bro/typeorm";
import { validate } from 'class-validator'

import AdminBro from "admin-bro";
import * as AdminBroExpress from "admin-bro-expressjs"
import AdminBro from "@admin-bro/core";
import * as AdminBroExpress from "@admin-bro/express"

Resource.validate = validate;
AdminBro.registerAdapter({ Database, Resource });
Expand Down Expand Up @@ -90,7 +90,3 @@ export class Person extends BaseEntity
## ManyToOne

Admin supports ManyToOne relationship but you also have to define @RealationId as stated in the example above.

## Warning

Typescript developers who want to use admin-bro of version `~1.3.0` - don't do this - use `~1.4.0` instead.
5 changes: 5 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
extends: [
'@commitlint/config-conventional',
],
}
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "admin-bro-typeorm",
"name": "@admin-bro/typeorm",
"version": "1.0.0",
"description": "TypeORM adapter for AdminBro",
"keywords": [
Expand All @@ -18,8 +18,8 @@
"test": "mocha -r ts-node/register ./spec/**/*.spec.ts",
"ts-node": "ts-node",
"lint": "tslint -c tslint.json './{src,spec}/**/*.ts'",
"postinstall": "tsc",
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js"
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js",
"release": "semantic-release"
},
"repository": {
"type": "git",
Expand All @@ -28,15 +28,15 @@
"author": "Artem Zabolotnyi <1arteha1@gmail.com>",
"license": "MIT",
"peerDependencies": {
"admin-bro": ">=2.2.0",
"@admin-bro/core": ">=3.0.0-beta.3",
"typeorm": ">=0.2.1"
},
"optionalDependencies": {},
"devDependencies": {
"@types/chai": "^4.2.4",
"@types/mocha": "^5.2.7",
"@types/node": "12.0.10",
"admin-bro": ">=2.2.0",
"@admin-bro/core": ">=3.0.0-beta.3",
"chai": "^4.2.0",
"class-validator": "^0.11.0",
"mocha": "^6.2.2",
Expand All @@ -45,6 +45,11 @@
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"typeorm": "^0.2.1",
"typescript": "^3.6.3"
"typescript": "^3.6.3",
"semantic-release": "^17.0.7",
"@semantic-release/git": "^9.0.0",
"husky": "^4.2.5",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4"
}
}
6 changes: 4 additions & 2 deletions spec/Resource.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { BaseProperty, BaseRecord, ValidationError } from "admin-bro";
import { BaseProperty, BaseRecord, ValidationError } from "@admin-bro/core";
import { validate } from "class-validator";

import { Car } from "./entities/Car";
Expand Down Expand Up @@ -43,7 +43,9 @@ describe("Resource", () => {

describe("#databaseName", () => {
it("returns correct database name", () => {
expect(resource.databaseName()).to.equal(process.env.POSTGRES_DATABASE);
expect(resource.databaseName()).to.equal(
process.env.POSTGRES_DATABASE || "database_test"
);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/Database.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Resource } from "./Resource";
import { Connection, BaseEntity } from "typeorm";

import { BaseDatabase } from "admin-bro";
import { BaseDatabase } from "@admin-bro/core";

export class Database extends BaseDatabase
{
Expand Down
2 changes: 1 addition & 1 deletion src/Property.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ColumnMetadata } from "typeorm/metadata/ColumnMetadata";
import { DATA_TYPES } from "./utils/data-types";

import { BaseProperty, PropertyType } from "admin-bro";
import { BaseProperty, PropertyType } from "@admin-bro/core";

export class Property extends BaseProperty
{
Expand Down
6 changes: 3 additions & 3 deletions src/Resource.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Property } from "./Property";
import { BaseEntity, In } from "typeorm";
import { BaseResource, ValidationError, Filter, BaseRecord } from "@admin-bro/core";

import { Property } from "./Property";
import { convertFilter } from "./utils/convertFilter";

import { BaseResource, ValidationError, Filter, BaseRecord } from "admin-bro";
import { ParamsType } from "admin-bro/types/src/backend/adapters/base-record";
type ParamsType = Record<string, any>;

export class Resource extends BaseResource
{
Expand Down
2 changes: 1 addition & 1 deletion src/utils/convertFilter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseEntity, FindConditions, Between, MoreThanOrEqual, LessThanOrEqual, Like } from "typeorm";
import { Filter } from "admin-bro";
import { Filter } from "@admin-bro/core";

function safeParseJSON(json: string)
{
Expand Down
2 changes: 1 addition & 1 deletion src/utils/data-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropertyType } from "admin-bro";
import { PropertyType } from "@admin-bro/core";

export type DataType = "string" | "number" | "float" | "datetime" | "date" | "array" | "object" | "boolean";

Expand Down

0 comments on commit d7b0f4f

Please sign in to comment.