CodeSampleX

Exemple

electron-updater 6.8.9: AppUpdater

Échantillon vérifié pour npm electron-updater 6.8.9: AppUpdater. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.

sha256:4a5a16d60c648631f22caaefcb4fb516ce9f7a44d45bd1d50bbc1cce21c7365b

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-26

Cas

HOW
Objectif
verify AppUpdater in pkg:npm/electron-updater@6.8.9
Paquets
Symboles
  • AppUpdater
Environnement
node 22.23.2
Créé
2026-08-26T10:50:14Z

Contrat

  1. AppUpdater is exported as a class constructor with subclasses inheriting from it
  2. AppUpdater manages channel, autoDownload, autoInstallOnAppQuit, allowPrerelease, allowDowngrade, and auth headers
  3. AppUpdater dispatches error events via dispatchError
  4. AppUpdater checks for updates against HTTP feed and emits checking-for-update and update-available
  5. AppUpdater downloads update payload and emits DOWNLOAD_PROGRESS and UPDATE_DOWNLOADED
  6. AppUpdater emits update-not-available when current version is already up to date
  7. CancellationToken integrates with update operations to handle cancellation
  8. NoOpLogger provides info, warn, and error logging methods

Fichiers

  • PROMPT.md
  • csx.json
  • index.js
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.js

Télécharger l’artefact source (tar.gz)

Code source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify AppUpdater in pkg:npm/electron-updater@6.8.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/electron-updater@6.8.9
Demonstrate these symbols/APIs:
  - AppUpdater

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:61a9be6187c92e59641fe38b2765312ba8c808e16b2a94d04d311c257158162a","contract":["AppUpdater is exported as a class constructor with subclasses inheriting from it","AppUpdater manages channel, autoDownload, autoInstallOnAppQuit, allowPrerelease, allowDowngrade, and auth headers","AppUpdater dispatches error events via dispatchError","AppUpdater checks for updates against HTTP feed and emits checking-for-update and update-available","AppUpdater downloads update payload and emits DOWNLOAD_PROGRESS and UPDATE_DOWNLOADED","AppUpdater emits update-not-available when current version is already up to date","CancellationToken integrates with update operations to handle cancellation","NoOpLogger provides info, warn, and error logging methods"],"goal":"verify AppUpdater in pkg:npm/electron-updater@6.8.9","kind":"HOW","packages":["pkg:npm/electron-updater@6.8.9"],"schemaVersion":1,"symbols":["AppUpdater"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/electron-updater@6.8.9"],"schemaVersion":1,"subject":"pkg:npm/electron-updater@6.8.9","symbols":["AppUpdater"],"verifierAdapter":"node-typescript@1"}
index.js
const http = require("http");
const {
  AppUpdater,
  NsisUpdater,
  AppImageUpdater,
  DebUpdater,
  RpmUpdater,
  PacmanUpdater,
  MacUpdater,
  BaseUpdater,
  NoOpLogger,
  CancellationToken,
  DOWNLOAD_PROGRESS,
  UPDATE_DOWNLOADED,
} = require("electron-updater");
const { HttpExecutor, configureRequestUrl, configureRequestOptions } = require("builder-util-runtime");

class NodeHttpExecutor extends HttpExecutor {
  async download(url, destination, options) {
    return await options.cancellationToken.createPromise((resolve, reject, onCancel) => {
      const requestOptions = {
        headers: options.headers || undefined,
        redirect: "manual",
      };
      configureRequestUrl(url, requestOptions);
      configureRequestOptions(requestOptions);
      this.doDownload(
        requestOptions,
        {
          destination,
          options,
          onCancel,
          callback: (error) => {
            if (error == null) {
              resolve(destination);
            } else {
              reject(error);
            }
          },
          responseHandler: null,
        },
        0
      );
    });
  }

  createRequest(options, callback) {
    return http.request(options, callback);
  }
}

class StandaloneAppAdapter {
  constructor(options = {}) {
    this.version = options.version || "1.0.0";
    this.name = options.name || "contract-updater-app";
    this.isPackaged = options.isPackaged !== undefined ? options.isPackaged : true;
    this.appUpdateConfigPath = options.appUpdateConfigPath || "";
    this.userDataPath = options.userDataPath || "";
    this.baseCachePath = options.baseCachePath || "";
    this._quitHandlers = [];
  }

  async whenReady() {}

  relaunch() {}

  quit() {
    for (const handler of this._quitHandlers) {
      handler(0);
    }
  }

  onQuit(handler) {
    this._quitHandlers.push(handler);
  }
}

