@muggleai/works 5.24.0-staging.172 → 5.24.0-staging.174

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.
@@ -9,7 +9,7 @@
9
9
  "name": "muggleai",
10
10
  "source": "./plugin",
11
11
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
12
- "version": "5.24.0-staging.172"
12
+ "version": "5.24.0-staging.174"
13
13
  }
14
14
  ]
15
15
  }
@@ -1,4 +1,4 @@
1
- import { __export, getLogger, getConfig, createChildLogger, buildElectronAppReleaseAssetUrl, getActiveRuntimeTarget, getAuthService, hasApiKey, getElectronAppVersion, getElectronAppDir, getPlatformKey, reconcileProjectPreferences, getDataDir, PREFERENCES_FILE_NAME, isFirstRun, writePreferences, DEFAULT_PREFERENCES, isElectronAppInstalled, getElectronAppChecksums, getChecksumForPlatform, getElectronAppSignedFromVersion, getReleaseSignerIdentityUri, verifyFileChecksum, resolveElectronAppExecutablePath, calculateFileChecksum, initTelemetry, Surface, ServiceName, track, EventName, getQaTools, getLocalQaTools, performLogout, assertDeviceCodeClientProvisioned, performLogin, toolRequiresAuth, getCallerCredentials, getElectronAppReleaseTagPrefix, hasShownDisclosure, markDisclosureShown, getBundledElectronAppVersion, getElectronAppVersionSource, getCredentialsFilePath, buildElectronAppChecksumsUrl, __require, getDisclosureCopy, buildOnboardingPlan, applyOnboardingAnswers, needsOnboarding, readRunView, RunViewError, renderRunViewText, writeRunViewHtml, openBrowserUrl, OnboardingBlanketChoice, PreferenceKey, resolvePreferences } from './chunk-CKBHCCAM.js';
1
+ import { __export, getLogger, getConfig, createChildLogger, buildElectronAppReleaseAssetUrl, getActiveRuntimeTarget, getAuthService, hasApiKey, getElectronAppVersion, getElectronAppDir, getPlatformKey, reconcileProjectPreferences, getDataDir, PREFERENCES_FILE_NAME, isFirstRun, writePreferences, DEFAULT_PREFERENCES, isElectronAppInstalled, getElectronAppChecksums, getChecksumForPlatform, getElectronAppSignedFromVersion, getReleaseSignerIdentityUri, verifyFileChecksum, resolveElectronAppExecutablePath, calculateFileChecksum, initTelemetry, Surface, ServiceName, track, EventName, getQaTools, getLocalQaTools, performLogout, assertDeviceCodeClientProvisioned, performLogin, toolRequiresAuth, getCallerCredentials, getElectronAppReleaseTagPrefix, hasShownDisclosure, markDisclosureShown, getBundledElectronAppVersion, getElectronAppVersionSource, getCredentialsFilePath, buildElectronAppChecksumsUrl, __require, getDisclosureCopy, buildOnboardingPlan, applyOnboardingAnswers, needsOnboarding, readRunView, RunViewError, renderRunViewText, writeRunViewHtml, openBrowserUrl, OnboardingBlanketChoice, PreferenceKey, resolvePreferences } from './chunk-NOID65AF.js';
2
2
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
3
  import { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema } from '@modelcontextprotocol/sdk/types.js';
4
4
  import { v4 } from 'uuid';
