Skip to content

Commit

Permalink
Automated paclet updating, renaming Info
Browse files Browse the repository at this point in the history
  • Loading branch information
flip phillips committed Mar 16, 2018
1 parent 2a6a002 commit 8ab51df
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Development/Paclets.nb
Git LFS file not shown
11 changes: 7 additions & 4 deletions FPTools/PacletInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
Publisher -> "Skidmore Vision Lab",
Copyright -> "©2018- Flip Phillips & Misc Contributors",
License -> "MIT",
Version -> "0.1.5",
BuildNumber -> "21",
Version -> "0.1.7",
BuildNumber -> "35",
MathematicaVersion -> "11.2+",
URL -> "https://github.com/flipphillips/FPTools",
Thumbnail -> "Documentation/icon.png",
Expand All @@ -27,8 +27,11 @@

"FPTools`ApplyIf",

"FPTools`FPVersionInfo","FPTools`FPVersionString","FPTools`FPWriteVersionInfo","FPTools`FPVersionBumpBuild"
"FPTools`FPVersionInformation",
"FPTools`FPVersionString","FPTools`FPBuildString",
"FPTools`FPWriteVersionInformation","FPTools`FPVersionBumpBuild",
"FPTools`UpdatePacletFile"
},
Context -> {"FPTools`"} }
}
]
]
7 changes: 5 additions & 2 deletions FPTools/Usage.wl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ ApplyIf::usage = "ApplyIf[f,g,x] applies g to x if f[x] is True.";


(* Versioning *)
FPVersionInfo::usage = "FPVersionInfo[path] gives an association with my primitive home grown versioning system.";
FPVersionInformation::usage = "FPVersionInformation[path] gives an association with my primitive home grown versioning system.";
FPVersionString::usage = "FPVersionString[path] returns the current build as a string. the option \"Build->True\" adds the build number to the end of the string.";
FPWriteVersionInfo::usage = "FPWriteVersionInfo[path,vi] takes a version information structure and writes it out. At this point it doesn't validate its structure.";
FPWriteVersionInformation::usage = "FPWriteVersionInformation[path,vi] takes a version information structure and writes it out. At this point it doesn't validate its structure.";
FPVersionBumpBuild::usage = "FPVersionBumpBuild[path] updates the build number in the version json file.";
FPBuildString::usage = "FPBuildString[path] returns the current build number as a string.";

UpdatePacletFile::usage = "UpdatePacletFile[ppath,vpath] writes a new PacletInfo file based on the current version and build in the FP version.json system."
30 changes: 24 additions & 6 deletions FPTools/Versioning.wl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

$versioningFile = "version.json";

FPVersionInfo[path_] := Module[{vp},
FPVersionInformation[path_] := Module[{vp},
vp = FileNameJoin[{path, $versioningFile}];
If[FileExistsQ[vp],
Association[Import[vp]],
{}]]
None]]

FPVersionString[path_, OptionsPattern[{"Build" -> False}]] :=
Module[{vi, vs},
vi = FPVersionInfo[path];
vi = FPVersionInformation[path];
If[vi === None, Return[""]];

vs = StringJoin[
Expand All @@ -22,14 +22,32 @@ FPVersionString[path_, OptionsPattern[{"Build" -> False}]] :=
vs <> " build " <> ToString[vi["build_number"]],
vs]]

FPWriteVersionInfo[path_, vi_] := Module[{vp, vvi = vi},
FPBuildString[path_] :=
Module[{vi},
vi = FPVersionInformation[path];
If[vi === None, "",ToString[vi["build_number"]]]
]

FPWriteVersionInformation[path_, vi_] := Module[{vp, vvi = vi},
vp = FileNameJoin[{path, $versioningFile}];
If[FileExistsQ[vp], DeleteFile[vp]];
vvi["date"] = DateString[];
Export[vp, vvi]]

FPVersionBumpBuild[path_] := Module[{vi},
vi = FPVersionInfo[path];
vi = FPVersionInformation[path];
If[vi === None, Return[{}]];
vi["build_number"] += 1;
FPWriteVersionInfo[path, vi]]
FPWriteVersionInformation[path, vi]]

UpdatePacletFile[ppath_, vpath_] := Module[{peepee, fn},
fn = FileNameJoin[{ppath, "PacletInfo.m"}];

peepee = Import[fn, "Text"];

Export[fn,
StringReplace[peepee,
{RegularExpression["(?m)^(\\s*)Version\\s*->\\s*\"(.*)\""] ->
"$1Version -> \"" <> FPVersionString[vpath] <> "\"",
RegularExpression["(?m)^(\\s*)BuildNumber\\s*->\\s*\"(.*)\""] ->
"$1BuildNumber -> \"" <> FPBuildString[vpath] <> "\""}], "Text"]]
13 changes: 7 additions & 6 deletions build.wls
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/usr/bin/env wolframscript

Print[];
(* directory = DirectoryName[$InputFileName]; *)
directory = Directory[];
pacletDirectory = FileNameJoin[{directory, "FPTools"}];

Print["Building from: ", directory];

FPVersionBumpBuild[directory];

Print["Using directory: ", directory];
files = FileNames["*.paclet", directory];
Print["Found paclets (to be deleted): ", files];
DeleteFile /@ files;

Print["Building new paclet"];
paclet = PackPaclet[FileNameJoin[{directory, "FPTools"}]];
UpdatePacletFile[pacletDirectory,directory];
paclet = PackPaclet[pacletDirectory];
Print["New paclet: ", paclet];

Print[];
Expand All @@ -21,9 +25,6 @@ Print["Found the following old paclets (uninstalling): ", Map[ #["Location"]&, p
Map[ PacletUninstall, paclets ];

(* install new version *)
(* directory = DirectoryName[$InputFileName]; *)
directory=Directory[];
Print["Using directory: ", directory];
files = FileNames["*.paclet", directory];
Print["Paclet file(s) found: ", files];
paclet = Last @ Sort @ files;
Expand Down
6 changes: 3 additions & 3 deletions version.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "FPTools",
"major_version": 0,
"minor_version": 1,
"revision_number": 5,
"build_number": 29,
"date": "Thu Mar 15 19:43:10 EDT 2018"
"revision_number": 7,
"build_number": 36,
"date": "Thu Mar 15 23:30:57 EDT 2018"
}

0 comments on commit 8ab51df

Please sign in to comment.