• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

typeorm / typeorm / 13573761448

27 Feb 2025 06:53PM UTC coverage: 72.376% (+0.007%) from 72.369%
13573761448

push

github

web-flow
refactor: use ansis instead of chalk (#11263)

8657 of 12650 branches covered (68.43%)

Branch coverage included in aggregate %.

35 of 52 new or added lines in 11 files covered. (67.31%)

4 existing lines in 3 files now uncovered.

17895 of 24036 relevant lines covered (74.45%)

144036.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

22.86
/src/commands/SchemaLogCommand.ts
1
import ansi from "ansis"
248✔
2
import path from "path"
248✔
3
import process from "process"
248✔
4
import yargs from "yargs"
5
import { DataSource } from "../data-source/DataSource"
6
import { PlatformTools } from "../platform/PlatformTools"
248✔
7
import { CommandUtils } from "./CommandUtils"
248✔
8

9
/**
10
 * Shows sql to be executed by schema:sync command.
11
 */
12
export class SchemaLogCommand implements yargs.CommandModule {
248✔
13
    command = "schema:log"
248✔
14
    describe =
248✔
15
        "Shows sql to be executed by schema:sync command. It shows sql log only for your default dataSource. " +
16
        "To run update queries on a concrete connection use -c option."
17

18
    builder(args: yargs.Argv) {
19
        return args.option("dataSource", {
×
20
            alias: "d",
21
            describe:
22
                "Path to the file where your DataSource instance is defined.",
23
            demandOption: true,
24
        })
25
    }
26

27
    async handler(args: yargs.Arguments) {
28
        let dataSource: DataSource | undefined = undefined
×
29
        try {
×
30
            dataSource = await CommandUtils.loadDataSource(
×
31
                path.resolve(process.cwd(), args.dataSource as string),
32
            )
33
            dataSource.setOptions({
×
34
                synchronize: false,
35
                migrationsRun: false,
36
                dropSchema: false,
37
                logging: false,
38
            })
39
            await dataSource.initialize()
×
40

41
            const sqlInMemory = await dataSource.driver
×
42
                .createSchemaBuilder()
43
                .log()
44

45
            if (sqlInMemory.upQueries.length === 0) {
×
46
                console.log(
×
47
                    ansi.yellow`Your schema is up to date - there are no queries to be executed by schema synchronization.`,
48
                )
49
            } else {
NEW
50
                const lineSeparator = "".padStart(
×
51
                    63 + String(sqlInMemory.upQueries.length).length,
52
                    "-",
53
                )
NEW
54
                console.log(ansi.yellow(lineSeparator))
×
UNCOV
55
                console.log(
×
56
                    ansi.yellow
57
                        .bold`-- Schema synchronization will execute following sql queries (${ansi.white(
58
                        sqlInMemory.upQueries.length.toString(),
59
                    )}):`,
60
                )
NEW
61
                console.log(ansi.yellow(lineSeparator))
×
62

63
                sqlInMemory.upQueries.forEach((upQuery) => {
×
64
                    let sqlString = upQuery.query
×
65
                    sqlString = sqlString.trim()
×
NEW
66
                    sqlString = sqlString.endsWith(";")
×
67
                        ? sqlString
68
                        : sqlString + ";"
UNCOV
69
                    console.log(PlatformTools.highlightSql(sqlString))
×
70
                })
71
            }
72
            await dataSource.destroy()
×
73
        } catch (err) {
74
            if (dataSource)
×
75
                PlatformTools.logCmdErr(
×
76
                    "Error during schema synchronization:",
77
                    err,
78
                )
79
            process.exit(1)
×
80
        }
81
    }
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc