Skip to content

Commit

Permalink
refactor(warthog): refactor into monorepo
Browse files Browse the repository at this point in the history
Split Warthog core and cli into packages.

closes goldcaddy77#147
  • Loading branch information
thiagozf committed Jan 1, 2020
1 parent 493c1b2 commit 5e6ad57
Show file tree
Hide file tree
Showing 295 changed files with 5,774 additions and 3,873 deletions.
9 changes: 5 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**/node_modules/**/*
/examples/**/coverage/**/*
/examples/**/node_modules/**/*
/**/generated/**/*
**/node_modules/**/*
**/coverage/**/*
**/generated/**/*
**/dist/**/*
**/tmp/**/*
!.eslintrc.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.tsbuildinfo

# Coverage directory used by tools like istanbul
coverage
Expand Down
19 changes: 19 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"linters": {
"*.ts": [
"eslint --fix",
"prettier --write",
"git add"
],
"*.{js,json}": [
"prettier --write",
"git add"
],
"*.md": [
"markdownlint"
]
},
"ignore": [
"**/generated/*"
]
}
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
**/generated/**/*
**/node_modules/**/*
**/dist/**/*
**/tmp/**/*
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 100,
"singleQuote": true
}
14 changes: 7 additions & 7 deletions examples/01-simple-model/generated/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ export interface UserWhereInput {
email_startsWith?: String | null
email_endsWith?: String | null
email_in?: String[] | String | null
age_eq?: Float | null
age_gt?: Float | null
age_gte?: Float | null
age_lt?: Float | null
age_lte?: Float | null
age_eq?: Int | null
age_gt?: Int | null
age_gte?: Int | null
age_lt?: Int | null
age_lte?: Int | null
age_in?: Int[] | Int | null
isRequired_eq?: Boolean | null
isRequired_in?: Boolean[] | Boolean | null
Expand Down Expand Up @@ -238,7 +238,7 @@ The javascript `Date` as string. Type represents date and time as the ISO Date s
export type DateTime = Date | string

/*
The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).
The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).
*/
export type Float = number

Expand All @@ -249,7 +249,7 @@ export type ID_Input = string | number
export type ID_Output = string

/*
The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.
The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.
*/
export type Int = number

Expand Down
28 changes: 16 additions & 12 deletions examples/01-simple-model/generated/classes.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
// This file has been auto-generated by Warthog. Do not update directly as it
// will be re-written. If you need to change this file, update models or add
// new TypeGraphQL objects
// @ts-ignore
import { GraphQLDateTime as DateTime } from "graphql-iso-date";
import { GraphQLID as ID } from "graphql";

// @ts-ignore
import {
ArgsType,
Field as TypeGraphQLField,
Float,
InputType as TypeGraphQLInputType,
Int
} from "type-graphql";
// @ts-ignore
import { registerEnumType } from "type-graphql";

// eslint-disable-next-line @typescript-eslint/no-var-requires
// @ts-ignore eslint-disable-next-line @typescript-eslint/no-var-requires
const { GraphQLJSONObject } = require("graphql-type-json");

// @ts-ignore
import { BaseWhereInput, JsonObject, PaginationArgs } from "../../../src";
import { BaseWhereInput, JsonObject, PaginationArgs } from "@warthog/core";
import { StringEnum } from "../src/user.model";
// @ts-ignore
import { User } from "../src/user.model";
Expand Down Expand Up @@ -167,19 +171,19 @@ export class UserWhereInput {
@TypeGraphQLField(() => [String], { nullable: true })
email_in?: string[];

@TypeGraphQLField({ nullable: true })
@TypeGraphQLField(() => Int, { nullable: true })
age_eq?: number;

@TypeGraphQLField({ nullable: true })
@TypeGraphQLField(() => Int, { nullable: true })
age_gt?: number;

@TypeGraphQLField({ nullable: true })
@TypeGraphQLField(() => Int, { nullable: true })
age_gte?: number;

@TypeGraphQLField({ nullable: true })
@TypeGraphQLField(() => Int, { nullable: true })
age_lt?: number;

@TypeGraphQLField({ nullable: true })
@TypeGraphQLField(() => Int, { nullable: true })
age_lte?: number;

@TypeGraphQLField(() => [Int], { nullable: true })
Expand All @@ -197,19 +201,19 @@ export class UserWhereInput {
@TypeGraphQLField(() => [StringEnum], { nullable: true })
stringEnumField_in?: StringEnum[];

@TypeGraphQLField({ nullable: true })
@TypeGraphQLField(() => Float, { nullable: true })
rating_eq?: number;

@TypeGraphQLField({ nullable: true })
@TypeGraphQLField(() => Float, { nullable: true })
rating_gt?: number;

@TypeGraphQLField({ nullable: true })
@TypeGraphQLField(() => Float, { nullable: true })
rating_gte?: number;

@TypeGraphQLField({ nullable: true })
@TypeGraphQLField(() => Float, { nullable: true })
rating_lt?: number;

@TypeGraphQLField({ nullable: true })
@TypeGraphQLField(() => Float, { nullable: true })
rating_lte?: number;

@TypeGraphQLField(() => [Float], { nullable: true })
Expand Down
2 changes: 1 addition & 1 deletion examples/01-simple-model/generated/ormconfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { getBaseConfig } from '../../../src';
import { getBaseConfig } from '@warthog/core';

module.exports = getBaseConfig();
10 changes: 5 additions & 5 deletions examples/01-simple-model/generated/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ input UserWhereInput {
email_startsWith: String
email_endsWith: String
email_in: [String!]
age_eq: Float
age_gt: Float
age_gte: Float
age_lt: Float
age_lte: Float
age_eq: Int
age_gt: Int
age_gte: Int
age_lt: Int
age_lte: Int
age_in: [Int!]
isRequired_eq: Boolean
isRequired_in: [Boolean!]
Expand Down
2 changes: 1 addition & 1 deletion examples/01-simple-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"start:ts": "DEBUG=warthog* ts-node-dev --type-check src/index.ts",
"start:prod": "ts-node src/index.ts",
"//": "Allows us to use the local warthog CLI in commands above",
"warthog": "../../bin/warthog"
"warthog": "../../packages/cli/bin/warthog"
},
"dependencies": {},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/01-simple-model/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'reflect-metadata';

import { logger } from '../../../src';
import { logger } from '@warthog/core';

import { getServer } from './server';

Expand Down
2 changes: 1 addition & 1 deletion examples/01-simple-model/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'reflect-metadata';

import { Server } from '../../../src';
import { Server } from '@warthog/core';

export function getServer(AppOptions = {}, dbOptions = {}) {
return new Server(
Expand Down
2 changes: 1 addition & 1 deletion examples/01-simple-model/src/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
IntField,
Model,
StringField
} from '../../../src';
} from '@warthog/core';

// Note: this must be exported and in the same file where it's attached with @EnumField
// Also - must use string enums
Expand Down
2 changes: 1 addition & 1 deletion examples/01-simple-model/src/user.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Arg, Args, Ctx, Mutation, Query, Resolver } from 'type-graphql';
import { Repository } from 'typeorm';
import { InjectRepository } from 'typeorm-typedi-extensions';

import { BaseContext, BaseResolver, StandardDeleteResponse } from '../../../src';
import { BaseContext, BaseResolver, StandardDeleteResponse } from '@warthog/core';
import {
UserCreateInput,
UserUpdateArgs,
Expand Down
2 changes: 1 addition & 1 deletion examples/01-simple-model/tools/seed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Faker from 'faker';

import { getBindingError, logger } from '../../../src';
import { getBindingError, logger } from '@warthog/core';

import { getServer } from '../src/server';

Expand Down
3 changes: 0 additions & 3 deletions examples/01-simple-model/warthog.config.js

This file was deleted.

6 changes: 4 additions & 2 deletions examples/02-complex-example/generated/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ export interface UserWhereInput {
export interface UserWhereUniqueInput {
id?: String | null
emailField?: String | null
enumField?: StringEnum | null
stringField?: String | null
}

export interface BaseGraphQLObject {
Expand Down Expand Up @@ -460,7 +462,7 @@ The javascript `Date` as string. Type represents date and time as the ISO Date s
export type DateTime = Date | string

/*
The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).
The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).
*/
export type Float = number

Expand All @@ -471,7 +473,7 @@ export type ID_Input = string | number
export type ID_Output = string

/*
The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.
The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.
*/
export type Int = number

Expand Down
14 changes: 12 additions & 2 deletions examples/02-complex-example/generated/classes.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
// This file has been auto-generated by Warthog. Do not update directly as it
// will be re-written. If you need to change this file, update models or add
// new TypeGraphQL objects
// @ts-ignore
import { GraphQLDateTime as DateTime } from "graphql-iso-date";
import { GraphQLID as ID } from "graphql";

// @ts-ignore
import {
ArgsType,
Field as TypeGraphQLField,
Float,
InputType as TypeGraphQLInputType,
Int
} from "type-graphql";
// @ts-ignore
import { registerEnumType } from "type-graphql";

// eslint-disable-next-line @typescript-eslint/no-var-requires
// @ts-ignore eslint-disable-next-line @typescript-eslint/no-var-requires
const { GraphQLJSONObject } = require("graphql-type-json");

// @ts-ignore
import { BaseWhereInput, JsonObject, PaginationArgs } from "../../../src";
import { BaseWhereInput, JsonObject, PaginationArgs } from "@warthog/core";
import { StringEnum } from "../src/modules/user/user.model";
// @ts-ignore
import { User } from "../src/modules/user/user.model";
Expand Down Expand Up @@ -613,6 +617,12 @@ export class UserWhereUniqueInput {

@TypeGraphQLField(() => String, { nullable: true })
emailField?: string;

@TypeGraphQLField(() => StringEnum, { nullable: true })
enumField?: StringEnum;

@TypeGraphQLField(() => String, { nullable: true })
stringField?: string;
}

@TypeGraphQLInputType()
Expand Down
2 changes: 1 addition & 1 deletion examples/02-complex-example/generated/ormconfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { getBaseConfig } from '../../../src';
import { getBaseConfig } from '@warthog/core';

module.exports = getBaseConfig();
2 changes: 2 additions & 0 deletions examples/02-complex-example/generated/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,6 @@ input UserWhereInput {
input UserWhereUniqueInput {
id: String
emailField: String
enumField: StringEnum
stringField: String
}
2 changes: 1 addition & 1 deletion examples/02-complex-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test": "jest --detectOpenHandles --verbose --coverage",
"test:watch": "jest --watch",
"//": "Allows us to use the local warthog CLI in commands above",
"warthog": "../../bin/warthog"
"warthog": "../../packages/cli/bin/warthog"
},
"dependencies": {
"debug": "^4.1.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/02-complex-example/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'reflect-metadata';

import { logger } from '../../../src';
import { logger } from '../../../packages/core/src';

import { getServer } from './server';

Expand Down
2 changes: 1 addition & 1 deletion examples/02-complex-example/src/modules/user/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
NumericField,
StringField,
FloatField
} from '../../../../../src';
} from '@warthog/core';

// Note: this must be exported and in the same file where it's attached with @EnumField
// Also - must use string enums
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Arg, Args, Authorized, Ctx, Mutation, Query, Resolver } from 'type-grap
import { Repository } from 'typeorm';
import { InjectRepository } from 'typeorm-typedi-extensions';

import { BaseContext, BaseResolver, StandardDeleteResponse } from '../../../../../src';
import { BaseContext, BaseResolver, StandardDeleteResponse } from '@warthog/core';
import {
UserCreateInput,
UserUpdateArgs,
Expand Down
2 changes: 1 addition & 1 deletion examples/02-complex-example/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'reflect-metadata';

import { authChecker, BaseContext, Server } from '../../../src/';
import { authChecker, BaseContext, Server } from '../../../packages/core/src/';

import { customLogger } from './logger';

Expand Down
3 changes: 0 additions & 3 deletions examples/02-complex-example/warthog.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion examples/03-one-to-many-relationship/generated/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { registerEnumType } from "type-graphql";
const { GraphQLJSONObject } = require("graphql-type-json");

// @ts-ignore
import { BaseWhereInput, JsonObject, PaginationArgs } from "../../../src";
import { BaseWhereInput, JsonObject, PaginationArgs } from "../../../packages/core/src";
// @ts-ignore
import { User } from "../src/user.model";
// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion examples/03-one-to-many-relationship/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start": "yarn start:ts",
"start:ts": "ts-node --type-check src/index.ts",
"//": "Allows us to use the local warthog CLI in commands above",
"warthog": "../../bin/warthog"
"warthog": "../../packages/cli/bin/warthog"
},
"dependencies": {
"handlebars": "^4.5.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/03-one-to-many-relationship/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'reflect-metadata';

import { logger } from '../../../src';
import { logger } from '@warthog/core';

import { getServer } from './server';

Expand Down
Loading

0 comments on commit 5e6ad57

Please sign in to comment.