@epic-web/workshop-utils 6.78.1 → 6.78.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps.server.js +29 -10
- package/package.json +1 -1
package/dist/apps.server.js
CHANGED
|
@@ -656,6 +656,14 @@ export async function getFullPathFromAppName(appName) {
|
|
|
656
656
|
});
|
|
657
657
|
return dir ?? appName;
|
|
658
658
|
}
|
|
659
|
+
async function resolveExistingAppPath(appName) {
|
|
660
|
+
const fullPath = await getFullPathFromAppName(appName);
|
|
661
|
+
if (!path.isAbsolute(fullPath))
|
|
662
|
+
return null;
|
|
663
|
+
if (!(await exists(fullPath)))
|
|
664
|
+
return null;
|
|
665
|
+
return fullPath;
|
|
666
|
+
}
|
|
659
667
|
export async function findSolutionDir({ fullPath, }) {
|
|
660
668
|
const dirName = path.basename(fullPath);
|
|
661
669
|
if (dirName.includes('.problem')) {
|
|
@@ -673,10 +681,11 @@ export async function findSolutionDir({ fullPath, }) {
|
|
|
673
681
|
}
|
|
674
682
|
else if (fullPath.endsWith('playground')) {
|
|
675
683
|
const appName = await getPlaygroundAppName();
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
684
|
+
const baseAppFullPath = appName
|
|
685
|
+
? await resolveExistingAppPath(appName)
|
|
686
|
+
: null;
|
|
687
|
+
if (baseAppFullPath) {
|
|
688
|
+
return findSolutionDir({ fullPath: baseAppFullPath });
|
|
680
689
|
}
|
|
681
690
|
}
|
|
682
691
|
return null;
|
|
@@ -698,8 +707,11 @@ export async function findProblemDir({ fullPath, }) {
|
|
|
698
707
|
}
|
|
699
708
|
else if (fullPath.endsWith('playground')) {
|
|
700
709
|
const appName = await getPlaygroundAppName();
|
|
701
|
-
|
|
702
|
-
|
|
710
|
+
const baseAppFullPath = appName
|
|
711
|
+
? await resolveExistingAppPath(appName)
|
|
712
|
+
: null;
|
|
713
|
+
if (baseAppFullPath) {
|
|
714
|
+
return findProblemDir({ fullPath: baseAppFullPath });
|
|
703
715
|
}
|
|
704
716
|
}
|
|
705
717
|
return null;
|
|
@@ -758,10 +770,13 @@ async function getDevInfo({ fullPath, portNumber, }) {
|
|
|
758
770
|
export async function getPlaygroundApp({ timings, request, } = {}) {
|
|
759
771
|
const playgroundDir = path.join(getWorkshopRoot(), 'playground');
|
|
760
772
|
const baseAppName = await getPlaygroundAppName();
|
|
761
|
-
const key = `playground-${baseAppName}`;
|
|
762
773
|
const baseAppFullPath = baseAppName
|
|
763
|
-
? await
|
|
774
|
+
? await resolveExistingAppPath(baseAppName)
|
|
764
775
|
: null;
|
|
776
|
+
if (baseAppName && !baseAppFullPath) {
|
|
777
|
+
log.warn(`Playground base app missing: ${baseAppName}`);
|
|
778
|
+
}
|
|
779
|
+
const key = `playground-${baseAppName}`;
|
|
765
780
|
const playgroundCacheEntry = await playgroundAppCache.get(key);
|
|
766
781
|
return cachified({
|
|
767
782
|
key,
|
|
@@ -786,15 +801,19 @@ export async function getPlaygroundApp({ timings, request, } = {}) {
|
|
|
786
801
|
getTestInfo({ fullPath: playgroundDir }),
|
|
787
802
|
getDevInfo({ fullPath: playgroundDir, portNumber }),
|
|
788
803
|
]);
|
|
789
|
-
const appModifiedTime = await getDirModifiedTime(await getFullPathFromAppName(baseAppName));
|
|
790
804
|
const playgroundAppModifiedTime = await getDirModifiedTime(playgroundDir);
|
|
805
|
+
const appModifiedTime = baseAppFullPath
|
|
806
|
+
? await getDirModifiedTime(baseAppFullPath)
|
|
807
|
+
: -1;
|
|
791
808
|
const type = 'playground';
|
|
792
809
|
const title = compiledReadme?.title ?? name;
|
|
793
810
|
return {
|
|
794
811
|
name,
|
|
795
812
|
appName: baseAppName,
|
|
796
813
|
type,
|
|
797
|
-
isUpToDate:
|
|
814
|
+
isUpToDate: baseAppFullPath
|
|
815
|
+
? appModifiedTime <= playgroundAppModifiedTime
|
|
816
|
+
: false,
|
|
798
817
|
fullPath: playgroundDir,
|
|
799
818
|
relativePath: playgroundDir.replace(`${getWorkshopRoot()}${path.sep}`, ''),
|
|
800
819
|
title,
|