prettier on src

This commit is contained in:
Kononnable 2018-03-18 20:26:48 +01:00
parent f2bbeb4afb
commit cf108fe638
6 changed files with 33 additions and 18 deletions

View File

@ -24,7 +24,7 @@ gulp.task('clean', function () {
gulp.task('prettier', function () {
return gulp.src('.prettierrc')
.pipe(shell(['prettier ./src/**/*.ts --write']))
.pipe(shell(['prettier ./test/**/*.ts --write']))
// .pipe(shell(['prettier ./test/**/*.ts --write']))
});
gulp.task('pre-commit', ['prettier'], function () {

View File

@ -15,11 +15,14 @@ export abstract class AbstractDriver {
): Promise<DatabaseModel> {
let dbModel = <DatabaseModel>{};
await this.ConnectToServer(database, server, port, user, password, ssl);
let sqlEscapedSchema='\''+ schema.split(',').join('\',\'')+'\''
let sqlEscapedSchema = "'" + schema.split(",").join("','") + "'";
dbModel.entities = await this.GetAllTables(sqlEscapedSchema);
await this.GetCoulmnsFromEntity(dbModel.entities, sqlEscapedSchema);
await this.GetIndexesFromEntity(dbModel.entities, sqlEscapedSchema);
dbModel.entities = await this.GetRelations(dbModel.entities, sqlEscapedSchema);
dbModel.entities = await this.GetRelations(
dbModel.entities,
sqlEscapedSchema
);
await this.DisconnectFromServer();
this.FindPrimaryColumnsFromIndexes(dbModel);
return dbModel;

View File

@ -43,7 +43,7 @@ export class MssqlDriver extends AbstractDriver {
response.forEach(val => {
let ent: EntityInfo = new EntityInfo();
ent.EntityName = val.TABLE_NAME;
ent.Schema=val.TABLE_SCHEMA;
ent.Schema = val.TABLE_SCHEMA;
ent.Columns = <ColumnInfo[]>[];
ent.Indexes = <IndexInfo[]>[];
ret.push(ent);
@ -239,7 +239,11 @@ export class MssqlDriver extends AbstractDriver {
break;
default:
TomgUtils.LogFatalError(
`Unknown column type: ${resp.DATA_TYPE} table name: ${resp.TABLE_NAME} column name: ${resp.COLUMN_NAME}`
`Unknown column type: ${
resp.DATA_TYPE
} table name: ${
resp.TABLE_NAME
} column name: ${resp.COLUMN_NAME}`
);
break;
}

View File

@ -91,8 +91,8 @@ export class MysqlDriver extends AbstractDriver {
: null;
break;
case "tinyint":
if (resp.column_type == 'tinyint(1)') {
colInfo.char_max_lenght = 1
if (resp.column_type == "tinyint(1)") {
colInfo.char_max_lenght = 1;
colInfo.ts_type = "boolean";
} else {
colInfo.char_max_lenght =
@ -232,7 +232,11 @@ export class MysqlDriver extends AbstractDriver {
break;
default:
TomgUtils.LogFatalError(
`Unknown column type: ${resp.DATA_TYPE} table name: ${resp.TABLE_NAME} column name: ${resp.COLUMN_NAME}`
`Unknown column type: ${
resp.DATA_TYPE
} table name: ${
resp.TABLE_NAME
} column name: ${resp.COLUMN_NAME}`
);
break;
}
@ -345,7 +349,7 @@ export class MysqlDriver extends AbstractDriver {
if (!ownerEntity) {
TomgUtils.LogFatalError(
`Relation between tables ${relationTmp.ownerTable} and ${
relationTmp.referencedTable
relationTmp.referencedTable
} didn't found entity model ${relationTmp.ownerTable}.`
);
return;
@ -356,7 +360,7 @@ export class MysqlDriver extends AbstractDriver {
if (!referencedEntity) {
TomgUtils.LogFatalError(
`Relation between tables ${relationTmp.ownerTable} and ${
relationTmp.referencedTable
relationTmp.referencedTable
} didn't found entity model ${relationTmp.referencedTable}.`
);
return;
@ -367,9 +371,9 @@ export class MysqlDriver extends AbstractDriver {
if (!ownerColumn) {
TomgUtils.LogFatalError(
`Relation between tables ${relationTmp.ownerTable} and ${
relationTmp.referencedTable
relationTmp.referencedTable
} didn't found entity column ${
relationTmp.ownerTable
relationTmp.ownerTable
}.${ownerColumn}.`
);
return;
@ -380,9 +384,9 @@ export class MysqlDriver extends AbstractDriver {
if (!relatedColumn) {
TomgUtils.LogFatalError(
`Relation between tables ${relationTmp.ownerTable} and ${
relationTmp.referencedTable
relationTmp.referencedTable
} didn't found entity column ${
relationTmp.referencedTable
relationTmp.referencedTable
}.${relatedColumn}.`
);
return;

View File

@ -44,7 +44,7 @@ export class PostgresDriver extends AbstractDriver {
response.forEach(val => {
let ent: EntityInfo = new EntityInfo();
ent.EntityName = val.table_name;
ent.Schema=val.table_schema;
ent.Schema = val.table_schema;
ent.Columns = <ColumnInfo[]>[];
ent.Indexes = <IndexInfo[]>[];
ret.push(ent);
@ -87,7 +87,7 @@ export class PostgresDriver extends AbstractDriver {
colInfo.default = colInfo.is_generated
? null
: resp.column_default;
colInfo.sql_type = resp.data_type;
colInfo.sql_type = resp.data_type;
switch (resp.data_type) {
case "integer":
colInfo.ts_type = "number";
@ -210,7 +210,11 @@ export class PostgresDriver extends AbstractDriver {
break;
default:
TomgUtils.LogFatalError(
`Unknown column type: ${resp.data_type} table name: ${resp.table_name} column name: ${resp.column_name}`
`Unknown column type: ${
resp.data_type
} table name: ${
resp.table_name
} column name: ${resp.column_name}`
);
break;
}

View File

@ -10,7 +10,7 @@ export class EntityInfo {
Imports: string[];
UniqueImports: string[];
Indexes: IndexInfo[];
Schema:string;
Schema: string;
relationImports(): any {
var returnString = "";