@beff/aula-cli 0.11.0 → 0.13.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/README.md +6 -1
- package/dist/src/{aula-voice-tts-HPJAJO2Q.js → aula-voice-tts-H2OQFQ5J.js} +1 -1
- package/dist/src/aula.js +2 -2
- package/dist/src/{chunk-KCGXC2RV.js → chunk-4FWDTPLR.js} +1 -1
- package/dist/src/{chunk-XCPBFMEA.js → chunk-D5N3QDDF.js} +1 -1
- package/dist/src/{chunk-Y56UHOZ2.js → chunk-F5RPEFZR.js} +2 -0
- package/dist/src/{chunk-5ABPFV55.js → chunk-G44UMBPW.js} +2 -2
- package/dist/src/{chunk-5TUGYMFH.js → chunk-S6IM5XXK.js} +3 -3
- package/dist/src/{chunk-5XVICDLW.js → chunk-THZNJBUF.js} +133 -18
- package/dist/src/{chunk-4PZYWKO5.js → chunk-UBVMGS2E.js} +1 -1
- package/dist/src/{chunk-3RB5T3CC.js → chunk-UQOXT6QN.js} +109 -87
- package/dist/src/{chunk-DFXG2P7A.js → chunk-WV2UYZND.js} +12 -7
- package/dist/src/chunk-XIVHJMET.js +111 -0
- package/dist/src/cli.js +29 -93
- package/dist/src/{commands-BUM4AG3N.js → commands-PLST75CP.js} +11 -10
- package/dist/src/problems-EI4DOEZ4.js +17 -0
- package/dist/src/project-7EROVEUE.js +16 -0
- package/dist/src/run-NE5HOAXA.js +235 -0
- package/dist/src/{server-ALRN2C2W.js → server-KXIU66BB.js} +35 -23
- package/dist/src/{site-A2I4P4GX.js → site-HUWODSZ3.js} +21 -77
- package/dist/src/workspace-load-DOHFEZFR.js +16 -0
- package/dist/web/app/assets/{56cf58c4 → 62289de9}/aula-method.js +1 -1
- package/dist/web/app/assets/{56cf58c4 → 62289de9}/aula.js +1 -1
- package/dist/web/app/assets/62289de9/build-worker.js +2 -0
- package/dist/web/app/assets/{56cf58c4 → 62289de9}/index.js +2 -2
- package/dist/web/app/assets/{protocol-C3Pseh4g.js → protocol-kcdbhuRm.js} +4 -4
- package/dist/web/app/assets/{src-DTLT9Lbm.js → src-DWqZcp-P.js} +1 -1
- package/dist/web/app/assets/{tex-mathjax-8QilZX4j.js → tex-mathjax-eWNptbJg.js} +1 -1
- package/dist/web/app/index.html +3 -3
- package/dist/web/site/assets/{82624cbe → 82618540}/aula-method.js +1 -1
- package/dist/web/site/assets/{82624cbe → 82618540}/aula.js +1 -1
- package/dist/web/site/assets/82618540/build-worker.js +2 -0
- package/dist/web/site/assets/{82624cbe → 82618540}/index.js +2 -2
- package/dist/web/site/assets/{protocol-BOv1ch3F.js → protocol-XMWr-E-D.js} +4 -4
- package/dist/web/site/assets/{src-DpS3WA7l.js → src-DfPcHwz-.js} +1 -1
- package/dist/web/site/assets/{tex-mathjax-CVHS5J80.js → tex-mathjax-DrZV_cwB.js} +1 -1
- package/dist/web/site/index.html +3 -3
- package/package.json +1 -1
- package/dist/src/chunk-JWBPHDVP.js +0 -104
- package/dist/src/problems-2IXR6RUV.js +0 -18
- package/dist/src/project-36YBXKCD.js +0 -16
- package/dist/src/run-YLF62D3C.js +0 -173
- package/dist/web/app/assets/56cf58c4/build-worker.js +0 -2
- package/dist/web/site/assets/82624cbe/build-worker.js +0 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createNodeBundler
|
|
2
|
+
createNodeBundler,
|
|
3
|
+
nodeTree
|
|
3
4
|
} from "./chunk-THQ5Y74K.js";
|
|
4
5
|
import {
|
|
5
6
|
VIDEO,
|
|
@@ -9,14 +10,16 @@ import {
|
|
|
9
10
|
} from "./chunk-F4XRXW6M.js";
|
|
10
11
|
import {
|
|
11
12
|
printDiagnostics
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-S6IM5XXK.js";
|
|
13
14
|
import {
|
|
14
15
|
chapterIndexes,
|
|
15
16
|
checkProject,
|
|
16
17
|
clipPlan,
|
|
17
18
|
clock,
|
|
19
|
+
draftSkipMessage,
|
|
18
20
|
exportCheck,
|
|
19
21
|
movesMarkdown,
|
|
22
|
+
narrateScript,
|
|
20
23
|
narrationAt,
|
|
21
24
|
noteLine,
|
|
22
25
|
notesLine,
|
|
@@ -25,28 +28,27 @@ import {
|
|
|
25
28
|
pictureStills,
|
|
26
29
|
previewJobs,
|
|
27
30
|
previewTargets,
|
|
31
|
+
scriptAudio,
|
|
28
32
|
scriptView,
|
|
29
33
|
targetChapters,
|
|
30
34
|
timedChapter,
|
|
31
35
|
timelineView,
|
|
36
|
+
wav,
|
|
32
37
|
wordNotes
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import {
|
|
35
|
-
narrateScript,
|
|
36
|
-
scriptAudio,
|
|
37
|
-
wav
|
|
38
|
-
} from "./chunk-JWBPHDVP.js";
|
|
38
|
+
} from "./chunk-THZNJBUF.js";
|
|
39
39
|
import {
|
|
40
40
|
narrationScript
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-4FWDTPLR.js";
|
|
42
42
|
import {
|
|
43
|
-
host
|
|
44
|
-
|
|
43
|
+
host,
|
|
44
|
+
loadProject
|
|
45
|
+
} from "./chunk-UBVMGS2E.js";
|
|
45
46
|
import {
|
|
46
47
|
folderOf,
|
|
47
48
|
nameOf
|
|
48
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-G44UMBPW.js";
|
|
49
50
|
import {
|
|
51
|
+
NO_PROJECT_MESSAGE,
|
|
50
52
|
ObjectRuntype,
|
|
51
53
|
OptionalFieldRuntype,
|
|
52
54
|
PROVIDED,
|
|
@@ -57,15 +59,16 @@ import {
|
|
|
57
59
|
buildParsers,
|
|
58
60
|
bundle,
|
|
59
61
|
isError,
|
|
62
|
+
projectModules,
|
|
60
63
|
wrongArgument
|
|
61
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-WV2UYZND.js";
|
|
62
65
|
import {
|
|
63
66
|
manim_exports
|
|
64
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-D5N3QDDF.js";
|
|
65
68
|
import {
|
|
66
69
|
chapterNames,
|
|
67
70
|
renderChapter
|
|
68
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-F5RPEFZR.js";
|
|
69
72
|
|
|
70
73
|
// src/commands.ts
|
|
71
74
|
import path2 from "node:path";
|
|
@@ -912,14 +915,6 @@ async function projectFiles(capabilities, bundler, root, folder) {
|
|
|
912
915
|
}
|
|
913
916
|
|
|
914
917
|
// src/commands.ts
|
|
915
|
-
async function withHeavy(capabilities, f) {
|
|
916
|
-
const release = await capabilities.locks.heavy();
|
|
917
|
-
try {
|
|
918
|
-
return await f();
|
|
919
|
-
} finally {
|
|
920
|
-
await release();
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
918
|
async function withWork(capabilities, f) {
|
|
924
919
|
const work = await capabilities.fs.mkdtemp(path2.join(capabilities.env.temp, "aula-"));
|
|
925
920
|
try {
|
|
@@ -984,20 +979,18 @@ async function timeChapters(capabilities, root, project, texts, only) {
|
|
|
984
979
|
const names = chapterNames(project);
|
|
985
980
|
const indexes = (only ?? names.map((_, i2) => i2)).filter((i2) => i2 > 0);
|
|
986
981
|
if (indexes.length === 0) return [];
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
return warnings;
|
|
1000
|
-
});
|
|
982
|
+
const n = await clock(capabilities.narrator, narrationScript(project, texts), only, names);
|
|
983
|
+
const h = host(capabilities, root);
|
|
984
|
+
const warnings = [];
|
|
985
|
+
for (const index of indexes) {
|
|
986
|
+
const drawn = renderChapter(project, index, {
|
|
987
|
+
host: h,
|
|
988
|
+
narration: narrationAt(n, index),
|
|
989
|
+
lint: true
|
|
990
|
+
});
|
|
991
|
+
warnings.push(...drawn.diagnostics.filter((d) => !isError(d)));
|
|
992
|
+
}
|
|
993
|
+
return warnings;
|
|
1001
994
|
}
|
|
1002
995
|
async function check(capabilities, root, project, only, json = false) {
|
|
1003
996
|
const chapters = chapterIndexes(project, only);
|
|
@@ -1018,6 +1011,44 @@ async function check(capabilities, root, project, only, json = false) {
|
|
|
1018
1011
|
printCounts(capabilities, project, { ...checked, findings, warnings });
|
|
1019
1012
|
return checked.errors === 0;
|
|
1020
1013
|
}
|
|
1014
|
+
async function checkRoot(capabilities, cwd, folder, only, json = false, includeDrafts = false) {
|
|
1015
|
+
const tree = nodeTree(capabilities, folder);
|
|
1016
|
+
const listed = await projectModules(tree, path2.basename(folder));
|
|
1017
|
+
if (listed._tag === "Left") throw new Problems(listed.left);
|
|
1018
|
+
if (listed.right.length === 0) throw new Error(NO_PROJECT_MESSAGE);
|
|
1019
|
+
const loaded = [];
|
|
1020
|
+
for (const mod of listed.right) {
|
|
1021
|
+
const projectFolder = mod.module === "index.ts" ? folder : path2.join(folder, path2.dirname(mod.module));
|
|
1022
|
+
const label = mod.module === "index.ts" ? path2.basename(folder) : path2.dirname(mod.module);
|
|
1023
|
+
const project = await loadProject(capabilities, cwd, projectFolder, listed.right.length === 1 ? only : []);
|
|
1024
|
+
loaded.push({ label, projectFolder, project });
|
|
1025
|
+
}
|
|
1026
|
+
const projects = [];
|
|
1027
|
+
for (const entry of loaded) {
|
|
1028
|
+
if (entry.project.draft && !includeDrafts) {
|
|
1029
|
+
capabilities.log.out(draftSkipMessage(entry.label));
|
|
1030
|
+
} else {
|
|
1031
|
+
projects.push(entry);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
if (projects.length === 0) return true;
|
|
1035
|
+
if (projects.length !== 1 && only.length > 0) {
|
|
1036
|
+
throw wrongArgument(
|
|
1037
|
+
"aula check takes chapters only when the folder gives one project",
|
|
1038
|
+
"pass a project folder, or omit the chapters to check every listed project"
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
if (listed.right.length !== 1 && projects.length === 1 && only.length > 0) {
|
|
1042
|
+
const entry = projects[0];
|
|
1043
|
+
if (entry === void 0) throw new Error("checkRoot: missing project after draft filter");
|
|
1044
|
+
entry.project = await loadProject(capabilities, cwd, entry.projectFolder, only);
|
|
1045
|
+
}
|
|
1046
|
+
let ok = true;
|
|
1047
|
+
for (const entry of projects) {
|
|
1048
|
+
ok = await check(capabilities, cwd, entry.project, only, json) && ok;
|
|
1049
|
+
}
|
|
1050
|
+
return ok;
|
|
1051
|
+
}
|
|
1021
1052
|
async function script(capabilities, root, project, only) {
|
|
1022
1053
|
capabilities.log.write(await scriptView(project, host(capabilities, root), capabilities.narrator, only));
|
|
1023
1054
|
return true;
|
|
@@ -1041,26 +1072,24 @@ async function preview(capabilities, root, project, folder, given) {
|
|
|
1041
1072
|
return withWork(capabilities, async (work) => {
|
|
1042
1073
|
const stopped = [];
|
|
1043
1074
|
const waits = [];
|
|
1044
|
-
await
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
job.written.push(path2.join(out, "moves.md"), ...sheets);
|
|
1063
|
-
});
|
|
1075
|
+
const n = await clock(capabilities.narrator, narrationScript(project, all), only, chapterNames(project));
|
|
1076
|
+
for (const job of jobs) await capabilities.fs.rm(job.out, { recursive: true, force: true });
|
|
1077
|
+
await parallel(jobs, capabilities.env.parallelism, async (job) => {
|
|
1078
|
+
const lottie = path2.join(work, `${job.base}.json`);
|
|
1079
|
+
const drawn = await drawChapter(capabilities, root, project, job.index, narrationAt(n, job.index), lottie);
|
|
1080
|
+
if (!drawn.ok) {
|
|
1081
|
+
stopped.push(...drawn.findings);
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
waits.push(...drawn.findings.filter((d) => !isError(d)));
|
|
1085
|
+
const { out } = job;
|
|
1086
|
+
const { window, stills } = pictureStills(drawn.narration, job, drawn.frames, drawn.embeds);
|
|
1087
|
+
const groups = inFolder(folderOf(project), pictureGroups(window, stills));
|
|
1088
|
+
const sheets = await capabilities.render.pictures({ lottie, out, groups });
|
|
1089
|
+
await capabilities.fs.mkdir(out, { recursive: true });
|
|
1090
|
+
const moves = job.text === null ? "title card\n" : movesMarkdown(timedChapter(job.index, job.name, job.text, drawn.narration));
|
|
1091
|
+
await capabilities.fs.writeFile(path2.join(out, "moves.md"), moves);
|
|
1092
|
+
job.written.push(path2.join(out, "moves.md"), ...sheets);
|
|
1064
1093
|
});
|
|
1065
1094
|
if (stopped.length) {
|
|
1066
1095
|
await printDiagnostics(capabilities, root, stopped);
|
|
@@ -1072,7 +1101,6 @@ async function preview(capabilities, root, project, folder, given) {
|
|
|
1072
1101
|
});
|
|
1073
1102
|
}
|
|
1074
1103
|
async function exportVideo(capabilities, root, project, file) {
|
|
1075
|
-
if (!file.endsWith(".mp4")) throw wrongArgument(`the video path must end in .mp4: ${file}`);
|
|
1076
1104
|
const names = chapterNames(project);
|
|
1077
1105
|
const checked = exportCheck(project, host(capabilities, root));
|
|
1078
1106
|
await printChecked(capabilities, root, project, checked);
|
|
@@ -1084,28 +1112,25 @@ async function exportVideo(capabilities, root, project, file) {
|
|
|
1084
1112
|
return withWork(capabilities, async (work) => {
|
|
1085
1113
|
const audio = path2.join(work, "narration.wav");
|
|
1086
1114
|
const cues = narrationScript(project, checked.texts);
|
|
1087
|
-
const narrated = await
|
|
1115
|
+
const narrated = await narrate(capabilities, cues);
|
|
1088
1116
|
const lotties = names.map((name) => path2.join(work, `${name}.json`));
|
|
1089
1117
|
const drawn = [];
|
|
1090
1118
|
const problems = [];
|
|
1091
1119
|
let done = 0;
|
|
1092
|
-
await
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
done
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
);
|
|
1107
|
-
}
|
|
1108
|
-
)
|
|
1120
|
+
await parallel(
|
|
1121
|
+
names.map((_, index) => index),
|
|
1122
|
+
capabilities.env.parallelism,
|
|
1123
|
+
async (index) => {
|
|
1124
|
+
const narration = narrated[index]?.narration;
|
|
1125
|
+
if (narration === void 0) throw new Error(`no narration of chapter ${String(index)}`);
|
|
1126
|
+
const chapter = await drawChapter(capabilities, root, project, index, narration, lotties[index] ?? "");
|
|
1127
|
+
drawn[index] = chapter;
|
|
1128
|
+
if (!chapter.ok) problems.push(...chapter.findings);
|
|
1129
|
+
done += 1;
|
|
1130
|
+
capabilities.log.out(
|
|
1131
|
+
`[${String(done)}/${String(names.length)}] ${names[index] ?? ""}: ${chapter.ok ? "drawn" : "FAILED"}`
|
|
1132
|
+
);
|
|
1133
|
+
}
|
|
1109
1134
|
);
|
|
1110
1135
|
if (problems.length) {
|
|
1111
1136
|
await printDiagnostics(capabilities, root, problems);
|
|
@@ -1122,16 +1147,13 @@ async function exportVideo(capabilities, root, project, file) {
|
|
|
1122
1147
|
VIDEO.fps
|
|
1123
1148
|
);
|
|
1124
1149
|
const clips = names.map((name) => path2.join(work, `${name}.mp4`));
|
|
1125
|
-
await
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
await capabilities.render.clip({ lottie: lotties[index] ?? "", out: clips[index] ?? "", ...clip });
|
|
1133
|
-
}
|
|
1134
|
-
)
|
|
1150
|
+
await parallel(
|
|
1151
|
+
names.map((_, index) => index),
|
|
1152
|
+
capabilities.env.parallelism,
|
|
1153
|
+
async (index) => {
|
|
1154
|
+
const clip = plan.clips[index] ?? { from: 0, frames: 0 };
|
|
1155
|
+
await capabilities.render.clip({ lottie: lotties[index] ?? "", out: clips[index] ?? "", ...clip });
|
|
1156
|
+
}
|
|
1135
1157
|
);
|
|
1136
1158
|
await capabilities.fs.mkdir(path2.dirname(file), { recursive: true });
|
|
1137
1159
|
const placed = await placedClips(
|
|
@@ -1149,7 +1171,6 @@ async function exportVideo(capabilities, root, project, file) {
|
|
|
1149
1171
|
});
|
|
1150
1172
|
}
|
|
1151
1173
|
async function bundle2(capabilities, project, file) {
|
|
1152
|
-
if (!file.endsWith(".zip")) throw new Error(`the zip path must end in .zip: ${file}`);
|
|
1153
1174
|
const home = folderOf(project);
|
|
1154
1175
|
const root = path2.parse(home).root;
|
|
1155
1176
|
const folder = path2.relative(root, home).split(path2.sep).join("/");
|
|
@@ -1187,6 +1208,7 @@ function tokensArgs(positional) {
|
|
|
1187
1208
|
|
|
1188
1209
|
export {
|
|
1189
1210
|
check,
|
|
1211
|
+
checkRoot,
|
|
1190
1212
|
script,
|
|
1191
1213
|
timeline,
|
|
1192
1214
|
preview,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
diagnosticOf
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-F5RPEFZR.js";
|
|
4
4
|
|
|
5
5
|
// ../../node_modules/.pnpm/@beff+client@1.0.1/node_modules/@beff/client/dist/esm/openapi-pp.js
|
|
6
6
|
var removeNullUnionBranch = (definition) => {
|
|
@@ -1251,12 +1251,10 @@ async function projectModules(tree, root) {
|
|
|
1251
1251
|
});
|
|
1252
1252
|
return errors.length > 0 ? { _tag: "Left", left: errors } : { _tag: "Right", right: found };
|
|
1253
1253
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
if (listed._tag === "Left") return listed;
|
|
1257
|
-
const projects = listed.right;
|
|
1254
|
+
var NO_PROJECT_MESSAGE = "no project here: pass a project or playlist folder (for example: aula web . or aula web examples)";
|
|
1255
|
+
async function bundleProjects(bundler, tree, root, projects) {
|
|
1258
1256
|
if (projects.length === 0) {
|
|
1259
|
-
throw new Error(
|
|
1257
|
+
throw new Error(NO_PROJECT_MESSAGE);
|
|
1260
1258
|
}
|
|
1261
1259
|
const list = [
|
|
1262
1260
|
...projects.map((project, i) => `import p${String(i)} from ${JSON.stringify(`./${project.module}`)};`),
|
|
@@ -1271,11 +1269,16 @@ async function bundleWorkspace(bundler, tree, root) {
|
|
|
1271
1269
|
return {
|
|
1272
1270
|
_tag: "Right",
|
|
1273
1271
|
right: {
|
|
1274
|
-
bundle: { name: root, projects, code: bundled.right.code, map: bundled.right.map },
|
|
1272
|
+
bundle: { name: root, projects: [...projects], code: bundled.right.code, map: bundled.right.map },
|
|
1275
1273
|
inputs: bundled.right.inputs
|
|
1276
1274
|
}
|
|
1277
1275
|
};
|
|
1278
1276
|
}
|
|
1277
|
+
async function bundleWorkspace(bundler, tree, root) {
|
|
1278
|
+
const listed = await projectModules(tree, root);
|
|
1279
|
+
if (listed._tag === "Left") return listed;
|
|
1280
|
+
return bundleProjects(bundler, tree, root, listed.right);
|
|
1281
|
+
}
|
|
1279
1282
|
|
|
1280
1283
|
// ../aula-project/src/diagnostics.ts
|
|
1281
1284
|
function error(message, more = {}) {
|
|
@@ -1310,6 +1313,8 @@ export {
|
|
|
1310
1313
|
bundle,
|
|
1311
1314
|
projectName,
|
|
1312
1315
|
projectModules,
|
|
1316
|
+
NO_PROJECT_MESSAGE,
|
|
1317
|
+
bundleProjects,
|
|
1313
1318
|
bundleWorkspace,
|
|
1314
1319
|
error,
|
|
1315
1320
|
isError,
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createNodeBundler,
|
|
3
|
+
nodeTree
|
|
4
|
+
} from "./chunk-THQ5Y74K.js";
|
|
5
|
+
import {
|
|
6
|
+
draftSkipMessage,
|
|
7
|
+
listedProjects,
|
|
8
|
+
loadBuiltProjects,
|
|
9
|
+
workspaceHost
|
|
10
|
+
} from "./chunk-THZNJBUF.js";
|
|
11
|
+
import {
|
|
12
|
+
NO_PROJECT_MESSAGE,
|
|
13
|
+
Problems,
|
|
14
|
+
bundleProjects,
|
|
15
|
+
bundleWorkspace,
|
|
16
|
+
wrongArgument
|
|
17
|
+
} from "./chunk-WV2UYZND.js";
|
|
18
|
+
import {
|
|
19
|
+
v8Frames
|
|
20
|
+
} from "./chunk-F5RPEFZR.js";
|
|
21
|
+
|
|
22
|
+
// src/workspace-load.ts
|
|
23
|
+
import { existsSync } from "node:fs";
|
|
24
|
+
import os from "node:os";
|
|
25
|
+
import path from "node:path";
|
|
26
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
27
|
+
var METHOD_STUB = "export const paragraph = () => () => ({});\n";
|
|
28
|
+
async function loadWorkspaceProjects(capabilities, workspaceBundle) {
|
|
29
|
+
const scratch = await capabilities.fs.mkdtemp(path.join(os.tmpdir(), "aula-workspace-"));
|
|
30
|
+
let count = 0;
|
|
31
|
+
try {
|
|
32
|
+
const method = path.join(scratch, "aula-method.mjs");
|
|
33
|
+
await capabilities.fs.writeFile(method, METHOD_STUB);
|
|
34
|
+
const bundledAula = path.join(path.dirname(fileURLToPath(import.meta.url)), "aula.js");
|
|
35
|
+
const player = {
|
|
36
|
+
"@beff/aula": existsSync(bundledAula) ? pathToFileURL(bundledAula).href : import.meta.resolve("@beff/aula"),
|
|
37
|
+
"@beff/aula-method": pathToFileURL(method).href
|
|
38
|
+
};
|
|
39
|
+
const modules = {
|
|
40
|
+
load: async ({ code }) => {
|
|
41
|
+
count += 1;
|
|
42
|
+
const file = path.join(scratch, `bundle-${String(count)}.mjs`);
|
|
43
|
+
await capabilities.fs.writeFile(file, code);
|
|
44
|
+
const url = pathToFileURL(file).href;
|
|
45
|
+
return { url, exports: await import(url) };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const loaded = await loadBuiltProjects(workspaceBundle, workspaceHost(v8Frames), modules, player);
|
|
49
|
+
if (loaded._tag === "Left") throw new Problems(loaded.left);
|
|
50
|
+
return loaded.right;
|
|
51
|
+
} finally {
|
|
52
|
+
await capabilities.fs.rm(scratch, { recursive: true, force: true });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function projectFolderLabel(root, project) {
|
|
56
|
+
return project.folder === "" ? path.basename(root) : project.folder;
|
|
57
|
+
}
|
|
58
|
+
async function resolveRootProjects(capabilities, root, includeDrafts) {
|
|
59
|
+
const tree = nodeTree(capabilities, root);
|
|
60
|
+
const name = path.basename(root);
|
|
61
|
+
const bundler = createNodeBundler();
|
|
62
|
+
try {
|
|
63
|
+
const bundled = await bundleWorkspace(bundler, tree, name);
|
|
64
|
+
if (bundled._tag === "Left") throw new Problems(bundled.left);
|
|
65
|
+
let bundle = bundled.right.bundle;
|
|
66
|
+
const inputs = bundled.right.inputs;
|
|
67
|
+
const loaded = await loadWorkspaceProjects(capabilities, bundle);
|
|
68
|
+
if (loaded.length === 0) throw new Error(NO_PROJECT_MESSAGE);
|
|
69
|
+
const projects = listedProjects(loaded, { includeDrafts });
|
|
70
|
+
for (const project of loaded) {
|
|
71
|
+
if (project.draft && !includeDrafts) {
|
|
72
|
+
capabilities.log.out(draftSkipMessage(projectFolderLabel(root, project)));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (projects.length !== loaded.length) {
|
|
76
|
+
const keep = new Set(projects.map((project) => project.name));
|
|
77
|
+
const filtered = bundle.projects.filter((project) => keep.has(project.name));
|
|
78
|
+
if (filtered.length > 0) {
|
|
79
|
+
const rebundled = await bundleProjects(bundler, tree, name, filtered);
|
|
80
|
+
if (rebundled._tag === "Left") throw new Problems(rebundled.left);
|
|
81
|
+
bundle = rebundled.right.bundle;
|
|
82
|
+
} else {
|
|
83
|
+
bundle = { ...bundle, projects: [], code: "export default [];\n", map: "{}" };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (includeDrafts) bundle = { ...bundle, includeDrafts: true };
|
|
87
|
+
return { loaded, projects, bundle, inputs };
|
|
88
|
+
} finally {
|
|
89
|
+
await bundler.stop();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function projectFolderOf(root, project) {
|
|
93
|
+
return project.folder === "" ? root : path.join(root, project.folder);
|
|
94
|
+
}
|
|
95
|
+
async function resolveOneProject(capabilities, root, includeDrafts, command) {
|
|
96
|
+
const { projects } = await resolveRootProjects(capabilities, root, includeDrafts);
|
|
97
|
+
if (projects.length === 1) {
|
|
98
|
+
const project = projects[0];
|
|
99
|
+
if (project === void 0) throw new Error("resolveOneProject: missing project");
|
|
100
|
+
return { folder: projectFolderOf(root, project), project };
|
|
101
|
+
}
|
|
102
|
+
throw wrongArgument(
|
|
103
|
+
`aula ${command} needs exactly one project after filtering`,
|
|
104
|
+
projects.length === 0 ? "pass a project folder, or pass --include-drafts when the project is a draft" : "pass a project folder, not a playlist folder with more than one project"
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
resolveRootProjects,
|
|
110
|
+
resolveOneProject
|
|
111
|
+
};
|