From 4f7481b55af021f5ffe12ff3d5d4d0ea6cb13f1c Mon Sep 17 00:00:00 2001 From: James Ward Date: Wed, 2 Sep 2020 10:47:36 -0400 Subject: [PATCH] chore: instead of require, import chalk from chalk (#6637) --- src/commands/CacheClearCommand.ts | 2 +- src/commands/EntityCreateCommand.ts | 2 +- src/commands/InitCommand.ts | 2 +- src/commands/MigrationCreateCommand.ts | 2 +- src/commands/MigrationGenerateCommand.ts | 2 +- src/commands/MigrationRevertCommand.ts | 2 +- src/commands/MigrationRunCommand.ts | 2 +- src/commands/MigrationShowCommand.ts | 2 +- src/commands/QueryCommand.ts | 2 +- src/commands/SchemaDropCommand.ts | 2 +- src/commands/SchemaLogCommand.ts | 5 ++--- src/commands/SchemaSyncCommand.ts | 2 +- src/commands/SubscriberCreateCommand.ts | 2 +- src/commands/VersionCommand.ts | 2 +- src/platform/PlatformTools.ts | 3 +-- 15 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/commands/CacheClearCommand.ts b/src/commands/CacheClearCommand.ts index 7c635611c8..79dba0e87a 100644 --- a/src/commands/CacheClearCommand.ts +++ b/src/commands/CacheClearCommand.ts @@ -2,7 +2,7 @@ import {createConnection} from "../index"; import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader"; import {Connection} from "../connection/Connection"; import * as yargs from "yargs"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Clear cache command. diff --git a/src/commands/EntityCreateCommand.ts b/src/commands/EntityCreateCommand.ts index 024aecb2dd..314fa203d1 100644 --- a/src/commands/EntityCreateCommand.ts +++ b/src/commands/EntityCreateCommand.ts @@ -1,7 +1,7 @@ import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader"; import {CommandUtils} from "./CommandUtils"; import * as yargs from "yargs"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Generates a new entity. diff --git a/src/commands/InitCommand.ts b/src/commands/InitCommand.ts index c3638ffe66..3dbe7f2c51 100644 --- a/src/commands/InitCommand.ts +++ b/src/commands/InitCommand.ts @@ -2,7 +2,7 @@ import {CommandUtils} from "./CommandUtils"; import {ObjectLiteral} from "../common/ObjectLiteral"; import * as path from "path"; import * as yargs from "yargs"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Generates a new project with TypeORM. diff --git a/src/commands/MigrationCreateCommand.ts b/src/commands/MigrationCreateCommand.ts index 8e56855c82..9d39b06174 100644 --- a/src/commands/MigrationCreateCommand.ts +++ b/src/commands/MigrationCreateCommand.ts @@ -2,7 +2,7 @@ import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader"; import {CommandUtils} from "./CommandUtils"; import {camelCase} from "../util/StringUtils"; import * as yargs from "yargs"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Creates a new migration file. diff --git a/src/commands/MigrationGenerateCommand.ts b/src/commands/MigrationGenerateCommand.ts index faf6edd382..f036fd67fc 100644 --- a/src/commands/MigrationGenerateCommand.ts +++ b/src/commands/MigrationGenerateCommand.ts @@ -6,7 +6,7 @@ import {MysqlDriver} from "../driver/mysql/MysqlDriver"; import {camelCase} from "../util/StringUtils"; import * as yargs from "yargs"; import {AuroraDataApiDriver} from "../driver/aurora-data-api/AuroraDataApiDriver"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Generates a new migration file with sql needs to be executed to update schema. diff --git a/src/commands/MigrationRevertCommand.ts b/src/commands/MigrationRevertCommand.ts index 5a7605ac18..1d70326c93 100644 --- a/src/commands/MigrationRevertCommand.ts +++ b/src/commands/MigrationRevertCommand.ts @@ -2,7 +2,7 @@ import {createConnection} from "../index"; import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader"; import {Connection} from "../connection/Connection"; import * as yargs from "yargs"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Reverts last migration command. diff --git a/src/commands/MigrationRunCommand.ts b/src/commands/MigrationRunCommand.ts index e27915fe17..f953d5b551 100644 --- a/src/commands/MigrationRunCommand.ts +++ b/src/commands/MigrationRunCommand.ts @@ -3,7 +3,7 @@ import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader"; import {Connection} from "../connection/Connection"; import * as process from "process"; import * as yargs from "yargs"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Runs migration command. diff --git a/src/commands/MigrationShowCommand.ts b/src/commands/MigrationShowCommand.ts index d72b62c9ae..8995faa6b0 100644 --- a/src/commands/MigrationShowCommand.ts +++ b/src/commands/MigrationShowCommand.ts @@ -3,7 +3,7 @@ import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader"; import {Connection} from "../connection/Connection"; import * as process from "process"; import * as yargs from "yargs"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Runs migration command. diff --git a/src/commands/QueryCommand.ts b/src/commands/QueryCommand.ts index 49bf0078e3..c7a62129f2 100644 --- a/src/commands/QueryCommand.ts +++ b/src/commands/QueryCommand.ts @@ -4,7 +4,7 @@ import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader"; import {Connection} from "../connection/Connection"; import {PlatformTools} from "../platform/PlatformTools"; import * as yargs from "yargs"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Executes an sql query on the given connection. diff --git a/src/commands/SchemaDropCommand.ts b/src/commands/SchemaDropCommand.ts index 2ce3caafd0..fcabb029c4 100644 --- a/src/commands/SchemaDropCommand.ts +++ b/src/commands/SchemaDropCommand.ts @@ -2,7 +2,7 @@ import {createConnection} from "../index"; import {Connection} from "../connection/Connection"; import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader"; import * as yargs from "yargs"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Drops all tables of the database from the given connection. diff --git a/src/commands/SchemaLogCommand.ts b/src/commands/SchemaLogCommand.ts index 86d99a0aac..73c1320934 100644 --- a/src/commands/SchemaLogCommand.ts +++ b/src/commands/SchemaLogCommand.ts @@ -3,8 +3,7 @@ import {Connection} from "../connection/Connection"; import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader"; import {highlight} from "cli-highlight"; import * as yargs from "yargs"; - -const chalk = require("chalk"); +import chalk from "chalk"; /** * Shows sql to be executed by schema:sync command. @@ -53,7 +52,7 @@ export class SchemaLogCommand implements yargs.CommandModule { } else { const lengthSeparators = String(sqlInMemory.upQueries.length).split("").map(char => "-").join(""); console.log(chalk.yellow("---------------------------------------------------------------" + lengthSeparators)); - console.log(chalk.yellow.bold(`-- Schema syncronization will execute following sql queries (${chalk.white(sqlInMemory.upQueries.length)}):`)); + console.log(chalk.yellow.bold(`-- Schema syncronization will execute following sql queries (${chalk.white(sqlInMemory.upQueries.length.toString())}):`)); console.log(chalk.yellow("---------------------------------------------------------------" + lengthSeparators)); sqlInMemory.upQueries.forEach(upQuery => { diff --git a/src/commands/SchemaSyncCommand.ts b/src/commands/SchemaSyncCommand.ts index 5ac12aab7d..3a1653344b 100644 --- a/src/commands/SchemaSyncCommand.ts +++ b/src/commands/SchemaSyncCommand.ts @@ -2,7 +2,7 @@ import {createConnection} from "../index"; import {Connection} from "../connection/Connection"; import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader"; import * as yargs from "yargs"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Synchronizes database schema with entities. diff --git a/src/commands/SubscriberCreateCommand.ts b/src/commands/SubscriberCreateCommand.ts index b91f40d014..65d908843d 100644 --- a/src/commands/SubscriberCreateCommand.ts +++ b/src/commands/SubscriberCreateCommand.ts @@ -1,7 +1,7 @@ import {ConnectionOptionsReader} from "../connection/ConnectionOptionsReader"; import {CommandUtils} from "./CommandUtils"; import * as yargs from "yargs"; -const chalk = require("chalk"); +import chalk from "chalk"; /** * Generates a new subscriber. diff --git a/src/commands/VersionCommand.ts b/src/commands/VersionCommand.ts index 3f2daaebaa..09361ea831 100644 --- a/src/commands/VersionCommand.ts +++ b/src/commands/VersionCommand.ts @@ -1,5 +1,5 @@ import * as yargs from "yargs"; -const exec = require("child_process").exec; +import {exec} from "child_process"; /** * Shows typeorm version. diff --git a/src/platform/PlatformTools.ts b/src/platform/PlatformTools.ts index 5af551057c..98e9d06689 100644 --- a/src/platform/PlatformTools.ts +++ b/src/platform/PlatformTools.ts @@ -1,12 +1,11 @@ import * as path from "path"; import * as fs from "fs"; +import chalk from "chalk"; import {highlight, Theme} from "cli-highlight"; export {ReadStream} from "fs"; export {EventEmitter} from "events"; export {Readable, Writable} from "stream"; -const chalk = require("chalk"); - /** * Platform-specific tools. */