Skip to content

Commit cc40ffc

Browse files
committed
fix tests, rm unused LPM code
1 parent b0dfc7a commit cc40ffc

File tree

4 files changed

+21
-58
lines changed

4 files changed

+21
-58
lines changed

Common/LPM/LPM.wl

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ BeginPackage["JerryI`LPM`"]
22

33
PacletRepositories::usage = "depricated"
44
LPMRepositories::usage = "LPMRepositories[{\"Github\" -> \"URL to the repo\", ...}] specify the wolfram packages to be synced via remote url"
5-
LPMLoad::usage = ""
5+
LPMLoad::usage = "LPMLoad[\"Directory\"->...] loads paclets stored by LPMRepositories[] without checking updates and etc"
66
Github::usage = "depricated"
77

88

@@ -38,7 +38,20 @@ inspectPackages[dir_String, cbk_] := Module[{
3838

3939
LPMRepositories = PacletRepositories;
4040

41-
LPMLoad[projectDir_String] := If[FileExistsQ[FileNameJoin[{projectDir, "wl_packages"}] ], Map[pacletDirectoryLoad] @ Map[DirectoryName] @ DeleteDuplicatesBy[FileNames["PacletInfo.wl" | "PacletInfo.m", {#}, {2}], DirectoryName]& @ FileNameJoin[{projectDir, "wl_packages"}], $Failed];
41+
LPMLoad[OptionsPattern[] ] := Module[{projectDir},
42+
If[OptionValue["Directory"]//StringQ,
43+
projectDir = OptionValue["Directory"];
44+
If[!StringQ[projectDir], Echo["LPM >> Sorry. This is a wrong folder!"]; Abort[]];
45+
,
46+
projectDir = NotebookDirectory[] // Quiet;
47+
If[!StringQ[projectDir], projectDir = DirectoryName[$InputFileName]];
48+
If[!StringQ[projectDir], Echo["LPM >> Sorry. We cannot work without a project directory. Save your notebook / script first"]; Abort[]];
49+
];
50+
51+
If[FileExistsQ[FileNameJoin[{projectDir, "wl_packages"}] ], Map[pacletDirectoryLoad] @ Map[DirectoryName] @ DeleteDuplicatesBy[FileNames["PacletInfo.wl" | "PacletInfo.m", {#}, {2}], DirectoryName]& @ FileNameJoin[{projectDir, "wl_packages"}], $Failed]
52+
]
53+
54+
Options[LPMLoad] = {"Directory"->None}
4255

4356
PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMode = OptionValue["StrictMode"], info, repos, cache, updated, removed, new, current, updatable, skipUpdates = OptionValue["Passive"], automaticUpdates = OptionValue["AutomaticUpdates"], versionControl, maxVersionDiff = OptionValue["MaxVersionDiff"]},
4457
(* making key-values pairs *)
@@ -49,7 +62,7 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
4962
projectDir = OptionValue["Directory"];
5063
If[!StringQ[projectDir], Echo["LPM >> Sorry. This is a wrong folder!"]; Abort[]];
5164
,
52-
projectDir = NotebookDirectory[];
65+
projectDir = NotebookDirectory[] // Quiet;
5366
If[!StringQ[projectDir], projectDir = DirectoryName[$InputFileName]];
5467
If[!StringQ[projectDir], Echo["LPM >> Sorry. We cannot work without a project directory. Save your notebook / script first"]; Abort[]];
5568
];
@@ -58,20 +71,6 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
5871
CreateDirectory[projectDir, CreateIntermediateDirectories->True];
5972
If[!FileExistsQ[projectDir], Echo["LPM >> Cannot create project directory by path "<>projectDir<>" !!!"]; Abort[] ];
6073
];
61-
62-
63-
If[FileExistsQ[FileNameJoin[{projectDir, ".wl_timestamp"}] ] && !OptionValue["ForceUpdates"],
64-
With[{time = Get[ FileNameJoin[{projectDir, ".wl_timestamp"}] ]},
65-
If[Now - time < OptionValue["UpdateInterval"] || strictMode,
66-
skipUpdates = True;
67-
68-
With[{c = CacheLoad[projectDir]}, If[AssociationQ[c] && !TrueQ[strictMode],
69-
If[Length[Complement[Keys[repos], Keys[c] ] ] > 0, skipUpdates = False];
70-
] ];
71-
72-
];
73-
]
74-
];
7574

7675
(* PASSIVE mode :: skips all checks and just loads wl_package folder *)
7776
If[skipUpdates,
@@ -137,30 +136,6 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
137136

138137
(* will be updated *)
139138
updated = ((#->repos[#])&/@ Keys[updatable]) // Association;
140-
141-
If[maxVersionDiff =!= None,
142-
(* filter if the version is too high *)
143-
versionControl = VersionsLoad[projectDir];
144-
If[versionControl =!= None,
145-
(* apply filter *)
146-
147-
updated = Table[ With[{
148-
lookupVersion = Lookup[versionControl, key, Missing[] ]
149-
},
150-
151-
If[
152-
MissingQ[lookupVersion] || (
153-
convertVersion[ updated[key]["Version"] ] - convertVersion[lookupVersion] <= maxVersionDiff
154-
),
155-
156-
key -> updated[key],
157-
158-
Echo["LPM >> Version difference is too high. Bundled: "<>lookupVersion<>" vs Remote: "<>updated[key]["Version"] ];
159-
Echo["Skipping..."];
160-
Nothing
161-
] ], {key, Keys[updated]}] // Association;
162-
];
163-
];
164139

165140
Echo[StringTemplate["LPM >> will be UPDATED: ``"][Length[updatable]]];
166141

@@ -171,13 +146,6 @@ PacletRepositories[list_List, OptionsPattern[]] := Module[{projectDir, strictMod
171146
(* update local cache file aka packages.json *)
172147
CacheStore[projectDir, repos];
173148

174-
(* store version (if applicable) *)
175-
If[maxVersionDiff =!= None && versionControl === None,
176-
VersionsStore[projectDir, repos]
177-
];
178-
179-
Put[Now, FileNameJoin[{projectDir, ".wl_timestamp"}] ];
180-
181149
(* finally load dirs *)
182150
inspectPackages[FileNameJoin[{projectDir, "wl_packages"}], OptionValue["ConflictResolutionFunction"] ];
183151
Map[pacletDirectoryLoad] @ Map[DirectoryName] @ DeleteDuplicatesBy[FileNames["PacletInfo.wl" | "PacletInfo.m", {#}, {2}], DirectoryName]& @ FileNameJoin[{projectDir, "wl_packages"}];
@@ -194,10 +162,6 @@ Options[PacletRepositories] = {"Directory"->None, "StrictMode"->False, "Passive"
194162
CacheStore[dir_String, repos_Association] := Export[FileNameJoin[{dir, "wl_packages_lock.wl"}], repos]
195163
CacheLoad[dir_String] := If[!FileExistsQ[FileNameJoin[{dir, "wl_packages_lock.wl"}]], Missing[], Import[FileNameJoin[{dir, "wl_packages_lock.wl"}]]];
196164

197-
VersionsStore[dir_String, repos_Association] := Export[FileNameJoin[{dir, "wl_packages_version.wl"}], Map[Function[data, data["Version"] ], repos] ]
198-
VersionsLoad[dir_String] := If[FileExistsQ[FileNameJoin[{dir, "wl_packages_version.wl"}] ], Import[FileNameJoin[{dir, "wl_packages_version.wl"}] ], None ]
199-
200-
201165
CheckUpdates[a_Association] := Module[{result},
202166
CheckUpdates[a, a["key"]]
203167
]

Scripts/start.wls

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,19 @@ Off[Part::partd]; (* avoid warning messages from WLX *)
1414
Needs["CoffeeLiqueur`ExtensionManager`" -> "WLJSPackages`"];
1515

1616
With[{deps = Get[FileNameJoin[{Directory[], "dependencies.wl"}] ]},
17-
If[FailureQ[LPMLoad[Directory[] ] ],
17+
If[FailureQ[LPMLoad[ "Directory" -> Directory[] ] ],
1818
Echo["wl_packages is empty"];
1919

2020
DeleteDirectory[FileNameJoin[{Directory[], "wl_packages"}], DeleteContents->True] // Quiet;
2121
DeleteDirectory[FileNameJoin[{Directory[], "wljs_packages"}], DeleteContents->True] // Quiet;
2222
DeleteFile[FileNameJoin[{Directory[], #}] ] &/@ {
23-
".wl_timestamp",
2423
"wl_packages_lock.wl"
2524
} // Quiet;
2625

2726
Echo["Installing all..."];
28-
LPMRepositories[Map[("Github"->#)&, deps["WL"] ], "Directory" -> Directory[], "MaxVersionDiff"-> 3 ];
27+
LPMRepositories[Map[("Github"->#)&, deps["WL"] ], "Directory" -> Directory[] ];
2928

30-
WLJSPackages`InstallAll[Map[("Github"->#)&, deps["WLJS"] ], "Directory" -> FileNameJoin[{Directory[], "wljs_packages"}], "MaxVersionDiff"-> 3];
29+
WLJSPackages`InstallAll[Map[("Github"->#)&, deps["WLJS"] ], "Directory" -> FileNameJoin[{Directory[], "wljs_packages"}] ];
3130
,
3231

3332
WLJSPackages`Load[FileNameJoin[{Directory[], "wljs_packages"}] ];

tests/integration/bars.show.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test.describe('Bar and Charts', () => {
2727
test('Bubble', async () => {
2828
await clearCell(page);
2929

30-
const outputCell = await evaluate(page, 'SeedRandom[120]; BubbleChart[RandomReal[1, {5, 7, 3}]]', 5000, 500);
30+
const outputCell = await evaluate(page, 'SeedRandom[120]; BubbleChart[RandomReal[1, {5, 7, 3}]]', 25000, 1500);
3131
await expect(outputCell).toHaveScreenshot(['screenshorts', 'bubble.png']);
3232
});
3333

tests/integration/basic.sugar.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ test.describe('Easy check for most basic decorators', () => {
175175
test('Plot', async () => {
176176
await clearCell(page);
177177

178-
const outputCell = await evaluate(page, 'Plot[x, {x,0,1}]', 25000);
178+
const outputCell = await evaluate(page, 'Plot[x, {x,0,1}]', 45000);
179179
await expect(outputCell).toHaveScreenshot(['screenshorts', 'plot.png']);
180180
});
181181

0 commit comments

Comments
 (0)