@epic-web/workshop-utils 6.61.0 → 6.61.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 +34 -9
- package/package.json +1 -1
package/dist/apps.server.js
CHANGED
|
@@ -16,12 +16,14 @@ import { cachified, exampleAppCache, playgroundAppCache, problemAppCache, soluti
|
|
|
16
16
|
import { compileMdx } from "./compile-mdx.server.js";
|
|
17
17
|
import { getAppConfig, getStackBlitzUrl } from "./config.server.js";
|
|
18
18
|
import { getPreferences } from "./db.server.js";
|
|
19
|
+
import { logger } from "./logger.js";
|
|
19
20
|
import { getDirModifiedTime } from "./modified-time.server.js";
|
|
20
21
|
import { closeProcess, isAppRunning, runAppDev, waitOnApp, } from "./process-manager.server.js";
|
|
21
22
|
import { requestStorageify } from "./request-context.server.js";
|
|
22
23
|
import { getServerTimeHeader, time } from "./timing.server.js";
|
|
23
24
|
import { dayjs } from "./utils.server.js";
|
|
24
25
|
import { getErrorMessage } from "./utils.js";
|
|
26
|
+
const log = logger('epic:apps');
|
|
25
27
|
global.__epicshop_apps_initialized__ ??= false;
|
|
26
28
|
export function setWorkshopRoot(root = process.env.EPICSHOP_CONTEXT_CWD ?? process.cwd()) {
|
|
27
29
|
process.env.EPICSHOP_CONTEXT_CWD = root;
|
|
@@ -656,14 +658,26 @@ async function getTestInfo({ fullPath, }) {
|
|
|
656
658
|
}
|
|
657
659
|
// tests are found in the corresponding solution directory
|
|
658
660
|
const testAppFullPath = (await findSolutionDir({ fullPath })) ?? fullPath;
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
661
|
+
try {
|
|
662
|
+
const dirList = await fs.promises.readdir(testAppFullPath);
|
|
663
|
+
const testFiles = dirList.filter((item) => item.includes('.test.'));
|
|
664
|
+
if (testFiles.length) {
|
|
665
|
+
return {
|
|
666
|
+
type: 'browser',
|
|
667
|
+
pathname: `${getPathname(fullPath)}test/`,
|
|
668
|
+
testFiles,
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
catch (error) {
|
|
673
|
+
// Handle ENOTDIR error (path is a file, not a directory)
|
|
674
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOTDIR') {
|
|
675
|
+
log(`Skipping non-directory path in getTestInfo: ${testAppFullPath}`);
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
// Re-throw other errors
|
|
679
|
+
throw error;
|
|
680
|
+
}
|
|
667
681
|
}
|
|
668
682
|
return { type: 'none' };
|
|
669
683
|
}
|
|
@@ -772,7 +786,18 @@ async function getExampleAppFromPath(fullPath, index, request) {
|
|
|
772
786
|
}
|
|
773
787
|
async function getExampleApps({ timings, request, } = {}) {
|
|
774
788
|
const examplesDir = path.join(getWorkshopRoot(), 'examples');
|
|
775
|
-
|
|
789
|
+
// Filter to only include directories, not files like README.mdx
|
|
790
|
+
const entries = await fs.promises
|
|
791
|
+
.readdir(examplesDir, { withFileTypes: true })
|
|
792
|
+
.catch(() => []);
|
|
793
|
+
const exampleDirs = entries
|
|
794
|
+
.filter((entry) => {
|
|
795
|
+
if (entry.isDirectory())
|
|
796
|
+
return true;
|
|
797
|
+
log(`Skipping non-directory in examples: ${entry.name}`);
|
|
798
|
+
return false;
|
|
799
|
+
})
|
|
800
|
+
.map((entry) => path.join(examplesDir, entry.name));
|
|
776
801
|
const exampleApps = [];
|
|
777
802
|
for (const exampleDir of exampleDirs) {
|
|
778
803
|
const index = exampleDirs.indexOf(exampleDir);
|