sim 2.1.4-dev.56.1 → 2.1.4-dev.57.1

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2701,14 +2701,22 @@ function resolveProfile(overrides = {}) {
2701
2701
  // src/version.ts
2702
2702
  import { readFileSync as readFileSync2 } from "node:fs";
2703
2703
  function readPackageVersion() {
2704
- const metadata = JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf8"));
2705
- if (typeof metadata !== "object" || metadata === null || !("version" in metadata) || typeof metadata.version !== "string") {
2706
- throw new Error("CLI package metadata is missing a valid version");
2707
- }
2708
- return metadata.version;
2704
+ try {
2705
+ const metadata = JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf8"));
2706
+ if (typeof metadata === "object" && metadata !== null && "version" in metadata && typeof metadata.version === "string") {
2707
+ return metadata.version;
2708
+ }
2709
+ } catch {}
2710
+ return "0.0.0-embedded";
2711
+ }
2712
+ var cachedVersion = null;
2713
+ function cliVersion() {
2714
+ cachedVersion ??= readPackageVersion();
2715
+ return cachedVersion;
2716
+ }
2717
+ function userAgent() {
2718
+ return `sim-cli/${cliVersion()} node/${process.versions.node} (${process.platform}; ${process.arch})`;
2709
2719
  }
2710
- var CLI_VERSION = readPackageVersion();
2711
- var USER_AGENT = `sim-cli/${CLI_VERSION} node/${process.versions.node} (${process.platform}; ${process.arch})`;
2712
2720
 
2713
2721
  // src/http/environment.ts
2714
2722
  var reported = new Set;
@@ -2991,7 +2999,7 @@ class SimClient {
2991
2999
  headers: {
2992
3000
  ...apiKey ? { "x-api-key": apiKey } : {},
2993
3001
  accept: "application/json",
2994
- "user-agent": USER_AGENT,
3002
+ "user-agent": userAgent(),
2995
3003
  ...hasBody ? { "content-type": "application/json" } : {},
2996
3004
  ...options.headers
2997
3005
  },
@@ -6490,7 +6498,7 @@ async function pollForKey(endpoint, auth, signal) {
6490
6498
  headers: {
6491
6499
  "content-type": "application/json",
6492
6500
  accept: "application/json",
6493
- "user-agent": USER_AGENT
6501
+ "user-agent": userAgent()
6494
6502
  },
6495
6503
  body: JSON.stringify({ request: auth.request, verifier: auth.pollSecret }),
6496
6504
  signal,
@@ -16361,7 +16369,7 @@ function addVersionOption(program2) {
16361
16369
  }
16362
16370
  program2.error("error: --version reports the Sim CLI version and takes no value. A command that acts on a deployment version reads it from --to-version.");
16363
16371
  });
16364
- program2.version(CLI_VERSION, "-V, --version [none]", "output the version number (takes no value)");
16372
+ program2.version(cliVersion(), "-V, --version [none]", "output the version number (takes no value)");
16365
16373
  }
16366
16374
  function buildProgram(options = {}) {
16367
16375
  const program2 = new Command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim",
3
- "version": "2.1.4-dev.56.1",
3
+ "version": "2.1.4-dev.57.1",
4
4
  "description": "Sim CLI - talk to the Sim API from your terminal",
5
5
  "type": "module",
6
6
  "bin": {