mindful_dart_util library

Utilities that only depend on Dart.

Classes

Log
Simplest logging for an app. It uses an "App" logger and static methods so Log.info(msg), etc

Functions

addRemoteToRepo({required Directory workingDir, required String remoteUrl, String remoteName = 'origin'}) → void
Init a git repo
areFilesIdentical(File file1, File file2) Future<bool>
@return true if file1's file size and SHA256 checksum is same as file2's.
areFilesOfEqualSize(File file1, File file2) Future<bool>
@return true if file1's File.stat().size is the same as file2's.
cloneAndBranch({required String repo, required Directory rootDir, required String repoSubDir, required String branchName}) → void
Clone a git repo
cloneRepo({required String repo, required Directory workingDir, String? outDirName}) → void
Clone a git repo
computeSHA256Checksum(File file) Future<String>
@return true if file1's SHA256 checksum is the same as file2's.
createBranch({required String branchName, required Directory workingDir}) → void
Create a git branch
createDirMoveOld(Directory rootDir) → void
Create a directory and if it exists, backup the existing directory, named -1, -2, etc.
dateOneWeekAgo() DateTime
The date 7 days ago
deepCopyDirectory(String sourceDirPath, String destinationDirPath) Future<void>
Copy a source directory to a destination with the
ensureDir(String dirName) → void
Ensure a directory exists
executingScriptsDirectory() Directory
The directory of the dart file with the currently executing main()
expandPath(String rootDirName) String
Expand file paths starting with ~/ or ./ to absolute dirs
fileStringFromCli({required String param, required String command, required List<String> args}) Future<String>
Given a param name that accepts a file name as the following argument return the text of the indicated file. @throw UsageException if there's not token following the param @throw FileSystemException if the indicated file does not exist.
findDuplicateFiles(Directory directory, String jsonResultPath, OnDupCheckStartedCallback onDupCheckStartedCallback, DupFoundCallback matchFoundCallback, NoDuplicateCallback onNoDuplicate) Future<Map<File, List<File>>>
Returns a map of a file to all it's dups
findDuplicateFilesWithSave(Directory directory, OnDupCheckStartedCallback onDupCheckStartedCallback, DupFoundCallback matchFoundCallback, NoDuplicateCallback noDuplicateCallback) Future<Map<File, List<File>>>
Looks for dups and saves a report
initAndBranch({required Directory rootDir, required String branchName}) → void
Init a git repo
initRepo({required Directory workingDir}) → void
Init a git repo
logAndThrowOnNon0Exit(ProcessResult process, String message, [List<int>? okExits]) → void
Logs the process result and throws if non-0
partition<T>(List<T> list, int size) Iterable<List<T>>
Partition a list into size'd chunks
runProcessSync({required String executable, required List<String> arguments, required String workingDir, required String throwingError, List<int>? okExits}) → void
Runs an external process, forces error handler, explicit working dir
sameTypes<S, V>() bool
Check whether two types are the same type in Dart when working with generic types.
saveResults(Map<String, List<String>> duplicates, String filePath) Future<void>
Saves a file with the dups
today() DateTime
Today's date
userHome() Directory?
Returns the user's home directory or null if none specified.

Typedefs

DupFoundCallback = void Function(File originalFile, File duplicateFile)
Callback function for dup found
NoDuplicateCallback = void Function(File file)
Callback function for no dups found
OnDupCheckStartedCallback = void Function(File file)
Callback function for start of check