@epic-web/workshop-utils 5.13.6 → 5.14.0
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/esm/apps.server.d.ts +9 -2
- package/dist/esm/apps.server.d.ts.map +1 -1
- package/dist/esm/apps.server.js +60 -45
- package/dist/esm/apps.server.js.map +1 -1
- package/dist/esm/config.server.d.ts +1 -1
- package/dist/esm/config.server.d.ts.map +1 -1
- package/dist/esm/config.server.js +6 -6
- package/dist/esm/config.server.js.map +1 -1
- package/dist/esm/diff.server.js +5 -5
- package/dist/esm/diff.server.js.map +1 -1
- package/dist/esm/epic-api.server.d.ts +1 -1
- package/dist/esm/epic-api.server.d.ts.map +1 -1
- package/dist/esm/epic-api.server.js +1 -1
- package/dist/esm/epic-api.server.js.map +1 -1
- package/dist/esm/git.server.d.ts.map +1 -1
- package/dist/esm/git.server.js +6 -2
- package/dist/esm/git.server.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,8 @@ import { type Timings } from './timing.server.js';
|
|
|
5
5
|
declare global {
|
|
6
6
|
var __epicshop_apps_initialized__: boolean | undefined;
|
|
7
7
|
}
|
|
8
|
-
export declare
|
|
8
|
+
export declare function setWorkshopRoot(root: string): void;
|
|
9
|
+
export declare function getWorkshopRoot(): string;
|
|
9
10
|
type CachifiedOptions = {
|
|
10
11
|
timings?: Timings;
|
|
11
12
|
request?: Request;
|
|
@@ -695,6 +696,8 @@ declare const PlaygroundAppSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
695
696
|
epicVideoEmbeds?: string[] | undefined;
|
|
696
697
|
}>;
|
|
697
698
|
declare const ExerciseSchema: z.ZodObject<{
|
|
699
|
+
/** the full path to the exercise directory */
|
|
700
|
+
fullPath: z.ZodString;
|
|
698
701
|
/** a unique identifier for the exercise */
|
|
699
702
|
exerciseNumber: z.ZodNumber;
|
|
700
703
|
/** used when displaying the list of files to match the list of apps in the file system (comes the name of the directory of the app) */
|
|
@@ -1851,6 +1854,7 @@ declare const ExerciseSchema: z.ZodObject<{
|
|
|
1851
1854
|
}, "strip", z.ZodTypeAny, {
|
|
1852
1855
|
title: string;
|
|
1853
1856
|
dirName: string;
|
|
1857
|
+
fullPath: string;
|
|
1854
1858
|
exerciseNumber: number;
|
|
1855
1859
|
steps: ({
|
|
1856
1860
|
stepNumber: number;
|
|
@@ -2072,6 +2076,7 @@ declare const ExerciseSchema: z.ZodObject<{
|
|
|
2072
2076
|
}, {
|
|
2073
2077
|
title: string;
|
|
2074
2078
|
dirName: string;
|
|
2079
|
+
fullPath: string;
|
|
2075
2080
|
exerciseNumber: number;
|
|
2076
2081
|
steps: ({
|
|
2077
2082
|
stepNumber: number;
|
|
@@ -3141,7 +3146,7 @@ export declare function isPlaygroundApp(app: any): app is PlaygroundApp;
|
|
|
3141
3146
|
export declare function isExampleApp(app: any): app is ExampleApp;
|
|
3142
3147
|
export declare function isExerciseStepApp(app: any): app is ExerciseStepApp;
|
|
3143
3148
|
export declare const modifiedTimes: Map<string, number>;
|
|
3144
|
-
export declare function init(): Promise<void>;
|
|
3149
|
+
export declare function init(workshopRoot?: string): Promise<void>;
|
|
3145
3150
|
export declare function setModifiedTimesForAppDirs(...filePaths: Array<string>): void;
|
|
3146
3151
|
export declare function getForceFreshForDir(cacheEntry: CacheEntry | null | undefined, ...dirs: Array<string | undefined | null>): true | undefined;
|
|
3147
3152
|
export declare function getExercises({ timings, request, }?: CachifiedOptions): Promise<Array<Exercise>>;
|
|
@@ -3171,6 +3176,7 @@ export declare function getPlaygroundApp({ timings, request, }?: CachifiedOption
|
|
|
3171
3176
|
export declare function getExercise(exerciseNumber: number | string, { request, timings }?: CachifiedOptions): Promise<{
|
|
3172
3177
|
title: string;
|
|
3173
3178
|
dirName: string;
|
|
3179
|
+
fullPath: string;
|
|
3174
3180
|
exerciseNumber: number;
|
|
3175
3181
|
steps: ({
|
|
3176
3182
|
stepNumber: number;
|
|
@@ -3393,6 +3399,7 @@ export declare function getExercise(exerciseNumber: number | string, { request,
|
|
|
3393
3399
|
export declare function requireExercise(exerciseNumber: number | string, { request, timings }?: CachifiedOptions): Promise<{
|
|
3394
3400
|
title: string;
|
|
3395
3401
|
dirName: string;
|
|
3402
|
+
fullPath: string;
|
|
3396
3403
|
exerciseNumber: number;
|
|
3397
3404
|
steps: ({
|
|
3398
3405
|
stepNumber: number;
|
|
@@ -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,qBAAqB,CAAA;AAKrD,OAAO,4BAA4B,CAAA;AAKnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAwBvB,OAAO,EAA6B,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAI5E,OAAO,CAAC,MAAM,CAAC;IACd,IAAI,6BAA6B,EAAE,OAAO,GAAG,SAAS,CAAA;CACtD;AAGD,
|
|
1
|
+
{"version":3,"file":"apps.server.d.ts","sourceRoot":"","sources":["../../src/apps.server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAKrD,OAAO,4BAA4B,CAAA;AAKnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAwBvB,OAAO,EAA6B,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAI5E,OAAO,CAAC,MAAM,CAAC;IACd,IAAI,6BAA6B,EAAE,OAAO,GAAG,SAAS,CAAA;CACtD;AAGD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,QAE3C;AAED,wBAAgB,eAAe,WAK9B;AAYD,KAAK,gBAAgB,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAkChE,QAAA,MAAM,yBAAyB;IA/B9B,sCAAsC;;IAEtC,qFAAqF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O,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;;;;;;;;;;;;GAsB5B;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,UAQ/C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA2BtE"}
|
package/dist/esm/apps.server.js
CHANGED
|
@@ -21,9 +21,18 @@ import { getServerTimeHeader, time } from './timing.server.js';
|
|
|
21
21
|
import { getErrorMessage } from './utils.js';
|
|
22
22
|
import { dayjs } from './utils.server.js';
|
|
23
23
|
global.__epicshop_apps_initialized__ ??= false;
|
|
24
|
-
export
|
|
25
|
-
process.env.EPICSHOP_CONTEXT_CWD
|
|
26
|
-
|
|
24
|
+
export function setWorkshopRoot(root) {
|
|
25
|
+
process.env.EPICSHOP_CONTEXT_CWD = root;
|
|
26
|
+
}
|
|
27
|
+
export function getWorkshopRoot() {
|
|
28
|
+
if (!process.env.EPICSHOP_CONTEXT_CWD) {
|
|
29
|
+
setWorkshopRoot(process.cwd());
|
|
30
|
+
}
|
|
31
|
+
return process.env.EPICSHOP_CONTEXT_CWD;
|
|
32
|
+
}
|
|
33
|
+
function getPlaygroundAppNameInfoPath() {
|
|
34
|
+
return path.join(getWorkshopRoot(), 'node_modules', '.cache', 'epicshop', 'playground.json');
|
|
35
|
+
}
|
|
27
36
|
const BaseAppSchema = z.object({
|
|
28
37
|
/** a unique identifier for the app */
|
|
29
38
|
name: z.string(),
|
|
@@ -76,6 +85,8 @@ const PlaygroundAppSchema = BaseAppSchema.extend({
|
|
|
76
85
|
isUpToDate: z.boolean(),
|
|
77
86
|
});
|
|
78
87
|
const ExerciseSchema = z.object({
|
|
88
|
+
/** the full path to the exercise directory */
|
|
89
|
+
fullPath: z.string(),
|
|
79
90
|
/** a unique identifier for the exercise */
|
|
80
91
|
exerciseNumber: z.number(),
|
|
81
92
|
/** used when displaying the list of files to match the list of apps in the file system (comes the name of the directory of the app) */
|
|
@@ -145,7 +156,10 @@ async function firstToExist(...files) {
|
|
|
145
156
|
return index === -1 ? null : files[index];
|
|
146
157
|
}
|
|
147
158
|
export const modifiedTimes = remember('modified_times', () => new Map());
|
|
148
|
-
export async function init() {
|
|
159
|
+
export async function init(workshopRoot) {
|
|
160
|
+
if (workshopRoot) {
|
|
161
|
+
setWorkshopRoot(workshopRoot);
|
|
162
|
+
}
|
|
149
163
|
if (global.__epicshop_apps_initialized__)
|
|
150
164
|
return;
|
|
151
165
|
global.__epicshop_apps_initialized__ = true;
|
|
@@ -156,11 +170,11 @@ export async function init() {
|
|
|
156
170
|
global.ENV = getEnv();
|
|
157
171
|
if (!ENV.EPICSHOP_DEPLOYED &&
|
|
158
172
|
process.env.EPICSHOP_ENABLE_WATCHER === 'true') {
|
|
159
|
-
const isIgnored = await isGitIgnored({ cwd:
|
|
173
|
+
const isIgnored = await isGitIgnored({ cwd: getWorkshopRoot() });
|
|
160
174
|
// watch the README, FINISHED, and package.json for changes that affect the apps
|
|
161
175
|
const filesToWatch = ['README.mdx', 'FINISHED.mdx', 'package.json'];
|
|
162
176
|
const chok = chokidar.watch(['examples', 'playground', 'exercises'], {
|
|
163
|
-
cwd:
|
|
177
|
+
cwd: getWorkshopRoot(),
|
|
164
178
|
ignoreInitial: true,
|
|
165
179
|
ignored(filePath, stats) {
|
|
166
180
|
if (isIgnored(filePath))
|
|
@@ -190,7 +204,7 @@ export async function init() {
|
|
|
190
204
|
},
|
|
191
205
|
});
|
|
192
206
|
chok.on('all', (_event, filePath) => {
|
|
193
|
-
setModifiedTimesForAppDirs(path.join(
|
|
207
|
+
setModifiedTimesForAppDirs(path.join(getWorkshopRoot(), filePath));
|
|
194
208
|
});
|
|
195
209
|
closeWithGrace(() => chok.close());
|
|
196
210
|
}
|
|
@@ -274,14 +288,14 @@ function extractExerciseNumber(dir) {
|
|
|
274
288
|
}
|
|
275
289
|
export async function getExercises({ timings, request, } = {}) {
|
|
276
290
|
const apps = await getApps({ request, timings });
|
|
277
|
-
const exerciseDirs = await readDir(path.join(
|
|
291
|
+
const exerciseDirs = await readDir(path.join(getWorkshopRoot(), 'exercises'));
|
|
278
292
|
const exercises = [];
|
|
279
293
|
for (const dirName of exerciseDirs) {
|
|
280
294
|
const exerciseNumber = extractExerciseNumber(dirName);
|
|
281
295
|
if (!exerciseNumber)
|
|
282
296
|
continue;
|
|
283
|
-
const compiledReadme = await compileMdxIfExists(path.join(
|
|
284
|
-
const compiledFinished = await compileMdxIfExists(path.join(
|
|
297
|
+
const compiledReadme = await compileMdxIfExists(path.join(getWorkshopRoot(), 'exercises', dirName, 'README.mdx'), { request });
|
|
298
|
+
const compiledFinished = await compileMdxIfExists(path.join(getWorkshopRoot(), 'exercises', dirName, 'FINISHED.mdx'), { request });
|
|
285
299
|
const steps = [];
|
|
286
300
|
const exerciseApps = apps
|
|
287
301
|
.filter(isExerciseStepApp)
|
|
@@ -295,6 +309,7 @@ export async function getExercises({ timings, request, } = {}) {
|
|
|
295
309
|
};
|
|
296
310
|
}
|
|
297
311
|
const exercise = ExerciseSchema.parse({
|
|
312
|
+
fullPath: path.join(getWorkshopRoot(), 'exercises', dirName),
|
|
298
313
|
exerciseNumber,
|
|
299
314
|
dirName,
|
|
300
315
|
instructionsCode: compiledReadme?.code,
|
|
@@ -419,7 +434,7 @@ const AppIdInfoSchema = z.object({
|
|
|
419
434
|
export function extractNumbersAndTypeFromAppNameOrPath(fullPathOrAppName) {
|
|
420
435
|
const info = {};
|
|
421
436
|
if (fullPathOrAppName.includes(path.sep)) {
|
|
422
|
-
const relativePath = fullPathOrAppName.replace(path.join(
|
|
437
|
+
const relativePath = fullPathOrAppName.replace(path.join(getWorkshopRoot(), 'exercises', path.sep), '');
|
|
423
438
|
const [exerciseNumberPart, stepNumberPart] = relativePath.split(path.sep);
|
|
424
439
|
if (!exerciseNumberPart || !stepNumberPart)
|
|
425
440
|
return null;
|
|
@@ -442,7 +457,7 @@ export function extractNumbersAndTypeFromAppNameOrPath(fullPathOrAppName) {
|
|
|
442
457
|
return null;
|
|
443
458
|
}
|
|
444
459
|
async function getProblemDirs() {
|
|
445
|
-
const exercisesDir = path.join(
|
|
460
|
+
const exercisesDir = path.join(getWorkshopRoot(), 'exercises');
|
|
446
461
|
const problemDirs = [];
|
|
447
462
|
const exerciseSubDirs = await readDir(exercisesDir);
|
|
448
463
|
for (const subDir of exerciseSubDirs) {
|
|
@@ -460,7 +475,7 @@ async function getProblemDirs() {
|
|
|
460
475
|
return problemDirs;
|
|
461
476
|
}
|
|
462
477
|
async function getSolutionDirs() {
|
|
463
|
-
const exercisesDir = path.join(
|
|
478
|
+
const exercisesDir = path.join(getWorkshopRoot(), 'exercises');
|
|
464
479
|
const solutionDirs = [];
|
|
465
480
|
const exerciseSubDirs = await readDir(exercisesDir);
|
|
466
481
|
for (const subDir of exerciseSubDirs) {
|
|
@@ -488,7 +503,7 @@ function getAppName(fullPath) {
|
|
|
488
503
|
if (/playground\/?$/.test(fullPath))
|
|
489
504
|
return 'playground';
|
|
490
505
|
if (/examples\/.+\/?$/.test(fullPath)) {
|
|
491
|
-
const restOfPath = fullPath.replace(`${
|
|
506
|
+
const restOfPath = fullPath.replace(`${getWorkshopRoot()}${path.sep}examples${path.sep}`, '');
|
|
492
507
|
return `example.${restOfPath.split(path.sep).join('__sep__')}`;
|
|
493
508
|
}
|
|
494
509
|
const appIdInfo = extractNumbersAndTypeFromAppNameOrPath(fullPath);
|
|
@@ -497,23 +512,23 @@ function getAppName(fullPath) {
|
|
|
497
512
|
return `${exerciseNumber}.${stepNumber}.${type}`;
|
|
498
513
|
}
|
|
499
514
|
else {
|
|
500
|
-
const relativePath = fullPath.replace(`${
|
|
515
|
+
const relativePath = fullPath.replace(`${getWorkshopRoot()}${path.sep}`, '');
|
|
501
516
|
return relativePath.split(path.sep).join('__sep__');
|
|
502
517
|
}
|
|
503
518
|
}
|
|
504
519
|
export async function getFullPathFromAppName(appName) {
|
|
505
520
|
if (appName === 'playground')
|
|
506
|
-
return path.join(
|
|
521
|
+
return path.join(getWorkshopRoot(), 'playground');
|
|
507
522
|
if (appName.startsWith('.example')) {
|
|
508
523
|
const relativePath = appName
|
|
509
524
|
.replace('.example', '')
|
|
510
525
|
.split('__sep__')
|
|
511
526
|
.join(path.sep);
|
|
512
|
-
return path.join(
|
|
527
|
+
return path.join(getWorkshopRoot(), 'examples', relativePath);
|
|
513
528
|
}
|
|
514
529
|
if (appName.includes('__sep__')) {
|
|
515
530
|
const relativePath = appName.replaceAll('__sep__', path.sep);
|
|
516
|
-
return path.join(
|
|
531
|
+
return path.join(getWorkshopRoot(), relativePath);
|
|
517
532
|
}
|
|
518
533
|
const [exerciseNumber, stepNumber, type] = appName.split('.');
|
|
519
534
|
const appDirs = type === 'problem'
|
|
@@ -612,7 +627,7 @@ async function getDevInfo({ fullPath, portNumber, }) {
|
|
|
612
627
|
}
|
|
613
628
|
}
|
|
614
629
|
export async function getPlaygroundApp({ timings, request, } = {}) {
|
|
615
|
-
const playgroundDir = path.join(
|
|
630
|
+
const playgroundDir = path.join(getWorkshopRoot(), 'playground');
|
|
616
631
|
const baseAppName = await getPlaygroundAppName();
|
|
617
632
|
const key = `playground-${baseAppName}`;
|
|
618
633
|
const baseAppFullPath = baseAppName
|
|
@@ -650,7 +665,7 @@ export async function getPlaygroundApp({ timings, request, } = {}) {
|
|
|
650
665
|
type,
|
|
651
666
|
isUpToDate: appModifiedTime <= playgroundAppModifiedTime,
|
|
652
667
|
fullPath: playgroundDir,
|
|
653
|
-
relativePath: playgroundDir.replace(`${
|
|
668
|
+
relativePath: playgroundDir.replace(`${getWorkshopRoot()}${path.sep}`, ''),
|
|
654
669
|
title,
|
|
655
670
|
epicVideoEmbeds: compiledReadme?.epicVideoEmbeds,
|
|
656
671
|
dirName,
|
|
@@ -680,7 +695,7 @@ async function getExampleAppFromPath(fullPath, index, request) {
|
|
|
680
695
|
name,
|
|
681
696
|
type,
|
|
682
697
|
fullPath,
|
|
683
|
-
relativePath: fullPath.replace(`${
|
|
698
|
+
relativePath: fullPath.replace(`${getWorkshopRoot()}${path.sep}`, ''),
|
|
684
699
|
title,
|
|
685
700
|
epicVideoEmbeds: compiledReadme?.epicVideoEmbeds,
|
|
686
701
|
dirName,
|
|
@@ -695,7 +710,7 @@ async function getExampleAppFromPath(fullPath, index, request) {
|
|
|
695
710
|
};
|
|
696
711
|
}
|
|
697
712
|
async function getExampleApps({ timings, request, } = {}) {
|
|
698
|
-
const examplesDir = path.join(
|
|
713
|
+
const examplesDir = path.join(getWorkshopRoot(), 'examples');
|
|
699
714
|
const exampleDirs = (await readDir(examplesDir)).map((p) => path.join(examplesDir, p));
|
|
700
715
|
const exampleApps = [];
|
|
701
716
|
for (const exampleDir of exampleDirs) {
|
|
@@ -753,7 +768,7 @@ async function getSolutionAppFromPath(fullPath, request) {
|
|
|
753
768
|
stepNumber,
|
|
754
769
|
dirName,
|
|
755
770
|
fullPath,
|
|
756
|
-
relativePath: fullPath.replace(`${
|
|
771
|
+
relativePath: fullPath.replace(`${getWorkshopRoot()}${path.sep}`, ''),
|
|
757
772
|
instructionsCode: compiledReadme?.code,
|
|
758
773
|
test,
|
|
759
774
|
dev,
|
|
@@ -765,7 +780,7 @@ async function getSolutionAppFromPath(fullPath, request) {
|
|
|
765
780
|
};
|
|
766
781
|
}
|
|
767
782
|
async function getSolutionApps({ timings, request, } = {}) {
|
|
768
|
-
const exercisesDir = path.join(
|
|
783
|
+
const exercisesDir = path.join(getWorkshopRoot(), 'exercises');
|
|
769
784
|
const solutionDirs = await getSolutionDirs();
|
|
770
785
|
const solutionApps = [];
|
|
771
786
|
for (const solutionDir of solutionDirs) {
|
|
@@ -821,7 +836,7 @@ async function getProblemAppFromPath(fullPath, request) {
|
|
|
821
836
|
stepNumber,
|
|
822
837
|
dirName,
|
|
823
838
|
fullPath,
|
|
824
|
-
relativePath: fullPath.replace(`${
|
|
839
|
+
relativePath: fullPath.replace(`${getWorkshopRoot()}${path.sep}`, ''),
|
|
825
840
|
instructionsCode: compiledReadme?.code,
|
|
826
841
|
test,
|
|
827
842
|
dev,
|
|
@@ -833,7 +848,7 @@ async function getProblemAppFromPath(fullPath, request) {
|
|
|
833
848
|
};
|
|
834
849
|
}
|
|
835
850
|
async function getProblemApps({ timings, request, } = {}) {
|
|
836
|
-
const exercisesDir = path.join(
|
|
851
|
+
const exercisesDir = path.join(getWorkshopRoot(), 'exercises');
|
|
837
852
|
const problemDirs = await getProblemDirs();
|
|
838
853
|
const problemApps = [];
|
|
839
854
|
for (const problemDir of problemDirs) {
|
|
@@ -950,8 +965,8 @@ export async function savePlayground() {
|
|
|
950
965
|
const playgroundApp = await getAppByName('playground');
|
|
951
966
|
invariant(playgroundApp, 'app with name "playground" does not exist');
|
|
952
967
|
invariant(isPlaygroundApp(playgroundApp), 'app with name "playground" exists, but it is not a playground type app');
|
|
953
|
-
const playgroundDir = path.join(
|
|
954
|
-
const savedPlaygroundsDir = path.join(
|
|
968
|
+
const playgroundDir = path.join(getWorkshopRoot(), 'playground');
|
|
969
|
+
const savedPlaygroundsDir = path.join(getWorkshopRoot(), 'saved-playgrounds');
|
|
955
970
|
await fsExtra.ensureDir(savedPlaygroundsDir);
|
|
956
971
|
const now = dayjs();
|
|
957
972
|
// note: the format must be filename safe
|
|
@@ -973,7 +988,7 @@ locally and uncheck "Enable saving playground."
|
|
|
973
988
|
export async function setPlayground(srcDir, { reset } = {}) {
|
|
974
989
|
const preferences = await getPreferences();
|
|
975
990
|
const playgroundApp = await getAppByName('playground');
|
|
976
|
-
const playgroundDir = path.join(
|
|
991
|
+
const playgroundDir = path.join(getWorkshopRoot(), 'playground');
|
|
977
992
|
if (playgroundApp && preferences?.playground?.persist) {
|
|
978
993
|
await savePlayground();
|
|
979
994
|
}
|
|
@@ -987,10 +1002,10 @@ export async function setPlayground(srcDir, { reset } = {}) {
|
|
|
987
1002
|
}
|
|
988
1003
|
const setPlaygroundTimestamp = Date.now();
|
|
989
1004
|
// run prepare-playground script if it exists
|
|
990
|
-
const preSetPlaygroundPath = await firstToExist(path.join(srcDir, 'epicshop', 'pre-set-playground.js'), path.join(
|
|
1005
|
+
const preSetPlaygroundPath = await firstToExist(path.join(srcDir, 'epicshop', 'pre-set-playground.js'), path.join(getWorkshopRoot(), 'epicshop', 'pre-set-playground.js'));
|
|
991
1006
|
if (preSetPlaygroundPath) {
|
|
992
1007
|
await execa('node', [preSetPlaygroundPath], {
|
|
993
|
-
cwd:
|
|
1008
|
+
cwd: getWorkshopRoot(),
|
|
994
1009
|
stdio: 'inherit',
|
|
995
1010
|
env: {
|
|
996
1011
|
EPICSHOP_PLAYGROUND_TIMESTAMP: setPlaygroundTimestamp.toString(),
|
|
@@ -1063,17 +1078,17 @@ export async function setPlayground(srcDir, { reset } = {}) {
|
|
|
1063
1078
|
await fsExtra.remove(path.join(playgroundDir, fileToDelete));
|
|
1064
1079
|
}
|
|
1065
1080
|
const appName = getAppName(srcDir);
|
|
1066
|
-
await fsExtra.ensureDir(path.dirname(
|
|
1067
|
-
await fsExtra.writeJSON(
|
|
1081
|
+
await fsExtra.ensureDir(path.dirname(getPlaygroundAppNameInfoPath()));
|
|
1082
|
+
await fsExtra.writeJSON(getPlaygroundAppNameInfoPath(), { appName });
|
|
1068
1083
|
const playgroundIsStillRunning = playgroundApp
|
|
1069
1084
|
? isAppRunning(playgroundApp)
|
|
1070
1085
|
: false;
|
|
1071
1086
|
const restartPlayground = playgroundWasRunning && !playgroundIsStillRunning;
|
|
1072
1087
|
// run postSet-playground script if it exists
|
|
1073
|
-
const postSetPlaygroundPath = await firstToExist(path.join(srcDir, 'epicshop', 'post-set-playground.js'), path.join(
|
|
1088
|
+
const postSetPlaygroundPath = await firstToExist(path.join(srcDir, 'epicshop', 'post-set-playground.js'), path.join(getWorkshopRoot(), 'epicshop', 'post-set-playground.js'));
|
|
1074
1089
|
if (postSetPlaygroundPath) {
|
|
1075
1090
|
await execa('node', [postSetPlaygroundPath], {
|
|
1076
|
-
cwd:
|
|
1091
|
+
cwd: getWorkshopRoot(),
|
|
1077
1092
|
stdio: 'inherit',
|
|
1078
1093
|
env: {
|
|
1079
1094
|
EPICSHOP_PLAYGROUND_TIMESTAMP: setPlaygroundTimestamp.toString(),
|
|
@@ -1097,11 +1112,11 @@ export async function setPlayground(srcDir, { reset } = {}) {
|
|
|
1097
1112
|
* is based on.
|
|
1098
1113
|
*/
|
|
1099
1114
|
export async function getPlaygroundAppName() {
|
|
1100
|
-
if (!(await exists(
|
|
1115
|
+
if (!(await exists(getPlaygroundAppNameInfoPath()))) {
|
|
1101
1116
|
return null;
|
|
1102
1117
|
}
|
|
1103
1118
|
try {
|
|
1104
|
-
const jsonString = await fs.promises.readFile(
|
|
1119
|
+
const jsonString = await fs.promises.readFile(getPlaygroundAppNameInfoPath(), 'utf8');
|
|
1105
1120
|
const { appName } = JSON.parse(jsonString);
|
|
1106
1121
|
if (typeof appName !== 'string')
|
|
1107
1122
|
return null;
|
|
@@ -1133,7 +1148,7 @@ export function getAppDisplayName(a, allApps) {
|
|
|
1133
1148
|
return displayName;
|
|
1134
1149
|
}
|
|
1135
1150
|
export async function getWorkshopInstructions({ request, } = {}) {
|
|
1136
|
-
const readmeFilepath = path.join(
|
|
1151
|
+
const readmeFilepath = path.join(getWorkshopRoot(), 'exercises', 'README.mdx');
|
|
1137
1152
|
const compiled = await compileMdx(readmeFilepath, { request }).then((r) => ({ ...r, status: 'success' }), (e) => {
|
|
1138
1153
|
console.error(`There was an error compiling the workshop readme`, readmeFilepath, e);
|
|
1139
1154
|
return { status: 'error', error: getErrorMessage(e) };
|
|
@@ -1141,7 +1156,7 @@ export async function getWorkshopInstructions({ request, } = {}) {
|
|
|
1141
1156
|
return { compiled, file: readmeFilepath, relativePath: 'exercises' };
|
|
1142
1157
|
}
|
|
1143
1158
|
export async function getWorkshopFinished({ request, } = {}) {
|
|
1144
|
-
const finishedFilepath = path.join(
|
|
1159
|
+
const finishedFilepath = path.join(getWorkshopRoot(), 'exercises', 'FINISHED.mdx');
|
|
1145
1160
|
const compiled = await compileMdx(finishedFilepath, { request }).then((r) => ({ ...r, status: 'success' }), (e) => {
|
|
1146
1161
|
console.error(`There was an error compiling the workshop finished.mdx`, finishedFilepath, e);
|
|
1147
1162
|
return { status: 'error', error: getErrorMessage(e) };
|
|
@@ -1152,9 +1167,9 @@ export async function getWorkshopFinished({ request, } = {}) {
|
|
|
1152
1167
|
relativePath: 'exercises/finished.mdx',
|
|
1153
1168
|
};
|
|
1154
1169
|
}
|
|
1155
|
-
const exercisesPath = path.join(workshopRoot, 'exercises/');
|
|
1156
|
-
const playgroundPath = path.join(workshopRoot, 'playground/');
|
|
1157
1170
|
export function getRelativePath(filePath) {
|
|
1171
|
+
const exercisesPath = path.join(getWorkshopRoot(), 'exercises/');
|
|
1172
|
+
const playgroundPath = path.join(getWorkshopRoot(), 'playground/');
|
|
1158
1173
|
return path
|
|
1159
1174
|
.normalize(filePath.replace(/^("|')|("|')$/g, ''))
|
|
1160
1175
|
.replace(playgroundPath, `playground${path.sep}`)
|
|
@@ -1164,7 +1179,7 @@ export function getRelativePath(filePath) {
|
|
|
1164
1179
|
* Given a file path, this will determine the path to the app that file belongs to.
|
|
1165
1180
|
*/
|
|
1166
1181
|
export function getAppPathFromFilePath(filePath) {
|
|
1167
|
-
const [, withinWorkshopRootHalf] = filePath.split(
|
|
1182
|
+
const [, withinWorkshopRootHalf] = filePath.split(getWorkshopRoot());
|
|
1168
1183
|
if (!withinWorkshopRootHalf) {
|
|
1169
1184
|
return null;
|
|
1170
1185
|
}
|
|
@@ -1173,15 +1188,15 @@ export function getAppPathFromFilePath(filePath) {
|
|
|
1173
1188
|
.filter(Boolean);
|
|
1174
1189
|
// Check if the file is in the playground
|
|
1175
1190
|
if (part1 === 'playground') {
|
|
1176
|
-
return path.join(
|
|
1191
|
+
return path.join(getWorkshopRoot(), 'playground');
|
|
1177
1192
|
}
|
|
1178
1193
|
// Check if the file is in an example
|
|
1179
1194
|
if (part1 === 'examples' && part2) {
|
|
1180
|
-
return path.join(
|
|
1195
|
+
return path.join(getWorkshopRoot(), 'examples', part2);
|
|
1181
1196
|
}
|
|
1182
1197
|
// Check if the file is in an exercise
|
|
1183
1198
|
if (part1 === 'exercises' && part2 && part3) {
|
|
1184
|
-
return path.join(
|
|
1199
|
+
return path.join(getWorkshopRoot(), 'exercises', part2, part3);
|
|
1185
1200
|
}
|
|
1186
1201
|
// If we couldn't determine the app path, return null
|
|
1187
1202
|
return null;
|