static void migrate(IMigration migration) { var shouldMigrate = EditorUtility.DisplayDialog("Migrate", "You are about to migrate your source files. " + "Make sure that you have committed your current project or that you have a backup of your project before you proceed.", "I have a backup - Migrate", "Cancel" ); if (shouldMigrate) { EditorUtility.DisplayDialog("Migrate", "Please select the folder, " + migration.workingDirectory + ".", "I will select the requested folder" ); var path = "Assets/"; path = EditorUtility.OpenFolderPanel(migration.version + ": " + migration.workingDirectory, path, string.Empty); if (!string.IsNullOrEmpty(path)) { var changedFiles = migration.Migrate(path); Debug.Log("Applying " + migration.version); foreach (var file in changedFiles) { MigrationUtils.WriteFiles(changedFiles); Debug.Log("Migrated " + file.fileName); } } else { throw new Exception("Could not complete migration! Selected path was invalid!"); } } }
public static void Main(string[] args) { var allMigrations = AppDomain.CurrentDomain .GetInstancesOf <IMigration>() .OrderBy(instance => instance.GetType().FullName) .ToArray(); if (args == null) { printUsage(allMigrations); } else if (args.Length == 1) { var arg = args[0]; if (arg == "-l") { printAllMigrations(allMigrations); } else { printUsage(allMigrations); } } else if (args.Length == 2) { var version = args[0]; var path = args[1]; var migrations = allMigrations.Where(m => m.version == version).ToArray(); if (migrations.Length == 0) { printVersionNotFound(version, allMigrations); } else { foreach (var m in migrations) { MigrationUtils.WriteFiles(m.Migrate(path)); } } } else { printUsage(allMigrations); } }