@noego/proper 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +1140 -0
- package/bin/cli.js.map +1 -0
- package/bin/cli.mjs +1192 -0
- package/bin/cli.mjs.map +1 -0
- package/bin/index.js +971 -0
- package/bin/index.js.map +1 -0
- package/bin/index.mjs +935 -0
- package/bin/index.mjs.map +1 -0
- package/package.json +55 -0
- package/readme.md +236 -0
package/bin/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../cli.ts","../framework/MigrationCLi.ts","../framework/MigrationFilter.ts","../framework/MigrationRunner.ts","../framework/MigrationDirectoryReader.ts","../framework/errors.ts","../framework/MigrationNode.ts","../framework/SqlMigrationBuilder.ts","../framework/MigrationSetup.ts","../framework/MigrationDialectParser.ts","../framework/SQLRunner.ts"],"sourcesContent":["#!/usr/bin/env node\nimport 'source-map-support/register';\n\nimport { MigrationCLIFactory } from \"./framework/MigrationCLi\";\nimport { migration_filter } from \"./framework/MigrationFilter\";\nimport { MigrationRunnerFactory } from \"./framework/MigrationRunner\";\nimport { CLIError } from \"./framework/errors\";\n\nconst args = MigrationCLIFactory.setup(process.argv);\n\n// Validate that at least one command is provided\nif (!args.commands || args.commands.length === 0) {\n console.error(\"Error: No command specified\");\n printUsage();\n process.exit(1);\n}\n\nconst commands = args.commands;\nconst command = commands[0];\nconst load_database = ![\"init\", 'create', 'help'].includes(command.toLowerCase());\nconst config_file = args.flags.config || \"proper.json\";\n\n// Handle help command\nif (command.toLowerCase() === 'help') {\n printUsage();\n process.exit(0);\n}\n\nconsole.log(`Loading database: ${load_database}`);\n\nconst pending_runner = load_database ?\n MigrationRunnerFactory.create(config_file) :\n MigrationRunnerFactory.createEmpty(config_file);\n\npending_runner.then(async runner => {\n try {\n if (load_database) {\n await runner.setup();\n }\n\n switch (command.toLowerCase()) {\n case \"up\":\n const migrations_forward = await runner.getMigrations();\n let upgraded = await migration_filter(migrations_forward, false);\n\n if (args.flags.increment) {\n const increment = parseInt(args.flags.increment);\n upgraded = upgraded.slice(0, increment);\n }\n\n console.log(`Applying ${upgraded.length} migration(s)`);\n\n if (upgraded.length > 0) {\n for (const migration of upgraded) {\n console.log(` - ${migration.name}`);\n }\n\n await runner.migrate(upgraded, true);\n console.log(\"Migration completed successfully\");\n } else {\n console.log(\"No pending migrations\");\n }\n await runner.close();\n break;\n\n case \"down\":\n const migrations_rollback = await runner.getMigrations();\n let downgraded = await migration_filter(migrations_rollback, true);\n\n downgraded = downgraded.reverse();\n\n if (args.flags.increment) {\n const increment = parseInt(args.flags.increment);\n downgraded = downgraded.slice(0, increment);\n }\n\n console.log(`Rolling back ${downgraded.length} migration(s)`);\n if (downgraded.length > 0) {\n for (const migration of downgraded) {\n console.log(` - ${migration.name}`);\n }\n\n await runner.migrate(downgraded, false);\n console.log(\"Rollback completed successfully\");\n } else {\n console.log(\"No migrations to roll back\");\n }\n\n await runner.close();\n break;\n\n case \"reset\":\n console.log(\"Resetting all migrations...\");\n await runner.reset();\n console.log(\"Reset completed successfully\");\n await runner.close();\n break;\n\n case \"create\":\n let filename = args.flags.name || commands[1];\n\n if (!filename) {\n throw new CLIError(\"Migration name is required\");\n }\n\n filename = filename.replace(/\\s/g, \"_\");\n runner.createMigration(filename);\n runner.close();\n break;\n\n case \"init\":\n await runner.init(config_file);\n runner.close();\n break;\n\n case \"status\":\n const { printTable } = require('console-table-printer');\n const migrations = await runner.getMigrations();\n\n console.log(\"Migration Status:\");\n\n const table = migrations.map(async m => {\n const status = await m.status();\n return {\n key: m.get_key(),\n status: status.completed ? \"completed\" : \"pending\",\n };\n });\n\n printTable(await Promise.all(table));\n runner.close();\n break;\n\n default:\n throw CLIError.unknownCommand(command);\n }\n\n } catch (error: any) {\n console.error(`Error: ${error.message}`);\n if (error.stack && process.env.DEBUG) {\n console.error(error.stack);\n }\n process.exit(1);\n }\n});\n\nfunction printUsage() {\n console.log(`\nSQL Proper - Database migration tool\n\nUsage: \n proper <command> [options]\n\nCommands:\n up Apply pending migrations\n down Roll back completed migrations\n reset Roll back all migrations and reapply them\n create Create a new migration\n init Initialize a new config file\n status Show migration status\n help Show this help message\n\nOptions:\n -c, --config Specify the config file (default: proper.json)\n --increment <n> Limit the number of migrations to apply or roll back\n\nExamples:\n proper up Apply all pending migrations\n proper up --increment 1 Apply only the next pending migration\n proper down Roll back the last applied migration\n proper create my_migration Create a new migration named \"my_migration\"\n proper init Create a new config file\n proper status Show the status of all migrations\n proper -c custom.json up Use a custom config file\n `);\n}\n","import minimist from \"minimist\";\n\nexport class MigrationCLIFactory {\n /**\n * Parse command line arguments into commands and flags\n * @param argv Optional array of command line arguments. If not provided, process.argv will be used.\n * @returns Object containing parsed commands and flags\n */\n static setup(argv?: string[]): { commands: string[], flags: Record<string, any> } {\n // Use provided args or default to process.argv\n const args = argv || process.argv;\n \n // Determine where to start slicing the arguments\n // We need to handle different invocation patterns:\n // 1. node script.js command => skip 'node' and 'script.js' \n // 2. ./cli.js command => skip './cli.js'\n // 3. proper command => skip 'proper' (likely a symlink to the script)\n // 4. command arg1 arg2 => don't skip anything (direct command invocation)\n let startIndex = 0;\n \n // Check for node\n if (args[0]?.includes('node')) {\n startIndex = 2; // Skip 'node' and script name\n }\n // Check for script file extensions\n else if (args[0] && /\\.(js|ts|mjs|cjs)$/i.test(args[0])) {\n startIndex = 1; // Skip just the script name\n }\n // Check for command name that might be a symlink to this script\n else if (args[0] && ['proper', 'migration', 'sql-proper'].includes(args[0].toLowerCase())) {\n startIndex = 1; // Skip the command name\n }\n \n // Parse the arguments\n const cli = minimist(args.slice(startIndex), {\n alias: {\n c: 'config',\n },\n });\n\n const { _: commands, ...flags } = cli;\n\n return {\n commands,\n flags\n };\n }\n}","import { MigrationNode } from \"./MigrationNode\";\n\n\n\n\nexport async function migration_filter(migrations:MigrationNode[],completed:boolean=true,keep:MigrationNode[]=[]){\n if(migrations.length === 0){\n return keep\n }\n\n const [first,...rest] = migrations\n\n const status = await first.status()\n\n if(status.completed == completed){\n keep.push(first)\n }\n\n return migration_filter(rest,completed,keep)\n}","// Node built-in modules\nimport fs from 'fs';\n\n// Database drivers\nimport mysql from 'mysql2/promise';\nimport * as sqlite from 'sqlite';\nimport * as sqlite3 from 'sqlite3';\n\n// Helper function to convert any error to Error object\nfunction toError(error: unknown): Error {\n if (error instanceof Error) return error;\n return new Error(String(error));\n}\n\n// Migration framework\nimport { MigrationConfig } from \"./MigrationConfig\";\nimport { MigrationDirectoryReader } from './MigrationDirectoryReader';\nimport { MigrationNode } from './MigrationNode';\nimport { MigrationSetup } from './MigrationSetup';\nimport { migration_filter } from './MigrationFilter';\nimport * as dialect from \"./MigrationDialectParser\";\n\n\nimport { ISQLRunner,SQLRunner,SQLiteRunner } from './SQLRunner';\nimport { ErrorMessage } from './ErrorMessage';\nimport { \n ConfigurationError, \n DatabaseConnectionError, \n MigrationExecutionError,\n CLIError \n} from './errors';\n\n\nexport class MigrationRunnerFactory {\n\n static async create(configFile:string,conn?:any){\n const configReader = new FileMigrationConfigReader(configFile);\n const config = configReader.loadFile();\n\n if(!conn){\n conn = await this.createConnection(config)\n }\n return new MigrationRunnerFactory().create(config,conn)\n }\n\n static async createConnection(config:MigrationConfig){\n let conn = null as any\n switch(config.database){\n case \"sql\":\n if (!config.sql){\n throw ConfigurationError.missingDatabaseConfiguration(\"sql\");\n }\n const settings = Object.assign({\n password:process.env.SQL_PASSWORD\n },config.sql);\n try {\n conn = await mysql.createConnection(settings);\n return conn;\n } catch (error) {\n throw DatabaseConnectionError.connectionFailed(\"sql\", toError(error).message);\n }\n case \"sqlite\":\n if (!config.sqlite){\n throw ConfigurationError.missingDatabaseConfiguration(\"sqlite\");\n }\n try {\n conn = await sqlite.open({\n filename:config.sqlite.database,\n driver:sqlite3.Database\n });\n return conn;\n } catch (error) {\n throw DatabaseConnectionError.connectionFailed(\"sqlite\", toError(error).message);\n }\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n \n }\n\n static async createEmpty(configFile:string){\n const configReader = new FileMigrationConfigReader(configFile);\n const config = configReader.loadFile();\n return new MigrationRunnerFactory().createEmpty(config)\n }\n\n\n async create(config:MigrationConfig,conn:any):Promise<MySQLMigrationRunner>{\n let sqlrunner:ISQLRunner\n switch(config.database){\n case \"sql\":\n sqlrunner = new SQLRunner(conn)\n break;\n case \"sqlite\":\n sqlrunner = new SQLiteRunner(conn)\n break;\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n const setup = new MigrationSetup(sqlrunner,config);\n const read_strategy = this.getReadStategy(config)\n\n const migration_files = new MigrationDirectoryReader(config.migration_folder,read_strategy,sqlrunner)\n\n // Ensure the migrations infrastructure (i.e. the migrations table)\n // exists before we hand the runner back to the caller – most callers\n // expect the runner to be immediately usable without having to invoke\n // `setup()` manually. This is particularly important for projects\n // (like Groom) that directly call `getMigrations()` and\n // `migrate(...)` after obtaining the runner.\n await setup.setup();\n\n return new MySQLMigrationRunner(config,migration_files,setup,sqlrunner,conn);\n }\n\n\n async createEmpty(config:MigrationConfig):Promise<MySQLMigrationRunner>{\n const conn = null as any\n let sqlrunner:ISQLRunner\n\n switch(config.database){\n case \"sql\":\n sqlrunner = new SQLRunner(conn)\n break;\n case \"sqlite\":\n sqlrunner = new SQLiteRunner(conn)\n break;\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n const setup = new MigrationSetup(sqlrunner,config);\n const read_strategy = this.getReadStategy(config)\n \n const migration_files = new MigrationDirectoryReader(config.migration_folder,read_strategy,sqlrunner)\n return new MySQLMigrationRunner(config,migration_files,setup,sqlrunner,conn);\n }\n\n private getReadStategy(config:MigrationConfig){\n switch(config.database){\n case \"sql\":\n return dialect.MySqlDialectParser\n case \"sqlite\":\n return dialect.SqliteDialectParser\n default:\n throw ConfigurationError.unknownDatabaseType(config.database);\n }\n }\n}\n\n\nexport interface MigrationHistory{\n name:string\n up:string\n down:string\n}\n\nexport interface IMigrationRunner {\n setup(): Promise<void>;\n terminate(): Promise<void>;\n getMigrationsHistory(): Promise<MigrationHistory[]>;\n getMigrations(): Promise<MigrationNode[]>;\n getPendingMigrations(): Promise<MigrationNode[]>;\n getCompletedMigrations(): Promise<MigrationNode[]>;\n migrate(migrationNodes: MigrationNode[], forward: boolean): Promise<void>;\n reset(): Promise<void>;\n createMigration(name: string): void;\n close(): Promise<void>;\n init(config_file: string): Promise<void>;\n}\n\nexport class MySQLMigrationRunner implements IMigrationRunner {\n constructor(\n private config:MigrationConfig,\n private directory:MigrationDirectoryReader,\n private setupRunner:MigrationSetup,\n private sqlrunner:ISQLRunner,\n private connection:mysql.Connection\n){\n\n }\n\n async setup(){\n try {\n await this.setupRunner.setup();\n } catch (error) {\n throw new MigrationExecutionError('Failed to set up migration database', undefined, undefined, toError(error));\n }\n }\n\n async terminate(){\n try {\n await this.setupRunner.teardown();\n } catch (error) {\n throw new MigrationExecutionError('Failed to tear down migration database', undefined, undefined, toError(error));\n }\n }\n\n async getMigrationsHistory():Promise<MigrationHistory[]>{\n try {\n const results = await this.sqlrunner.query(`\n select * \n from ${this.config.migration_table}\n `);\n return results[0] as any;\n } catch (error) {\n throw new MigrationExecutionError('Failed to get migration history', undefined, undefined, toError(error));\n }\n }\n\n\n async getMigrations(){\n try {\n return this.directory.loadMigrations(this.config.migration_table,this.connection);\n } catch (error) {\n throw new MigrationExecutionError('Failed to load migrations', undefined, undefined, toError(error));\n }\n }\n\n async getPendingMigrations(){\n try {\n const migrations = await this.getMigrations();\n return migration_filter(migrations,false);\n } catch (error) {\n if (error instanceof MigrationExecutionError) {\n throw error;\n }\n throw new MigrationExecutionError('Failed to get pending migrations', undefined, undefined, toError(error));\n }\n }\n\n async getCompletedMigrations(){\n try {\n const migrations = await this.getMigrations();\n return migration_filter(migrations,true);\n } catch (error) {\n if (error instanceof MigrationExecutionError) {\n throw error;\n }\n throw new MigrationExecutionError('Failed to get completed migrations', undefined, undefined, toError(error));\n }\n }\n\n async migrate(migrationNodes:MigrationNode[],forward:boolean):Promise<void>{\n for(let node of migrationNodes){\n try {\n if(forward){\n await node.up();\n }else{\n await node.down();\n }\n } catch (error) {\n throw new MigrationExecutionError(\n `Failed to ${forward ? 'apply' : 'rollback'} migration`,\n node.name || String(node),\n forward ? node.up_sql() : node.down_sql(),\n toError(error)\n );\n }\n }\n }\n\n\n async reset(){\n try {\n let migrations = await this.getMigrations();\n const rollback = await migration_filter(migrations,true);\n await this.migrate(rollback.reverse(),false);\n migrations = await this.getMigrations();\n const rollforward = await migration_filter(migrations,false);\n await this.migrate(rollforward,true);\n } catch (error) {\n if (error instanceof MigrationExecutionError) {\n throw error;\n }\n throw new MigrationExecutionError('Failed to reset migrations', undefined, undefined, toError(error));\n }\n }\n\n\n createMigration(name:string){\n try {\n const creator = new MigrationCreator(this.config);\n creator.create(name);\n } catch (error) {\n throw new MigrationExecutionError(`Failed to create migration: ${name}`, undefined, undefined, toError(error));\n }\n }\n\n\n async close(){\n if (this.sqlrunner) {\n try {\n await this.sqlrunner.end();\n } catch (error) {\n throw new DatabaseConnectionError(`Failed to close database connection: ${toError(error).message}`);\n }\n }\n }\n\n\n async init(config_file:string){\n try {\n console.log(`Checking for ${config_file}`);\n const config_exist = fs.existsSync(config_file);\n\n if(!config_exist){\n console.log(`Creating ${config_file}`);\n const default_config = {\n \"migration_folder\":\"migrations\",\n \"migration_table\":\"proper_migrations\",\n \"database\": \"sql\",\n \"sql\":{\n \"host\":\"localhost\",\n \"user\":\"root\",\n \"database\":\"proper\",\n \"password\":\"\"\n }\n };\n fs.writeFileSync(config_file,JSON.stringify(default_config,null,2)); \n console.log(`Created ${config_file}`);\n }\n } catch (error) {\n throw new ConfigurationError(`Failed to initialize config file: ${toError(error).message}`);\n }\n }\n}\n\n\nexport class FileMigrationConfigReader{\n\n constructor(private configFile:string){\n\n }\n\n loadFile(){\n try {\n const fileContent = fs.readFileSync(this.configFile);\n const config:MigrationConfig = JSON.parse(fileContent.toString());\n \n // Validate required fields\n if (!config.migration_folder) {\n throw ConfigurationError.missingRequiredProperty('migration_folder');\n }\n \n if (!config.migration_table) {\n throw ConfigurationError.missingRequiredProperty('migration_table');\n }\n \n // For backward compatibility: if database type is omitted we derive\n // it from the presence of the dialect specific configuration\n // blocks. This keeps older `proper.json` files – that only defined\n // an \"sql\" or \"sqlite\" section – working without modification.\n if (!config.database) {\n if (config.sql) {\n config.database = 'sql';\n } else if (config.sqlite) {\n config.database = 'sqlite';\n } else {\n throw ConfigurationError.missingRequiredProperty('database');\n }\n }\n \n return config;\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error;\n }\n const err = toError(error);\n if (err.message.includes('ENOENT')) {\n throw new ConfigurationError(`Config file not found: ${this.configFile}`);\n }\n throw new ConfigurationError(`Failed to load config file: ${err.message}`);\n }\n }\n}\n\n\nexport class MigrationCreator{\n constructor(private config:MigrationConfig){\n \n }\n\n\n create(name:string){\n if (!name) {\n throw new CLIError('Migration name is required');\n }\n\n try {\n // Ensure the migration folder exists\n if (!fs.existsSync(this.config.migration_folder)) {\n fs.mkdirSync(this.config.migration_folder, { recursive: true });\n }\n\n const now_timestamp = Date.now();\n\n const filename_up = `${now_timestamp}_${name}.up.sql`;\n const filename_down = `${now_timestamp}_${name}.down.sql`;\n\n fs.writeFileSync(`${this.config.migration_folder}/${filename_up}`,`\n-- Write your up migration here\n `.trim());\n\n fs.writeFileSync(`${this.config.migration_folder}/${filename_down}`,`\n-- Write your down migration here\n `.trim());\n \n console.log(`Created migration files:`);\n console.log(` ${filename_up}`);\n console.log(` ${filename_down}`);\n } catch (error) {\n if (error instanceof CLIError) {\n throw error;\n }\n throw new MigrationExecutionError(`Failed to create migration files: ${toError(error).message}`);\n }\n }\n}","import fs from \"fs\";\nimport path from \"path\";\nimport { MigrationNode } from './MigrationNode';\nimport { SqlMigrationBuilder } from './SqlMigrationBuilder';\nimport mysql from \"mysql2/promise\";\nimport { ISQLRunner } from \"./SQLRunner\";\n\n\nexport interface MigrationOptions{\n conn:mysql.Connection\n}\n\nexport class MigrationDirectoryReader {\n\n constructor(private directory: string,private read_strategy:any,private sqlrunner:ISQLRunner) {\n \n }\n\n loadMigrations(table:string,connection:any):MigrationNode[] {\n\n fs.existsSync(this.directory) || fs.mkdirSync(this.directory);\n const dir_content = fs.readdirSync(this.directory,{withFileTypes:true}).filter(file=>file.isFile()).map(file=>file.name);\n\n let migration_files = dir_content.map(file => {\n return {\n migration_key: file.replace(/\\.(up|down)\\.(sql|js)/i, \"\").toLowerCase(),\n directory: this.directory,\n relative_path: path.join(this.directory, file),\n file,\n };\n }).sort();\n\n\n const migration_sorter: any = {};\n\n migration_files.forEach((migration) => {\n const builder = migration_sorter[migration.migration_key] = migration_sorter[migration.migration_key] || new SqlMigrationBuilder(migration.migration_key);\n this.loadMigration(builder, migration.relative_path);\n });\n\n\n const keys = Object.keys(migration_sorter)\n\n keys.sort()\n\n const built = keys.map(key=>{\n return migration_sorter[key].build(table,this.sqlrunner) \n })\n return built\n\n }\n\n\n loadMigration(builder: SqlMigrationBuilder, file: string) {\n const is_sql = /sql$/i.test(file);\n const is_js = /js$/i.test(file);\n const is_up = /up\\.(js|sql)/i.test(file);\n const is_down = /down\\.(js|sql)/i.test(file);\n if (is_sql && is_up) {\n const content = this.sql_up(file);\n builder.set_up(file,content);\n } else if (is_sql && is_down) {\n const content = this.sql_down(file);\n builder.set_down(file,content);\n } else {\n throw new Error(`Invalid migration file: ${file}`);\n }\n return builder;\n }\n\n\n sql_up(file: string) {\n let content = fs.readFileSync(file).toString();\n content = this.read_strategy(content);\n return content.trim();\n }\n\n sql_down(file: string) {\n let content = fs.readFileSync(file).toString();\n content = this.read_strategy(content);\n return content.trim();\n }\n\n}\n","/**\n * Base class for all migration-related errors\n */\nexport class MigrationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'MigrationError';\n // This is needed to make instanceof work correctly in ES5\n Object.setPrototypeOf(this, MigrationError.prototype);\n }\n}\n\n/**\n * Error thrown when there is an issue with the configuration\n */\nexport class ConfigurationError extends MigrationError {\n constructor(message: string) {\n super(`Configuration Error: ${message}`);\n this.name = 'ConfigurationError';\n Object.setPrototypeOf(this, ConfigurationError.prototype);\n }\n\n /**\n * Helper method for missing database configuration\n * @param dbType The database type (e.g., 'sql', 'sqlite')\n * @returns A ConfigurationError with appropriate message\n */\n static missingDatabaseConfiguration(dbType: string): ConfigurationError {\n return new ConfigurationError(`Missing ${dbType} configuration`);\n }\n\n /**\n * Helper method for unknown database type\n * @param dbType The unknown database type\n * @returns A ConfigurationError with appropriate message\n */\n static unknownDatabaseType(dbType: string): ConfigurationError {\n return new ConfigurationError(`Unknown database type: ${dbType}`);\n }\n\n /**\n * Helper method for missing required configuration properties\n * @param property The name of the missing property\n * @returns A ConfigurationError with appropriate message\n */\n static missingRequiredProperty(property: string): ConfigurationError {\n return new ConfigurationError(`Missing required property: ${property}`);\n }\n}\n\n/**\n * Error thrown when there is an issue with the database connection\n */\nexport class DatabaseConnectionError extends MigrationError {\n constructor(message: string) {\n super(`Database Connection Error: ${message}`);\n this.name = 'DatabaseConnectionError';\n Object.setPrototypeOf(this, DatabaseConnectionError.prototype);\n }\n\n /**\n * Helper method for connection errors\n * @param dbType The database type (e.g., 'sql', 'sqlite')\n * @param details Additional error details\n * @returns A DatabaseConnectionError with appropriate message\n */\n static connectionFailed(dbType: string, details?: string): DatabaseConnectionError {\n const message = details \n ? `Failed to connect to ${dbType} database: ${details}`\n : `Failed to connect to ${dbType} database`;\n return new DatabaseConnectionError(message);\n }\n\n /**\n * Helper method for authentication errors\n * @param dbType The database type (e.g., 'sql', 'sqlite')\n * @returns A DatabaseConnectionError with appropriate message\n */\n static authenticationFailed(dbType: string): DatabaseConnectionError {\n return new DatabaseConnectionError(`Authentication failed for ${dbType} database`);\n }\n}\n\n/**\n * Error thrown when there is an issue with executing a migration\n */\nexport class MigrationExecutionError extends MigrationError {\n constructor(\n message: string,\n public readonly migrationName?: string,\n public readonly sql?: string,\n public readonly originalError?: Error\n ) {\n /*\n * The public `message` that gets surfaced to callers **must not** include the\n * raw SQL text. The SQL string is already exposed through the dedicated\n * `sql` property and adding it to the message makes it unnecessarily noisy\n * and difficult to assert against in unit-tests. Therefore we only embed\n * the essential information (error type, optional migration name and the\n * short error message) in the main message string while keeping the full\n * SQL available separately.\n */\n let fullMessage = `Migration Execution Error${migrationName ? ` in '${migrationName}'` : ''}: ${message}`;\n\n if(originalError){\n fullMessage += `\\nOriginal Error:\\n${originalError.message}`;\n }\n\n super(fullMessage);\n this.name = 'MigrationExecutionError';\n Object.setPrototypeOf(this, MigrationExecutionError.prototype);\n }\n\n /**\n * Helper method for SQL execution errors\n * @param migrationName The name of the migration\n * @param sql The SQL that caused the error\n * @param originalError The original error thrown by the database driver\n * @returns A MigrationExecutionError with appropriate message\n */\n static sqlExecutionFailed(migrationName: string, sql: string, originalError: Error): MigrationExecutionError {\n return new MigrationExecutionError(\n originalError.message,\n migrationName,\n sql,\n originalError\n );\n }\n\n /**\n * Helper method for missing migration file errors\n * @param filename The missing file\n * @returns A MigrationExecutionError with appropriate message\n */\n static missingMigrationFile(filename: string): MigrationExecutionError {\n return new MigrationExecutionError(`Migration file not found: ${filename}`);\n }\n\n /**\n * Helper method for invalid migration file format errors\n * @param filename The invalid file\n * @param details Additional error details\n * @returns A MigrationExecutionError with appropriate message\n */\n static invalidMigrationFile(filename: string, details?: string): MigrationExecutionError {\n const message = details\n ? `Invalid migration file format in ${filename}: ${details}`\n : `Invalid migration file format in ${filename}`;\n return new MigrationExecutionError(message);\n }\n}\n\n/**\n * Error thrown when there is an issue with the migration CLI\n */\nexport class CLIError extends MigrationError {\n constructor(message: string) {\n super(`CLI Error: ${message}`);\n this.name = 'CLIError';\n Object.setPrototypeOf(this, CLIError.prototype);\n }\n\n /**\n * Helper method for missing command errors\n * @returns A CLIError with appropriate message\n */\n static missingCommand(): CLIError {\n return new CLIError('No command specified. Run with --help for usage information.');\n }\n\n /**\n * Helper method for unknown command errors\n * @param command The unknown command\n * @returns A CLIError with appropriate message\n */\n static unknownCommand(command: string): CLIError {\n return new CLIError(`Unknown command: ${command}. Run with --help for usage information.`);\n }\n\n /**\n * Helper method for missing required argument errors\n * @param argument The missing argument\n * @returns A CLIError with appropriate message\n */\n static missingRequiredArgument(argument: string): CLIError {\n return new CLIError(`Missing required argument: ${argument}`);\n }\n}\n","import { Connection } from 'mysql2/promise';\nimport { MigrationStatus } from './MigrationStatus';\nimport { ISQLRunner } from './SQLRunner';\nimport { MigrationExecutionError } from './errors';\n\nexport abstract class MigrationNode {\n name: string;\n\n constructor(name?: string) {\n this.name = name || '';\n }\n\n abstract get_key():string;\n abstract status(): Promise<MigrationStatus>;\n abstract up(): Promise<void>;\n abstract down(): Promise<void>;\n abstract up_sql(): string;\n abstract down_sql(): string;\n}\n\n\nexport class SqlMigrationNode extends MigrationNode {\n up_sql(): string {\n return this.sql_up;\n }\n down_sql(): string {\n return this.sql_down;\n }\n get_key(): string {\n return this.key;\n }\n\n constructor(private conn:ISQLRunner,\n private table:string, \n private key:string,\n private up_file:string,\n private sql_up:string,\n private down_file:string,\n private sql_down:string) {\n super(key);\n }\n\n async status(): Promise<MigrationStatus> {\n try {\n const result = await this.conn.query(`\n select * \n from ${this.table}\n where migration_key = ?;\n `, [this.key]);\n\n if(result.length > 0 && result[0].length > 0){\n return {\n completed: true\n };\n } else {\n return {\n completed: false\n };\n }\n } catch (error) {\n throw new MigrationExecutionError(\n `Error checking status for migration`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n async up(): Promise<void> {\n try {\n await this.conn.execute(this.sql_up);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing UP migration`,\n this.key,\n this.sql_up,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n \n try {\n await this.conn.execute(`\n insert into ${this.table} (migration_key,up,down)\n values (?,?,?)\n `, [this.key, this.up_file, this.down_file]);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error recording migration completion`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n async down(): Promise<void> {\n try {\n await this.conn.execute(this.sql_down);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing DOWN migration`,\n this.key,\n this.sql_down,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n \n try {\n await this.conn.execute(`\n delete from ${this.table}\n where migration_key = ?\n `, [this.key]);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error removing migration record`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n}\n\n\nexport class SqliteMigrationNode extends MigrationNode {\n up_sql(): string {\n return this.sql_up;\n }\n down_sql(): string {\n return this.sql_down;\n }\n constructor(\n private conn: ISQLRunner, // your SQLite runner\n private table: string,\n private key: string,\n private up_file: string,\n private sql_up: string,\n private down_file: string,\n private sql_down: string\n ) {\n super(key);\n }\n\n /**\n * Returns the unique key for this migration (e.g. timestamp + name).\n */\n get_key(): string {\n return this.key;\n }\n\n /**\n * Check if this migration is already completed by looking in the migration table.\n */\n async status(): Promise<MigrationStatus> {\n try {\n // Usually `this.conn.query(...)` returns an array of rows.\n // The first element might be the row set, depending on your runner.\n const cursor = await this.conn.query(\n `SELECT * FROM ${this.table} WHERE migration_key = ?;`,\n [this.key]\n );\n\n // Usually, `cursor[0]` is the row array in many MySQL runners;\n // In a SQLite scenario, it may be just `cursor`\n // So adjust depending on your actual runner's return shape.\n const rows = cursor[0] as any[];\n\n if (rows && rows.length > 0) {\n return { completed: true };\n } else {\n return { completed: false };\n }\n } catch (error) {\n throw new MigrationExecutionError(\n `Error checking status for migration`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n /**\n * Run the 'up' SQL, then record this migration in the table.\n */\n async up(): Promise<void> {\n try {\n // Execute the 'up' script\n await this.conn.execute(this.sql_up);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing UP migration`,\n this.key,\n this.sql_up,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n\n // Insert a record of this migration having completed\n try {\n await this.conn.execute(\n `\n INSERT INTO ${this.table} (migration_key, up, down)\n VALUES (?, ?, ?)\n `,\n [this.key, this.up_file, this.down_file]\n );\n } catch (error) {\n throw new MigrationExecutionError(\n `Error recording migration completion`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n\n /**\n * Run the 'down' SQL, then remove this migration record from the table.\n */\n async down(): Promise<void> {\n try {\n // Execute the 'down' script\n await this.conn.execute(this.sql_down);\n } catch (error) {\n throw new MigrationExecutionError(\n `Error executing DOWN migration`,\n this.key,\n this.sql_down,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n\n // Remove the migration from the table\n try {\n await this.conn.execute(\n `\n DELETE FROM ${this.table}\n WHERE migration_key = ?\n `,\n [this.key]\n );\n } catch (error) {\n throw new MigrationExecutionError(\n `Error removing migration record`,\n this.key,\n undefined,\n error instanceof Error ? error : new Error(String(error))\n );\n }\n }\n}","import { Connection } from 'mysql2/promise';\nimport { SqlMigrationNode } from './MigrationNode';\nimport { ISQLRunner } from './SQLRunner';\n\n\n\nexport class SqlMigrationBuilder {\n\n private up: string = '';\n private up_file: string = '';\n private down: string = '';\n private down_file: string = '';\n\n constructor(private key: string) {\n }\n\n set_up(file:string,up: string) {\n this.up_file = file;\n this.up = up;\n }\n\n set_down(file:string,down: string) {\n this.down_file = file;\n this.down = down;\n }\n\n build(table:string,conn: ISQLRunner) {\n return new SqlMigrationNode(conn, table,this.key, this.up_file, this.up, this.down_file,this.down);\n }\n}\n","import { MigrationConfig } from \"./MigrationConfig\";\nimport fs from \"fs\";\nimport { ISQLRunner } from './SQLRunner';\n\nexport class MigrationSetup {\n constructor(private sqlrunner: ISQLRunner, private config: MigrationConfig) {}\n\n\n async setup() {\n\n fs.existsSync(this.config.migration_folder) || fs.mkdirSync(this.config.migration_folder);\n\n const tableName = this.config.migration_table;\n\n // Use dialect-specific DDL so that the migrations table can be created\n // both in MySQL/MariaDB and in SQLite. The two dialects differ mainly\n // in the auto-increment syntax and the column types.\n const createTableSql = this.config.database === 'sqlite'\n ? `CREATE TABLE IF NOT EXISTS ${tableName} (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n migration_key TEXT,\n up TEXT,\n down TEXT,\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n )`\n : `CREATE TABLE IF NOT EXISTS ${tableName} (\n id INT AUTO_INCREMENT PRIMARY KEY,\n migration_key VARCHAR(255),\n up VARCHAR(255),\n down VARCHAR(255),\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n )`;\n\n await this.sqlrunner.query(createTableSql);\n }\n\n async teardown() {\n await this.sqlrunner.execute(`DROP TABLE ${this.config.migration_table}`);\n }\n}\n\n\n\n\n","export function MySqlDialectParser(sql: string): string {\n const lines = sql.split('\\n');\n let result = '';\n \n // We start \"in MySQL\" so that lines before [sql] are kept.\n let isInMySQLBlock = true;\n \n // e.g. `-- [sql]`, `-- [ sql ]`, `-- [mysql]`, ignoring case/spaces\n const startSQLRegex = /^\\s*--\\s*\\[\\s*(sql|mysql)\\s*\\]\\s*$/i;\n // e.g. `-- [sqlite]`, `-- [ pg ]`, `-- [mydialect]` (any bracket means \"turn off MySQL\")\n const anyDialectRegex = /^\\s*--\\s*\\[\\s*\\w+\\s*\\]\\s*$/i;\n \n for (const line of lines) {\n const trimmed = line.trim();\n \n // If line is \" -- [sql] \" or \" -- [mysql] \", we *turn on* MySQL capturing:\n if (startSQLRegex.test(trimmed)) {\n isInMySQLBlock = true;\n // We also include this line in output\n result += line + '\\n';\n continue;\n }\n \n // If line is *some other* bracket, e.g. \" -- [sqlite] \"\n // then switch MySQL off, and do NOT keep that line\n if (anyDialectRegex.test(trimmed) && !startSQLRegex.test(trimmed)) {\n isInMySQLBlock = false;\n // Skip to next line\n continue;\n }\n \n // If we get here and see a line without a [dialect] marker,\n // and we were previously turned off because of non-mysql dialect,\n // then check if it's common SQL (like CREATE INDEX).\n // Turn MySQL back on for this line\n if (!isInMySQLBlock && line.toLowerCase().includes('create index')) {\n isInMySQLBlock = true;\n }\n \n // If we're in MySQL mode, keep the line\n if (isInMySQLBlock) {\n result += line + '\\n';\n }\n }\n \n return result;\n}\n\nexport function SqliteDialectParser(sql: string): string {\n const lines = sql.split('\\n');\n let result = '';\n let isInSqliteBlock = true;\n\n // Regex to detect a line that starts Sqlite code block:\n const startSqliteRegex = /^\\s*--\\s*\\[\\s*sqlite\\s*\\]\\s*$/i;\n const anyDialectRegex = /^\\s*--\\s*\\[\\s*\\w+\\s*\\]\\s*$/i;\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n if (startSqliteRegex.test(trimmed)) {\n // If we see a \"-- [sqlite]\" line, start capturing\n isInSqliteBlock = true;\n result += line + '\\n';\n continue;\n } else if (anyDialectRegex.test(trimmed) && !startSqliteRegex.test(trimmed)) {\n // If we see a *different* bracket line, turn off capturing\n isInSqliteBlock = false;\n continue;\n }\n \n // If we get here and see a line without a [dialect] marker,\n // and we were previously turned off because of non-sqlite dialect,\n // then check if it's common SQL (like CREATE INDEX).\n // Turn SQLite back on for this line\n if (!isInSqliteBlock && line.toLowerCase().includes('create index')) {\n isInSqliteBlock = true;\n }\n \n // If we are in the Sqlite block, capture the line\n if (isInSqliteBlock) {\n result += line + '\\n';\n }\n }\n \n return result;\n}","\nimport * as sqlite from 'sqlite';\nimport { Statement } from 'sqlite3';\nimport mysql from 'mysql2/promise';\n\n\n\ntype QueryResult = {\n stmt: Statement;\n lastID: number;\n changes: number;\n}\n\nexport interface ISQLRunner {\n query(sql: string, params?: any[]): Promise<any>;\n execute(sql: string, params?: any[]): Promise<any>;\n end(): Promise<void>;\n}\n\n/**\n * Base class that implements the common contract and helper utilities that are\n * shared between the different dialect runners. The concrete subclasses only\n * need to implement the three primitive methods `_query`, `_execute` and\n * `_end` that perform the actual driver-specific interaction. Everything else\n * – such as ensuring a uniform return shape – is handled here once.\n */\nabstract class BaseSQLRunner implements ISQLRunner {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract _query(sql: string, params?: any[]): Promise<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract _execute(sql: string, params?: any[]): Promise<any>;\n abstract _end(): Promise<void>;\n\n /**\n * Ensures that both MySQL and SQLite return the same tuple shape that callers\n * expect: `[rowsOrResult, extra]`. For SQLite there is no `extra` metadata\n * comparable to MySQL's `FieldPacket[]`, so we just use `undefined`.\n */\n async query(sql: string, params: any[] = []): Promise<any> {\n const result = await this._query(sql, params);\n\n // MySQL already returns the desired tuple. For SQLite we need to wrap.\n return Array.isArray(result) && result.length === 2 ? result : [result, undefined];\n }\n\n async execute(sql: string, params: any[] = []): Promise<any> {\n const result = await this._execute(sql, params);\n return Array.isArray(result) && result.length === 2 ? result : [result, undefined];\n }\n\n async end(): Promise<void> {\n await this._end();\n }\n}\n\nexport class SQLRunner extends BaseSQLRunner {\n constructor(private connection: mysql.Connection) {\n super();\n }\n\n // The MySQL driver already returns the correct tuple shapes.\n async _query(sql: string, params: any[] = []) {\n return await this.connection.query(sql, params);\n }\n\n async _execute(sql: string, params: any[] = []) {\n return await this.connection.execute(sql, params);\n }\n\n async _end() {\n if (this.connection) {\n await this.connection.end();\n }\n }\n}\n\nexport class SQLiteRunner extends BaseSQLRunner {\n constructor(private connection: sqlite.Database) {\n super();\n }\n\n async _query(sql: string, params: any[] = []) {\n const stmt = await this.connection.prepare(sql);\n try {\n const rows = await stmt.all(...params);\n return rows;\n } finally {\n await stmt.finalize();\n }\n }\n\n async _execute(sql: string, params: any[] = []) {\n if (this.isMultiStatement(sql)) {\n return await this.executeMultiStatement(sql, params)\n .catch((err) => {\n console.error((\n \"Error executing multi-statement SQL:\\n\"+\n `${sql}\\n`\n ), err);\n throw err;\n });\n }\n \n const stmt = await this.connection.prepare(sql);\n try {\n const info = await stmt.run(...params);\n return info;\n } finally {\n await stmt.finalize();\n }\n }\n\n private isMultiStatement(sql: string): boolean {\n // SQLite does not support multiple statements in a single query.\n return sql.split(';').length > 1;\n }\n\n private async executeMultiStatement(sql: string, params: any[] = []) {\n const statements = sql.split(';')\n .map((s) => s.split('\\n')\n .map(\n s=>this.removeComments(s))\n .filter(s=>s.trim()!='')\n .join('\\n')\n )\n .filter((s) => s.trim() !== '');\n \n const infos = await statements.reduce(async (prev,statement) => {\n const infos = await prev;\n const stmt = await this.connection.prepare(`${statement};`);\n try {\n const info = await stmt.run(...params);\n infos.push(info);\n return infos;\n }\n finally {\n await stmt.finalize();\n }\n },Promise.resolve([null] as any[]))\n .then((infos:QueryResult[]) => {\n return infos.filter((info) => info !== null);\n })\n return infos.reduce((acc,latest)=>{\n if(latest){\n acc.stmt = latest.stmt;\n acc.lastID = latest.lastID;\n acc.changes += latest.changes;\n }\n return acc\n })\n }\n\n private removeComments(sql: string): string {\n // Remove single-line comments\n sql = sql.replace(/--.*$/gm, '');\n return sql;\n }\n\n\n async _end() {\n if (this.connection) {\n await this.connection.close();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sBAAO;;;ACDP,sBAAqB;AAEd,IAAM,sBAAN,MAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM7B,OAAO,MAAM,MAAqE;AARtF;AAUQ,UAAMA,QAAO,QAAQ,QAAQ;AAQ7B,QAAI,aAAa;AAGjB,SAAI,KAAAA,MAAK,CAAC,MAAN,mBAAS,SAAS,SAAS;AAC3B,mBAAa;AAAA,IACjB,WAESA,MAAK,CAAC,KAAK,sBAAsB,KAAKA,MAAK,CAAC,CAAC,GAAG;AACrD,mBAAa;AAAA,IACjB,WAESA,MAAK,CAAC,KAAK,CAAC,UAAU,aAAa,YAAY,EAAE,SAASA,MAAK,CAAC,EAAE,YAAY,CAAC,GAAG;AACvF,mBAAa;AAAA,IACjB;AAGA,UAAM,UAAM,gBAAAC,SAASD,MAAK,MAAM,UAAU,GAAG;AAAA,MACzC,OAAO;AAAA,QACH,GAAG;AAAA,MACP;AAAA,IACJ,CAAC;AA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