function createConfiguredUpdater(UpdaterClass, appAdapter, updateUrl) {
  const updater = new UpdaterClass(null, appAdapter);
  updater.httpExecutor = new NodeHttpExecutor();
  if (updateUrl) {
    updater.setFeedURL({
      provider: "generic",
      url: updateUrl,
    });
  }
  updater.logger = new NoOpLogger();
  updater.autoDownload = false;
  return updater;
}

module.exports = {
  AppUpdater,
  NsisUpdater,
  AppImageUpdater,
  DebUpdater,
  RpmUpdater,
  PacmanUpdater,
  MacUpdater,
  BaseUpdater,
  NoOpLogger,
  CancellationToken,
  DOWNLOAD_PROGRESS,
  UPDATE_DOWNLOADED,
  NodeHttpExecutor,
  StandaloneAppAdapter,
  createConfiguredUpdater,
};
package-lock.json
{
  "name": "electron-updater-appupdater-contract",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "electron-updater-appupdater-contract",
      "version": "1.0.0",
      "dependencies": {
        "electron-updater": "6.8.9"
      }
    },
    "node_modules/argparse": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
      "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
      "license": "Python-2.0"
    },
    "node_modules/builder-util-runtime": {
      "version": "9.7.0",
      "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.7.0.tgz",
      "integrity": "sha512-g/kR520giAFYkSXTzcmF3kqQq7wi8F6N6SzeDgZrqTBN+VHdmgWOyTdD1yD7AATDId/yXLvuP34CxW46/BwCdw==",
      "license": "MIT",
      "dependencies": {
        "debug": "^4.3.4",
        "sax": "^1.2.4"
      },
      "engines": {
        "node": ">=12.0.0"
      }
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/electron-updater": {
      "version": "6.8.9",
      "resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-6.8.9.tgz",
      "integrity": "sha512-ZhVxM9iGONUpZGI1FxdMRgJjUFXi7AYGVa5PwKlO1tV1/4zDxQmfKpXOHVztKrd6L9rLcFjERvi1Mf2vxyTkig==",
      "license": "MIT",
      "dependencies": {
        "builder-util-runtime": "9.7.0",
        "fs-extra": "^10.1.0",
        "js-yaml": "^4.1.0",
        "lazy-val": "^1.0.5",
        "lodash.escaperegexp": "^4.1.2",
        "lodash.isequal": "^4.5.0",
        "semver": "~7.7.3",
        "tiny-typed-emitter": "^2.1.0"
      }
    },
    "node_modules/fs-extra": {
      "version": "10.1.0",
      "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
      "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
      "license": "MIT",
      "dependencies": {
        "graceful-fs": "^4.2.0",
        "jsonfile": "^6.0.1",
        "universalify": "^2.0.0"
      },
      "engines": {
        "node": ">=12"
      }
    },
    "node_modules/graceful-fs": {
      "version": "4.2.11",
      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
      "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
      "license": "ISC"
    },
    "node_modules/js-yaml": {
      "version": "4.3.1",
      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz",
      "integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/puzrin"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/nodeca"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "argparse": "^2.0.1"
      },
      "bin": {
        "js-yaml": "bin/js-yaml.js"
      }
    },
    "node_modules/jsonfile": {
      "version": "6.2.1",
      "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz",
      "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==",
      "license": "MIT",
      "dependencies": {
        "universalify": "^2.0.0"
      },
      "optionalDependencies": {
        "graceful-fs": "^4.1.6"
      }
    },
    "node_modules/lazy-val": {
      "version": "1.0.5",
      "resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.5.tgz",
      "integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==",
      "license": "MIT"
    },
    "node_modules/lodash.escaperegexp": {
      "version": "4.1.2",
      "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz",
      "integrity": "sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw==",
      "license": "MIT"
    },
    "node_modules/lodash.isequal": {
      "version": "4.5.0",
      "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
      "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==",
      "deprecated": "This package is deprecated. Use require('node:util').isDeepStrictEqual instead.",
      "license": "MIT"
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    },
    "node_modules/sax": {
      "version": "1.6.1",
      "resolved": "https://registry.npmjs.org/sax/-/sax-1.6.1.tgz",
      "integrity": "sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==",
      "license": "BlueOak-1.0.0",
      "engines": {
        "node": ">=11.0.0"
      }
    },
    "node_modules/semver": {
      "version": "7.7.4",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
      "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver.js"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/tiny-typed-emitter": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz",
      "integrity": "sha512-qVtvMxeXbVej0cQWKqVSSAHmKZEHAvxdF8HEUBFWts8h+xEo5m/lEiPakuyZ3BnCBjOD8i24kzNOiOLLgsSxhA==",
      "license": "MIT"
    },
    "node_modules/universalify": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
      "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
      "license": "MIT",
      "engines": {
        "node": ">= 10.0.0"
      }
    }
  }
}
package.json
{
  "name": "electron-updater-appupdater-contract",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for electron-updater AppUpdater",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "electron-updater": "6.8.9"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify AppUpdater in pkg:npm/electron-updater@6.8.9",
  "kind": "HOW",
  "packages": [
    "pkg:npm/electron-updater@6.8.9"
  ],
  "symbols": [
    "AppUpdater"
  ]
}
test/contract.js
const assert = require("assert");
const http = require("http");
const path = require("path");
const os = require("os");
const fs = require("fs");
const crypto = require("crypto");
const {
  AppUpdater,
  NsisUpdater,
  AppImageUpdater,
  DebUpdater,
  RpmUpdater,
  PacmanUpdater,
  MacUpdater,
  BaseUpdater,
  NoOpLogger,
  CancellationToken,
  DOWNLOAD_PROGRESS,
  UPDATE_DOWNLOADED,
  StandaloneAppAdapter,
  createConfiguredUpdater,
} = require("../index.js");

