mythix 4.0.1 → 4.0.2
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/LICENSE +1 -1
- package/lib/cli/cli-utils.mjs +4 -3
- package/lib/cli/command-base.mjs +4 -0
- package/lib/cli/commands/migrate-command.mjs +13 -10
- package/package.json +1 -1
package/LICENSE
CHANGED
package/lib/cli/cli-utils.mjs
CHANGED
|
@@ -97,8 +97,8 @@ export async function executeCommandByName(commandName) {
|
|
|
97
97
|
if (Nife.isEmpty(mythixConfigPath))
|
|
98
98
|
mythixConfigPath = PWD;
|
|
99
99
|
|
|
100
|
-
let
|
|
101
|
-
let Application = await
|
|
100
|
+
let cliConfig = await loadMythixConfig(mythixConfigPath);
|
|
101
|
+
let Application = await cliConfig.getApplicationClass(cliConfig);
|
|
102
102
|
let Commands = Application.getCommandList();
|
|
103
103
|
|
|
104
104
|
CommandClass = Commands[commandName];
|
|
@@ -109,7 +109,7 @@ export async function executeCommandByName(commandName) {
|
|
|
109
109
|
|
|
110
110
|
let applicationConfig = CommandClass.applicationConfig;
|
|
111
111
|
if (typeof applicationConfig === 'function')
|
|
112
|
-
applicationConfig = applicationConfig(
|
|
112
|
+
applicationConfig = applicationConfig(cliConfig, Application);
|
|
113
113
|
else if (applicationConfig)
|
|
114
114
|
applicationConfig = Nife.extend(true, { cli: true, httpServer: false, autoReload: false, logger: { level: Logger.LEVEL_WARN }, runTasks: false }, applicationConfig);
|
|
115
115
|
|
|
@@ -132,6 +132,7 @@ export async function executeCommandByName(commandName) {
|
|
|
132
132
|
await application.start();
|
|
133
133
|
|
|
134
134
|
commandContext = await getArgumentsContext(application);
|
|
135
|
+
commandContext.cliConfig = cliConfig;
|
|
135
136
|
|
|
136
137
|
let commandOptions = commandContext[commandName] || {};
|
|
137
138
|
let commandInstance = new CommandClass(application, commandOptions);
|
package/lib/cli/command-base.mjs
CHANGED
|
@@ -38,7 +38,7 @@ export class MigrateCommand extends CommandBase {
|
|
|
38
38
|
if (fileName.match(/^_/) && stats.isDirectory())
|
|
39
39
|
return false;
|
|
40
40
|
|
|
41
|
-
if (stats.isFile() && !fileName.match(/^\d{14}.*\.js$/))
|
|
41
|
+
if (stats.isFile() && !fileName.match(/^\d{14}.*\.[mc]?js$/))
|
|
42
42
|
return false;
|
|
43
43
|
|
|
44
44
|
return true;
|
|
@@ -76,7 +76,10 @@ export class MigrateCommand extends CommandBase {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
async executeMigration(application, dbConnection, migrationFileName, useTransaction, rollback) {
|
|
79
|
-
let migration =
|
|
79
|
+
let migration = await import(migrationFileName);
|
|
80
|
+
if (migration && migration.default)
|
|
81
|
+
migration = migration.default;
|
|
82
|
+
|
|
80
83
|
let startTime = Nife.now();
|
|
81
84
|
|
|
82
85
|
if (rollback) {
|
|
@@ -146,14 +149,14 @@ export class MigrateCommand extends CommandBase {
|
|
|
146
149
|
);
|
|
147
150
|
};
|
|
148
151
|
|
|
149
|
-
let
|
|
150
|
-
let
|
|
151
|
-
let dbConnection
|
|
152
|
-
let migrationsPath
|
|
153
|
-
let migrationFiles
|
|
154
|
-
let useTransaction
|
|
155
|
-
let rollback
|
|
156
|
-
let migrationID
|
|
152
|
+
let cliConfig = this.getCLIConfig();
|
|
153
|
+
let application = this.getApplication();
|
|
154
|
+
let dbConnection = application.getConnection();
|
|
155
|
+
let migrationsPath = cliConfig.migrationRoot || Path.resolve(cliConfig.appRootPath, 'migrations');
|
|
156
|
+
let migrationFiles = this.getMigrationFiles(migrationsPath);
|
|
157
|
+
let useTransaction = args.transaction;
|
|
158
|
+
let rollback = args.rollback;
|
|
159
|
+
let migrationID = args.revision;
|
|
157
160
|
|
|
158
161
|
if (!migrationID)
|
|
159
162
|
migrationID = await this.fetchLastMigrationIDFromDB(dbConnection);
|