@usejourney/cli 0.1.3 → 0.1.5
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/index.js +88 -28
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -499,6 +499,40 @@ function overallOk(results) {
|
|
|
499
499
|
return results.every((r) => r.ok);
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
+
// src/util/dispatcher.ts
|
|
503
|
+
var current;
|
|
504
|
+
var warnedInsecure = false;
|
|
505
|
+
var defaults = {};
|
|
506
|
+
function setDispatcherDefaults(opts) {
|
|
507
|
+
defaults = opts;
|
|
508
|
+
}
|
|
509
|
+
async function configureDispatcher(opts) {
|
|
510
|
+
const insecure = opts.insecure === true || defaults.insecure === true;
|
|
511
|
+
const connectTimeoutMs = defaults.connectTimeoutMs ?? opts.connectTimeoutMs;
|
|
512
|
+
if (!insecure && connectTimeoutMs === void 0) return void 0;
|
|
513
|
+
const key = `${insecure}:${connectTimeoutMs ?? "default"}`;
|
|
514
|
+
if (current?.key === key) return current.agent;
|
|
515
|
+
const { Agent, fetch: undiciFetch, setGlobalDispatcher } = await import("undici");
|
|
516
|
+
const agent = new Agent({
|
|
517
|
+
...connectTimeoutMs !== void 0 ? { connectTimeout: connectTimeoutMs } : {},
|
|
518
|
+
connect: {
|
|
519
|
+
...insecure ? { rejectUnauthorized: false } : {},
|
|
520
|
+
// `connect.timeout` is what the connector actually reads; undici spreads
|
|
521
|
+
// `connect` last, so the top-level `connectTimeout` alone would be
|
|
522
|
+
// clobbered by this object. Set both.
|
|
523
|
+
...connectTimeoutMs !== void 0 ? { timeout: connectTimeoutMs } : {}
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
setGlobalDispatcher(agent);
|
|
527
|
+
globalThis.fetch = undiciFetch;
|
|
528
|
+
current = { key, agent };
|
|
529
|
+
if (insecure && !warnedInsecure) {
|
|
530
|
+
warnedInsecure = true;
|
|
531
|
+
console.error("journey: WARNING \u2014 TLS verification disabled (--insecure)");
|
|
532
|
+
}
|
|
533
|
+
return agent;
|
|
534
|
+
}
|
|
535
|
+
|
|
502
536
|
// src/util/projectCoreLink.ts
|
|
503
537
|
import { existsSync, readFileSync } from "fs";
|
|
504
538
|
import { mkdir as mkdir3, symlink } from "fs/promises";
|
|
@@ -529,16 +563,6 @@ async function ensureProjectCoreLink(projectDir) {
|
|
|
529
563
|
}
|
|
530
564
|
|
|
531
565
|
// src/commands/run.ts
|
|
532
|
-
var insecureAgent;
|
|
533
|
-
async function enableInsecureTls() {
|
|
534
|
-
if (!insecureAgent) {
|
|
535
|
-
const { Agent, setGlobalDispatcher } = await import("undici");
|
|
536
|
-
insecureAgent = new Agent({ connect: { rejectUnauthorized: false } });
|
|
537
|
-
setGlobalDispatcher(insecureAgent);
|
|
538
|
-
console.error("journey: WARNING \u2014 TLS verification disabled (--insecure)");
|
|
539
|
-
}
|
|
540
|
-
return insecureAgent;
|
|
541
|
-
}
|
|
542
566
|
async function runCommand(opts) {
|
|
543
567
|
const loaded = await loadConfig4(opts.projectDir);
|
|
544
568
|
const paths = resolveConfigPaths4(loaded);
|
|
@@ -559,14 +583,20 @@ async function runCommand(opts) {
|
|
|
559
583
|
if (baseUrl) ctx.baseUrl = baseUrl;
|
|
560
584
|
const logger = opts.debug ? createConsoleLogger() : loggerFromEnv();
|
|
561
585
|
if (logger) ctx.logger = logger;
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
586
|
+
const connectTimeoutMs = opts.connectTimeoutMs ?? loaded.config.connectTimeoutMs;
|
|
587
|
+
const dispatcher = await configureDispatcher({
|
|
588
|
+
insecure: opts.insecure || loaded.config.tlsRejectUnauthorized === false,
|
|
589
|
+
...connectTimeoutMs !== void 0 ? { connectTimeoutMs } : {}
|
|
590
|
+
});
|
|
591
|
+
if (dispatcher !== void 0) ctx.dispatcher = dispatcher;
|
|
565
592
|
const subCache = createSubJourneyCache(opts.cache ?? "process", {
|
|
566
593
|
diskDir: join5(opts.projectDir, ".journey", "cache", "sub-journey")
|
|
567
594
|
});
|
|
568
595
|
if (subCache) ctx.subJourneyCache = subCache;
|
|
569
596
|
if (opts.cacheTtlMs !== void 0) ctx.subJourneyCacheTtlMs = opts.cacheTtlMs;
|
|
597
|
+
if (opts.timeoutMs !== void 0) {
|
|
598
|
+
ctx.defaultTimeoutMs = opts.timeoutMs === 0 ? null : opts.timeoutMs;
|
|
599
|
+
}
|
|
570
600
|
const results = await runAllRegistered(ctx);
|
|
571
601
|
printResults(results);
|
|
572
602
|
const cacheDir = join5(opts.projectDir, ".journey", "cache");
|
|
@@ -699,10 +729,10 @@ function formatArgs(args) {
|
|
|
699
729
|
// src/server/runner.ts
|
|
700
730
|
async function runJourneyFile(opts) {
|
|
701
731
|
const abs = isAbsolute5(opts.file) ? opts.file : opts.file.includes("/") || opts.file.includes("\\") ? resolve5(process.cwd(), opts.file) : join6(opts.journeysDir, opts.file);
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
}
|
|
732
|
+
const dispatcher = await configureDispatcher({
|
|
733
|
+
insecure: opts.loaded.config.tlsRejectUnauthorized === false,
|
|
734
|
+
...opts.loaded.config.connectTimeoutMs !== void 0 ? { connectTimeoutMs: opts.loaded.config.connectTimeoutMs } : {}
|
|
735
|
+
});
|
|
706
736
|
clearActiveEnvironment3();
|
|
707
737
|
const envName = opts.env ?? opts.loaded.config.defaultEnvironment;
|
|
708
738
|
if (envName) {
|
|
@@ -722,6 +752,9 @@ async function runJourneyFile(opts) {
|
|
|
722
752
|
if (opts.subJourneyCacheTtlMs !== void 0) {
|
|
723
753
|
ctx.subJourneyCacheTtlMs = opts.subJourneyCacheTtlMs;
|
|
724
754
|
}
|
|
755
|
+
if (opts.timeoutMs !== void 0) {
|
|
756
|
+
ctx.defaultTimeoutMs = opts.timeoutMs === 0 ? null : opts.timeoutMs;
|
|
757
|
+
}
|
|
725
758
|
const unpatchConsole = logger ? patchConsole(logger) : () => {
|
|
726
759
|
};
|
|
727
760
|
let results;
|
|
@@ -1191,13 +1224,13 @@ var PATCHABLE_CONFIG_KEYS = ["tlsRejectUnauthorized"];
|
|
|
1191
1224
|
async function patchProjectConfig(projectDir, patch) {
|
|
1192
1225
|
const configPath = join9(projectDir, "journey.config.json");
|
|
1193
1226
|
const raw = await readFile2(configPath, "utf8");
|
|
1194
|
-
const
|
|
1227
|
+
const current2 = JSON.parse(raw);
|
|
1195
1228
|
for (const key of Object.keys(patch)) {
|
|
1196
1229
|
if (!PATCHABLE_CONFIG_KEYS.includes(key)) {
|
|
1197
1230
|
throw new Error(`config key "${key}" is not patchable via the API`);
|
|
1198
1231
|
}
|
|
1199
1232
|
}
|
|
1200
|
-
const merged = { ...
|
|
1233
|
+
const merged = { ...current2 };
|
|
1201
1234
|
for (const key of PATCHABLE_CONFIG_KEYS) {
|
|
1202
1235
|
if (Object.prototype.hasOwnProperty.call(patch, key)) {
|
|
1203
1236
|
merged[key] = patch[key];
|
|
@@ -1334,7 +1367,7 @@ async function proxyRequest(body) {
|
|
|
1334
1367
|
durationMs: Date.now() - started
|
|
1335
1368
|
};
|
|
1336
1369
|
}
|
|
1337
|
-
async function route(req, res, projectDir, debug, setProjectDir, cacheFor, cacheTtlMs) {
|
|
1370
|
+
async function route(req, res, projectDir, debug, setProjectDir, cacheFor, cacheTtlMs, timeoutMs) {
|
|
1338
1371
|
if (req.method === "OPTIONS") {
|
|
1339
1372
|
res.writeHead(204, {
|
|
1340
1373
|
"access-control-allow-origin": "*",
|
|
@@ -1553,7 +1586,8 @@ async function route(req, res, projectDir, debug, setProjectDir, cacheFor, cache
|
|
|
1553
1586
|
...typeof body.upToStepIdx === "number" ? { upToStepIdx: body.upToStepIdx } : {},
|
|
1554
1587
|
...debug ? { debug: true } : {},
|
|
1555
1588
|
...subJourneyCache !== void 0 ? { subJourneyCache } : {},
|
|
1556
|
-
...cacheTtlMs !== void 0 ? { subJourneyCacheTtlMs: cacheTtlMs } : {}
|
|
1589
|
+
...cacheTtlMs !== void 0 ? { subJourneyCacheTtlMs: cacheTtlMs } : {},
|
|
1590
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {}
|
|
1557
1591
|
});
|
|
1558
1592
|
if (body.stream) {
|
|
1559
1593
|
runPromise.catch((err) => {
|
|
@@ -1659,7 +1693,8 @@ async function startServer(opts) {
|
|
|
1659
1693
|
opts.debug ?? false,
|
|
1660
1694
|
setProjectDir,
|
|
1661
1695
|
cacheFor,
|
|
1662
|
-
opts.cacheTtlMs
|
|
1696
|
+
opts.cacheTtlMs,
|
|
1697
|
+
opts.timeoutMs
|
|
1663
1698
|
);
|
|
1664
1699
|
});
|
|
1665
1700
|
await new Promise((resolve7, reject) => {
|
|
@@ -1677,14 +1712,19 @@ async function startServer(opts) {
|
|
|
1677
1712
|
|
|
1678
1713
|
// src/commands/serve.ts
|
|
1679
1714
|
async function runServe(opts) {
|
|
1680
|
-
|
|
1715
|
+
setDispatcherDefaults({
|
|
1716
|
+
...opts.insecure !== void 0 ? { insecure: opts.insecure } : {},
|
|
1717
|
+
...opts.connectTimeoutMs !== void 0 ? { connectTimeoutMs: opts.connectTimeoutMs } : {}
|
|
1718
|
+
});
|
|
1719
|
+
await configureDispatcher({});
|
|
1681
1720
|
const srv = await startServer({
|
|
1682
1721
|
projectDir: opts.projectDir,
|
|
1683
1722
|
...opts.host !== void 0 ? { host: opts.host } : {},
|
|
1684
1723
|
...opts.port !== void 0 ? { port: opts.port } : {},
|
|
1685
1724
|
...opts.debug !== void 0 ? { debug: opts.debug } : {},
|
|
1686
1725
|
...opts.cache !== void 0 ? { cache: opts.cache } : {},
|
|
1687
|
-
...opts.cacheTtlMs !== void 0 ? { cacheTtlMs: opts.cacheTtlMs } : {}
|
|
1726
|
+
...opts.cacheTtlMs !== void 0 ? { cacheTtlMs: opts.cacheTtlMs } : {},
|
|
1727
|
+
...opts.timeoutMs !== void 0 ? { timeoutMs: opts.timeoutMs } : {}
|
|
1688
1728
|
});
|
|
1689
1729
|
console.log(`Journey API listening at ${srv.url}`);
|
|
1690
1730
|
console.log(`For the GUI, run: pnpm --filter @usejourney/gui dev`);
|
|
@@ -1741,7 +1781,15 @@ function buildProgram() {
|
|
|
1741
1781
|
"Sub-journey output cache: off|run|process|disk",
|
|
1742
1782
|
parseCacheMode,
|
|
1743
1783
|
"process"
|
|
1744
|
-
).option("--cache-ttl <ms>", "Default sub-journey cache TTL in ms", (v) => parseInt(v, 10)).
|
|
1784
|
+
).option("--cache-ttl <ms>", "Default sub-journey cache TTL in ms", (v) => parseInt(v, 10)).option(
|
|
1785
|
+
"--timeout <ms>",
|
|
1786
|
+
"Request timeout in ms; 0 disables (default 60000)",
|
|
1787
|
+
(v) => parseInt(v, 10)
|
|
1788
|
+
).option(
|
|
1789
|
+
"--connect-timeout <ms>",
|
|
1790
|
+
"DNS + TCP + TLS connect timeout in ms; 0 disables (default 10000)",
|
|
1791
|
+
(v) => parseInt(v, 10)
|
|
1792
|
+
).description("Run one or more journeys (or --all)").action(
|
|
1745
1793
|
(files, options) => handle(
|
|
1746
1794
|
() => runCommand({
|
|
1747
1795
|
projectDir: process.cwd(),
|
|
@@ -1752,7 +1800,9 @@ function buildProgram() {
|
|
|
1752
1800
|
...options.watch !== void 0 ? { watch: options.watch } : {},
|
|
1753
1801
|
...options.insecure !== void 0 ? { insecure: options.insecure } : {},
|
|
1754
1802
|
...options.cache !== void 0 ? { cache: options.cache } : {},
|
|
1755
|
-
...options.cacheTtl !== void 0 ? { cacheTtlMs: options.cacheTtl } : {}
|
|
1803
|
+
...options.cacheTtl !== void 0 ? { cacheTtlMs: options.cacheTtl } : {},
|
|
1804
|
+
...options.timeout !== void 0 ? { timeoutMs: options.timeout } : {},
|
|
1805
|
+
...options.connectTimeout !== void 0 ? { connectTimeoutMs: options.connectTimeout } : {}
|
|
1756
1806
|
})
|
|
1757
1807
|
)
|
|
1758
1808
|
);
|
|
@@ -1816,7 +1866,15 @@ function buildProgram() {
|
|
|
1816
1866
|
"Sub-journey output cache: off|run|process|disk",
|
|
1817
1867
|
parseCacheMode,
|
|
1818
1868
|
"process"
|
|
1819
|
-
).option("--cache-ttl <ms>", "Default sub-journey cache TTL in ms", (v) => parseInt(v, 10)).
|
|
1869
|
+
).option("--cache-ttl <ms>", "Default sub-journey cache TTL in ms", (v) => parseInt(v, 10)).option(
|
|
1870
|
+
"--timeout <ms>",
|
|
1871
|
+
"Request timeout in ms for journey runs triggered via the API; 0 disables (default 60000)",
|
|
1872
|
+
(v) => parseInt(v, 10)
|
|
1873
|
+
).option(
|
|
1874
|
+
"--connect-timeout <ms>",
|
|
1875
|
+
"DNS + TCP + TLS connect timeout in ms; 0 disables (default 10000)",
|
|
1876
|
+
(v) => parseInt(v, 10)
|
|
1877
|
+
).description("Run the GUI backend API for the current project").action(
|
|
1820
1878
|
(options) => {
|
|
1821
1879
|
const projectDir = options.project ? resolvePath(process.cwd(), options.project) : process.cwd();
|
|
1822
1880
|
return handle(
|
|
@@ -1827,7 +1885,9 @@ function buildProgram() {
|
|
|
1827
1885
|
...options.debug !== void 0 ? { debug: options.debug } : {},
|
|
1828
1886
|
...options.insecure !== void 0 ? { insecure: options.insecure } : {},
|
|
1829
1887
|
...options.cache !== void 0 ? { cache: options.cache } : {},
|
|
1830
|
-
...options.cacheTtl !== void 0 ? { cacheTtlMs: options.cacheTtl } : {}
|
|
1888
|
+
...options.cacheTtl !== void 0 ? { cacheTtlMs: options.cacheTtl } : {},
|
|
1889
|
+
...options.timeout !== void 0 ? { timeoutMs: options.timeout } : {},
|
|
1890
|
+
...options.connectTimeout !== void 0 ? { connectTimeoutMs: options.connectTimeout } : {}
|
|
1831
1891
|
})
|
|
1832
1892
|
);
|
|
1833
1893
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usejourney/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"commander": "^12.1.0",
|
|
24
24
|
"tsx": "^4.21.0",
|
|
25
25
|
"undici": "^8.3.0",
|
|
26
|
-
"@usejourney/
|
|
27
|
-
"@usejourney/
|
|
28
|
-
"@usejourney/k6-adapter": "^0.1.
|
|
29
|
-
"@usejourney/
|
|
26
|
+
"@usejourney/codegen": "^0.1.5",
|
|
27
|
+
"@usejourney/core": "0.1.5",
|
|
28
|
+
"@usejourney/k6-adapter": "^0.1.5",
|
|
29
|
+
"@usejourney/postman-adapter": "^0.1.5"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/newman": "^5.3.6",
|