async function main() {
  // 1. AppUpdater class and inheritance contract
  assert.strictEqual(typeof AppUpdater, "function", "AppUpdater must be a class constructor");
  assert(NsisUpdater.prototype instanceof AppUpdater, "NsisUpdater must inherit from AppUpdater");
  assert(AppImageUpdater.prototype instanceof AppUpdater, "AppImageUpdater must inherit from AppUpdater");
  assert(DebUpdater.prototype instanceof AppUpdater, "DebUpdater must inherit from AppUpdater");
  assert(RpmUpdater.prototype instanceof AppUpdater, "RpmUpdater must inherit from AppUpdater");
  assert(PacmanUpdater.prototype instanceof AppUpdater, "PacmanUpdater must inherit from AppUpdater");
  assert(MacUpdater.prototype instanceof AppUpdater, "MacUpdater must inherit from AppUpdater");
  assert(BaseUpdater.prototype instanceof AppUpdater, "BaseUpdater must inherit from AppUpdater");

  // 2. Setup temporary paths for offline app adapter
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "electron-updater-contract-"));
  const userDataDir = path.join(tempDir, "userData");
  const cacheDir = path.join(tempDir, "cache");
  const configPath = path.join(tempDir, "app-update.yml");
  fs.mkdirSync(userDataDir, { recursive: true });
  fs.mkdirSync(cacheDir, { recursive: true });
  fs.writeFileSync(configPath, "provider: generic\n");

  const appAdapter = new StandaloneAppAdapter({
    version: "1.0.0",
    name: "contract-updater-app",
    isPackaged: true,
    appUpdateConfigPath: configPath,
    userDataPath: userDataDir,
    baseCachePath: cacheDir,
  });

  // 3. Mock HTTP update server (offline localhost)
  const installerPayload = Buffer.from("contract-test-installer-binary-data");
  const installerSha512 = crypto.createHash("sha512").update(installerPayload).digest("base64");
  let serverMode = "available";

  const server = http.createServer((req, res) => {
    if (req.url.includes(".yml")) {
      if (serverMode === "available") {
        const ymlContent = `version: 1.2.0
files:
  - url: test-app-setup-1.2.0.exe
    sha512: ${installerSha512}
    size: ${installerPayload.length}
path: test-app-setup-1.2.0.exe
sha512: ${installerSha512}
releaseDate: 2026-01-01T00:00:00.000Z
`;
        res.writeHead(200, { "Content-Type": "text/yaml" });
        res.end(ymlContent);
      } else {
        const ymlContent = `version: 1.0.0
files:
  - url: test-app-setup-1.0.0.exe
    sha512: ${installerSha512}
    size: ${installerPayload.length}
path: test-app-setup-1.0.0.exe
sha512: ${installerSha512}
releaseDate: 2026-01-01T00:00:00.000Z
`;
        res.writeHead(200, { "Content-Type": "text/yaml" });
        res.end(ymlContent);
      }
    } else if (req.url.includes("test-app-setup-1.2.0.exe")) {
      res.writeHead(200, {
        "Content-Type": "application/octet-stream",
        "Content-Length": installerPayload.length,
      });
      res.end(installerPayload);
    } else {
      res.writeHead(404);
      res.end();
    }
  });

  await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
  const serverPort = server.address().port;
  const feedUrl = `http://127.0.0.1:${serverPort}`;

  try {
    // 4. AppUpdater property and configuration contract
    const updater = createConfiguredUpdater(NsisUpdater, appAdapter, feedUrl);
    updater.allowPrerelease = true;
    updater.allowDowngrade = true;
    updater.channel = "beta";
    updater.addAuthHeader("Bearer mock-test-token");

    assert.strictEqual(updater.autoDownload, false, "autoDownload should be false");
    assert.strictEqual(updater.allowPrerelease, true, "allowPrerelease should be true");
    assert.strictEqual(updater.allowDowngrade, true, "allowDowngrade should be true");
    assert.strictEqual(updater.channel, "beta", "channel should be beta");
    assert.strictEqual(updater.requestHeaders.authorization, "Bearer mock-test-token", "auth header should be set");
    assert.strictEqual(updater.getFeedURL(), "Deprecated. Do not use it.", "getFeedURL deprecation behavior");

    // 5. Error dispatching contract
    let capturedError = null;
    updater.once("error", (err) => {
      capturedError = err;
    });
    updater.dispatchError(new Error("contract test error"));
    assert(capturedError && capturedError.message === "contract test error", "dispatchError should emit error event");

    // 6. Check for updates (update available)
    let checkingEmitted = false;
    let availableInfo = null;
    updater.on("checking-for-update", () => {
      checkingEmitted = true;
    });
    updater.on("update-available", (info) => {
      availableInfo = info;
    });

    const checkResult = await updater.checkForUpdates();
    assert(checkResult, "checkForUpdates result should exist");
    assert.strictEqual(checkResult.updateInfo.version, "1.2.0", "update version should be 1.2.0");
    assert.strictEqual(checkingEmitted, true, "checking-for-update event should have fired");
    assert(availableInfo, "update-available event should have fired");
    assert.strictEqual(availableInfo.version, "1.2.0", "availableInfo version should match");

    // 7. Download update contract
    let progressFired = false;
    let downloadedInfo = null;
    updater.on(DOWNLOAD_PROGRESS, (progress) => {
      progressFired = true;
      assert(progress.percent >= 0 && progress.percent <= 100, "progress percent should be between 0 and 100");
    });
    updater.on(UPDATE_DOWNLOADED, (info) => {
      downloadedInfo = info;
    });

    const downloadedFiles = await updater.downloadUpdate();
    assert(Array.isArray(downloadedFiles) && downloadedFiles.length > 0, "downloadedFiles should be a non-empty array");
    assert.strictEqual(progressFired, true, "DOWNLOAD_PROGRESS event should have fired");
    assert(downloadedInfo, "UPDATE_DOWNLOADED event should have fired");
    assert.strictEqual(downloadedInfo.version, "1.2.0", "downloadedInfo version should match 1.2.0");

    const downloadedFilePath = downloadedFiles[0];
    assert(fs.existsSync(downloadedFilePath), "downloaded file should exist on disk");
    const downloadedContent = fs.readFileSync(downloadedFilePath);
    assert.deepStrictEqual(downloadedContent, installerPayload, "downloaded content should match payload exactly");

    // 8. Check for updates (update not available)
    serverMode = "not-available";
    let notAvailableInfo = null;
    updater.on("update-not-available", (info) => {
      notAvailableInfo = info;
    });

    const notAvailableResult = await updater.checkForUpdates();
    assert(notAvailableResult, "notAvailableResult should exist");
    assert.strictEqual(notAvailableResult.updateInfo.version, "1.0.0", "version should be 1.0.0");
    assert(notAvailableInfo, "update-not-available event should have fired");
    assert.strictEqual(notAvailableInfo.version, "1.0.0", "notAvailableInfo version should match 1.0.0");

    // 9. CancellationToken contract
    const token = new CancellationToken();
    assert.strictEqual(token.cancelled, false, "token should not be cancelled initially");
    token.cancel();
    assert.strictEqual(token.cancelled, true, "token should be cancelled after cancel()");

    // 10. NoOpLogger contract
    const logger = new NoOpLogger();
    assert.strictEqual(typeof logger.info, "function", "logger.info should be a function");
    assert.strictEqual(typeof logger.warn, "function", "logger.warn should be a function");
    assert.strictEqual(typeof logger.error, "function", "logger.error should be a function");

    console.log("AppUpdater contract verified successfully.");
  } finally {
    server.close();
    fs.rmSync(tempDir, { recursive: true, force: true });
  }
}

main().catch((err) => {
  console.error("Contract test failed:", err);
  process.exit(1);
});

Seeder d'origine

anonyme