@monosmith/plugin-sdk 0.4.0 → 0.6.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/conformance/check-generation.use-case.js +3 -0
- package/package.json +1 -1
- package/protocol/protocol-schema.contract.js +119 -0
- package/protocol/protocol-types.contract.d.ts +76 -0
- package/serve/index.d.ts +1 -1
- package/serve/plugin-members.config.js +1 -0
- package/serve/plugin.contract.d.ts +6 -2
|
@@ -21,7 +21,10 @@ function article(kind) {
|
|
|
21
21
|
export async function checkGeneration(client, workspace, report) {
|
|
22
22
|
const language = effectiveRoles(client.info).includes('language');
|
|
23
23
|
const made = [];
|
|
24
|
+
const declared = client.info.kinds ?? [];
|
|
24
25
|
for (const kind of ['app', 'lib', 'package']) {
|
|
26
|
+
if (declared.length > 0 && !declared.includes(kind))
|
|
27
|
+
continue;
|
|
25
28
|
const name = `c${kind}`;
|
|
26
29
|
const params = {
|
|
27
30
|
kind,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monosmith/plugin-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The TypeScript SDK for writing smith plugins: the protocol's types, the serve loop, a test host, the conformance checks, templating and key-order-keeping JSON editing. No runtime dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -207,6 +207,17 @@ export const protocolSchema = {
|
|
|
207
207
|
},
|
|
208
208
|
"capability": "latest",
|
|
209
209
|
"notification": false
|
|
210
|
+
},
|
|
211
|
+
"sbom/components": {
|
|
212
|
+
"description": "Asks which components a project ships (its locked dependencies, read from a lockfile where the ecosystem has one and from the manifest otherwise), as package URLs, for the SBOM a release attaches.",
|
|
213
|
+
"params": {
|
|
214
|
+
"$ref": "#/$defs/ComponentsParams"
|
|
215
|
+
},
|
|
216
|
+
"result": {
|
|
217
|
+
"$ref": "#/$defs/ComponentsResult"
|
|
218
|
+
},
|
|
219
|
+
"capability": "components",
|
|
220
|
+
"notification": false
|
|
210
221
|
}
|
|
211
222
|
},
|
|
212
223
|
"x-errorCodes": [
|
|
@@ -531,6 +542,10 @@ export const protocolSchema = {
|
|
|
531
542
|
"cancel": {
|
|
532
543
|
"type": "boolean",
|
|
533
544
|
"description": "Cancel says the plugin stops the work of a request when the host sends a cancel notification with its id, then answers that request with its result (if the work was already done) or the request-cancelled error. A host never sends the notification to a plugin without it."
|
|
545
|
+
},
|
|
546
|
+
"components": {
|
|
547
|
+
"type": "boolean",
|
|
548
|
+
"description": "Components lists a project's dependencies for its SBOM."
|
|
534
549
|
}
|
|
535
550
|
}
|
|
536
551
|
},
|
|
@@ -588,6 +603,62 @@ export const protocolSchema = {
|
|
|
588
603
|
}
|
|
589
604
|
}
|
|
590
605
|
},
|
|
606
|
+
"Component": {
|
|
607
|
+
"description": "Component is one dependency of a project.",
|
|
608
|
+
"type": "object",
|
|
609
|
+
"properties": {
|
|
610
|
+
"name": {
|
|
611
|
+
"type": "string"
|
|
612
|
+
},
|
|
613
|
+
"version": {
|
|
614
|
+
"type": "string",
|
|
615
|
+
"description": "Version is the locked version, or the declared range when the project has no lockfile."
|
|
616
|
+
},
|
|
617
|
+
"purl": {
|
|
618
|
+
"type": "string",
|
|
619
|
+
"description": "PURL is the package URL (https://github.com/package-url/purl-spec)."
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
"required": [
|
|
623
|
+
"name",
|
|
624
|
+
"purl"
|
|
625
|
+
]
|
|
626
|
+
},
|
|
627
|
+
"ComponentsParams": {
|
|
628
|
+
"description": "ComponentsParams asks a plugin for the components one of its projects ships: what a CycloneDX SBOM lists.",
|
|
629
|
+
"type": "object",
|
|
630
|
+
"properties": {
|
|
631
|
+
"project": {
|
|
632
|
+
"$ref": "#/$defs/Project"
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
"required": [
|
|
636
|
+
"project"
|
|
637
|
+
]
|
|
638
|
+
},
|
|
639
|
+
"ComponentsResult": {
|
|
640
|
+
"description": "ComponentsResult lists the components, read from a lockfile where the ecosystem has one and from the manifest otherwise. An empty list is an answer: the project declares no dependencies.",
|
|
641
|
+
"type": "object",
|
|
642
|
+
"properties": {
|
|
643
|
+
"components": {
|
|
644
|
+
"type": "array",
|
|
645
|
+
"items": {
|
|
646
|
+
"$ref": "#/$defs/Component"
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
"source": {
|
|
650
|
+
"type": "string",
|
|
651
|
+
"description": "Source is the workspace-relative file the list was read from, \"\" when the project has none."
|
|
652
|
+
},
|
|
653
|
+
"purl": {
|
|
654
|
+
"type": "string",
|
|
655
|
+
"description": "PURL is the project's own package URL when it has a registry identity (without a version: the release supplies it); \"\" otherwise."
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
"required": [
|
|
659
|
+
"components"
|
|
660
|
+
]
|
|
661
|
+
},
|
|
591
662
|
"ContributeParams": {
|
|
592
663
|
"description": "ContributeParams hands a plugin the projects it applies to: those whose stack includes it, or, for a workspace-wide convention, those of the languages it supports that smith.toml enables it for.",
|
|
593
664
|
"type": "object",
|
|
@@ -642,6 +713,10 @@ export const protocolSchema = {
|
|
|
642
713
|
}
|
|
643
714
|
},
|
|
644
715
|
"description": "DependsOn adds dependencies to tasks the project already has, by task name ({\"lint\": [\"slice-check\"]})."
|
|
716
|
+
},
|
|
717
|
+
"release": {
|
|
718
|
+
"$ref": "#/$defs/ReleaseDefaults",
|
|
719
|
+
"description": "Release is how the project's release files are made, for a project that releases through GitHub releases and leaves them out of its smith.toml [projects.<name>.release] table; what the table sets wins."
|
|
645
720
|
}
|
|
646
721
|
}
|
|
647
722
|
},
|
|
@@ -1163,6 +1238,13 @@ export const protocolSchema = {
|
|
|
1163
1238
|
"$ref": "#/$defs/Stack"
|
|
1164
1239
|
},
|
|
1165
1240
|
"description": "Stacks are ready-made stacks the plugin publishes."
|
|
1241
|
+
},
|
|
1242
|
+
"kinds": {
|
|
1243
|
+
"type": "array",
|
|
1244
|
+
"items": {
|
|
1245
|
+
"$ref": "#/$defs/ProjectKind"
|
|
1246
|
+
},
|
|
1247
|
+
"description": "Kinds are the project kinds the plugin can scaffold with generate. Absent or empty means all three (app, lib and package): what every plugin that says nothing does. A plugin that scaffolds only some, such as an app, lists them, so the host offers and the conformance suite asks for just those."
|
|
1166
1248
|
}
|
|
1167
1249
|
},
|
|
1168
1250
|
"required": [
|
|
@@ -1627,6 +1709,43 @@ export const protocolSchema = {
|
|
|
1627
1709
|
"auth"
|
|
1628
1710
|
]
|
|
1629
1711
|
},
|
|
1712
|
+
"ReleaseDefaults": {
|
|
1713
|
+
"description": "ReleaseDefaults are release settings a plugin supplies for a project: the same fields as the release-from-a-command settings of smith.toml, used for the ones the project's table leaves out.",
|
|
1714
|
+
"type": "object",
|
|
1715
|
+
"properties": {
|
|
1716
|
+
"build": {
|
|
1717
|
+
"type": "string",
|
|
1718
|
+
"description": "Build is the shell command that makes the files, run at the workspace root on a runner of each platform."
|
|
1719
|
+
},
|
|
1720
|
+
"assets": {
|
|
1721
|
+
"type": "array",
|
|
1722
|
+
"items": {
|
|
1723
|
+
"type": "string"
|
|
1724
|
+
},
|
|
1725
|
+
"description": "Assets are workspace-relative globs of the files Build leaves."
|
|
1726
|
+
},
|
|
1727
|
+
"platforms": {
|
|
1728
|
+
"type": "array",
|
|
1729
|
+
"items": {
|
|
1730
|
+
"type": "string"
|
|
1731
|
+
},
|
|
1732
|
+
"description": "Platforms are the runner platforms (windows-x64, macos-arm64, macos-x64, linux-x64, linux-arm64)."
|
|
1733
|
+
},
|
|
1734
|
+
"assetName": {
|
|
1735
|
+
"type": "string",
|
|
1736
|
+
"description": "AssetName renames each file on upload; see the asset_name setting."
|
|
1737
|
+
},
|
|
1738
|
+
"checksums": {
|
|
1739
|
+
"type": "boolean",
|
|
1740
|
+
"description": "Checksums attaches a checksums file for the files a runner uploads."
|
|
1741
|
+
}
|
|
1742
|
+
},
|
|
1743
|
+
"required": [
|
|
1744
|
+
"build",
|
|
1745
|
+
"assets",
|
|
1746
|
+
"platforms"
|
|
1747
|
+
]
|
|
1748
|
+
},
|
|
1630
1749
|
"RemoveParams": {
|
|
1631
1750
|
"description": "RemoveParams tells a plugin a project is being removed. The host deletes the project's directory first; the plugin cleans what it owns outside it (a go.work entry, a lockfile, an installed package).",
|
|
1632
1751
|
"type": "object",
|
|
@@ -160,6 +160,8 @@ export interface Capabilities {
|
|
|
160
160
|
* request-cancelled error. A host never sends the notification to a plugin without it.
|
|
161
161
|
*/
|
|
162
162
|
cancel?: boolean;
|
|
163
|
+
/** Components lists a project's dependencies for its SBOM. */
|
|
164
|
+
components?: boolean;
|
|
163
165
|
}
|
|
164
166
|
/**
|
|
165
167
|
* ChangeKindParams asks a plugin what changing a project's kind edits. The plugin writes nothing:
|
|
@@ -203,6 +205,35 @@ export interface ChangeKindResult {
|
|
|
203
205
|
*/
|
|
204
206
|
warnings?: string[];
|
|
205
207
|
}
|
|
208
|
+
/** Component is one dependency of a project. */
|
|
209
|
+
export interface Component {
|
|
210
|
+
name: string;
|
|
211
|
+
/** Version is the locked version, or the declared range when the project has no lockfile. */
|
|
212
|
+
version?: string;
|
|
213
|
+
/** PURL is the package URL (https://github.com/package-url/purl-spec). */
|
|
214
|
+
purl: string;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* ComponentsParams asks a plugin for the components one of its projects ships: what a CycloneDX
|
|
218
|
+
* SBOM lists.
|
|
219
|
+
*/
|
|
220
|
+
export interface ComponentsParams {
|
|
221
|
+
project: Project;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* ComponentsResult lists the components, read from a lockfile where the ecosystem has one and from
|
|
225
|
+
* the manifest otherwise. An empty list is an answer: the project declares no dependencies.
|
|
226
|
+
*/
|
|
227
|
+
export interface ComponentsResult {
|
|
228
|
+
components: Component[];
|
|
229
|
+
/** Source is the workspace-relative file the list was read from, "" when the project has none. */
|
|
230
|
+
source?: string;
|
|
231
|
+
/**
|
|
232
|
+
* PURL is the project's own package URL when it has a registry identity (without a version: the
|
|
233
|
+
* release supplies it); "" otherwise.
|
|
234
|
+
*/
|
|
235
|
+
purl?: string;
|
|
236
|
+
}
|
|
206
237
|
/**
|
|
207
238
|
* ContributeParams hands a plugin the projects it applies to: those whose stack includes it, or,
|
|
208
239
|
* for a workspace-wide convention, those of the languages it supports that smith.toml enables it
|
|
@@ -229,6 +260,12 @@ export interface Contribution {
|
|
|
229
260
|
* ["slice-check"]}).
|
|
230
261
|
*/
|
|
231
262
|
dependsOn?: Record<string, string[]>;
|
|
263
|
+
/**
|
|
264
|
+
* Release is how the project's release files are made, for a project that releases through GitHub
|
|
265
|
+
* releases and leaves them out of its smith.toml [projects.<name>.release] table; what the table
|
|
266
|
+
* sets wins.
|
|
267
|
+
*/
|
|
268
|
+
release?: ReleaseDefaults;
|
|
232
269
|
}
|
|
233
270
|
/** Credential is a secret the release phase needs. */
|
|
234
271
|
export interface Credential {
|
|
@@ -491,6 +528,13 @@ export interface InitializeResult {
|
|
|
491
528
|
conflicts?: PluginRef[];
|
|
492
529
|
/** Stacks are ready-made stacks the plugin publishes. */
|
|
493
530
|
stacks?: Stack[];
|
|
531
|
+
/**
|
|
532
|
+
* Kinds are the project kinds the plugin can scaffold with generate. Absent or empty means all
|
|
533
|
+
* three (app, lib and package): what every plugin that says nothing does. A plugin that scaffolds
|
|
534
|
+
* only some, such as an app, lists them, so the host offers and the conformance suite asks for
|
|
535
|
+
* just those.
|
|
536
|
+
*/
|
|
537
|
+
kinds?: ProjectKind[];
|
|
494
538
|
}
|
|
495
539
|
/**
|
|
496
540
|
* Input is one input of an ActionStep. Values are written as quoted YAML strings, except true and
|
|
@@ -796,6 +840,28 @@ export interface Registry {
|
|
|
796
840
|
*/
|
|
797
841
|
maven?: string;
|
|
798
842
|
}
|
|
843
|
+
/**
|
|
844
|
+
* ReleaseDefaults are release settings a plugin supplies for a project: the same fields as the
|
|
845
|
+
* release-from-a-command settings of smith.toml, used for the ones the project's table leaves out.
|
|
846
|
+
*/
|
|
847
|
+
export interface ReleaseDefaults {
|
|
848
|
+
/**
|
|
849
|
+
* Build is the shell command that makes the files, run at the workspace root on a runner of each
|
|
850
|
+
* platform.
|
|
851
|
+
*/
|
|
852
|
+
build: string;
|
|
853
|
+
/** Assets are workspace-relative globs of the files Build leaves. */
|
|
854
|
+
assets: string[];
|
|
855
|
+
/**
|
|
856
|
+
* Platforms are the runner platforms (windows-x64, macos-arm64, macos-x64, linux-x64,
|
|
857
|
+
* linux-arm64).
|
|
858
|
+
*/
|
|
859
|
+
platforms: string[];
|
|
860
|
+
/** AssetName renames each file on upload; see the asset_name setting. */
|
|
861
|
+
assetName?: string;
|
|
862
|
+
/** Checksums attaches a checksums file for the files a runner uploads. */
|
|
863
|
+
checksums?: boolean;
|
|
864
|
+
}
|
|
799
865
|
/**
|
|
800
866
|
* RemoveParams tells a plugin a project is being removed. The host deletes the project's directory
|
|
801
867
|
* first; the plugin cleans what it owns outside it (a go.work entry, a lockfile, an installed
|
|
@@ -1121,6 +1187,16 @@ export interface ProtocolMethods {
|
|
|
1121
1187
|
result: LatestResult;
|
|
1122
1188
|
capability: 'latest';
|
|
1123
1189
|
};
|
|
1190
|
+
/**
|
|
1191
|
+
* Asks which components a project ships (its locked dependencies, read from a lockfile where the
|
|
1192
|
+
* ecosystem has one and from the manifest otherwise), as package URLs, for the SBOM a release
|
|
1193
|
+
* attaches.
|
|
1194
|
+
*/
|
|
1195
|
+
'sbom/components': {
|
|
1196
|
+
params: ComponentsParams;
|
|
1197
|
+
result: ComponentsResult;
|
|
1198
|
+
capability: 'components';
|
|
1199
|
+
};
|
|
1124
1200
|
}
|
|
1125
1201
|
export type MethodName = keyof ProtocolMethods;
|
|
1126
1202
|
export type ParamsOf<M extends MethodName> = ProtocolMethods[M]['params'];
|
package/serve/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { serve, serveStreams } from './serve.use-case.ts';
|
|
2
2
|
export { capabilitiesOf, implementsMethod } from './capabilities-of.algorithm.ts';
|
|
3
|
-
export type { Awaitable, Cancellable, CIContributor, Contributor, DeclarationEditor, DependencyManager, Discoverer, DoctorContributor, Generator, KindChanger, LatestReader, Plugin, PluginDescription, Publisher, RegistryReader, Remover, SmithPlugin, Versioner, } from './plugin.contract.ts';
|
|
3
|
+
export type { Awaitable, Cancellable, CIContributor, ComponentLister, Contributor, DeclarationEditor, DependencyManager, Discoverer, DoctorContributor, Generator, KindChanger, LatestReader, Plugin, PluginDescription, Publisher, RegistryReader, Remover, SmithPlugin, Versioner, } from './plugin.contract.ts';
|
|
4
4
|
export type { FrameSink, ServeStreams } from './protocol-streams.contract.ts';
|
|
@@ -23,4 +23,5 @@ export const PLUGIN_MEMBERS = {
|
|
|
23
23
|
'dependencies/declared': { member: 'declared', requires: ['declared', 'rewrite'] },
|
|
24
24
|
'dependencies/rewrite': { member: 'rewrite', requires: ['declared', 'rewrite'] },
|
|
25
25
|
'dependencies/latest': { member: 'latest', requires: ['latest'] },
|
|
26
|
+
'sbom/components': { member: 'components', requires: ['components'] },
|
|
26
27
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChangeKindParams, ChangeKindResult, CIParams, CIResult, ContributeParams, ContributeResult, DeclaredParams, DeclaredResult, DependencyResult, DiscoverParams, DiscoverResult, DoctorParams, DoctorResult, GenerateParams, GenerateResult, InitializeParams, InitializeResult, InstallParams, LatestParams, LatestResult, PublishedParams, PublishedResult, PublishParams, PublishResult, RemoveParams, RemoveResult, RewriteParams, UninstallParams, VersionParams, VersionResult } from '../protocol/index.ts';
|
|
1
|
+
import type { ChangeKindParams, ChangeKindResult, CIParams, CIResult, ComponentsParams, ComponentsResult, ContributeParams, ContributeResult, DeclaredParams, DeclaredResult, DependencyResult, DiscoverParams, DiscoverResult, DoctorParams, DoctorResult, GenerateParams, GenerateResult, InitializeParams, InitializeResult, InstallParams, LatestParams, LatestResult, PublishedParams, PublishedResult, PublishParams, PublishResult, RemoveParams, RemoveResult, RewriteParams, UninstallParams, VersionParams, VersionResult } from '../protocol/index.ts';
|
|
2
2
|
/** A result now or later: every method of a plugin may be `async`. */
|
|
3
3
|
export type Awaitable<T> = T | Promise<T>;
|
|
4
4
|
/** What a plugin says about itself. The serve loop fills in `protocolVersion` and `capabilities`. */
|
|
@@ -44,6 +44,10 @@ export interface Remover {
|
|
|
44
44
|
export interface KindChanger {
|
|
45
45
|
changeKind: (params: ChangeKindParams, signal: AbortSignal) => Awaitable<ChangeKindResult>;
|
|
46
46
|
}
|
|
47
|
+
/** `sbom/components`: the components a project ships, for the SBOM a release attaches. */
|
|
48
|
+
export interface ComponentLister {
|
|
49
|
+
components: (params: ComponentsParams, signal: AbortSignal) => Awaitable<ComponentsResult>;
|
|
50
|
+
}
|
|
47
51
|
/** `dependencies/install` and `dependencies/uninstall`: both, or the capability is not advertised. */
|
|
48
52
|
export interface DependencyManager {
|
|
49
53
|
install: (params: InstallParams, signal: AbortSignal) => Awaitable<DependencyResult>;
|
|
@@ -81,4 +85,4 @@ export interface Cancellable {
|
|
|
81
85
|
* from `cancellable`. How many requests it can work on at once is declared in
|
|
82
86
|
* `describe`'s `concurrency`: omit it for one at a time, in order.
|
|
83
87
|
*/
|
|
84
|
-
export type SmithPlugin = Plugin & Partial<Discoverer & Generator & Versioner & Publisher & RegistryReader & CIContributor & DoctorContributor & Remover & KindChanger & DependencyManager & DeclarationEditor & LatestReader & Contributor & Cancellable>;
|
|
88
|
+
export type SmithPlugin = Plugin & Partial<Discoverer & Generator & Versioner & Publisher & RegistryReader & CIContributor & DoctorContributor & Remover & KindChanger & ComponentLister & DependencyManager & DeclarationEditor & LatestReader & Contributor & Cancellable>;
|