-
Notifications
You must be signed in to change notification settings - Fork 44
/
build-paclet.m
106 lines (60 loc) · 2.35 KB
/
build-paclet.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
(* ::Package:: *)
$appName = "MaTeX";
printAbort[str_] := (Print["ABORTING: ", Style[str, Red, Bold]]; Quit[])
If[$VersionNumber < 10.0, printAbort["Mathematica 10.0 or later required."]]
$dir =
Which[
$InputFileName =!= "", DirectoryName[$InputFileName],
$Notebooks, NotebookDirectory[],
True, printAbort["Cannot determine script directory."]
];
SetDirectory[$dir]
If[Not@DirectoryQ[$appName], printAbort["Application directory not found."]]
Check[
Quiet[PacletDirectoryAdd[$appName], PacletDirectoryAdd::expobs];
Needs[$appName <> "`"],
printAbort["Cannot add paclet directory and load package."]
]
If[AbsoluteFileName[$appName] =!= Lookup[PacletInformation[$appName], "Location"],
printAbort["Wrong paclet loaded."]
]
date = DateString[{"Year", "Month", "Day"}];
time = DateString[{"Hour24", "Minute", "Second"}];
$buildDir = StringTemplate["``-``-``"][$appName, date, time]
If[DirectoryQ[$buildDir], printAbort["Build directory already exists."] ]
template =
StringTemplate[
Import[FileNameJoin[{$appName, $appName <> ".m"}], "String"],
Delimiters -> "%%"
];
versionData = <|
"version" -> Lookup[PacletInformation[$appName], "Version"],
"mathversion" -> Lookup[PacletInformation[$appName], "WolframVersion"],
"date" -> DateString[{"MonthName", " ", "DayShort", ", ", "Year"}]
|>
$appDir = FileNameJoin[{$buildDir, $appName}]
CreateDirectory[$buildDir]
CopyDirectory[$appName, $appDir]
DeleteDirectory[FileNameJoin[{$appDir, "Documentation"}], DeleteContents -> True]
CopyDirectory[
FileNameJoin[{"build", $appName, "Documentation"}],
FileNameJoin[{$appDir, "Documentation"}]
]
AddPath["PackageTools"]
Needs["PackageTools`"]
(* Note: Indexing must be done with 11.2, not any later version, as indices are not backwards-compatible. *)
SetDirectory@FileNameJoin[{$appDir, "Documentation", "English"}];
MRun[
MCode[
Needs["DocumentationSearch`"];
DocumentationSearch`CreateDocumentationIndex[Directory[], Directory[], "TextSearchIndex", "UseWolframLanguageData" -> False];
],
"11.2"
]
ResetDirectory[];
CopyFile["LICENSE.txt", FileNameJoin[{$appDir, "LICENSE.txt"}]]
Export[FileNameJoin[{$appDir, $appName <> ".m"}], template[versionData], "String"]
DeleteFile /@ FileNames[".*", $appDir, Infinity]
PackPaclet[$appDir]
DeleteDirectory[$appDir, DeleteContents -> True]
ResetDirectory[]