@sparkelf/dsh-plus 0.2.4-alpha.47 → 0.2.5-alpha.49
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/lib/bin.js +780 -326
- package/lib/types/bin.js +1 -1
- package/lib/types/capabilities.d.ts +139 -0
- package/lib/types/capabilities.js +688 -0
- package/lib/types/cli.d.ts +17 -0
- package/lib/types/cli.js +913 -0
- package/lib/types/manifest.d.ts +137 -0
- package/lib/types/manifest.js +398 -0
- package/lib/types/profile.d.ts +218 -0
- package/lib/types/profile.js +670 -0
- package/lib/types/server.d.ts +70 -0
- package/lib/types/server.js +158 -0
- package/lib/types/standalone-cli.js +274 -93
- package/lib/types/standalone-profile.d.ts +54 -17
- package/lib/types/standalone-profile.js +273 -247
- package/package.json +169 -124
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime paths and profile composition for a standalone Plus installation.
|
|
3
|
+
*
|
|
4
|
+
* A standalone consumer installs the distribution from the registry and owns its
|
|
5
|
+
* profile, so this module answers the two questions every command shares: where the
|
|
6
|
+
* DSH home and profile live, and what the profile manifest must contain. The bundle
|
|
7
|
+
* order comes from the installed distribution rather than from a copy here, because
|
|
8
|
+
* the launcher mounts exactly the bundles the profile names and nothing expands a
|
|
9
|
+
* bundle's own list.
|
|
10
|
+
*/
|
|
11
|
+
import { readDistributionFacts } from './manifest.ts';
|
|
12
|
+
/** Profile name the launcher materializes when no edition is selected. */
|
|
13
|
+
export declare const DEFAULT_PROFILE = "plus";
|
|
14
|
+
/** Resolved locations for one standalone installation. */
|
|
15
|
+
export interface StandalonePaths {
|
|
16
|
+
/** DSH home holding profiles, credentials, and session data. */
|
|
17
|
+
readonly home: string;
|
|
18
|
+
/** Profile name the launcher boots, as the installing package declares it. */
|
|
19
|
+
readonly profileName: string;
|
|
20
|
+
/** Capabilities the deployment omits, as package name to override spec. */
|
|
21
|
+
readonly omittedPackages: Readonly<Record<string, string>>;
|
|
22
|
+
/** Profile directory the launcher boots. */
|
|
23
|
+
readonly profileDirectory: string;
|
|
24
|
+
/** Installed Plus distribution directory. */
|
|
25
|
+
readonly distributionDirectory: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the file that was actually invoked from the path the shell was handed.
|
|
29
|
+
*
|
|
30
|
+
* A global npm install links `<prefix>/bin/dsh-plus` to the package entry. Resolving
|
|
31
|
+
* `@sparkelf/dsh-plus` from that link starts at the bin directory, which has no
|
|
32
|
+
* `node_modules`, so every globally installed command reported the distribution as
|
|
33
|
+
* missing. The real path is the package file, and the package resolves its own name.
|
|
34
|
+
*
|
|
35
|
+
* @param invoked - `process.argv[1]`, or undefined when node ran without a script.
|
|
36
|
+
* @param fallback - this module's own file, used when there is no script path.
|
|
37
|
+
* @returns an absolute path that exists, or the input when it cannot be resolved.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveInvocationAnchor(invoked: string | undefined, fallback: string): string;
|
|
40
|
+
/** Resolve the DSH home, honouring the environment override the launcher itself reads. */
|
|
41
|
+
export declare function resolveHome(env?: NodeJS.ProcessEnv): string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether one absolute path is the other or sits beneath it.
|
|
44
|
+
*
|
|
45
|
+
* A path outside the parent has a relative form starting with `..`, which every
|
|
46
|
+
* platform answers the same way. Comparing the text against a literal separator is
|
|
47
|
+
* not: Windows separates with a backslash, so a nested path never matched its own
|
|
48
|
+
* ancestor and every Windows installation reported the distribution as sitting
|
|
49
|
+
* outside its own tree.
|
|
50
|
+
*
|
|
51
|
+
* @param candidate - absolute path to test.
|
|
52
|
+
* @param parent - absolute path that may contain it.
|
|
53
|
+
* @param platform - separating convention, injectable so the Windows answer is
|
|
54
|
+
* testable where the suite runs on a POSIX host.
|
|
55
|
+
* @returns true when the candidate is the parent or inside it.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isWithin(candidate: string, parent: string, platform?: NodeJS.Platform): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Resolve the installed distribution directory from one requiring anchor.
|
|
60
|
+
*
|
|
61
|
+
* The anchor must be a path inside the consumer's own tree. Resolving from this
|
|
62
|
+
* module instead would find the distribution the module itself was loaded from,
|
|
63
|
+
* which is the repository during development and the consumer's install otherwise.
|
|
64
|
+
*
|
|
65
|
+
* @param anchor - `package.json` path or directory in the consumer tree.
|
|
66
|
+
* @returns absolute path to the installed distribution.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveDistributionDirectory(anchor: string): string;
|
|
69
|
+
/** The reviewed bundle order and pins the installed distribution declares, for one variant. */
|
|
70
|
+
export declare function readDistributionProfile(distributionDirectory: string, editionId?: string, extraExcludes?: readonly string[]): {
|
|
71
|
+
readonly name: string;
|
|
72
|
+
readonly version: string;
|
|
73
|
+
readonly dshRange: string;
|
|
74
|
+
readonly runtimeVersion: string;
|
|
75
|
+
readonly bundles: readonly string[];
|
|
76
|
+
readonly dependencies: Readonly<Record<string, string>>;
|
|
77
|
+
readonly allowBuilds: Readonly<Record<string, boolean>>;
|
|
78
|
+
readonly overrides: Readonly<Record<string, string>>;
|
|
79
|
+
readonly omittedPackages: Readonly<Record<string, string>>;
|
|
80
|
+
readonly editions: ReturnType<typeof readDistributionFacts>['editions'];
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Give the profile its own installed tree, built from the distribution's declarations.
|
|
84
|
+
*
|
|
85
|
+
* The launcher resolves a bundle from the profile directory, so the profile needs its
|
|
86
|
+
* own `node_modules`. Pointing it at the consumer's tree was cheaper, but it made the
|
|
87
|
+
* profile inherit whatever npm had already installed — including the official packages
|
|
88
|
+
* the distribution's `overrides` exist to replace. npm applies `overrides` only from a
|
|
89
|
+
* project's own root, so a profile without its own tree cannot receive them at all, and
|
|
90
|
+
* a patch delivered that way silently never arrives.
|
|
91
|
+
*
|
|
92
|
+
* Installing here makes the profile that root: pnpm reads `overrides` from the
|
|
93
|
+
* profile's own `pnpm-workspace.yaml`, which `writeProfileOverrides` writes before this
|
|
94
|
+
* runs. The install is skipped once the tree exists so a start does not pay for it
|
|
95
|
+
* twice; `dsh-plus apply` remains the command that reinstalls after a change.
|
|
96
|
+
*
|
|
97
|
+
* @param paths - resolved standalone paths.
|
|
98
|
+
*/
|
|
99
|
+
export declare function installProfilePackages(paths: StandalonePaths, omitted?: ReadonlySet<string>, runtimeVersion?: string, registry?: string): void;
|
|
100
|
+
/**
|
|
101
|
+
* Move the shared official services onto the runtime's exact version.
|
|
102
|
+
*
|
|
103
|
+
* The republished builds were cut against one runtime, and DSH disables a row when the exact
|
|
104
|
+
* peers a plugin declares disagree with the process it shares. Plugins declare those services as
|
|
105
|
+
* peers, so the names worth pinning are the peers actually installed -- read from the tree and
|
|
106
|
+
* checked against the registry. The rest of the official family keeps its resolved versions:
|
|
107
|
+
* pinning everything traded one mismatch for a tree with holes.
|
|
108
|
+
*
|
|
109
|
+
* @param profileDirectory - profile whose tree was just installed.
|
|
110
|
+
* @param runtimeVersion - exact runtime the profile boots.
|
|
111
|
+
* @param registry - registry the profile installs from.
|
|
112
|
+
* @returns how many services were realigned.
|
|
113
|
+
*/
|
|
114
|
+
export declare function alignOfficialVersions(profileDirectory: string, runtimeVersion: string, registry: string): number;
|
|
115
|
+
/**
|
|
116
|
+
* Assert every bundle row the profile declares resolves in its installed tree.
|
|
117
|
+
*
|
|
118
|
+
* A row without an installed package mounts nothing and reports nothing: the client module
|
|
119
|
+
* system simply never registers it, and every earlier step passes. Reading the rows back from
|
|
120
|
+
* the manifest on disk rather than from the projection is what makes this cover the tree the
|
|
121
|
+
* launcher actually boots.
|
|
122
|
+
*
|
|
123
|
+
* @param profileDirectory - profile whose node_modules was just installed.
|
|
124
|
+
*/
|
|
125
|
+
export declare function assertProfileBundles(profileDirectory: string): void;
|
|
126
|
+
/**
|
|
127
|
+
* Make each replaced package declare the name of the location it occupies.
|
|
128
|
+
*
|
|
129
|
+
* \`overrides\` installs our build at the official path, but the manifest inside still
|
|
130
|
+
* names our scope. The client module system resolves a loader entry's declared name and
|
|
131
|
+
* then requires the manifest it finds to declare that same name
|
|
132
|
+
* (\`client/modules\`: \`name === expectedPackageName\`); a mismatch makes the package own no
|
|
133
|
+
* browser module at all. The symptom is silent — the packages install, the server starts,
|
|
134
|
+
* and the panels those packages render simply never appear.
|
|
135
|
+
*
|
|
136
|
+
* The rewrite replaces the file rather than writing through it: pnpm hard-links a package
|
|
137
|
+
* manifest into its content-addressed store, so an in-place write would edit every
|
|
138
|
+
* profile sharing that store entry.
|
|
139
|
+
*
|
|
140
|
+
* @param profileModules - the profile's \`node_modules\` directory.
|
|
141
|
+
*/
|
|
142
|
+
export declare function alignReplacedPackageNames(profileModules: string, omitted?: ReadonlySet<string>): void;
|
|
143
|
+
/**
|
|
144
|
+
* The registries to try, in order, for this machine.
|
|
145
|
+
*
|
|
146
|
+
* A mainland locale reaches the mirror faster than the origin, which is why the Desktop
|
|
147
|
+
* installer already prefers it there. The same choice belongs to the profile install: it
|
|
148
|
+
* fetches a full dependency closure, so the delay is the first thing a consumer notices.
|
|
149
|
+
* `DSH_PLUS_INSTALL_REGISTRY` overrides the choice, and a failure falls back once.
|
|
150
|
+
*
|
|
151
|
+
* @returns registries to try in order.
|
|
152
|
+
*/
|
|
153
|
+
export declare function registryOrder(): readonly string[];
|
|
154
|
+
/**
|
|
155
|
+
* Report whether pnpm can run.
|
|
156
|
+
*
|
|
157
|
+
* The profile installs its own tree so its \`overrides\` apply, and only pnpm reads those
|
|
158
|
+
* from a workspace, so pnpm is a prerequisite the distribution cannot supply. Probing
|
|
159
|
+
* first turns a cryptic failure from the install into a message naming what is missing.
|
|
160
|
+
*
|
|
161
|
+
* @returns \`true\` when pnpm answers with a version.
|
|
162
|
+
*/
|
|
163
|
+
export declare function pnpmAvailable(): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* The commands that install pnpm, in the order worth trying.
|
|
166
|
+
*
|
|
167
|
+
* Corepack ships with Node and needs no download, so it comes first; npm is the fallback
|
|
168
|
+
* for an installation whose Corepack is absent or disabled. Both are the consumer's own
|
|
169
|
+
* toolchain, which is what lets the first start offer to install rather than only report.
|
|
170
|
+
*
|
|
171
|
+
* @returns commands to try in order, stopping at the first that works.
|
|
172
|
+
*/
|
|
173
|
+
export declare function pnpmInstallCommands(): readonly string[];
|
|
174
|
+
/**
|
|
175
|
+
* The command to show a consumer who declines the automatic install.
|
|
176
|
+
*
|
|
177
|
+
* @returns the preferred command, which is the one the offer runs first.
|
|
178
|
+
*/
|
|
179
|
+
export declare function pnpmInstallCommand(): string;
|
|
180
|
+
/** Resolve every path a command needs, without creating anything. */
|
|
181
|
+
export declare function resolvePaths(anchor: string, env?: NodeJS.ProcessEnv, editionId?: string): StandalonePaths;
|
|
182
|
+
/**
|
|
183
|
+
* Write the profile manifest when it is absent, leaving an existing one untouched.
|
|
184
|
+
*
|
|
185
|
+
* The distribution's own plugin dependencies are seeded here so the launcher can
|
|
186
|
+
* resolve every bundle from the profile directory: a bundle the profile cannot
|
|
187
|
+
* resolve fails activation with a module-resolution error, and no step in the
|
|
188
|
+
* launcher expands the distribution's bundle list on its own.
|
|
189
|
+
*
|
|
190
|
+
* The profile also links the consumer's installed packages, because the launcher
|
|
191
|
+
* resolves each bundle from the profile directory rather than from the directory
|
|
192
|
+
* that installed them.
|
|
193
|
+
*
|
|
194
|
+
* @param paths - resolved standalone paths.
|
|
195
|
+
* @param editionId - product edition to materialize.
|
|
196
|
+
* @param extraExcludes - packages the caller drops on top of the edition's own exclusions.
|
|
197
|
+
* @param dryRun - write the profile files without installing their dependency tree.
|
|
198
|
+
* @returns whether this call created the manifest.
|
|
199
|
+
*/
|
|
200
|
+
export declare function ensureProfile(paths: StandalonePaths, editionId?: string, extraExcludes?: readonly string[], dryRun?: boolean): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Apply the reviewed npm-target patches to the profile's installed packages.
|
|
203
|
+
*
|
|
204
|
+
* A standalone installation runs no `apply` step: it installs the distribution from
|
|
205
|
+
* the registry, links the consumer's packages, and starts. The npm patches a
|
|
206
|
+
* distribution declares therefore need an owner that does not require an official
|
|
207
|
+
* source checkout — the source half of the apply step needs one, this does not.
|
|
208
|
+
*
|
|
209
|
+
* The work is idempotent: a patch whose reverse already applies is left alone, so a
|
|
210
|
+
* second start neither re-applies nor fails. A reinstall restores the published bytes,
|
|
211
|
+
* which is why this runs on every start rather than once.
|
|
212
|
+
*
|
|
213
|
+
* @param distributionDirectory - the installed `@sparkelf/dsh-plus` directory.
|
|
214
|
+
* @param profileDirectory - the standalone profile directory.
|
|
215
|
+
* @returns the labels of the patches that were applied.
|
|
216
|
+
*/
|
|
217
|
+
export declare function applyProfileNpmPatches(distributionDirectory: string, profileDirectory: string): string[];
|
|
218
|
+
//# sourceMappingURL=profile.d.ts.map
|