prisma-migration-migrator
Advanced tools
Comparing version 0.0.19 to 0.0.20
@@ -1,2 +0,1 @@ | ||
#!/usr/bin/env node | ||
import type { MigratorParameters } from './migrator/types.js'; | ||
@@ -3,0 +2,0 @@ import { migrator } from './migrator/index.js'; |
@@ -1,2 +0,1 @@ | ||
#!/usr/bin/env node | ||
import { fileURLToPath } from 'node:url'; | ||
@@ -6,23 +5,24 @@ import { migrator } from './migrator/index.js'; | ||
import { checkIfSetupIsNeeded } from './setup/pre-check.mjs'; | ||
import { errorLog, successLog, warningLog } from './setup/textStyles.mjs'; | ||
async function executeMigrator({ skipCheck, prismaFolderPath, }) { | ||
async function executeMigrator() { | ||
const args = process.argv.slice(3); | ||
const prismaFolderPath = args[2] || 'prisma'; | ||
try { | ||
if (!skipCheck) { | ||
if (!args.includes('--skip-check')) { | ||
console.log('> No --skip-check flag detected. Checking if setup is needed for knex to run alongside prisma...'); | ||
const setupNeeded = await checkIfSetupIsNeeded({ prismaFolderPath }); | ||
if (setupNeeded) { | ||
warningLog(`> Setup is needed. Running setup for knex to run alongside prisma...`); | ||
console.log(`> Setup is needed. Running setup for knex to run alongside prisma...`); | ||
await setup(); | ||
successLog('> Setup completed. Continuing with the migration conversion process...'); | ||
console.log('> Setup completed. Continuing with the migration conversion process...'); | ||
} | ||
else { | ||
successLog('> Setup is not needed. Continuing with the migration conversion process...'); | ||
console.log('> Setup is not needed. Continuing with the migration conversion process...'); | ||
} | ||
} | ||
await migrator({ prismaFolderPath }); | ||
successLog(`Migrations converted successfully. Check the migrations directory.`); | ||
console.log(`Migrations converted successfully. Check the migrations directory.`); | ||
process.exit(0); | ||
} | ||
catch (err) { | ||
errorLog(`Error converting migrations. Check the error message below for more information.`); | ||
console.error(`Error converting migrations. Check the error message below for more information.`); | ||
console.error(err); | ||
@@ -32,24 +32,9 @@ process.exit(1); | ||
} | ||
function getFlags(argv) { | ||
const filterArgs = (flag) => flag.includes('--'); | ||
const mapFlags = (flag) => flag.split('--')[1].split('='); | ||
const args = argv.slice(2).filter(filterArgs).map(mapFlags); | ||
const flagsObj = {}; | ||
for (const arg of args) { | ||
flagsObj[arg[0]] = arg[1] || true; | ||
} | ||
return flagsObj; | ||
} | ||
async function main() { | ||
const flags = getFlags(process.argv); | ||
if (flags.setup) { | ||
const args = process.argv.slice(2); | ||
if (args.includes('--setup')) { | ||
await setup(); | ||
} | ||
else { | ||
const skipCheck = !!flags['skip-check']; | ||
const prismaFolderPath = flags['prisma-folder-path'] && | ||
typeof flags['prisma-folder-path'] === 'string' | ||
? flags['prisma-folder-path'] | ||
: 'prisma'; | ||
await executeMigrator({ skipCheck, prismaFolderPath }); | ||
await executeMigrator(); | ||
} | ||
@@ -56,0 +41,0 @@ } |
{ | ||
"name": "prisma-migration-migrator", | ||
"version": "0.0.19", | ||
"version": "0.0.20", | ||
"description": "Replace Prisma as the migration engine with Knex, while keeping it as ORM", | ||
@@ -15,3 +15,2 @@ "type": "module", | ||
}, | ||
"main": "dist/index.js", | ||
"scripts": { | ||
@@ -18,0 +17,0 @@ "build": "rm -rf dist && rm -rf tsconfig.build.tsbuildinfo && tsc --project tsconfig.build.json", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
74070
798