@econ-v1/app-sdk 7.6.11 → 7.6.12
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/burger-build/cli.js
CHANGED
|
@@ -795,6 +795,15 @@ ${named}`);
|
|
|
795
795
|
return { problems };
|
|
796
796
|
return { code: await result.outputs[0].text() };
|
|
797
797
|
}
|
|
798
|
+
function bunfigTestPreloads(projectDir) {
|
|
799
|
+
const path = join2(projectDir, "bunfig.toml");
|
|
800
|
+
if (!existsSync(path))
|
|
801
|
+
return [];
|
|
802
|
+
const config = Bun.TOML.parse(readFileSync2(path, "utf8"));
|
|
803
|
+
const preload = config.test?.preload;
|
|
804
|
+
const entries = typeof preload === "string" ? [preload] : Array.isArray(preload) ? preload : [];
|
|
805
|
+
return entries.filter((entry) => typeof entry === "string").map((entry) => resolveRelativeFile(projectDir, entry)).filter((file) => file !== undefined);
|
|
806
|
+
}
|
|
798
807
|
async function prepareTests(options) {
|
|
799
808
|
assertSupportedBun();
|
|
800
809
|
const cwd = process.cwd();
|
|
@@ -852,6 +861,7 @@ async function prepareTests(options) {
|
|
|
852
861
|
`) };
|
|
853
862
|
}
|
|
854
863
|
}
|
|
864
|
+
const preloads = bunfigTestPreloads(cwd).filter((file) => ws.sources.has(file));
|
|
855
865
|
for (const file of files) {
|
|
856
866
|
const output = join2(out, preparedPath(relative2(root, file)));
|
|
857
867
|
const prepared = readFileSync2(output, "utf8").replace(MOCK_MODULE_CALL, (call, quote, specifier) => {
|
|
@@ -859,7 +869,9 @@ async function prepareTests(options) {
|
|
|
859
869
|
const replacement = rewritten === undefined ? undefined : ("external" in rewritten) ? rewritten.external : undefined;
|
|
860
870
|
return replacement === undefined ? call : call.replace(`${quote}${specifier}${quote}`, JSON.stringify(replacement));
|
|
861
871
|
});
|
|
862
|
-
|
|
872
|
+
const preloadImports = TEST_FILE.test(file) ? preloads.map((preload) => `import ${JSON.stringify(relativeSpecifier(dirname(output), join2(out, preparedPath(relative2(root, preload)))))};
|
|
873
|
+
`).join("") : "";
|
|
874
|
+
writeFileSync2(output, preloadImports + prepared);
|
|
863
875
|
const source = readFileSync2(file, "utf8");
|
|
864
876
|
const code = codeOf(file, source) ?? source;
|
|
865
877
|
const imports = new Bun.Transpiler({ loader: loaderFor2(file) }).scan(source).imports;
|
|
@@ -789,6 +789,15 @@ ${named}`);
|
|
|
789
789
|
return { problems };
|
|
790
790
|
return { code: await result.outputs[0].text() };
|
|
791
791
|
}
|
|
792
|
+
function bunfigTestPreloads(projectDir) {
|
|
793
|
+
const path = join2(projectDir, "bunfig.toml");
|
|
794
|
+
if (!existsSync(path))
|
|
795
|
+
return [];
|
|
796
|
+
const config = Bun.TOML.parse(readFileSync2(path, "utf8"));
|
|
797
|
+
const preload = config.test?.preload;
|
|
798
|
+
const entries = typeof preload === "string" ? [preload] : Array.isArray(preload) ? preload : [];
|
|
799
|
+
return entries.filter((entry) => typeof entry === "string").map((entry) => resolveRelativeFile(projectDir, entry)).filter((file) => file !== undefined);
|
|
800
|
+
}
|
|
792
801
|
async function prepareTests(options) {
|
|
793
802
|
assertSupportedBun();
|
|
794
803
|
const cwd = process.cwd();
|
|
@@ -846,6 +855,7 @@ async function prepareTests(options) {
|
|
|
846
855
|
`) };
|
|
847
856
|
}
|
|
848
857
|
}
|
|
858
|
+
const preloads = bunfigTestPreloads(cwd).filter((file) => ws.sources.has(file));
|
|
849
859
|
for (const file of files) {
|
|
850
860
|
const output = join2(out, preparedPath(relative2(root, file)));
|
|
851
861
|
const prepared = readFileSync2(output, "utf8").replace(MOCK_MODULE_CALL, (call, quote, specifier) => {
|
|
@@ -853,7 +863,9 @@ async function prepareTests(options) {
|
|
|
853
863
|
const replacement = rewritten === undefined ? undefined : ("external" in rewritten) ? rewritten.external : undefined;
|
|
854
864
|
return replacement === undefined ? call : call.replace(`${quote}${specifier}${quote}`, JSON.stringify(replacement));
|
|
855
865
|
});
|
|
856
|
-
|
|
866
|
+
const preloadImports = TEST_FILE.test(file) ? preloads.map((preload) => `import ${JSON.stringify(relativeSpecifier(dirname(output), join2(out, preparedPath(relative2(root, preload)))))};
|
|
867
|
+
`).join("") : "";
|
|
868
|
+
writeFileSync2(output, preloadImports + prepared);
|
|
857
869
|
const source = readFileSync2(file, "utf8");
|
|
858
870
|
const code = codeOf(file, source) ?? source;
|
|
859
871
|
const imports = new Bun.Transpiler({ loader: loaderFor2(file) }).scan(source).imports;
|
|
@@ -65,6 +65,11 @@ export declare function staticallyImportedMocks(file: string, code: string, impo
|
|
|
65
65
|
kind: string;
|
|
66
66
|
path: string;
|
|
67
67
|
}[]): string[];
|
|
68
|
+
/**
|
|
69
|
+
* The files `bunfig.toml` `[test] preload` names in `projectDir`, resolved like
|
|
70
|
+
* a relative import. `bun test` evaluates them before each test file.
|
|
71
|
+
*/
|
|
72
|
+
export declare function bunfigTestPreloads(projectDir: string): string[];
|
|
68
73
|
/**
|
|
69
74
|
* Turn an app's sources and tests into files `node-app-burger test` can run:
|
|
70
75
|
* one transpiled ES module per source file (module boundaries preserved so
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@econ-v1/app-sdk",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.12",
|
|
4
4
|
"description": "TypeScript SDK for building Node mini-app plugins (Bun runtime) on the Lightning-powered marketplace daemon",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"author": "Node contributors",
|