upgrade dependencies
This commit is contained in:
parent
414a17dfa5
commit
86c2dd4bc5
@ -31,7 +31,8 @@ module.exports = {
|
||||
"import/extensions": ["off"],
|
||||
"no-param-reassign": ["off"],
|
||||
"@typescript-eslint/no-explicit-any": ["off"],
|
||||
"no-loop-func": ["off"]
|
||||
"no-loop-func": ["off"],
|
||||
"@typescript-eslint/explicit-module-boundary-types": ["off"]
|
||||
},
|
||||
settings: {
|
||||
"import/resolver": {
|
||||
|
2600
package-lock.json
generated
2600
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
70
package.json
70
package.json
@ -10,7 +10,7 @@
|
||||
"build": "npm run clean && tsc && ncp src/templates/ dist/src/templates/ && ncp package.json dist/package.json",
|
||||
"prepare": "npm run build",
|
||||
"pretest": "tsc --noEmit",
|
||||
"test": "nyc --reporter=lcov ts-node ./node_modules/mocha/bin/_mocha test/**/*.test.ts -- --bail",
|
||||
"test": "nyc --reporter=lcov ts-node ./node_modules/mocha/bin/_mocha test/**/*.test.ts --config test/configs/mocha.json -- --bail",
|
||||
"posttest": "eslint ./src/**/*.ts ./test/**/*.ts",
|
||||
"clean": "rimraf coverage output dist",
|
||||
"prettier": "prettier --write ./src/*.ts ./src/**/*.ts"
|
||||
@ -27,62 +27,62 @@
|
||||
"homepage": "https://github.com/Kononnable/typeorm-model-generator#readme",
|
||||
"dependencies": {
|
||||
"change-case": "^4.1.1",
|
||||
"fs-extra": "^9.0.0",
|
||||
"fs-extra": "^9.0.1",
|
||||
"handlebars": "^4.7.6",
|
||||
"inquirer": "^7.1.0",
|
||||
"mssql": "^6.2.0",
|
||||
"inquirer": "^7.3.3",
|
||||
"mssql": "^6.2.1",
|
||||
"mysql": "^2.18.1",
|
||||
"pg": "^8.0.3",
|
||||
"pg": "^8.3.0",
|
||||
"pluralize": "^8.0.0",
|
||||
"prettier": "^2.0.5",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"sqlite3": "^4.1.1",
|
||||
"typeorm": "^0.2.24",
|
||||
"yargs": "^15.3.1"
|
||||
"sqlite3": "^5.0.0",
|
||||
"typeorm": "^0.2.25",
|
||||
"yargs": "^15.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/array.prototype.flatmap": "^1.2.1",
|
||||
"@types/chai": "^4.2.11",
|
||||
"@types/chai-as-promised": "^7.1.2",
|
||||
"@types/array.prototype.flatmap": "^1.2.2",
|
||||
"@types/chai": "^4.2.12",
|
||||
"@types/chai-as-promised": "^7.1.3",
|
||||
"@types/chai-subset": "^1.3.3",
|
||||
"@types/eslint": "^6.8.0",
|
||||
"@types/fs-extra": "^8.1.0",
|
||||
"@types/eslint": "^7.2.0",
|
||||
"@types/fs-extra": "^9.0.1",
|
||||
"@types/handlebars": "^4.1.0",
|
||||
"@types/inquirer": "^6.5.0",
|
||||
"@types/mocha": "^7.0.2",
|
||||
"@types/mssql": "^6.0.0",
|
||||
"@types/mysql": "^2.15.10",
|
||||
"@types/node": "^13.13.2",
|
||||
"@types/oracledb": "^4.2.0",
|
||||
"@types/pg": "^7.14.3",
|
||||
"@types/inquirer": "^7.3.0",
|
||||
"@types/mocha": "^8.0.1",
|
||||
"@types/mssql": "^6.0.3",
|
||||
"@types/mysql": "^2.15.15",
|
||||
"@types/node": "^14.0.27",
|
||||
"@types/oracledb": "^5.0.0",
|
||||
"@types/pg": "^7.14.4",
|
||||
"@types/pluralize": "0.0.29",
|
||||
"@types/prettier": "^2.0.0",
|
||||
"@types/sinon": "^9.0.0",
|
||||
"@types/prettier": "^2.0.2",
|
||||
"@types/sinon": "^9.0.4",
|
||||
"@types/sqlite3": "^3.1.6",
|
||||
"@types/yargs": "^15.0.4",
|
||||
"@typescript-eslint/eslint-plugin": "^2.29.0",
|
||||
"@typescript-eslint/parser": "^2.29.0",
|
||||
"@typescript-eslint/typescript-estree": "^2.29.0",
|
||||
"@types/yargs": "^15.0.5",
|
||||
"@typescript-eslint/eslint-plugin": "^3.7.1",
|
||||
"@typescript-eslint/parser": "^3.7.1",
|
||||
"@typescript-eslint/typescript-estree": "^3.7.1",
|
||||
"array.prototype.flatmap": "^1.2.3",
|
||||
"chai": "^4.2.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-subset": "^1.6.0",
|
||||
"codecov": "^3.6.1",
|
||||
"codecov": "^3.7.2",
|
||||
"dotenv": "^8.2.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-airbnb-base": "^14.1.0",
|
||||
"eslint": "^7.5.0",
|
||||
"eslint-config-airbnb-base": "^14.2.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-import": "^2.20.2",
|
||||
"eslint-plugin-import": "^2.22.0",
|
||||
"husky": "^4.2.5",
|
||||
"lint-staged": "^10.1.7",
|
||||
"mocha": "^7.1.2",
|
||||
"lint-staged": "^10.2.11",
|
||||
"mocha": "^8.1.0",
|
||||
"ncp": "^2.0.0",
|
||||
"nyc": "^15.0.1",
|
||||
"nyc": "^15.1.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"sinon": "^9.0.2",
|
||||
"sinon-chai": "^3.5.0",
|
||||
"ts-node": "^8.9.1",
|
||||
"typescript": "^3.8.3",
|
||||
"ts-node": "^8.10.2",
|
||||
"typescript": "^3.9.7",
|
||||
"yn": "^4.0.0"
|
||||
},
|
||||
"husky": {
|
||||
|
@ -50,7 +50,7 @@ function generateModels(
|
||||
"templates",
|
||||
"entity.mst"
|
||||
);
|
||||
const entityTemplate = fs.readFileSync(entityTemplatePath, "UTF-8");
|
||||
const entityTemplate = fs.readFileSync(entityTemplatePath, "utf-8");
|
||||
const entityCompliedTemplate = Handlebars.compile(entityTemplate, {
|
||||
noEscape: true,
|
||||
});
|
||||
@ -97,7 +97,7 @@ function generateModels(
|
||||
formatted = withImportStatements;
|
||||
}
|
||||
fs.writeFileSync(resultFilePath, formatted, {
|
||||
encoding: "UTF-8",
|
||||
encoding: "utf-8",
|
||||
flag: "w",
|
||||
});
|
||||
});
|
||||
@ -109,7 +109,7 @@ function createIndexFile(
|
||||
entitiesPath: string
|
||||
) {
|
||||
const templatePath = path.resolve(__dirname, "templates", "index.mst");
|
||||
const template = fs.readFileSync(templatePath, "UTF-8");
|
||||
const template = fs.readFileSync(templatePath, "utf-8");
|
||||
const compliedTemplate = Handlebars.compile(template, {
|
||||
noEscape: true,
|
||||
});
|
||||
@ -130,7 +130,7 @@ function createIndexFile(
|
||||
}
|
||||
const resultFilePath = path.resolve(entitiesPath, `${fileName}.ts`);
|
||||
fs.writeFileSync(resultFilePath, formatted, {
|
||||
encoding: "UTF-8",
|
||||
encoding: "utf-8",
|
||||
flag: "w",
|
||||
});
|
||||
}
|
||||
@ -257,7 +257,7 @@ function createHandlebarsHelpers(generationOptions: IGenerationOptions): void {
|
||||
|
||||
function createTsConfigFile(outputPath: string): void {
|
||||
const templatePath = path.resolve(__dirname, "templates", "tsconfig.mst");
|
||||
const template = fs.readFileSync(templatePath, "UTF-8");
|
||||
const template = fs.readFileSync(templatePath, "utf-8");
|
||||
const compliedTemplate = Handlebars.compile(template, {
|
||||
noEscape: true,
|
||||
});
|
||||
@ -265,7 +265,7 @@ function createTsConfigFile(outputPath: string): void {
|
||||
const formatted = Prettier.format(rendered, { parser: "json" });
|
||||
const resultFilePath = path.resolve(outputPath, "tsconfig.json");
|
||||
fs.writeFileSync(resultFilePath, formatted, {
|
||||
encoding: "UTF-8",
|
||||
encoding: "utf-8",
|
||||
flag: "w",
|
||||
});
|
||||
}
|
||||
@ -274,7 +274,7 @@ function createTypeOrmConfig(
|
||||
connectionOptions: IConnectionOptions
|
||||
): void {
|
||||
const templatePath = path.resolve(__dirname, "templates", "ormconfig.mst");
|
||||
const template = fs.readFileSync(templatePath, "UTF-8");
|
||||
const template = fs.readFileSync(templatePath, "utf-8");
|
||||
const compliedTemplate = Handlebars.compile(template, {
|
||||
noEscape: true,
|
||||
});
|
||||
@ -282,7 +282,7 @@ function createTypeOrmConfig(
|
||||
const formatted = Prettier.format(rendered, { parser: "json" });
|
||||
const resultFilePath = path.resolve(outputPath, "ormconfig.json");
|
||||
fs.writeFileSync(resultFilePath, formatted, {
|
||||
encoding: "UTF-8",
|
||||
encoding: "utf-8",
|
||||
flag: "w",
|
||||
});
|
||||
}
|
||||
|
@ -267,6 +267,7 @@ WHERE TABLE_TYPE='BASE TABLE' and TABLE_SCHEMA in (${schema}) AND TABLE_CATALOG
|
||||
dbNames: string
|
||||
): Promise<Entity[]> {
|
||||
const request = new this.MSSQL.Request(this.Connection);
|
||||
/* eslint-disable camelcase */
|
||||
const response: {
|
||||
TableName: string;
|
||||
TableSchema: string;
|
||||
@ -275,19 +276,13 @@ WHERE TABLE_TYPE='BASE TABLE' and TABLE_SCHEMA in (${schema}) AND TABLE_CATALOG
|
||||
is_unique: boolean;
|
||||
is_primary_key: boolean;
|
||||
}[] = [];
|
||||
/* eslint-enable camelcase */
|
||||
await Promise.all(
|
||||
dbNames.split(",").map(async (dbName) => {
|
||||
if (dbNames.length > 1) {
|
||||
await this.UseDB(dbName);
|
||||
}
|
||||
const resp: {
|
||||
TableName: string;
|
||||
TableSchema: string;
|
||||
IndexName: string;
|
||||
ColumnName: string;
|
||||
is_unique: boolean;
|
||||
is_primary_key: boolean;
|
||||
}[] = (
|
||||
const resp = (
|
||||
await request.query(`SELECT
|
||||
TableName = t.name,
|
||||
TableSchema = s.name,
|
||||
@ -351,6 +346,7 @@ WHERE TABLE_TYPE='BASE TABLE' and TABLE_SCHEMA in (${schema}) AND TABLE_CATALOG
|
||||
const request = new this.MSSQL.Request(this.Connection);
|
||||
const response: {
|
||||
TableWithForeignKey: string;
|
||||
// eslint-disable-next-line camelcase
|
||||
FK_PartNo: number;
|
||||
ForeignKeyColumn: string;
|
||||
TableReferenced: string;
|
||||
@ -366,6 +362,7 @@ WHERE TABLE_TYPE='BASE TABLE' and TABLE_SCHEMA in (${schema}) AND TABLE_CATALOG
|
||||
}
|
||||
const resp: {
|
||||
TableWithForeignKey: string;
|
||||
// eslint-disable-next-line camelcase
|
||||
FK_PartNo: number;
|
||||
ForeignKeyColumn: string;
|
||||
TableReferenced: string;
|
||||
|
@ -308,6 +308,7 @@ export default class MysqlDriver extends AbstractDriver {
|
||||
schema: string,
|
||||
dbNames: string
|
||||
): Promise<Entity[]> {
|
||||
/* eslint-disable camelcase */
|
||||
const response = await this.ExecQuery<{
|
||||
TableName: string;
|
||||
IndexName: string;
|
||||
@ -315,11 +316,12 @@ export default class MysqlDriver extends AbstractDriver {
|
||||
is_unique: number;
|
||||
is_primary_key: number;
|
||||
}>(`SELECT TABLE_NAME TableName,INDEX_NAME IndexName,COLUMN_NAME ColumnName,CASE WHEN NON_UNIQUE=0 THEN 1 ELSE 0 END is_unique,
|
||||
CASE WHEN INDEX_NAME='PRIMARY' THEN 1 ELSE 0 END is_primary_key
|
||||
FROM information_schema.statistics sta
|
||||
WHERE table_schema IN (${MysqlDriver.escapeCommaSeparatedList(
|
||||
dbNames
|
||||
)})`);
|
||||
CASE WHEN INDEX_NAME='PRIMARY' THEN 1 ELSE 0 END is_primary_key
|
||||
FROM information_schema.statistics sta
|
||||
WHERE table_schema IN (${MysqlDriver.escapeCommaSeparatedList(
|
||||
dbNames
|
||||
)})`);
|
||||
/* eslint-enable camelcase */
|
||||
entities.forEach((ent) => {
|
||||
const entityIndices = response.filter(
|
||||
(filterVal) => filterVal.TableName === ent.tscName
|
||||
@ -356,12 +358,14 @@ export default class MysqlDriver extends AbstractDriver {
|
||||
): Promise<Entity[]> {
|
||||
const response = await this.ExecQuery<{
|
||||
TableWithForeignKey: string;
|
||||
// eslint-disable-next-line camelcase
|
||||
FK_PartNo: number;
|
||||
ForeignKeyColumn: string;
|
||||
TableReferenced: string;
|
||||
ForeignKeyColumnReferenced: string;
|
||||
onDelete: "RESTRICT" | "CASCADE" | "SET NULL" | "NO_ACTION";
|
||||
onUpdate: "RESTRICT" | "CASCADE" | "SET NULL" | "NO_ACTION";
|
||||
// eslint-disable-next-line camelcase
|
||||
object_id: string;
|
||||
}>(`SELECT
|
||||
CU.TABLE_NAME TableWithForeignKey,
|
||||
|
@ -63,6 +63,7 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
schema: string
|
||||
): Promise<Entity[]> {
|
||||
const response: {
|
||||
/* eslint-disable camelcase */
|
||||
table_name: string;
|
||||
column_name: string;
|
||||
udt_name: string;
|
||||
@ -75,6 +76,7 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
isidentity: string;
|
||||
isunique: string;
|
||||
enumvalues: string | null;
|
||||
/* eslint-enable camelcase */
|
||||
}[] = (
|
||||
await this.Connection
|
||||
.query(`SELECT table_name,column_name,udt_name,column_default,is_nullable,
|
||||
@ -436,7 +438,9 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
tablename: string;
|
||||
indexname: string;
|
||||
columnname: string;
|
||||
// eslint-disable-next-line camelcase
|
||||
is_unique: number;
|
||||
// eslint-disable-next-line camelcase
|
||||
is_primary_key: number;
|
||||
}[] = (
|
||||
await this.Connection.query(`SELECT
|
||||
@ -498,12 +502,14 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
): Promise<Entity[]> {
|
||||
const response: {
|
||||
tablewithforeignkey: string;
|
||||
// eslint-disable-next-line camelcase
|
||||
fk_partno: number;
|
||||
foreignkeycolumn: string;
|
||||
tablereferenced: string;
|
||||
foreignkeycolumnreferenced: string;
|
||||
ondelete: "RESTRICT" | "CASCADE" | "SET NULL" | "NO ACTION";
|
||||
onupdate: "RESTRICT" | "CASCADE" | "SET NULL" | "NO ACTION";
|
||||
// eslint-disable-next-line camelcase
|
||||
object_id: string;
|
||||
// Distinct because of note in https://www.postgresql.org/docs/9.1/information-schema.html
|
||||
}[] = (
|
||||
@ -621,7 +627,6 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
password: connectionOptons.password,
|
||||
port: connectionOptons.port,
|
||||
ssl: connectionOptons.ssl,
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
statement_timeout: 60 * 60 * 1000,
|
||||
user: connectionOptons.user,
|
||||
});
|
||||
|
@ -54,6 +54,7 @@ export default class SqliteDriver extends AbstractDriver {
|
||||
tableNames.length > 0
|
||||
? ` AND NOT tbl_name IN ('${tableNames.join("','")}')`
|
||||
: "";
|
||||
// eslint-disable-next-line camelcase
|
||||
const rows = await this.ExecQuery<{ tbl_name: string; sql: string }>(
|
||||
`SELECT tbl_name, sql FROM "sqlite_master" WHERE "type" = 'table' AND name NOT LIKE 'sqlite_%' ${tableCondition}`
|
||||
);
|
||||
@ -82,6 +83,7 @@ export default class SqliteDriver extends AbstractDriver {
|
||||
name: string;
|
||||
type: string;
|
||||
notnull: number;
|
||||
// eslint-disable-next-line camelcase
|
||||
dflt_value: string;
|
||||
pk: number;
|
||||
}>(`PRAGMA table_info('${ent.tscName}');`);
|
||||
@ -322,11 +324,13 @@ export default class SqliteDriver extends AbstractDriver {
|
||||
table: string;
|
||||
from: string;
|
||||
to: string;
|
||||
// eslint-disable-next-line camelcase
|
||||
on_update:
|
||||
| "RESTRICT"
|
||||
| "CASCADE"
|
||||
| "SET NULL"
|
||||
| "NO ACTION";
|
||||
// eslint-disable-next-line camelcase
|
||||
on_delete:
|
||||
| "RESTRICT"
|
||||
| "CASCADE"
|
||||
|
@ -18,7 +18,8 @@ module.exports = {
|
||||
"import/prefer-default-export": ["off"],
|
||||
"@typescript-eslint/no-explicit-any": ["off"],
|
||||
"@typescript-eslint/camelcase": ["off"],
|
||||
"@typescript-eslint/class-name-casing": ["off"]
|
||||
"@typescript-eslint/class-name-casing": ["off"],
|
||||
"@typescript-eslint/ban-types": ["off"]
|
||||
},
|
||||
settings: {
|
||||
"import/resolver": {
|
||||
|
5
test/configs/mocha.json
Normal file
5
test/configs/mocha.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"timeout": 60000,
|
||||
"slow": 20000,
|
||||
"R": "spec"
|
||||
}
|
@ -7,6 +7,7 @@ import * as chaiSubset from "chai-subset";
|
||||
import * as flatMap from "array.prototype.flatmap";
|
||||
import * as yn from "yn";
|
||||
import { CLIEngine } from "eslint";
|
||||
import * as dotEnv from "dotenv"
|
||||
import EntityFileToJson from "../utils/EntityFileToJson";
|
||||
import { createDriver, dataCollectionPhase } from "../../src/Engine";
|
||||
import * as GTU from "../utils/GeneralTestUtils";
|
||||
@ -15,7 +16,7 @@ import IConnectionOptions from "../../src/IConnectionOptions";
|
||||
import modelCustomizationPhase from "../../src/ModelCustomization";
|
||||
import modelGenerationPhase from "../../src/ModelGeneration";
|
||||
|
||||
require("dotenv").config();
|
||||
dotEnv.config();
|
||||
|
||||
flatMap.shim();
|
||||
chai.use(chaiSubset);
|
||||
|
@ -1,3 +0,0 @@
|
||||
--timeout 60000
|
||||
--slow 20000
|
||||
-R spec
|
@ -1,6 +1,7 @@
|
||||
import { ConnectionOptions, createConnection } from "typeorm";
|
||||
import * as ts from "typescript";
|
||||
import * as yn from "yn";
|
||||
import * as path from "path"
|
||||
import IGenerationOptions, {
|
||||
getDefaultGenerationOptions
|
||||
} from "../../src/IGenerationOptions";
|
||||
@ -11,8 +12,6 @@ import PostgresDriver from "../../src/drivers/PostgresDriver";
|
||||
import OracleDriver from "../../src/drivers/OracleDriver";
|
||||
import MysqlDriver from "../../src/drivers/MysqlDriver";
|
||||
|
||||
import path = require("path");
|
||||
|
||||
export function getGenerationOptions(resultsPath: string): IGenerationOptions {
|
||||
const retVal = getDefaultGenerationOptions();
|
||||
retVal.resultsPath = resultsPath;
|
||||
|
Loading…
Reference in New Issue
Block a user