Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace chalk with picocolors #2736

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drizzle-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"ava": "^5.1.0",
"better-sqlite3": "^9.4.3",
"camelcase": "^7.0.1",
"chalk": "^5.2.0",
"commander": "^12.1.0",
"dockerode": "^3.3.4",
"dotenv": "^16.0.3",
Expand All @@ -96,6 +95,7 @@
"mysql2": "2.3.3",
"node-fetch": "^3.3.2",
"pg": "^8.11.5",
"picocolors": "^1.0.1",
"pluralize": "^8.0.0",
"postgres": "^3.4.4",
"prettier": "^2.8.1",
Expand Down
8 changes: 4 additions & 4 deletions drizzle-kit/src/cli/commands/drop.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import pico from 'picocolors';
import { readFileSync, rmSync, writeFileSync } from 'fs';
import fs from 'fs';
import { render } from 'hanji';
Expand All @@ -19,7 +19,7 @@ export const dropMigration = async ({

if (journal.entries.length === 0) {
console.log(
`[${chalk.blue('i')}] no migration entries found in ${metaFilePath}`,
`[${pico.blue('i')}] no migration entries found in ${metaFilePath}`,
);
return;
}
Expand Down Expand Up @@ -51,8 +51,8 @@ export const dropMigration = async ({
}

console.log(
`[${chalk.green('✓')}] ${
chalk.bold(
`[${pico.green('✓')}] ${
pico.bold(
result.data.tag,
)
} migration successfully dropped`,
Expand Down
38 changes: 19 additions & 19 deletions drizzle-kit/src/cli/commands/introspect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import pico from 'picocolors';
import { writeFileSync } from 'fs';
import { render, renderWithTask } from 'hanji';
import { Minimatch } from 'minimatch';
Expand Down Expand Up @@ -116,7 +116,7 @@ export const introspectPostgres = async (
} else {
render(
`[${
chalk.blue(
pico.blue(
'i',
)
}] No SQL generated, you already have migrations in project`,
Expand All @@ -125,20 +125,20 @@ export const introspectPostgres = async (

render(
`[${
chalk.green(
pico.green(
'✓',
)
}] You schema file is ready ➜ ${chalk.bold.underline.blue(schemaFile)} 🚀`,
}] You schema file is ready ➜ ${pico.blue(pico.bold(pico.underline(schemaFile)))} 🚀`,
);
render(
`[${
chalk.green(
pico.green(
'✓',
)
}] You relations file is ready ➜ ${
chalk.bold.underline.blue(
pico.blue(pico.bold(pico.underline(
relationsFile,
)
)))
} 🚀`,
);
process.exit(0);
Expand Down Expand Up @@ -226,7 +226,7 @@ export const introspectMysql = async (
} else {
render(
`[${
chalk.blue(
pico.blue(
'i',
)
}] No SQL generated, you already have migrations in project`,
Expand All @@ -235,20 +235,20 @@ export const introspectMysql = async (

render(
`[${
chalk.green(
pico.green(
'✓',
)
}] You schema file is ready ➜ ${chalk.bold.underline.blue(schemaFile)} 🚀`,
}] You schema file is ready ➜ ${pico.blue(pico.bold(pico.underline(schemaFile)))} 🚀`,
);
render(
`[${
chalk.green(
pico.green(
'✓',
)
}] You relations file is ready ➜ ${
chalk.bold.underline.blue(
pico.blue(pico.bold(pico.underline(
relationsFile,
)
)))
} 🚀`,
);
process.exit(0);
Expand Down Expand Up @@ -337,7 +337,7 @@ export const introspectSqlite = async (
} else {
render(
`[${
chalk.blue(
pico.blue(
'i',
)
}] No SQL generated, you already have migrations in project`,
Expand All @@ -346,20 +346,20 @@ export const introspectSqlite = async (

render(
`[${
chalk.green(
pico.green(
'✓',
)
}] You schema file is ready ➜ ${chalk.bold.underline.blue(schemaFile)} 🚀`,
}] You schema file is ready ➜ ${pico.blue(pico.bold(pico.underline(schemaFile)))} 🚀`,
);
render(
`[${
chalk.green(
pico.green(
'✓',
)
}] You relations file is ready ➜ ${
chalk.bold.underline.blue(
pico.blue(pico.bold(pico.underline(
relationsFile,
)
)))
} 🚀`,
);
process.exit(0);
Expand Down
44 changes: 22 additions & 22 deletions drizzle-kit/src/cli/commands/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
prepareSqliteMigrationSnapshot,
} from '../../migrationPreparator';

import chalk from 'chalk';
import pico from 'picocolors';
import { render } from 'hanji';
import path, { join } from 'path';
import { TypeOf } from 'zod';
Expand Down Expand Up @@ -276,15 +276,15 @@ function mysqlSchemaSuggestions(
`\n`
+ withStyle.suggestion(
`We are suggesting to change ${
chalk.blue(
pico.blue(
column.name,
)
} column in ${
chalk.blueBright(
pico.blueBright(
table.name,
)
} table from serial to bigint unsigned\n\n${
chalk.blueBright(
pico.blueBright(
`bigint("${column.name}", { mode: "number", unsigned: true }).notNull().autoincrement().unique(${
uniqueForSerial?.name ? `"${uniqueForSerial?.name}"` : ''
})`,
Expand Down Expand Up @@ -526,8 +526,8 @@ export const promptColumnsConflicts = async <T extends Named>(

if (isRenamePromptItem(data)) {
console.log(
`${chalk.yellow('~')} ${data.from.name} › ${data.to.name} ${
chalk.gray(
`${pico.yellow('~')} ${data.from.name} › ${data.to.name} ${
pico.gray(
'column will be renamed',
)
}`,
Expand All @@ -539,8 +539,8 @@ export const promptColumnsConflicts = async <T extends Named>(
leftMissing = leftMissing.filter(Boolean);
} else {
console.log(
`${chalk.green('+')} ${data.name} ${
chalk.gray(
`${pico.green('+')} ${data.name} ${
pico.gray(
'column will be created',
)
}`,
Expand All @@ -550,7 +550,7 @@ export const promptColumnsConflicts = async <T extends Named>(
index += 1;
} while (index < newColumns.length);
console.log(
chalk.gray(`--- all columns conflicts in ${tableName} table resolved ---\n`),
pico.gray(`--- all columns conflicts in ${tableName} table resolved ---\n`),
);

result.deleted.push(...leftMissing);
Expand Down Expand Up @@ -609,8 +609,8 @@ export const promptNamedWithSchemasConflict = async <T extends NamedWithSchema>(
: `${data.to.schema}.`;

console.log(
`${chalk.yellow('~')} ${schemaFromPrefix}${data.from.name} › ${schemaToPrefix}${data.to.name} ${
chalk.gray(
`${pico.yellow('~')} ${schemaFromPrefix}${data.from.name} › ${schemaToPrefix}${data.to.name} ${
pico.gray(
`${entity} will be renamed/moved`,
)
}`,
Expand All @@ -632,8 +632,8 @@ export const promptNamedWithSchemasConflict = async <T extends NamedWithSchema>(
leftMissing = leftMissing.filter(Boolean);
} else {
console.log(
`${chalk.green('+')} ${data.name} ${
chalk.gray(
`${pico.green('+')} ${data.name} ${
pico.gray(
`${entity} will be created`,
)
}`,
Expand All @@ -642,7 +642,7 @@ export const promptNamedWithSchemasConflict = async <T extends NamedWithSchema>(
}
index += 1;
} while (index < newItems.length);
console.log(chalk.gray(`--- all ${entity} conflicts resolved ---\n`));
console.log(pico.gray(`--- all ${entity} conflicts resolved ---\n`));
result.deleted.push(...leftMissing);
return result;
};
Expand Down Expand Up @@ -680,8 +680,8 @@ export const promptSchemasConflict = async <T extends Named>(

if (isRenamePromptItem(data)) {
console.log(
`${chalk.yellow('~')} ${data.from.name} › ${data.to.name} ${
chalk.gray(
`${pico.yellow('~')} ${data.from.name} › ${data.to.name} ${
pico.gray(
'schema will be renamed',
)
}`,
Expand All @@ -691,8 +691,8 @@ export const promptSchemasConflict = async <T extends Named>(
leftMissing = leftMissing.filter(Boolean);
} else {
console.log(
`${chalk.green('+')} ${data.name} ${
chalk.gray(
`${pico.green('+')} ${data.name} ${
pico.gray(
'schema will be created',
)
}`,
Expand All @@ -701,7 +701,7 @@ export const promptSchemasConflict = async <T extends Named>(
}
index += 1;
} while (index < newSchemas.length);
console.log(chalk.gray('--- all schemas conflicts resolved ---\n'));
console.log(pico.gray('--- all schemas conflicts resolved ---\n'));
result.deleted.push(...leftMissing);
return result;
};
Expand Down Expand Up @@ -799,12 +799,12 @@ export const writeResult = ({

render(
`[${
chalk.green(
pico.green(
'✓',
)
}] Your SQL migration file ➜ ${
chalk.bold.underline.blue(
path.join(`${outFolder}/${tag}.sql`),
pico.blue(pico.bold(pico.underline(
path.join(`${outFolder}/${tag}.sql`),))
)
} 🚀`,
);
Expand Down
26 changes: 13 additions & 13 deletions drizzle-kit/src/cli/commands/mysqlPushUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import pico from 'picocolors';
import { render } from 'hanji';
import { TypeOf } from 'zod';
import { JsonAlterColumnTypeStatement, JsonStatement } from '../../jsonStatements';
Expand Down Expand Up @@ -127,7 +127,7 @@ export const logSuggestionsAndReturn = async (
if (count > 0) {
infoToPrint.push(
`· You're about to delete ${
chalk.underline(
pico.underline(
statement.tableName,
)
} table with ${count} items`,
Expand All @@ -143,7 +143,7 @@ export const logSuggestionsAndReturn = async (
if (count > 0) {
infoToPrint.push(
`· You're about to delete ${
chalk.underline(
pico.underline(
statement.columnName,
)
} column in ${statement.tableName} table with ${count} items`,
Expand All @@ -159,7 +159,7 @@ export const logSuggestionsAndReturn = async (
if (count > 0) {
infoToPrint.push(
`· You're about to delete ${
chalk.underline(
pico.underline(
statement.name,
)
} schema with ${count} tables`,
Expand All @@ -175,14 +175,14 @@ export const logSuggestionsAndReturn = async (
if (count > 0) {
infoToPrint.push(
`· You're about to change ${
chalk.underline(
pico.underline(
statement.columnName,
)
} column type from ${
chalk.underline(
pico.underline(
statement.oldDataType,
)
} to ${chalk.underline(statement.newDataType)} with ${count} items`,
} to ${pico.underline(statement.newDataType)} with ${count} items`,
);
statementsToExecute.push(`truncate table ${statement.tableName};`);
tablesToTruncate.push(statement.tableName);
Expand All @@ -198,7 +198,7 @@ export const logSuggestionsAndReturn = async (
if (count > 0) {
infoToPrint.push(
`· You're about to remove default value from ${
chalk.underline(
pico.underline(
statement.columnName,
)
} not-null column with ${count} items`,
Expand All @@ -221,7 +221,7 @@ export const logSuggestionsAndReturn = async (
if (count > 0) {
infoToPrint.push(
`· You're about to set not-null constraint to ${
chalk.underline(
pico.underline(
statement.columnName,
)
} column without default, which contains ${count} items`,
Expand Down Expand Up @@ -258,7 +258,7 @@ export const logSuggestionsAndReturn = async (
if (count > 0) {
infoToPrint.push(
`· You're about to change ${
chalk.underline(
pico.underline(
statement.tableName,
)
} primary key. This statements may fail and you table may left without primary key`,
Expand Down Expand Up @@ -295,7 +295,7 @@ export const logSuggestionsAndReturn = async (
if (count > 0) {
infoToPrint.push(
`· You're about to add not-null ${
chalk.underline(
pico.underline(
statement.column.name,
)
} column without default value, which contains ${count} items`,
Expand All @@ -316,11 +316,11 @@ export const logSuggestionsAndReturn = async (
const unsquashedUnique = MySqlSquasher.unsquashUnique(statement.data);
console.log(
`· You're about to add ${
chalk.underline(
pico.underline(
unsquashedUnique.name,
)
} unique constraint to the table, which contains ${count} items. If this statement fails, you will receive an error from the database. Do you want to truncate ${
chalk.underline(
pico.underline(
statement.tableName,
)
} table?\n`,
Expand Down
2 changes: 1 addition & 1 deletion drizzle-kit/src/cli/commands/mysqlUp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import pico from 'picocolors';
import fs, { writeFileSync } from 'fs';
import path from 'path';
import { Column, MySqlSchema, MySqlSchemaV4, MySqlSchemaV5, mysqlSchemaV5, Table } from '../../serializer/mysqlSchema';
Expand Down
Loading