-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
99 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
code/lib/cli/src/automigrate/helpers/getMigrationSummary.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import chalk from 'chalk'; | ||
|
||
const logger = console; | ||
|
||
export const commandLog = (message: string) => { | ||
process.stdout.write(chalk.cyan(' • ') + message); | ||
|
||
// Need `void` to be able to use this function in a then of a Promise<void> | ||
return (errorMessage?: string | void, errorInfo?: string) => { | ||
if (errorMessage) { | ||
process.stdout.write(`. ${chalk.red('✖')}\n`); | ||
logger.error(`\n ${chalk.red(errorMessage)}`); | ||
|
||
if (!errorInfo) { | ||
return; | ||
} | ||
|
||
const newErrorInfo = errorInfo | ||
.split('\n') | ||
.map((line) => ` ${chalk.dim(line)}`) | ||
.join('\n'); | ||
logger.error(`${newErrorInfo}\n`); | ||
return; | ||
} | ||
|
||
process.stdout.write(`. ${chalk.green('✓')}\n`); | ||
}; | ||
}; | ||
|
||
export function paddedLog(message: string) { | ||
const newMessage = message | ||
.split('\n') | ||
.map((line) => ` ${line}`) | ||
.join('\n'); | ||
|
||
logger.log(newMessage); | ||
} | ||
|
||
export function getChars(char: string, amount: number) { | ||
let line = ''; | ||
for (let lc = 0; lc < amount; lc += 1) { | ||
line += char; | ||
} | ||
|
||
return line; | ||
} | ||
|
||
export function codeLog(codeLines: string[], leftPadAmount?: number) { | ||
let maxLength = 0; | ||
const newLines = codeLines.map((line) => { | ||
maxLength = line.length > maxLength ? line.length : maxLength; | ||
return line; | ||
}); | ||
|
||
const finalResult = newLines | ||
.map((line) => { | ||
const rightPadAmount = maxLength - line.length; | ||
let newLine = line + getChars(' ', rightPadAmount); | ||
newLine = getChars(' ', leftPadAmount || 2) + chalk.inverse(` ${newLine} `); | ||
return newLine; | ||
}) | ||
.join('\n'); | ||
|
||
logger.log(finalResult); | ||
} |