@epic-web/workshop-utils 5.0.1 → 5.0.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.
@@ -2,6 +2,9 @@ import { type CacheEntry } from '@epic-web/cachified';
2
2
  import '@total-typescript/ts-reset';
3
3
  import { z } from 'zod';
4
4
  import { type Timings } from './timing.server.js';
5
+ declare global {
6
+ var __epicshop_apps_initialized__: boolean | undefined;
7
+ }
5
8
  export declare const workshopRoot: string;
6
9
  type CachifiedOptions = {
7
10
  timings?: Timings;
@@ -3138,8 +3141,8 @@ export declare function isPlaygroundApp(app: any): app is PlaygroundApp;
3138
3141
  export declare function isExampleApp(app: any): app is ExampleApp;
3139
3142
  export declare function isExerciseStepApp(app: any): app is ExerciseStepApp;
3140
3143
  export declare const modifiedTimes: Map<string, number>;
3141
- export declare function init(): void;
3142
- export declare function setModifiedTimesForDir(dir: string): void;
3144
+ export declare function init(): Promise<void>;
3145
+ export declare function setModifiedTimesForAppDirs(...filePaths: Array<string>): void;
3143
3146
  export declare function getForceFreshForDir(cacheEntry: CacheEntry | null | undefined, ...dirs: Array<string | undefined | null>): true | undefined;
3144
3147
  export declare function getExercises({ timings, request, }?: CachifiedOptions): Promise<Array<Exercise>>;
3145
3148
  export declare function getApps({ timings, request, forceFresh, }?: CachifiedOptions & {
@@ -4179,5 +4182,9 @@ export declare function getWorkshopFinished({ request, }?: {
4179
4182
  readonly relativePath: "exercises/finished.mdx";
4180
4183
  }>;
4181
4184
  export declare function getRelativePath(filePath: string): string;
4185
+ /**
4186
+ * Given a file path, this will determine the path to the app that file belongs to.
4187
+ */
4188
+ export declare function getAppPathFromFilePath(filePath: string): string | null;
4182
4189
  export {};
4183
4190
  //# sourceMappingURL=apps.server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"apps.server.d.ts","sourceRoot":"","sources":["../../src/apps.server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,qBAA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AAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAGpD;AAED,wBAAsB,aAAa,CAClC,MAAM,EAAE,MAAM,EACd,EAAE,KAAK,EAAE,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,iBAwInC;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,2BAgBzC;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,UAmB5D;AAED,wBAAsB,uBAAuB,CAAC,EAC7C,OAAO,GACP,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;;;GAc5B;AAED,wBAAsB,mBAAmB,CAAC,EACzC,OAAO,GACP,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;;;GAkB5B;AAID,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,UAK/C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA2BtE"}
@@ -1,22 +1,23 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { remember } from '@epic-web/remember';
4
+ import chokidar from 'chokidar';
4
5
  /// TODO: figure out why this import is necessary (without it tsc seems to not honor the boolean reset 🤷‍♂️)
5
6
  import '@total-typescript/ts-reset';
7
+ import closeWithGrace from 'close-with-grace';
6
8
  import { execa } from 'execa';
7
9
  import fsExtra from 'fs-extra';
8
- import { glob } from 'glob';
9
10
  import { globby, isGitIgnored } from 'globby';
10
11
  import { z } from 'zod';
11
12
  import { appsCache, cachified, exampleAppCache, playgroundAppCache, problemAppCache, solutionAppCache, } from './cache.server.js';
12
- import { getWatcher, withoutWatcher } from './change-tracker.server.js';
13
13
  import { compileMdx } from './compile-mdx.server.js';
14
- import { bustWorkshopConfigCache, getAppConfig, getStackBlitzUrl, getWorkshopConfig, } from './config.server.js';
14
+ import { getAppConfig, getStackBlitzUrl, getWorkshopConfig, } from './config.server.js';
15
15
  import { getEnv, init as initEnv } from './env.server.js';
16
+ import { getDirModifiedTime } from './modified-time.server.js';
16
17
  import { closeProcess, isAppRunning, runAppDev, waitOnApp, } from './process-manager.server.js';
17
- import { getServerTimeHeader } from './timing.server.js';
18
+ import { getServerTimeHeader, time } from './timing.server.js';
18
19
  import { getErrorMessage } from './utils.js';
19
- let initialized = false;
20
+ global.__epicshop_apps_initialized__ ??= false;
20
21
  export const workshopRoot = (process.env.EPICSHOP_CONTEXT_CWD =
21
22
  process.env.EPICSHOP_CONTEXT_CWD ?? process.cwd());
22
23
  const playgroundAppNameInfoPath = path.join(workshopRoot, 'node_modules', '.cache', 'epicshop', 'playground.json');
@@ -141,27 +142,53 @@ async function firstToExist(...files) {
141
142
  return index === -1 ? null : files[index];
142
143
  }
143
144
  export const modifiedTimes = remember('modified_times', () => new Map());
144
- export function init() {
145
- if (initialized)
145
+ export async function init() {
146
+ if (global.__epicshop_apps_initialized__)
146
147
  return;
147
- initialized = true;
148
+ global.__epicshop_apps_initialized__ = true;
148
149
  const config = getWorkshopConfig();
149
150
  process.env.EPICSHOP_GITHUB_REPO = config.githubRepo;
150
151
  process.env.EPICSHOP_GITHUB_ROOT = config.githubRoot;
151
152
  initEnv();
152
153
  global.ENV = getEnv();
153
- getWatcher()?.on('all', handleFileChanges);
154
- }
155
- async function handleFileChanges(event, filePath) {
156
- if (filePath === path.join(workshopRoot, 'package.json')) {
157
- bustWorkshopConfigCache();
158
- }
159
- const apps = await getApps();
160
- for (const app of apps) {
161
- if (filePath.startsWith(app.fullPath)) {
162
- modifiedTimes.set(app.fullPath, Date.now());
163
- break;
164
- }
154
+ if (!ENV.EPICSHOP_DEPLOYED) {
155
+ const isIgnored = await isGitIgnored({ cwd: workshopRoot });
156
+ // watch the README, FINISHED, and package.json for changes that affect the apps
157
+ const filesToWatch = ['README.mdx', 'FINISHED.mdx', 'package.json'];
158
+ const chok = chokidar.watch(['examples', 'playground', 'exercises'], {
159
+ cwd: workshopRoot,
160
+ ignoreInitial: true,
161
+ ignored(filePath, stats) {
162
+ if (isIgnored(filePath))
163
+ return true;
164
+ if (filePath.includes('.git'))
165
+ return true;
166
+ if (stats?.isDirectory()) {
167
+ if (filePath.endsWith('playground'))
168
+ return false;
169
+ const pathParts = filePath.split(path.sep);
170
+ if (pathParts.at(-2) === 'examples')
171
+ return false;
172
+ // steps
173
+ if (pathParts.at(-3) === 'exercises')
174
+ return false;
175
+ // exercises
176
+ if (pathParts.at(-2) === 'exercises')
177
+ return false;
178
+ // the exercise dir itself
179
+ if (pathParts.at(-1) === 'exercises')
180
+ return false;
181
+ return true;
182
+ }
183
+ return stats?.isFile()
184
+ ? !filesToWatch.some((file) => filePath.endsWith(file))
185
+ : false;
186
+ },
187
+ });
188
+ chok.on('all', (_event, filePath) => {
189
+ setModifiedTimesForAppDirs(path.join(workshopRoot, filePath));
190
+ });
191
+ closeWithGrace(() => chok.close());
165
192
  }
166
193
  }
167
194
  function getForceFresh(cacheEntry) {
@@ -172,8 +199,17 @@ function getForceFresh(cacheEntry) {
172
199
  return undefined;
173
200
  return latestModifiedTime > cacheEntry.metadata.createdTime ? true : undefined;
174
201
  }
175
- export function setModifiedTimesForDir(dir) {
176
- modifiedTimes.set(dir, Date.now());
202
+ export function setModifiedTimesForAppDirs(...filePaths) {
203
+ const now = Date.now();
204
+ for (const filePath of filePaths) {
205
+ const appDir = getAppPathFromFilePath(filePath);
206
+ if (appDir) {
207
+ modifiedTimes.set(appDir, now);
208
+ }
209
+ else {
210
+ console.warn(`filePath ${filePath} does not match any app dir`);
211
+ }
212
+ }
177
213
  }
178
214
  export function getForceFreshForDir(cacheEntry, ...dirs) {
179
215
  const truthyDirs = dirs.filter(Boolean);
@@ -275,8 +311,7 @@ export async function getExercises({ timings, request, } = {}) {
275
311
  }
276
312
  let appCallCount = 0;
277
313
  export async function getApps({ timings, request, forceFresh, } = {}) {
278
- if (!initialized)
279
- init();
314
+ await init();
280
315
  const key = 'apps';
281
316
  const apps = await cachified({
282
317
  key,
@@ -289,10 +324,24 @@ export async function getApps({ timings, request, forceFresh, } = {}) {
289
324
  ttl: 1000 * 60 * 60 * 24,
290
325
  forceFresh: forceFresh ?? getForceFresh(appsCache.get(key)),
291
326
  getFreshValue: async () => {
292
- const playgroundApp = await getPlaygroundApp({ request, timings });
293
- const problemApps = await getProblemApps({ request, timings });
294
- const solutionApps = await getSolutionApps({ request, timings });
295
- const exampleApps = await getExampleApps({ request, timings });
327
+ const [playgroundApp, problemApps, solutionApps, exampleApps] = await Promise.all([
328
+ time(() => getPlaygroundApp({ request, timings }), {
329
+ type: 'getPlaygroundApp',
330
+ timings,
331
+ }),
332
+ time(() => getProblemApps({ request, timings }), {
333
+ type: 'getProblemApps',
334
+ timings,
335
+ }),
336
+ time(() => getSolutionApps({ request, timings }), {
337
+ type: 'getSolutionApps',
338
+ timings,
339
+ }),
340
+ time(() => getExampleApps({ request, timings }), {
341
+ type: 'getExampleApps',
342
+ timings,
343
+ }),
344
+ ]);
296
345
  const sortedApps = [
297
346
  playgroundApp,
298
347
  ...problemApps,
@@ -389,18 +438,38 @@ export function extractNumbersAndTypeFromAppNameOrPath(fullPathOrAppName) {
389
438
  }
390
439
  async function getProblemDirs() {
391
440
  const exercisesDir = path.join(workshopRoot, 'exercises');
392
- const problemDirs = (await glob('**/*.problem*', {
393
- cwd: exercisesDir,
394
- ignore: 'node_modules/**',
395
- })).map((p) => path.join(exercisesDir, p));
441
+ const problemDirs = [];
442
+ const exerciseSubDirs = await readDir(exercisesDir);
443
+ for (const subDir of exerciseSubDirs) {
444
+ const fullSubDir = path.join(exercisesDir, subDir);
445
+ // catch handles non-directories without us having to bother checking
446
+ // whether it's a directory
447
+ const subDirContents = await readDir(fullSubDir).catch(() => null);
448
+ if (!subDirContents)
449
+ continue;
450
+ const problemSubDirs = subDirContents
451
+ .filter((dir) => dir.includes('.problem'))
452
+ .map((dir) => path.join(fullSubDir, dir));
453
+ problemDirs.push(...problemSubDirs);
454
+ }
396
455
  return problemDirs;
397
456
  }
398
457
  async function getSolutionDirs() {
399
458
  const exercisesDir = path.join(workshopRoot, 'exercises');
400
- const solutionDirs = (await glob('**/*.solution*', {
401
- cwd: exercisesDir,
402
- ignore: 'node_modules/**',
403
- })).map((p) => path.join(exercisesDir, p));
459
+ const solutionDirs = [];
460
+ const exerciseSubDirs = await readDir(exercisesDir);
461
+ for (const subDir of exerciseSubDirs) {
462
+ const fullSubDir = path.join(exercisesDir, subDir);
463
+ // catch handles non-directories without us having to bother checking
464
+ // whether it's a directory
465
+ const subDirContents = await readDir(fullSubDir).catch(() => null);
466
+ if (!subDirContents)
467
+ continue;
468
+ const solutionSubDirs = subDirContents
469
+ .filter((dir) => dir.includes('.solution'))
470
+ .map((dir) => path.join(fullSubDir, dir));
471
+ solutionDirs.push(...solutionSubDirs);
472
+ }
404
473
  return solutionDirs;
405
474
  }
406
475
  /**
@@ -622,7 +691,7 @@ async function getExampleAppFromPath(fullPath, index, request) {
622
691
  }
623
692
  async function getExampleApps({ timings, request, } = {}) {
624
693
  const examplesDir = path.join(workshopRoot, 'examples');
625
- const exampleDirs = (await glob('*', { cwd: examplesDir, ignore: 'node_modules/**' })).map((p) => path.join(examplesDir, p));
694
+ const exampleDirs = (await readDir(examplesDir)).map((p) => path.join(examplesDir, p));
626
695
  const exampleApps = [];
627
696
  for (const exampleDir of exampleDirs) {
628
697
  const index = exampleDirs.indexOf(exampleDir);
@@ -635,10 +704,12 @@ async function getExampleApps({ timings, request, } = {}) {
635
704
  timingKey: exampleDir.replace(`${examplesDir}${path.sep}`, ''),
636
705
  request,
637
706
  forceFresh: getForceFreshForDir(exampleAppCache.get(key), exampleDir),
638
- getFreshValue: () => getExampleAppFromPath(exampleDir, index, request).catch((error) => {
639
- console.error(error);
640
- return null;
641
- }),
707
+ getFreshValue: async () => {
708
+ return getExampleAppFromPath(exampleDir, index, request).catch((error) => {
709
+ console.error(error);
710
+ return null;
711
+ });
712
+ },
642
713
  });
643
714
  if (exampleApp)
644
715
  exampleApps.push(exampleApp);
@@ -701,10 +772,12 @@ async function getSolutionApps({ timings, request, } = {}) {
701
772
  request,
702
773
  ttl: 1000 * 60 * 60 * 24,
703
774
  forceFresh: getForceFreshForDir(solutionAppCache.get(solutionDir), solutionDir),
704
- getFreshValue: () => getSolutionAppFromPath(solutionDir, request).catch((error) => {
705
- console.error(error);
706
- return null;
707
- }),
775
+ getFreshValue: async () => {
776
+ return getSolutionAppFromPath(solutionDir, request).catch((error) => {
777
+ console.error(error);
778
+ return null;
779
+ });
780
+ },
708
781
  });
709
782
  if (solutionApp)
710
783
  solutionApps.push(solutionApp);
@@ -768,10 +841,12 @@ async function getProblemApps({ timings, request, } = {}) {
768
841
  request,
769
842
  ttl: 1000 * 60 * 60 * 24,
770
843
  forceFresh: getForceFreshForDir(problemAppCache.get(problemDir), problemDir, solutionDir),
771
- getFreshValue: () => getProblemAppFromPath(problemDir).catch((error) => {
772
- console.error(error);
773
- return null;
774
- }),
844
+ getFreshValue: async () => {
845
+ return getProblemAppFromPath(problemDir).catch((error) => {
846
+ console.error(error);
847
+ return null;
848
+ });
849
+ },
775
850
  });
776
851
  if (problemApp)
777
852
  problemApps.push(problemApp);
@@ -868,125 +943,121 @@ export async function getAppFromFile(filePath) {
868
943
  }
869
944
  export async function setPlayground(srcDir, { reset } = {}) {
870
945
  const destDir = path.join(workshopRoot, 'playground');
871
- await withoutWatcher(async () => {
872
- const isIgnored = await isGitIgnored({ cwd: srcDir });
873
- const playgroundApp = await getAppByName('playground');
874
- const playgroundWasRunning = playgroundApp
875
- ? isAppRunning(playgroundApp)
876
- : false;
877
- if (playgroundApp && reset) {
878
- await closeProcess(playgroundApp.name);
879
- await fsExtra.remove(destDir);
880
- }
881
- const setPlaygroundTimestamp = Date.now();
882
- // run prepare-playground script if it exists
883
- const preSetPlaygroundPath = await firstToExist(path.join(srcDir, 'epicshop', 'pre-set-playground.js'), path.join(workshopRoot, 'epicshop', 'pre-set-playground.js'));
884
- if (preSetPlaygroundPath) {
885
- await execa('node', [preSetPlaygroundPath], {
886
- cwd: workshopRoot,
887
- stdio: 'inherit',
888
- env: {
889
- EPICSHOP_PLAYGROUND_TIMESTAMP: setPlaygroundTimestamp.toString(),
890
- EPICSHOP_PLAYGROUND_DEST_DIR: destDir,
891
- EPICSHOP_PLAYGROUND_SRC_DIR: srcDir,
892
- EPICSHOP_PLAYGROUND_WAS_RUNNING: playgroundWasRunning.toString(),
893
- },
894
- });
895
- }
896
- const basename = path.basename(srcDir);
897
- // If we don't delete the destination node_modules first then copying the new
898
- // node_modules has issues.
899
- await fsExtra.remove(path.join(destDir, 'node_modules'));
900
- // Copy the contents of the source directory to the destination directory recursively
901
- await fsExtra.copy(srcDir, destDir, {
902
- filter: async (srcFile, destFile) => {
903
- if (srcFile.includes(`${basename}${path.sep}build`) ||
904
- srcFile.includes(`${basename}${path.sep}public${path.sep}build`)) {
905
- return false;
906
- }
907
- if (srcFile === srcDir)
908
- return true;
909
- // we copy node_modules even though it's .gitignored
910
- if (srcFile.includes('node_modules'))
946
+ const isIgnored = await isGitIgnored({ cwd: srcDir });
947
+ const playgroundApp = await getAppByName('playground');
948
+ const playgroundWasRunning = playgroundApp
949
+ ? isAppRunning(playgroundApp)
950
+ : false;
951
+ if (playgroundApp && reset) {
952
+ await closeProcess(playgroundApp.name);
953
+ await fsExtra.remove(destDir);
954
+ }
955
+ const setPlaygroundTimestamp = Date.now();
956
+ // run prepare-playground script if it exists
957
+ const preSetPlaygroundPath = await firstToExist(path.join(srcDir, 'epicshop', 'pre-set-playground.js'), path.join(workshopRoot, 'epicshop', 'pre-set-playground.js'));
958
+ if (preSetPlaygroundPath) {
959
+ await execa('node', [preSetPlaygroundPath], {
960
+ cwd: workshopRoot,
961
+ stdio: 'inherit',
962
+ env: {
963
+ EPICSHOP_PLAYGROUND_TIMESTAMP: setPlaygroundTimestamp.toString(),
964
+ EPICSHOP_PLAYGROUND_DEST_DIR: destDir,
965
+ EPICSHOP_PLAYGROUND_SRC_DIR: srcDir,
966
+ EPICSHOP_PLAYGROUND_WAS_RUNNING: playgroundWasRunning.toString(),
967
+ },
968
+ });
969
+ }
970
+ const basename = path.basename(srcDir);
971
+ // If we don't delete the destination node_modules first then copying the new
972
+ // node_modules has issues.
973
+ await fsExtra.remove(path.join(destDir, 'node_modules'));
974
+ // Copy the contents of the source directory to the destination directory recursively
975
+ await fsExtra.copy(srcDir, destDir, {
976
+ filter: async (srcFile, destFile) => {
977
+ if (srcFile.includes(`${basename}${path.sep}build`) ||
978
+ srcFile.includes(`${basename}${path.sep}public${path.sep}build`)) {
979
+ return false;
980
+ }
981
+ if (srcFile === srcDir)
982
+ return true;
983
+ // we copy node_modules even though it's .gitignored
984
+ if (srcFile.includes('node_modules'))
985
+ return true;
986
+ // make sure .env is copied whether it's .gitignored or not
987
+ if (srcFile.endsWith('.env'))
988
+ return true;
989
+ if (isIgnored(srcFile))
990
+ return false;
991
+ try {
992
+ const isDir = (await fsExtra.stat(srcFile)).isDirectory();
993
+ if (isDir)
911
994
  return true;
912
- // make sure .env is copied whether it's .gitignored or not
913
- if (srcFile.endsWith('.env'))
995
+ const destIsDir = (await fsExtra.stat(destFile)).isDirectory();
996
+ // weird, but ok
997
+ if (destIsDir)
914
998
  return true;
915
- if (isIgnored(srcFile))
999
+ // it's better to check if the contents are the same before copying
1000
+ // because it avoids unnecessary writes and reduces the impact on any
1001
+ // file watchers (like the remix dev server). In practice, it's definitely
1002
+ // slower, but it's better because it doesn't cause the dev server to
1003
+ // crash as often.
1004
+ const currentContents = await fsExtra.readFile(destFile);
1005
+ const newContents = await fsExtra.readFile(srcFile);
1006
+ if (currentContents.equals(newContents))
916
1007
  return false;
917
- try {
918
- const isDir = (await fsExtra.stat(srcFile)).isDirectory();
919
- if (isDir)
920
- return true;
921
- const destIsDir = (await fsExtra.stat(destFile)).isDirectory();
922
- // weird, but ok
923
- if (destIsDir)
924
- return true;
925
- // it's better to check if the contents are the same before copying
926
- // because it avoids unnecessary writes and reduces the impact on any
927
- // file watchers (like the remix dev server). In practice, it's definitely
928
- // slower, but it's better because it doesn't cause the dev server to
929
- // crash as often.
930
- const currentContents = await fsExtra.readFile(destFile);
931
- const newContents = await fsExtra.readFile(srcFile);
932
- if (currentContents.equals(newContents))
933
- return false;
934
- return true;
935
- }
936
- catch {
937
- // 🤷‍♂️ should probably copy it in this case
938
- return true;
939
- }
1008
+ return true;
1009
+ }
1010
+ catch {
1011
+ // 🤷‍♂️ should probably copy it in this case
1012
+ return true;
1013
+ }
1014
+ },
1015
+ });
1016
+ async function getFiles(dir) {
1017
+ // make globby friendly to windows
1018
+ const dirPath = dir.replace(/\\/g, '/');
1019
+ const files = await globby([`${dirPath}/**/*`, '!**/build/**/*'], {
1020
+ onlyFiles: false,
1021
+ dot: true,
1022
+ });
1023
+ return files.map((f) => f.replace(dirPath, ''));
1024
+ }
1025
+ // Remove files from destDir that were in destDir before but are not in srcDir
1026
+ const srcFiles = await getFiles(srcDir);
1027
+ const destFiles = await getFiles(destDir);
1028
+ const filesToDelete = destFiles.filter((fileName) => !srcFiles.includes(fileName));
1029
+ for (const fileToDelete of filesToDelete) {
1030
+ await fsExtra.remove(path.join(destDir, fileToDelete));
1031
+ }
1032
+ const appName = getAppName(srcDir);
1033
+ await fsExtra.ensureDir(path.dirname(playgroundAppNameInfoPath));
1034
+ await fsExtra.writeJSON(playgroundAppNameInfoPath, { appName });
1035
+ const playgroundIsStillRunning = playgroundApp
1036
+ ? isAppRunning(playgroundApp)
1037
+ : false;
1038
+ const restartPlayground = playgroundWasRunning && !playgroundIsStillRunning;
1039
+ // run postSet-playground script if it exists
1040
+ const postSetPlaygroundPath = await firstToExist(path.join(srcDir, 'epicshop', 'post-set-playground.js'), path.join(workshopRoot, 'epicshop', 'post-set-playground.js'));
1041
+ if (postSetPlaygroundPath) {
1042
+ await execa('node', [postSetPlaygroundPath], {
1043
+ cwd: workshopRoot,
1044
+ stdio: 'inherit',
1045
+ env: {
1046
+ EPICSHOP_PLAYGROUND_TIMESTAMP: setPlaygroundTimestamp.toString(),
1047
+ EPICSHOP_PLAYGROUND_SRC_DIR: srcDir,
1048
+ EPICSHOP_PLAYGROUND_DEST_DIR: destDir,
1049
+ EPICSHOP_PLAYGROUND_WAS_RUNNING: playgroundWasRunning.toString(),
1050
+ EPICSHOP_PLAYGROUND_IS_STILL_RUNNING: playgroundIsStillRunning.toString(),
1051
+ EPICSHOP_PLAYGROUND_RESTART_PLAYGROUND: restartPlayground.toString(),
940
1052
  },
941
1053
  });
942
- async function getFiles(dir) {
943
- // make globby friendly to windows
944
- const dirPath = dir.replace(/\\/g, '/');
945
- const files = await globby([`${dirPath}/**/*`, '!**/build/**/*'], {
946
- onlyFiles: false,
947
- dot: true,
948
- });
949
- return files.map((f) => f.replace(dirPath, ''));
950
- }
951
- // Remove files from destDir that were in destDir before but are not in srcDir
952
- const srcFiles = await getFiles(srcDir);
953
- const destFiles = await getFiles(destDir);
954
- const filesToDelete = destFiles.filter((fileName) => !srcFiles.includes(fileName));
955
- for (const fileToDelete of filesToDelete) {
956
- await fsExtra.remove(path.join(destDir, fileToDelete));
957
- }
958
- const appName = getAppName(srcDir);
959
- await fsExtra.ensureDir(path.dirname(playgroundAppNameInfoPath));
960
- await fsExtra.writeJSON(playgroundAppNameInfoPath, { appName });
961
- const playgroundIsStillRunning = playgroundApp
962
- ? isAppRunning(playgroundApp)
963
- : false;
964
- const restartPlayground = playgroundWasRunning && !playgroundIsStillRunning;
965
- // run postSet-playground script if it exists
966
- const postSetPlaygroundPath = await firstToExist(path.join(srcDir, 'epicshop', 'post-set-playground.js'), path.join(workshopRoot, 'epicshop', 'post-set-playground.js'));
967
- if (postSetPlaygroundPath) {
968
- await execa('node', [postSetPlaygroundPath], {
969
- cwd: workshopRoot,
970
- stdio: 'inherit',
971
- env: {
972
- EPICSHOP_PLAYGROUND_TIMESTAMP: setPlaygroundTimestamp.toString(),
973
- EPICSHOP_PLAYGROUND_SRC_DIR: srcDir,
974
- EPICSHOP_PLAYGROUND_DEST_DIR: destDir,
975
- EPICSHOP_PLAYGROUND_WAS_RUNNING: playgroundWasRunning.toString(),
976
- EPICSHOP_PLAYGROUND_IS_STILL_RUNNING: playgroundIsStillRunning.toString(),
977
- EPICSHOP_PLAYGROUND_RESTART_PLAYGROUND: restartPlayground.toString(),
978
- },
979
- });
980
- }
981
- // since we are running without the watcher we need to set the modified time
982
- modifiedTimes.set(destDir, Date.now());
983
- if (playgroundApp && restartPlayground) {
984
- await runAppDev(playgroundApp);
985
- await waitOnApp(playgroundApp);
986
- }
987
- });
988
- // let the app know the playground changed
989
- getWatcher()?.emit('all', 'playground', destDir);
1054
+ }
1055
+ // since we are running without the watcher we need to set the modified time
1056
+ modifiedTimes.set(destDir, Date.now());
1057
+ if (playgroundApp && restartPlayground) {
1058
+ await runAppDev(playgroundApp);
1059
+ await waitOnApp(playgroundApp);
1060
+ }
990
1061
  }
991
1062
  /**
992
1063
  * The playground is based on another app. This returns the app the playground
@@ -1007,31 +1078,6 @@ export async function getPlaygroundAppName() {
1007
1078
  return null;
1008
1079
  }
1009
1080
  }
1010
- async function getDirModifiedTime(dir) {
1011
- // we can't use modifiedTimes because it only stores the modified times of
1012
- // things the app started.
1013
- const isIgnored = await isGitIgnored({ cwd: dir });
1014
- const files = await fs.promises.readdir(dir, { withFileTypes: true });
1015
- const modifiedTimes = await Promise.all(files.map(async (file) => {
1016
- if (isIgnored(file.name))
1017
- return 0;
1018
- const filePath = path.join(dir, file.name);
1019
- if (file.isDirectory()) {
1020
- return getDirModifiedTime(filePath);
1021
- }
1022
- else {
1023
- try {
1024
- const { mtimeMs } = await fs.promises.stat(filePath);
1025
- return mtimeMs;
1026
- }
1027
- catch {
1028
- // Handle errors (e.g., file access permissions, file has been moved or deleted)
1029
- return 0;
1030
- }
1031
- }
1032
- }));
1033
- return Math.max(0, ...modifiedTimes); // Ensure there is a default of 0 if all files are ignored
1034
- }
1035
1081
  export function getAppDisplayName(a, allApps) {
1036
1082
  let displayName = `${a.title} (${a.type})`;
1037
1083
  if (isExerciseStepApp(a)) {
@@ -1081,4 +1127,30 @@ export function getRelativePath(filePath) {
1081
1127
  .replace(playgroundPath, `playground${path.sep}`)
1082
1128
  .replace(exercisesPath, '');
1083
1129
  }
1130
+ /**
1131
+ * Given a file path, this will determine the path to the app that file belongs to.
1132
+ */
1133
+ export function getAppPathFromFilePath(filePath) {
1134
+ const [, withinWorkshopRootHalf] = filePath.split(workshopRoot);
1135
+ if (!withinWorkshopRootHalf) {
1136
+ return null;
1137
+ }
1138
+ const [part1, part2, part3] = withinWorkshopRootHalf
1139
+ .split(path.sep)
1140
+ .filter(Boolean);
1141
+ // Check if the file is in the playground
1142
+ if (part1 === 'playground') {
1143
+ return path.join(workshopRoot, 'playground');
1144
+ }
1145
+ // Check if the file is in an example
1146
+ if (part1 === 'examples' && part2) {
1147
+ return path.join(workshopRoot, 'examples', part2);
1148
+ }
1149
+ // Check if the file is in an exercise
1150
+ if (part1 === 'exercises' && part2 && part3) {
1151
+ return path.join(workshopRoot, 'exercises', part2, part3);
1152
+ }
1153
+ // If we couldn't determine the app path, return null
1154
+ return null;
1155
+ }
1084
1156
  //# sourceMappingURL=apps.server.js.map