diff --git a/.travis.yml b/.travis.yml index dae660a..1b05f74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,36 @@ language: node_js node_js: -- stable -- 8 -- 6 + - stable + - 8 + - 6 sudo: required services: -- docker + - docker env: - matrix: - - POSTGRES_Skip=0 POSTGRES_Host=localhost POSTGRES_Port=5432 POSTGRES_Username=postgres - POSTGRES_Password=!Passw0rd POSTGRES_Database=typeorm_mg POSTGRES_SSL=0 MYSQL_Skip=0 - MYSQL_Host=localhost MYSQL_Port=3306 MYSQL_Username=root MYSQL_Password=!Passw0rd - MYSQL_Database=typeorm_mg MYSQL_SSL=1 MARIADB_Skip=0 MARIADB_Host=localhost MARIADB_Port=3307 - MARIADB_Username=root MARIADB_Password=!Passw0rd MARIADB_Database=typeorm_mg MARIADB_SSL=0 - global: - secure: Xj6wO8aghAhi6nvBI/HTtW9mIq9xfigIQfCC7ZkgAcqS4Oe3ba+7A5pCJq6Fxndadc6Bg1bZ3BGCH3Upf/Yv3zCFybsk43LwwXPJoG9gCrva/me7Sd+ws30EcD2dsKbvjZqNYai/XdrhzJY+KlxWvS/g3N/puBNffcU5hteo1zllxakQIAiavJ64D4g+Th8LSytmb2qDDToSsCxXkzNSutaKgZSf6T8QCWzcl0NCZkl69s9kX7L5335HVBD9lR/EKFC4wqHQjryCDRAyNRvItZRNlTPqgOI8lvcTsH9zKozDwEz7h/zcLebbY/+YTsLB5pb2sa62tkQE0x24TG7bLxujQShEQZU8itkRSV+w6+0JpBHQPlSUppkQJBNGKao7GaO/Eix4mSyvHkeECmTWDtEpBGWERYLqCKGe2Nj3BfcA2Ue6pjz9CX8wnrCbx53j6be3M/g/gcx7fbJbX3P95yc1CWAaR+tJKlP38rTcyo+o+Db1Ft0pzRJyZGmkGGPnCj6LxWYSmVqumLYDyqAMBDcQYuVwaKaTsJtU/2OBb3+zjKmWivV+19SXBqILvFbLv9IYLavpMr9OAwDGcJu0+mF+VCjGkZTlBxWJ53PmCoIJ6Qx/5o67LsCYL4L/hugNETlOEEKwe/k1mBraYWB0jI3mBUCV0d8J5P+ZQhwIZo4= + matrix: + - >- + POSTGRES_Skip=0 POSTGRES_Host=localhost POSTGRES_Port=5432 + POSTGRES_Username=postgres POSTGRES_Password=!Passw0rd + POSTGRES_Database=typeorm_mg POSTGRES_SSL=0 MYSQL_Skip=0 + MYSQL_Host=localhost MYSQL_Port=3306 MYSQL_Username=root + MYSQL_Password=!Passw0rd MYSQL_Database=typeorm_mg MYSQL_SSL=1 + MARIADB_Skip=0 MARIADB_Host=localhost MARIADB_Port=3307 + MARIADB_Username=root MARIADB_Password=!Passw0rd + MARIADB_Database=typeorm_mg MARIADB_SSL=0 + global: + secure: >- + Xj6wO8aghAhi6nvBI/HTtW9mIq9xfigIQfCC7ZkgAcqS4Oe3ba+7A5pCJq6Fxndadc6Bg1bZ3BGCH3Upf/Yv3zCFybsk43LwwXPJoG9gCrva/me7Sd+ws30EcD2dsKbvjZqNYai/XdrhzJY+KlxWvS/g3N/puBNffcU5hteo1zllxakQIAiavJ64D4g+Th8LSytmb2qDDToSsCxXkzNSutaKgZSf6T8QCWzcl0NCZkl69s9kX7L5335HVBD9lR/EKFC4wqHQjryCDRAyNRvItZRNlTPqgOI8lvcTsH9zKozDwEz7h/zcLebbY/+YTsLB5pb2sa62tkQE0x24TG7bLxujQShEQZU8itkRSV+w6+0JpBHQPlSUppkQJBNGKao7GaO/Eix4mSyvHkeECmTWDtEpBGWERYLqCKGe2Nj3BfcA2Ue6pjz9CX8wnrCbx53j6be3M/g/gcx7fbJbX3P95yc1CWAaR+tJKlP38rTcyo+o+Db1Ft0pzRJyZGmkGGPnCj6LxWYSmVqumLYDyqAMBDcQYuVwaKaTsJtU/2OBb3+zjKmWivV+19SXBqILvFbLv9IYLavpMr9OAwDGcJu0+mF+VCjGkZTlBxWJ53PmCoIJ6Qx/5o67LsCYL4L/hugNETlOEEKwe/k1mBraYWB0jI3mBUCV0d8J5P+ZQhwIZo4= before_install: - - sudo service mysql stop - - sudo service postgresql stop - - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" - - docker-compose up -d - - npm install -g npm@5 - - npm install -g greenkeeper-lockfile@1 - + - sudo service mysql stop + - sudo service postgresql stop + - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" + - docker-compose up -d + - npm install -g npm@5 + - npm install -g greenkeeper-lockfile@1 before_script: -- greenkeeper-lockfile-update -- npm run typings-install -- npm link typescript -- tsc + - greenkeeper-lockfile-update + - npm run typings-install + - npm link typescript + - tsc after_script: -- greenkeeper-lockfile-upload + - greenkeeper-lockfile-upload diff --git a/codecov.yml b/codecov.yml index 176f14b..d87b44e 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,14 +1,14 @@ parsers: - javascript: - enable_partials: yes + javascript: + enable_partials: yes comment: - layout: diff - behavior: default + layout: diff + behavior: default codecov: - notify: - require_ci_to_pass: no + notify: + require_ci_to_pass: no coverage: - status: - project: - default: - threshold: 5% + status: + project: + default: + threshold: 5% diff --git a/docker-compose.yml b/docker-compose.yml index 5884c91..cf9b21c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -47,4 +47,3 @@ services: # environment: # DB_SID: "ORCLCDB" # SYS_PASSWORD: "Oradoc_db1" - \ No newline at end of file diff --git a/src/Engine.ts b/src/Engine.ts index f2f8d2d..4817c7c 100644 --- a/src/Engine.ts +++ b/src/Engine.ts @@ -16,12 +16,12 @@ export class Engine { if (dbModel.entities.length > 0) { this.createModelFromMetadata(dbModel); } else { - TomgUtils.LogFatalError('Tables not found in selected database. Skipping creation of typeorm model.',false); + TomgUtils.LogFatalError('Tables not found in selected database. Skipping creation of typeorm model.', false); } return true; } - private async getEntitiesInfo(database: string, server: string, port: number, user: string, password: string, schemaName:string, ssl:boolean): Promise { - return await this.driver.GetDataFromServer(database, server, port, user, password,schemaName,ssl) + private async getEntitiesInfo(database: string, server: string, port: number, user: string, password: string, schemaName: string, ssl: boolean): Promise { + return await this.driver.GetDataFromServer(database, server, port, user, password, schemaName, ssl) } private createModelFromMetadata(databaseModel: DatabaseModel) { @@ -38,10 +38,10 @@ export class Engine { }); if (!fs.existsSync(entitesPath)) fs.mkdirSync(entitesPath); - let compliedTemplate = Handlebars.compile(template,{noEscape:true}) + let compliedTemplate = Handlebars.compile(template, { noEscape: true }) databaseModel.entities.forEach(element => { let resultFilePath = path.resolve(entitesPath, element.EntityName + '.ts'); - let rendered =compliedTemplate(element) + let rendered = compliedTemplate(element) fs.writeFileSync(resultFilePath, rendered, { encoding: 'UTF-8', flag: 'w' }) }); } @@ -83,6 +83,6 @@ export interface EngineOptions { password: string, resultsPath: string, databaseType: string, - schemaName:string, - ssl:boolean + schemaName: string, + ssl: boolean } diff --git a/src/Utils.ts b/src/Utils.ts index ae1b70d..3d34d96 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -1,12 +1,12 @@ import * as data from './../../package.json' -export function LogFatalError(errText:string, isABug:boolean=true,errObject?:any) { -let x = data; +export function LogFatalError(errText: string, isABug: boolean = true, errObject?: any) { + let x = data; console.error(`Fatal error occured.`) console.error(`${x.name}@${x.version} node@${process.version}`) console.error(`Fatal error occured in typeorm-model-generator.`) console.error(`If this is a bug please open an issue including this log on ${x.bugs.url}`) - if (isABug&&!errObject) errObject=new Error().stack - if (!!errObject) console.error(errObject) + if (isABug && !errObject) errObject = new Error().stack + if (!!errObject) console.error(errObject) process.abort() } diff --git a/src/drivers/AbstractDriver.ts b/src/drivers/AbstractDriver.ts index 707a86c..a63850c 100644 --- a/src/drivers/AbstractDriver.ts +++ b/src/drivers/AbstractDriver.ts @@ -4,22 +4,22 @@ import { DatabaseModel } from './../models/DatabaseModel' * AbstractDriver */ export abstract class AbstractDriver { - async GetDataFromServer(database: string, server: string, port: number, user: string, password: string, schema:string, ssl:boolean): Promise { + async GetDataFromServer(database: string, server: string, port: number, user: string, password: string, schema: string, ssl: boolean): Promise { let dbModel = {}; - await this.ConnectToServer(database, server, port, user, password,ssl); + await this.ConnectToServer(database, server, port, user, password, ssl); dbModel.entities = await this.GetAllTables(schema); - await this.GetCoulmnsFromEntity(dbModel.entities,schema); - await this.GetIndexesFromEntity(dbModel.entities,schema); - dbModel.entities = await this.GetRelations(dbModel.entities,schema); + await this.GetCoulmnsFromEntity(dbModel.entities, schema); + await this.GetIndexesFromEntity(dbModel.entities, schema); + dbModel.entities = await this.GetRelations(dbModel.entities, schema); await this.DisconnectFromServer(); this.FindPrimaryColumnsFromIndexes(dbModel) return dbModel; } - abstract async ConnectToServer(database: string, server: string, port: number, user: string, password: string,ssl:boolean); - abstract async GetAllTables(schema:string): Promise - abstract async GetCoulmnsFromEntity(entities: EntityInfo[],schema:string): Promise; - abstract async GetIndexesFromEntity(entities: EntityInfo[],schema:string): Promise; - abstract async GetRelations(entities: EntityInfo[],schema:string): Promise; + abstract async ConnectToServer(database: string, server: string, port: number, user: string, password: string, ssl: boolean); + abstract async GetAllTables(schema: string): Promise + abstract async GetCoulmnsFromEntity(entities: EntityInfo[], schema: string): Promise; + abstract async GetIndexesFromEntity(entities: EntityInfo[], schema: string): Promise; + abstract async GetRelations(entities: EntityInfo[], schema: string): Promise; abstract async FindPrimaryColumnsFromIndexes(dbModel: DatabaseModel); abstract async DisconnectFromServer(); @@ -27,4 +27,4 @@ export abstract class AbstractDriver { abstract async DropDB(dbName: string); abstract async UseDB(dbName: string); abstract async CheckIfDBExists(dbName: string): Promise; -} \ No newline at end of file +} diff --git a/src/drivers/MariaDbDriver.ts b/src/drivers/MariaDbDriver.ts index 3595d97..db75c97 100644 --- a/src/drivers/MariaDbDriver.ts +++ b/src/drivers/MariaDbDriver.ts @@ -9,6 +9,6 @@ import { MysqlDriver } from './MysqlDriver'; * MariaDb */ export class MariaDbDriver extends MysqlDriver { - readonly EngineName:string = 'MariaDb' - -} \ No newline at end of file + readonly EngineName: string = 'MariaDb' + +} diff --git a/src/drivers/MssqlDriver.ts b/src/drivers/MssqlDriver.ts index 06c8fe1..488beaf 100644 --- a/src/drivers/MssqlDriver.ts +++ b/src/drivers/MssqlDriver.ts @@ -14,7 +14,7 @@ export class MssqlDriver extends AbstractDriver { dbModel.entities.forEach(entity => { let primaryIndex = entity.Indexes.find(v => v.isPrimaryKey); if (!primaryIndex) { - TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`,false) + TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`, false) return; } entity.Columns.forEach(col => { @@ -361,15 +361,15 @@ order by isOneToMany = false; } let ownerRelation = new RelationInfo() - let columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '') + let columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '') if (referencedEntity.Columns.filter((filterVal) => { return filterVal.name == columnName; - }).length>0){ - for (let i=2;i<=ownerEntity.Columns.length;i++){ - columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '')+i.toString(); + }).length > 0) { + for (let i = 2; i <= ownerEntity.Columns.length; i++) { + columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '') + i.toString(); if (referencedEntity.Columns.filter((filterVal) => { return filterVal.name == columnName; - }).length==0) break; + }).length == 0) break; } } ownerRelation.actionOnDelete = relationTmp.actionOnDelete @@ -442,7 +442,7 @@ order by resolve(true) } else { - TomgUtils.LogFatalError('Error connecting to MSSQL Server.',false,err.message) + TomgUtils.LogFatalError('Error connecting to MSSQL Server.', false, err.message) reject(err) } }); diff --git a/src/drivers/MysqlDriver.ts b/src/drivers/MysqlDriver.ts index 92aca50..9e370c5 100644 --- a/src/drivers/MysqlDriver.ts +++ b/src/drivers/MysqlDriver.ts @@ -15,7 +15,7 @@ export class MysqlDriver extends AbstractDriver { dbModel.entities.forEach(entity => { let primaryIndex = entity.Indexes.find(v => v.isPrimaryKey); if (!primaryIndex) { - TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`,false) + TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`, false) return; } entity.Columns.forEach(col => { @@ -334,7 +334,7 @@ export class MysqlDriver extends AbstractDriver { if (referencedEntity.Columns.filter((filterVal) => { return filterVal.name == columnName; }).length > 0) { - for (let i=2;i<=ownerEntity.Columns.length;i++){ + for (let i = 2; i <= ownerEntity.Columns.length; i++) { columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '') + i.toString(); if (referencedEntity.Columns.filter((filterVal) => { return filterVal.name == columnName; @@ -392,7 +392,7 @@ export class MysqlDriver extends AbstractDriver { resolve(true) } else { - TomgUtils.LogFatalError(`Error disconnecting to ${this.EngineName} Server.`,false,err.message) + TomgUtils.LogFatalError(`Error disconnecting to ${this.EngineName} Server.`, false, err.message) reject(err) } }); @@ -439,7 +439,7 @@ export class MysqlDriver extends AbstractDriver { resolve(true) } else { - TomgUtils.LogFatalError(`Error connecting to ${this.EngineName} Server.`,false,err.message) + TomgUtils.LogFatalError(`Error connecting to ${this.EngineName} Server.`, false, err.message) reject(err) } }); diff --git a/src/drivers/OracleDriver.ts b/src/drivers/OracleDriver.ts index 73ee5b5..b0f8d34 100644 --- a/src/drivers/OracleDriver.ts +++ b/src/drivers/OracleDriver.ts @@ -3,7 +3,7 @@ import { ColumnInfo } from './../models/ColumnInfo' import { EntityInfo } from './../models/EntityInfo' import { RelationInfo } from './../models/RelationInfo' import { DatabaseModel } from './../models/DatabaseModel' -import {promisify} from 'util' +import { promisify } from 'util' import { request } from 'https'; import * as TomgUtils from './../Utils' @@ -11,14 +11,14 @@ import * as TomgUtils from './../Utils' /** * OracleDriver */ - export class OracleDriver extends AbstractDriver { - Oracle:any; +export class OracleDriver extends AbstractDriver { + Oracle: any; constructor() { super(); try { - this.Oracle= require('oracledb') + this.Oracle = require('oracledb') } catch (error) { - TomgUtils.LogFatalError('',false,error); + TomgUtils.LogFatalError('', false, error); throw error; } @@ -29,7 +29,7 @@ import * as TomgUtils from './../Utils' dbModel.entities.forEach(entity => { let primaryIndex = entity.Indexes.find(v => v.isPrimaryKey); if (!primaryIndex) { - TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`,false) + TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`, false) return; } entity.Columns.forEach(col => { @@ -43,7 +43,7 @@ import * as TomgUtils from './../Utils' async GetAllTables(schema: string): Promise { - let response :any[][] = ( await this.Connection.execute(` SELECT TABLE_NAME FROM all_tables WHERE owner = (select user from dual)`)).rows!; + let response: any[][] = (await this.Connection.execute(` SELECT TABLE_NAME FROM all_tables WHERE owner = (select user from dual)`)).rows!; let ret: EntityInfo[] = []; response.forEach((val) => { let ent: EntityInfo = new EntityInfo(); @@ -55,11 +55,11 @@ import * as TomgUtils from './../Utils' return ret; } async GetCoulmnsFromEntity(entities: EntityInfo[], schema: string): Promise { - let response :any[][] = ( await this.Connection.execute(`SELECT TABLE_NAME, COLUMN_NAME, DATA_DEFAULT, NULLABLE, DATA_TYPE, DATA_LENGTH, + let response: any[][] = (await this.Connection.execute(`SELECT TABLE_NAME, COLUMN_NAME, DATA_DEFAULT, NULLABLE, DATA_TYPE, DATA_LENGTH, DATA_PRECISION, DATA_SCALE, IDENTITY_COLUMN FROM USER_TAB_COLUMNS`)).rows!; - entities.forEach((ent) => { + entities.forEach((ent) => { response.filter((filterVal) => { return filterVal[0] == ent.EntityName; }).forEach((resp) => { @@ -90,7 +90,7 @@ import * as TomgUtils from './../Utils' return entities; } async GetIndexesFromEntity(entities: EntityInfo[], schema: string): Promise { - let response :any[][] = ( await this.Connection.execute(`SELECT ind.TABLE_NAME, ind.INDEX_NAME, col.COLUMN_NAME,ind.UNIQUENESS, CASE WHEN uc.CONSTRAINT_NAME IS NULL THEN 0 ELSE 1 END + let response: any[][] = (await this.Connection.execute(`SELECT ind.TABLE_NAME, ind.INDEX_NAME, col.COLUMN_NAME,ind.UNIQUENESS, CASE WHEN uc.CONSTRAINT_NAME IS NULL THEN 0 ELSE 1 END FROM USER_INDEXES ind JOIN USER_IND_COLUMNS col ON ind.INDEX_NAME=col.INDEX_NAME LEFT JOIN USER_CONSTRAINTS uc ON uc.INDEX_NAME = ind.INDEX_NAME @@ -126,7 +126,7 @@ import * as TomgUtils from './../Utils' return entities; } async GetRelations(entities: EntityInfo[], schema: string): Promise { - let response :any[][] = ( await this.Connection.execute(`select owner.TABLE_NAME ownTbl,ownCol.POSITION,ownCol.COLUMN_NAME, + let response: any[][] = (await this.Connection.execute(`select owner.TABLE_NAME ownTbl,ownCol.POSITION,ownCol.COLUMN_NAME, child.TABLE_NAME,childCol.COLUMN_NAME, owner.DELETE_RULE, 4,owner.CONSTRAINT_NAME @@ -261,28 +261,28 @@ import * as TomgUtils from './../Utils' private Connection: any/*Oracle.IConnection*/; async ConnectToServer(database: string, server: string, port: number, user: string, password: string, ssl: boolean) { - let config: any/*Oracle.IConnectionAttributes*/ = { + let config: any/*Oracle.IConnectionAttributes*/ = { user: user, password: password, // connectString: `${server}:${port}/ORCLCDB.localdomain/${database}`, connectString: `${server}:${port}/${database}`, - externalAuth: ssl + externalAuth: ssl } - let that=this; + let that = this; let promise = new Promise( (resolve, reject) => { - this.Oracle.getConnection( + this.Oracle.getConnection( config, function (err, connection) { if (!err) { //Connection successfull - that.Connection=connection + that.Connection = connection resolve(true) } else { - TomgUtils.LogFatalError('Error connecting to Oracle Server.',false,err.message) + TomgUtils.LogFatalError('Error connecting to Oracle Server.', false, err.message) reject(err) } diff --git a/src/drivers/PostgresDriver.ts b/src/drivers/PostgresDriver.ts index f3bc2ed..d205d53 100644 --- a/src/drivers/PostgresDriver.ts +++ b/src/drivers/PostgresDriver.ts @@ -15,7 +15,7 @@ export class PostgresDriver extends AbstractDriver { dbModel.entities.forEach(entity => { let primaryIndex = entity.Indexes.find(v => v.isPrimaryKey); if (!primaryIndex) { - TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`,false) + TomgUtils.LogFatalError(`Table ${entity.EntityName} has no PK.`, false) return; } entity.Columns.forEach(col => { @@ -389,15 +389,15 @@ export class PostgresDriver extends AbstractDriver { isOneToMany = false; } let ownerRelation = new RelationInfo() - let columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '') + let columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '') if (referencedEntity.Columns.filter((filterVal) => { return filterVal.name == columnName; - }).length>0){ - for (let i=2;i<=ownerEntity.Columns.length;i++){ - columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '')+i.toString(); + }).length > 0) { + for (let i = 2; i <= ownerEntity.Columns.length; i++) { + columnName = ownerEntity.EntityName.toLowerCase() + (isOneToMany ? 's' : '') + i.toString(); if (referencedEntity.Columns.filter((filterVal) => { return filterVal.name == columnName; - }).length==0) break; + }).length == 0) break; } } ownerRelation.actionOnDelete = relationTmp.actionOnDelete @@ -452,7 +452,7 @@ export class PostgresDriver extends AbstractDriver { resolve(true) } else { - TomgUtils.LogFatalError('Error connecting to Postgres Server.',false,err.message) + TomgUtils.LogFatalError('Error connecting to Postgres Server.', false, err.message) reject(err) } }); @@ -480,7 +480,7 @@ export class PostgresDriver extends AbstractDriver { resolve(true) } else { - TomgUtils.LogFatalError('Error connecting to Postgres Server.',false,err.message) + TomgUtils.LogFatalError('Error connecting to Postgres Server.', false, err.message) reject(err) } }); diff --git a/src/index.ts b/src/index.ts index 4cb9518..ca61eb8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -86,7 +86,7 @@ switch (argv.e) { standardPort = 1521; break; default: - TomgUtils.LogFatalError('Database engine not recognized.',false) + TomgUtils.LogFatalError('Database engine not recognized.', false) throw new Error('Database engine not recognized.'); } @@ -107,4 +107,3 @@ console.log(`[${new Date().toLocaleTimeString()}] Starting creation of model cla engine.createModelFromDatabase().then(() => { console.info(`[${new Date().toLocaleTimeString()}] Typeorm model classes created.`) }) - diff --git a/src/models/ColumnInfo.ts b/src/models/ColumnInfo.ts index 3c241c2..97997e5 100644 --- a/src/models/ColumnInfo.ts +++ b/src/models/ColumnInfo.ts @@ -22,5 +22,3 @@ export class ColumnInfo { } } - - diff --git a/src/models/DatabaseModel.ts b/src/models/DatabaseModel.ts index c05eaff..411534e 100644 --- a/src/models/DatabaseModel.ts +++ b/src/models/DatabaseModel.ts @@ -1,4 +1,4 @@ -import {EntityInfo} from './EntityInfo' +import { EntityInfo } from './EntityInfo' export class DatabaseModel { entities: EntityInfo[]; config: { @@ -6,11 +6,11 @@ export class DatabaseModel { cascadeUpdate: boolean, cascadeRemove: boolean, } - relationImports():any{ - let that=this; - return function(text, render) { - if ('l'!=render(text)) return `import {${render(text)}} from "./${render(text)}"` - else return ''; + relationImports(): any { + let that = this; + return function (text, render) { + if ('l' != render(text)) return `import {${render(text)}} from "./${render(text)}"` + else return ''; + } } - } -} \ No newline at end of file +} diff --git a/src/models/EntityInfo.ts b/src/models/EntityInfo.ts index 68c4a3a..f3fe230 100644 --- a/src/models/EntityInfo.ts +++ b/src/models/EntityInfo.ts @@ -8,23 +8,23 @@ export class EntityInfo { Indexes: IndexInfo[]; relationImports(): any { - var returnString = ""; - var imports: string[] = []; - this.Columns.forEach((column) => { - column.relations.forEach( - (relation) => { - if (this.EntityName!=relation.relatedTable) + var returnString = ""; + var imports: string[] = []; + this.Columns.forEach((column) => { + column.relations.forEach( + (relation) => { + if (this.EntityName != relation.relatedTable) imports.push(relation.relatedTable); - } - ) - }); - imports.filter(function (elem, index, self) { - return index == self.indexOf(elem); - }).forEach((imp)=>{ - returnString+=`import {${imp}} from './${imp}'\n` - }) + } + ) + }); + imports.filter(function (elem, index, self) { + return index == self.indexOf(elem); + }).forEach((imp) => { + returnString += `import {${imp}} from './${imp}'\n` + }) - return returnString; + return returnString; } - -} \ No newline at end of file + +} diff --git a/src/models/IndexColumnInfo.ts b/src/models/IndexColumnInfo.ts index 1d9e579..5513189 100644 --- a/src/models/IndexColumnInfo.ts +++ b/src/models/IndexColumnInfo.ts @@ -1,5 +1,5 @@ -interface IndexColumnInfo{ - name:string, +interface IndexColumnInfo { + name: string, //isDescending:boolean, // isIncludedColumn:boolean -} \ No newline at end of file +} diff --git a/src/models/IndexInfo.ts b/src/models/IndexInfo.ts index ea9b74a..3fc7540 100644 --- a/src/models/IndexInfo.ts +++ b/src/models/IndexInfo.ts @@ -2,8 +2,8 @@ * IndexInfo */ interface IndexInfo { - name:string, - columns:IndexColumnInfo[], - isUnique:boolean, - isPrimaryKey:boolean, + name: string, + columns: IndexColumnInfo[], + isUnique: boolean, + isPrimaryKey: boolean, } diff --git a/src/models/RelationInfo.ts b/src/models/RelationInfo.ts index eb7d0b7..f68ffce 100644 --- a/src/models/RelationInfo.ts +++ b/src/models/RelationInfo.ts @@ -1,4 +1,5 @@ -export class RelationInfo { [x: string]: any; +export class RelationInfo { + [x: string]: any; isOwner: boolean relationType: "OneToOne" | "OneToMany" | "ManyToOne" @@ -13,4 +14,4 @@ export class RelationInfo { [x: string]: any; return this.relationType == "OneToMany" } -} \ No newline at end of file +} diff --git a/src/models/RelationTempInfo.ts b/src/models/RelationTempInfo.ts index 0837f6e..94a82ec 100644 --- a/src/models/RelationTempInfo.ts +++ b/src/models/RelationTempInfo.ts @@ -1,9 +1,9 @@ -interface RelationTempInfo{ - ownerTable:string, - ownerColumnsNames:string[], - referencedTable:string, - referencedColumnsNames:string[], - actionOnDelete:"RESTRICT"|"CASCADE"|"SET NULL"|"NO ACTION", - actionOnUpdate:"RESTRICT"|"CASCADE"|"SET NULL"|"NO ACTION", - object_id:number|string -} \ No newline at end of file +interface RelationTempInfo { + ownerTable: string, + ownerColumnsNames: string[], + referencedTable: string, + referencedColumnsNames: string[], + actionOnDelete: "RESTRICT" | "CASCADE" | "SET NULL" | "NO ACTION", + actionOnUpdate: "RESTRICT" | "CASCADE" | "SET NULL" | "NO ACTION", + object_id: number | string +} diff --git a/test/drivers/MssqlDriver.test.ts b/test/drivers/MssqlDriver.test.ts index bbcb22a..70a547f 100644 --- a/test/drivers/MssqlDriver.test.ts +++ b/test/drivers/MssqlDriver.test.ts @@ -7,19 +7,19 @@ import { ColumnInfo } from './../../src/models/ColumnInfo' import { RelationInfo } from './../../src/models/RelationInfo' import { Table, IColumnMetadata } from "mssql"; - class fakeResponse implements MSSQL.IResult { - recordsets: MSSQL.IRecordSet[]; - recordset: MSSQL.IRecordSet; - rowsAffected: number[]; - output: { [key: string]: any; }; - - } - class fakeRecordset extends Array implements MSSQL.IRecordSet{ +class fakeResponse implements MSSQL.IResult { + recordsets: MSSQL.IRecordSet[]; + recordset: MSSQL.IRecordSet; + rowsAffected: number[]; + output: { [key: string]: any; }; + +} +class fakeRecordset extends Array implements MSSQL.IRecordSet{ columns: IColumnMetadata; - toTable(): Table{ + toTable(): Table { return new Table(); } - } +} describe('MssqlDriver', function () { let driver: MssqlDriver @@ -48,10 +48,10 @@ describe('MssqlDriver', function () { .returns( { query: (q) => { - - let response=new fakeResponse(); - - response.recordset=new fakeRecordset(); + + let response = new fakeResponse(); + + response.recordset = new fakeRecordset(); response.recordset.push({ TABLE_SCHEMA: 'schema', TABLE_NAME: 'name' }) return response; } @@ -71,13 +71,13 @@ describe('MssqlDriver', function () { .returns( { query: (q) => { - let response=new fakeResponse(); - response.recordset=new fakeRecordset(); + let response = new fakeResponse(); + response.recordset = new fakeRecordset(); response.recordset.push({ TABLE_NAME: 'name', CHARACTER_MAXIMUM_LENGTH: 0, COLUMN_DEFAULT: 'a', COLUMN_NAME: 'name', DATA_TYPE: 'int', IS_NULLABLE: 'YES', NUMERIC_PRECISION: 0, NUMERIC_SCALE: 0, - IsIdentity:1 + IsIdentity: 1 }) return response; } @@ -97,7 +97,7 @@ describe('MssqlDriver', function () { default: 'a', is_nullable: true, isPrimary: false, - is_generated:true, + is_generated: true, name: 'name', numericPrecision: null, numericScale: null, @@ -105,10 +105,10 @@ describe('MssqlDriver', function () { ts_type: 'number', relations: [] }) - let result = await driver.GetCoulmnsFromEntity(entities,'schema'); + let result = await driver.GetCoulmnsFromEntity(entities, 'schema'); expect(result).to.be.deep.equal(expected) }) it('should find primary indexes') it('should get indexes info') it('should get relations info') -}) \ No newline at end of file +}) diff --git a/test/integration/entityTypes/mariadb/entity/Post.ts b/test/integration/entityTypes/mariadb/entity/Post.ts index 2b25f57..61d4028 100644 --- a/test/integration/entityTypes/mariadb/entity/Post.ts +++ b/test/integration/entityTypes/mariadb/entity/Post.ts @@ -91,4 +91,4 @@ export class Post { // @Column("simple-array") // simpleArray: string[]; -} \ No newline at end of file +} diff --git a/test/integration/entityTypes/mssql/entity/Post.ts b/test/integration/entityTypes/mssql/entity/Post.ts index 43b4c19..39311cf 100644 --- a/test/integration/entityTypes/mssql/entity/Post.ts +++ b/test/integration/entityTypes/mssql/entity/Post.ts @@ -118,4 +118,4 @@ export class Post { // @Column("simple-array") // simpleArray: string[]; -} \ No newline at end of file +} diff --git a/test/integration/entityTypes/mysql/entity/Post.ts b/test/integration/entityTypes/mysql/entity/Post.ts index 8149e01..16a217e 100644 --- a/test/integration/entityTypes/mysql/entity/Post.ts +++ b/test/integration/entityTypes/mysql/entity/Post.ts @@ -90,4 +90,4 @@ export class Post { // @Column("simple-array") // simpleArray: string[]; -} \ No newline at end of file +} diff --git a/test/integration/entityTypes/postgres/entity/Post.ts b/test/integration/entityTypes/postgres/entity/Post.ts index 9acf3ea..fb81185 100644 --- a/test/integration/entityTypes/postgres/entity/Post.ts +++ b/test/integration/entityTypes/postgres/entity/Post.ts @@ -237,4 +237,4 @@ export class Post { // @Column("simple-array") // simpleArray: string[]; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample1-simple-entity/entity/Post.ts b/test/integration/examples/sample1-simple-entity/entity/Post.ts index 6c208ff..acc4bc1 100644 --- a/test/integration/examples/sample1-simple-entity/entity/Post.ts +++ b/test/integration/examples/sample1-simple-entity/entity/Post.ts @@ -1,4 +1,4 @@ -import {Column, Entity,PrimaryGeneratedColumn,Index,Generated} from "typeorm"; +import { Column, Entity, PrimaryGeneratedColumn, Index, Generated } from "typeorm"; @Entity("Post") export class Post { @@ -17,4 +17,4 @@ export class Post { }) likesCount: number; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample11-all-types-entity/entity/EverythingEntity.ts b/test/integration/examples/sample11-all-types-entity/entity/EverythingEntity.ts index a2eb712..a627625 100644 --- a/test/integration/examples/sample11-all-types-entity/entity/EverythingEntity.ts +++ b/test/integration/examples/sample11-all-types-entity/entity/EverythingEntity.ts @@ -2,7 +2,7 @@ import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn, Index } f @Entity("EverythingEntity") export class EverythingEntity { - //TODO: change to check column types per database engine + //TODO: change to check column types per database engine @PrimaryGeneratedColumn() id: number; @@ -69,4 +69,4 @@ export class EverythingEntity { // @UpdateDateColumn() // updatedDate: Date; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample16-indexes/entity/Post.ts b/test/integration/examples/sample16-indexes/entity/Post.ts index 531fcfa..cf25a35 100644 --- a/test/integration/examples/sample16-indexes/entity/Post.ts +++ b/test/integration/examples/sample16-indexes/entity/Post.ts @@ -1,8 +1,8 @@ -import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm" +import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm" @Entity("Post") -@Index("my_index_with_id_and_text", ["id", "text"], {unique:true}) -@Index("my_index_with_id_and_title", (post: Post) => [post.id, post.title], {unique:true}) +@Index("my_index_with_id_and_text", ["id", "text"], { unique: true }) +@Index("my_index_with_id_and_title", (post: Post) => [post.id, post.title], { unique: true }) export class Post { @PrimaryGeneratedColumn() @@ -23,4 +23,4 @@ export class Post { @Index() likesCount: number; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample17-versioning/entity/Post.ts b/test/integration/examples/sample17-versioning/entity/Post.ts index 60b8d24..e9f1bc1 100644 --- a/test/integration/examples/sample17-versioning/entity/Post.ts +++ b/test/integration/examples/sample17-versioning/entity/Post.ts @@ -1,4 +1,4 @@ -import { Column, Entity, Index, PrimaryGeneratedColumn, VersionColumn } from "typeorm" +import { Column, Entity, Index, PrimaryGeneratedColumn, VersionColumn } from "typeorm" @Entity("Post") export class Post { @@ -14,5 +14,5 @@ export class Post { @VersionColumn() version: number; - -} \ No newline at end of file + +} diff --git a/test/integration/examples/sample2-one-to-one/entity/Post.ts b/test/integration/examples/sample2-one-to-one/entity/Post.ts index cec9818..f715c0a 100644 --- a/test/integration/examples/sample2-one-to-one/entity/Post.ts +++ b/test/integration/examples/sample2-one-to-one/entity/Post.ts @@ -27,7 +27,7 @@ export class Post { @Index({ unique: true }) category: PostCategory; - // post has relation with details. cascade inserts here means if new PostDetails instance will be set to this + // post has relation with details. cascade inserts here means if new PostDetails instance will be set to this // relation it will be inserted automatically to the db when you save this Post entity @OneToOne(type => PostDetails, details => details.post, { cascade: true @@ -69,4 +69,4 @@ export class Post { @Index({ unique: true }) author: PostAuthor; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample2-one-to-one/entity/PostAuthor.ts b/test/integration/examples/sample2-one-to-one/entity/PostAuthor.ts index 9dfb66e..d80d803 100644 --- a/test/integration/examples/sample2-one-to-one/entity/PostAuthor.ts +++ b/test/integration/examples/sample2-one-to-one/entity/PostAuthor.ts @@ -1,5 +1,5 @@ -import {PrimaryGeneratedColumn, Column, Entity, OneToOne,JoinColumn} from "typeorm"; -import {Post} from "./Post"; +import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn } from "typeorm"; +import { Post } from "./Post"; @Entity("PostAuthor") export class PostAuthor { @@ -13,4 +13,4 @@ export class PostAuthor { @OneToOne(type => Post, post => post.author) post: Post; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample2-one-to-one/entity/PostCategory.ts b/test/integration/examples/sample2-one-to-one/entity/PostCategory.ts index 6b302b0..c7b2311 100644 --- a/test/integration/examples/sample2-one-to-one/entity/PostCategory.ts +++ b/test/integration/examples/sample2-one-to-one/entity/PostCategory.ts @@ -1,4 +1,4 @@ -import {PrimaryGeneratedColumn, Column, Entity, OneToOne,JoinColumn} from "typeorm"; +import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn } from "typeorm"; @Entity("PostCategory") export class PostCategory { @@ -9,4 +9,4 @@ export class PostCategory { @Column() name: string; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample2-one-to-one/entity/PostDetails.ts b/test/integration/examples/sample2-one-to-one/entity/PostDetails.ts index 917af60..b68e075 100644 --- a/test/integration/examples/sample2-one-to-one/entity/PostDetails.ts +++ b/test/integration/examples/sample2-one-to-one/entity/PostDetails.ts @@ -22,4 +22,4 @@ export class PostDetails { }) post: Post; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample2-one-to-one/entity/PostImage.ts b/test/integration/examples/sample2-one-to-one/entity/PostImage.ts index afea4c8..6e71d4e 100644 --- a/test/integration/examples/sample2-one-to-one/entity/PostImage.ts +++ b/test/integration/examples/sample2-one-to-one/entity/PostImage.ts @@ -1,5 +1,5 @@ -import {PrimaryGeneratedColumn, Column, Entity, OneToOne,JoinColumn} from "typeorm"; -import {Post} from "./Post"; +import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn } from "typeorm"; +import { Post } from "./Post"; @Entity("PostImage") export class PostImage { @@ -13,4 +13,4 @@ export class PostImage { @OneToOne(type => Post, post => post.image) post: Post; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample2-one-to-one/entity/PostInformation.ts b/test/integration/examples/sample2-one-to-one/entity/PostInformation.ts index 0673ca4..f71ef43 100644 --- a/test/integration/examples/sample2-one-to-one/entity/PostInformation.ts +++ b/test/integration/examples/sample2-one-to-one/entity/PostInformation.ts @@ -13,4 +13,4 @@ export class PostInformation { @OneToOne(type => Post, post => post.information) post: Post; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample2-one-to-one/entity/PostMetadata.ts b/test/integration/examples/sample2-one-to-one/entity/PostMetadata.ts index c2f75d1..da7eee3 100644 --- a/test/integration/examples/sample2-one-to-one/entity/PostMetadata.ts +++ b/test/integration/examples/sample2-one-to-one/entity/PostMetadata.ts @@ -1,5 +1,5 @@ -import {PrimaryGeneratedColumn, Column, Entity, OneToOne,JoinColumn} from "typeorm"; -import {Post} from "./Post"; +import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn } from "typeorm"; +import { Post } from "./Post"; @Entity("PostMetadata") export class PostMetadata { @@ -13,4 +13,4 @@ export class PostMetadata { @OneToOne(type => Post, post => post.metadata) post: Post; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample27-composite-primary-keys/entity/Post.ts b/test/integration/examples/sample27-composite-primary-keys/entity/Post.ts index 26d9d80..6e716e5 100644 --- a/test/integration/examples/sample27-composite-primary-keys/entity/Post.ts +++ b/test/integration/examples/sample27-composite-primary-keys/entity/Post.ts @@ -1,4 +1,4 @@ -import {Column, Entity, PrimaryColumn} from "typeorm"; +import { Column, Entity, PrimaryColumn } from "typeorm"; @Entity("Post") export class Post { @@ -12,4 +12,4 @@ export class Post { @Column() text: string; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample3-many-to-one/entity/Post.ts b/test/integration/examples/sample3-many-to-one/entity/Post.ts index 36b60ea..4505194 100644 --- a/test/integration/examples/sample3-many-to-one/entity/Post.ts +++ b/test/integration/examples/sample3-many-to-one/entity/Post.ts @@ -25,7 +25,7 @@ export class Post { }) category: PostCategory; - // post has relation with details. cascade inserts here means if new PostDetails instance will be set to this + // post has relation with details. cascade inserts here means if new PostDetails instance will be set to this // relation it will be inserted automatically to the db when you save this Post entity @ManyToOne(type => PostDetails, details => details.posts, { cascade: true, @@ -57,4 +57,4 @@ export class Post { @ManyToOne(type => PostAuthor, author => author.posts) author: PostAuthor; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample3-many-to-one/entity/PostAuthor.ts b/test/integration/examples/sample3-many-to-one/entity/PostAuthor.ts index 90b0d38..bc8b77e 100644 --- a/test/integration/examples/sample3-many-to-one/entity/PostAuthor.ts +++ b/test/integration/examples/sample3-many-to-one/entity/PostAuthor.ts @@ -1,5 +1,5 @@ import { PrimaryGeneratedColumn, Column, Entity, OneToOne, OneToMany, ManyToOne, JoinColumn } from "typeorm"; -import {Post} from "./Post"; +import { Post } from "./Post"; @Entity("PostAuthor") export class PostAuthor { @@ -13,4 +13,4 @@ export class PostAuthor { @OneToMany(type => Post, post => post.author) posts: Post[]; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample3-many-to-one/entity/PostCategory.ts b/test/integration/examples/sample3-many-to-one/entity/PostCategory.ts index bae28e4..c92df8f 100644 --- a/test/integration/examples/sample3-many-to-one/entity/PostCategory.ts +++ b/test/integration/examples/sample3-many-to-one/entity/PostCategory.ts @@ -9,4 +9,4 @@ export class PostCategory { @Column() name: string; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample3-many-to-one/entity/PostDetails.ts b/test/integration/examples/sample3-many-to-one/entity/PostDetails.ts index 4cf9d2c..3c1a2f6 100644 --- a/test/integration/examples/sample3-many-to-one/entity/PostDetails.ts +++ b/test/integration/examples/sample3-many-to-one/entity/PostDetails.ts @@ -25,4 +25,4 @@ export class PostDetails { @OneToMany(type => Post, post => post.details) posts: Post[]; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample3-many-to-one/entity/PostImage.ts b/test/integration/examples/sample3-many-to-one/entity/PostImage.ts index 2965712..dad410d 100644 --- a/test/integration/examples/sample3-many-to-one/entity/PostImage.ts +++ b/test/integration/examples/sample3-many-to-one/entity/PostImage.ts @@ -13,4 +13,4 @@ export class PostImage { @OneToMany(type => Post, post => post.image) posts: Post[]; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample3-many-to-one/entity/PostInformation.ts b/test/integration/examples/sample3-many-to-one/entity/PostInformation.ts index def7ca5..5e427e3 100644 --- a/test/integration/examples/sample3-many-to-one/entity/PostInformation.ts +++ b/test/integration/examples/sample3-many-to-one/entity/PostInformation.ts @@ -13,4 +13,4 @@ export class PostInformation { @OneToMany(type => Post, post => post.information) posts: Post[]; -} \ No newline at end of file +} diff --git a/test/integration/examples/sample3-many-to-one/entity/PostMetadata.ts b/test/integration/examples/sample3-many-to-one/entity/PostMetadata.ts index ce724db..3b2fb19 100644 --- a/test/integration/examples/sample3-many-to-one/entity/PostMetadata.ts +++ b/test/integration/examples/sample3-many-to-one/entity/PostMetadata.ts @@ -1,5 +1,5 @@ import { PrimaryGeneratedColumn, Column, Entity, OneToOne, OneToMany, ManyToOne, JoinColumn } from "typeorm"; -import {Post} from "./Post"; +import { Post } from "./Post"; @Entity("PostMetadata") export class PostMetadata { @@ -13,4 +13,4 @@ export class PostMetadata { @OneToMany(type => Post, post => post.metadata) posts: Post[]; -} \ No newline at end of file +} diff --git a/test/integration/github-issues/12/entity/Post.ts b/test/integration/github-issues/12/entity/Post.ts index 79d2472..3a94f13 100644 --- a/test/integration/github-issues/12/entity/Post.ts +++ b/test/integration/github-issues/12/entity/Post.ts @@ -13,4 +13,4 @@ export class Post { @ManyToOne(type => PostAuthor, author => author.posts2) author2: PostAuthor; -} \ No newline at end of file +} diff --git a/test/integration/github-issues/12/entity/PostAuthor.ts b/test/integration/github-issues/12/entity/PostAuthor.ts index 9d5a433..d203269 100644 --- a/test/integration/github-issues/12/entity/PostAuthor.ts +++ b/test/integration/github-issues/12/entity/PostAuthor.ts @@ -13,4 +13,4 @@ export class PostAuthor { @OneToMany(type => Post, post => post.author2) posts2: Post[]; -} \ No newline at end of file +} diff --git a/test/integration/integration.test.ts b/test/integration/integration.test.ts index fe0619b..fe7c24f 100644 --- a/test/integration/integration.test.ts +++ b/test/integration/integration.test.ts @@ -53,10 +53,10 @@ describe("TypeOrm examples", async function () { case 'mysql': engine = await GTU.createMysqlModels(filesOrgPathJS, resultsPath) break; - case 'mariadb': + case 'mariadb': engine = await GTU.createMariaDBModels(filesOrgPathJS, resultsPath) break; - case 'oracle': + case 'oracle': engine = await GTU.createOracleDBModels(filesOrgPathJS, resultsPath) break; diff --git a/test/utils/EntityFileToJson.ts b/test/utils/EntityFileToJson.ts index 9ea6b4f..22f9a42 100644 --- a/test/utils/EntityFileToJson.ts +++ b/test/utils/EntityFileToJson.ts @@ -21,7 +21,7 @@ export class EntityFileToJson { // if (!x.endsWith('[]')) { // x = x + '[]'// can't distinguish OneTwoMany from OneToOne without indexes // } - x=x.trim(); + x = x.trim(); return x; }); } else { @@ -93,7 +93,7 @@ export class EntityFileToJson { for (let line of lines) { let trimmedLine = line.trim(); if (trimmedLine.startsWith('//')) { - continue; //commented line + continue; //commented line } if (isMultilineStatement) trimmedLine = priorPartOfMultilineStatement + ' ' + trimmedLine @@ -102,7 +102,7 @@ export class EntityFileToJson { else if (!isInClassBody) { if (trimmedLine.startsWith('import')) { - continue; //import statement is not part of entity definition + continue; //import statement is not part of entity definition } else if (trimmedLine.startsWith('@Entity')) { continue; //TODO:entity options } else if (trimmedLine.startsWith('export class')) { @@ -244,7 +244,7 @@ export class EntityFileToJson { // if (!x.endsWith('[]')) { // x = x + '[]'// can't distinguish OneTwoMany from OneToOne without indexes // } - x=x.trim(); + x = x.trim(); return x; }); @@ -274,15 +274,15 @@ export class EntityFileToJson { console.log(`${trimmedLine}`) } - retVal.columns=retVal.columns.map(col=>{ + retVal.columns = retVal.columns.map(col => { if (col.columnName.endsWith('Id')) - col.columnName=col.columnName.substr(0,col.columnName.length-2) + col.columnName = col.columnName.substr(0, col.columnName.length - 2) return col; }) - retVal.indicies=retVal.indicies.map(ind=>{ - ind.columnNames=ind.columnNames.map(colName=>{ + retVal.indicies = retVal.indicies.map(ind => { + ind.columnNames = ind.columnNames.map(colName => { if (colName.endsWith('Id')) - colName=colName.substr(0,colName.length-2) + colName = colName.substr(0, colName.length - 2) return colName; }) return ind; @@ -314,4 +314,4 @@ class EntityIndex { indexName: string columnNames: string[] = [] isUnique: boolean = false -} \ No newline at end of file +} diff --git a/test/utils/GeneralTestUtils.ts b/test/utils/GeneralTestUtils.ts index 65e5fdb..68a88ad 100644 --- a/test/utils/GeneralTestUtils.ts +++ b/test/utils/GeneralTestUtils.ts @@ -250,4 +250,4 @@ export function compileTsFiles(fileNames: string[], options: ts.CompilerOptions) }); return compileErrors; -} \ No newline at end of file +} diff --git a/tsconfig.json b/tsconfig.json index 09773a7..d8e44e0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,8 +14,9 @@ "moduleResolution": "node", "outDir": "dist", "newLine": "LF" - }, "include": [ + }, + "include": [ "src", "test" ] -} \ No newline at end of file +} diff --git a/typings.json b/typings.json index 82bf57c..91fce6a 100644 --- a/typings.json +++ b/typings.json @@ -1,10 +1,10 @@ { - "globalDevDependencies": { - "mustache": "registry:dt/mustache#0.8.2+20160510002910" - }, - "dependencies": { - "mssql": "registry:dt/mssql#3.3.0+20170311011547", - "yargs": "registry:npm/yargs#5.0.0+20160907000723", - "yn": "registry:npm/yn#1.3.0+20170508185912" - } + "globalDevDependencies": { + "mustache": "registry:dt/mustache#0.8.2+20160510002910" + }, + "dependencies": { + "mssql": "registry:dt/mssql#3.3.0+20170311011547", + "yargs": "registry:npm/yargs#5.0.0+20160907000723", + "yn": "registry:npm/yn#1.3.0+20170508185912" + } }