@gcoredev/fastedge-test 0.2.2 → 0.2.3
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/bin/fastedge-debug.js +38 -3
- package/dist/lib/index.cjs +31 -13
- package/dist/lib/index.js +34 -14
- package/dist/lib/test-framework/index.cjs +31 -13
- package/dist/lib/test-framework/index.js +33 -14
- package/dist/lib/utils/fastedge-cli.d.ts +36 -1
- package/dist/server.js +27 -27
- package/docs/API.md +56 -56
- package/docs/DEBUGGER.md +31 -11
- package/docs/TEST_CONFIG.md +2 -2
- package/docs/TEST_FRAMEWORK.md +7 -7
- package/package.json +1 -1
package/bin/fastedge-debug.js
CHANGED
|
@@ -34,8 +34,43 @@ function resolveAppRoot(startPath) {
|
|
|
34
34
|
return dir;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
// Parse `--project-dir <path>` / `--project-dir=<path>` and strip it from argv
|
|
38
|
+
// before the server import, so the server's own arg handling doesn't see it.
|
|
39
|
+
// When set, it overrides the positional fallback for resolveAppRoot — useful
|
|
40
|
+
// when running from a nested sandbox (e.g. `cd fastedge-test && npm run debug`
|
|
41
|
+
// with the project root one directory up).
|
|
42
|
+
function extractProjectDirFlag(argv) {
|
|
43
|
+
for (let i = 2; i < argv.length; i++) {
|
|
44
|
+
const a = argv[i];
|
|
45
|
+
if (a === "--project-dir" || a === "-C") {
|
|
46
|
+
const value = argv[i + 1];
|
|
47
|
+
if (!value) {
|
|
48
|
+
console.error(`Error: ${a} requires a path argument.`);
|
|
49
|
+
process.exit(2);
|
|
50
|
+
}
|
|
51
|
+
argv.splice(i, 2);
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
const eq = a.startsWith("--project-dir=")
|
|
55
|
+
? a.slice("--project-dir=".length)
|
|
56
|
+
: a.startsWith("-C=")
|
|
57
|
+
? a.slice("-C=".length)
|
|
58
|
+
: null;
|
|
59
|
+
if (eq !== null) {
|
|
60
|
+
argv.splice(i, 1);
|
|
61
|
+
return eq;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const projectDirFlag = extractProjectDirFlag(process.argv);
|
|
68
|
+
const startPath = projectDirFlag
|
|
69
|
+
? resolve(projectDirFlag)
|
|
70
|
+
: process.argv[2]
|
|
71
|
+
? resolve(process.argv[2])
|
|
72
|
+
: process.cwd();
|
|
73
|
+
|
|
74
|
+
process.env.WORKSPACE_PATH = resolveAppRoot(startPath);
|
|
40
75
|
|
|
41
76
|
import("../dist/server.js");
|
package/dist/lib/index.cjs
CHANGED
|
@@ -2910,19 +2910,37 @@ function getCliBinaryName() {
|
|
|
2910
2910
|
throw new Error(`Unsupported platform: ${import_os.default.platform()}`);
|
|
2911
2911
|
}
|
|
2912
2912
|
}
|
|
2913
|
-
function
|
|
2913
|
+
function getPackageRoot(startDir = _currentDir) {
|
|
2914
|
+
let dir = startDir;
|
|
2915
|
+
while (true) {
|
|
2916
|
+
const pkgPath = (0, import_path2.join)(dir, "package.json");
|
|
2917
|
+
if ((0, import_fs.existsSync)(pkgPath)) {
|
|
2918
|
+
try {
|
|
2919
|
+
const pkg = JSON.parse((0, import_fs.readFileSync)(pkgPath, "utf8"));
|
|
2920
|
+
if (pkg.name === "@gcoredev/fastedge-test") return dir;
|
|
2921
|
+
} catch {
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
const parent = (0, import_path2.dirname)(dir);
|
|
2925
|
+
if (parent === dir) return null;
|
|
2926
|
+
dir = parent;
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
function getBundledCliPaths(startDir = _currentDir) {
|
|
2914
2930
|
const binaryName = getCliBinaryName();
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
(0, import_path2.join)(
|
|
2925
|
-
|
|
2931
|
+
const candidates = [];
|
|
2932
|
+
const root = getPackageRoot(startDir);
|
|
2933
|
+
if (root) {
|
|
2934
|
+
candidates.push(
|
|
2935
|
+
(0, import_path2.join)(root, "dist", "fastedge-cli", binaryName),
|
|
2936
|
+
(0, import_path2.join)(root, "fastedge-run", binaryName)
|
|
2937
|
+
);
|
|
2938
|
+
}
|
|
2939
|
+
candidates.push(
|
|
2940
|
+
(0, import_path2.join)(startDir, "fastedge-cli", binaryName),
|
|
2941
|
+
(0, import_path2.join)(startDir, "..", "fastedge-cli", binaryName)
|
|
2942
|
+
);
|
|
2943
|
+
return candidates;
|
|
2926
2944
|
}
|
|
2927
2945
|
function ensureExecutable(binaryPath) {
|
|
2928
2946
|
if (process.platform !== "win32") {
|
|
@@ -2960,7 +2978,7 @@ async function findFastEdgeRunCli() {
|
|
|
2960
2978
|
} catch (error) {
|
|
2961
2979
|
}
|
|
2962
2980
|
throw new Error(
|
|
2963
|
-
"fastedge-run CLI not found in any of these locations:\n 1. FASTEDGE_RUN_PATH environment variable\n 2. Bundled
|
|
2981
|
+
"fastedge-run CLI not found in any of these locations:\n 1. FASTEDGE_RUN_PATH environment variable\n 2. Bundled inside the @gcoredev/fastedge-test package (dist/fastedge-cli/<binary> when installed, fastedge-run/<binary> in the source tree)\n 3. System PATH (which/where fastedge-run)\n\nTo fix this:\n - Set FASTEDGE_RUN_PATH to a fastedge-run binary you have locally, or\n - Install fastedge-run in PATH: cargo install fastedge-run, or\n - Reinstall @gcoredev/fastedge-test to restore the bundled binary (or, when developing this repo, place the platform binary in fastedge-run/)"
|
|
2964
2982
|
);
|
|
2965
2983
|
}
|
|
2966
2984
|
|
package/dist/lib/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
2
|
+
|
|
1
3
|
// server/runner/ProxyWasmRunner.ts
|
|
2
4
|
import { WASI } from "node:wasi";
|
|
3
5
|
|
|
@@ -2849,7 +2851,7 @@ import { spawn, execSync as execSync2 } from "child_process";
|
|
|
2849
2851
|
|
|
2850
2852
|
// server/utils/fastedge-cli.ts
|
|
2851
2853
|
import { execSync } from "child_process";
|
|
2852
|
-
import { existsSync, chmodSync } from "fs";
|
|
2854
|
+
import { existsSync, chmodSync, readFileSync } from "fs";
|
|
2853
2855
|
import { join, dirname } from "path";
|
|
2854
2856
|
import { fileURLToPath } from "url";
|
|
2855
2857
|
import os from "os";
|
|
@@ -2866,19 +2868,37 @@ function getCliBinaryName() {
|
|
|
2866
2868
|
throw new Error(`Unsupported platform: ${os.platform()}`);
|
|
2867
2869
|
}
|
|
2868
2870
|
}
|
|
2869
|
-
function
|
|
2871
|
+
function getPackageRoot(startDir = _currentDir) {
|
|
2872
|
+
let dir = startDir;
|
|
2873
|
+
while (true) {
|
|
2874
|
+
const pkgPath = join(dir, "package.json");
|
|
2875
|
+
if (existsSync(pkgPath)) {
|
|
2876
|
+
try {
|
|
2877
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
2878
|
+
if (pkg.name === "@gcoredev/fastedge-test") return dir;
|
|
2879
|
+
} catch {
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
const parent = dirname(dir);
|
|
2883
|
+
if (parent === dir) return null;
|
|
2884
|
+
dir = parent;
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
function getBundledCliPaths(startDir = _currentDir) {
|
|
2870
2888
|
const binaryName = getCliBinaryName();
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
join(
|
|
2881
|
-
|
|
2889
|
+
const candidates = [];
|
|
2890
|
+
const root = getPackageRoot(startDir);
|
|
2891
|
+
if (root) {
|
|
2892
|
+
candidates.push(
|
|
2893
|
+
join(root, "dist", "fastedge-cli", binaryName),
|
|
2894
|
+
join(root, "fastedge-run", binaryName)
|
|
2895
|
+
);
|
|
2896
|
+
}
|
|
2897
|
+
candidates.push(
|
|
2898
|
+
join(startDir, "fastedge-cli", binaryName),
|
|
2899
|
+
join(startDir, "..", "fastedge-cli", binaryName)
|
|
2900
|
+
);
|
|
2901
|
+
return candidates;
|
|
2882
2902
|
}
|
|
2883
2903
|
function ensureExecutable(binaryPath) {
|
|
2884
2904
|
if (process.platform !== "win32") {
|
|
@@ -2916,7 +2936,7 @@ async function findFastEdgeRunCli() {
|
|
|
2916
2936
|
} catch (error) {
|
|
2917
2937
|
}
|
|
2918
2938
|
throw new Error(
|
|
2919
|
-
"fastedge-run CLI not found in any of these locations:\n 1. FASTEDGE_RUN_PATH environment variable\n 2. Bundled
|
|
2939
|
+
"fastedge-run CLI not found in any of these locations:\n 1. FASTEDGE_RUN_PATH environment variable\n 2. Bundled inside the @gcoredev/fastedge-test package (dist/fastedge-cli/<binary> when installed, fastedge-run/<binary> in the source tree)\n 3. System PATH (which/where fastedge-run)\n\nTo fix this:\n - Set FASTEDGE_RUN_PATH to a fastedge-run binary you have locally, or\n - Install fastedge-run in PATH: cargo install fastedge-run, or\n - Reinstall @gcoredev/fastedge-test to restore the bundled binary (or, when developing this repo, place the platform binary in fastedge-run/)"
|
|
2920
2940
|
);
|
|
2921
2941
|
}
|
|
2922
2942
|
|
|
@@ -21307,19 +21307,37 @@ function getCliBinaryName() {
|
|
|
21307
21307
|
throw new Error(`Unsupported platform: ${import_os.default.platform()}`);
|
|
21308
21308
|
}
|
|
21309
21309
|
}
|
|
21310
|
-
function
|
|
21310
|
+
function getPackageRoot(startDir = _currentDir) {
|
|
21311
|
+
let dir = startDir;
|
|
21312
|
+
while (true) {
|
|
21313
|
+
const pkgPath = (0, import_path2.join)(dir, "package.json");
|
|
21314
|
+
if ((0, import_fs.existsSync)(pkgPath)) {
|
|
21315
|
+
try {
|
|
21316
|
+
const pkg = JSON.parse((0, import_fs.readFileSync)(pkgPath, "utf8"));
|
|
21317
|
+
if (pkg.name === "@gcoredev/fastedge-test") return dir;
|
|
21318
|
+
} catch {
|
|
21319
|
+
}
|
|
21320
|
+
}
|
|
21321
|
+
const parent = (0, import_path2.dirname)(dir);
|
|
21322
|
+
if (parent === dir) return null;
|
|
21323
|
+
dir = parent;
|
|
21324
|
+
}
|
|
21325
|
+
}
|
|
21326
|
+
function getBundledCliPaths(startDir = _currentDir) {
|
|
21311
21327
|
const binaryName = getCliBinaryName();
|
|
21312
|
-
|
|
21313
|
-
|
|
21314
|
-
|
|
21315
|
-
|
|
21316
|
-
|
|
21317
|
-
|
|
21318
|
-
|
|
21319
|
-
|
|
21320
|
-
|
|
21321
|
-
(0, import_path2.join)(
|
|
21322
|
-
|
|
21328
|
+
const candidates = [];
|
|
21329
|
+
const root = getPackageRoot(startDir);
|
|
21330
|
+
if (root) {
|
|
21331
|
+
candidates.push(
|
|
21332
|
+
(0, import_path2.join)(root, "dist", "fastedge-cli", binaryName),
|
|
21333
|
+
(0, import_path2.join)(root, "fastedge-run", binaryName)
|
|
21334
|
+
);
|
|
21335
|
+
}
|
|
21336
|
+
candidates.push(
|
|
21337
|
+
(0, import_path2.join)(startDir, "fastedge-cli", binaryName),
|
|
21338
|
+
(0, import_path2.join)(startDir, "..", "fastedge-cli", binaryName)
|
|
21339
|
+
);
|
|
21340
|
+
return candidates;
|
|
21323
21341
|
}
|
|
21324
21342
|
function ensureExecutable(binaryPath) {
|
|
21325
21343
|
if (process.platform !== "win32") {
|
|
@@ -21357,7 +21375,7 @@ async function findFastEdgeRunCli() {
|
|
|
21357
21375
|
} catch (error) {
|
|
21358
21376
|
}
|
|
21359
21377
|
throw new Error(
|
|
21360
|
-
"fastedge-run CLI not found in any of these locations:\n 1. FASTEDGE_RUN_PATH environment variable\n 2. Bundled
|
|
21378
|
+
"fastedge-run CLI not found in any of these locations:\n 1. FASTEDGE_RUN_PATH environment variable\n 2. Bundled inside the @gcoredev/fastedge-test package (dist/fastedge-cli/<binary> when installed, fastedge-run/<binary> in the source tree)\n 3. System PATH (which/where fastedge-run)\n\nTo fix this:\n - Set FASTEDGE_RUN_PATH to a fastedge-run binary you have locally, or\n - Install fastedge-run in PATH: cargo install fastedge-run, or\n - Reinstall @gcoredev/fastedge-test to restore the bundled binary (or, when developing this repo, place the platform binary in fastedge-run/)"
|
|
21361
21379
|
);
|
|
21362
21380
|
}
|
|
21363
21381
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -21254,7 +21255,7 @@ import { spawn, execSync as execSync2 } from "child_process";
|
|
|
21254
21255
|
|
|
21255
21256
|
// server/utils/fastedge-cli.ts
|
|
21256
21257
|
import { execSync } from "child_process";
|
|
21257
|
-
import { existsSync, chmodSync } from "fs";
|
|
21258
|
+
import { existsSync, chmodSync, readFileSync } from "fs";
|
|
21258
21259
|
import { join, dirname } from "path";
|
|
21259
21260
|
import { fileURLToPath } from "url";
|
|
21260
21261
|
import os from "os";
|
|
@@ -21271,19 +21272,37 @@ function getCliBinaryName() {
|
|
|
21271
21272
|
throw new Error(`Unsupported platform: ${os.platform()}`);
|
|
21272
21273
|
}
|
|
21273
21274
|
}
|
|
21274
|
-
function
|
|
21275
|
+
function getPackageRoot(startDir = _currentDir) {
|
|
21276
|
+
let dir = startDir;
|
|
21277
|
+
while (true) {
|
|
21278
|
+
const pkgPath = join(dir, "package.json");
|
|
21279
|
+
if (existsSync(pkgPath)) {
|
|
21280
|
+
try {
|
|
21281
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
21282
|
+
if (pkg.name === "@gcoredev/fastedge-test") return dir;
|
|
21283
|
+
} catch {
|
|
21284
|
+
}
|
|
21285
|
+
}
|
|
21286
|
+
const parent = dirname(dir);
|
|
21287
|
+
if (parent === dir) return null;
|
|
21288
|
+
dir = parent;
|
|
21289
|
+
}
|
|
21290
|
+
}
|
|
21291
|
+
function getBundledCliPaths(startDir = _currentDir) {
|
|
21275
21292
|
const binaryName = getCliBinaryName();
|
|
21276
|
-
|
|
21277
|
-
|
|
21278
|
-
|
|
21279
|
-
|
|
21280
|
-
|
|
21281
|
-
|
|
21282
|
-
|
|
21283
|
-
|
|
21284
|
-
|
|
21285
|
-
join(
|
|
21286
|
-
|
|
21293
|
+
const candidates = [];
|
|
21294
|
+
const root = getPackageRoot(startDir);
|
|
21295
|
+
if (root) {
|
|
21296
|
+
candidates.push(
|
|
21297
|
+
join(root, "dist", "fastedge-cli", binaryName),
|
|
21298
|
+
join(root, "fastedge-run", binaryName)
|
|
21299
|
+
);
|
|
21300
|
+
}
|
|
21301
|
+
candidates.push(
|
|
21302
|
+
join(startDir, "fastedge-cli", binaryName),
|
|
21303
|
+
join(startDir, "..", "fastedge-cli", binaryName)
|
|
21304
|
+
);
|
|
21305
|
+
return candidates;
|
|
21287
21306
|
}
|
|
21288
21307
|
function ensureExecutable(binaryPath) {
|
|
21289
21308
|
if (process.platform !== "win32") {
|
|
@@ -21321,7 +21340,7 @@ async function findFastEdgeRunCli() {
|
|
|
21321
21340
|
} catch (error) {
|
|
21322
21341
|
}
|
|
21323
21342
|
throw new Error(
|
|
21324
|
-
"fastedge-run CLI not found in any of these locations:\n 1. FASTEDGE_RUN_PATH environment variable\n 2. Bundled
|
|
21343
|
+
"fastedge-run CLI not found in any of these locations:\n 1. FASTEDGE_RUN_PATH environment variable\n 2. Bundled inside the @gcoredev/fastedge-test package (dist/fastedge-cli/<binary> when installed, fastedge-run/<binary> in the source tree)\n 3. System PATH (which/where fastedge-run)\n\nTo fix this:\n - Set FASTEDGE_RUN_PATH to a fastedge-run binary you have locally, or\n - Install fastedge-run in PATH: cargo install fastedge-run, or\n - Reinstall @gcoredev/fastedge-test to restore the bundled binary (or, when developing this repo, place the platform binary in fastedge-run/)"
|
|
21325
21344
|
);
|
|
21326
21345
|
}
|
|
21327
21346
|
|
|
@@ -3,9 +3,44 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Discovers the FastEdge-run CLI binary in the following order:
|
|
5
5
|
* 1. FASTEDGE_RUN_PATH environment variable
|
|
6
|
-
* 2. Bundled binary
|
|
6
|
+
* 2. Bundled binary inside the @gcoredev/fastedge-test package, anchored on
|
|
7
|
+
* the package root (see getPackageRoot):
|
|
8
|
+
* • dist/fastedge-cli/<binary> — published npm layout
|
|
9
|
+
* • fastedge-run/<binary> — in-repo source/dev layout
|
|
7
10
|
* 3. PATH (using 'which' or 'where' command)
|
|
8
11
|
*/
|
|
12
|
+
/**
|
|
13
|
+
* Walk up from `startDir` until a package.json with name "@gcoredev/fastedge-test"
|
|
14
|
+
* is found. Anchoring on the package name (rather than hardcoded depths or an
|
|
15
|
+
* unbounded walk) keeps the search robust across bundle layouts and avoids
|
|
16
|
+
* climbing into a sibling package in workspace/monorepo installs.
|
|
17
|
+
*
|
|
18
|
+
* `startDir` defaults to the directory of this file (resolved at module load).
|
|
19
|
+
* It is overridable for tests so the resolver can be exercised against
|
|
20
|
+
* synthetic package layouts.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getPackageRoot(startDir?: string): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Get possible bundled CLI paths.
|
|
25
|
+
*
|
|
26
|
+
* Two resolution modes, both contribute candidates:
|
|
27
|
+
*
|
|
28
|
+
* 1. **Package-root anchored** (primary) — when a `@gcoredev/fastedge-test`
|
|
29
|
+
* package.json can be located via `getPackageRoot`, candidates resolve
|
|
30
|
+
* against it: the published npm layout (`dist/fastedge-cli/`) and the
|
|
31
|
+
* in-repo source layout (`fastedge-run/`).
|
|
32
|
+
*
|
|
33
|
+
* 2. **startDir-relative fallback** — covers bundle layouts that ship
|
|
34
|
+
* without our package.json available nearby. Notably the VSCode extension
|
|
35
|
+
* copies `dist/server.js` and `dist/fastedge-cli/` into its own tree, so
|
|
36
|
+
* the walker can't anchor on our package root. The fallback lets the
|
|
37
|
+
* server bundle locate the sibling `fastedge-cli/` directory directly.
|
|
38
|
+
*
|
|
39
|
+
* `findFastEdgeRunCli` filters by existence, so listing extra candidates is
|
|
40
|
+
* safe — the first one that actually exists wins. `startDir` is overridable
|
|
41
|
+
* for tests.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getBundledCliPaths(startDir?: string): string[];
|
|
9
44
|
/**
|
|
10
45
|
* Find the FastEdge-run CLI binary
|
|
11
46
|
* @returns The absolute path to the fastedge-run binary
|