-
Notifications
You must be signed in to change notification settings - Fork 0
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
12 changed files
with
135 additions
and
97 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env node | ||
import { setup } from './setup/index.mjs'; | ||
import { executeMigrationWorkflow } from './index.js'; | ||
|
||
function getFlags(argv): Record<string, string | boolean> { | ||
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; | ||
} | ||
|
||
// Entry point for the CLI | ||
async function main() { | ||
const flags: { | ||
setup?: boolean; | ||
'skip-check'?: boolean; | ||
'prisma-folder-path'?: string; | ||
} = getFlags(process.argv); | ||
|
||
if (flags.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'; | ||
try { | ||
await executeMigrationWorkflow({ skipCheck, prismaFolderPath }); | ||
process.exit(0); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
|
||
main(); |
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
Oops, something went wrong.