sim-setup 1.0.24-preview.149.1 → 1.0.24-preview.150.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 +34 -34
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6654,6 +6654,14 @@ var require_dist = __commonJS(function(exports, module) {
6654
6654
  })();
6655
6655
  });
6656
6656
 
6657
+ // ../utils/src/object.ts
6658
+ function isRecordLike(value) {
6659
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6660
+ }
6661
+ function toRecordOrNull(value) {
6662
+ return isRecordLike(value) ? value : null;
6663
+ }
6664
+
6657
6665
  // src/configuration-sources.ts
6658
6666
  import { spawnSync as spawnSync3 } from "node:child_process";
6659
6667
  import { existsSync as existsSync5, readFileSync as readFileSync5, realpathSync } from "node:fs";
@@ -6677,9 +6685,6 @@ function runSafely(runner, command, args, cwd) {
6677
6685
  return { status: null, stdout: "", stderr: "" };
6678
6686
  }
6679
6687
  }
6680
- function asRecord(value) {
6681
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
6682
- }
6683
6688
  function parseJson(value) {
6684
6689
  try {
6685
6690
  return JSON.parse(value);
@@ -6819,14 +6824,14 @@ function parseDockerInspectEnvironment(output) {
6819
6824
  return null;
6820
6825
  const candidates = [];
6821
6826
  for (const item of parsed) {
6822
- const record = asRecord(item);
6823
- const config = asRecord(record?.Config);
6827
+ const record = toRecordOrNull(item);
6828
+ const config = toRecordOrNull(record?.Config);
6824
6829
  if (!config || !Array.isArray(config.Env))
6825
6830
  continue;
6826
6831
  const values = parseEnvironmentEntries(config.Env);
6827
6832
  if (!values)
6828
6833
  continue;
6829
- const state = asRecord(record?.State);
6834
+ const state = toRecordOrNull(record?.State);
6830
6835
  candidates.push({
6831
6836
  running: state?.Running === true,
6832
6837
  created: typeof record?.Created === "string" ? record.Created : "",
@@ -6846,7 +6851,7 @@ function parseComposeProjects(output) {
6846
6851
  return null;
6847
6852
  const projects = [];
6848
6853
  for (const item of parsed) {
6849
- const record = asRecord(item);
6854
+ const record = toRecordOrNull(item);
6850
6855
  const name = record?.Name;
6851
6856
  const configFiles = record?.ConfigFiles;
6852
6857
  if (typeof name !== "string" || typeof configFiles !== "string")
@@ -6859,14 +6864,14 @@ function parseComposeProjects(output) {
6859
6864
  return projects;
6860
6865
  }
6861
6866
  function parseComposeConfigEnvironment(output) {
6862
- const parsed = asRecord(parseJson(output));
6863
- const services = asRecord(parsed?.services);
6864
- const app = asRecord(services?.simstudio);
6867
+ const parsed = toRecordOrNull(parseJson(output));
6868
+ const services = toRecordOrNull(parsed?.services);
6869
+ const app = toRecordOrNull(services?.simstudio);
6865
6870
  if (!app)
6866
6871
  return null;
6867
6872
  if (Array.isArray(app.environment))
6868
6873
  return parseEnvironmentEntries(app.environment);
6869
- const environment = asRecord(app.environment);
6874
+ const environment = toRecordOrNull(app.environment);
6870
6875
  if (!environment)
6871
6876
  return null;
6872
6877
  const values = new Map;
@@ -7172,11 +7177,11 @@ function decodeBase64(value) {
7172
7177
  return Buffer.from(value, "base64").toString("utf8");
7173
7178
  }
7174
7179
  function resourceEnvironment(kind, resource) {
7175
- const record = asRecord(resource);
7180
+ const record = toRecordOrNull(resource);
7176
7181
  if (!record)
7177
7182
  return { values: null, warning: "Kubernetes returned an invalid resource." };
7178
7183
  const values = new Map;
7179
- const data = record.data === undefined ? {} : asRecord(record.data);
7184
+ const data = record.data === undefined ? {} : toRecordOrNull(record.data);
7180
7185
  if (!data)
7181
7186
  return { values: null, warning: "Kubernetes returned invalid resource data." };
7182
7187
  for (const [key, value] of Object.entries(data)) {
@@ -7194,7 +7199,7 @@ function resourceEnvironment(kind, resource) {
7194
7199
  }
7195
7200
  }
7196
7201
  const secondaryKey = kind === "secret" ? "stringData" : "binaryData";
7197
- const secondary = record[secondaryKey] === undefined ? {} : asRecord(record[secondaryKey]);
7202
+ const secondary = record[secondaryKey] === undefined ? {} : toRecordOrNull(record[secondaryKey]);
7198
7203
  if (!secondary)
7199
7204
  return { values: null, warning: "Kubernetes returned invalid resource data." };
7200
7205
  for (const [key, value] of Object.entries(secondary)) {
@@ -7236,7 +7241,7 @@ function loadKubernetesResource(kind, name, optional, lookup) {
7236
7241
  };
7237
7242
  }
7238
7243
  function resolveKubernetesContainerEnvironment(container, lookup) {
7239
- const record = asRecord(container);
7244
+ const record = toRecordOrNull(container);
7240
7245
  if (!record)
7241
7246
  return { values: null, warning: "The app container definition is invalid." };
7242
7247
  const values = new Map;
@@ -7245,11 +7250,11 @@ function resolveKubernetesContainerEnvironment(container, lookup) {
7245
7250
  return { values: null, warning: "The app container envFrom definition is invalid." };
7246
7251
  }
7247
7252
  for (const source of envFrom) {
7248
- const sourceRecord = asRecord(source);
7253
+ const sourceRecord = toRecordOrNull(source);
7249
7254
  if (!sourceRecord)
7250
7255
  return { values: null, warning: "The app container envFrom entry is invalid." };
7251
- const secretRef = asRecord(sourceRecord.secretRef);
7252
- const configMapRef = asRecord(sourceRecord.configMapRef);
7256
+ const secretRef = toRecordOrNull(sourceRecord.secretRef);
7257
+ const configMapRef = toRecordOrNull(sourceRecord.configMapRef);
7253
7258
  const kind = secretRef ? "secret" : configMapRef ? "configmap" : null;
7254
7259
  const reference = secretRef ?? configMapRef;
7255
7260
  if (!kind || !reference || typeof reference.name !== "string") {
@@ -7270,7 +7275,7 @@ function resolveKubernetesContainerEnvironment(container, lookup) {
7270
7275
  return { values: null, warning: "The app container env definition is invalid." };
7271
7276
  }
7272
7277
  for (const entry of explicitEnv) {
7273
- const env = asRecord(entry);
7278
+ const env = toRecordOrNull(entry);
7274
7279
  if (!env || typeof env.name !== "string" || env.name === "") {
7275
7280
  return { values: null, warning: "The app container has an invalid explicit env entry." };
7276
7281
  }
@@ -7285,9 +7290,9 @@ function resolveKubernetesContainerEnvironment(container, lookup) {
7285
7290
  values.set(env.name, "");
7286
7291
  continue;
7287
7292
  }
7288
- const valueFrom = asRecord(env.valueFrom);
7289
- const secretKeyRef = asRecord(valueFrom?.secretKeyRef);
7290
- const configMapKeyRef = asRecord(valueFrom?.configMapKeyRef);
7293
+ const valueFrom = toRecordOrNull(env.valueFrom);
7294
+ const secretKeyRef = toRecordOrNull(valueFrom?.secretKeyRef);
7295
+ const configMapKeyRef = toRecordOrNull(valueFrom?.configMapKeyRef);
7291
7296
  const kind = secretKeyRef ? "secret" : configMapKeyRef ? "configmap" : null;
7292
7297
  const reference = secretKeyRef ?? configMapKeyRef;
7293
7298
  if (!kind || !reference || typeof reference.name !== "string" || typeof reference.key !== "string") {
@@ -7320,7 +7325,7 @@ function parseHelmReleases(output) {
7320
7325
  return null;
7321
7326
  const releases = [];
7322
7327
  for (const item of parsed) {
7323
- const record = asRecord(item);
7328
+ const record = toRecordOrNull(item);
7324
7329
  if (typeof record?.name !== "string" || typeof record.namespace !== "string" || typeof record.chart !== "string") {
7325
7330
  return null;
7326
7331
  }
@@ -7380,23 +7385,23 @@ function discoverHelmReleases(runner, root) {
7380
7385
  sources.push(helmUnknown(release, context, `Cannot read the app Deployment in namespace "${release.namespace}"; verify kubectl access to the current context.`));
7381
7386
  continue;
7382
7387
  }
7383
- const deploymentList = asRecord(parseJson(deploymentResult.stdout));
7388
+ const deploymentList = toRecordOrNull(parseJson(deploymentResult.stdout));
7384
7389
  const items = deploymentList?.items;
7385
7390
  const itemCount = Array.isArray(items) ? items.length : null;
7386
7391
  if (!Array.isArray(items) || items.length !== 1) {
7387
7392
  sources.push(helmUnknown(release, context, itemCount === 0 ? "No app Deployment matched the Sim instance/component labels." : "More than one app Deployment matched the Sim instance/component labels."));
7388
7393
  continue;
7389
7394
  }
7390
- const deployment = asRecord(items[0]);
7391
- const spec = asRecord(deployment?.spec);
7392
- const template = asRecord(spec?.template);
7393
- const podSpec = asRecord(template?.spec);
7395
+ const deployment = toRecordOrNull(items[0]);
7396
+ const spec = toRecordOrNull(deployment?.spec);
7397
+ const template = toRecordOrNull(spec?.template);
7398
+ const podSpec = toRecordOrNull(template?.spec);
7394
7399
  const containers = podSpec?.containers;
7395
7400
  if (!Array.isArray(containers)) {
7396
7401
  sources.push(helmUnknown(release, context, "The app Deployment has no readable containers list."));
7397
7402
  continue;
7398
7403
  }
7399
- const appContainer = containers.find((container) => asRecord(container)?.name === "app");
7404
+ const appContainer = containers.find((container) => toRecordOrNull(container)?.name === "app");
7400
7405
  if (!appContainer) {
7401
7406
  sources.push(helmUnknown(release, context, 'The app Deployment has no container named "app".'));
7402
7407
  continue;
@@ -10503,11 +10508,6 @@ function generateSecureToken(byteLength = 24) {
10503
10508
  }
10504
10509
  var init_tokens = () => {};
10505
10510
 
10506
- // ../utils/src/object.ts
10507
- function isRecordLike(value) {
10508
- return typeof value === "object" && value !== null && !Array.isArray(value);
10509
- }
10510
-
10511
10511
  // ../utils/src/retry.ts
10512
10512
  function parseRetryAfter(header, maxMs = RETRY_AFTER_MAX_MS) {
10513
10513
  if (!header)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim-setup",
3
- "version": "1.0.24-preview.149.1",
3
+ "version": "1.0.24-preview.150.1",
4
4
  "description": "Set up and manage a self-hosted Sim installation",
5
5
  "type": "module",
6
6
  "bin": {