diff --git a/bin/index.js b/bin/index.js index cdca329..7ab96e1 100644 --- a/bin/index.js +++ b/bin/index.js @@ -20,11 +20,13 @@ class EntryPoint { this.#argv = process.argv.slice(2); } - start() { + async start() { if (!Migrator.migrate()) { return; } + versionChecker.fetch(); + if (this.#argv.length === 0 || constants.notAllowedKeywords.some(x => x === this.#argv[0])) { this.#defaultYargs(); return; @@ -59,6 +61,8 @@ class EntryPoint { EntryPoint.#projectYargs(keyword, project); }) .catch((_) => _); + + versionChecker.inform(); } #defaultYargs() { @@ -111,8 +115,4 @@ class EntryPoint { } } -versionChecker.fetch(); - new EntryPoint().start(); - -versionChecker.inform(); \ No newline at end of file diff --git a/bin/migrator/dot-dever.js b/bin/migrator/dot-dever.js index b28d7c1..21d93c5 100644 --- a/bin/migrator/dot-dever.js +++ b/bin/migrator/dot-dever.js @@ -1,13 +1,19 @@ import schemaValidator, {SchemaTypes} from "../common/validators/schema-validator.js"; import ConfigLoader from "../configuration/config-loader.js"; +import {Config} from '../common/models/dot-dever/external.js'; + import DotDeverAddMigrationVersion002 from "./migrations/dot-dever/dot-dever-add-migration-version.002.js"; import DotDeverCreateConfigFile001 from "./migrations/dot-dever/dot-dever-create-config-file.001.js"; export default new class { - migrate() { - let config = ConfigLoader.get(); - + /** + * Migrate + * @param config {Config} + * @param migrationVersion {number} + * @returns {boolean} + */ + migrate(config, migrationVersion) { config = DotDeverCreateConfigFile001.migrate(config); config = DotDeverAddMigrationVersion002.migrate(config); @@ -16,8 +22,9 @@ export default new class { return false; } + config.migrationVersion = migrationVersion; ConfigLoader.write(config); return true; } -} \ No newline at end of file +} diff --git a/bin/migrator/index.js b/bin/migrator/index.js index 609af9d..b27636f 100644 --- a/bin/migrator/index.js +++ b/bin/migrator/index.js @@ -13,12 +13,7 @@ export default new class { return true; } - if (dotDever.migrate(config)) { - config.migrationVersion = this.#migrationVersion; - configLoader.write(config); - - console.log(`Migration to version ${this.#migrationVersion} completed successfully`); - + if (dotDever.migrate(config, this.#migrationVersion)) { return true; } else { console.error(chalk.redBright('Migration of .dever failed validation.')); @@ -27,4 +22,4 @@ export default new class { return false; } } -} \ No newline at end of file +}