code linting
This commit is contained in:
parent
2349391340
commit
12c9fbae9b
11
.eslintrc.js
11
.eslintrc.js
@ -40,14 +40,5 @@ module.exports = {
|
||||
extensions: [".js", ".jsx", ".ts", ".tsx"]
|
||||
}
|
||||
}
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ["**/*.test.ts"],
|
||||
rules: {
|
||||
"no-unused-expressions": "off",
|
||||
"func-names": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
@ -41,8 +41,8 @@ before_script:
|
||||
- if [ -n "$DOCKER_USERNAME" ]; then mkdir /opt/oracle; npm i oracledb --no-save; docker cp typeorm-mg-oracle-client:/usr/lib/oracle/12.2/client64/lib /opt/oracle/instantclient_12_2; fi
|
||||
- export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH
|
||||
script:
|
||||
- sleep 60
|
||||
- travis_retry sh -c 'sleep 60 && npm t -- --colors'
|
||||
- docker ps
|
||||
- travis_retry sh -c 'sleep 60 && docker ps && npm t -- --colors'
|
||||
after_success:
|
||||
- codecov
|
||||
dd:
|
||||
|
@ -8,7 +8,7 @@
|
||||
"build": "npm run clean && tsc && ncp src/entity.mst dist/src/entity.mst",
|
||||
"prepare": "npm run build",
|
||||
"pretest": "tsc --noEmit",
|
||||
"test": "nyc --reporter=lcov ts-node ./node_modules/mocha/bin/_mocha test/**/*.test.ts -- -R spec --bail",
|
||||
"test": "nyc --reporter=lcov ts-node ./node_modules/mocha/bin/_mocha test/**/*.test.ts -- --bail",
|
||||
"posttest": "eslint ./**/*.ts ./src/**/*.ts ./test/**/*.ts",
|
||||
"clean": "rimraf coverage output dist",
|
||||
"prettier": "prettier --write ./src/*.ts ./src/**/*.ts"
|
||||
|
@ -162,7 +162,7 @@ function removeColumnDefaultProperties(
|
||||
}
|
||||
dbModel.forEach(entity => {
|
||||
entity.columns.forEach(column => {
|
||||
const defVal = defaultValues[column.tscType as any];
|
||||
const defVal = defaultValues[column.tscType];
|
||||
if (defVal) {
|
||||
if (
|
||||
column.options.length &&
|
||||
|
@ -4,16 +4,14 @@ import { Entity } from "./models/Entity";
|
||||
export function LogError(
|
||||
errText: string,
|
||||
isABug: boolean = true,
|
||||
passedError?: any
|
||||
passedError?: string | ErrorConstructor
|
||||
) {
|
||||
let errObject = passedError;
|
||||
console.error(errText);
|
||||
console.error(`Error occured in typeorm-model-generator.`);
|
||||
console.error(`${packageVersion()} node@${process.version}`);
|
||||
console.error(
|
||||
`If you think this is a bug please open an issue including this log on ${
|
||||
(packagejson as any).bugs.url
|
||||
}`
|
||||
`If you think this is a bug please open an issue including this log on ${packagejson.bugs.url}`
|
||||
);
|
||||
if (isABug && !passedError) {
|
||||
errObject = new Error().stack;
|
||||
@ -23,7 +21,7 @@ export function LogError(
|
||||
}
|
||||
}
|
||||
export function packageVersion() {
|
||||
return `${(packagejson as any).name}@${(packagejson as any).version}`;
|
||||
return `${packagejson.name}@${packagejson.version}`;
|
||||
}
|
||||
export function findNameForNewField(
|
||||
_fieldName: string,
|
||||
|
@ -89,7 +89,7 @@ WHERE TABLE_TYPE='BASE TABLE' and TABLE_SCHEMA in (${schema}) AND TABLE_CATALOG
|
||||
const defaultValue = MssqlDriver.ReturnDefaultValueFunction(
|
||||
resp.COLUMN_DEFAULT
|
||||
);
|
||||
const columnType = resp.DATA_TYPE as any;
|
||||
const columnType = resp.DATA_TYPE;
|
||||
let tscType = "";
|
||||
switch (resp.DATA_TYPE) {
|
||||
case "bigint":
|
||||
|
@ -456,21 +456,19 @@ export default class MysqlDriver extends AbstractDriver {
|
||||
}
|
||||
|
||||
public async CreateDB(dbName: string) {
|
||||
await this.ExecQuery<any>(`CREATE DATABASE ${dbName}; `);
|
||||
await this.ExecQuery(`CREATE DATABASE ${dbName}; `);
|
||||
}
|
||||
|
||||
public async UseDB(dbName: string) {
|
||||
await this.ExecQuery<any>(`USE ${dbName}; `);
|
||||
await this.ExecQuery(`USE ${dbName}; `);
|
||||
}
|
||||
|
||||
public async DropDB(dbName: string) {
|
||||
await this.ExecQuery<any>(`DROP DATABASE ${dbName}; `);
|
||||
await this.ExecQuery(`DROP DATABASE ${dbName}; `);
|
||||
}
|
||||
|
||||
public async CheckIfDBExists(dbName: string): Promise<boolean> {
|
||||
const resp = await this.ExecQuery<any>(
|
||||
`SHOW DATABASES LIKE '${dbName}' `
|
||||
);
|
||||
const resp = await this.ExecQuery(`SHOW DATABASES LIKE '${dbName}' `);
|
||||
return resp.length > 0;
|
||||
}
|
||||
|
||||
@ -480,7 +478,7 @@ export default class MysqlDriver extends AbstractDriver {
|
||||
const stream = query.stream({});
|
||||
const promise = new Promise<boolean>((resolve, reject) => {
|
||||
stream.on("data", chunk => {
|
||||
ret.push((chunk as any) as T);
|
||||
ret.push((chunk as unknown) as T);
|
||||
});
|
||||
stream.on("error", err => reject(err));
|
||||
stream.on("end", () => resolve(true));
|
||||
|
@ -86,7 +86,7 @@ export default class OracleDriver extends AbstractDriver {
|
||||
resp.DATA_DEFAULT
|
||||
);
|
||||
const DATA_TYPE = resp.DATA_TYPE.replace(/\([0-9]+\)/g, "");
|
||||
const columnType = DATA_TYPE.toLowerCase() as any;
|
||||
const columnType = DATA_TYPE.toLowerCase();
|
||||
let tscType = "";
|
||||
switch (DATA_TYPE.toLowerCase()) {
|
||||
case "char":
|
||||
@ -332,22 +332,22 @@ export default class OracleDriver extends AbstractDriver {
|
||||
}
|
||||
}
|
||||
|
||||
public async ConnectToServer(connectionOptons: IConnectionOptions) {
|
||||
public async ConnectToServer(connectionOptions: IConnectionOptions) {
|
||||
let config: any;
|
||||
if (connectionOptons.user === String(process.env.ORACLE_UsernameSys)) {
|
||||
if (connectionOptions.user === String(process.env.ORACLE_UsernameSys)) {
|
||||
config /* Oracle.IConnectionAttributes */ = {
|
||||
connectString: `${connectionOptons.host}:${connectionOptons.port}/${connectionOptons.databaseName}`,
|
||||
externalAuth: connectionOptons.ssl,
|
||||
password: connectionOptons.password,
|
||||
connectString: `${connectionOptions.host}:${connectionOptions.port}/${connectionOptions.databaseName}`,
|
||||
externalAuth: connectionOptions.ssl,
|
||||
password: connectionOptions.password,
|
||||
privilege: this.Oracle.SYSDBA,
|
||||
user: connectionOptons.user
|
||||
user: connectionOptions.user
|
||||
};
|
||||
} else {
|
||||
config /* Oracle.IConnectionAttributes */ = {
|
||||
connectString: `${connectionOptons.host}:${connectionOptons.port}/${connectionOptons.databaseName}`,
|
||||
externalAuth: connectionOptons.ssl,
|
||||
password: connectionOptons.password,
|
||||
user: connectionOptons.user
|
||||
connectString: `${connectionOptions.host}:${connectionOptions.port}/${connectionOptions.databaseName}`,
|
||||
externalAuth: connectionOptions.ssl,
|
||||
password: connectionOptions.password,
|
||||
user: connectionOptions.user
|
||||
};
|
||||
}
|
||||
const that = this;
|
||||
|
@ -114,7 +114,7 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
}
|
||||
return;
|
||||
}
|
||||
const columnType = columnTypes.sqlType as any;
|
||||
const columnType = columnTypes.sqlType;
|
||||
let tscType = columnTypes.tsType;
|
||||
if (columnTypes.isArray) options.array = true;
|
||||
if (columnTypes.enumValues.length > 0)
|
||||
@ -123,7 +123,7 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
tscType = tscType
|
||||
.split("|")
|
||||
.map(x => `${x.replace("|", "").trim()}[]`)
|
||||
.join(" | ") as any;
|
||||
.join(" | ");
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -24,7 +24,7 @@ export default class SqliteDriver extends AbstractDriver {
|
||||
|
||||
public sqlite = sqliteLib.verbose();
|
||||
|
||||
public db: any;
|
||||
public db: sqliteLib.Database;
|
||||
|
||||
public tablesWithGeneratedPrimaryKey: string[] = new Array<string>();
|
||||
|
||||
@ -176,12 +176,18 @@ export default class SqliteDriver extends AbstractDriver {
|
||||
) &&
|
||||
sqlOptions
|
||||
) {
|
||||
options.precision = sqlOptions[0]
|
||||
.substring(1, sqlOptions[0].length - 1)
|
||||
.split(",")[0] as any;
|
||||
options.scale = sqlOptions[0]
|
||||
.substring(1, sqlOptions[0].length - 1)
|
||||
.split(",")[1] as any;
|
||||
options.precision = Number.parseInt(
|
||||
sqlOptions[0]
|
||||
.substring(1, sqlOptions[0].length - 1)
|
||||
.split(",")[0],
|
||||
10
|
||||
);
|
||||
options.scale = Number.parseInt(
|
||||
sqlOptions[0]
|
||||
.substring(1, sqlOptions[0].length - 1)
|
||||
.split(",")[1],
|
||||
10
|
||||
);
|
||||
}
|
||||
if (
|
||||
this.ColumnTypesWithLength.some(
|
||||
@ -203,10 +209,13 @@ export default class SqliteDriver extends AbstractDriver {
|
||||
) &&
|
||||
sqlOptions
|
||||
) {
|
||||
options.width = sqlOptions[0].substring(
|
||||
1,
|
||||
sqlOptions[0].length - 1
|
||||
) as any;
|
||||
options.width = Number.parseInt(
|
||||
sqlOptions[0].substring(
|
||||
1,
|
||||
sqlOptions[0].length - 1
|
||||
),
|
||||
10
|
||||
);
|
||||
}
|
||||
|
||||
if (columnType) {
|
||||
@ -267,39 +276,6 @@ export default class SqliteDriver extends AbstractDriver {
|
||||
});
|
||||
}
|
||||
ent.indices.push(indexInfo);
|
||||
|
||||
// indexColumnsResponse.forEach(element => {
|
||||
// const indexColumnInfo: IndexColumnInfo = {} as IndexColumnInfo;
|
||||
// if (
|
||||
// ent.indices.filter(filterVal => {
|
||||
// return filterVal.name === resp.name;
|
||||
// }).length > 0
|
||||
// ) {
|
||||
// indexInfo = ent.indices.find(
|
||||
// filterVal => filterVal.name === resp.name
|
||||
// )!;
|
||||
// } else {
|
||||
// indexInfo.columns = [] as IndexColumnInfo[];
|
||||
// indexInfo.name = resp.name;
|
||||
// indexInfo.isUnique = resp.unique === 1;
|
||||
// ent.indices.push(indexInfo);
|
||||
// }
|
||||
// indexColumnInfo.name = element.name;
|
||||
// if (
|
||||
// indexColumnsResponse.length === 1 &&
|
||||
// indexInfo.isUnique
|
||||
// ) {
|
||||
// ent.columns
|
||||
// .filter(
|
||||
// v => v.tscName === indexColumnInfo.name
|
||||
// )
|
||||
// .forEach(v => {
|
||||
// // eslint-disable-next-line no-param-reassign
|
||||
// v.options.unique = true;
|
||||
// });
|
||||
// }
|
||||
// indexInfo.columns.push(indexColumnInfo);
|
||||
// });
|
||||
})
|
||||
);
|
||||
})
|
||||
@ -425,7 +401,7 @@ export default class SqliteDriver extends AbstractDriver {
|
||||
}
|
||||
|
||||
public async ExecQuery<T>(sql: string): Promise<T[]> {
|
||||
let ret: any;
|
||||
let ret: T[] = [];
|
||||
const promise = new Promise<boolean>((resolve, reject) => {
|
||||
this.db.serialize(() => {
|
||||
this.db.all(sql, [], (err, row) => {
|
||||
|
54
src/index.ts
54
src/index.ts
@ -216,7 +216,7 @@ async function GetUtilParametersByInquirer() {
|
||||
const connectionOptions: IConnectionOptions = new IConnectionOptions();
|
||||
const generationOptions: IGenerationOptions = new IGenerationOptions();
|
||||
|
||||
connectionOptions.databaseType = ((await inquirer.prompt([
|
||||
connectionOptions.databaseType = (await inquirer.prompt([
|
||||
{
|
||||
choices: [
|
||||
"mssql",
|
||||
@ -230,10 +230,10 @@ async function GetUtilParametersByInquirer() {
|
||||
name: "engine",
|
||||
type: "list"
|
||||
}
|
||||
])) as any).engine;
|
||||
])).engine;
|
||||
const driver = createDriver(connectionOptions.databaseType);
|
||||
if (connectionOptions.databaseType !== "sqlite") {
|
||||
const answ: any = await inquirer.prompt([
|
||||
const answ = await inquirer.prompt([
|
||||
{
|
||||
default: "localhost",
|
||||
message: "Database address:",
|
||||
@ -283,7 +283,7 @@ async function GetUtilParametersByInquirer() {
|
||||
connectionOptions.databaseType === "mssql" ||
|
||||
connectionOptions.databaseType === "postgres"
|
||||
) {
|
||||
connectionOptions.schemaName = ((await inquirer.prompt([
|
||||
connectionOptions.schemaName = (await inquirer.prompt([
|
||||
{
|
||||
default: driver.standardSchema,
|
||||
message:
|
||||
@ -291,7 +291,7 @@ async function GetUtilParametersByInquirer() {
|
||||
name: "schema",
|
||||
type: "input"
|
||||
}
|
||||
])) as any).schema;
|
||||
])).schema;
|
||||
}
|
||||
connectionOptions.port = answ.port;
|
||||
connectionOptions.host = answ.host;
|
||||
@ -300,38 +300,38 @@ async function GetUtilParametersByInquirer() {
|
||||
connectionOptions.databaseName = answ.dbName;
|
||||
connectionOptions.ssl = answ.ssl;
|
||||
} else {
|
||||
connectionOptions.databaseName = ((await inquirer.prompt([
|
||||
connectionOptions.databaseName = (await inquirer.prompt([
|
||||
{
|
||||
default: "",
|
||||
message: "Path to database file:",
|
||||
name: "dbName",
|
||||
type: "input"
|
||||
}
|
||||
])) as any).dbName;
|
||||
])).dbName;
|
||||
}
|
||||
generationOptions.resultsPath = ((await inquirer.prompt([
|
||||
generationOptions.resultsPath = (await inquirer.prompt([
|
||||
{
|
||||
default: path.resolve(process.cwd(), "output"),
|
||||
message: "Path where generated models should be stored:",
|
||||
name: "output",
|
||||
type: "input"
|
||||
}
|
||||
])) as any).output;
|
||||
])).output;
|
||||
|
||||
if (
|
||||
connectionOptions.databaseType === "mssql" ||
|
||||
connectionOptions.databaseType === "postgres"
|
||||
) {
|
||||
const { changeRequestTimeout } = (await inquirer.prompt([
|
||||
const { changeRequestTimeout } = await inquirer.prompt([
|
||||
{
|
||||
default: false,
|
||||
message: "Do you want to change default sql query timeout?",
|
||||
name: "changeRequestTimeout",
|
||||
type: "confirm"
|
||||
}
|
||||
])) as any;
|
||||
]);
|
||||
if (changeRequestTimeout) {
|
||||
const { timeout } = (await inquirer.prompt({
|
||||
const { timeout } = await inquirer.prompt({
|
||||
message: "Query timeout(ms):",
|
||||
name: "timeout",
|
||||
type: "input",
|
||||
@ -339,20 +339,20 @@ async function GetUtilParametersByInquirer() {
|
||||
const valid = !Number.isNaN(parseInt(value, 10));
|
||||
return valid || "Please enter a valid number";
|
||||
}
|
||||
})) as any;
|
||||
});
|
||||
connectionOptions.timeout = timeout;
|
||||
}
|
||||
}
|
||||
const { customizeGeneration } = (await inquirer.prompt([
|
||||
const { customizeGeneration } = await inquirer.prompt([
|
||||
{
|
||||
default: false,
|
||||
message: "Do you want to customize generated model?",
|
||||
name: "customizeGeneration",
|
||||
type: "confirm"
|
||||
}
|
||||
])) as any;
|
||||
]);
|
||||
if (customizeGeneration) {
|
||||
const customizations: string[] = ((await inquirer.prompt([
|
||||
const customizations: string[] = (await inquirer.prompt([
|
||||
{
|
||||
choices: [
|
||||
{
|
||||
@ -394,9 +394,9 @@ async function GetUtilParametersByInquirer() {
|
||||
name: "selected",
|
||||
type: "checkbox"
|
||||
}
|
||||
])) as any).selected;
|
||||
])).selected;
|
||||
|
||||
generationOptions.propertyVisibility = ((await inquirer.prompt([
|
||||
generationOptions.propertyVisibility = (await inquirer.prompt([
|
||||
{
|
||||
choices: ["public", "protected", "private", "none"],
|
||||
message:
|
||||
@ -405,9 +405,9 @@ async function GetUtilParametersByInquirer() {
|
||||
default: "none",
|
||||
type: "list"
|
||||
}
|
||||
])) as any).propertyVisibility;
|
||||
])).propertyVisibility;
|
||||
|
||||
const { strictModeRaw } = (await inquirer.prompt([
|
||||
const { strictModeRaw } = await inquirer.prompt([
|
||||
{
|
||||
choices: ["none", "?", "!"],
|
||||
message: "Mark fields as optional(?) or non-null(!)",
|
||||
@ -415,7 +415,7 @@ async function GetUtilParametersByInquirer() {
|
||||
default: "none",
|
||||
type: "list"
|
||||
}
|
||||
])) as any;
|
||||
]);
|
||||
|
||||
generationOptions.strictMode =
|
||||
strictModeRaw === "none" ? false : strictModeRaw;
|
||||
@ -431,7 +431,7 @@ async function GetUtilParametersByInquirer() {
|
||||
);
|
||||
|
||||
if (customizations.includes("namingStrategy")) {
|
||||
const namingStrategyPath = ((await inquirer.prompt([
|
||||
const namingStrategyPath = (await inquirer.prompt([
|
||||
{
|
||||
default: path.resolve(process.cwd()),
|
||||
message: "Path to custom naming strategy file:",
|
||||
@ -445,7 +445,7 @@ async function GetUtilParametersByInquirer() {
|
||||
);
|
||||
}
|
||||
}
|
||||
])) as any).namingStrategy;
|
||||
])).namingStrategy;
|
||||
|
||||
if (namingStrategyPath && namingStrategyPath !== "") {
|
||||
generationOptions.customNamingStrategyPath = namingStrategyPath;
|
||||
@ -454,7 +454,7 @@ async function GetUtilParametersByInquirer() {
|
||||
}
|
||||
}
|
||||
if (customizations.includes("namingConvention")) {
|
||||
const namingConventions = (await inquirer.prompt([
|
||||
const namingConventions = await inquirer.prompt([
|
||||
{
|
||||
choices: ["pascal", "param", "camel", "none"],
|
||||
default: "pascal",
|
||||
@ -476,21 +476,21 @@ async function GetUtilParametersByInquirer() {
|
||||
name: "propertyCase",
|
||||
type: "list"
|
||||
}
|
||||
])) as any;
|
||||
]);
|
||||
generationOptions.convertCaseFile = namingConventions.fileCase;
|
||||
generationOptions.convertCaseProperty =
|
||||
namingConventions.propertyCase;
|
||||
generationOptions.convertCaseEntity = namingConventions.entityCase;
|
||||
}
|
||||
}
|
||||
const { saveConfig } = (await inquirer.prompt([
|
||||
const { saveConfig } = await inquirer.prompt([
|
||||
{
|
||||
default: false,
|
||||
message: "Save configuration to config file?",
|
||||
name: "saveConfig",
|
||||
type: "confirm"
|
||||
}
|
||||
])) as any;
|
||||
]);
|
||||
if (saveConfig) {
|
||||
await fs.writeJson(
|
||||
path.resolve(process.cwd(), ".tomg-config"),
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ColumnType } from "typeorm";
|
||||
|
||||
export type Column = {
|
||||
tscType: any;
|
||||
tscType: string;
|
||||
tscName: string;
|
||||
type: ColumnType | string; // todo: remove ?
|
||||
|
||||
|
@ -23,7 +23,7 @@ class FakeRecordset extends Array<any> implements MSSQL.IRecordSet<any> {
|
||||
}
|
||||
}
|
||||
|
||||
describe("MssqlDriver", function() {
|
||||
describe("MssqlDriver", () => {
|
||||
let driver: MssqlDriver;
|
||||
const sandbox = Sinon.sandbox.create();
|
||||
|
||||
|
@ -22,27 +22,19 @@ require("dotenv").config();
|
||||
|
||||
chai.use(chaiSubset);
|
||||
|
||||
it("Column default values", async function() {
|
||||
it("Column default values", async () => {
|
||||
const testPartialPath = "test/integration/defaultValues";
|
||||
this.timeout(60000);
|
||||
this.slow(10000); // compiling created models takes time
|
||||
await runTestsFromPath(testPartialPath, true);
|
||||
});
|
||||
it("Platform specyfic types", async function() {
|
||||
this.timeout(60000);
|
||||
this.slow(10000); // compiling created models takes time
|
||||
}).timeout();
|
||||
it("Platform specyfic types", async () => {
|
||||
const testPartialPath = "test/integration/entityTypes";
|
||||
await runTestsFromPath(testPartialPath, true);
|
||||
});
|
||||
describe("GitHub issues", async function() {
|
||||
this.timeout(60000);
|
||||
this.slow(10000); // compiling created models takes time
|
||||
describe("GitHub issues", async () => {
|
||||
const testPartialPath = "test/integration/github-issues";
|
||||
await runTestsFromPath(testPartialPath, false);
|
||||
});
|
||||
describe("TypeOrm examples", async function() {
|
||||
this.timeout(60000);
|
||||
this.slow(10000); // compiling created models takes time
|
||||
describe("TypeOrm examples", async () => {
|
||||
const testPartialPath = "test/integration/examples";
|
||||
await runTestsFromPath(testPartialPath, false);
|
||||
});
|
||||
@ -77,7 +69,7 @@ function runTestForMultipleDrivers(
|
||||
dbDrivers: string[],
|
||||
testPartialPath: string
|
||||
) {
|
||||
it(testName, async function() {
|
||||
it(testName, async () => {
|
||||
const driversToRun = selectDriversForSpecyficTest();
|
||||
const modelGenerationPromises = driversToRun.map(async dbDriver => {
|
||||
const {
|
||||
@ -228,7 +220,7 @@ function compileGeneratedModel(filesGenPath: string, drivers: string[]) {
|
||||
);
|
||||
}
|
||||
});
|
||||
const compileErrors = GTU.compileTsFiles(currentDirectoryFiles, {
|
||||
const compiledWithoutErrors = GTU.compileTsFiles(currentDirectoryFiles, {
|
||||
experimentalDecorators: true,
|
||||
sourceMap: false,
|
||||
emitDecoratorMetadata: true,
|
||||
@ -236,8 +228,10 @@ function compileGeneratedModel(filesGenPath: string, drivers: string[]) {
|
||||
moduleResolution: ts.ModuleResolutionKind.NodeJs,
|
||||
module: ts.ModuleKind.CommonJS
|
||||
});
|
||||
expect(compileErrors, "Errors detected while compiling generated model").to
|
||||
.be.false;
|
||||
expect(
|
||||
compiledWithoutErrors,
|
||||
"Errors detected while compiling generated model"
|
||||
).to.equal(true);
|
||||
}
|
||||
|
||||
async function prepareTestRuns(
|
||||
|
3
test/mocha.opts
Normal file
3
test/mocha.opts
Normal file
@ -0,0 +1,3 @@
|
||||
--timeout 60000
|
||||
--slow 20000
|
||||
-R spec
|
@ -6,7 +6,7 @@ class EntityJson {
|
||||
|
||||
public columns: EntityColumn[] = [] as EntityColumn[];
|
||||
|
||||
public indicies: EntityIndex[] = [] as EntityIndex[];
|
||||
public indices: EntityIndex[] = [] as EntityIndex[];
|
||||
}
|
||||
class EntityColumn {
|
||||
public columnName: string;
|
||||
@ -15,12 +15,7 @@ class EntityColumn {
|
||||
|
||||
public columnOptions: any = {};
|
||||
|
||||
public relationType:
|
||||
| "OneToOne"
|
||||
| "OneToMany"
|
||||
| "ManyToOne"
|
||||
| "ManyToMany"
|
||||
| "None" = "None";
|
||||
public relationType: "OneToOne" | "OneToMany" | "ManyToOne" | "ManyToMany";
|
||||
|
||||
public isOwnerOfRelation: boolean = false;
|
||||
}
|
||||
@ -283,7 +278,7 @@ export default class EntityFileToJson {
|
||||
isMultilineStatement = false;
|
||||
const ind = new EntityIndex();
|
||||
EntityFileToJson.getIndexOptions(trimmedLine, ind);
|
||||
retVal.indicies.push(ind);
|
||||
retVal.indices.push(ind);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -424,7 +419,7 @@ export default class EntityFileToJson {
|
||||
isMultilineStatement = false;
|
||||
const ind = new EntityIndex();
|
||||
EntityFileToJson.getIndexOptions(trimmedLine, ind);
|
||||
retVal.indicies.push(ind);
|
||||
retVal.indices.push(ind);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -472,13 +467,11 @@ export default class EntityFileToJson {
|
||||
);
|
||||
}
|
||||
if (
|
||||
retVal.indicies.length > 0 &&
|
||||
retVal.indicies[retVal.indicies.length - 1].columnNames
|
||||
retVal.indices.length > 0 &&
|
||||
retVal.indices[retVal.indices.length - 1].columnNames
|
||||
.length === 0
|
||||
) {
|
||||
retVal.indicies[
|
||||
retVal.indicies.length - 1
|
||||
].columnNames.push(
|
||||
retVal.indices[retVal.indices.length - 1].columnNames.push(
|
||||
retVal.columns[retVal.columns.length - 1].columnName
|
||||
);
|
||||
}
|
||||
@ -494,7 +487,7 @@ export default class EntityFileToJson {
|
||||
console.log(`${trimmedLine}`);
|
||||
});
|
||||
|
||||
retVal.indicies = retVal.indicies.map(ind => {
|
||||
retVal.indices = retVal.indices.map(ind => {
|
||||
ind.columnNames = ind.columnNames.map(colName => {
|
||||
if (colName.endsWith("Id")) {
|
||||
colName = colName.substr(0, colName.length - 2);
|
||||
|
@ -301,7 +301,7 @@ export function compileTsFiles(
|
||||
): boolean {
|
||||
const program = ts.createProgram(fileNames, options);
|
||||
const emitResult = program.emit();
|
||||
let compileErrors = false;
|
||||
let compiledWithoutErrors = true;
|
||||
const preDiagnostics = ts.getPreEmitDiagnostics(program);
|
||||
|
||||
const allDiagnostics = [...preDiagnostics, ...emitResult.diagnostics];
|
||||
@ -318,10 +318,10 @@ export function compileTsFiles(
|
||||
`${diagnostic.file!.fileName} (${lineAndCharacter.line +
|
||||
1},${lineAndCharacter.character + 1}): ${message}`
|
||||
);
|
||||
compileErrors = true;
|
||||
compiledWithoutErrors = false;
|
||||
});
|
||||
|
||||
return compileErrors;
|
||||
return compiledWithoutErrors;
|
||||
}
|
||||
|
||||
export function getEnabledDbDrivers() {
|
||||
|
Loading…
Reference in New Issue
Block a user