dsh-update-status 0.3.2 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +10 -7
- package/README.zh.md +10 -7
- package/docs/platform-acceptance.md +7 -5
- package/docs/service-supervision.md +50 -13
- package/lib/client.js +83 -13
- package/lib/client.js.map +1 -1
- package/lib/index.js +347 -43
- package/lib/plan-D9Ybaj-3.js +746 -0
- package/lib/service-cli.d.ts +94 -0
- package/lib/service-cli.js +244 -403
- package/package.json +2 -6
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//#region src/service/types.d.ts
|
|
2
|
+
/** Cross-platform, user-owned DSH Web supervision contracts. */
|
|
3
|
+
type ServicePlatform = 'darwin' | 'linux' | 'win32';
|
|
4
|
+
interface ServiceSpec {
|
|
5
|
+
readonly schemaVersion: 1;
|
|
6
|
+
readonly platform: ServicePlatform;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
/** Absolute Node executable used to launch the DSH CLI. */
|
|
9
|
+
readonly nodePath: string;
|
|
10
|
+
/** Absolute DSH CLI executable (the file behind the `dsh` command). */
|
|
11
|
+
readonly dshPath: string;
|
|
12
|
+
readonly profile: string;
|
|
13
|
+
readonly workspace: string;
|
|
14
|
+
readonly host: string;
|
|
15
|
+
readonly port: number;
|
|
16
|
+
readonly home: string;
|
|
17
|
+
readonly dshHome?: string;
|
|
18
|
+
readonly logDir: string;
|
|
19
|
+
/** Final audited PATH persisted by install and reused by every later action. */
|
|
20
|
+
readonly servicePath?: string;
|
|
21
|
+
readonly servicePathSource?: 'current' | 'minimal' | 'explicit';
|
|
22
|
+
readonly servicePathCapturedAt?: string;
|
|
23
|
+
/** Windows command extension lookup, persisted alongside PATH. */
|
|
24
|
+
readonly servicePathExt?: string;
|
|
25
|
+
/** Human-readable warnings retained in the receipt and dry-run output. */
|
|
26
|
+
readonly servicePathWarnings?: readonly string[];
|
|
27
|
+
/** Absolute launchctl/systemctl/schtasks path; later actions never search PATH. */
|
|
28
|
+
readonly nativeServiceCommand?: string;
|
|
29
|
+
/** Written by the user-service definition, never inferred from a TTY. */
|
|
30
|
+
readonly supervisorMarker: 'dsh-update-status';
|
|
31
|
+
}
|
|
32
|
+
interface ServicePaths {
|
|
33
|
+
readonly stateFile: string;
|
|
34
|
+
readonly definitionFile: string;
|
|
35
|
+
/** macOS and Windows: the wrapper that owns the restart loop. */
|
|
36
|
+
readonly wrapperFile?: string;
|
|
37
|
+
readonly stdoutFile: string;
|
|
38
|
+
readonly stderrFile: string;
|
|
39
|
+
}
|
|
40
|
+
interface ServicePlan {
|
|
41
|
+
readonly spec: ServiceSpec;
|
|
42
|
+
readonly paths: ServicePaths;
|
|
43
|
+
readonly definition: string;
|
|
44
|
+
readonly wrapper?: string;
|
|
45
|
+
readonly installCommand: readonly string[];
|
|
46
|
+
readonly startCommand: readonly string[];
|
|
47
|
+
/**
|
|
48
|
+
* One copy-only line that lets the service take over again after it stopped
|
|
49
|
+
* (a tripped start limit, a given-up wrapper). Displayed only — never run by
|
|
50
|
+
* the plugin.
|
|
51
|
+
*/
|
|
52
|
+
readonly recoverCommand: string;
|
|
53
|
+
readonly statusCommand: readonly string[];
|
|
54
|
+
readonly stopCommand: readonly string[];
|
|
55
|
+
readonly uninstallCommand: readonly string[];
|
|
56
|
+
}
|
|
57
|
+
interface CliEnvironment {
|
|
58
|
+
readonly platform: NodeJS.Platform;
|
|
59
|
+
readonly home: string;
|
|
60
|
+
/** Numeric uid needed by launchctl's `gui/<uid>` domain. */
|
|
61
|
+
readonly uid?: number;
|
|
62
|
+
readonly cwd: string;
|
|
63
|
+
readonly execPath: string;
|
|
64
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
65
|
+
readonly path?: string;
|
|
66
|
+
}
|
|
67
|
+
interface CommandResult {
|
|
68
|
+
readonly status: number | null;
|
|
69
|
+
readonly stdout: string;
|
|
70
|
+
readonly stderr: string;
|
|
71
|
+
readonly error?: string;
|
|
72
|
+
}
|
|
73
|
+
type CommandRunner = (file: string, args: readonly string[]) => CommandResult;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/service/observe.d.ts
|
|
76
|
+
type ServiceVerification = {
|
|
77
|
+
readonly kind: 'settled';
|
|
78
|
+
} | {
|
|
79
|
+
readonly kind: 'crash-loop';
|
|
80
|
+
readonly recentRestarts: number;
|
|
81
|
+
readonly windowMs: number;
|
|
82
|
+
} | {
|
|
83
|
+
readonly kind: 'not-running';
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/service/cli.d.ts
|
|
87
|
+
export declare function serialisePlan(plan: ServicePlan): string;
|
|
88
|
+
export interface CliHooks {
|
|
89
|
+
readonly preflight?: (spec: ServiceSpec) => void;
|
|
90
|
+
/** Injected in tests; defaults to the real post-activation verification. */
|
|
91
|
+
readonly verify?: (spec: ServiceSpec) => Promise<ServiceVerification>;
|
|
92
|
+
}
|
|
93
|
+
export declare function main(argv?: readonly string[], env?: CliEnvironment, run?: CommandRunner, hooks?: CliHooks): Promise<number>;
|
|
94
|
+
//#endregion
|