@primitivedotdev/cli 0.26.2 → 0.26.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.
@@ -1,64 +1,45 @@
1
- // Auto-detect proxy environment variables at CLI startup so users
2
- // behind a corporate proxy don't have to prefix every command with
3
- // `NODE_USE_ENV_PROXY=1`.
4
- //
5
- // Node 22+ ignores `HTTP_PROXY` / `HTTPS_PROXY` for the built-in
6
- // `fetch` / undici client unless `NODE_USE_ENV_PROXY=1` is set. That
7
- // turns a one-line proxy export into per-command friction: every CLI
8
- // invocation either inherits the prefix or fails with `ENETUNREACH`.
9
- //
10
- // This module is called once from `bin/run.js` before any network
11
- // initialization. If any of the standard proxy env vars are set AND
12
- // `NODE_USE_ENV_PROXY` is not already set explicitly, it sets it to
13
- // `1` for the current process and prints a one-time stderr hint so
14
- // the user knows what changed.
15
- //
16
- // An explicit `NODE_USE_ENV_PROXY` value (including `0`, `""`, etc.)
17
- // is always respected: if the user has chosen to disable proxy use
18
- // for this invocation, we don't override that choice.
1
+ //#region src/oclif/proxy-auto-detect.ts
19
2
  const PROXY_ENV_VARS = [
20
- "HTTP_PROXY",
21
- "HTTPS_PROXY",
22
- "http_proxy",
23
- "https_proxy",
3
+ "HTTP_PROXY",
4
+ "HTTPS_PROXY",
5
+ "http_proxy",
6
+ "https_proxy"
24
7
  ];
25
- // Module-level latch so the hint is printed at most once per process
26
- // even if `applyProxyAutoDetect` is called more than once (e.g. from
27
- // tests, or if a future entry point routes through it twice).
28
8
  let hintPrinted = false;
29
- // Test-only: reset the one-shot hint latch so each test case can
30
- // observe the first-call behavior independently.
31
- export function _resetHintLatchForTest() {
32
- hintPrinted = false;
9
+ function _resetHintLatchForTest() {
10
+ hintPrinted = false;
33
11
  }
34
12
  function detectProxyVars(env) {
35
- return PROXY_ENV_VARS.filter((name) => {
36
- const value = env[name];
37
- return typeof value === "string" && value.length > 0;
38
- });
13
+ return PROXY_ENV_VARS.filter((name) => {
14
+ const value = env[name];
15
+ return typeof value === "string" && value.length > 0;
16
+ });
39
17
  }
40
- export function applyProxyAutoDetect(options = {}) {
41
- const env = options.env ?? process.env;
42
- const stderr = options.stderr ?? process.stderr;
43
- const detectedVars = detectProxyVars(env);
44
- if (detectedVars.length === 0) {
45
- return { applied: false, detectedVars: [], reason: "no_proxy_env" };
46
- }
47
- // Respect any explicit `NODE_USE_ENV_PROXY` value, including `0`
48
- // or an empty string. The user has made a deliberate choice and
49
- // auto-detection must not silently override it.
50
- if (Object.hasOwn(env, "NODE_USE_ENV_PROXY")) {
51
- return {
52
- applied: false,
53
- detectedVars,
54
- reason: "node_use_env_proxy_already_set",
55
- };
56
- }
57
- env.NODE_USE_ENV_PROXY = "1";
58
- if (!hintPrinted) {
59
- hintPrinted = true;
60
- const names = detectedVars.join("/");
61
- stderr.write(`primitive: proxy detected via ${names}, NODE_USE_ENV_PROXY=1 set automatically\n`);
62
- }
63
- return { applied: true, detectedVars, reason: "applied" };
18
+ function applyProxyAutoDetect(options = {}) {
19
+ const env = options.env ?? process.env;
20
+ const stderr = options.stderr ?? process.stderr;
21
+ const detectedVars = detectProxyVars(env);
22
+ if (detectedVars.length === 0) return {
23
+ applied: false,
24
+ detectedVars: [],
25
+ reason: "no_proxy_env"
26
+ };
27
+ if (Object.hasOwn(env, "NODE_USE_ENV_PROXY")) return {
28
+ applied: false,
29
+ detectedVars,
30
+ reason: "node_use_env_proxy_already_set"
31
+ };
32
+ env.NODE_USE_ENV_PROXY = "1";
33
+ if (!hintPrinted) {
34
+ hintPrinted = true;
35
+ const names = detectedVars.join("/");
36
+ stderr.write(`primitive: proxy detected via ${names}, NODE_USE_ENV_PROXY=1 set automatically\n`);
37
+ }
38
+ return {
39
+ applied: true,
40
+ detectedVars,
41
+ reason: "applied"
42
+ };
64
43
  }
44
+ //#endregion
45
+ export { _resetHintLatchForTest, applyProxyAutoDetect };
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@primitivedotdev/cli",
3
- "version": "0.26.2",
3
+ "version": "0.26.3",
4
4
  "description": "Official Primitive CLI: deploy Primitive Functions, send and inspect mail, manage endpoints, all from the terminal. Wraps the @primitivedotdev/sdk runtime client with one-shot commands.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "files": [
8
8
  "bin",
9
- "dist",
10
- "oclif.manifest.json"
9
+ "dist"
11
10
  ],
12
11
  "bin": {
13
12
  "primitive": "./bin/run.js"
@@ -56,15 +55,14 @@
56
55
  "topicSeparator": " "
57
56
  },
58
57
  "scripts": {
59
- "build": "tsc -p tsconfig.oclif.json",
58
+ "build": "tsdown",
60
59
  "test": "vitest run",
61
60
  "test:coverage": "vitest run --coverage",
62
61
  "test:watch": "vitest",
63
62
  "typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
64
63
  "lint": "biome check --error-on-warnings src tests",
65
64
  "lint:fix": "biome check --write --error-on-warnings src tests",
66
- "prepack": "pnpm build && oclif manifest",
67
- "postpack": "shx rm -f oclif.manifest.json",
65
+ "prepack": "pnpm build",
68
66
  "prepublishOnly": "pnpm build"
69
67
  },
70
68
  "keywords": [
@@ -91,15 +89,15 @@
91
89
  "dependencies": {
92
90
  "@oclif/core": "^4.10.5",
93
91
  "@oclif/plugin-autocomplete": "^3.2.45",
94
- "@oclif/plugin-help": "^6.2.44",
95
- "@primitivedotdev/sdk": "^0.26.0"
92
+ "@oclif/plugin-help": "^6.2.44"
96
93
  },
97
94
  "devDependencies": {
98
95
  "@biomejs/biome": "^2.4.10",
96
+ "@primitivedotdev/api-core": "workspace:*",
99
97
  "@types/node": "^22.10.2",
100
98
  "@vitest/coverage-v8": "^4.1.4",
101
99
  "oclif": "^4.23.0",
102
- "shx": "^0.3.4",
100
+ "tsdown": "^0.21.10",
103
101
  "tsx": "^4.21.0",
104
102
  "typescript": "^5.7.2",
105
103
  "vite": "^8.0.8",