@deepseek-ai/dsh-plugin-manager 0.2.3-alpha.1 → 0.2.3-alpha.3
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 +16 -4
- package/README.md +16 -2
- package/README.zh.md +16 -2
- package/lib/index.js +275 -24
- package/lib/typert.host.js +32 -21
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +29 -18
- package/lib/types/grammar.d.ts +55 -0
- package/lib/types/grammar.d.ts.map +1 -0
- package/lib/types/grammar.js +76 -0
- package/lib/types/grammar.js.map +1 -0
- package/lib/types/index.d.ts +5 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +54 -15
- package/lib/types/index.js.map +1 -1
- package/lib/types/plugin-reference.d.ts +90 -0
- package/lib/types/plugin-reference.d.ts.map +1 -0
- package/lib/types/plugin-reference.js +158 -0
- package/lib/types/plugin-reference.js.map +1 -0
- package/lib/types/types.d.ts +7 -0
- package/lib/types/types.d.ts.map +1 -1
- package/package.json +46 -40
- package/src/grammar.ts +103 -0
- package/src/index.ts +52 -14
- package/src/plugin-reference.ts +238 -0
- package/src/types.ts +7 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe `@[label](dsh-plugin:<package>)` mention grammar shared by the Host resolver and the Web client.
|
|
3
|
+
*
|
|
4
|
+
* @module @deepseek-ai/dsh-plugin-manager/grammar
|
|
5
|
+
*/
|
|
6
|
+
/** One plugin package to mention; the label defaults to the package name. */
|
|
7
|
+
export interface PluginReferenceInput {
|
|
8
|
+
readonly packageName: string;
|
|
9
|
+
readonly label?: string;
|
|
10
|
+
}
|
|
11
|
+
/** One matched canonical mention with its UTF-16 source range. */
|
|
12
|
+
export interface PluginMentionMatch {
|
|
13
|
+
readonly start: number;
|
|
14
|
+
readonly end: number;
|
|
15
|
+
readonly packageName: string;
|
|
16
|
+
readonly label: string;
|
|
17
|
+
}
|
|
18
|
+
/** One cited plugin package with the label its mention displays. */
|
|
19
|
+
export interface PluginMentionReference {
|
|
20
|
+
readonly packageName: string;
|
|
21
|
+
readonly label: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether a string is a bare npm package name.
|
|
25
|
+
* @param value - candidate package name.
|
|
26
|
+
* @returns whether the value names one package without a subpath.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isPluginPackageName(value: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Render one canonical Markdown mention.
|
|
31
|
+
* @param reference - package name and optional display label.
|
|
32
|
+
* @returns the canonical mention.
|
|
33
|
+
* @throws Error when the package name is not a bare npm package name.
|
|
34
|
+
*/
|
|
35
|
+
export declare function formatPluginMention(reference: PluginReferenceInput): string;
|
|
36
|
+
/**
|
|
37
|
+
* Find the nearest canonical mention at or after `from`; a mention whose URI does not name a bare package is ordinary text.
|
|
38
|
+
* @param text - text that may contain mentions.
|
|
39
|
+
* @param from - inclusive UTF-16 start offset.
|
|
40
|
+
* @returns the matched mention and its range, or undefined when none follows.
|
|
41
|
+
*/
|
|
42
|
+
export declare function nextPluginMention(text: string, from?: number): PluginMentionMatch | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The package named by a mention that occupies the whole string.
|
|
45
|
+
* @param mention - one canonical mention.
|
|
46
|
+
* @returns the package name, or undefined when the string is not exactly one mention.
|
|
47
|
+
*/
|
|
48
|
+
export declare function packageNameOfPluginMention(mention: string): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Collect the plugins that canonical mentions cite; the text itself is left unchanged.
|
|
51
|
+
* @param text - user text that may cite plugins.
|
|
52
|
+
* @returns references in appearance order.
|
|
53
|
+
*/
|
|
54
|
+
export declare function parsePluginMentions(text: string): PluginMentionReference[];
|
|
55
|
+
//# sourceMappingURL=grammar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grammar.d.ts","sourceRoot":"","sources":["../../src/grammar.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,6EAA6E;AAC7E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,kEAAkE;AAClE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAED,oEAAoE;AACpE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAYD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,oBAAoB,GAAG,MAAM,CAK3E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,kBAAkB,GAAG,SAAS,CASxF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG9E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB,EAAE,CAM1E"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe `@[label](dsh-plugin:<package>)` mention grammar shared by the Host resolver and the Web client.
|
|
3
|
+
*
|
|
4
|
+
* @module @deepseek-ai/dsh-plugin-manager/grammar
|
|
5
|
+
*/
|
|
6
|
+
/** URI scheme reserved for plugin references. */
|
|
7
|
+
const PLUGIN_REFERENCE_SCHEME = 'dsh-plugin:';
|
|
8
|
+
const PACKAGE_NAME = /^(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/u;
|
|
9
|
+
const MENTION_SOURCE = String.raw `@\[((?:\\.|[^\\\]])*)\]\((dsh-plugin:[^\s)]+)\)`;
|
|
10
|
+
/** Escape `\` and `]` in a mention label. */
|
|
11
|
+
function escapeLabel(label) {
|
|
12
|
+
return label.replace(/[\\\]]/gu, match => `\\${match}`);
|
|
13
|
+
}
|
|
14
|
+
/** Reverse {@link escapeLabel}. */
|
|
15
|
+
function unescapeLabel(label) {
|
|
16
|
+
return label.replace(/\\(.)/gu, '$1');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Whether a string is a bare npm package name.
|
|
20
|
+
* @param value - candidate package name.
|
|
21
|
+
* @returns whether the value names one package without a subpath.
|
|
22
|
+
*/
|
|
23
|
+
export function isPluginPackageName(value) {
|
|
24
|
+
return PACKAGE_NAME.test(value);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Render one canonical Markdown mention.
|
|
28
|
+
* @param reference - package name and optional display label.
|
|
29
|
+
* @returns the canonical mention.
|
|
30
|
+
* @throws Error when the package name is not a bare npm package name.
|
|
31
|
+
*/
|
|
32
|
+
export function formatPluginMention(reference) {
|
|
33
|
+
if (!isPluginPackageName(reference.packageName)) {
|
|
34
|
+
throw new Error(`invalid plugin package name ${JSON.stringify(reference.packageName)}`);
|
|
35
|
+
}
|
|
36
|
+
return `@[${escapeLabel(reference.label ?? reference.packageName)}](${PLUGIN_REFERENCE_SCHEME}${reference.packageName})`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Find the nearest canonical mention at or after `from`; a mention whose URI does not name a bare package is ordinary text.
|
|
40
|
+
* @param text - text that may contain mentions.
|
|
41
|
+
* @param from - inclusive UTF-16 start offset.
|
|
42
|
+
* @returns the matched mention and its range, or undefined when none follows.
|
|
43
|
+
*/
|
|
44
|
+
export function nextPluginMention(text, from = 0) {
|
|
45
|
+
const pattern = new RegExp(MENTION_SOURCE, 'gu');
|
|
46
|
+
pattern.lastIndex = from;
|
|
47
|
+
for (let match = pattern.exec(text); match !== null; match = pattern.exec(text)) {
|
|
48
|
+
const packageName = match[2].slice(PLUGIN_REFERENCE_SCHEME.length);
|
|
49
|
+
if (!isPluginPackageName(packageName))
|
|
50
|
+
continue;
|
|
51
|
+
return { start: match.index, end: match.index + match[0].length, packageName, label: unescapeLabel(match[1]) };
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The package named by a mention that occupies the whole string.
|
|
57
|
+
* @param mention - one canonical mention.
|
|
58
|
+
* @returns the package name, or undefined when the string is not exactly one mention.
|
|
59
|
+
*/
|
|
60
|
+
export function packageNameOfPluginMention(mention) {
|
|
61
|
+
const match = nextPluginMention(mention);
|
|
62
|
+
return match !== undefined && match.start === 0 && match.end === mention.length ? match.packageName : undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Collect the plugins that canonical mentions cite; the text itself is left unchanged.
|
|
66
|
+
* @param text - user text that may cite plugins.
|
|
67
|
+
* @returns references in appearance order.
|
|
68
|
+
*/
|
|
69
|
+
export function parsePluginMentions(text) {
|
|
70
|
+
const references = [];
|
|
71
|
+
for (let match = nextPluginMention(text); match !== undefined; match = nextPluginMention(text, match.end)) {
|
|
72
|
+
references.push({ packageName: match.packageName, label: match.label });
|
|
73
|
+
}
|
|
74
|
+
return references;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=grammar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grammar.js","sourceRoot":"","sources":["../../src/grammar.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iDAAiD;AACjD,MAAM,uBAAuB,GAAG,aAAa,CAAA;AAE7C,MAAM,YAAY,GAAG,uDAAuD,CAAA;AAC5E,MAAM,cAAc,GA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,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAA;QAC9E,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC;YAAE,SAAQ;QAC/C,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAW,CAAC,EAAE,CAAA;IAC1H,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAe;IACxD,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;IACxC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAA;AACjH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,MAAM,UAAU,GAA6B,EAAE,CAAA;IAC/C,KAAK,IAAI,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,SAAS,EAAE,KAAK,GAAG,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1G,UAAU,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;IACzE,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -131,7 +131,9 @@ export declare class PluginManager extends TypertRemoteService {
|
|
|
131
131
|
* installation manifest cannot be read; Remote callers receive `gateway/internal`.
|
|
132
132
|
*/
|
|
133
133
|
listBundles(): Promise<BundleInfo[]>;
|
|
134
|
-
/** The
|
|
134
|
+
/** The `listBundles()` records, limited to `only` when given; each named record equals its full-listing record. */
|
|
135
|
+
private listing;
|
|
136
|
+
/** The bundle inventory before update eligibility; each name is read independently of the others. */
|
|
135
137
|
private readBundles;
|
|
136
138
|
/** Read the registries this manager asks: the configured first one, its fallbacks in order, and what pnpm's own configuration names.
|
|
137
139
|
* @returns The registries in pnpm's comparison form; null is the one pnpm's own configuration names, `resolved` as pnpm reads it now.
|
|
@@ -167,8 +169,8 @@ export declare class PluginManager extends TypertRemoteService {
|
|
|
167
169
|
* @param name Installed profile dependency name.
|
|
168
170
|
* @param version Exact version newer than the installed one.
|
|
169
171
|
* @param options The registry asked first, as for `listVersions`; the Git spec of `version`, required for and accepted
|
|
170
|
-
* only by a bundle `listBundles` lists with `update: 'git'`;
|
|
171
|
-
* installation's logs and cancellation.
|
|
172
|
+
* only by a bundle `listBundles` lists with `update: 'git'`; the request id naming the progress and the target
|
|
173
|
+
* installation's logs and cancellation; and the pending build scripts to allow, saved before anything is removed.
|
|
172
174
|
* @returns The versions, the last step that ran with its result, and the reinstallation when one ran.
|
|
173
175
|
*/
|
|
174
176
|
updateBundle(name: string, version: string, options?: UpdateBundleOptions): Promise<PluginUpdateResult>;
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAG7C,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,OAAO,EAAE,mBAAmB,EAAsC,MAAM,kCAAkC,CAAA;AAE1G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,q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B;IAS/B,yEAAyE;YAC3D,YAAY;YAOZ,YAAY;IAuB1B,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,SAAS;IAMjB;;;OAGG;YACW,eAAe;IAY7B;;;;OAIG;YACW,gBAAgB;IAK9B;;;;OAIG;YACW,MAAM;YAYN,MAAM;IA0DpB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,eAAe;IAQvB,+FAA+F;IAC/F,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,SAAS;CASlB;AAED,eAAe,aAAa,CAAA"}
|
package/lib/types/index.js
CHANGED
|
@@ -56,6 +56,7 @@ import { attributeFailure, normalizeRegistry, NPMMIRROR_REGISTRY, registryPlan }
|
|
|
56
56
|
import { flatten, writePluginEnabled } from "./patch.js";
|
|
57
57
|
import { incompatiblePlugin, ManagementFailure } from "./failure.js";
|
|
58
58
|
import { PluginManagerError, readProfileState } from "./error.js";
|
|
59
|
+
import { installPluginReference } from "./plugin-reference.js";
|
|
59
60
|
import { approveBuilds, recordPendingBuilds } from "./build-approval.js";
|
|
60
61
|
import { checkGitConnection, checkGithubConnection } from "./github-connection.js";
|
|
61
62
|
import { chooseGitTransport, sshGitSpec } from "./git-transport.js";
|
|
@@ -78,7 +79,7 @@ function messageOf(error) { return error instanceof Error ? error.message : Stri
|
|
|
78
79
|
/** An expected refusal keeps its code; anything else becomes an operation error carrying its exact diagnostic. */
|
|
79
80
|
function managementError(error) {
|
|
80
81
|
if (error instanceof UnsupportedBundlePlatformError)
|
|
81
|
-
return { code: 'unsupported-platform' };
|
|
82
|
+
return { code: 'unsupported-platform', platforms: [...error.platforms] };
|
|
82
83
|
if (!(error instanceof ManagementFailure))
|
|
83
84
|
return { code: 'operation-error', diagnostic: messageOf(error) };
|
|
84
85
|
return { code: error.code, ...error.incompatible === undefined ? {} : { incompatible: error.incompatible } };
|
|
@@ -375,6 +376,12 @@ let PluginManager = (() => {
|
|
|
375
376
|
this.abort.abort();
|
|
376
377
|
await Promise.allSettled([...this.packageOperations]);
|
|
377
378
|
}, 'plugin-manager: package cancellation');
|
|
379
|
+
ctx.effect(() => installPluginReference(ctx, {
|
|
380
|
+
listBundles: names => Promise.resolve().then(() => this.listing(new Set(names))),
|
|
381
|
+
readInventory: () => readPluginInventory(ctx),
|
|
382
|
+
bundleDir: name => resolveBundleDir('dsh', name, this.profile.installAnchor, this.profile.dir),
|
|
383
|
+
profile: this.profile,
|
|
384
|
+
}), 'plugin-manager: plugin references');
|
|
378
385
|
ctx.inject(['connection'], (scope) => {
|
|
379
386
|
scope.effect(() => scope.connection.fetch.register({
|
|
380
387
|
path: DETAIL_FILE_PATH, methods: ['GET'], requestBody: 'buffered', fetch: request => this.serveDetailFile(request),
|
|
@@ -477,13 +484,18 @@ let PluginManager = (() => {
|
|
|
477
484
|
* installation manifest cannot be read; Remote callers receive `gateway/internal`.
|
|
478
485
|
*/
|
|
479
486
|
listBundles() {
|
|
480
|
-
|
|
487
|
+
// The profile reads throw synchronously; starting from a resolved promise reports that as a rejection.
|
|
488
|
+
return Promise.resolve().then(() => this.listing());
|
|
489
|
+
}
|
|
490
|
+
/** The `listBundles()` records, limited to `only` when given; each named record equals its full-listing record. */
|
|
491
|
+
listing(only) {
|
|
492
|
+
return this.readBundles(only).map((bundle) => {
|
|
481
493
|
const target = updateRefusal(bundle, bundle.name);
|
|
482
494
|
return typeof target === 'string' ? bundle : { ...bundle, update: target.kind };
|
|
483
|
-
})
|
|
495
|
+
});
|
|
484
496
|
}
|
|
485
|
-
/** The bundle inventory before update eligibility
|
|
486
|
-
readBundles() {
|
|
497
|
+
/** The bundle inventory before update eligibility; each name is read independently of the others. */
|
|
498
|
+
readBundles(only) {
|
|
487
499
|
const { manifest, exemptions, installation } = readProfileState(() => ({
|
|
488
500
|
manifest: readProfileManifest('dsh', this.profile.dir),
|
|
489
501
|
exemptions: readProfileVersionExemptions(this.profile.dir),
|
|
@@ -493,7 +505,8 @@ let PluginManager = (() => {
|
|
|
493
505
|
const recorded = manifest.dependencies ?? {};
|
|
494
506
|
const dependencies = Object.keys(recorded);
|
|
495
507
|
const catalog = new Map(OFFICIAL_ON_DEMAND_CATALOG.map(entry => [entry.packageName, entry]));
|
|
496
|
-
const names = [...new Set([...selected, ...dependencies, ...Object.keys(installation.dependencies ?? {}), ...catalog.keys()])]
|
|
508
|
+
const names = [...new Set([...selected, ...dependencies, ...Object.keys(installation.dependencies ?? {}), ...catalog.keys()])]
|
|
509
|
+
.filter(name => only?.has(name) ?? true);
|
|
497
510
|
const bundles = [];
|
|
498
511
|
const runtimeVersion = getDshRuntimeVersion();
|
|
499
512
|
for (const name of names) {
|
|
@@ -680,7 +693,7 @@ let PluginManager = (() => {
|
|
|
680
693
|
* and DSH compatibility, and the registry that answered; or why no list could be read, with every registry asked.
|
|
681
694
|
*/
|
|
682
695
|
async listVersions(name, options, signal) {
|
|
683
|
-
const target = updateRefusal(
|
|
696
|
+
const target = updateRefusal(this.listing(new Set([name])).find(bundle => bundle.name === name), name);
|
|
684
697
|
if (typeof target === 'string')
|
|
685
698
|
return { status: 'refused', problem: 'not-updatable', reason: target, attempts: [] };
|
|
686
699
|
if (target.kind === 'git')
|
|
@@ -745,8 +758,8 @@ let PluginManager = (() => {
|
|
|
745
758
|
* @param name Installed profile dependency name.
|
|
746
759
|
* @param version Exact version newer than the installed one.
|
|
747
760
|
* @param options The registry asked first, as for `listVersions`; the Git spec of `version`, required for and accepted
|
|
748
|
-
* only by a bundle `listBundles` lists with `update: 'git'`;
|
|
749
|
-
* installation's logs and cancellation.
|
|
761
|
+
* only by a bundle `listBundles` lists with `update: 'git'`; the request id naming the progress and the target
|
|
762
|
+
* installation's logs and cancellation; and the pending build scripts to allow, saved before anything is removed.
|
|
750
763
|
* @returns The versions, the last step that ran with its result, and the reinstallation when one ran.
|
|
751
764
|
*/
|
|
752
765
|
async updateBundle(name, version, options) {
|
|
@@ -756,7 +769,7 @@ let PluginManager = (() => {
|
|
|
756
769
|
this.ownerContext.emit('plugin-manager/update-state', { requestId, step });
|
|
757
770
|
};
|
|
758
771
|
announce('checking');
|
|
759
|
-
const target = updateRefusal(
|
|
772
|
+
const target = updateRefusal(this.listing(new Set([name])).find(item => item.name === name), name);
|
|
760
773
|
const from = typeof target === 'string' ? '' : target.installed;
|
|
761
774
|
const refusedBefore = (error) => ({
|
|
762
775
|
from, to: version, step: 'check',
|
|
@@ -775,13 +788,36 @@ let PluginManager = (() => {
|
|
|
775
788
|
return refusedBefore(planned);
|
|
776
789
|
const { spec, registry, saveExact } = planned;
|
|
777
790
|
const { enabled } = bundle;
|
|
791
|
+
const approved = options?.approvedBuilds;
|
|
792
|
+
// The approval is saved before anything is removed: `pnpm remove` drops the undecided entries it would decide.
|
|
793
|
+
const approve = async () => {
|
|
794
|
+
if (approved === undefined)
|
|
795
|
+
return undefined;
|
|
796
|
+
try {
|
|
797
|
+
await withFileLock(join(this.profile.dir, 'package.json'), async () => {
|
|
798
|
+
// A manager disposed while the update was checked writes nothing.
|
|
799
|
+
this.abort.signal.throwIfAborted();
|
|
800
|
+
await approveBuilds(this.profile.dir, approved);
|
|
801
|
+
}, { waitMs: this.lockWaitMs });
|
|
802
|
+
}
|
|
803
|
+
catch (error) {
|
|
804
|
+
return managementError(error);
|
|
805
|
+
}
|
|
806
|
+
return undefined;
|
|
807
|
+
};
|
|
778
808
|
// A lock timeout or disposal rejects instead of reporting; it reads as the failed step it is.
|
|
779
809
|
const settled = (stage, target, operation) => operation.catch((error) => ({ changed: false, application: 'failed', stage, target, error: managementError(error) }));
|
|
780
|
-
const installTarget = () =>
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
810
|
+
const installTarget = async () => {
|
|
811
|
+
const result = await settled('install', spec, this.installBundle(spec, {
|
|
812
|
+
saveExact, enabled, expected: { name, version },
|
|
813
|
+
...registry === undefined ? {} : { registry }, ...requestId === undefined ? {} : { requestId },
|
|
814
|
+
}));
|
|
815
|
+
return approved === undefined ? result : { ...result, approvedBuilds: approved };
|
|
816
|
+
};
|
|
784
817
|
if (this.ownerContext.get('hmr') === undefined) {
|
|
818
|
+
const refusal = await approve();
|
|
819
|
+
if (refusal !== undefined)
|
|
820
|
+
return refusedBefore(refusal);
|
|
785
821
|
announce('installing');
|
|
786
822
|
return { from, to: version, step: 'install', result: await installTarget() };
|
|
787
823
|
}
|
|
@@ -796,6 +832,9 @@ let PluginManager = (() => {
|
|
|
796
832
|
},
|
|
797
833
|
};
|
|
798
834
|
}
|
|
835
|
+
const refusal = await approve();
|
|
836
|
+
if (refusal !== undefined)
|
|
837
|
+
return refusedBefore(refusal);
|
|
799
838
|
// The removed version is installed again where it came from, else over the configured plan, as its removal asks.
|
|
800
839
|
const previousRegistry = this.installedFrom.get(name);
|
|
801
840
|
announce('removing');
|
|
@@ -1202,7 +1241,7 @@ let PluginManager = (() => {
|
|
|
1202
1241
|
removeBundle(name) {
|
|
1203
1242
|
return this.change(async (result) => {
|
|
1204
1243
|
const installed = await this.configure(async () => {
|
|
1205
|
-
const bundle =
|
|
1244
|
+
const bundle = this.listing(new Set([name])).find(item => item.name === name);
|
|
1206
1245
|
if (bundle === undefined || !bundle.removable)
|
|
1207
1246
|
throw new ManagementFailure('not-removable');
|
|
1208
1247
|
if (this.ownerContext.get('hmr') === undefined && (this.profile.startedBundles.includes(name)
|