Skip to content

Latest commit

 

History

History
85 lines (49 loc) · 6.46 KB

README.md

File metadata and controls

85 lines (49 loc) · 6.46 KB

fmsync

fmsync

Build Coverage Code quality License Release

Introduction

fmsync ensures that a Markdown file's created date is synchronised with the created date found in its Front Matter. It can do this either on the command line or by using a service configured to constantly watch for changes in Front Matter of files in one or more directories.

Installation

Windows

The latest Windows MSI release is always available here. Alternatively, a full set of Windows MSI releases including prereleases is available here. If a prerelease version is installed, you must uninstall it before installing the next bona fide release version.

Download and run the MSI file. By default, it will install the command line tools as well as a Windows service.

Mac

This repo includes a build for macOS and all tests pass including functional tests running on a macOS VM. So, I am confident that this can work on a Mac. However, I do not have a Mac and I have never tried fmsync on macOS nor have I packaged it up into any form of installer. It is available as a zipped set of binaries on the releases page. If someone can validate the binaries released or is able to help with packaging up into some sort of installer, I'd be grateful.

Linux

No release available. Whilst this project will compile for Linux, it has been removed from the build workflow and no Linux release is available due to fragmentation across different filesystems and Linux distributions making it difficult or in some cases impossible to get and set a created-date for a file. I am happy to revist this if needs be.

Command Line

Usage

Execute FmSync passing a path to a directory which contains files you wish to recursively scan. For any Markdown files found, the file's created date will be updated to match that of the created date found in the file's Front Matter where one exists.

fmsync c:\my-markdownfiles

Logging

By default, only Information, Warnings and Errors are logged to both the console and to a file located in C:\ProgramData\Elzik\fmsync\Elzik.FmSync.ConsoleYYYYMMDD.log on Windows and ~/Library/Logs/Elzik/fmsync/Elzik.FmSync.ConsoleYYYYMMDD.log on macOS. A new file will be created for each day that the tool is used and files older than 7 days are removed.

Worker Service

Usage

After installation, FmSync will be running as a Windows service, watching all of the directories listed in WatcherOptions:WatchedDirectoryPaths. Each time a file is created or edited, FmSync will check if the Front Matter created date is the same as the underlying file's created date and then update the latter to match the former if necessary.

Logging

By default, only Information, Warnings and Errors are logged to both the console (only when started on the command line) and to a file located in C:\ProgramData\Elzik\fmsync\Elzik.FmSync.WorkerYYYYMMDD.log on Windows and ~/Library/Logs/Elzik/fmsync/Elzik.FmSync.ConsoleYYYYMMDD.log on macOS. A new file will be created for each day that the tool is used and files older than 7 days are removed.

Configuration

FmSync is configured through a separate appSettings.json file for both the command line tool (C:\Program Files\Elzik\fmsync\CommandLine\appSettings.json by default on Windows) and the service (C:\Program Files\Elzik\fmsync\Service\appSettings.json by default on Windows) which contains the following sections:

WatcherOptions (Only applicable when running as a service)

This contains a single setting WatchedDirectoryPaths which contains an array of paths, one for each directory to watch for new and changed files which need their created date synchronising. For example, to watch the c:\my-markdownfiles directory for changes:

"WatcherOptions": {
    "WatchedDirectoryPaths": ["c:\\my-markdownfiles"]
  }

Serilog

Logging is provided for by Serilog with the default behaviours as described in the logging sections above. It is beyond the scope of this readme to document this configuration. See the Serilog documentation for general information about configuration. Currently, Console and File Sinks are implemented and more information can be found on their respective repos.

When opening any GitHub Issues, change the MinimumLevel configuration to Debug to increase the amount of information being logged.

FrontMatterOptions

TimeZoneId

  • This contains a single setting, TimeZoneId, which by default is empty. When this setting is empty are not present all created dates found in Front Matter sections at the beginning of a file will be considered as if they were in the current time zone settings for the machine the application is running on.
  • Alternatively, TimeZoneId can be set to any time zone as specified in the Timezone column of this documentation. FmSync will then use this timezone when setting the created date on a file.
  • If the date given in a file's Front Matter contains a time offset, the TimeZoneId given here will be ignored and the offset given will be taken into account when setting the created date on a file.

FileSystemOptions

This contains a single setting, FilenamePattern, which by default is *.md. Only files matching this filter will be acted upon by FmSync.