MACRO: Macro Repository (i.e. Version Control) Beta


#1

#Macro Repository (i.e. Version Control) Beta

Required: OS/X Yosemite or later

##NOTICE:

This is an early beta version of the Macro Repository set of macros..

  1. These macros are completely functional.
  2. However, the functionality is subject to change.
  3. These macros DO NOT modify your existing macros in any way.
  4. Documentation is somewhere between minimal and non-existent.

##LICENSE / DISCLAIMER:
Copyright (c) 2017 Daniel Thomas

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

#INSTALLATION FILES:

Updated 2017/01/19 17:24 PST: v0.1.7

Macro Repository.v0.1.7.kmmacros (143.3 KB)

#PURPOSE:

This set of macros helps you maintain a "Macro Repository". For our purposes, a "Repository" is a folder that contains all your Groups and Macros, broken out into individual files and folders.

Generally speaking, you would place the Repository folder under some sort of Version Control System (VCS), such as Git.

This allows you to keep track of changes to your macros, over time, so you can compare different versions to see what's changed, or revert back to a previous version, or even recover deleted macros.

#USAGE:

  1. Create a folder to act as your repository. Put the folder under Version Control if you want.
  2. Edit the macro "[KM] Macro Repository Updater" (Feel free to rename it.)
  • Find the magenta-colored actions near the top, and change them to set the variable macrep_repositoryFolderPath to your repository folder.
  1. Run the macro "[KM] Macro Repository Updater", and it will populate the files and folders inside your Repository folder.
  • If you get any errors, please report them and I'll deal with them.
  1. If you're using a VCS, commit the changes.

Anytime you want to update the repository, just run the macro again.

##Viewing the Repository Files:
The repository files are JSON files. I recommend you view them with TextWrangler or BBEdit, because it has good automatic color-coding.

More documentation to come (see below).

##Importing a Repository File:

  1. Open the JSON file in an editor, select everything, and copy it to the clipboard.
  2. In the KM Editor, run the macro [KM] Macro Repository JSON Paster to paste the Group or Macro into KM.
  • A Macro will get pasted into whatever group you have selected.
  • Existing macros or groups will NOT be overwritten (you'll end up with two copies of the group or macro).

#DOCUMENTATION:
As I said at the start, there isn't much. So what I need from you beta-testers is for you to ask questions, and help me identify what to document.

So I've decided not to document anything else at all, to start. Just ask questions, I'll answer them, and hopefully by the time we're done, I'll be able to put something comprehensive together.

I realize this isn't ideal, but I've spent the past 3 or 4 days trying to figure out how to do the documentation, and finally just gave up.

cc: @ccstone, @Tom


Output list of macros
JXA - Classes, Subclasses / Libraries, Sub-Libraries. Is it possible?
Backup Just by Selecting All Macro Folders, but Which Option?
Possible to Run 2 "Instances" of KM Editor?
#2

This looks/sounds great! :thumbsup:

Unfortunately, I got an error running the Updater:

I'm running:
Keyboard Maestro 7.3.1 (7.3.1) on macOS 10.11.4

Suggestions to fix?


I did make two changes:

1. Renamed the Macro to "[KM] Macro Repository Updater (Author.@DanThomas)"
2. Copied the Set Variable outside of the IF/Then Action, and then disabled the If/Then.

<img src="/uploads/default/original/2X/5/55968aaa69c937c13b68219c8cce314a5fdb34f2.png" width="529" height="558">

#3

That would certainly be the error I would expect, if any.

Background: As I’m sure you know, KM stores its groups and macros in a “plist” file. It’s basically an XML file.

So, after saving all the groups and macros to individual JSON files, I read them back in, and reconstruct a plist file from them, and compare the results. If they don’t match, then there’s some sort of situation I didn’t expect.

When I get a mismatch, I save the original and reconstructed plist files to the “/tmp/” folder, as indicated in the error message.

Can you compare the two files and see what the mismatch is? It will either be an obvious and fairly simple mismatch, or something worse. You can use something like “Beyond Compare”, or BBEdit’s “Search->Find Differences”. Whatever you use, it might take a minute or two, because the files are large.

Let me know what you find.

If you really felt trusting, you could zip the two files and email them or PM them to me. Since they contain all your macros, that’s up to you. I know you know you can trust me, but I’ll also understand if you don’t, so no worries there.

Thanks!


#4

Actually you have to also change the test for UserName.

To make things simpler, you might consider using this instead:

Thanks. Expect a PM shortly.


#5

Got your PM. Looks like an easy fix. There’s actually nothing wrong with the code - it’s the process that rebuilds the plist to compare. I’ll report back soon.


#6

OK, updated to new version 0.1.1. The link is in the original post. Should fix your error, plus another one I found.

Let me know if you want details as to what was wrong or not. I don’t know how much to bore you. :slight_smile:


#7

I also get an error (with 0.1.1). When comparing the plists it’s 6×:

<integer>-1</integer> in the “Original” plist vs <real>-1</real> in the “Test” plist.


#8

What’s the <key> right above the mismatch?


#9

ClickCount


#10

Can you tell what action it is? Look for “MacroActionType”.


#11

It might not be an action - it could be in a group trigger I suppose.


#12

I only see the Action key in that dict:

<dict>
  <key>Action</key>
  <string>MoveAndClick</string>
  <key>Button</key>
  <integer>0</integer>
  <key>ClickCount</key>
  <integer>-1</integer>
  <key>DisplayMatches</key>
  <false/>
  <key>DragHorizontalPosition</key>
  <string>200</string>


#13

Sorry, it stll fails, but with a new, unhelpful error msg, and no plist files in /tmp.
BTW, I deleted both of your old macros and the /temp plist files before I installed and ran the Updater.

Something weird is going on though, during the macro, my KM Editor flashes, and the current macro and group are changed to:


#14

The dict of “ClickCount” is part of the array on an “Actions” key, in case this helps.

I try to localize the macro…


#15

That’s normal. It’s because you have some macros that don’t really have “Name” properties defined (long story). I’ll explain all that when we get these initial bugs worked out.

As for the unhelpful error message: Can you change the very last line in the JXA script that passes “false” to pass “true”, and see if it gives a different error message? Thanks.


#16

Thanks. I know what the issue is. Fix coming shortly.


#17

@JMichaelTX - Try wiping out the repository folder and running it again. It’s possible something was left in an inconsistent state.


#18

Sorry, same error as #1:

Adding zip of /tmp plist files to PM.


#19

Right, got your PM. The message is the same, but the reason is vastly different. Give me a little to figure it out.

If you wipe out the repository folder and run it again, you get the same error, right? I’m only asking because it’s a truly strange error.


#20

Tom - Posted version 0.1.2. It should fix your problem. Let me know.

Also, make sure you clear out the repository folder before running it again.