Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: refactor(warthog): monorepo #287

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript 3.4 introduced the --incremental option to enable faster subsequent builds. This flag tells TS to save information about the project graph in a file called .tsbuildinfo. The next time TypeScript is invoked with --incremental, it will use that information to detect the least costly way to type-check and emit changes to your project. The incremental option is also enabled by default when you have composite projects. Since we are going monorepo, both of these features can be useful during development and so I added it here.


# 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
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep in package.json for now.

8 changes: 1 addition & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
"[html]": {
"editor.formatOnSave": false
},
"eslint.validate": [
"javascript",
{
"language": "typescript",
"autoFix": true
}
],
"eslint.validate": ["javascript", "typescript"],
"search.exclude": {
"dist/": true,
"node_modules/": true
Expand Down
10 changes: 5 additions & 5 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
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.

2 changes: 2 additions & 0 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
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 '@warthog/core';

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
5 changes: 3 additions & 2 deletions examples/02-complex-example/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'reflect-metadata';

import { authChecker, BaseContext, Server } from '../../../src/';
import { authChecker } from '@warthog/core';
import { BaseContext, Server } from '@warthog/server-express';

import { customLogger } from './logger';

interface Context extends BaseContext {
user: {
email: string;
id: string;
permissions: string;
permissions: string[];
};
}

Expand Down
2 changes: 1 addition & 1 deletion examples/02-complex-example/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';
import { Binding } from '../generated/binding';
Expand Down
3 changes: 0 additions & 3 deletions examples/02-complex-example/warthog.config.js

This file was deleted.

4 changes: 2 additions & 2 deletions examples/03-one-to-many-relationship/generated/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ export interface BaseWhereInput {

export interface PostCreateInput {
title: String
userId: String
userId: ID_Output
}

export interface PostUpdateInput {
title?: String | null
userId?: String | null
userId?: ID_Input | null
}

export interface PostWhereInput {
Expand Down
Loading