-
-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): refactor internals to reduce number of cycles
Most of the circular dependencies as reported by `madge` are now gone, both in the TS code as in the compiled JS. This should reduce weird circular dependency issues in some environments, like with webpack. Example of issues this should solve: `TypeError: Cannot read property 'getGlobalStorage' of undefined` due to `Utils` being undefined from inside `MetadataStorage`. Some general remarks: - do not import from barrel files (`index.ts`) - move types and interfaces to separate files - when we need some import for a type only, use interface to get around cycles - sometimes it was needed to fallback to `any` (e.g. with `EntityManager`) Still some cycles are there, but they should hopefully not matter (hard to get around them without doing breaking changes).
- Loading branch information
Showing
83 changed files
with
539 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import yargs, { Argv } from 'yargs'; | ||
|
||
import { ConfigurationLoader, Utils } from '@mikro-orm/core'; | ||
import { ClearCacheCommand } from './commands/ClearCacheCommand'; | ||
import { GenerateEntitiesCommand } from './commands/GenerateEntitiesCommand'; | ||
import { SchemaCommandFactory } from './commands/SchemaCommandFactory'; | ||
import { MigrationCommandFactory } from './commands/MigrationCommandFactory'; | ||
import { DebugCommand } from './commands/DebugCommand'; | ||
import { GenerateCacheCommand } from './commands/GenerateCacheCommand'; | ||
import { ImportCommand } from './commands/ImportCommand'; | ||
|
||
export class CLIConfigurator { | ||
|
||
static async configure(): Promise<Argv> { | ||
const settings = await ConfigurationLoader.getSettings(); | ||
|
||
if (settings.useTsNode) { | ||
await ConfigurationLoader.registerTsNode(settings.tsConfigPath); | ||
} | ||
|
||
// noinspection HtmlDeprecatedTag | ||
return yargs | ||
.scriptName('mikro-orm') | ||
.version(Utils.getORMVersion()) | ||
.usage('Usage: $0 <command> [options]') | ||
.example('$0 schema:update --run', 'Runs schema synchronization') | ||
.alias('v', 'version') | ||
.alias('h', 'help') | ||
.command(new ClearCacheCommand()) | ||
.command(new GenerateCacheCommand()) | ||
.command(new GenerateEntitiesCommand()) | ||
.command(new ImportCommand()) | ||
.command(SchemaCommandFactory.create('create')) | ||
.command(SchemaCommandFactory.create('drop')) | ||
.command(SchemaCommandFactory.create('update')) | ||
.command(MigrationCommandFactory.create('create')) | ||
.command(MigrationCommandFactory.create('up')) | ||
.command(MigrationCommandFactory.create('down')) | ||
.command(MigrationCommandFactory.create('list')) | ||
.command(MigrationCommandFactory.create('pending')) | ||
.command(new DebugCommand()) | ||
.recommendCommands() | ||
.strict(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './CLIHelper'; | ||
export * from './CLIConfigurator'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.