@usejourney/cli 0.1.4 → 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 +63 -22
- 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,9 +583,12 @@ 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
|
});
|
|
@@ -702,10 +729,10 @@ function formatArgs(args) {
|
|
|
702
729
|
// src/server/runner.ts
|
|
703
730
|
async function runJourneyFile(opts) {
|
|
704
731
|
const abs = isAbsolute5(opts.file) ? opts.file : opts.file.includes("/") || opts.file.includes("\\") ? resolve5(process.cwd(), opts.file) : join6(opts.journeysDir, opts.file);
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
}
|
|
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
|
+
});
|
|
709
736
|
clearActiveEnvironment3();
|
|
710
737
|
const envName = opts.env ?? opts.loaded.config.defaultEnvironment;
|
|
711
738
|
if (envName) {
|
|
@@ -1197,13 +1224,13 @@ var PATCHABLE_CONFIG_KEYS = ["tlsRejectUnauthorized"];
|
|
|
1197
1224
|
async function patchProjectConfig(projectDir, patch) {
|
|
1198
1225
|
const configPath = join9(projectDir, "journey.config.json");
|
|
1199
1226
|
const raw = await readFile2(configPath, "utf8");
|
|
1200
|
-
const
|
|
1227
|
+
const current2 = JSON.parse(raw);
|
|
1201
1228
|
for (const key of Object.keys(patch)) {
|
|
1202
1229
|
if (!PATCHABLE_CONFIG_KEYS.includes(key)) {
|
|
1203
1230
|
throw new Error(`config key "${key}" is not patchable via the API`);
|
|
1204
1231
|
}
|
|
1205
1232
|
}
|
|
1206
|
-
const merged = { ...
|
|
1233
|
+
const merged = { ...current2 };
|
|
1207
1234
|
for (const key of PATCHABLE_CONFIG_KEYS) {
|
|
1208
1235
|
if (Object.prototype.hasOwnProperty.call(patch, key)) {
|
|
1209
1236
|
merged[key] = patch[key];
|
|
@@ -1685,7 +1712,11 @@ async function startServer(opts) {
|
|
|
1685
1712
|
|
|
1686
1713
|
// src/commands/serve.ts
|
|
1687
1714
|
async function runServe(opts) {
|
|
1688
|
-
|
|
1715
|
+
setDispatcherDefaults({
|
|
1716
|
+
...opts.insecure !== void 0 ? { insecure: opts.insecure } : {},
|
|
1717
|
+
...opts.connectTimeoutMs !== void 0 ? { connectTimeoutMs: opts.connectTimeoutMs } : {}
|
|
1718
|
+
});
|
|
1719
|
+
await configureDispatcher({});
|
|
1689
1720
|
const srv = await startServer({
|
|
1690
1721
|
projectDir: opts.projectDir,
|
|
1691
1722
|
...opts.host !== void 0 ? { host: opts.host } : {},
|
|
@@ -1754,6 +1785,10 @@ function buildProgram() {
|
|
|
1754
1785
|
"--timeout <ms>",
|
|
1755
1786
|
"Request timeout in ms; 0 disables (default 60000)",
|
|
1756
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)
|
|
1757
1792
|
).description("Run one or more journeys (or --all)").action(
|
|
1758
1793
|
(files, options) => handle(
|
|
1759
1794
|
() => runCommand({
|
|
@@ -1766,7 +1801,8 @@ function buildProgram() {
|
|
|
1766
1801
|
...options.insecure !== void 0 ? { insecure: options.insecure } : {},
|
|
1767
1802
|
...options.cache !== void 0 ? { cache: options.cache } : {},
|
|
1768
1803
|
...options.cacheTtl !== void 0 ? { cacheTtlMs: options.cacheTtl } : {},
|
|
1769
|
-
...options.timeout !== void 0 ? { timeoutMs: options.timeout } : {}
|
|
1804
|
+
...options.timeout !== void 0 ? { timeoutMs: options.timeout } : {},
|
|
1805
|
+
...options.connectTimeout !== void 0 ? { connectTimeoutMs: options.connectTimeout } : {}
|
|
1770
1806
|
})
|
|
1771
1807
|
)
|
|
1772
1808
|
);
|
|
@@ -1834,6 +1870,10 @@ function buildProgram() {
|
|
|
1834
1870
|
"--timeout <ms>",
|
|
1835
1871
|
"Request timeout in ms for journey runs triggered via the API; 0 disables (default 60000)",
|
|
1836
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)
|
|
1837
1877
|
).description("Run the GUI backend API for the current project").action(
|
|
1838
1878
|
(options) => {
|
|
1839
1879
|
const projectDir = options.project ? resolvePath(process.cwd(), options.project) : process.cwd();
|
|
@@ -1846,7 +1886,8 @@ function buildProgram() {
|
|
|
1846
1886
|
...options.insecure !== void 0 ? { insecure: options.insecure } : {},
|
|
1847
1887
|
...options.cache !== void 0 ? { cache: options.cache } : {},
|
|
1848
1888
|
...options.cacheTtl !== void 0 ? { cacheTtlMs: options.cacheTtl } : {},
|
|
1849
|
-
...options.timeout !== void 0 ? { timeoutMs: options.timeout } : {}
|
|
1889
|
+
...options.timeout !== void 0 ? { timeoutMs: options.timeout } : {},
|
|
1890
|
+
...options.connectTimeout !== void 0 ? { connectTimeoutMs: options.connectTimeout } : {}
|
|
1850
1891
|
})
|
|
1851
1892
|
);
|
|
1852
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/codegen": "^0.1.
|
|
27
|
-
"@usejourney/core": "0.1.
|
|
28
|
-
"@usejourney/k6-adapter": "^0.1.
|
|
29
|
-
"@usejourney/postman-adapter": "^0.1.
|
|
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",
|