@@ -1042,7 +1042,7 @@ async function resolveGsScreenshotUrls(report, opts) {
1042
1042
  if (gsUrls.length === 0) {
1043
1043
  return report;
1044
1044
  }
1045
- const mcps = await import('./src-RGG3V3ZX.js');
1045
+ const mcps = await import('./src-LD2BVJE4.js');
1046
1046
  const credentials = await mcps.getCallerCredentialsAsync();
1047
1047
  if (!credentials.bearerToken && !credentials.apiKey) {
1048
1048
  stderrWrite(
@@ -158,10 +158,10 @@ var RuntimeTarget = /* @__PURE__ */ ((RuntimeTarget2) => {
158
158
  RuntimeTarget2["Dev"] = "dev";
159
159
  return RuntimeTarget2;
160
160
  })(RuntimeTarget || {});
161
- var ElectronAppReleaseStream = /* @__PURE__ */ ((ElectronAppReleaseStream3) => {
162
- ElectronAppReleaseStream3["Production"] = "production";
163
- ElectronAppReleaseStream3["Staging"] = "staging";
164
- return ElectronAppReleaseStream3;
161
+ var ElectronAppReleaseStream = /* @__PURE__ */ ((ElectronAppReleaseStream4) => {
162
+ ElectronAppReleaseStream4["Production"] = "production";
163
+ ElectronAppReleaseStream4["Staging"] = "staging";
164
+ return ElectronAppReleaseStream4;
165
165
  })(ElectronAppReleaseStream || {});
166
166
  var DEFAULT_AUTH0_SCOPE = "openid profile email offline_access";
167
167
  var DEFAULT_WEB_SERVICE_URL = "http://localhost:3001";
@@ -292,6 +292,14 @@ function resolveElectronAppExecutablePath(params) {
292
292
  }
293
293
  return path15.join(params.installDir, ...ELECTRON_APP_EXECUTABLE_PATH_SEGMENTS[params.platformName]);
294
294
  }
295
+
296
+ // packages/mcps/src/shared/electron-app-install-dir.ts
297
+ function buildElectronAppDirName(params) {
298
+ if (params.releaseStream === "production" /* Production */) {
299
+ return params.version;
300
+ }
301
+ return `${params.version}-${params.releaseStream}`;
302
+ }
295
303
  var DEV_MANIFEST = {
296
304
  release: "dev",
297
305
  buildId: "dev",
@@ -422,12 +430,6 @@ function getMuggleConfig() {
422
430
  function getDataDir2() {
423
431
  return getDataDir();
424
432
  }
425
- function buildElectronAppDirName(params) {
426
- if (params.releaseStream === "production" /* Production */) {
427
- return params.version;
428
- }
429
- return `${params.version}-${params.releaseStream}`;
430
- }
431
433
  function buildOAuthSessionFileName(params) {
432
434
  if (params.runtimeTarget === "production" /* Production */) {
433
435
  return OAUTH_SESSION_FILE;
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { runCli } from './chunk-YQAYCH3I.js';
3
- import './chunk-CKBHCCAM.js';
2
+ import { runCli } from './chunk-5ZCT7BYF.js';
3
+ import './chunk-NOID65AF.js';
4
4
 
5
5
  // src/cli/main.ts
6
6
  runCli().catch((error) => {
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { src_exports as commands, createUnifiedMcpServer, server_exports as server } from './chunk-YQAYCH3I.js';
2
- export { createChildLogger, e2e_exports as e2e, getConfig, getLocalQaTools, getLogger, getQaTools, local_exports as localQa, mcp_exports as mcp, e2e_exports as qa, src_exports as shared } from './chunk-CKBHCCAM.js';
1
+ export { src_exports as commands, createUnifiedMcpServer, server_exports as server } from './chunk-5ZCT7BYF.js';
2
+ export { createChildLogger, e2e_exports as e2e, getConfig, getLocalQaTools, getLogger, getQaTools, local_exports as localQa, mcp_exports as mcp, e2e_exports as qa, src_exports as shared } from './chunk-NOID65AF.js';
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "muggle",
3
3
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
4
- "version": "5.24.0-staging.172",
4
+ "version": "5.24.0-staging.174",
5
5
  "author": {
6
6
  "name": "Muggle AI",
7
7
  "email": "support@muggle-ai.com"
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.24.0-staging.172",
7
+ "@muggleai/works@5.24.0-staging.174",
8
8
  "serve"
9
9
  ],
10
10
  "env": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muggle",
3
- "version": "5.24.0-staging.172",
3
+ "version": "5.24.0-staging.174",
4
4
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
5
5
  "author": {
6
6
  "name": "Muggle AI",
@@ -2,7 +2,7 @@
2
2
  "name": "muggle",
3
3
  "displayName": "Muggle AI",
4
4
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
5
- "version": "5.24.0-staging.172",
5
+ "version": "5.24.0-staging.174",
6
6
  "author": {
7
7
  "name": "Muggle AI",
8
8
  "email": "support@muggle-ai.com"
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.24.0-staging.172",
7
+ "@muggleai/works@5.24.0-staging.174",
8
8
  "serve"
9
9
  ]
10
10
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "release": "5.18.0",
3
- "buildId": "run-172-1",
4
- "commitSha": "c36aaa0dd147d46f8d8bd2ae3cb16b6208e6d0a6",
5
- "buildTime": "2026-10-22T23:48:10Z",
3
+ "buildId": "run-174-1",
4
+ "commitSha": "7892a8736b1a82beb30d166005cd9c3b90dca792",
5
+ "buildTime": "2026-10-23T00:15:33Z",
6
6
  "serviceName": "muggle-ai-works-mcp"
7
7
  }
@@ -1 +1 @@
1
- export { ACTION_SCRIPT_FILE_NAME, DEFAULT_PREFERENCES, ELECTRON_APP_EXECUTABLE_PATH_SEGMENTS, ElectronAppPlatform, ElectronAppReleaseStream, HTML_VIEW_OFFER_LINE, ONBOARDING_BLANKET_OPTIONS, ONBOARDING_CHOICE_GROUPS, ONBOARDING_MAX_OFFERS, ONBOARDING_PRIMER_BULLETS, ONBOARDING_PRIMER_HEADLINE, ONBOARDING_TOGGLE_GROUPS, ONBOARDING_TOGGLE_PROMPT, ONBOARDING_UNSELECTED_TOGGLE_VALUE, OnboardingBlanketChoice, OnboardingGroupKind, PREFERENCES_FILE_NAME, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_SCHEMA, PREFERENCES_VERSION, PREFERENCE_ALLOWED_VALUES, PreferenceKey, PreferenceValue, ProjectPreferencesReconcileOutcome, RUN_SESSIONS_DIR_NAME, RUN_VIEW_DASHBOARD_LINK_LABEL, RunViewError, RuntimeTarget, SCREENSHOT_DIR_RELATIVE_PATH, SCREENSHOT_FILE_EXTENSION, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, applyOnboardingAnswers, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, buildElectronAppReleaseAssetUrl, buildElectronAppReleaseTag, buildOnboardingPlan, calculateFileChecksum, completeOnboarding, createApiKeyWithToken, createChildLogger, deleteApiKeyData, deleteCredentials, e2e_exports as e2e, formatPreferencesOneLiner, getActiveElectronAppReleaseStream, getActiveRuntimeTarget, getApiKey, getApiKeyFilePath, getAuthService, getBundledElectronAppVersion, getCallerCredentials, getCallerCredentialsAsync, getChecksumForPlatform, getConfig, getCredentialsFilePath, getDashboardBaseUrl, getDataDir, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLocalQaTools, getLogger, getOnboardingToggleKeys, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getRunSessionsDir, getValidApiKeyData, getValidCredentials, hasApiKey, isElectronAppInstalled, isElectronAppPlatform, isFirstRun, loadApiKeyData, loadCredentials, local_exports as localQa, markOnboardingCompleted, mcp_exports as mcp, needsOnboarding, openBrowserUrl, performLogin, performLogout, pollDeviceCode, e2e_exports as qa, readPreferencesMetadata, readRunView, reconcileProjectPreferences, recordOnboardingSkip, renderRunViewHtml, renderRunViewText, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveBlanketPreferences, resolveElectronAppExecutablePath, resolveElectronAppPathOrNull, resolveOnboardingAnswers, resolvePreferences, resolveRunSessionPath, resolveRuntimeTarget, resolveTogglePreferences, saveApiKey, saveApiKeyData, saveCredentials, startDeviceCodeFlow, toolRequiresAuth, validatePreference, verifyFileChecksum, writePreferences, writePreferencesWithMetadata, writeRunViewHtml } from './chunk-CKBHCCAM.js';
1
+ export { ACTION_SCRIPT_FILE_NAME, DEFAULT_PREFERENCES, ELECTRON_APP_EXECUTABLE_PATH_SEGMENTS, ElectronAppPlatform, ElectronAppReleaseStream, HTML_VIEW_OFFER_LINE, ONBOARDING_BLANKET_OPTIONS, ONBOARDING_CHOICE_GROUPS, ONBOARDING_MAX_OFFERS, ONBOARDING_PRIMER_BULLETS, ONBOARDING_PRIMER_HEADLINE, ONBOARDING_TOGGLE_GROUPS, ONBOARDING_TOGGLE_PROMPT, ONBOARDING_UNSELECTED_TOGGLE_VALUE, OnboardingBlanketChoice, OnboardingGroupKind, PREFERENCES_FILE_NAME, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_SCHEMA, PREFERENCES_VERSION, PREFERENCE_ALLOWED_VALUES, PreferenceKey, PreferenceValue, ProjectPreferencesReconcileOutcome, RUN_SESSIONS_DIR_NAME, RUN_VIEW_DASHBOARD_LINK_LABEL, RunViewError, RuntimeTarget, SCREENSHOT_DIR_RELATIVE_PATH, SCREENSHOT_FILE_EXTENSION, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, applyOnboardingAnswers, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, buildElectronAppReleaseAssetUrl, buildElectronAppReleaseTag, buildOnboardingPlan, calculateFileChecksum, completeOnboarding, createApiKeyWithToken, createChildLogger, deleteApiKeyData, deleteCredentials, e2e_exports as e2e, formatPreferencesOneLiner, getActiveElectronAppReleaseStream, getActiveRuntimeTarget, getApiKey, getApiKeyFilePath, getAuthService, getBundledElectronAppVersion, getCallerCredentials, getCallerCredentialsAsync, getChecksumForPlatform, getConfig, getCredentialsFilePath, getDashboardBaseUrl, getDataDir, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLocalQaTools, getLogger, getOnboardingToggleKeys, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getRunSessionsDir, getValidApiKeyData, getValidCredentials, hasApiKey, isElectronAppInstalled, isElectronAppPlatform, isFirstRun, loadApiKeyData, loadCredentials, local_exports as localQa, markOnboardingCompleted, mcp_exports as mcp, needsOnboarding, openBrowserUrl, performLogin, performLogout, pollDeviceCode, e2e_exports as qa, readPreferencesMetadata, readRunView, reconcileProjectPreferences, recordOnboardingSkip, renderRunViewHtml, renderRunViewText, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveBlanketPreferences, resolveElectronAppExecutablePath, resolveElectronAppPathOrNull, resolveOnboardingAnswers, resolvePreferences, resolveRunSessionPath, resolveRuntimeTarget, resolveTogglePreferences, saveApiKey, saveApiKeyData, saveCredentials, startDeviceCodeFlow, toolRequiresAuth, validatePreference, verifyFileChecksum, writePreferences, writePreferencesWithMetadata, writeRunViewHtml } from './chunk-NOID65AF.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@muggleai/works",
3
3
  "mcpName": "io.github.multiplex-ai/muggle",
4
- "version": "5.24.0-staging.172",
4
+ "version": "5.24.0-staging.174",
5
5
  "description": "13 years of Microsoft hyperscale engineering, packaged as a harness for your AI coding agent.",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
@@ -15,6 +15,7 @@
15
15
  ".claude-plugin/marketplace.json",
16
16
  "scripts/postinstall.mjs",
17
17
  "scripts/claude-marketplace-sync.mjs",
18
+ "scripts/electron-app-install-dir.mjs",
18
19
  "scripts/onboarding-backfill.mjs",
19
20
  "scripts/release-integrity",
20
21
  "config/runtime-targets.json"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "muggle",
3
3
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
4
- "version": "5.24.0-staging.172",
4
+ "version": "5.24.0-staging.174",
5
5
  "author": {
6
6
  "name": "Muggle AI",
7
7
  "email": "support@muggle-ai.com"
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.24.0-staging.172",
7
+ "@muggleai/works@5.24.0-staging.174",
8
8
  "serve"
9
9
  ],
10
10
  "env": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muggle",
3
- "version": "5.24.0-staging.172",
3
+ "version": "5.24.0-staging.174",
4
4
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
5
5
  "author": {
6
6
  "name": "Muggle AI",
@@ -2,7 +2,7 @@
2
2
  "name": "muggle",
3
3
  "displayName": "Muggle AI",
4
4
  "description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
5
- "version": "5.24.0-staging.172",
5
+ "version": "5.24.0-staging.174",
6
6
  "author": {
7
7
  "name": "Muggle AI",
8
8
  "email": "support@muggle-ai.com"
package/plugin/.mcp.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "@muggleai/works@5.24.0-staging.172",
7
+ "@muggleai/works@5.24.0-staging.174",
8
8
  "serve"
9
9
  ]
10
10
  }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Release stream whose studio installs into the bare version directory, so
3
+ * installs that predate per-stream directories stay valid.
4
+ */
5
+ const BARE_DIRECTORY_RELEASE_STREAM = "production";
6
+
7
+ const BARE_VERSION_DIRECTORY_PATTERN = /^\d+\.\d+\.\d+$/;
8
+
9
+ /**
10
+ * Build the directory name, under `~/.muggle-ai/electron-app`, that a studio
11
+ * release installs into. Mirrors `buildElectronAppDirName` in
12
+ * packages/mcps/src/shared/electron-app-install-dir.ts, which is where the
13
+ * runtime looks for the binary.
14
+ * @param {object} params - Directory parameters.
15
+ * @param {string} params.version - Electron app version.
16
+ * @param {string} params.releaseStream - Release stream the binary came from.
17
+ * @returns {string} Directory name, for example "1.9.0" or "1.9.0-staging".
18
+ */
19
+ export function buildElectronAppDirName({ version, releaseStream }) {
20
+ if (releaseStream === BARE_DIRECTORY_RELEASE_STREAM) {
21
+ return version;
22
+ }
23
+ return `${version}-${releaseStream}`;
24
+ }
25
+
26
+ /**
27
+ * Whether a directory under `~/.muggle-ai/electron-app` is an outdated install
28
+ * of the given stream. Each install lane prunes only its own stream's
29
+ * directories, so a staging install never deletes the production studio and a
30
+ * production install never deletes the staging one.
31
+ * @param {object} params - Check parameters.
32
+ * @param {string} params.directoryName - Directory to classify.
33
+ * @param {string} params.releaseStream - Stream the current install belongs to.
34
+ * @param {string} params.currentDirectoryName - Directory the current install uses.
35
+ * @returns {boolean} True when the directory belongs to the stream and is not the current install.
36
+ */
37
+ export function isOutdatedStreamInstall({ directoryName, releaseStream, currentDirectoryName }) {
38
+ if (directoryName === currentDirectoryName) {
39
+ return false;
40
+ }
41
+ if (releaseStream === BARE_DIRECTORY_RELEASE_STREAM) {
42
+ return BARE_VERSION_DIRECTORY_PATTERN.test(directoryName);
43
+ }
44
+ const streamSuffix = `-${releaseStream}`;
45
+ return (
46
+ directoryName.endsWith(streamSuffix) &&
47
+ BARE_VERSION_DIRECTORY_PATTERN.test(directoryName.slice(0, -streamSuffix.length))
48
+ );
49
+ }
@@ -26,6 +26,7 @@ import { pipeline } from "stream/promises";
26
26
  import { createRequire } from "module";
27
27
  import { fileURLToPath } from "url";
28
28
  import { pointClaudeMarketplaceAtPackage } from "./claude-marketplace-sync.mjs";
29
+ import { buildElectronAppDirName, isOutdatedStreamInstall } from "./electron-app-install-dir.mjs";
29
30
  import { backfillOnboardingStamp } from "./onboarding-backfill.mjs";
30
31
  import {
31
32
  SIGNATURE_BUNDLE_SUFFIX,
@@ -34,7 +35,6 @@ import {
34
35
  } from "./release-integrity/index.mjs";
35
36
 
36
37
  const require = createRequire(import.meta.url);
37
- const VERSION_DIRECTORY_NAME_PATTERN = /^\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?$/;
38
38
  const INSTALL_METADATA_FILE_NAME = ".install-metadata.json";
39
39
  const INSTALL_MANIFEST_FILE_NAME = "install-manifest.json";
40
40
  const LOG_FILE_NAME = "postinstall.log";
@@ -324,15 +324,6 @@ function getPlatformKey() {
324
324
  }
325
325
  }
326
326
 
327
- /**
328
- * Check whether a directory name looks like a version folder.
329
- * @param {string} directoryName - Directory name to validate
330
- * @returns {boolean} True when the directory name is a version
331
- */
332
- function isVersionDirectoryName(directoryName) {
333
- return VERSION_DIRECTORY_NAME_PATTERN.test(directoryName);
334
- }
335
-
336
327
  /**
337
328
  * Calculate SHA256 checksum of a file.
338
329
  * @param {string} filePath - Path to the file
@@ -381,12 +372,13 @@ async function verifyFileChecksum(filePath, expectedChecksum) {
381
372
  }
382
373
 
383
374
  /**
384
- * Remove Electron app version directories that do not match the current version.
375
+ * Remove this release stream's Electron app directories other than the current install.
385
376
  * @param {object} params - Cleanup parameters
386
377
  * @param {string} params.appDir - Base Electron app directory
387
- * @param {string} params.currentVersion - Version that should be kept
378
+ * @param {string} params.releaseStream - Stream the current install belongs to
379
+ * @param {string} params.currentDirectoryName - Directory the current install uses
388
380
  */
389
- function cleanupNonCurrentVersions({ appDir, currentVersion }) {
381
+ function cleanupOutdatedStreamInstalls({ appDir, releaseStream, currentDirectoryName }) {
390
382
  if (!existsSync(appDir)) {
391
383
  return;
392
384
  }
@@ -398,11 +390,13 @@ function cleanupNonCurrentVersions({ appDir, currentVersion }) {
398
390
  continue;
399
391
  }
400
392
 
401
- if (!isVersionDirectoryName(appEntry.name)) {
402
- continue;
403
- }
404
-
405
- if (appEntry.name === currentVersion) {
393
+ if (
394
+ !isOutdatedStreamInstall({
395
+ directoryName: appEntry.name,
396
+ releaseStream: releaseStream,
397
+ currentDirectoryName: currentDirectoryName,
398
+ })
399
+ ) {
406
400
  continue;
407
401
  }
408
402
 
@@ -657,7 +651,8 @@ async function downloadElectronApp() {
657
651
  const downloadUrl = `${baseUrl}/${releaseTagPrefix}${version}/${binaryName}`;
658
652
 
659
653
  const appDir = getElectronAppDir();
660
- const versionDir = join(appDir, version);
654
+ const versionDirectoryName = buildElectronAppDirName({ version: version, releaseStream: releaseStream });
655
+ const versionDir = join(appDir, versionDirectoryName);
661
656
  const metadataPath = getInstallMetadataPath(versionDir);
662
657
 
663
658
  // Check if already downloaded and extracted correctly
@@ -674,7 +669,11 @@ async function downloadElectronApp() {
674
669
  });
675
670
 
676
671
  if (existingInstallVerification.valid) {
677
- cleanupNonCurrentVersions({ appDir: appDir, currentVersion: version });
672
+ cleanupOutdatedStreamInstalls({
673
+ appDir: appDir,
674
+ releaseStream: releaseStream,
675
+ currentDirectoryName: versionDirectoryName,
676
+ });
678
677
  log(`Electron app v${version} already installed at ${versionDir}`);
679
678
  return;
680
679
  }
@@ -815,7 +814,11 @@ async function downloadElectronApp() {
815
814
  expectedArchiveChecksum: expectedChecksum,
816
815
  });
817
816
 
818
- cleanupNonCurrentVersions({ appDir: appDir, currentVersion: version });
817
+ cleanupOutdatedStreamInstalls({
818
+ appDir: appDir,
819
+ releaseStream: releaseStream,
820
+ currentDirectoryName: versionDirectoryName,
821
+ });
819
822
 
820
823
  log(`Electron app installed to ${versionDir}`);
821
824
  } catch (error) {