build: run format in ci (#11342)

* style: run format on existing files

* build: run format in ci

* build: add format:ci to check formatting in ci
This commit is contained in:
Mike Guida 2025-03-20 12:27:09 -06:00 committed by GitHub
parent b0ea913f4e
commit de8eb04c72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 26 additions and 18 deletions

View File

@ -20,10 +20,12 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "18.x"
- uses: actions/checkout@v4
- run: npm i
- run: npm run lint
- run: npm run format:ci
# These tests run in standard node containers with their db attached as a service
database-tests:
@ -36,7 +38,6 @@ jobs:
with:
node-container: ${{matrix.node-container}}
# These tests run with custom docker image attributes that can't be specified in a GHA service
database-compose-tests:
strategy:

View File

@ -150,7 +150,7 @@
"peerDependencies": {
"@google-cloud/spanner": "^5.18.0",
"@sap/hana-client": "^2.12.25",
"better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0" ,
"better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
"hdb-pool": "^0.1.6",
"ioredis": "^5.0.4",
"mongodb": "^5.8.0",
@ -244,6 +244,7 @@
"pack": "gulp pack",
"lint": "eslint .",
"format": "prettier --cache --write --end-of-line auto \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"",
"format:ci": "prettier --check --end-of-line auto \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1"
},
"bin": {
@ -257,4 +258,4 @@
"url": "https://opencollective.com/typeorm",
"logo": "https://opencollective.com/opencollective/logo.txt"
}
}
}

View File

@ -14,7 +14,7 @@ export class CommandUtils {
): Promise<DataSource> {
let dataSourceFileExports
try {
[dataSourceFileExports] = await importOrRequireFile(
;[dataSourceFileExports] = await importOrRequireFile(
dataSourceFilePath,
)
} catch (err) {

View File

@ -520,7 +520,7 @@ export class DataSource {
/**
* Executes raw SQL query and returns raw database results.
*
*
* @see [Official docs](https://typeorm.io/data-source-api) for examples.
*/
async query<T = any>(

View File

@ -169,7 +169,7 @@ export class EntityManager {
/**
* Executes raw SQL query and returns raw database results.
*
*
* @see [Official docs](https://typeorm.io/entity-manager-api) for examples.
*/
async query<T = any>(query: string, parameters?: any[]): Promise<T> {

View File

@ -1152,7 +1152,8 @@ export abstract class QueryBuilder<Entity extends ObjectLiteral> {
const cteStrings = this.expressionMap.commonTableExpressions.map(
(cte) => {
let cteBodyExpression = typeof cte.queryBuilder === 'string' ? cte.queryBuilder : '';
let cteBodyExpression =
typeof cte.queryBuilder === "string" ? cte.queryBuilder : ""
if (typeof cte.queryBuilder !== "string") {
if (cte.queryBuilder.hasCommonTableExpressions()) {
throw new TypeORMError(

View File

@ -644,7 +644,7 @@ export class Repository<Entity extends ObjectLiteral> {
/**
* Executes a raw SQL query and returns a raw database results.
* Raw query execution is supported only by relational databases (MongoDB is not supported).
*
*
* @see [Official docs](https://typeorm.io/repository-api) for examples.
*/
query(query: string, parameters?: any[]): Promise<any> {

View File

@ -1,9 +1,4 @@
import {
Entity,
ManyToOne,
OneToMany,
PrimaryColumn
} from "../../../../../src"
import { Entity, ManyToOne, OneToMany, PrimaryColumn } from "../../../../../src"
import { Company } from "./Company"
import { TimeSheet } from "./TimeSheet"

View File

@ -25,11 +25,21 @@ describe("multi-database > basic-functionality", () => {
it(`[${platform}] produces deterministic, unique, and valid table names for relative paths; leaves absolute paths unchanged`, () => {
const testMap = [
["FILENAME.db", "filename.db"],
["..\\FILENAME.db", platform === 'win32' ? "../filename.db" : "..\\filename.db"],
[".\\FILENAME.db", platform === 'win32' ? "./filename.db" : ".\\filename.db"],
[
"..\\FILENAME.db",
platform === "win32"
? "../filename.db"
: "..\\filename.db",
],
[
".\\FILENAME.db",
platform === "win32"
? "./filename.db"
: ".\\filename.db",
],
[
"..\\longpathdir\\longpathdir\\longpathdir\\longpathdir\\longpathdir\\longpathdir\\longpathdir\\FILENAME.db",
platform === 'win32'
platform === "win32"
? "../longpathdir/longpathdir/longpathdir/longpathdir/longpathdir/longpathdir/longpathdir/filename.db"
: "..\\longpathdir\\longpathdir\\longpathdir\\longpathdir\\longpathdir\\longpathdir\\longpathdir\\filename.db",
],