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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Wyatt Greenway
3
+ Copyright (c) 2023 Wyatt Greenway
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -97,8 +97,8 @@ export async function executeCommandByName(commandName) {
97
97
  if (Nife.isEmpty(mythixConfigPath))
98
98
  mythixConfigPath = PWD;
99
99
 
100
- let config = await loadMythixConfig(mythixConfigPath);
101
- let Application = await config.getApplicationClass(config);
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(config, Application);
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);
@@ -22,6 +22,10 @@ export class CommandBase {
22
22
  });
23
23
  }
24
24
 
25
+ getCLIConfig() {
26
+ return this.options.cliConfig || {};
27
+ }
28
+
25
29
  getOptions() {
26
30
  return this.options;
27
31
  }
@@ -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 = require(migrationFileName);
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 application = this.getApplication();
150
- let applicationOptions = application.getOptions();
151
- let dbConnection = application.getConnection();
152
- let migrationsPath = applicationOptions.migrationsPath;
153
- let migrationFiles = this.getMigrationFiles(migrationsPath);
154
- let useTransaction = args.transaction;
155
- let rollback = args.rollback;
156
- let migrationID = args.revision;
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mythix",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Mythix is a NodeJS web-app framework",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",