@linxin666/dsh-client-ui-plugin-manager 0.4.12 → 0.4.14
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/README.i18n.yaml +2 -2
- package/README.md +6 -2
- package/README.zh.md +6 -2
- package/cordis.patch.yml +9 -0
- package/lib/client.js +825 -16
- package/lib/client.js.map +1 -1
- package/lib/index.js +686 -138
- package/lib/types/client/BuiltinPlugins.d.ts +41 -0
- package/lib/types/client/PluginListToolbar.d.ts +5 -4
- package/lib/types/client/builtin-plugins-mount.d.ts +42 -0
- package/lib/types/client/index.d.ts +10 -8
- package/lib/types/client/locales.d.ts +93 -0
- package/lib/types/client/native-faces.d.ts +61 -0
- package/lib/types/core/builtin.d.ts +178 -0
- package/lib/types/core/protocol.d.ts +33 -4
- package/lib/types/host/bundle-guard.d.ts +12 -1
- package/lib/types/host/gateway.d.ts +189 -2
- package/lib/types/host/legacy-migration.d.ts +2 -2
- package/lib/types/host/restart.d.ts +96 -4
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +5 -2
|
@@ -24,6 +24,26 @@ import { type OutputCapture } from './console-output.ts';
|
|
|
24
24
|
* @returns the rejection message, or undefined when the spec is safe.
|
|
25
25
|
*/
|
|
26
26
|
export declare function unsafeSpecReason(spec: string): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Whether one CLI run's captured output carries the skipped-build-script
|
|
29
|
+
* condition.
|
|
30
|
+
*
|
|
31
|
+
* `dsh plugin` forwards to pnpm, so a non-zero exit is pnpm's own verdict —
|
|
32
|
+
* except this one, which pnpm prints *after* it has written the profile: a
|
|
33
|
+
* dependency that declares a build script is not built until it is approved, and
|
|
34
|
+
* the unapproved one fails the command while the package is already on disk and
|
|
35
|
+
* the profile already carries it. Measured 2026-10-31 against the CLI's bundled
|
|
36
|
+
* pnpm 11.9.0 and against pnpm 11.24.0: `dsh plugin --profile web add
|
|
37
|
+
* cpu-features` exits 1 with its dependency landed, and the family aggregate
|
|
38
|
+
* exits the same way naming cloudflared, cpu-features and ssh2.
|
|
39
|
+
*
|
|
40
|
+
* The condition is necessary and not sufficient: only the profile can say
|
|
41
|
+
* whether the change the caller asked for really landed. The job runner reads it
|
|
42
|
+
* and keeps the exit a failure when it did not.
|
|
43
|
+
* @param output - the captured stdout and stderr of one CLI run.
|
|
44
|
+
* @returns true when pnpm named the build scripts it skipped.
|
|
45
|
+
*/
|
|
46
|
+
export declare function reportsIgnoredBuilds(output: string): boolean;
|
|
27
47
|
/** One CLI-backed operation in flight or settled. */
|
|
28
48
|
export interface GatewayJob {
|
|
29
49
|
id: string;
|
|
@@ -61,10 +81,45 @@ export interface GatewayJob {
|
|
|
61
81
|
* reporting a clean in-place update.
|
|
62
82
|
*/
|
|
63
83
|
restartRequired?: string[];
|
|
84
|
+
/**
|
|
85
|
+
* Conditions a settled run reported while still carrying its change out:
|
|
86
|
+
* pnpm's own words about a non-zero exit the gateway accepted because the
|
|
87
|
+
* profile really moved ({@link reportsIgnoredBuilds}). The job is `done` —
|
|
88
|
+
* the packages are installed — and this rides the same optional string-list
|
|
89
|
+
* fact channel as {@link GatewayJob.restartRequired}, because the `notices`
|
|
90
|
+
* ledger records row-state moves in the conflict-row shape and a build-script
|
|
91
|
+
* diagnostic is neither a row nor a state.
|
|
92
|
+
*/
|
|
93
|
+
warnings?: string[];
|
|
64
94
|
error?: string;
|
|
65
95
|
}
|
|
66
96
|
/** The binary search roots for the dsh CLI. */
|
|
67
97
|
export declare function findDshBinary(env?: NodeJS.ProcessEnv, platform?: string, exists?: (path: string) => boolean, hostEntryPath?: string | undefined, resourcesPath?: string | undefined): string | null;
|
|
98
|
+
/**
|
|
99
|
+
* The installation copy of one bundle package, when the DSH installation this
|
|
100
|
+
* runtime runs out of carries it.
|
|
101
|
+
*
|
|
102
|
+
* A CLI-created profile names the official bundles in `dsh.profile.bundles`
|
|
103
|
+
* without ever installing them: `@deepseek-ai/dsh-base` and
|
|
104
|
+
* `@deepseek-ai/dsh-web-app` are mounted from the DSH installation the loader
|
|
105
|
+
* runs out of, so no profile copy exists and their rows are declared by the
|
|
106
|
+
* installation's own package. That copy is the one whose rows mount, so a
|
|
107
|
+
* missing profile copy is not proof of an unknown declaration set (see
|
|
108
|
+
* {@link CliGateway.liveOverrideIds}).
|
|
109
|
+
*
|
|
110
|
+
* Resolution follows Node's own lookup from the CLI entry: every ancestor
|
|
111
|
+
* directory contributes `node_modules/<name>`, plus the npm-global and
|
|
112
|
+
* homebrew `<ancestor>/lib/node_modules/<name>`. The entry is resolved through
|
|
113
|
+
* its symlinks first, because npm-global and homebrew install the `dsh` shim
|
|
114
|
+
* as a link into the package tree while the shim's own directory carries no
|
|
115
|
+
* packages.
|
|
116
|
+
* @param binary - the resolved dsh CLI path, or null when this runtime has none.
|
|
117
|
+
* @param name - the bundle package name from `dsh.profile.bundles`.
|
|
118
|
+
* @param exists - existence probe (test seam).
|
|
119
|
+
* @param resolveReal - symlink resolver (test seam).
|
|
120
|
+
* @returns the installation package directory, or undefined when it has none.
|
|
121
|
+
*/
|
|
122
|
+
export declare function hostBundleDir(binary: string | null, name: string, exists?: (path: string) => boolean, resolveReal?: (path: string) => string | undefined): string | undefined;
|
|
68
123
|
/**
|
|
69
124
|
* Read a file's leading bytes for the shebang probe. Every failure — a missing
|
|
70
125
|
* file, a directory, a permission error, an unreadable asar entry — reads as
|
|
@@ -395,8 +450,40 @@ export declare class CliGateway {
|
|
|
395
450
|
private restoreSpec;
|
|
396
451
|
/** Execute the legacy aggregate migration and settle the job. */
|
|
397
452
|
private runMigration;
|
|
398
|
-
/**
|
|
453
|
+
/**
|
|
454
|
+
* Restore the original legacy package after a failed migration.
|
|
455
|
+
*
|
|
456
|
+
* The forward migration removed the legacy package first, so the way back is
|
|
457
|
+
* a remove-then-add in the other direction — and each half has to be read, not
|
|
458
|
+
* assumed. A removal that does not take the new aggregate back out leaves the
|
|
459
|
+
* profile carrying it with the legacy package gone, and re-adding the legacy
|
|
460
|
+
* package on top of it is exactly the dual-mount shape this path exists to
|
|
461
|
+
* avoid: both bundles declare the same row ids, the loader mounts one of them
|
|
462
|
+
* without a word, and the next update resolves against a profile that no
|
|
463
|
+
* longer describes itself. Such a rollback is reported as incomplete
|
|
464
|
+
* ({@link incompleteRollback}) instead of claimed as done.
|
|
465
|
+
* @returns true when the rollback finished — the legacy package is back, or
|
|
466
|
+
* the profile deliberately keeps the single current aggregate — and false
|
|
467
|
+
* when it could not run or could not finish, in which case `job.error`
|
|
468
|
+
* already carries the report and the caller must not replace it with its
|
|
469
|
+
* own reason.
|
|
470
|
+
*/
|
|
399
471
|
private rollbackMigration;
|
|
472
|
+
/**
|
|
473
|
+
* The report for a rollback that could not take the new aggregate back out.
|
|
474
|
+
*
|
|
475
|
+
* The profile is left carrying the new package with the legacy one gone,
|
|
476
|
+
* which is neither the migration nor a rollback, and it is not a state the
|
|
477
|
+
* legacy package may be re-added into: both bundles declare the same row ids,
|
|
478
|
+
* so keeping one of them is the only safe outcome. The message therefore says
|
|
479
|
+
* what actually happened, never claims a rollback that did not run, and names
|
|
480
|
+
* the two commands that carry it out by hand.
|
|
481
|
+
* @param targetId - the new aggregate this migration installed.
|
|
482
|
+
* @param restoreOld - the exact spec that reinstalls the legacy package.
|
|
483
|
+
* @param reason - the CLI's own words, or the exit it reported.
|
|
484
|
+
* @returns the job error text.
|
|
485
|
+
*/
|
|
486
|
+
private incompleteRollback;
|
|
400
487
|
/** Spawn the CLI, through the test seam when present. */
|
|
401
488
|
private spawnCli;
|
|
402
489
|
/**
|
|
@@ -576,6 +663,33 @@ export declare class CliGateway {
|
|
|
576
663
|
* existed.
|
|
577
664
|
*/
|
|
578
665
|
status(jobId: string): GatewayJob | undefined;
|
|
666
|
+
/**
|
|
667
|
+
* Whether this gateway's own record says the last in-place update of one
|
|
668
|
+
* plugin at one version never settled.
|
|
669
|
+
*
|
|
670
|
+
* The update path writes the profile before it verifies it: the CLI puts the
|
|
671
|
+
* target version on disk, and the boot preflight (`--dump-config`, see
|
|
672
|
+
* {@link verifyBoot}) then decides whether the run is reported as landed. A
|
|
673
|
+
* preflight failure the plugin is not implicated in settles the job as an
|
|
674
|
+
* error with the new version already installed, which leaves the profile at
|
|
675
|
+
* the target version while the update itself failed. That state cannot be
|
|
676
|
+
* reached again through the update action — the row already carries the
|
|
677
|
+
* latest version, so the route answers 409 "already at <version>" and the
|
|
678
|
+
* only way out is a reinstall run by hand. This is the fact that lets that
|
|
679
|
+
* route tell the state apart from a plugin that is genuinely up to date,
|
|
680
|
+
* which must keep its 409.
|
|
681
|
+
*
|
|
682
|
+
* Only the most recent update of the plugin counts. A settled run — a later
|
|
683
|
+
* success, or a run that landed nothing and rolled back — is the plugin's
|
|
684
|
+
* current standing, whatever an older failed attempt said, so the scan starts
|
|
685
|
+
* at the newest settled job and stops at the first one that is this plugin's
|
|
686
|
+
* update. Jobs this gateway no longer holds (the ring cap, a restart) are
|
|
687
|
+
* unknown rather than failed, and answer false.
|
|
688
|
+
* @param id - the installed package name.
|
|
689
|
+
* @param version - the version the profile currently carries.
|
|
690
|
+
* @returns true when the newest recorded update of `id` failed at `version`.
|
|
691
|
+
*/
|
|
692
|
+
lastUpdateFailed(id: string, version: string): boolean;
|
|
579
693
|
/** Capture the layer snapshot and the dependency names (tolerant parse). */
|
|
580
694
|
private capture;
|
|
581
695
|
/** The plugin row a finished operation produced (installed or removed). */
|
|
@@ -584,6 +698,17 @@ export declare class CliGateway {
|
|
|
584
698
|
private run;
|
|
585
699
|
/** The mutation body of {@link run}. */
|
|
586
700
|
private runInner;
|
|
701
|
+
/**
|
|
702
|
+
* Carry an accepted non-zero exit to the caller and to the host log.
|
|
703
|
+
*
|
|
704
|
+
* Every post-check passed, so the change landed and the job settles `done`;
|
|
705
|
+
* the pnpm output is kept anyway, because it is the only record that a
|
|
706
|
+
* dependency was installed without its build script — a fact the next boot
|
|
707
|
+
* reports as a missing native module, with nothing left to attribute it to.
|
|
708
|
+
* @param job - the job the run settles.
|
|
709
|
+
* @param tolerated - the exit the profile overruled.
|
|
710
|
+
*/
|
|
711
|
+
private recordToleratedExit;
|
|
587
712
|
/**
|
|
588
713
|
* Post-mutation duplicate-mount safeguard (B9): remove the bundles entries
|
|
589
714
|
* the CLI's reconciliation newly added for packages the before-state
|
|
@@ -611,7 +736,7 @@ export declare class CliGateway {
|
|
|
611
736
|
private compositionOf;
|
|
612
737
|
/**
|
|
613
738
|
* The entry ids a user-layer override may still point at: the composed ids
|
|
614
|
-
* plus every id the
|
|
739
|
+
* plus every id the bundles the profile lists still declare.
|
|
615
740
|
*
|
|
616
741
|
* The composition alone does not prove a row is retired. A host that
|
|
617
742
|
* composes while a bundle is being replaced — the remove-then-install half of
|
|
@@ -620,11 +745,41 @@ export declare class CliGateway {
|
|
|
620
745
|
* gone, and pruning on that probe deletes the user's override for a row that
|
|
621
746
|
* still exists (0.4.7 lost `web-ui-remote-web-ui` and `ui-schedule` this
|
|
622
747
|
* way). Declarations live in the bundle layers, so they survive that window.
|
|
748
|
+
*
|
|
749
|
+
* Every listed bundle therefore has to answer with the declarations the
|
|
750
|
+
* loader will actually mount, which for an installation-provided bundle is
|
|
751
|
+
* the installation's copy rather than a profile copy that never existed
|
|
752
|
+
* ({@link bundleLayerDir}).
|
|
623
753
|
* @param composed - the entry ids of the composition probe.
|
|
624
754
|
* @returns the ids to keep, or undefined when a declared layer cannot be
|
|
625
755
|
* read, which proves nothing either way and must leave the file alone.
|
|
626
756
|
*/
|
|
627
757
|
private liveOverrideIds;
|
|
758
|
+
/**
|
|
759
|
+
* The directory whose `cordis.patch.yml` declares one listed bundle's rows,
|
|
760
|
+
* or undefined when those declarations cannot be known.
|
|
761
|
+
*
|
|
762
|
+
* The profile's own copy answers whenever it is installed. A profile that
|
|
763
|
+
* lists a bundle its own `node_modules` does not carry is normally a
|
|
764
|
+
* CLI-created profile naming the installation's bundles — it never installs
|
|
765
|
+
* `@deepseek-ai/dsh-base` or `@deepseek-ai/dsh-web-app`, the loader mounts
|
|
766
|
+
* them out of the DSH installation, and {@link hostBundleDir} names that copy,
|
|
767
|
+
* whose rows are by construction the ones this boot carries.
|
|
768
|
+
*
|
|
769
|
+
* Everything else that reads as missing is a package this profile installs
|
|
770
|
+
* itself, caught mid-install or mid-replace. Its rows can be declared by the
|
|
771
|
+
* copy that is gone and by no other, so they are unknown, never empty:
|
|
772
|
+
* pruning on that guess is how 0.4.7 lost the user's `web-ui-remote-web-ui`
|
|
773
|
+
* and `ui-schedule` overrides. The profile's own dependency list separates
|
|
774
|
+
* the two cases, because it is written by the same pnpm call that creates the
|
|
775
|
+
* directory: a dependency is this profile's package, so a missing directory
|
|
776
|
+
* there is unfinished work rather than an installation-provided bundle.
|
|
777
|
+
* @param name - one entry of `dsh.profile.bundles`.
|
|
778
|
+
* @param dependencies - the profile manifest's dependency map.
|
|
779
|
+
* @param binary - the dsh CLI path, or null when this runtime has none.
|
|
780
|
+
* @returns the declaring package directory, or undefined when unknown.
|
|
781
|
+
*/
|
|
782
|
+
private bundleLayerDir;
|
|
628
783
|
/**
|
|
629
784
|
* The entry names the installed bundles' own rows carry, by entry id.
|
|
630
785
|
*
|
|
@@ -700,6 +855,38 @@ export declare class CliGateway {
|
|
|
700
855
|
private unresolvableInsertNames;
|
|
701
856
|
/** The new dependency of an install, when one exists. */
|
|
702
857
|
private newDependency;
|
|
858
|
+
/**
|
|
859
|
+
* Whether a run wrote a package that declares its own bundle without the
|
|
860
|
+
* profile selecting it.
|
|
861
|
+
*
|
|
862
|
+
* The landing reads in {@link runInner} look at `dependencies` alone, and
|
|
863
|
+
* pnpm writes that line before the build-script gate decides the exit: a
|
|
864
|
+
* dependency is not a mount. A package declaring `dsh.bundle` is only
|
|
865
|
+
* reachable through `dsh.profile.bundles`, so a selection that never landed
|
|
866
|
+
* (a fresh install) or left with the run (a replacement of a selected
|
|
867
|
+
* package) is a half mount: the composition carries not one row of it while
|
|
868
|
+
* every other check passes.
|
|
869
|
+
* @param name - the dependency the run added or targeted.
|
|
870
|
+
* @param bundles - the selection the CLI's own run left behind, read before
|
|
871
|
+
* the duplicate-mount strip can correct its entries.
|
|
872
|
+
* @param required - whether the selection has to be present: always for a
|
|
873
|
+
* fresh install, and for a replacement only when the profile already
|
|
874
|
+
* selected the package (a patch-row mount was never selected to lose).
|
|
875
|
+
* @returns whether a bundle-declaring package ended up unselected.
|
|
876
|
+
*/
|
|
877
|
+
private bundleSelectionMissing;
|
|
878
|
+
/**
|
|
879
|
+
* The diagnostic for {@link bundleSelectionMissing}: which package the
|
|
880
|
+
* composition does not mount, and the two steps that repair it. Repeating the
|
|
881
|
+
* same command cannot — the CLI reconciles only the dependencies it newly
|
|
882
|
+
* added — so the remedy is an approval followed by remove and add.
|
|
883
|
+
* @param name - the dependency left unselected.
|
|
884
|
+
* @param lead - the run's own prefix for the sentence.
|
|
885
|
+
* @param tolerated - the accepted non-zero exit, whose pnpm tail names the
|
|
886
|
+
* build scripts it skipped.
|
|
887
|
+
* @returns the error text.
|
|
888
|
+
*/
|
|
889
|
+
private halfMountError;
|
|
703
890
|
/** The claimed entry ids of one installed dependency (its own bundle patch, or its name). */
|
|
704
891
|
private claimedEntriesOf;
|
|
705
892
|
/** Whether the new install claims an entry id another plugin already holds. */
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The runtime identifiers (web-ui-* rows, settings section, API paths,
|
|
5
5
|
* storage keys) stay frozen; only the npm aggregate package name changes.
|
|
6
|
-
* This module is the single migration map
|
|
7
|
-
*
|
|
6
|
+
* This module is the single migration map for the plugin-manager update job,
|
|
7
|
+
* the one official writer that rewrites a user profile.
|
|
8
8
|
*/
|
|
9
9
|
/** The previously published aggregate package name. */
|
|
10
10
|
export declare const LEGACY_AGGREGATE = "@linxin666/dsh-web-ui-all";
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
* guarantee in {@link SHELL_RESTART_CAPABILITY_ENV}; a host that sees no such
|
|
20
20
|
* marker answers 'manual' instead of stopping itself (see
|
|
21
21
|
* {@link shellRestartIsSupported}).
|
|
22
|
+
* - A host that systemd started is restarted by systemd: the manager owns this
|
|
23
|
+
* process tree, so asking it to restart the unit is the one action that
|
|
24
|
+
* survives this process stopping. The host proves that case from its own
|
|
25
|
+
* cgroup and environment ({@link readSystemdFacts}) and names the unit it
|
|
26
|
+
* asks; the request goes out after the response, because the stop job starts
|
|
27
|
+
* the moment the request is queued. Mode 'systemd'. A system unit keeps the
|
|
28
|
+
* manual answer: restarting it needs privileges this process does not have.
|
|
22
29
|
* - A host this plugin can prove is a terminal launch (an interactive stdio
|
|
23
30
|
* pair, no Electron in the environment) is restarted in place: a detached
|
|
24
31
|
* helper waits for this process to exit and re-executes the same command
|
|
@@ -32,8 +39,10 @@
|
|
|
32
39
|
* spawning anything; {@link performRestart} is the effectful half.
|
|
33
40
|
* @module @linxin666/dsh-client-ui-plugin-manager/host
|
|
34
41
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
import { type ChildProcess, type SpawnOptions } from 'node:child_process';
|
|
43
|
+
import { type RestartMode } from '../core/protocol.ts';
|
|
44
|
+
/** How a restart request is carried out (single source: core/protocol.ts). */
|
|
45
|
+
export type { RestartMode };
|
|
37
46
|
/** The command line a relaunch re-executes. */
|
|
38
47
|
export interface RelaunchCommand {
|
|
39
48
|
/** Absolute path of the executable (Node, or the Electron binary in Node mode). */
|
|
@@ -50,6 +59,8 @@ export interface RestartPlan {
|
|
|
50
59
|
mode: RestartMode;
|
|
51
60
|
/** Present exactly when mode is 'relaunch'. */
|
|
52
61
|
command?: RelaunchCommand;
|
|
62
|
+
/** Present exactly when mode is 'systemd': the unit systemd is asked to restart. */
|
|
63
|
+
unit?: string;
|
|
53
64
|
}
|
|
54
65
|
/** The process facts the verdict is derived from. */
|
|
55
66
|
export interface RestartFacts {
|
|
@@ -62,7 +73,59 @@ export interface RestartFacts {
|
|
|
62
73
|
cwd: string;
|
|
63
74
|
/** Whether stdio is a terminal (a launch a human can see and stop). */
|
|
64
75
|
interactive: boolean;
|
|
76
|
+
/** The systemd unit this process runs as, when it runs as one. */
|
|
77
|
+
systemd?: SystemdFacts;
|
|
65
78
|
}
|
|
79
|
+
/** The systemd unit this host was started as, when it was started as one. */
|
|
80
|
+
export interface SystemdFacts {
|
|
81
|
+
/** Unit name as the cgroup spells it, e.g. `dsh-web.service`. */
|
|
82
|
+
unit: string;
|
|
83
|
+
/** Which manager owns the unit: this user's own manager, or the system manager. */
|
|
84
|
+
scope: 'user' | 'system';
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Read the systemd-service facts out of a cgroup path and a launch environment,
|
|
88
|
+
* without touching the system.
|
|
89
|
+
*
|
|
90
|
+
* All three markers must hold, and each one is what makes a false positive a
|
|
91
|
+
* real hazard rather than a wrong label:
|
|
92
|
+
* - The cgroup's last segment is the decisive one: only a `*.service` unit of
|
|
93
|
+
* the conservative shape this package accepts on the wire names a service,
|
|
94
|
+
* while a scope, a session, or a container path is not a unit. A process this
|
|
95
|
+
* host starts by hand lands in a scope of its own or shares the host's
|
|
96
|
+
* cgroup, so this segment is what separates a service from what runs inside
|
|
97
|
+
* one.
|
|
98
|
+
* - `INVOCATION_ID` rules a launch out but proves nothing on its own: every
|
|
99
|
+
* process this host starts inherits the host's own marker unchanged, so its
|
|
100
|
+
* presence is indistinguishable from the host's. It is what rejects a cgroup
|
|
101
|
+
* path that ends in a service unit only because some other tool put the
|
|
102
|
+
* process there, which is not a service any manager restarts on request.
|
|
103
|
+
* - The slice says which manager owns it. Only this user's manager is
|
|
104
|
+
* reachable without privileges, and it is reachable only through its own
|
|
105
|
+
* socket ({@link readSystemdFacts} checks that; this parser takes the answer).
|
|
106
|
+
*
|
|
107
|
+
* The user manager's own cgroup ends in `user@<uid>.service`. That is a unit
|
|
108
|
+
* name of this shape, and restarting it takes down every service the manager
|
|
109
|
+
* runs, so it is refused rather than read as this host's own unit.
|
|
110
|
+
* @param cgroup - the cgroup path (or a whole `/proc/self/cgroup` line).
|
|
111
|
+
* @param env - the launch environment.
|
|
112
|
+
* @param managerSocket - whether this user's systemd manager socket exists.
|
|
113
|
+
* @returns the unit and its scope, or undefined when this is not a service
|
|
114
|
+
* this package can ask for a restart.
|
|
115
|
+
*/
|
|
116
|
+
export declare function parseSystemdFacts(cgroup: string, env: NodeJS.ProcessEnv, managerSocket: boolean): SystemdFacts | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Read this process's own systemd-service facts (Linux only).
|
|
119
|
+
*
|
|
120
|
+
* Every step is a read that fails on another platform, in a container, or
|
|
121
|
+
* under an init that is not systemd, and each failure answers "not a systemd
|
|
122
|
+
* service" instead of throwing: the route that reads this must keep answering
|
|
123
|
+
* 'manual' rather than turning a restart plan into a 500.
|
|
124
|
+
* @param env - the launch environment (INVOCATION_ID, XDG_RUNTIME_DIR).
|
|
125
|
+
* @param cgroupFile - the file carrying this process's cgroup (test seam).
|
|
126
|
+
* @returns the unit and scope, or undefined when this host is not a service.
|
|
127
|
+
*/
|
|
128
|
+
export declare function readSystemdFacts(env?: NodeJS.ProcessEnv, cgroupFile?: string): SystemdFacts | undefined;
|
|
66
129
|
/** Grace period between answering the restart request and leaving the process. */
|
|
67
130
|
export declare const RESTART_EXIT_DELAY_MS = 400;
|
|
68
131
|
/**
|
|
@@ -87,7 +150,8 @@ export declare const RESTART_WAIT_MS = 30000;
|
|
|
87
150
|
/**
|
|
88
151
|
* Decide how a restart request is carried out.
|
|
89
152
|
* @param facts - the running process's launch facts.
|
|
90
|
-
* @returns the planned mode, with the relaunch command when one is used
|
|
153
|
+
* @returns the planned mode, with the relaunch command when one is used and
|
|
154
|
+
* the systemd unit when systemd performs the restart.
|
|
91
155
|
*/
|
|
92
156
|
export declare function planRestart(facts: RestartFacts): RestartPlan;
|
|
93
157
|
/** Absolute path of the relaunch journal this plugin appends to. */
|
|
@@ -99,10 +163,35 @@ export declare function restartLogPath(home?: string): string;
|
|
|
99
163
|
* @returns true when a helper process was actually created.
|
|
100
164
|
*/
|
|
101
165
|
export declare function startRelaunchHelper(command: RelaunchCommand, logPath?: string): boolean;
|
|
166
|
+
/** Effect seams for {@link requestUnitRestart} (tests replace them). */
|
|
167
|
+
export interface UnitRestartRuntime {
|
|
168
|
+
/** Start the manager command; the default is node's own `spawn`. */
|
|
169
|
+
spawn?: (executable: string, args: readonly string[], options: SpawnOptions) => ChildProcess;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Ask this user's systemd manager to restart one unit.
|
|
173
|
+
*
|
|
174
|
+
* `--no-block` returns as soon as the request is queued, so the caller is never
|
|
175
|
+
* held by a stop job it just started and the manager owns the rest. What the
|
|
176
|
+
* command itself says goes to the journal, and so does a deterministic non-zero
|
|
177
|
+
* exit code; a signal death is not, because it is the stop job this request
|
|
178
|
+
* queued (the note beside the exit handler spells that out). From here a
|
|
179
|
+
* refused request looks exactly like a queued one, and the journal is the only
|
|
180
|
+
* place that difference can be read. Nothing is thrown: by the time
|
|
181
|
+
* this runs the route has already answered 202, so an exception here would be
|
|
182
|
+
* an unhandled event in a host nobody is left watching.
|
|
183
|
+
* @param unit - the unit to restart.
|
|
184
|
+
* @param logPath - journal that records what the command said and how it ended.
|
|
185
|
+
* @param runtime - effect seams; the default spawns systemctl detached.
|
|
186
|
+
* @returns true when a systemctl process was actually created.
|
|
187
|
+
*/
|
|
188
|
+
export declare function requestUnitRestart(unit: string, logPath?: string, runtime?: UnitRestartRuntime): boolean;
|
|
102
189
|
/** Effect seams for {@link performRestart} (tests replace them). */
|
|
103
190
|
export interface RestartRuntime {
|
|
104
191
|
/** Start the relaunch helper; false means no replacement was created. */
|
|
105
192
|
startHelper?: (command: RelaunchCommand) => boolean;
|
|
193
|
+
/** Ask systemd to restart one unit. */
|
|
194
|
+
requestUnit?: (unit: string) => void;
|
|
106
195
|
/** Leave this process. */
|
|
107
196
|
exit?: () => void;
|
|
108
197
|
/** Schedule the exit (delay seam). */
|
|
@@ -111,8 +200,11 @@ export interface RestartRuntime {
|
|
|
111
200
|
/**
|
|
112
201
|
* Carry out one restart plan.
|
|
113
202
|
* @param plan - the verdict from {@link planRestart}.
|
|
114
|
-
* @param runtime - effect seams; the defaults spawn the helper
|
|
203
|
+
* @param runtime - effect seams; the defaults spawn the helper, ask systemd,
|
|
204
|
+
* and exit.
|
|
115
205
|
* @returns the mode actually used: 'relaunch' degrades to 'manual' when the
|
|
116
206
|
* helper could not be started, so a process that cannot be replaced stays up.
|
|
207
|
+
* A systemd request goes out after the answer and is not awaited, so it keeps
|
|
208
|
+
* the mode it was planned with; a failed request is journaled, not reported.
|
|
117
209
|
*/
|
|
118
210
|
export declare function performRestart(plan: RestartPlan, runtime?: RestartRuntime): RestartMode;
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-client-ui-plugin-manager",
|
|
3
3
|
"description": "Update checking for the dsh web GUI's official Plugins page: compares installed plugins against the version their registry source serves, gates the update on the DSH runtime minimum the release declares, and drives the update through the official installer channel or this package's loopback CLI gateway.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.14",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
"default": "./lib/client.js"
|
|
17
17
|
},
|
|
18
18
|
"./src/*": "./src/*",
|
|
19
|
+
"./locale/en.json": "./locale/en.json",
|
|
20
|
+
"./locale/zh.json": "./locale/zh.json",
|
|
19
21
|
"./package.json": "./package.json"
|
|
20
22
|
},
|
|
21
23
|
"dsh": {
|
|
@@ -70,7 +72,8 @@
|
|
|
70
72
|
"README.md",
|
|
71
73
|
"README.zh.md",
|
|
72
74
|
"README.i18n.yaml",
|
|
73
|
-
"icon.svg"
|
|
75
|
+
"icon.svg",
|
|
76
|
+
"locale"
|
|
74
77
|
],
|
|
75
78
|
"license": "BSD-3-Clause",
|
|
76
79
|
"dependencies": {
|