Skip to content

Commit 82fbb41

Browse files
committed
💥 NEW: MySQL added
1 parent a7c0e07 commit 82fbb41

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"formatter": {
1414
"enabled": true,
1515
"indentStyle": "tab",
16-
"lineWidth": 180,
16+
"lineWidth": 110,
1717
"indentWidth": 4
1818
},
1919
"organizeImports": {

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@
4444
"build": "tsdown",
4545
"lint": "biome lint",
4646
"format": "biome format --write",
47-
"dev": "bun src/index.ts",
4847
"copy-templates": "xcopy \"templates\" \"dist\\templates\" /E /I /Y",
49-
"link": "bun run build && bun copy-templates && bun link"
48+
"link": "pnpm run build && pnpm copy-templates && pnpm link"
5049
},
5150
"devDependencies": {
5251
"@biomejs/biome": "1.9.4",

src/configs/databases/mysql.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const MySQLlDatabasesConfigs = [
2+
{
3+
name: 'MySQL',
4+
path: 'mysql',
5+
template_path: 'templates/mysql/mysql',
6+
env_var: {
7+
DATABASE_URL: 'jdbc:mysql://localhost:3306/your_database_name',
8+
},
9+
packages: ['drizzle-orm', 'mysql2', 'dotenv', 'drizzle-kit -D'],
10+
},
11+
]
12+
13+
export function getMySQLlDatabasesConfigs() {
14+
return MySQLlDatabasesConfigs.map((config) => {
15+
return {
16+
label: config.name,
17+
value: config.path,
18+
}
19+
})
20+
}
21+
22+
export default MySQLlDatabasesConfigs

src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import createConfigFile from './utils/drizzle-config-update'
99
import pkgMangerRun from './utils/pkg-manger-run'
1010
import dbLists, { dbListsByValue } from './configs/dblists'
1111
import UpdateScripts from './utils/update-scripts'
12+
import MySQLlDatabasesConfigs, { getMySQLlDatabasesConfigs } from './configs/databases/mysql'
1213

1314
const __dirname = path.dirname(fileURLToPath(import.meta.url))
14-
const databaseConfigs = [...PostgresqlDatabasesConfigs, ...SQLiteDatabasesConfigs]
15+
const databaseConfigs = [...PostgresqlDatabasesConfigs, ...SQLiteDatabasesConfigs, ...MySQLlDatabasesConfigs]
1516

1617
const databaseGroups = {
1718
PostgreSQL: getPostgresqlDatabasesConfigs(),
1819
SQLite: getSQLiteDatabasesConfigs(),
20+
MySQL: getMySQLlDatabasesConfigs(),
1921
}
2022

2123
const dbGroup = await select({
@@ -49,7 +51,6 @@ if (dbPath === undefined) {
4951
}
5052

5153
// move to template = dbPath
52-
5354
const dbConfig = databaseConfigs.find((config) => config.path === dbOption)
5455

5556
if (dbConfig === undefined) {
@@ -136,6 +137,8 @@ try {
136137
)
137138
} catch (err) {
138139
s.stop('🚨 Failed to install packages')
139-
console.error('😞 Installation failed. Please check your internet connection and \nverify that your package manager is installed and functioning correctly.')
140+
console.error(
141+
'😞 Installation failed. Please check your internet connection and \nverify that your package manager is installed and functioning correctly.',
142+
)
140143
process.exit(1)
141144
}

src/utils/drizzle-config-update.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import fs from 'fs-extra'
22

3-
async function createConfigFile(drizzle_configTargetPath: string, drizzle_configPath: string, dbPath: string) {
3+
async function createConfigFile(
4+
drizzle_configTargetPath: string,
5+
drizzle_configPath: string,
6+
dbPath: string,
7+
) {
48
// Read the template file content as text
59
let content = await fs.readFile(drizzle_configPath, 'utf-8')
610

0 commit comments

Comments
 (0)