prismcast 1.9.0 → 1.10.0
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.
- package/dist/app.d.ts +1 -1
- package/dist/app.js +27 -9
- package/dist/app.js.map +1 -1
- package/dist/browser/cdp.js +7 -7
- package/dist/browser/cdp.js.map +1 -1
- package/dist/browser/channelSelection.d.ts +41 -11
- package/dist/browser/channelSelection.js +75 -24
- package/dist/browser/channelSelection.js.map +1 -1
- package/dist/browser/display.d.ts +1 -1
- package/dist/browser/index.d.ts +8 -8
- package/dist/browser/index.js +42 -43
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/login.d.ts +2 -2
- package/dist/browser/login.js +1 -1
- package/dist/browser/manifestInterceptor.d.ts +77 -0
- package/dist/browser/manifestInterceptor.js +323 -0
- package/dist/browser/manifestInterceptor.js.map +1 -0
- package/dist/browser/precaching.js +4 -4
- package/dist/browser/tuning/comcastPolymer.d.ts +1 -1
- package/dist/browser/tuning/cox.d.ts +1 -1
- package/dist/browser/tuning/directv.d.ts +1 -1
- package/dist/browser/tuning/directv.js +61 -62
- package/dist/browser/tuning/directv.js.map +1 -1
- package/dist/browser/tuning/fox.d.ts +1 -1
- package/dist/browser/tuning/fox.js +171 -14
- package/dist/browser/tuning/fox.js.map +1 -1
- package/dist/browser/tuning/hbo.d.ts +1 -1
- package/dist/browser/tuning/hbo.js +6 -6
- package/dist/browser/tuning/hbo.js.map +1 -1
- package/dist/browser/tuning/hulu.d.ts +1 -1
- package/dist/browser/tuning/hulu.js +117 -110
- package/dist/browser/tuning/hulu.js.map +1 -1
- package/dist/browser/tuning/shared.d.ts +3 -3
- package/dist/browser/tuning/shared.js +5 -5
- package/dist/browser/tuning/sling.d.ts +1 -1
- package/dist/browser/tuning/sling.js +28 -28
- package/dist/browser/tuning/sling.js.map +1 -1
- package/dist/browser/tuning/spectrum.d.ts +1 -1
- package/dist/browser/tuning/spectrum.js +21 -22
- package/dist/browser/tuning/spectrum.js.map +1 -1
- package/dist/browser/tuning/thumbnailRow.d.ts +1 -1
- package/dist/browser/tuning/thumbnailRow.js +1 -1
- package/dist/browser/tuning/tileClick.d.ts +1 -1
- package/dist/browser/tuning/tileClick.js +5 -5
- package/dist/browser/tuning/xfinity.d.ts +1 -1
- package/dist/browser/tuning/youtubeTv.d.ts +1 -1
- package/dist/browser/tuning/youtubeTv.js +17 -18
- package/dist/browser/tuning/youtubeTv.js.map +1 -1
- package/dist/browser/video.d.ts +20 -6
- package/dist/browser/video.js +30 -38
- package/dist/browser/video.js.map +1 -1
- package/dist/channels/index.d.ts +1 -2
- package/dist/channels/index.js +73 -40
- package/dist/channels/index.js.map +1 -1
- package/dist/config/channelForm.d.ts +58 -0
- package/dist/config/channelForm.js +129 -0
- package/dist/config/channelForm.js.map +1 -0
- package/dist/config/consistencyProbe.d.ts +7 -0
- package/dist/config/consistencyProbe.js +143 -0
- package/dist/config/consistencyProbe.js.map +1 -0
- package/dist/config/health.d.ts +4 -3
- package/dist/config/health.js +75 -62
- package/dist/config/health.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +19 -12
- package/dist/config/index.js.map +1 -1
- package/dist/config/paths.d.ts +9 -3
- package/dist/config/paths.js +12 -4
- package/dist/config/paths.js.map +1 -1
- package/dist/config/persistence.context.d.ts +8 -0
- package/dist/config/persistence.context.js +30 -0
- package/dist/config/persistence.context.js.map +1 -0
- package/dist/config/persistence.d.ts +110 -12
- package/dist/config/persistence.js +351 -32
- package/dist/config/persistence.js.map +1 -1
- package/dist/config/presets.d.ts +14 -4
- package/dist/config/presets.js +84 -75
- package/dist/config/presets.js.map +1 -1
- package/dist/config/profiles.d.ts +2 -2
- package/dist/config/profiles.js +7 -9
- package/dist/config/profiles.js.map +1 -1
- package/dist/config/servicePacks.d.ts +2 -2
- package/dist/config/servicePacks.js +28 -28
- package/dist/config/servicePacks.js.map +1 -1
- package/dist/config/services.d.ts +62 -36
- package/dist/config/services.js +150 -136
- package/dist/config/services.js.map +1 -1
- package/dist/config/sites.d.ts +3 -3
- package/dist/config/sites.js +16 -16
- package/dist/config/sites.js.map +1 -1
- package/dist/config/userChannels.d.ts +500 -41
- package/dist/config/userChannels.js +1201 -312
- package/dist/config/userChannels.js.map +1 -1
- package/dist/config/userConfig.d.ts +103 -10
- package/dist/config/userConfig.js +277 -117
- package/dist/config/userConfig.js.map +1 -1
- package/dist/config/userProfiles.d.ts +4 -2
- package/dist/config/userProfiles.js +72 -26
- package/dist/config/userProfiles.js.map +1 -1
- package/dist/hdhr/channelMap.js +8 -11
- package/dist/hdhr/channelMap.js.map +1 -1
- package/dist/hdhr/deviceId.js +10 -9
- package/dist/hdhr/deviceId.js.map +1 -1
- package/dist/hdhr/discover.js +4 -5
- package/dist/hdhr/discover.js.map +1 -1
- package/dist/hdhr/index.js +6 -10
- package/dist/hdhr/index.js.map +1 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/native/codecInference.d.ts +44 -0
- package/dist/native/codecInference.js +327 -0
- package/dist/native/codecInference.js.map +1 -0
- package/dist/native/decrypt.d.ts +1 -1
- package/dist/native/index.d.ts +5 -5
- package/dist/native/index.js +42 -64
- package/dist/native/index.js.map +1 -1
- package/dist/native/probe.d.ts +27 -9
- package/dist/native/probe.js +158 -67
- package/dist/native/probe.js.map +1 -1
- package/dist/native/proxy.d.ts +4 -2
- package/dist/native/proxy.js +52 -49
- package/dist/native/proxy.js.map +1 -1
- package/dist/native/tokenExpiry.d.ts +22 -0
- package/dist/native/tokenExpiry.js +153 -0
- package/dist/native/tokenExpiry.js.map +1 -0
- package/dist/routes/auth.js +6 -10
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/components.js +2 -2
- package/dist/routes/components.js.map +1 -1
- package/dist/routes/config/channels/endpoints/browse.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/browse.js +195 -0
- package/dist/routes/config/channels/endpoints/browse.js.map +1 -0
- package/dist/routes/config/channels/endpoints/bulk.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/bulk.js +128 -0
- package/dist/routes/config/channels/endpoints/bulk.js.map +1 -0
- package/dist/routes/config/channels/endpoints/crud.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/crud.js +504 -0
- package/dist/routes/config/channels/endpoints/crud.js.map +1 -0
- package/dist/routes/config/channels/endpoints/importExport.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/importExport.js +131 -0
- package/dist/routes/config/channels/endpoints/importExport.js.map +1 -0
- package/dist/routes/config/channels/endpoints/predefined.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/predefined.js +78 -0
- package/dist/routes/config/channels/endpoints/predefined.js.map +1 -0
- package/dist/routes/config/channels/endpoints/prefs.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/prefs.js +58 -0
- package/dist/routes/config/channels/endpoints/prefs.js.map +1 -0
- package/dist/routes/config/channels/endpoints/service.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/service.js +149 -0
- package/dist/routes/config/channels/endpoints/service.js.map +1 -0
- package/dist/routes/config/channels/endpoints/tags.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/tags.js +185 -0
- package/dist/routes/config/channels/endpoints/tags.js.map +1 -0
- package/dist/routes/config/channels/http/handler.d.ts +10 -0
- package/dist/routes/config/channels/http/handler.js +20 -0
- package/dist/routes/config/channels/http/handler.js.map +1 -0
- package/dist/routes/config/channels/http/playlistHint.d.ts +25 -0
- package/dist/routes/config/channels/http/playlistHint.js +40 -0
- package/dist/routes/config/channels/http/playlistHint.js.map +1 -0
- package/dist/routes/config/channels/http/serviceWarning.d.ts +10 -0
- package/dist/routes/config/channels/http/serviceWarning.js +28 -0
- package/dist/routes/config/channels/http/serviceWarning.js.map +1 -0
- package/dist/routes/config/channels/index.d.ts +3 -3
- package/dist/routes/config/channels/index.js +1 -1
- package/dist/routes/config/channels/index.js.map +1 -1
- package/dist/routes/config/channels/{routes.d.ts → setup.d.ts} +1 -1
- package/dist/routes/config/channels/setup.js +23 -0
- package/dist/routes/config/channels/setup.js.map +1 -0
- package/dist/routes/config/channels/table.d.ts +9 -9
- package/dist/routes/config/channels/table.js +124 -76
- package/dist/routes/config/channels/table.js.map +1 -1
- package/dist/routes/config/http/envelope.d.ts +111 -0
- package/dist/routes/config/http/envelope.js +103 -0
- package/dist/routes/config/http/envelope.js.map +1 -0
- package/dist/routes/config/index.d.ts +9 -9
- package/dist/routes/config/index.js +2 -2
- package/dist/routes/config/index.js.map +1 -1
- package/dist/routes/config/services.js +69 -68
- package/dist/routes/config/services.js.map +1 -1
- package/dist/routes/config/settings.d.ts +1 -1
- package/dist/routes/config/settings.js +45 -38
- package/dist/routes/config/settings.js.map +1 -1
- package/dist/routes/debug.js +12 -11
- package/dist/routes/debug.js.map +1 -1
- package/dist/routes/icons.js +2 -2
- package/dist/routes/icons.js.map +1 -1
- package/dist/routes/logs.js +19 -30
- package/dist/routes/logs.js.map +1 -1
- package/dist/routes/mpegts.js +1 -1
- package/dist/routes/playlist.d.ts +1 -1
- package/dist/routes/playlist.js +37 -26
- package/dist/routes/playlist.js.map +1 -1
- package/dist/routes/root/content.js +27 -6
- package/dist/routes/root/content.js.map +1 -1
- package/dist/routes/root/index.js +2 -5
- package/dist/routes/root/index.js.map +1 -1
- package/dist/routes/root/scripts/channels.js +16 -16
- package/dist/routes/root/scripts/channels.js.map +1 -1
- package/dist/routes/root/scripts/config.js +59 -59
- package/dist/routes/root/scripts/config.js.map +1 -1
- package/dist/routes/root/scripts/index.d.ts +4 -4
- package/dist/routes/root/scripts/shared.js +24 -10
- package/dist/routes/root/scripts/shared.js.map +1 -1
- package/dist/routes/root/scripts/status.d.ts +4 -0
- package/dist/routes/root/scripts/status.handlers.d.ts +182 -0
- package/dist/routes/root/scripts/status.handlers.js +713 -0
- package/dist/routes/root/scripts/status.handlers.js.map +1 -0
- package/dist/routes/root/scripts/status.js +86 -488
- package/dist/routes/root/scripts/status.js.map +1 -1
- package/dist/routes/root/styles.js +5 -5
- package/dist/routes/services.js +18 -15
- package/dist/routes/services.js.map +1 -1
- package/dist/routes/sse.d.ts +16 -0
- package/dist/routes/sse.js +29 -0
- package/dist/routes/sse.js.map +1 -0
- package/dist/routes/streams.js +10 -23
- package/dist/routes/streams.js.map +1 -1
- package/dist/routes/ui.d.ts +2 -2
- package/dist/routes/upgrade.js +6 -7
- package/dist/routes/upgrade.js.map +1 -1
- package/dist/service/commands.context.d.ts +6 -0
- package/dist/service/commands.context.js +47 -0
- package/dist/service/commands.context.js.map +1 -0
- package/dist/service/commands.d.ts +53 -8
- package/dist/service/commands.js +171 -188
- package/dist/service/commands.js.map +1 -1
- package/dist/service/generators.context.d.ts +6 -0
- package/dist/service/generators.context.js +45 -0
- package/dist/service/generators.context.js.map +1 -0
- package/dist/service/generators.d.ts +56 -16
- package/dist/service/generators.js +499 -383
- package/dist/service/generators.js.map +1 -1
- package/dist/service/index.d.ts +2 -2
- package/dist/streaming/clients.d.ts +2 -2
- package/dist/streaming/clients.js +2 -2
- package/dist/streaming/codec.d.ts +2 -2
- package/dist/streaming/codec.js +0 -1
- package/dist/streaming/codec.js.map +1 -1
- package/dist/streaming/fmp4Segmenter.d.ts +2 -2
- package/dist/streaming/fmp4Segmenter.js +12 -12
- package/dist/streaming/hls.d.ts +3 -3
- package/dist/streaming/hls.js +81 -70
- package/dist/streaming/hls.js.map +1 -1
- package/dist/streaming/hlsResume.d.ts +3 -3
- package/dist/streaming/hlsResume.js +5 -5
- package/dist/streaming/hlsSegments.d.ts +5 -2
- package/dist/streaming/hlsSegments.js +14 -9
- package/dist/streaming/hlsSegments.js.map +1 -1
- package/dist/streaming/monitor.d.ts +12 -12
- package/dist/streaming/monitor.js +80 -54
- package/dist/streaming/monitor.js.map +1 -1
- package/dist/streaming/mp4Parser.d.ts +34 -4
- package/dist/streaming/mp4Parser.js +111 -29
- package/dist/streaming/mp4Parser.js.map +1 -1
- package/dist/streaming/mpegts.d.ts +1 -1
- package/dist/streaming/mpegts.js +13 -10
- package/dist/streaming/mpegts.js.map +1 -1
- package/dist/streaming/playlistBuilder.d.ts +1 -1
- package/dist/streaming/playlistBuilder.js +2 -2
- package/dist/streaming/preroll.d.ts +9 -9
- package/dist/streaming/preroll.js +39 -41
- package/dist/streaming/preroll.js.map +1 -1
- package/dist/streaming/pretune.js +4 -4
- package/dist/streaming/pretune.js.map +1 -1
- package/dist/streaming/recovery.d.ts +3 -3
- package/dist/streaming/recovery.js +4 -4
- package/dist/streaming/registry.d.ts +6 -6
- package/dist/streaming/setup.d.ts +9 -8
- package/dist/streaming/setup.js +97 -49
- package/dist/streaming/setup.js.map +1 -1
- package/dist/streaming/showInfo.d.ts +9 -3
- package/dist/streaming/showInfo.js +26 -18
- package/dist/streaming/showInfo.js.map +1 -1
- package/dist/streaming/statusEmitter.d.ts +4 -4
- package/dist/streaming/statusEmitter.js +2 -2
- package/dist/types/channels.d.ts +133 -34
- package/dist/types/channels.js +39 -1
- package/dist/types/channels.js.map +1 -1
- package/dist/types/config.d.ts +20 -1
- package/dist/types/index.d.ts +9 -8
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/profiles.d.ts +5 -4
- package/dist/types/selection.d.ts +48 -4
- package/dist/types/streaming.d.ts +1 -1
- package/dist/upgrade/commands.context.d.ts +6 -0
- package/dist/upgrade/commands.context.js +29 -0
- package/dist/upgrade/commands.context.js.map +1 -0
- package/dist/upgrade/commands.d.ts +29 -2
- package/dist/upgrade/commands.js +87 -134
- package/dist/upgrade/commands.js.map +1 -1
- package/dist/upgrade/detection.context.d.ts +6 -0
- package/dist/upgrade/detection.context.js +24 -0
- package/dist/upgrade/detection.context.js.map +1 -0
- package/dist/upgrade/detection.d.ts +140 -10
- package/dist/upgrade/detection.js +153 -66
- package/dist/upgrade/detection.js.map +1 -1
- package/dist/upgrade/index.d.ts +2 -2
- package/dist/utils/chromeFetch.d.ts +1 -1
- package/dist/utils/chromeFetch.js +1 -1
- package/dist/utils/clock.d.ts +14 -0
- package/dist/utils/clock.js +28 -0
- package/dist/utils/clock.js.map +1 -0
- package/dist/utils/debugFilter.d.ts +1 -1
- package/dist/utils/debugFilter.js +6 -4
- package/dist/utils/debugFilter.js.map +1 -1
- package/dist/utils/delay.d.ts +2 -3
- package/dist/utils/delay.js +10 -16
- package/dist/utils/delay.js.map +1 -1
- package/dist/utils/evaluate.js +12 -14
- package/dist/utils/evaluate.js.map +1 -1
- package/dist/utils/ffmpeg.context.d.ts +6 -0
- package/dist/utils/ffmpeg.context.js +31 -0
- package/dist/utils/ffmpeg.context.js.map +1 -0
- package/dist/utils/ffmpeg.d.ts +85 -29
- package/dist/utils/ffmpeg.js +126 -129
- package/dist/utils/ffmpeg.js.map +1 -1
- package/dist/utils/fileLogger.d.ts +18 -2
- package/dist/utils/fileLogger.js +58 -30
- package/dist/utils/fileLogger.js.map +1 -1
- package/dist/utils/format.d.ts +1 -1
- package/dist/utils/format.js +2 -2
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/html.js +1 -3
- package/dist/utils/html.js.map +1 -1
- package/dist/utils/index.d.ts +21 -20
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.js +16 -20
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/m3u.d.ts +18 -3
- package/dist/utils/m3u.js +28 -14
- package/dist/utils/m3u.js.map +1 -1
- package/dist/utils/memo.d.ts +19 -0
- package/dist/utils/memo.js +53 -0
- package/dist/utils/memo.js.map +1 -0
- package/dist/utils/morganStream.js +2 -2
- package/dist/utils/morganStream.js.map +1 -1
- package/dist/utils/pid.d.ts +2 -2
- package/dist/utils/pid.js +2 -2
- package/dist/utils/platform.d.ts +1 -1
- package/dist/utils/platform.js +3 -3
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/retry.d.ts +2 -0
- package/dist/utils/retry.js +9 -7
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/sanitize.d.ts +2 -2
- package/dist/utils/sanitize.js +4 -4
- package/dist/utils/timing.d.ts +6 -3
- package/dist/utils/timing.js +10 -6
- package/dist/utils/timing.js.map +1 -1
- package/dist/utils/version.d.ts +3 -2
- package/dist/utils/version.js +14 -27
- package/dist/utils/version.js.map +1 -1
- package/package.json +13 -7
- package/dist/native/intercept.d.ts +0 -35
- package/dist/native/intercept.js +0 -181
- package/dist/native/intercept.js.map +0 -1
- package/dist/routes/config/channels/routes.js +0 -1505
- package/dist/routes/config/channels/routes.js.map +0 -1
|
@@ -1,6 +1,33 @@
|
|
|
1
|
+
import type { InstallInfo } from "./detection.ts";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Result of running an upgrade command. The success flag distinguishes ran-without-error from threw-or-exited-non-zero; the runner does not surface the actual
|
|
4
|
+
* error because execSync's stderr is inherited to the user's terminal directly.
|
|
5
|
+
*/
|
|
6
|
+
export interface UpgradeResult {
|
|
7
|
+
readonly success: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The runtime context handleUpgradeCommand consumes. Each field models one capability the command needs - detection, version lookup, subprocess execution,
|
|
11
|
+
* stdout/stderr output, process termination, and a service-mode probe. Decision logic is a pure function of this shape; production wires it through
|
|
12
|
+
* createDefaultUpgradeContext (in commands.context.ts), tests pass a context literal.
|
|
13
|
+
*/
|
|
14
|
+
export interface UpgradeContext {
|
|
15
|
+
readonly detect: () => InstallInfo;
|
|
16
|
+
readonly exit: (code: number) => never;
|
|
17
|
+
readonly fetchLatestVersion: () => Promise<string | null>;
|
|
18
|
+
readonly isService: boolean;
|
|
19
|
+
readonly runUpgradeCommand: (cmd: string, options: {
|
|
20
|
+
cwd?: string;
|
|
21
|
+
}) => UpgradeResult;
|
|
22
|
+
readonly stderr: (line: string) => void;
|
|
23
|
+
readonly stdout: (line: string) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Main handler for the `upgrade` subcommand. Parses arguments and orchestrates the appropriate upgrade flow through the UpgradeContext. Pure function of
|
|
27
|
+
* UpgradeContext modulo the help/usage paths that just write to stdout - no detection, registry, subprocess, or process state is touched outside the context's
|
|
28
|
+
* methods.
|
|
3
29
|
* @param args - Arguments after 'upgrade' (e.g., ['--check', '--force']).
|
|
30
|
+
* @param ctx - The upgrade context. Defaults to createDefaultUpgradeContext() which wires real runtime I/O.
|
|
4
31
|
* @returns Exit code (0 for success, 1 for error).
|
|
5
32
|
*/
|
|
6
|
-
export declare function handleUpgradeCommand(args: string[]): Promise<number>;
|
|
33
|
+
export declare function handleUpgradeCommand(args: readonly string[], ctx?: UpgradeContext): Promise<number>;
|
package/dist/upgrade/commands.js
CHANGED
|
@@ -1,195 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { getPackageVersion, isVersionLessThan, normalizeVersion } from "../utils/version.js";
|
|
2
|
+
import { createDefaultUpgradeContext } from "./commands.context.js";
|
|
3
|
+
/* The upgrade subcommand handles `prismcast upgrade [--check] [--force] [-h|--help]`. Detection picks the install method, the registry lookup checks for a
|
|
4
|
+
* newer version, and the runner executes the per-method upgrade command (or prints manual instructions for non-upgradeable methods).
|
|
4
5
|
*/
|
|
5
|
-
import { fetchLatestVersion, getPackageVersion, isVersionLessThan, normalizeVersion } from "../utils/version.js";
|
|
6
|
-
import { print, printError } from "../utils/cliOutput.js";
|
|
7
|
-
import { detectInstallMethod } from "./detection.js";
|
|
8
|
-
import { execSync } from "node:child_process";
|
|
9
|
-
import { isRunningAsService } from "../utils/platform.js";
|
|
10
|
-
/* These handlers implement the `prismcast upgrade` subcommand for detecting the installation method, checking for updates, and executing the appropriate upgrade
|
|
11
|
-
* command. The pattern mirrors the service subcommand handlers in service/commands.ts.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Formats the display name for an installation method.
|
|
15
|
-
* @param info - The installation info to format.
|
|
16
|
-
* @returns A human-readable name for the install method.
|
|
17
|
-
*/
|
|
18
|
-
function formatMethodName(info) {
|
|
19
|
-
switch (info.method) {
|
|
20
|
-
case "docker": {
|
|
21
|
-
return "Docker";
|
|
22
|
-
}
|
|
23
|
-
case "homebrew": {
|
|
24
|
-
return "Homebrew";
|
|
25
|
-
}
|
|
26
|
-
case "npm-global": {
|
|
27
|
-
return "npm (global)";
|
|
28
|
-
}
|
|
29
|
-
case "npm-local": {
|
|
30
|
-
return "npm (local)";
|
|
31
|
-
}
|
|
32
|
-
default: {
|
|
33
|
-
return "Unknown";
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
6
|
/**
|
|
38
7
|
* Prints usage information for the upgrade subcommand.
|
|
8
|
+
* @param ctx - The upgrade context (used for stdout output).
|
|
39
9
|
*/
|
|
40
|
-
function printUpgradeUsage() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
10
|
+
function printUpgradeUsage(ctx) {
|
|
11
|
+
ctx.stdout("Usage: prismcast upgrade [options]");
|
|
12
|
+
ctx.stdout("");
|
|
13
|
+
ctx.stdout("Upgrade PrismCast to the latest version.");
|
|
14
|
+
ctx.stdout("");
|
|
15
|
+
ctx.stdout("Options:");
|
|
16
|
+
ctx.stdout(" --check Show upgrade information without upgrading");
|
|
17
|
+
ctx.stdout(" --force Upgrade even if already up to date");
|
|
18
|
+
ctx.stdout(" -h, --help Show this help message");
|
|
49
19
|
}
|
|
50
20
|
/**
|
|
51
|
-
* Prints the upgrade
|
|
21
|
+
* Prints the upgrade summary table (shared between --check mode and the pre-upgrade display).
|
|
22
|
+
* @param ctx - The upgrade context (used for stdout output).
|
|
52
23
|
* @param info - The detected installation info.
|
|
53
24
|
* @param currentVersion - The currently running version.
|
|
54
25
|
* @param latestVersion - The latest available version, or null if unknown.
|
|
55
26
|
*/
|
|
56
|
-
function printUpgradeInfo(info, currentVersion, latestVersion) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
27
|
+
function printUpgradeInfo(ctx, info, currentVersion, latestVersion) {
|
|
28
|
+
ctx.stdout("PrismCast Upgrade Check");
|
|
29
|
+
ctx.stdout("─".repeat(40));
|
|
30
|
+
ctx.stdout("Current version: v" + currentVersion);
|
|
60
31
|
if (latestVersion) {
|
|
61
|
-
|
|
32
|
+
ctx.stdout("Latest version: v" + latestVersion);
|
|
62
33
|
}
|
|
63
34
|
else {
|
|
64
|
-
|
|
35
|
+
ctx.stdout("Latest version: (unable to check)");
|
|
65
36
|
}
|
|
66
|
-
|
|
37
|
+
ctx.stdout("Install method: " + info.displayName);
|
|
67
38
|
if (info.upgradeable) {
|
|
68
|
-
|
|
39
|
+
ctx.stdout("Upgrade command: " + info.upgradeCommand);
|
|
69
40
|
}
|
|
70
41
|
}
|
|
71
42
|
/**
|
|
72
|
-
*
|
|
43
|
+
* Prints the full report for a non-upgradeable install method - the summary table, a blank line, the strategy's manual upgrade message, and the indented
|
|
44
|
+
* command. Single source of truth for "this is what the user sees when we cannot upgrade in-place," shared between the --check flow and the main upgrade flow.
|
|
45
|
+
* The parameter type is the narrow NonUpgradeableInstallInfo variant; callers narrow via the discriminated union before invoking, so manualUpgradeMessage is
|
|
46
|
+
* always in scope.
|
|
47
|
+
* @param ctx - The upgrade context (used for stdout output).
|
|
48
|
+
* @param info - The detected non-upgradeable installation info.
|
|
49
|
+
* @param currentVersion - The currently running version.
|
|
50
|
+
* @param latestVersion - The latest available version, or null if unknown.
|
|
51
|
+
*/
|
|
52
|
+
function printNonUpgradeableSummary(ctx, info, currentVersion, latestVersion) {
|
|
53
|
+
printUpgradeInfo(ctx, info, currentVersion, latestVersion);
|
|
54
|
+
ctx.stdout("");
|
|
55
|
+
for (const line of info.manualUpgradeMessage) {
|
|
56
|
+
ctx.stdout(line);
|
|
57
|
+
}
|
|
58
|
+
ctx.stdout(" " + info.upgradeCommand);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Handles the --check flag: prints upgrade information and exits with 0.
|
|
62
|
+
* @param ctx - The upgrade context.
|
|
73
63
|
* @param info - The detected installation info.
|
|
74
64
|
* @param currentVersion - The currently running version.
|
|
75
65
|
* @param latestVersion - The latest available version, or null if unknown.
|
|
76
|
-
* @returns Exit code (0
|
|
66
|
+
* @returns Exit code (0).
|
|
77
67
|
*/
|
|
78
|
-
function handleCheck(info, currentVersion, latestVersion) {
|
|
79
|
-
printUpgradeInfo(info, currentVersion, latestVersion);
|
|
80
|
-
print("");
|
|
68
|
+
function handleCheck(ctx, info, currentVersion, latestVersion) {
|
|
81
69
|
if (!info.upgradeable) {
|
|
82
|
-
|
|
83
|
-
if (info.method === "docker") {
|
|
84
|
-
print("To upgrade, pull the latest image and recreate the container:");
|
|
85
|
-
print(" " + info.upgradeCommand);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
print("Unable to detect installation method. Please upgrade manually:");
|
|
89
|
-
print(" " + info.upgradeCommand);
|
|
90
|
-
}
|
|
70
|
+
printNonUpgradeableSummary(ctx, info, currentVersion, latestVersion);
|
|
91
71
|
return 0;
|
|
92
72
|
}
|
|
73
|
+
printUpgradeInfo(ctx, info, currentVersion, latestVersion);
|
|
74
|
+
ctx.stdout("");
|
|
93
75
|
if (!latestVersion) {
|
|
94
|
-
|
|
76
|
+
ctx.stdout("Run 'prismcast upgrade --force' to upgrade without a version check.");
|
|
95
77
|
}
|
|
96
78
|
else if (!isVersionLessThan(currentVersion, latestVersion)) {
|
|
97
|
-
|
|
79
|
+
ctx.stdout("PrismCast v" + currentVersion + " is already the latest version.");
|
|
98
80
|
}
|
|
99
81
|
else {
|
|
100
|
-
|
|
82
|
+
ctx.stdout("Run 'prismcast upgrade' to upgrade.");
|
|
101
83
|
}
|
|
102
84
|
return 0;
|
|
103
85
|
}
|
|
104
86
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*/
|
|
109
|
-
function executeUpgrade(info) {
|
|
110
|
-
try {
|
|
111
|
-
// For npm-local, run the install from the project directory that contains the dependency.
|
|
112
|
-
const options = { encoding: "utf-8", stdio: "inherit" };
|
|
113
|
-
if ((info.method === "npm-local") && info.packageDir) {
|
|
114
|
-
options.cwd = info.packageDir;
|
|
115
|
-
}
|
|
116
|
-
execSync(info.upgradeCommand, options);
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
catch {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Main handler for the `upgrade` subcommand. Parses arguments and executes the appropriate upgrade logic.
|
|
87
|
+
* Main handler for the `upgrade` subcommand. Parses arguments and orchestrates the appropriate upgrade flow through the UpgradeContext. Pure function of
|
|
88
|
+
* UpgradeContext modulo the help/usage paths that just write to stdout - no detection, registry, subprocess, or process state is touched outside the context's
|
|
89
|
+
* methods.
|
|
125
90
|
* @param args - Arguments after 'upgrade' (e.g., ['--check', '--force']).
|
|
91
|
+
* @param ctx - The upgrade context. Defaults to createDefaultUpgradeContext() which wires real runtime I/O.
|
|
126
92
|
* @returns Exit code (0 for success, 1 for error).
|
|
127
93
|
*/
|
|
128
|
-
export async function handleUpgradeCommand(args) {
|
|
129
|
-
// Parse flags.
|
|
94
|
+
export async function handleUpgradeCommand(args, ctx = createDefaultUpgradeContext()) {
|
|
130
95
|
const showHelp = args.includes("--help") || args.includes("-h") || args.includes("help");
|
|
131
96
|
const checkOnly = args.includes("--check");
|
|
132
97
|
const force = args.includes("--force");
|
|
133
98
|
if (showHelp) {
|
|
134
|
-
printUpgradeUsage();
|
|
99
|
+
printUpgradeUsage(ctx);
|
|
135
100
|
return 0;
|
|
136
101
|
}
|
|
137
|
-
|
|
138
|
-
const info = detectInstallMethod();
|
|
102
|
+
const info = ctx.detect();
|
|
139
103
|
const currentVersion = normalizeVersion(getPackageVersion());
|
|
140
|
-
|
|
141
|
-
const latestVersion = await fetchLatestVersion();
|
|
142
|
-
// Handle --check mode.
|
|
104
|
+
const latestVersion = await ctx.fetchLatestVersion();
|
|
143
105
|
if (checkOnly) {
|
|
144
|
-
return handleCheck(info, currentVersion, latestVersion);
|
|
106
|
+
return handleCheck(ctx, info, currentVersion, latestVersion);
|
|
145
107
|
}
|
|
146
|
-
//
|
|
108
|
+
// Non-upgradeable methods (docker, unknown): delegate to the shared summary helper, which is the SSOT for the version-table-plus-manual-instructions report.
|
|
109
|
+
// The InstallInfo union narrows on `!info.upgradeable` to expose manualUpgradeMessage; the consumer never switches on info.method.
|
|
147
110
|
if (!info.upgradeable) {
|
|
148
|
-
|
|
149
|
-
print("");
|
|
150
|
-
if (info.method === "docker") {
|
|
151
|
-
print("Docker containers cannot be upgraded in-place.");
|
|
152
|
-
print("To upgrade, pull the latest image and recreate the container:");
|
|
153
|
-
print(" " + info.upgradeCommand);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
print("Unable to detect installation method. Please upgrade manually:");
|
|
157
|
-
print(" " + info.upgradeCommand);
|
|
158
|
-
}
|
|
111
|
+
printNonUpgradeableSummary(ctx, info, currentVersion, latestVersion);
|
|
159
112
|
return 0;
|
|
160
113
|
}
|
|
161
|
-
//
|
|
114
|
+
// Already-current short-circuit: skip when --force is set or when we could not check the registry. Without --force, an indeterminate version check is fatal
|
|
115
|
+
// because we should not blindly run npm install when we can not see whether it would do anything.
|
|
162
116
|
if (!force && latestVersion && !isVersionLessThan(currentVersion, latestVersion)) {
|
|
163
|
-
|
|
164
|
-
|
|
117
|
+
ctx.stdout("PrismCast v" + currentVersion + " is already the latest version.");
|
|
118
|
+
ctx.stdout("Use --force to upgrade anyway.");
|
|
165
119
|
return 0;
|
|
166
120
|
}
|
|
167
|
-
// If we couldn't check the latest version and --force wasn't specified, warn the user.
|
|
168
121
|
if (!force && !latestVersion) {
|
|
169
|
-
|
|
122
|
+
ctx.stderr("Unable to check for updates. Run with --force to upgrade anyway.");
|
|
170
123
|
return 1;
|
|
171
124
|
}
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
// Execute the upgrade.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
125
|
+
// Pre-upgrade announcement so the user knows what is about to run.
|
|
126
|
+
ctx.stdout("Upgrading PrismCast...");
|
|
127
|
+
ctx.stdout("Install method: " + info.displayName);
|
|
128
|
+
ctx.stdout("Running: " + info.upgradeCommand);
|
|
129
|
+
ctx.stdout("");
|
|
130
|
+
// Execute the upgrade. packageDir is set only by the npm-local strategy (it is the lone field in ResolvableFields and only npm-local declares a resolver),
|
|
131
|
+
// so reading it directly is sufficient - the runner uses it as cwd when present and falls back to process.cwd() when absent.
|
|
132
|
+
const result = ctx.runUpgradeCommand(info.upgradeCommand, { cwd: info.packageDir });
|
|
133
|
+
if (!result.success) {
|
|
134
|
+
ctx.stderr("");
|
|
135
|
+
ctx.stderr("Upgrade failed. Check the output above for details.");
|
|
181
136
|
return 1;
|
|
182
137
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
//
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
print("Please restart PrismCast manually to use the new version.");
|
|
138
|
+
ctx.stdout("");
|
|
139
|
+
ctx.stdout("Upgrade complete.");
|
|
140
|
+
// Service-managed processes restart automatically when we exit; manual installs need a user-driven restart.
|
|
141
|
+
if (ctx.isService) {
|
|
142
|
+
ctx.stdout("Restarting PrismCast via service manager...");
|
|
143
|
+
ctx.exit(0);
|
|
192
144
|
}
|
|
145
|
+
ctx.stdout("Please restart PrismCast manually to use the new version.");
|
|
193
146
|
return 0;
|
|
194
147
|
}
|
|
195
148
|
//# sourceMappingURL=commands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/upgrade/commands.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/upgrade/commands.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,q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AE,CAAC;QAE5B,GAAG,CAAC,MAAM,CAAC,kEAAkE,CAAC,CAAC;QAE/E,OAAO,CAAC,CAAC;IACX,CAAC;IAED,mEAAmE;IACnE,GAAG,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;IACrC,GAAG,CAAC,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,GAAG,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;IAC9C,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAEf,2JAA2J;IAC3J,6HAA6H;IAC7H,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAEpF,IAAG,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAEnB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,qDAAqD,CAAC,CAAC;QAElE,OAAO,CAAC,CAAC;IACX,CAAC;IAED,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACf,GAAG,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAEhC,4GAA4G;IAC5G,IAAG,GAAG,CAAC,SAAS,EAAE,CAAC;QAEjB,GAAG,CAAC,MAAM,CAAC,6CAA6C,CAAC,CAAC;QAE1D,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;IAED,GAAG,CAAC,MAAM,CAAC,2DAA2D,CAAC,CAAC;IAExE,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DetectionContext } from "./detection.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Builds the default DetectionContext from real runtime I/O.
|
|
4
|
+
* @returns A DetectionContext populated from the live process.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createDefaultDetectionContext(): DetectionContext;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { isRunningInContainer } from "../utils/platform.js";
|
|
4
|
+
import url from "node:url";
|
|
5
|
+
/**
|
|
6
|
+
* Builds the default DetectionContext from real runtime I/O.
|
|
7
|
+
* @returns A DetectionContext populated from the live process.
|
|
8
|
+
*/
|
|
9
|
+
export function createDefaultDetectionContext() {
|
|
10
|
+
return {
|
|
11
|
+
currentFile: url.fileURLToPath(import.meta.url),
|
|
12
|
+
fileExists: existsSync,
|
|
13
|
+
isContainer: isRunningInContainer(),
|
|
14
|
+
runCommand: (cmd) => {
|
|
15
|
+
try {
|
|
16
|
+
return execSync(cmd, { encoding: "utf-8", timeout: 5000 }).trim();
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=detection.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detection.context.js","sourceRoot":"","sources":["../../src/upgrade/detection.context.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B;;;GAGG;AACH,MAAM,UAAU,6BAA6B;IAE3C,OAAO;QAEL,WAAW,EAAE,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/C,UAAU,EAAE,UAAU;QACtB,WAAW,EAAE,oBAAoB,EAAE;QACnC,UAAU,EAAE,CAAC,GAAW,EAAiB,EAAE;YAEzC,IAAI,CAAC;gBAEH,OAAO,QAAQ,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YACpE,CAAC;YAAC,MAAM,CAAC;gBAEP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,15 +1,145 @@
|
|
|
1
|
-
export type InstallMethod = "docker" | "homebrew" | "npm-global" | "npm-local" | "unknown";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* The runtime context detection consumes. Each field is one narrow capability the decision logic depends on - the path of the running module, whether we are
|
|
3
|
+
* inside a Docker container, the ability to run a shell command and read its trimmed stdout, the ability to check that a path exists. Decision logic is a pure
|
|
4
|
+
* function of this shape; the default adapter wires it from real I/O, tests pass a context literal.
|
|
4
5
|
*/
|
|
5
|
-
export interface
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export interface DetectionContext {
|
|
7
|
+
readonly currentFile: string;
|
|
8
|
+
readonly fileExists: (path: string) => boolean;
|
|
9
|
+
readonly isContainer: boolean;
|
|
10
|
+
readonly runCommand: (cmd: string) => string | null;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
13
|
+
* The narrow set of InstallInfo fields a strategy's resolver may compute from the runtime context. Today there's only one - npm-local's packageDir, derived
|
|
14
|
+
* from the consumer's project root - but the dedicated type guarantees the resolver cannot accidentally override the strategy's constant fields. Adding a new
|
|
15
|
+
* resolvable field is an additive edit here; strategies opt in by declaring the field on their resolve return.
|
|
14
16
|
*/
|
|
15
|
-
export
|
|
17
|
+
export interface ResolvableFields {
|
|
18
|
+
readonly packageDir?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Common fields shared by every install strategy. Generic in the literal id type so each strategy declaration carries its own narrow id (e.g.,
|
|
22
|
+
* InstallStrategyBase<"docker">), which the registry then harvests into the RegisteredMethod literal union.
|
|
23
|
+
*
|
|
24
|
+
* Strategies own no state and perform no I/O outside what the context exposes.
|
|
25
|
+
*/
|
|
26
|
+
interface InstallStrategyBase<M extends string = string> {
|
|
27
|
+
readonly displayName: string;
|
|
28
|
+
readonly id: M;
|
|
29
|
+
readonly matches: (ctx: DetectionContext) => boolean;
|
|
30
|
+
readonly resolve?: (ctx: DetectionContext) => ResolvableFields;
|
|
31
|
+
readonly upgradeCommand: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Strategy variant for install methods the tool can upgrade in place. The runner invokes upgradeCommand directly; no manual-instruction strings are needed.
|
|
35
|
+
*/
|
|
36
|
+
export interface UpgradeableInstallStrategy<M extends string = string> extends InstallStrategyBase<M> {
|
|
37
|
+
readonly upgradeable: true;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Strategy variant for install methods the tool cannot upgrade in place. Carries manualUpgradeMessage - the user-facing prose lines that explain why the
|
|
41
|
+
* automated path is unavailable and what the user should do instead. The dispatcher copies this onto the resulting InstallInfo so the consumer (commands.ts)
|
|
42
|
+
* never has to switch on the install method to choose its messaging.
|
|
43
|
+
*/
|
|
44
|
+
export interface NonUpgradeableInstallStrategy<M extends string = string> extends InstallStrategyBase<M> {
|
|
45
|
+
readonly manualUpgradeMessage: readonly string[];
|
|
46
|
+
readonly upgradeable: false;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Discriminated union of install-method strategies. Discriminator is `upgradeable`. Consumers narrow on it to access manualUpgradeMessage with type safety;
|
|
50
|
+
* structurally impossible to declare an upgradeable strategy that carries manual instructions or a non-upgradeable strategy that omits them.
|
|
51
|
+
*/
|
|
52
|
+
export type InstallStrategy<M extends string = string> = UpgradeableInstallStrategy<M> | NonUpgradeableInstallStrategy<M>;
|
|
53
|
+
declare const STRATEGY_TUPLE: readonly [{
|
|
54
|
+
readonly displayName: "Docker";
|
|
55
|
+
readonly id: "docker";
|
|
56
|
+
readonly manualUpgradeMessage: readonly ["Docker containers cannot be upgraded in-place.", "To upgrade, pull the latest image and recreate the container:"];
|
|
57
|
+
readonly matches: (ctx: DetectionContext) => boolean;
|
|
58
|
+
readonly upgradeCommand: "docker pull ghcr.io/hjdhjd/prismcast:latest && docker compose up -d";
|
|
59
|
+
readonly upgradeable: false;
|
|
60
|
+
}, {
|
|
61
|
+
readonly displayName: "Homebrew";
|
|
62
|
+
readonly id: "homebrew";
|
|
63
|
+
readonly matches: (ctx: DetectionContext) => boolean;
|
|
64
|
+
readonly upgradeCommand: "brew update && brew upgrade prismcast";
|
|
65
|
+
readonly upgradeable: true;
|
|
66
|
+
}, {
|
|
67
|
+
readonly displayName: "npm (global)";
|
|
68
|
+
readonly id: "npm-global";
|
|
69
|
+
readonly matches: (ctx: DetectionContext) => boolean;
|
|
70
|
+
readonly upgradeCommand: "npm install -g prismcast@latest";
|
|
71
|
+
readonly upgradeable: true;
|
|
72
|
+
}, {
|
|
73
|
+
readonly displayName: "npm (local)";
|
|
74
|
+
readonly id: "npm-local";
|
|
75
|
+
readonly matches: (ctx: DetectionContext) => boolean;
|
|
76
|
+
readonly resolve: (ctx: DetectionContext) => ResolvableFields;
|
|
77
|
+
readonly upgradeCommand: "npm install prismcast@latest";
|
|
78
|
+
readonly upgradeable: true;
|
|
79
|
+
}];
|
|
80
|
+
/**
|
|
81
|
+
* The literal-union type of install method ids that strategies actually register for. Derived from the strategy tuple rather than declared in parallel - adding
|
|
82
|
+
* a strategy automatically widens this type, removing one is impossible without removing the strategy. There is no way for the type and the registry to drift.
|
|
83
|
+
*/
|
|
84
|
+
export type RegisteredMethod = typeof STRATEGY_TUPLE[number]["id"];
|
|
85
|
+
/**
|
|
86
|
+
* The install-method strategy registry. Same runtime data as STRATEGY_TUPLE; the public name carries the wide InstallStrategy<RegisteredMethod> type so the
|
|
87
|
+
* dispatcher (and any future consumer that iterates) sees the union uniformly. Order is priority order: docker first (container probe is unambiguous), homebrew
|
|
88
|
+
* (path marker is unambiguous), npm-global (requires successful npm prefix lookup), npm-local (broader path marker). Adding a new install method is appending an
|
|
89
|
+
* entry to STRATEGY_TUPLE.
|
|
90
|
+
*/
|
|
91
|
+
export declare const INSTALL_STRATEGIES: readonly InstallStrategy<RegisteredMethod>[];
|
|
92
|
+
/**
|
|
93
|
+
* The full install-method discriminator. Adds the unknown sentinel that the dispatcher returns when no strategy in the registry matches; everything else is
|
|
94
|
+
* registered. Consumers (e.g., commands.ts's switch on info.method) that need exhaustive coverage get it via this type.
|
|
95
|
+
*/
|
|
96
|
+
export type InstallMethod = RegisteredMethod | "unknown";
|
|
97
|
+
/**
|
|
98
|
+
* Common fields shared by every InstallInfo variant. Mirrors InstallStrategyBase but with `method: InstallMethod` instead of `id: M`, and extends ResolvableFields
|
|
99
|
+
* so packageDir is optionally present on either variant.
|
|
100
|
+
*/
|
|
101
|
+
interface InstallInfoBase extends ResolvableFields {
|
|
102
|
+
readonly displayName: string;
|
|
103
|
+
readonly method: InstallMethod;
|
|
104
|
+
readonly upgradeCommand: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* InstallInfo variant for upgradeable install methods. The upgrade runner can invoke upgradeCommand directly.
|
|
108
|
+
*/
|
|
109
|
+
export interface UpgradeableInstallInfo extends InstallInfoBase {
|
|
110
|
+
readonly upgradeable: true;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* InstallInfo variant for non-upgradeable install methods. Carries manualUpgradeMessage - the prose lines printed before the indented upgradeCommand. The
|
|
114
|
+
* structural guarantee that manualUpgradeMessage exists exactly when upgradeable is false means consumers (commands.ts) can narrow on `!info.upgradeable` and
|
|
115
|
+
* read the message with type safety, rather than switching on info.method to pick the right messaging.
|
|
116
|
+
*/
|
|
117
|
+
export interface NonUpgradeableInstallInfo extends InstallInfoBase {
|
|
118
|
+
readonly manualUpgradeMessage: readonly string[];
|
|
119
|
+
readonly upgradeable: false;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Information about the detected installation method and how to upgrade. Discriminated union over `upgradeable`; consumers narrow on it to choose between
|
|
123
|
+
* "run the command" and "print manual instructions" without ever switching on info.method.
|
|
124
|
+
*/
|
|
125
|
+
export type InstallInfo = UpgradeableInstallInfo | NonUpgradeableInstallInfo;
|
|
126
|
+
/**
|
|
127
|
+
* The fallback InstallInfo returned when no strategy in the registry matches. Development builds, npx invocations, and unrecognized layouts land here. The
|
|
128
|
+
* upgrade command points at the canonical npm-global install path because that is the most likely successful manual upgrade, but upgradeable is false so the
|
|
129
|
+
* tool prints instructions rather than running the command.
|
|
130
|
+
*/
|
|
131
|
+
export declare const UNKNOWN_INSTALL: NonUpgradeableInstallInfo;
|
|
132
|
+
/**
|
|
133
|
+
* Detects the installation method. Walks INSTALL_STRATEGIES in priority order; on the first match, builds an InstallInfo by composing the strategy's optional
|
|
134
|
+
* resolver output with the strategy's constant fields. The resolver's return type is restricted to ResolvableFields, so it cannot override id, displayName,
|
|
135
|
+
* upgradeCommand, or upgradeable; the spread order also places constants after the resolved fields as belt-and-suspenders. The strategy's `upgradeable`
|
|
136
|
+
* discriminator selects which InstallInfo variant the dispatcher emits, carrying manualUpgradeMessage through for the non-upgradeable case.
|
|
137
|
+
*
|
|
138
|
+
* Pure function of DetectionContext - all I/O happens inside the context's runCommand and fileExists callbacks, which the default adapter wires to real system
|
|
139
|
+
* calls and tests stub inline. Falls back to UNKNOWN_INSTALL when no strategy matches.
|
|
140
|
+
*
|
|
141
|
+
* @param ctx - The runtime context. Defaults to createDefaultDetectionContext() which builds one from real I/O.
|
|
142
|
+
* @returns Installation information.
|
|
143
|
+
*/
|
|
144
|
+
export declare function detectInstallMethod(ctx?: DetectionContext): InstallInfo;
|
|
145
|
+
export {};
|