forge-sql-orm 1.0.22 → 1.0.24
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/README.md +91 -6
- package/dist/ForgeSQLORM.js +39 -16
- package/dist/ForgeSQLORM.js.map +1 -1
- package/dist/ForgeSQLORM.mjs +39 -16
- package/dist/ForgeSQLORM.mjs.map +1 -1
- package/dist/core/ForgeSQLCrudOperations.d.ts +3 -2
- package/dist/core/ForgeSQLCrudOperations.d.ts.map +1 -1
- package/dist/core/ForgeSQLORM.d.ts +2 -2
- package/dist/core/ForgeSQLORM.d.ts.map +1 -1
- package/dist/core/ForgeSQLQueryBuilder.d.ts +14 -0
- package/dist/core/ForgeSQLQueryBuilder.d.ts.map +1 -1
- package/dist/core/ForgeSQLSelectOperations.d.ts +3 -1
- package/dist/core/ForgeSQLSelectOperations.d.ts.map +1 -1
- package/dist-cli/cli.js +71 -42
- package/dist-cli/cli.js.map +1 -1
- package/dist-cli/cli.mjs +71 -42
- package/dist-cli/cli.mjs.map +1 -1
- package/dist-cli/forgeSqlCLI.js +8 -9
- package/package.json +23 -23
- package/src/core/ForgeSQLCrudOperations.ts +13 -7
- package/src/core/ForgeSQLORM.ts +23 -7
- package/src/core/ForgeSQLQueryBuilder.ts +15 -0
- package/src/core/ForgeSQLSelectOperations.ts +14 -5
- package/dist-cli/tsm/bin.js +0 -18
- package/dist-cli/tsm/config/index.d.ts +0 -22
- package/dist-cli/tsm/config/index.js +0 -1
- package/dist-cli/tsm/license +0 -9
- package/dist-cli/tsm/loader.mjs +0 -1
- package/dist-cli/tsm/package.json +0 -51
- package/dist-cli/tsm/readme.md +0 -62
- package/dist-cli/tsm/require.js +0 -1
- package/dist-cli/tsm/utils.js +0 -1
package/dist-cli/cli.mjs
CHANGED
|
@@ -295,12 +295,24 @@ const PATCHES = [
|
|
|
295
295
|
// 🗑️ Remove unused dialects (mssql, postgres, sqlite) in MikroORM
|
|
296
296
|
{
|
|
297
297
|
file: "node_modules/@mikro-orm/knex/MonkeyPatchable.d.ts",
|
|
298
|
-
deleteLines: [
|
|
298
|
+
deleteLines: [
|
|
299
|
+
/^.*mssql.*$/gim,
|
|
300
|
+
/^.*MsSql.*$/gim,
|
|
301
|
+
/^\s*Postgres.*$/gm,
|
|
302
|
+
/^.*Sqlite3.*$/gm,
|
|
303
|
+
/^.*BetterSqlite3.*$/gim
|
|
304
|
+
],
|
|
299
305
|
description: "Removing unused dialects from MonkeyPatchable.d.ts"
|
|
300
306
|
},
|
|
301
307
|
{
|
|
302
308
|
file: "node_modules/@mikro-orm/knex/MonkeyPatchable.js",
|
|
303
|
-
deleteLines: [
|
|
309
|
+
deleteLines: [
|
|
310
|
+
/^.*mssql.*$/gim,
|
|
311
|
+
/^.*MsSql.*$/gim,
|
|
312
|
+
/^.*postgres.*$/gim,
|
|
313
|
+
/^.*sqlite.*$/gim,
|
|
314
|
+
/^.*Sqlite.*$/gim
|
|
315
|
+
],
|
|
304
316
|
description: "Removing unused dialects from MonkeyPatchable.js"
|
|
305
317
|
},
|
|
306
318
|
{
|
|
@@ -343,7 +355,10 @@ const PATCHES = [
|
|
|
343
355
|
// 🛠️ Patch Knex to remove `Migrator` and `Seeder`
|
|
344
356
|
{
|
|
345
357
|
file: "node_modules/knex/lib/knex-builder/make-knex.js",
|
|
346
|
-
deleteLines: [
|
|
358
|
+
deleteLines: [
|
|
359
|
+
/^const \{ Migrator \} = require\('\.\.\/migrations\/migrate\/Migrator'\);$/gm,
|
|
360
|
+
/^const Seeder = require\('\.\.\/migrations\/seed\/Seeder'\);$/gm
|
|
361
|
+
],
|
|
347
362
|
description: "Removing `Migrator` and `Seeder` requires from make-knex.js"
|
|
348
363
|
},
|
|
349
364
|
{
|
|
@@ -367,7 +382,19 @@ const PATCHES = [
|
|
|
367
382
|
// },
|
|
368
383
|
{
|
|
369
384
|
file: "node_modules/knex/lib/dialects/index.js",
|
|
370
|
-
deleteLines: [
|
|
385
|
+
deleteLines: [
|
|
386
|
+
/^.*mssql.*$/gim,
|
|
387
|
+
/^.*MsSql.*$/gim,
|
|
388
|
+
/^.*postgresql.*$/gim,
|
|
389
|
+
/^.*sqlite.*$/gim,
|
|
390
|
+
/^.*oracle.*$/gim,
|
|
391
|
+
/^.*oracledb.*$/gim,
|
|
392
|
+
/^.*pgnative.*$/gim,
|
|
393
|
+
/^.*postgres.*$/gim,
|
|
394
|
+
/^.*redshift.*$/gim,
|
|
395
|
+
/^.*sqlite3.*$/gim,
|
|
396
|
+
/^.*cockroachdb.*$/gim
|
|
397
|
+
],
|
|
371
398
|
description: "Removing unused dialects from @mikro-orm/knex/dialects/index.js"
|
|
372
399
|
},
|
|
373
400
|
{
|
|
@@ -399,52 +426,54 @@ const PATCHES = [
|
|
|
399
426
|
];
|
|
400
427
|
function runPostInstallPatch() {
|
|
401
428
|
console.log("🔧 Applying MikroORM & Knex patches...");
|
|
402
|
-
PATCHES.forEach(
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (
|
|
410
|
-
|
|
411
|
-
|
|
429
|
+
PATCHES.forEach(
|
|
430
|
+
({ file, search, replace, deleteLines, deleteFile, deleteFolder, description }) => {
|
|
431
|
+
if (file) {
|
|
432
|
+
const filePath = path.resolve(file);
|
|
433
|
+
if (fs.existsSync(filePath)) {
|
|
434
|
+
let content = fs.readFileSync(filePath, "utf8");
|
|
435
|
+
let originalContent = content;
|
|
436
|
+
if (search && replace) {
|
|
437
|
+
if (typeof search === "string" ? content.includes(search) : search.test(content)) {
|
|
438
|
+
content = content.replace(search, replace);
|
|
439
|
+
console.log(`[PATCHED] ${description}`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
if (deleteLines) {
|
|
443
|
+
deleteLines.forEach((pattern) => {
|
|
444
|
+
content = content.split("\n").filter((line) => !pattern.test(line)).join("\n");
|
|
445
|
+
});
|
|
446
|
+
if (content !== originalContent) {
|
|
447
|
+
console.log(`[CLEANED] Removed matching lines in ${file}`);
|
|
448
|
+
}
|
|
412
449
|
}
|
|
413
|
-
}
|
|
414
|
-
if (deleteLines) {
|
|
415
|
-
deleteLines.forEach((pattern) => {
|
|
416
|
-
content = content.split("\n").filter((line) => !pattern.test(line)).join("\n");
|
|
417
|
-
});
|
|
418
450
|
if (content !== originalContent) {
|
|
419
|
-
|
|
451
|
+
fs.writeFileSync(filePath, content, "utf8");
|
|
420
452
|
}
|
|
453
|
+
if (content.trim() === "") {
|
|
454
|
+
fs.unlinkSync(filePath);
|
|
455
|
+
console.log(`[REMOVED] ${filePath} (file is now empty)`);
|
|
456
|
+
}
|
|
457
|
+
} else {
|
|
458
|
+
console.warn(`[WARNING] File not found: ${file}`);
|
|
421
459
|
}
|
|
422
|
-
if (content !== originalContent) {
|
|
423
|
-
fs.writeFileSync(filePath, content, "utf8");
|
|
424
|
-
}
|
|
425
|
-
if (content.trim() === "") {
|
|
426
|
-
fs.unlinkSync(filePath);
|
|
427
|
-
console.log(`[REMOVED] ${filePath} (file is now empty)`);
|
|
428
|
-
}
|
|
429
|
-
} else {
|
|
430
|
-
console.warn(`[WARNING] File not found: ${file}`);
|
|
431
460
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
461
|
+
if (deleteFile) {
|
|
462
|
+
const deleteFilePath = path.resolve(__dirname, "../", deleteFile);
|
|
463
|
+
if (fs.existsSync(deleteFilePath)) {
|
|
464
|
+
fs.unlinkSync(deleteFilePath);
|
|
465
|
+
console.log(`[DELETED] ${description}`);
|
|
466
|
+
}
|
|
438
467
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
468
|
+
if (deleteFolder) {
|
|
469
|
+
const deleteFolderPath = path.resolve(__dirname, "../", deleteFolder);
|
|
470
|
+
if (fs.existsSync(deleteFolderPath)) {
|
|
471
|
+
fs.rmSync(deleteFolderPath, { recursive: true, force: true });
|
|
472
|
+
console.log(`[DELETED] ${description}`);
|
|
473
|
+
}
|
|
445
474
|
}
|
|
446
475
|
}
|
|
447
|
-
|
|
476
|
+
);
|
|
448
477
|
console.log("🎉 MikroORM & Knex patching completed!");
|
|
449
478
|
}
|
|
450
479
|
dotenv.config();
|
package/dist-cli/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","sources":["../scripts/actions/generate-models.ts","../scripts/actions/migrations-create.ts","../scripts/actions/migrations-update.ts","../scripts/actions/PatchPostinstall.ts","../scripts/cli.ts"],"sourcesContent":["import \"reflect-metadata\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport {defineConfig, MikroORM, MongoNamingStrategy} from \"@mikro-orm/mysql\";\nimport {EntityGenerator} from \"@mikro-orm/entity-generator\";\n\nconst regenerateIndexFile = (outputPath: string) => {\n const entitiesDir = path.resolve(outputPath);\n const indexPath = path.join(entitiesDir, \"index.ts\");\n\n const entityFiles = fs\n .readdirSync(entitiesDir)\n .filter((file) => file.endsWith(\".ts\") && file !== \"index.ts\");\n\n const imports = entityFiles.map((file) => {\n const entityName = path.basename(file, \".ts\");\n return `import { ${entityName} } from \"./${entityName}\";`;\n });\n\n const indexContent = `${imports.join(\"\\n\")}\\n\\nexport default [${entityFiles.map((file) => path.basename(file, \".ts\")).join(\", \")}];\\n`;\n\n fs.writeFileSync(indexPath, indexContent, \"utf8\");\n console.log(`✅ Updated index.ts with ${entityFiles.length} entities.`);\n};\n\nexport const generateModels = async (options: any) => {\n try {\n const ormConfig = defineConfig({\n host: options.host,\n port: options.port,\n user: options.user,\n password: options.password,\n dbName: options.dbName,\n namingStrategy: MongoNamingStrategy,\n discovery: { warnWhenNoEntities: false },\n extensions: [EntityGenerator],\n debug: true,\n }) as Parameters<typeof MikroORM.initSync>[0];\n\n const orm = MikroORM.initSync(ormConfig);\n console.log(`✅ Connected to ${options.dbName} at ${options.host}:${options.port}`);\n\n await orm.entityGenerator.generate({\n entitySchema: true,\n bidirectionalRelations: false,\n identifiedReferences: false,\n forceUndefined: true,\n undefinedDefaults: true,\n useCoreBaseEntity: false,\n onlyPurePivotTables: false,\n outputPurePivotTables: false,\n scalarPropertiesForRelations: \"always\",\n save: true,\n path: options.output,\n });\n\n regenerateIndexFile(options.output);\n\n console.log(`✅ Entities generated at: ${options.output}`);\n process.exit(0);\n } catch (error) {\n console.error(`❌ Error generating entities:`, error);\n process.exit(1);\n }\n};\n","import \"reflect-metadata\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport {MikroORM} from \"@mikro-orm/mysql\";\nimport { execSync } from 'child_process';\nimport { rmSync } from 'fs';\n\n/**\n * Cleans SQL statements by removing unnecessary database options.\n * @param sql - The raw SQL statement.\n * @returns The cleaned SQL statement.\n */\nfunction cleanSQLStatement(sql: string): string {\n return sql.replace(/\\s+default\\s+character\\s+set\\s+utf8mb4\\s+engine\\s*=\\s*InnoDB;?/gi, \"\").trim();\n}\n\n/**\n * Generates a migration file using the provided SQL statements.\n * @param createStatements - Array of SQL statements.\n * @param version - Migration version number.\n * @returns TypeScript migration file content.\n */\nfunction generateMigrationFile(createStatements: string[], version: number): string {\n const versionPrefix = `v${version}_MIGRATION`;\n\n // Clean each SQL statement and generate migration lines with .enqueue()\n const migrationLines = createStatements\n .map(\n (stmt, index) =>\n ` .enqueue(\"${versionPrefix}${index}\", \\\"${cleanSQLStatement(stmt)}\\\")`, // eslint-disable-line no-useless-escape\n )\n .join(\"\\n\");\n\n // Migration template\n return `import { MigrationRunner } from \"@forge/sql/out/migration\";\n\nexport default (migrationRunner: MigrationRunner): MigrationRunner => {\n return migrationRunner\n${migrationLines};\n};`;\n}\n\n/**\n * Saves the generated migration file along with `migrationCount.ts` and `index.ts`.\n * @param migrationCode - The migration code to be written to the file.\n * @param version - Migration version number.\n * @param outputDir - Directory where the migration files will be saved.\n */\nfunction saveMigrationFiles(migrationCode: string, version: number, outputDir: string) {\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n const migrationFilePath = path.join(outputDir, `migrationV${version}.ts`);\n const migrationCountPath = path.join(outputDir, `migrationCount.ts`);\n const indexFilePath = path.join(outputDir, `index.ts`);\n\n // Write the migration file\n fs.writeFileSync(migrationFilePath, migrationCode);\n\n // Write the migration count file\n fs.writeFileSync(migrationCountPath, `export const MIGRATION_VERSION = ${version};`);\n\n // Generate the migration index file\n const indexFileContent = `import { MigrationRunner } from \"@forge/sql/out/migration\";\nimport { MIGRATION_VERSION } from \"./migrationCount\";\n\nexport type MigrationType = (\n migrationRunner: MigrationRunner,\n) => MigrationRunner;\n\nexport default async (\n migrationRunner: MigrationRunner,\n): Promise<MigrationRunner> => {\n for (let i = 1; i <= MIGRATION_VERSION; i++) {\n const migrations = (await import(\\`./migrationV\\${i}\\`)) as {\n default: MigrationType;\n };\n migrations.default(migrationRunner);\n }\n return migrationRunner;\n};`;\n\n fs.writeFileSync(indexFilePath, indexFileContent);\n\n console.log(`✅ Migration file created: ${migrationFilePath}`);\n console.log(`✅ Migration count file updated: ${migrationCountPath}`);\n console.log(`✅ Migration index file created: ${indexFilePath}`);\n}\n\n/**\n * Extracts only the relevant SQL statements for migration.\n * @param schema - The full database schema as SQL.\n * @returns Filtered list of SQL statements.\n */\nconst extractCreateStatements = (schema: string): string[] => {\n const statements = schema.split(\";\").map((s) => s.trim());\n\n return statements.filter(\n (stmt) =>\n stmt.startsWith(\"create table\") ||\n (stmt.startsWith(\"alter table\") && stmt.includes(\"add index\")) ||\n stmt.startsWith(\"primary\"),\n );\n};\n\n/**\n * Dynamically loads `entities` from `index.ts` in the specified directory.\n * @param entitiesPath - Path to the directory containing `index.ts`.\n * @returns Array of entity classes.\n */\nconst loadEntities = async (entitiesPath: string) => {\n try {\n const indexFilePath = path.resolve(path.join(entitiesPath, \"index.ts\"));\n if (!fs.existsSync(indexFilePath)) {\n console.error(`❌ Error: index.ts not found in ${indexFilePath}`);\n process.exit(1);\n }\n\n const { default: entities } = await import(indexFilePath);\n console.log(`✅ Loaded ${entities.length} entities from ${entitiesPath}`);\n return entities;\n } catch (error) {\n console.error(`❌ Error loading index.ts from ${entitiesPath}:`, error);\n process.exit(1);\n }\n};\n\n/**\n * Loads the current migration version from `migrationCount.ts`.\n * @param migrationPath - Path to the migration folder.\n * @returns The latest migration version.\n */\nconst loadMigrationVersion = async (migrationPath: string): Promise<number> => {\n try {\n const migrationCountFilePath = path.resolve(path.join(migrationPath, \"migrationCount.ts\"));\n if (!fs.existsSync(migrationCountFilePath)) {\n return 0;\n }\n\n const { MIGRATION_VERSION } = await import(migrationCountFilePath);\n console.log(`✅ Current migration version: ${MIGRATION_VERSION}`);\n return MIGRATION_VERSION as number;\n } catch (error) {\n console.error(`❌ Error loading migrationCount:`, error);\n process.exit(1);\n }\n};\n\n/**\n * Creates a full database migration.\n * @param options - Database connection settings and output paths.\n */\nexport const createMigration = async (options: any) => {\n try {\n let version = await loadMigrationVersion(options.output);\n\n if (version > 0) {\n console.error(`❌ Error: Migration has already been created.`);\n process.exit(1);\n }\n\n // Start from version 1 if no previous migrations exist\n version = 1;\n\n // Load entities dynamically from index.ts\n const entities = await loadEntities(options.entitiesPath);\n\n // Initialize MikroORM\n const orm = MikroORM.initSync({\n host: options.host,\n port: options.port,\n user: options.user,\n password: options.password,\n dbName: options.dbName,\n entities: entities,\n });\n\n // Generate SQL schema\n const createSchemaSQL = await orm.schema.getCreateSchemaSQL({ wrap: true });\n const statements = extractCreateStatements(createSchemaSQL);\n\n // Generate and save migration files\n const migrationFile = generateMigrationFile(statements, version);\n saveMigrationFiles(migrationFile, version, options.output);\n\n console.log(`✅ Migration successfully created!`);\n process.exit(0);\n } catch (error) {\n console.error(`❌ Error during migration creation:`, error);\n process.exit(1);\n }\n};\n","import \"reflect-metadata\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport {MikroORM} from \"@mikro-orm/mysql\";\n\n/**\n * Cleans SQL statements by removing unnecessary database options.\n * @param sql - The raw SQL statement.\n * @returns The cleaned SQL statement.\n */\nfunction cleanSQLStatement(sql: string): string {\n return sql.replace(/\\s+default\\s+character\\s+set\\s+utf8mb4\\s+engine\\s*=\\s*InnoDB;?/gi, \"\").trim();\n}\n\n/**\n * Generates a migration file using the provided SQL statements.\n * @param createStatements - Array of SQL statements.\n * @param version - Migration version number.\n * @returns TypeScript migration file content.\n */\nfunction generateMigrationFile(createStatements: string[], version: number): string {\n const versionPrefix = `v${version}_MIGRATION`;\n\n // Clean each SQL statement and generate migration lines with .enqueue()\n const migrationLines = createStatements\n .map(\n (stmt, index) =>\n ` .enqueue(\"${versionPrefix}${index}\", \\\"${cleanSQLStatement(stmt)}\\\")`, // eslint-disable-line no-useless-escape\n )\n .join(\"\\n\");\n\n // Migration template\n return `import { MigrationRunner } from \"@forge/sql/out/migration\";\n\nexport default (migrationRunner: MigrationRunner): MigrationRunner => {\n return migrationRunner\n${migrationLines};\n};`;\n}\n\n/**\n * Saves the generated migration file along with `migrationCount.ts` and `index.ts`.\n * @param migrationCode - The migration code to be written to the file.\n * @param version - Migration version number.\n * @param outputDir - Directory where the migration files will be saved.\n */\nfunction saveMigrationFiles(migrationCode: string, version: number, outputDir: string) {\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n const migrationFilePath = path.join(outputDir, `migrationV${version}.ts`);\n const migrationCountPath = path.join(outputDir, `migrationCount.ts`);\n const indexFilePath = path.join(outputDir, `index.ts`);\n\n // Write the migration file\n fs.writeFileSync(migrationFilePath, migrationCode);\n\n // Write the migration count file\n fs.writeFileSync(migrationCountPath, `export const MIGRATION_VERSION = ${version};`);\n\n // Generate the migration index file\n const indexFileContent = `import { MigrationRunner } from \"@forge/sql/out/migration\";\nimport { MIGRATION_VERSION } from \"./migrationCount\";\n\nexport type MigrationType = (\n migrationRunner: MigrationRunner,\n) => MigrationRunner;\n\nexport default async (\n migrationRunner: MigrationRunner,\n): Promise<MigrationRunner> => {\n for (let i = 1; i <= MIGRATION_VERSION; i++) {\n const migrations = (await import(\\`./migrationV\\${i}\\`)) as {\n default: MigrationType;\n };\n migrations.default(migrationRunner);\n }\n return migrationRunner;\n};`;\n\n fs.writeFileSync(indexFilePath, indexFileContent);\n\n console.log(`✅ Migration file created: ${migrationFilePath}`);\n console.log(`✅ Migration count file updated: ${migrationCountPath}`);\n console.log(`✅ Migration index file created: ${indexFilePath}`);\n}\n\n/**\n * Extracts only the relevant SQL statements for migration.\n * @param schema - The full database schema as SQL.\n * @returns Filtered list of SQL statements.\n */\nconst extractCreateStatements = (schema: string): string[] => {\n const statements = schema.split(\";\").map((s) => s.trim());\n\n return statements.filter(\n (stmt) =>\n stmt.startsWith(\"create table\") ||\n (stmt.startsWith(\"alter table\") && stmt.includes(\"add index\")) ||\n (stmt.startsWith(\"alter table\") && stmt.includes(\"add\") && !stmt.includes(\"foreign\")) ||\n (stmt.startsWith(\"alter table\") && stmt.includes(\"modify\") && !stmt.includes(\"foreign\")),\n );\n};\n\n/**\n * Dynamically loads `entities` from `index.ts` in the specified directory.\n * @param entitiesPath - Path to the directory containing `index.ts`.\n * @returns Array of entity classes.\n */\nconst loadEntities = async (entitiesPath: string) => {\n try {\n const indexFilePath = path.resolve(path.join(entitiesPath, \"index.ts\"));\n if (!fs.existsSync(indexFilePath)) {\n console.error(`❌ Error: index.ts not found in ${entitiesPath}`);\n process.exit(1);\n }\n\n const { default: entities } = await import(indexFilePath);\n console.log(`✅ Loaded ${entities.length} entities from ${entitiesPath}`);\n return entities;\n } catch (error) {\n console.error(`❌ Error loading index.ts from ${entitiesPath}:`, error);\n process.exit(1);\n }\n};\n\n/**\n * Loads the current migration version from `migrationCount.ts`.\n * @param migrationPath - Path to the migration folder.\n * @returns The latest migration version.\n */\nconst loadMigrationVersion = async (migrationPath: string): Promise<number> => {\n try {\n const migrationCountFilePath = path.resolve(path.join(migrationPath, \"migrationCount.ts\"));\n if (!fs.existsSync(migrationCountFilePath)) {\n console.warn(\n `⚠️ Warning: migrationCount.ts not found in ${migrationCountFilePath}, assuming no previous migrations.`,\n );\n return 0;\n }\n\n const { MIGRATION_VERSION } = await import(migrationCountFilePath);\n console.log(`✅ Current migration version: ${MIGRATION_VERSION}`);\n return MIGRATION_VERSION as number;\n } catch (error) {\n console.error(`❌ Error loading migrationCount:`, error);\n process.exit(1);\n }\n};\n\n/**\n * Updates an existing database migration by generating schema modifications.\n * @param options - Database connection settings and output paths.\n */\nexport const updateMigration = async (options: any) => {\n try {\n let version = await loadMigrationVersion(options.output);\n\n if (version < 1) {\n console.log(\n `⚠️ Initial migration not found. Run \"npx forge-sql-orm migrations:create\" first.`,\n );\n process.exit(0);\n }\n version += 1;\n\n // Load entities dynamically from index.ts\n const entities = await loadEntities(options.entitiesPath);\n\n // Initialize MikroORM\n const orm = MikroORM.initSync({\n host: options.host,\n port: options.port,\n user: options.user,\n password: options.password,\n dbName: options.dbName,\n entities,\n debug: true,\n });\n\n // Generate SQL schema updates\n const createSchemaSQL = await orm.schema.getUpdateSchemaMigrationSQL({ wrap: true });\n const statements = extractCreateStatements(createSchemaSQL?.down || \"\");\n\n if (statements.length) {\n const migrationFile = generateMigrationFile(statements, version);\n saveMigrationFiles(migrationFile, version, options.output);\n\n console.log(`✅ Migration successfully updated!`);\n process.exit(0);\n } else {\n console.log(`⚠️ No new migration changes detected.`);\n process.exit(0);\n }\n } catch (error) {\n console.error(`❌ Error during migration update:`, error);\n process.exit(1);\n }\n};\n","import fs from \"fs\";\nimport path from \"path\";\n\n/**\n * Automates patches for MikroORM and Knex to fix Webpack issues.\n * - Removes problematic `require()` calls.\n * - Deletes unnecessary files and folders.\n * - Fixes dynamic imports (`import(id)`) in MikroORM.\n */\n\ninterface Patch {\n file?: string; // File to modify (optional)\n search?: RegExp; // Regex pattern to find problematic code\n replace?: string; // Replacement string for problematic code\n deleteLines?: RegExp[]; // List of regex patterns to remove specific lines\n description: string; // Description of the patch\n deleteFile?: string; // Path of the file to delete (optional)\n deleteFolder?: string; // Path of the folder to delete (optional)\n}\n\nconst PATCHES: Patch[] = [\n // 🗑️ Remove unused dialects (mssql, postgres, sqlite) in MikroORM\n {\n file: \"node_modules/@mikro-orm/knex/MonkeyPatchable.d.ts\",\n deleteLines: [/^.*mssql.*$/gim, /^.*MsSql.*$/gim, /^\\s*Postgres.*$/gm, /^.*Sqlite3.*$/gm, /^.*BetterSqlite3.*$/gim],\n description: \"Removing unused dialects from MonkeyPatchable.d.ts\"\n },\n {\n file: \"node_modules/@mikro-orm/knex/MonkeyPatchable.js\",\n deleteLines: [/^.*mssql.*$/gim, /^.*MsSql.*$/gim, /^.*postgres.*$/gim, /^.*sqlite.*$/gim, /^.*Sqlite.*$/gim],\n description: \"Removing unused dialects from MonkeyPatchable.js\"\n },\n {\n file: \"node_modules/@mikro-orm/knex/dialects/index.js\",\n deleteLines: [/^.*mssql.*$/gim, /^.*MsSql.*$/gim, /^.*postgresql.*$/gim, /^.*sqlite.*$/gim],\n description: \"Removing unused dialects from @mikro-orm/knex/dialects/index.js\"\n },\n {\n deleteFolder: \"node_modules/@mikro-orm/knex/dialects/mssql\",\n description: \"Removing mssql dialect from MikroORM\"\n },\n {\n deleteFolder: \"node_modules/@mikro-orm/knex/dialects/postgresql\",\n description: \"Removing postgresql dialect from MikroORM\"\n },\n {\n deleteFolder: \"node_modules/@mikro-orm/knex/dialects/sqlite\",\n description: \"Removing sqlite dialect from MikroORM\"\n },\n\n // 🔄 Fix Webpack `Critical dependency: the request of a dependency is an expression`\n {\n file: \"node_modules/@mikro-orm/core/utils/Configuration.js\",\n search: /dynamicImportProvider:\\s*\\/\\* istanbul ignore next \\*\\/\\s*\\(id\\) => import\\(id\\),/g,\n replace: \"dynamicImportProvider: /* istanbul ignore next */ () => Promise.resolve({}),\",\n description: \"Fixing dynamic imports in MikroORM Configuration\"\n },\n {\n file: \"node_modules/@mikro-orm/core/utils/Utils.js\",\n search: /static dynamicImportProvider = \\(id\\) => import\\(id\\);/g,\n replace: \"static dynamicImportProvider = () => Promise.resolve({});\",\n description: \"Fixing dynamic imports in MikroORM Utils.js\"\n },\n\n // 🛑 Remove deprecated `require.extensions` usage\n {\n file: \"node_modules/@mikro-orm/core/utils/Utils.js\",\n search: /\\s\\|\\|\\s*\\(require\\.extensions\\s*&&\\s*!!require\\.extensions\\['\\.ts'\\]\\);\\s*/g,\n replace: \";\",\n description: \"Removing deprecated `require.extensions` check in MikroORM\"\n },\n\n // 🛠️ Patch Knex to remove `Migrator` and `Seeder`\n {\n file: \"node_modules/knex/lib/knex-builder/make-knex.js\",\n deleteLines: [/^const \\{ Migrator \\} = require\\('\\.\\.\\/migrations\\/migrate\\/Migrator'\\);$/gm, /^const Seeder = require\\('\\.\\.\\/migrations\\/seed\\/Seeder'\\);$/gm],\n description: \"Removing `Migrator` and `Seeder` requires from make-knex.js\"\n },\n {\n file: \"node_modules/knex/lib/knex-builder/make-knex.js\",\n search: /\\sreturn new Migrator\\(this\\);/g,\n replace: \"return null;\",\n description: \"Replacing `return new Migrator(this);` with `return null;`\"\n },\n {\n file: \"node_modules/knex/lib/knex-builder/make-knex.js\",\n search: /\\sreturn new Seeder\\(this\\);/g,\n replace: \"return null;\",\n description: \"Replacing `return new Seeder(this);` with `return null;`\"\n },\n // 🔄 Patch for MikroORM Entity Generator to use 'forge-sql-orm'\n // {\n // file: \"node_modules/@mikro-orm/entity-generator/SourceFile.js\",\n // search: /^.* from '@mikro-orm.*$/gim,\n // replace: \" }).join(', '))} } from 'forge-sql-orm';`);\",\n // description: \"Replacing entity generator imports with 'forge-sql-orm'\"\n // },\n {\n file: \"node_modules/knex/lib/dialects/index.js\",\n deleteLines: [/^.*mssql.*$/gim, /^.*MsSql.*$/gim, /^.*postgresql.*$/gim, /^.*sqlite.*$/gim, /^.*oracle.*$/gim, /^.*oracledb.*$/gim, /^.*pgnative.*$/gim, /^.*postgres.*$/gim, /^.*redshift.*$/gim, /^.*sqlite3.*$/gim, /^.*cockroachdb.*$/gim],\n description: \"Removing unused dialects from @mikro-orm/knex/dialects/index.js\"\n },\n {\n file: \"node_modules/@mikro-orm/core/utils/Utils.js\",\n search: /\\s\\|\\|\\s*\\(require\\.extensions\\s*&&\\s*!!require\\.extensions\\['\\.ts'\\]\\);\\s*/g,\n replace: \";\", // Replaces with semicolon to keep syntax valid\n description: \"Removing deprecated `require.extensions` check from MikroORM\"\n },\n {\n file: \"node_modules/@mikro-orm/core/utils/Utils.js\",\n search: /^.*extensions.*$/gim,\n replace: \"{\", // Replaces with semicolon to keep syntax valid\n description: \"Removing deprecated `require.extensions` check from MikroORM\"\n },\n {\n file: \"node_modules/@mikro-orm/core/utils/Utils.js\",\n search: /^.*package.json.*$/gim,\n replace: \"return 0;\", // Replaces with semicolon to keep syntax valid\n description: \"Removing deprecated `require.extensions` check from MikroORM\"\n },\n {\n file: \"node_modules/@mikro-orm/knex/dialects/mysql/index.js\",\n deleteLines: [/^.*MariaDbKnexDialect.*$/gim],\n description: \"Removing MariaDbKnexDialect\"\n },\n\n];\n\n\n\n\n\n/**\n * Runs the MikroORM & Knex patching logic.\n */\nexport function runPostInstallPatch() {\n console.log(\"🔧 Applying MikroORM & Knex patches...\");\n PATCHES.forEach(({ file, search, replace, deleteLines, deleteFile, deleteFolder, description }) => {\n if (file) {\n const filePath = path.resolve(file);\n if (fs.existsSync(filePath)) {\n let content = fs.readFileSync(filePath, \"utf8\");\n let originalContent = content;\n\n // 🔄 Replace text\n if (search && replace) {\n if (typeof search === \"string\" ? content.includes(search) : search.test(content)) {\n content = content.replace(search, replace);\n console.log(`[PATCHED] ${description}`);\n }\n }\n\n // 🗑️ Remove matching lines\n if (deleteLines) {\n deleteLines.forEach((pattern) => {\n content = content\n .split(\"\\n\")\n .filter((line) => !pattern.test(line))\n .join(\"\\n\");\n });\n if (content !== originalContent) {\n console.log(`[CLEANED] Removed matching lines in ${file}`);\n }\n }\n\n // 💾 Save changes only if file was modified\n if (content !== originalContent) {\n fs.writeFileSync(filePath, content, \"utf8\");\n }\n\n // 🚮 Remove empty files\n if (content.trim() === \"\") {\n fs.unlinkSync(filePath);\n console.log(`[REMOVED] ${filePath} (file is now empty)`);\n }\n } else {\n console.warn(`[WARNING] File not found: ${file}`);\n }\n }\n\n // 🚮 Delete specific files\n if (deleteFile) {\n const deleteFilePath = path.resolve(__dirname, \"../\", deleteFile);\n if (fs.existsSync(deleteFilePath)) {\n fs.unlinkSync(deleteFilePath);\n console.log(`[DELETED] ${description}`);\n }\n }\n\n // 🚮 Delete entire folders\n if (deleteFolder) {\n const deleteFolderPath = path.resolve(__dirname, \"../\", deleteFolder);\n if (fs.existsSync(deleteFolderPath)) {\n fs.rmSync(deleteFolderPath, {recursive: true, force: true});\n console.log(`[DELETED] ${description}`);\n }\n }\n })\n\n console.log(\"🎉 MikroORM & Knex patching completed!\");\n}\n","#!/usr/bin/env node\n\nimport { Command } from \"commander\";\nimport dotenv from \"dotenv\";\nimport inquirer from \"inquirer\";\nimport { generateModels } from \"./actions/generate-models\";\nimport { createMigration } from \"./actions/migrations-create\";\nimport { updateMigration } from \"./actions/migrations-update\";\nimport {runPostInstallPatch} from \"./actions/PatchPostinstall\";\n\n// 🔄 Load environment variables from `.env` file\ndotenv.config();\n\n/**\n * Prompts the user for missing parameters using Inquirer.js.\n * @param config - The current configuration object.\n * @param defaultOutput - Default output path.\n * @param customAskMissingParams - Optional function for additional prompts.\n * @returns Updated configuration with user input.\n */\nconst askMissingParams = async (\n config: any,\n defaultOutput: string,\n customAskMissingParams?: (cfg: any, questions: unknown[]) => void,\n) => {\n const questions: unknown[] = [];\n\n if (!config.host)\n questions.push({\n type: \"input\",\n name: \"host\",\n message: \"Enter database host:\",\n default: \"localhost\",\n });\n\n if (!config.port)\n questions.push({\n type: \"input\",\n name: \"port\",\n message: \"Enter database port:\",\n default: \"3306\",\n validate: (input: string) => !isNaN(parseInt(input, 10)),\n });\n\n if (!config.user)\n questions.push({\n type: \"input\",\n name: \"user\",\n message: \"Enter database user:\",\n default: \"root\",\n });\n\n if (!config.password)\n questions.push({\n type: \"password\",\n name: \"password\",\n message: \"Enter database password:\",\n mask: \"*\",\n });\n\n if (!config.dbName)\n questions.push({\n type: \"input\",\n name: \"dbName\",\n message: \"Enter database name:\",\n });\n\n if (!config.output)\n questions.push({\n type: \"input\",\n name: \"output\",\n message: \"Enter output path:\",\n default: defaultOutput,\n });\n\n // Allow additional questions from the caller\n if (customAskMissingParams) {\n customAskMissingParams(config, questions);\n }\n\n // If there are missing parameters, prompt the user\n if (questions.length > 0) {\n // @ts-ignore - Ignore TypeScript warning for dynamic question type\n const answers = await inquirer.prompt(questions);\n return { ...config, ...answers, port: parseInt(answers.port, 10) };\n }\n\n return config;\n};\n\n/**\n * Retrieves configuration parameters from command-line arguments and environment variables.\n * If any required parameters are missing, prompts the user for input.\n * @param cmd - The command object containing CLI options.\n * @param defaultOutput - Default output directory.\n * @param customConfig - Optional function for additional configuration parameters.\n * @param customAskMissingParams - Optional function for additional prompts.\n * @returns A fully resolved configuration object.\n */\nconst getConfig = async (\n cmd: any,\n defaultOutput: string,\n customConfig?: () => any,\n customAskMissingParams?: (cfg: any, questions: unknown[]) => void,\n) => {\n let config = {\n host: cmd.host || process.env.FORGE_SQL_ORM_HOST,\n port: cmd.port\n ? parseInt(cmd.port, 10)\n : process.env.FORGE_SQL_ORM_PORT\n ? parseInt(process.env.FORGE_SQL_ORM_PORT, 10)\n : undefined,\n user: cmd.user || process.env.FORGE_SQL_ORM_USER,\n password: cmd.password || process.env.FORGE_SQL_ORM_PASSWORD,\n dbName: cmd.dbName || process.env.FORGE_SQL_ORM_DBNAME,\n output: cmd.output || process.env.FORGE_SQL_ORM_OUTPUT,\n };\n\n // Merge additional configurations if provided\n if (customConfig) {\n config = { ...config, ...customConfig() };\n }\n\n return await askMissingParams(config, defaultOutput, customAskMissingParams);\n};\n\n// 📌 Initialize CLI\nconst program = new Command();\nprogram.version(\"1.0.0\");\n\n// ✅ Command: Generate database models (Entities)\nprogram\n .command(\"generate:model\")\n .description(\"Generate MikroORM models from the database.\")\n .option(\"--host <string>\", \"Database host\")\n .option(\"--port <number>\", \"Database port\")\n .option(\"--user <string>\", \"Database user\")\n .option(\"--password <string>\", \"Database password\")\n .option(\"--dbName <string>\", \"Database name\")\n .option(\"--output <string>\", \"Output path for entities\")\n .action(async (cmd) => {\n const config = await getConfig(cmd, \"./database/entities\");\n await generateModels(config);\n });\n\n// ✅ Command: Create initial database migration\nprogram\n .command(\"migrations:create\")\n .description(\"Generate an initial migration for the entire database.\")\n .option(\"--host <string>\", \"Database host\")\n .option(\"--port <number>\", \"Database port\")\n .option(\"--user <string>\", \"Database user\")\n .option(\"--password <string>\", \"Database password\")\n .option(\"--dbName <string>\", \"Database name\")\n .option(\"--output <string>\", \"Output path for migrations\")\n .option(\"--entitiesPath <string>\", \"Path to the folder containing entities\")\n .action(async (cmd) => {\n const config = await getConfig(\n cmd,\n \"./database/migration\",\n () => ({\n entitiesPath: cmd.entitiesPath || process.env.FORGE_SQL_ORM_ENTITIES_PATH,\n }),\n (cfg, questions: unknown[]) => {\n if (!cfg.entitiesPath)\n questions.push({\n type: \"input\",\n name: \"entitiesPath\",\n message: \"Enter the path to entities:\",\n default: \"./database/entities\",\n });\n },\n );\n await createMigration(config);\n });\n\n// ✅ Command: Update migration for schema changes\nprogram\n .command(\"migrations:update\")\n .description(\"Generate a migration to update the database schema.\")\n .option(\"--host <string>\", \"Database host\")\n .option(\"--port <number>\", \"Database port\")\n .option(\"--user <string>\", \"Database user\")\n .option(\"--password <string>\", \"Database password\")\n .option(\"--dbName <string>\", \"Database name\")\n .option(\"--output <string>\", \"Output path for migrations\")\n .option(\"--entitiesPath <string>\", \"Path to the folder containing entities\")\n .action(async (cmd) => {\n const config = await getConfig(\n cmd,\n \"./database/migration\",\n () => ({\n entitiesPath: cmd.entitiesPath || process.env.FORGE_SQL_ORM_ENTITIES_PATH,\n }),\n (cfg, questions: unknown[]) => {\n if (!cfg.entitiesPath)\n questions.push({\n type: \"input\",\n name: \"entitiesPath\",\n message: \"Enter the path to entities:\",\n default: \"./database/entities\",\n });\n },\n );\n await updateMigration(config);\n });\n\n// Patch MikroORM and Knex\nprogram\n .command(\"patch:mikroorm\")\n .description(\"Patch MikroORM and Knex dependencies to work properly with Forge\")\n .action(async () => {\n console.log(\"Running MikroORM patch...\");\n await runPostInstallPatch();\n await runPostInstallPatch();\n await runPostInstallPatch();\n console.log(\"✅ MikroORM patch applied successfully!\");\n });\n\n// 🔥 Execute CLI\nprogram.parse(process.argv);\n"],"names":["cleanSQLStatement","generateMigrationFile","saveMigrationFiles","extractCreateStatements","loadEntities","loadMigrationVersion"],"mappings":";;;;;;;;;AAMA,MAAM,sBAAsB,CAAC,eAAuB;AAC5C,QAAA,cAAc,KAAK,QAAQ,UAAU;AAC3C,QAAM,YAAY,KAAK,KAAK,aAAa,UAAU;AAEnD,QAAM,cAAc,GACjB,YAAY,WAAW,EACvB,OAAO,CAAC,SAAS,KAAK,SAAS,KAAK,KAAK,SAAS,UAAU;AAE/D,QAAM,UAAU,YAAY,IAAI,CAAC,SAAS;AACxC,UAAM,aAAa,KAAK,SAAS,MAAM,KAAK;AACrC,WAAA,YAAY,UAAU,cAAc,UAAU;AAAA,EAAA,CACtD;AAED,QAAM,eAAe,GAAG,QAAQ,KAAK,IAAI,CAAC;AAAA;AAAA,kBAAuB,YAAY,IAAI,CAAC,SAAS,KAAK,SAAS,MAAM,KAAK,CAAC,EAAE,KAAK,IAAI,CAAC;AAAA;AAE9H,KAAA,cAAc,WAAW,cAAc,MAAM;AAChD,UAAQ,IAAI,2BAA2B,YAAY,MAAM,YAAY;AACvE;AAEa,MAAA,iBAAiB,OAAO,YAAiB;AAChD,MAAA;AACF,UAAM,YAAY,aAAa;AAAA,MAC7B,MAAM,QAAQ;AAAA,MACd,MAAM,QAAQ;AAAA,MACd,MAAM,QAAQ;AAAA,MACd,UAAU,QAAQ;AAAA,MAClB,QAAQ,QAAQ;AAAA,MAChB,gBAAgB;AAAA,MAChB,WAAW,EAAE,oBAAoB,MAAM;AAAA,MACvC,YA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,QAAQ,IAAI;AAAA,IAAA;AAAA,IAEhD,CAAC,KAAK,cAAyB;AAC7B,UAAI,CAAC,IAAI;AACP,kBAAU,KAAK;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,SAAS;AAAA,QAAA,CACV;AAAA,IAAA;AAAA,EAEP;AACA,QAAM,gBAAgB,MAAM;AAC9B,CAAC;AAGH,QACG,QAAQ,mBAAmB,EAC3B,YAAY,qDAAqD,EACjE,OAAO,mBAAmB,eAAe,EACzC,OAAO,mBAAmB,eAAe,EACzC,OAAO,mBAAmB,eAAe,EACzC,OAAO,uBAAuB,mBAAmB,EACjD,OAAO,qBAAqB,eAAe,EAC3C,OAAO,qBAAqB,4BAA4B,EACxD,OAAO,2BAA2B,wCAAwC,EAC1E,OAAO,OAAO,QAAQ;AACrB,QAAM,SAAS,MAAM;AAAA,IACnB;AAAA,IACA;AAAA,IACA,OAAO;AAAA,MACL,cAAc,IAAI,gBAAgB,QAAQ,IAAI;AAAA,IAAA;AAAA,IAEhD,CAAC,KAAK,cAAyB;AAC7B,UAAI,CAAC,IAAI;AACP,kBAAU,KAAK;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,SAAS;AAAA,QAAA,CACV;AAAA,IAAA;AAAA,EAEP;AACA,QAAM,gBAAgB,MAAM;AAC9B,CAAC;AAGH,QACK,QAAQ,gBAAgB,EACxB,YAAY,kEAAkE,EAC9E,OAAO,YAAY;AAClB,UAAQ,IAAI,2BAA2B;AACvC,QAAM,oBAAoB;AAC1B,QAAM,oBAAoB;AAC1B,QAAM,oBAAoB;AAC1B,UAAQ,IAAI,wCAAwC;AACtD,CAAC;AAGL,QAAQ,MAAM,QAAQ,IAAI;"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","sources":["../scripts/actions/generate-models.ts","../scripts/actions/migrations-create.ts","../scripts/actions/migrations-update.ts","../scripts/actions/PatchPostinstall.ts","../scripts/cli.ts"],"sourcesContent":["import \"reflect-metadata\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { defineConfig, MikroORM, MongoNamingStrategy } from \"@mikro-orm/mysql\";\nimport { EntityGenerator } from \"@mikro-orm/entity-generator\";\n\nconst regenerateIndexFile = (outputPath: string) => {\n const entitiesDir = path.resolve(outputPath);\n const indexPath = path.join(entitiesDir, \"index.ts\");\n\n const entityFiles = fs\n .readdirSync(entitiesDir)\n .filter((file) => file.endsWith(\".ts\") && file !== \"index.ts\");\n\n const imports = entityFiles.map((file) => {\n const entityName = path.basename(file, \".ts\");\n return `import { ${entityName} } from \"./${entityName}\";`;\n });\n\n const indexContent = `${imports.join(\"\\n\")}\\n\\nexport default [${entityFiles.map((file) => path.basename(file, \".ts\")).join(\", \")}];\\n`;\n\n fs.writeFileSync(indexPath, indexContent, \"utf8\");\n console.log(`✅ Updated index.ts with ${entityFiles.length} entities.`);\n};\n\nexport const generateModels = async (options: any) => {\n try {\n const ormConfig = defineConfig({\n host: options.host,\n port: options.port,\n user: options.user,\n password: options.password,\n dbName: options.dbName,\n namingStrategy: MongoNamingStrategy,\n discovery: { warnWhenNoEntities: false },\n extensions: [EntityGenerator],\n debug: true,\n }) as Parameters<typeof MikroORM.initSync>[0];\n\n const orm = MikroORM.initSync(ormConfig);\n console.log(`✅ Connected to ${options.dbName} at ${options.host}:${options.port}`);\n\n await orm.entityGenerator.generate({\n entitySchema: true,\n bidirectionalRelations: false,\n identifiedReferences: false,\n forceUndefined: true,\n undefinedDefaults: true,\n useCoreBaseEntity: false,\n onlyPurePivotTables: false,\n outputPurePivotTables: false,\n scalarPropertiesForRelations: \"always\",\n save: true,\n path: options.output,\n });\n\n regenerateIndexFile(options.output);\n\n console.log(`✅ Entities generated at: ${options.output}`);\n process.exit(0);\n } catch (error) {\n console.error(`❌ Error generating entities:`, error);\n process.exit(1);\n }\n};\n","import \"reflect-metadata\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { MikroORM } from \"@mikro-orm/mysql\";\nimport { execSync } from \"child_process\";\nimport { rmSync } from \"fs\";\n\n/**\n * Cleans SQL statements by removing unnecessary database options.\n * @param sql - The raw SQL statement.\n * @returns The cleaned SQL statement.\n */\nfunction cleanSQLStatement(sql: string): string {\n return sql.replace(/\\s+default\\s+character\\s+set\\s+utf8mb4\\s+engine\\s*=\\s*InnoDB;?/gi, \"\").trim();\n}\n\n/**\n * Generates a migration file using the provided SQL statements.\n * @param createStatements - Array of SQL statements.\n * @param version - Migration version number.\n * @returns TypeScript migration file content.\n */\nfunction generateMigrationFile(createStatements: string[], version: number): string {\n const versionPrefix = `v${version}_MIGRATION`;\n\n // Clean each SQL statement and generate migration lines with .enqueue()\n const migrationLines = createStatements\n .map(\n (stmt, index) =>\n ` .enqueue(\"${versionPrefix}${index}\", \\\"${cleanSQLStatement(stmt)}\\\")`, // eslint-disable-line no-useless-escape\n )\n .join(\"\\n\");\n\n // Migration template\n return `import { MigrationRunner } from \"@forge/sql/out/migration\";\n\nexport default (migrationRunner: MigrationRunner): MigrationRunner => {\n return migrationRunner\n${migrationLines};\n};`;\n}\n\n/**\n * Saves the generated migration file along with `migrationCount.ts` and `index.ts`.\n * @param migrationCode - The migration code to be written to the file.\n * @param version - Migration version number.\n * @param outputDir - Directory where the migration files will be saved.\n */\nfunction saveMigrationFiles(migrationCode: string, version: number, outputDir: string) {\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n const migrationFilePath = path.join(outputDir, `migrationV${version}.ts`);\n const migrationCountPath = path.join(outputDir, `migrationCount.ts`);\n const indexFilePath = path.join(outputDir, `index.ts`);\n\n // Write the migration file\n fs.writeFileSync(migrationFilePath, migrationCode);\n\n // Write the migration count file\n fs.writeFileSync(migrationCountPath, `export const MIGRATION_VERSION = ${version};`);\n\n // Generate the migration index file\n const indexFileContent = `import { MigrationRunner } from \"@forge/sql/out/migration\";\nimport { MIGRATION_VERSION } from \"./migrationCount\";\n\nexport type MigrationType = (\n migrationRunner: MigrationRunner,\n) => MigrationRunner;\n\nexport default async (\n migrationRunner: MigrationRunner,\n): Promise<MigrationRunner> => {\n for (let i = 1; i <= MIGRATION_VERSION; i++) {\n const migrations = (await import(\\`./migrationV\\${i}\\`)) as {\n default: MigrationType;\n };\n migrations.default(migrationRunner);\n }\n return migrationRunner;\n};`;\n\n fs.writeFileSync(indexFilePath, indexFileContent);\n\n console.log(`✅ Migration file created: ${migrationFilePath}`);\n console.log(`✅ Migration count file updated: ${migrationCountPath}`);\n console.log(`✅ Migration index file created: ${indexFilePath}`);\n}\n\n/**\n * Extracts only the relevant SQL statements for migration.\n * @param schema - The full database schema as SQL.\n * @returns Filtered list of SQL statements.\n */\nconst extractCreateStatements = (schema: string): string[] => {\n const statements = schema.split(\";\").map((s) => s.trim());\n\n return statements.filter(\n (stmt) =>\n stmt.startsWith(\"create table\") ||\n (stmt.startsWith(\"alter table\") && stmt.includes(\"add index\")) ||\n stmt.startsWith(\"primary\"),\n );\n};\n\n/**\n * Dynamically loads `entities` from `index.ts` in the specified directory.\n * @param entitiesPath - Path to the directory containing `index.ts`.\n * @returns Array of entity classes.\n */\nconst loadEntities = async (entitiesPath: string) => {\n try {\n const indexFilePath = path.resolve(path.join(entitiesPath, \"index.ts\"));\n if (!fs.existsSync(indexFilePath)) {\n console.error(`❌ Error: index.ts not found in ${indexFilePath}`);\n process.exit(1);\n }\n\n const { default: entities } = await import(indexFilePath);\n console.log(`✅ Loaded ${entities.length} entities from ${entitiesPath}`);\n return entities;\n } catch (error) {\n console.error(`❌ Error loading index.ts from ${entitiesPath}:`, error);\n process.exit(1);\n }\n};\n\n/**\n * Loads the current migration version from `migrationCount.ts`.\n * @param migrationPath - Path to the migration folder.\n * @returns The latest migration version.\n */\nconst loadMigrationVersion = async (migrationPath: string): Promise<number> => {\n try {\n const migrationCountFilePath = path.resolve(path.join(migrationPath, \"migrationCount.ts\"));\n if (!fs.existsSync(migrationCountFilePath)) {\n return 0;\n }\n\n const { MIGRATION_VERSION } = await import(migrationCountFilePath);\n console.log(`✅ Current migration version: ${MIGRATION_VERSION}`);\n return MIGRATION_VERSION as number;\n } catch (error) {\n console.error(`❌ Error loading migrationCount:`, error);\n process.exit(1);\n }\n};\n\n/**\n * Creates a full database migration.\n * @param options - Database connection settings and output paths.\n */\nexport const createMigration = async (options: any) => {\n try {\n let version = await loadMigrationVersion(options.output);\n\n if (version > 0) {\n console.error(`❌ Error: Migration has already been created.`);\n process.exit(1);\n }\n\n // Start from version 1 if no previous migrations exist\n version = 1;\n\n // Load entities dynamically from index.ts\n const entities = await loadEntities(options.entitiesPath);\n\n // Initialize MikroORM\n const orm = MikroORM.initSync({\n host: options.host,\n port: options.port,\n user: options.user,\n password: options.password,\n dbName: options.dbName,\n entities: entities,\n });\n\n // Generate SQL schema\n const createSchemaSQL = await orm.schema.getCreateSchemaSQL({ wrap: true });\n const statements = extractCreateStatements(createSchemaSQL);\n\n // Generate and save migration files\n const migrationFile = generateMigrationFile(statements, version);\n saveMigrationFiles(migrationFile, version, options.output);\n\n console.log(`✅ Migration successfully created!`);\n process.exit(0);\n } catch (error) {\n console.error(`❌ Error during migration creation:`, error);\n process.exit(1);\n }\n};\n","import \"reflect-metadata\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { MikroORM } from \"@mikro-orm/mysql\";\n\n/**\n * Cleans SQL statements by removing unnecessary database options.\n * @param sql - The raw SQL statement.\n * @returns The cleaned SQL statement.\n */\nfunction cleanSQLStatement(sql: string): string {\n return sql.replace(/\\s+default\\s+character\\s+set\\s+utf8mb4\\s+engine\\s*=\\s*InnoDB;?/gi, \"\").trim();\n}\n\n/**\n * Generates a migration file using the provided SQL statements.\n * @param createStatements - Array of SQL statements.\n * @param version - Migration version number.\n * @returns TypeScript migration file content.\n */\nfunction generateMigrationFile(createStatements: string[], version: number): string {\n const versionPrefix = `v${version}_MIGRATION`;\n\n // Clean each SQL statement and generate migration lines with .enqueue()\n const migrationLines = createStatements\n .map(\n (stmt, index) =>\n ` .enqueue(\"${versionPrefix}${index}\", \\\"${cleanSQLStatement(stmt)}\\\")`, // eslint-disable-line no-useless-escape\n )\n .join(\"\\n\");\n\n // Migration template\n return `import { MigrationRunner } from \"@forge/sql/out/migration\";\n\nexport default (migrationRunner: MigrationRunner): MigrationRunner => {\n return migrationRunner\n${migrationLines};\n};`;\n}\n\n/**\n * Saves the generated migration file along with `migrationCount.ts` and `index.ts`.\n * @param migrationCode - The migration code to be written to the file.\n * @param version - Migration version number.\n * @param outputDir - Directory where the migration files will be saved.\n */\nfunction saveMigrationFiles(migrationCode: string, version: number, outputDir: string) {\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n const migrationFilePath = path.join(outputDir, `migrationV${version}.ts`);\n const migrationCountPath = path.join(outputDir, `migrationCount.ts`);\n const indexFilePath = path.join(outputDir, `index.ts`);\n\n // Write the migration file\n fs.writeFileSync(migrationFilePath, migrationCode);\n\n // Write the migration count file\n fs.writeFileSync(migrationCountPath, `export const MIGRATION_VERSION = ${version};`);\n\n // Generate the migration index file\n const indexFileContent = `import { MigrationRunner } from \"@forge/sql/out/migration\";\nimport { MIGRATION_VERSION } from \"./migrationCount\";\n\nexport type MigrationType = (\n migrationRunner: MigrationRunner,\n) => MigrationRunner;\n\nexport default async (\n migrationRunner: MigrationRunner,\n): Promise<MigrationRunner> => {\n for (let i = 1; i <= MIGRATION_VERSION; i++) {\n const migrations = (await import(\\`./migrationV\\${i}\\`)) as {\n default: MigrationType;\n };\n migrations.default(migrationRunner);\n }\n return migrationRunner;\n};`;\n\n fs.writeFileSync(indexFilePath, indexFileContent);\n\n console.log(`✅ Migration file created: ${migrationFilePath}`);\n console.log(`✅ Migration count file updated: ${migrationCountPath}`);\n console.log(`✅ Migration index file created: ${indexFilePath}`);\n}\n\n/**\n * Extracts only the relevant SQL statements for migration.\n * @param schema - The full database schema as SQL.\n * @returns Filtered list of SQL statements.\n */\nconst extractCreateStatements = (schema: string): string[] => {\n const statements = schema.split(\";\").map((s) => s.trim());\n\n return statements.filter(\n (stmt) =>\n stmt.startsWith(\"create table\") ||\n (stmt.startsWith(\"alter table\") && stmt.includes(\"add index\")) ||\n (stmt.startsWith(\"alter table\") && stmt.includes(\"add\") && !stmt.includes(\"foreign\")) ||\n (stmt.startsWith(\"alter table\") && stmt.includes(\"modify\") && !stmt.includes(\"foreign\")),\n );\n};\n\n/**\n * Dynamically loads `entities` from `index.ts` in the specified directory.\n * @param entitiesPath - Path to the directory containing `index.ts`.\n * @returns Array of entity classes.\n */\nconst loadEntities = async (entitiesPath: string) => {\n try {\n const indexFilePath = path.resolve(path.join(entitiesPath, \"index.ts\"));\n if (!fs.existsSync(indexFilePath)) {\n console.error(`❌ Error: index.ts not found in ${entitiesPath}`);\n process.exit(1);\n }\n\n const { default: entities } = await import(indexFilePath);\n console.log(`✅ Loaded ${entities.length} entities from ${entitiesPath}`);\n return entities;\n } catch (error) {\n console.error(`❌ Error loading index.ts from ${entitiesPath}:`, error);\n process.exit(1);\n }\n};\n\n/**\n * Loads the current migration version from `migrationCount.ts`.\n * @param migrationPath - Path to the migration folder.\n * @returns The latest migration version.\n */\nconst loadMigrationVersion = async (migrationPath: string): Promise<number> => {\n try {\n const migrationCountFilePath = path.resolve(path.join(migrationPath, \"migrationCount.ts\"));\n if (!fs.existsSync(migrationCountFilePath)) {\n console.warn(\n `⚠️ Warning: migrationCount.ts not found in ${migrationCountFilePath}, assuming no previous migrations.`,\n );\n return 0;\n }\n\n const { MIGRATION_VERSION } = await import(migrationCountFilePath);\n console.log(`✅ Current migration version: ${MIGRATION_VERSION}`);\n return MIGRATION_VERSION as number;\n } catch (error) {\n console.error(`❌ Error loading migrationCount:`, error);\n process.exit(1);\n }\n};\n\n/**\n * Updates an existing database migration by generating schema modifications.\n * @param options - Database connection settings and output paths.\n */\nexport const updateMigration = async (options: any) => {\n try {\n let version = await loadMigrationVersion(options.output);\n\n if (version < 1) {\n console.log(\n `⚠️ Initial migration not found. Run \"npx forge-sql-orm migrations:create\" first.`,\n );\n process.exit(0);\n }\n version += 1;\n\n // Load entities dynamically from index.ts\n const entities = await loadEntities(options.entitiesPath);\n\n // Initialize MikroORM\n const orm = MikroORM.initSync({\n host: options.host,\n port: options.port,\n user: options.user,\n password: options.password,\n dbName: options.dbName,\n entities,\n debug: true,\n });\n\n // Generate SQL schema updates\n const createSchemaSQL = await orm.schema.getUpdateSchemaMigrationSQL({ wrap: true });\n const statements = extractCreateStatements(createSchemaSQL?.down || \"\");\n\n if (statements.length) {\n const migrationFile = generateMigrationFile(statements, version);\n saveMigrationFiles(migrationFile, version, options.output);\n\n console.log(`✅ Migration successfully updated!`);\n process.exit(0);\n } else {\n console.log(`⚠️ No new migration changes detected.`);\n process.exit(0);\n }\n } catch (error) {\n console.error(`❌ Error during migration update:`, error);\n process.exit(1);\n }\n};\n","import fs from \"fs\";\nimport path from \"path\";\n\n/**\n * Automates patches for MikroORM and Knex to fix Webpack issues.\n * - Removes problematic `require()` calls.\n * - Deletes unnecessary files and folders.\n * - Fixes dynamic imports (`import(id)`) in MikroORM.\n */\n\ninterface Patch {\n file?: string; // File to modify (optional)\n search?: RegExp; // Regex pattern to find problematic code\n replace?: string; // Replacement string for problematic code\n deleteLines?: RegExp[]; // List of regex patterns to remove specific lines\n description: string; // Description of the patch\n deleteFile?: string; // Path of the file to delete (optional)\n deleteFolder?: string; // Path of the folder to delete (optional)\n}\n\nconst PATCHES: Patch[] = [\n // 🗑️ Remove unused dialects (mssql, postgres, sqlite) in MikroORM\n {\n file: \"node_modules/@mikro-orm/knex/MonkeyPatchable.d.ts\",\n deleteLines: [\n /^.*mssql.*$/gim,\n /^.*MsSql.*$/gim,\n /^\\s*Postgres.*$/gm,\n /^.*Sqlite3.*$/gm,\n /^.*BetterSqlite3.*$/gim,\n ],\n description: \"Removing unused dialects from MonkeyPatchable.d.ts\",\n },\n {\n file: \"node_modules/@mikro-orm/knex/MonkeyPatchable.js\",\n deleteLines: [\n /^.*mssql.*$/gim,\n /^.*MsSql.*$/gim,\n /^.*postgres.*$/gim,\n /^.*sqlite.*$/gim,\n /^.*Sqlite.*$/gim,\n ],\n description: \"Removing unused dialects from MonkeyPatchable.js\",\n },\n {\n file: \"node_modules/@mikro-orm/knex/dialects/index.js\",\n deleteLines: [/^.*mssql.*$/gim, /^.*MsSql.*$/gim, /^.*postgresql.*$/gim, /^.*sqlite.*$/gim],\n description: \"Removing unused dialects from @mikro-orm/knex/dialects/index.js\",\n },\n {\n deleteFolder: \"node_modules/@mikro-orm/knex/dialects/mssql\",\n description: \"Removing mssql dialect from MikroORM\",\n },\n {\n deleteFolder: \"node_modules/@mikro-orm/knex/dialects/postgresql\",\n description: \"Removing postgresql dialect from MikroORM\",\n },\n {\n deleteFolder: \"node_modules/@mikro-orm/knex/dialects/sqlite\",\n description: \"Removing sqlite dialect from MikroORM\",\n },\n\n // 🔄 Fix Webpack `Critical dependency: the request of a dependency is an expression`\n {\n file: \"node_modules/@mikro-orm/core/utils/Configuration.js\",\n search: /dynamicImportProvider:\\s*\\/\\* istanbul ignore next \\*\\/\\s*\\(id\\) => import\\(id\\),/g,\n replace: \"dynamicImportProvider: /* istanbul ignore next */ () => Promise.resolve({}),\",\n description: \"Fixing dynamic imports in MikroORM Configuration\",\n },\n {\n file: \"node_modules/@mikro-orm/core/utils/Utils.js\",\n search: /static dynamicImportProvider = \\(id\\) => import\\(id\\);/g,\n replace: \"static dynamicImportProvider = () => Promise.resolve({});\",\n description: \"Fixing dynamic imports in MikroORM Utils.js\",\n },\n\n // 🛑 Remove deprecated `require.extensions` usage\n {\n file: \"node_modules/@mikro-orm/core/utils/Utils.js\",\n search: /\\s\\|\\|\\s*\\(require\\.extensions\\s*&&\\s*!!require\\.extensions\\['\\.ts'\\]\\);\\s*/g,\n replace: \";\",\n description: \"Removing deprecated `require.extensions` check in MikroORM\",\n },\n\n // 🛠️ Patch Knex to remove `Migrator` and `Seeder`\n {\n file: \"node_modules/knex/lib/knex-builder/make-knex.js\",\n deleteLines: [\n /^const \\{ Migrator \\} = require\\('\\.\\.\\/migrations\\/migrate\\/Migrator'\\);$/gm,\n /^const Seeder = require\\('\\.\\.\\/migrations\\/seed\\/Seeder'\\);$/gm,\n ],\n description: \"Removing `Migrator` and `Seeder` requires from make-knex.js\",\n },\n {\n file: \"node_modules/knex/lib/knex-builder/make-knex.js\",\n search: /\\sreturn new Migrator\\(this\\);/g,\n replace: \"return null;\",\n description: \"Replacing `return new Migrator(this);` with `return null;`\",\n },\n {\n file: \"node_modules/knex/lib/knex-builder/make-knex.js\",\n search: /\\sreturn new Seeder\\(this\\);/g,\n replace: \"return null;\",\n description: \"Replacing `return new Seeder(this);` with `return null;`\",\n },\n // 🔄 Patch for MikroORM Entity Generator to use 'forge-sql-orm'\n // {\n // file: \"node_modules/@mikro-orm/entity-generator/SourceFile.js\",\n // search: /^.* from '@mikro-orm.*$/gim,\n // replace: \" }).join(', '))} } from 'forge-sql-orm';`);\",\n // description: \"Replacing entity generator imports with 'forge-sql-orm'\"\n // },\n {\n file: \"node_modules/knex/lib/dialects/index.js\",\n deleteLines: [\n /^.*mssql.*$/gim,\n /^.*MsSql.*$/gim,\n /^.*postgresql.*$/gim,\n /^.*sqlite.*$/gim,\n /^.*oracle.*$/gim,\n /^.*oracledb.*$/gim,\n /^.*pgnative.*$/gim,\n /^.*postgres.*$/gim,\n /^.*redshift.*$/gim,\n /^.*sqlite3.*$/gim,\n /^.*cockroachdb.*$/gim,\n ],\n description: \"Removing unused dialects from @mikro-orm/knex/dialects/index.js\",\n },\n {\n file: \"node_modules/@mikro-orm/core/utils/Utils.js\",\n search: /\\s\\|\\|\\s*\\(require\\.extensions\\s*&&\\s*!!require\\.extensions\\['\\.ts'\\]\\);\\s*/g,\n replace: \";\", // Replaces with semicolon to keep syntax valid\n description: \"Removing deprecated `require.extensions` check from MikroORM\",\n },\n {\n file: \"node_modules/@mikro-orm/core/utils/Utils.js\",\n search: /^.*extensions.*$/gim,\n replace: \"{\", // Replaces with semicolon to keep syntax valid\n description: \"Removing deprecated `require.extensions` check from MikroORM\",\n },\n {\n file: \"node_modules/@mikro-orm/core/utils/Utils.js\",\n search: /^.*package.json.*$/gim,\n replace: \"return 0;\", // Replaces with semicolon to keep syntax valid\n description: \"Removing deprecated `require.extensions` check from MikroORM\",\n },\n {\n file: \"node_modules/@mikro-orm/knex/dialects/mysql/index.js\",\n deleteLines: [/^.*MariaDbKnexDialect.*$/gim],\n description: \"Removing MariaDbKnexDialect\",\n },\n];\n\n/**\n * Runs the MikroORM & Knex patching logic.\n */\nexport function runPostInstallPatch() {\n console.log(\"🔧 Applying MikroORM & Knex patches...\");\n PATCHES.forEach(\n ({ file, search, replace, deleteLines, deleteFile, deleteFolder, description }) => {\n if (file) {\n const filePath = path.resolve(file);\n if (fs.existsSync(filePath)) {\n let content = fs.readFileSync(filePath, \"utf8\");\n let originalContent = content;\n\n // 🔄 Replace text\n if (search && replace) {\n if (typeof search === \"string\" ? content.includes(search) : search.test(content)) {\n content = content.replace(search, replace);\n console.log(`[PATCHED] ${description}`);\n }\n }\n\n // 🗑️ Remove matching lines\n if (deleteLines) {\n deleteLines.forEach((pattern) => {\n content = content\n .split(\"\\n\")\n .filter((line) => !pattern.test(line))\n .join(\"\\n\");\n });\n if (content !== originalContent) {\n console.log(`[CLEANED] Removed matching lines in ${file}`);\n }\n }\n\n // 💾 Save changes only if file was modified\n if (content !== originalContent) {\n fs.writeFileSync(filePath, content, \"utf8\");\n }\n\n // 🚮 Remove empty files\n if (content.trim() === \"\") {\n fs.unlinkSync(filePath);\n console.log(`[REMOVED] ${filePath} (file is now empty)`);\n }\n } else {\n console.warn(`[WARNING] File not found: ${file}`);\n }\n }\n\n // 🚮 Delete specific files\n if (deleteFile) {\n const deleteFilePath = path.resolve(__dirname, \"../\", deleteFile);\n if (fs.existsSync(deleteFilePath)) {\n fs.unlinkSync(deleteFilePath);\n console.log(`[DELETED] ${description}`);\n }\n }\n\n // 🚮 Delete entire folders\n if (deleteFolder) {\n const deleteFolderPath = path.resolve(__dirname, \"../\", deleteFolder);\n if (fs.existsSync(deleteFolderPath)) {\n fs.rmSync(deleteFolderPath, { recursive: true, force: true });\n console.log(`[DELETED] ${description}`);\n }\n }\n },\n );\n\n console.log(\"🎉 MikroORM & Knex patching completed!\");\n}\n","#!/usr/bin/env node\n\nimport { Command } from \"commander\";\nimport dotenv from \"dotenv\";\nimport inquirer from \"inquirer\";\nimport { generateModels } from \"./actions/generate-models\";\nimport { createMigration } from \"./actions/migrations-create\";\nimport { updateMigration } from \"./actions/migrations-update\";\nimport { runPostInstallPatch } from \"./actions/PatchPostinstall\";\n\n// 🔄 Load environment variables from `.env` file\ndotenv.config();\n\n/**\n * Prompts the user for missing parameters using Inquirer.js.\n * @param config - The current configuration object.\n * @param defaultOutput - Default output path.\n * @param customAskMissingParams - Optional function for additional prompts.\n * @returns Updated configuration with user input.\n */\nconst askMissingParams = async (\n config: any,\n defaultOutput: string,\n customAskMissingParams?: (cfg: any, questions: unknown[]) => void,\n) => {\n const questions: unknown[] = [];\n\n if (!config.host)\n questions.push({\n type: \"input\",\n name: \"host\",\n message: \"Enter database host:\",\n default: \"localhost\",\n });\n\n if (!config.port)\n questions.push({\n type: \"input\",\n name: \"port\",\n message: \"Enter database port:\",\n default: \"3306\",\n validate: (input: string) => !isNaN(parseInt(input, 10)),\n });\n\n if (!config.user)\n questions.push({\n type: \"input\",\n name: \"user\",\n message: \"Enter database user:\",\n default: \"root\",\n });\n\n if (!config.password)\n questions.push({\n type: \"password\",\n name: \"password\",\n message: \"Enter database password:\",\n mask: \"*\",\n });\n\n if (!config.dbName)\n questions.push({\n type: \"input\",\n name: \"dbName\",\n message: \"Enter database name:\",\n });\n\n if (!config.output)\n questions.push({\n type: \"input\",\n name: \"output\",\n message: \"Enter output path:\",\n default: defaultOutput,\n });\n\n // Allow additional questions from the caller\n if (customAskMissingParams) {\n customAskMissingParams(config, questions);\n }\n\n // If there are missing parameters, prompt the user\n if (questions.length > 0) {\n // @ts-ignore - Ignore TypeScript warning for dynamic question type\n const answers = await inquirer.prompt(questions);\n return { ...config, ...answers, port: parseInt(answers.port, 10) };\n }\n\n return config;\n};\n\n/**\n * Retrieves configuration parameters from command-line arguments and environment variables.\n * If any required parameters are missing, prompts the user for input.\n * @param cmd - The command object containing CLI options.\n * @param defaultOutput - Default output directory.\n * @param customConfig - Optional function for additional configuration parameters.\n * @param customAskMissingParams - Optional function for additional prompts.\n * @returns A fully resolved configuration object.\n */\nconst getConfig = async (\n cmd: any,\n defaultOutput: string,\n customConfig?: () => any,\n customAskMissingParams?: (cfg: any, questions: unknown[]) => void,\n) => {\n let config = {\n host: cmd.host || process.env.FORGE_SQL_ORM_HOST,\n port: cmd.port\n ? parseInt(cmd.port, 10)\n : process.env.FORGE_SQL_ORM_PORT\n ? parseInt(process.env.FORGE_SQL_ORM_PORT, 10)\n : undefined,\n user: cmd.user || process.env.FORGE_SQL_ORM_USER,\n password: cmd.password || process.env.FORGE_SQL_ORM_PASSWORD,\n dbName: cmd.dbName || process.env.FORGE_SQL_ORM_DBNAME,\n output: cmd.output || process.env.FORGE_SQL_ORM_OUTPUT,\n };\n\n // Merge additional configurations if provided\n if (customConfig) {\n config = { ...config, ...customConfig() };\n }\n\n return await askMissingParams(config, defaultOutput, customAskMissingParams);\n};\n\n// 📌 Initialize CLI\nconst program = new Command();\nprogram.version(\"1.0.0\");\n\n// ✅ Command: Generate database models (Entities)\nprogram\n .command(\"generate:model\")\n .description(\"Generate MikroORM models from the database.\")\n .option(\"--host <string>\", \"Database host\")\n .option(\"--port <number>\", \"Database port\")\n .option(\"--user <string>\", \"Database user\")\n .option(\"--password <string>\", \"Database password\")\n .option(\"--dbName <string>\", \"Database name\")\n .option(\"--output <string>\", \"Output path for entities\")\n .action(async (cmd) => {\n const config = await getConfig(cmd, \"./database/entities\");\n await generateModels(config);\n });\n\n// ✅ Command: Create initial database migration\nprogram\n .command(\"migrations:create\")\n .description(\"Generate an initial migration for the entire database.\")\n .option(\"--host <string>\", \"Database host\")\n .option(\"--port <number>\", \"Database port\")\n .option(\"--user <string>\", \"Database user\")\n .option(\"--password <string>\", \"Database password\")\n .option(\"--dbName <string>\", \"Database name\")\n .option(\"--output <string>\", \"Output path for migrations\")\n .option(\"--entitiesPath <string>\", \"Path to the folder containing entities\")\n .action(async (cmd) => {\n const config = await getConfig(\n cmd,\n \"./database/migration\",\n () => ({\n entitiesPath: cmd.entitiesPath || process.env.FORGE_SQL_ORM_ENTITIES_PATH,\n }),\n (cfg, questions: unknown[]) => {\n if (!cfg.entitiesPath)\n questions.push({\n type: \"input\",\n name: \"entitiesPath\",\n message: \"Enter the path to entities:\",\n default: \"./database/entities\",\n });\n },\n );\n await createMigration(config);\n });\n\n// ✅ Command: Update migration for schema changes\nprogram\n .command(\"migrations:update\")\n .description(\"Generate a migration to update the database schema.\")\n .option(\"--host <string>\", \"Database host\")\n .option(\"--port <number>\", \"Database port\")\n .option(\"--user <string>\", \"Database user\")\n .option(\"--password <string>\", \"Database password\")\n .option(\"--dbName <string>\", \"Database name\")\n .option(\"--output <string>\", \"Output path for migrations\")\n .option(\"--entitiesPath <string>\", \"Path to the folder containing entities\")\n .action(async (cmd) => {\n const config = await getConfig(\n cmd,\n \"./database/migration\",\n () => ({\n entitiesPath: cmd.entitiesPath || process.env.FORGE_SQL_ORM_ENTITIES_PATH,\n }),\n (cfg, questions: unknown[]) => {\n if (!cfg.entitiesPath)\n questions.push({\n type: \"input\",\n name: \"entitiesPath\",\n message: \"Enter the path to entities:\",\n default: \"./database/entities\",\n });\n },\n );\n await updateMigration(config);\n });\n\n// Patch MikroORM and Knex\nprogram\n .command(\"patch:mikroorm\")\n .description(\"Patch MikroORM and Knex dependencies to work properly with Forge\")\n .action(async () => {\n console.log(\"Running MikroORM patch...\");\n await runPostInstallPatch();\n await runPostInstallPatch();\n await runPostInstallPatch();\n console.log(\"✅ MikroORM patch applied successfully!\");\n });\n\n// 🔥 Execute CLI\nprogram.parse(process.argv);\n"],"names":["cleanSQLStatement","generateMigrationFile","save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QAAQ,mBAAmB,EAC3B,YAAY,qDAAqD,EACjE,OAAO,mBAAmB,eAAe,EACzC,OAAO,mBAAmB,eAAe,EACzC,OAAO,mBAAmB,eAAe,EACzC,OAAO,uBAAuB,mBAAmB,EACjD,OAAO,qBAAqB,eAAe,EAC3C,OAAO,qBAAqB,4BAA4B,EACxD,OAAO,2BAA2B,wCAAwC,EAC1E,OAAO,OAAO,QAAQ;AACrB,QAAM,SAAS,MAAM;AAAA,IACnB;AAAA,IACA;AAAA,IACA,OAAO;AAAA,MACL,cAAc,IAAI,gBAAgB,QAAQ,IAAI;AAAA,IAAA;AAAA,IAEhD,CAAC,KAAK,cAAyB;AAC7B,UAAI,CAAC,IAAI;AACP,kBAAU,KAAK;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,SAAS;AAAA,QAAA,CACV;AAAA,IAAA;AAAA,EAEP;AACA,QAAM,gBAAgB,MAAM;AAC9B,CAAC;AAGH,QACG,QAAQ,gBAAgB,EACxB,YAAY,kEAAkE,EAC9E,OAAO,YAAY;AAClB,UAAQ,IAAI,2BAA2B;AACvC,QAAM,oBAAoB;AAC1B,QAAM,oBAAoB;AAC1B,QAAM,oBAAoB;AAC1B,UAAQ,IAAI,wCAAwC;AACtD,CAAC;AAGH,QAAQ,MAAM,QAAQ,IAAI;"}
|
package/dist-cli/forgeSqlCLI.js
CHANGED
|
@@ -9,17 +9,16 @@ const args = process.argv.slice(2).join(" ");
|
|
|
9
9
|
|
|
10
10
|
// Resolve the path to cli.ts (your TypeScript entry file)
|
|
11
11
|
const cliPath = path.resolve(__dirname, "cli.js");
|
|
12
|
-
const tsmPath = path.resolve(__dirname, "tsm","bin.js");
|
|
13
12
|
|
|
14
13
|
// Function to run a command
|
|
15
14
|
const runCommand = (cmd) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
try {
|
|
16
|
+
execSync(cmd, { stdio: "inherit", shell: true });
|
|
17
|
+
process.exit(0);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.error("⚠️ Command execution failed:", e.message);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
23
22
|
};
|
|
24
23
|
|
|
25
|
-
runCommand(`
|
|
24
|
+
runCommand(`npx --yes tsm --no-warnings ${cliPath} ${args}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "forge-sql-orm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"description": "Mikro-ORM integration for Forge-SQL in Atlassian Forge applications.",
|
|
5
5
|
"main": "dist/ForgeSQLORM.js",
|
|
6
6
|
"module": "dist/ForgeSQLORM.mjs",
|
|
@@ -27,33 +27,33 @@
|
|
|
27
27
|
"database"
|
|
28
28
|
],
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@eslint/js": "^9.
|
|
31
|
-
"@mikro-orm/cli": "^6.4.
|
|
32
|
-
"@mikro-orm/entity-generator": "^6.4.
|
|
33
|
-
"@mikro-orm/reflection": "^6.4.
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
35
|
-
"@typescript-eslint/parser": "^8.
|
|
36
|
-
"@vitest/coverage-v8": "^3.0.
|
|
37
|
-
"@vitest/ui": "^3.0.
|
|
38
|
-
"eslint": "^9.
|
|
39
|
-
"eslint-config-prettier": "^10.
|
|
30
|
+
"@eslint/js": "^9.22.0",
|
|
31
|
+
"@mikro-orm/cli": "^6.4.9",
|
|
32
|
+
"@mikro-orm/entity-generator": "^6.4.9",
|
|
33
|
+
"@mikro-orm/reflection": "^6.4.9",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^8.26.0",
|
|
35
|
+
"@typescript-eslint/parser": "^8.26.0",
|
|
36
|
+
"@vitest/coverage-v8": "^3.0.8",
|
|
37
|
+
"@vitest/ui": "^3.0.8",
|
|
38
|
+
"eslint": "^9.22.0",
|
|
39
|
+
"eslint-config-prettier": "^10.1.1",
|
|
40
40
|
"eslint-plugin-import": "^2.31.0",
|
|
41
41
|
"eslint-plugin-node": "^11.1.0",
|
|
42
42
|
"eslint-plugin-prettier": "^5.2.3",
|
|
43
43
|
"eslint-plugin-promise": "^7.2.1",
|
|
44
44
|
"eslint-plugin-vitest": "^0.5.4",
|
|
45
45
|
"globals": "^16.0.0",
|
|
46
|
-
"inquirer": "^12.4.
|
|
46
|
+
"inquirer": "^12.4.3",
|
|
47
47
|
"mysql": "^2.18.1",
|
|
48
|
-
"mysql2": "^3.
|
|
49
|
-
"prettier": "^3.5.
|
|
48
|
+
"mysql2": "^3.13.0",
|
|
49
|
+
"prettier": "^3.5.3",
|
|
50
50
|
"ts-node": "^10.9.2",
|
|
51
51
|
"tsup": "^8.4.0",
|
|
52
|
-
"typescript": "^5.
|
|
53
|
-
"typescript-eslint": "^8.
|
|
54
|
-
"vite": "^6.2.
|
|
52
|
+
"typescript": "^5.8.2",
|
|
53
|
+
"typescript-eslint": "^8.26.0",
|
|
54
|
+
"vite": "^6.2.1",
|
|
55
55
|
"vite-plugin-static-copy": "^2.3.0",
|
|
56
|
-
"vitest": "^3.0.
|
|
56
|
+
"vitest": "^3.0.8"
|
|
57
57
|
},
|
|
58
58
|
"license": "MIT",
|
|
59
59
|
"author": "Vasyl Zakharchenko",
|
|
@@ -61,14 +61,14 @@
|
|
|
61
61
|
"test": "vitest --run --config vitest.config.mjs",
|
|
62
62
|
"test:coverage": "vitest --run --config vitest.config.mjs --coverage",
|
|
63
63
|
"test:watch": "vitest --watch",
|
|
64
|
-
"lint": "eslint
|
|
65
|
-
"lint:fix": "eslint
|
|
64
|
+
"lint": "eslint src examples/forge-sql-orm-example/src examples/forge-sql-orm-example-simple/src --ext .ts,.tsx,.mjs",
|
|
65
|
+
"lint:fix": "eslint src --ext .ts,.tsx,.mjs --fix",
|
|
66
66
|
"format": "prettier --write .",
|
|
67
67
|
"clean": "rm -rf dist",
|
|
68
68
|
"build": "npm run clean && vite build && npm run build:types",
|
|
69
69
|
"build:types": "tsc --emitDeclarationOnly",
|
|
70
70
|
"build:cli": "vite build --mode cli",
|
|
71
|
-
"dependency:fix": "
|
|
71
|
+
"dependency:fix": "node ./dist-cli/forgeSqlCLI.js patch:mikroorm",
|
|
72
72
|
"prepublish:npm": "npm run build:cli && npm run build",
|
|
73
73
|
"publish:npm": "npm publish --access public"
|
|
74
74
|
},
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
],
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@forge/resolver": "^1.6.7",
|
|
85
|
-
"@mikro-orm/core": "6.4.
|
|
86
|
-
"@mikro-orm/mysql": "6.4.
|
|
85
|
+
"@mikro-orm/core": "6.4.9",
|
|
86
|
+
"@mikro-orm/mysql": "6.4.9",
|
|
87
87
|
"moment": "^2.30.1"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { UpdateQueryResponse, sql } from "@forge/sql";
|
|
2
|
-
import { EntityProperty, EntitySchema } from "..";
|
|
2
|
+
import { EntityProperty, EntitySchema, ForgeSqlOrmOptions } from "..";
|
|
3
3
|
import type { types } from "@mikro-orm/core/types";
|
|
4
4
|
import { transformValue } from "../utils/sqlUtils";
|
|
5
5
|
import { CRUDForgeSQL, ForgeSqlOperation } from "./ForgeSQLQueryBuilder";
|
|
6
6
|
|
|
7
7
|
export class ForgeSQLCrudOperations implements CRUDForgeSQL {
|
|
8
8
|
private readonly forgeOperations: ForgeSqlOperation;
|
|
9
|
+
private readonly options: ForgeSqlOrmOptions;
|
|
9
10
|
|
|
10
|
-
constructor(forgeSqlOperations: ForgeSqlOperation) {
|
|
11
|
+
constructor(forgeSqlOperations: ForgeSqlOperation, options: ForgeSqlOrmOptions) {
|
|
11
12
|
this.forgeOperations = forgeSqlOperations;
|
|
13
|
+
this.options = options;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -94,8 +96,9 @@ export class ForgeSQLCrudOperations implements CRUDForgeSQL {
|
|
|
94
96
|
if (!models || models.length === 0) return 0;
|
|
95
97
|
|
|
96
98
|
const query = await this.generateInsertScript(schema, models, updateIfExists);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
if (this.options?.logRawSqlQuery) {
|
|
100
|
+
console.debug("INSERT SQL: " + query.sql);
|
|
101
|
+
}
|
|
99
102
|
const sqlStatement = sql.prepare<UpdateQueryResponse>(query.sql);
|
|
100
103
|
const updateQueryResponseResult = await sqlStatement.execute();
|
|
101
104
|
return updateQueryResponseResult.rows.insertId;
|
|
@@ -133,8 +136,9 @@ export class ForgeSQLCrudOperations implements CRUDForgeSQL {
|
|
|
133
136
|
queryBuilder.andWhere({ [primaryKey.name]: { $eq: id } });
|
|
134
137
|
|
|
135
138
|
const query = queryBuilder.getFormattedQuery();
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
if (this.options?.logRawSqlQuery) {
|
|
140
|
+
console.debug("DELETE SQL: " + query);
|
|
141
|
+
}
|
|
138
142
|
const sqlStatement = sql.prepare<UpdateQueryResponse>(query);
|
|
139
143
|
const updateQueryResponseResult = await sqlStatement.execute();
|
|
140
144
|
return updateQueryResponseResult.rows.affectedRows;
|
|
@@ -158,7 +162,9 @@ export class ForgeSQLCrudOperations implements CRUDForgeSQL {
|
|
|
158
162
|
queryBuilder.andWhere({ [pk.name]: { $eq: value } });
|
|
159
163
|
});
|
|
160
164
|
const query = queryBuilder.getFormattedQuery();
|
|
161
|
-
|
|
165
|
+
if (this.options?.logRawSqlQuery) {
|
|
166
|
+
console.debug("UPDATE SQL: " + query);
|
|
167
|
+
}
|
|
162
168
|
await this.forgeOperations.fetch().executeRawUpdateSQL(query);
|
|
163
169
|
}
|
|
164
170
|
}
|
package/src/core/ForgeSQLORM.ts
CHANGED
|
@@ -4,7 +4,12 @@ import type { AnyEntity, EntityClass, EntityClassGroup } from "@mikro-orm/core/t
|
|
|
4
4
|
import type { QueryBuilder } from "@mikro-orm/knex/query";
|
|
5
5
|
import { MemoryCacheAdapter, MikroORM, NullCacheAdapter } from "@mikro-orm/mysql";
|
|
6
6
|
import { ForgeSQLCrudOperations } from "./ForgeSQLCrudOperations";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
CRUDForgeSQL,
|
|
9
|
+
ForgeSqlOperation,
|
|
10
|
+
ForgeSqlOrmOptions,
|
|
11
|
+
SchemaSqlForgeSql,
|
|
12
|
+
} from "./ForgeSQLQueryBuilder";
|
|
8
13
|
import { ForgeSQLSelectOperations } from "./ForgeSQLSelectOperations";
|
|
9
14
|
import type { Knex } from "knex";
|
|
10
15
|
|
|
@@ -20,9 +25,11 @@ class ForgeSQLORMImpl implements ForgeSqlOperation {
|
|
|
20
25
|
/**
|
|
21
26
|
* Private constructor to enforce singleton behavior.
|
|
22
27
|
* @param entities - The list of entities for ORM initialization.
|
|
28
|
+
* @param options - Options for configuring ForgeSQL ORM behavior.
|
|
23
29
|
*/
|
|
24
30
|
private constructor(
|
|
25
31
|
entities: (EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[],
|
|
32
|
+
options?: ForgeSqlOrmOptions,
|
|
26
33
|
) {
|
|
27
34
|
console.debug("Initializing ForgeSQLORM...");
|
|
28
35
|
|
|
@@ -44,10 +51,11 @@ class ForgeSQLORMImpl implements ForgeSqlOperation {
|
|
|
44
51
|
},
|
|
45
52
|
entities: entities,
|
|
46
53
|
preferTs: false,
|
|
54
|
+
debug: false,
|
|
47
55
|
});
|
|
48
|
-
|
|
49
|
-
this.crudOperations = new ForgeSQLCrudOperations(this);
|
|
50
|
-
this.fetchOperations = new ForgeSQLSelectOperations();
|
|
56
|
+
const newOptions: ForgeSqlOrmOptions = options ?? { logRawSqlQuery: false };
|
|
57
|
+
this.crudOperations = new ForgeSQLCrudOperations(this, newOptions);
|
|
58
|
+
this.fetchOperations = new ForgeSQLSelectOperations(newOptions);
|
|
51
59
|
} catch (error) {
|
|
52
60
|
console.error("ForgeSQLORM initialization failed:", error);
|
|
53
61
|
throw error; // Prevents inconsistent state
|
|
@@ -57,13 +65,15 @@ class ForgeSQLORMImpl implements ForgeSqlOperation {
|
|
|
57
65
|
/**
|
|
58
66
|
* Returns the singleton instance of ForgeSQLORMImpl.
|
|
59
67
|
* @param entities - List of entities (required only on first initialization).
|
|
68
|
+
* @param options - Options for configuring ForgeSQL ORM behavior.
|
|
60
69
|
* @returns The singleton instance of ForgeSQLORMImpl.
|
|
61
70
|
*/
|
|
62
71
|
static getInstance(
|
|
63
72
|
entities: (EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[],
|
|
73
|
+
options?: ForgeSqlOrmOptions
|
|
64
74
|
): ForgeSqlOperation {
|
|
65
75
|
if (!ForgeSQLORMImpl.instance) {
|
|
66
|
-
ForgeSQLORMImpl.instance = new ForgeSQLORMImpl(entities);
|
|
76
|
+
ForgeSQLORMImpl.instance = new ForgeSQLORMImpl(entities, options);
|
|
67
77
|
}
|
|
68
78
|
return ForgeSQLORMImpl.instance;
|
|
69
79
|
}
|
|
@@ -99,6 +109,11 @@ class ForgeSQLORMImpl implements ForgeSqlOperation {
|
|
|
99
109
|
return this.mikroORM.em.createQueryBuilder(entityName, alias, undefined, loggerContext);
|
|
100
110
|
}
|
|
101
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Provides access to the underlying Knex instance for building complex query parts.
|
|
114
|
+
* enabling advanced query customization and performance tuning.
|
|
115
|
+
* @returns The Knex instance, which can be used for query building.
|
|
116
|
+
*/
|
|
102
117
|
getKnex(): Knex<any, any[]> {
|
|
103
118
|
return this.mikroORM.em.getKnex();
|
|
104
119
|
}
|
|
@@ -110,8 +125,9 @@ class ForgeSQLORMImpl implements ForgeSqlOperation {
|
|
|
110
125
|
class ForgeSQLORM {
|
|
111
126
|
private readonly ormInstance: ForgeSqlOperation;
|
|
112
127
|
|
|
113
|
-
constructor(entities: (EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[]
|
|
114
|
-
|
|
128
|
+
constructor(entities: (EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[],
|
|
129
|
+
options?: ForgeSqlOrmOptions) {
|
|
130
|
+
this.ormInstance = ForgeSQLORMImpl.getInstance(entities, options);
|
|
115
131
|
}
|
|
116
132
|
|
|
117
133
|
/**
|