@acryldev/blends 1.7.17 → 1.7.19
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/dist/index.js +1 -1
- package/docs/framework/README.md +1 -0
- package/docs/framework/guides/share-plugins.md +117 -0
- package/lib/cordis/door.d.ts +7 -0
- package/lib/cordis/door.js +27 -7
- package/pack/pack-blank-mac.mjs +4 -0
- package/package.json +1 -1
- package/plugins/desktop-shell/main.ts +20 -1
- package/plugins/desktop-shell/package.json +1 -1
- package/plugins/door/package.json +1 -1
- package/plugins/door/src/cli/acryl.ts +11 -5
- package/plugins/door/src/host/door.ts +23 -3
- package/plugins/door/src/host/operator-routes.ts +4 -1
- package/plugins/door/src/host/verbs.ts +2 -2
- package/plugins/manifest/index.ts +9 -2
- package/plugins/plugin-share/README.md +6 -0
- package/plugins/plugin-share/index.ts +313 -16
- package/plugins/plugin-share/merge-edits.ts +85 -0
- package/plugins/plugin-share/npm-login.ts +43 -0
- package/plugins/plugin-share/package.json +1 -1
- package/plugins/plugin-share/package.ts +15 -7
- package/plugins/plugin-share/publish.ts +21 -0
- package/plugins/plugin-share/registry-source.ts +62 -0
|
@@ -30,10 +30,15 @@ export function packageManifest(
|
|
|
30
30
|
? {}
|
|
31
31
|
: {
|
|
32
32
|
license: release.license,
|
|
33
|
-
repository
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
// An npm package has no repository of its own to name.
|
|
34
|
+
...(release.owner === undefined || release.repo === undefined
|
|
35
|
+
? {}
|
|
36
|
+
: {
|
|
37
|
+
repository: {
|
|
38
|
+
type: 'git',
|
|
39
|
+
url: `git+https://github.com/${release.owner}/${release.repo}.git`,
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
37
42
|
}),
|
|
38
43
|
type: 'module',
|
|
39
44
|
exports: { '.': './index.ts', './package.json': './package.json' },
|
|
@@ -47,8 +52,9 @@ export function packageManifest(
|
|
|
47
52
|
|
|
48
53
|
/** Where a package is going to be released: written in now, so what is planned is byte for byte what is released. */
|
|
49
54
|
export interface PackageRelease {
|
|
50
|
-
|
|
51
|
-
readonly
|
|
55
|
+
/** The GitHub repository the package is released from; absent for npm. */
|
|
56
|
+
readonly owner?: string
|
|
57
|
+
readonly repo?: string
|
|
52
58
|
readonly license: string
|
|
53
59
|
}
|
|
54
60
|
|
|
@@ -56,6 +62,8 @@ export interface PackageOptions {
|
|
|
56
62
|
/** This version, instead of the one already packaged. */
|
|
57
63
|
readonly version?: string
|
|
58
64
|
readonly release?: PackageRelease
|
|
65
|
+
/** The name in the package's `package.json` when it is not the plugin's folder name (npm: `@scope/name`). */
|
|
66
|
+
readonly packageName?: string
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
export interface PackagedPlugin {
|
|
@@ -142,7 +150,7 @@ export async function packagePlugin(
|
|
|
142
150
|
try {
|
|
143
151
|
writeFileSync(
|
|
144
152
|
join(target, 'package.json'),
|
|
145
|
-
`${JSON.stringify(packageManifest(name, description, version, options.release), null, 2)}\n`,
|
|
153
|
+
`${JSON.stringify(packageManifest(options.packageName ?? name, description, version, options.release), null, 2)}\n`,
|
|
146
154
|
)
|
|
147
155
|
if (!existsSync(join(target, 'README.md'))) {
|
|
148
156
|
writeFileSync(
|
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
* Publishing a plugin: what a person is asked to say yes to, and the comparison that makes the yes mean exactly that. Pure; the service does the I/O.
|
|
3
3
|
*/
|
|
4
4
|
import type { PublishGitPort, RepositoryHostPort } from '@acryldev/plugin-hub-core'
|
|
5
|
+
import type { NpmPort } from './npm-login.ts'
|
|
5
6
|
|
|
6
7
|
/** Everything that leaves the machine, named before anything does. */
|
|
7
8
|
export interface PublishPlan {
|
|
9
|
+
/** Where it goes: a GitHub release (absent) or an npm registry. For npm `owner` is the scope and `repo` the plugin's name. */
|
|
10
|
+
readonly target?: 'npm'
|
|
11
|
+
/** npm: the package's name (`@scope/name`) and the registry it is published to. */
|
|
12
|
+
readonly package?: string
|
|
13
|
+
readonly registry?: string
|
|
8
14
|
readonly owner: string
|
|
9
15
|
readonly repo: string
|
|
10
16
|
readonly version: string
|
|
@@ -46,24 +52,39 @@ export interface PublishOptions {
|
|
|
46
52
|
readonly owner?: string
|
|
47
53
|
/** The license the plugin is offered under, as an SPDX id; MIT when absent. The plan shows it before the person says yes. */
|
|
48
54
|
readonly license?: string
|
|
55
|
+
/** `npm`: publish to an npm registry with the person's own npm login instead of to GitHub. */
|
|
56
|
+
readonly to?: 'npm'
|
|
57
|
+
/** npm: the scope of the package; the account npm is signed in as when absent. */
|
|
58
|
+
readonly scope?: string
|
|
59
|
+
/** npm: the registry; the public one when absent. */
|
|
60
|
+
readonly registry?: string
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
/** Where a publish goes through: the person's own `gh` and `git`. A test passes stand-ins, so no test publishes. */
|
|
52
64
|
export interface PublishPorts {
|
|
53
65
|
readonly host: RepositoryHostPort
|
|
54
66
|
readonly git: PublishGitPort
|
|
67
|
+
/** The person's own npm (`npm whoami`, `npm publish`); the default is their installed npm. A test passes a stand-in. */
|
|
68
|
+
readonly npm?: NpmPort
|
|
55
69
|
}
|
|
56
70
|
|
|
57
71
|
/** The line a friend copies: it names the bytes, so the check comes for free. */
|
|
58
72
|
export const pullLineOf = (owner: string, repo: string, version: string, digest: string): string =>
|
|
59
73
|
`npm run acryl -- plugin pull github:${owner}/${repo}@${version}@sha256:${digest}`
|
|
60
74
|
|
|
75
|
+
/** The line a friend copies for an npm package. */
|
|
76
|
+
export const npmPullLineOf = (name: string, version: string, digest: string): string =>
|
|
77
|
+
`npm run acryl -- plugin pull npm:${name}@${version}@sha256:${digest}`
|
|
78
|
+
|
|
61
79
|
/**
|
|
62
80
|
* The same plan: what the person confirmed is what would be published now. `released` only explains the version, and is gone once the next one is packaged.
|
|
63
81
|
* Field by field, so a plan that came back through JSON from another surface (the frame's confirm) is the same plan whatever order its fields arrived in.
|
|
64
82
|
*/
|
|
65
83
|
export function samePlan(a: PublishPlan, b: PublishPlan): boolean {
|
|
66
84
|
return (
|
|
85
|
+
a.target === b.target &&
|
|
86
|
+
a.package === b.package &&
|
|
87
|
+
a.registry === b.registry &&
|
|
67
88
|
a.owner === b.owner &&
|
|
68
89
|
a.repo === b.repo &&
|
|
69
90
|
a.version === b.version &&
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `registry:<id>`: a plugin the public registry (cordisplugins.github.io) lists, pulled by the id it shows. The registry only points at a public GitHub
|
|
3
|
+
* release, so the id is turned into the `github:<owner>/<repo>@<version>` source that release has, and the integrity the registry lists is the check the
|
|
4
|
+
* download must pass: a release changed after the registry read it is refused. Pure; the caller fetches the index.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const REGISTRY_INDEX_URL = 'https://cordisplugins.github.io/registry/index.json'
|
|
8
|
+
|
|
9
|
+
/** What a pull needs of one registry entry (the rest of the entry is for the page that shows it). */
|
|
10
|
+
export interface RegistryHit {
|
|
11
|
+
/** `github:<owner>/<repo>@<version>`: what another machine fetches, and what the app records. */
|
|
12
|
+
readonly source: string
|
|
13
|
+
/** The sha512 the registry lists for the release file. */
|
|
14
|
+
readonly integrity: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type RegistryLookup =
|
|
18
|
+
| { readonly ok: true; readonly hit: RegistryHit }
|
|
19
|
+
| { readonly ok: false; readonly reason: string; readonly next: string }
|
|
20
|
+
|
|
21
|
+
const GITHUB_REPO =
|
|
22
|
+
/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]*)\/([A-Za-z0-9][A-Za-z0-9._-]*?)(?:\.git)?\/?$/u
|
|
23
|
+
|
|
24
|
+
/** Find `id` (or the package name, `@scope/name`) in the index text; its release as a source, or why there is none. */
|
|
25
|
+
export function lookUpRegistry(indexText: string, id: string): RegistryLookup {
|
|
26
|
+
let entries: unknown
|
|
27
|
+
try {
|
|
28
|
+
entries = (JSON.parse(indexText) as { entries?: unknown }).entries
|
|
29
|
+
} catch {
|
|
30
|
+
entries = undefined
|
|
31
|
+
}
|
|
32
|
+
if (!Array.isArray(entries))
|
|
33
|
+
return {
|
|
34
|
+
ok: false,
|
|
35
|
+
reason: 'the registry answered in a way this app does not understand',
|
|
36
|
+
next: 'try again later, or pull github:<owner>/<repo> from the plugin page',
|
|
37
|
+
}
|
|
38
|
+
const wanted = id.trim().toLowerCase()
|
|
39
|
+
const entry = entries.find(
|
|
40
|
+
(item: { id?: unknown; name?: unknown }) =>
|
|
41
|
+
typeof item?.id === 'string' &&
|
|
42
|
+
(item.id.toLowerCase() === wanted ||
|
|
43
|
+
(typeof item.name === 'string' && item.name.toLowerCase() === wanted)),
|
|
44
|
+
) as { repo?: unknown; version?: unknown; integrity?: unknown } | undefined
|
|
45
|
+
if (entry === undefined)
|
|
46
|
+
return {
|
|
47
|
+
ok: false,
|
|
48
|
+
reason: `the registry lists no plugin ${id}`,
|
|
49
|
+
next: 'copy the id from https://cordisplugins.github.io, or pull github:<owner>/<repo>',
|
|
50
|
+
}
|
|
51
|
+
const repo = typeof entry.repo === 'string' ? GITHUB_REPO.exec(entry.repo) : null
|
|
52
|
+
if (repo === null || typeof entry.version !== 'string' || typeof entry.integrity !== 'string')
|
|
53
|
+
return {
|
|
54
|
+
ok: false,
|
|
55
|
+
reason: `the registry's entry for ${id} does not name a GitHub release this app can pull`,
|
|
56
|
+
next: 'open its page on https://cordisplugins.github.io for how to install it',
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
ok: true,
|
|
60
|
+
hit: { source: `github:${repo[1]}/${repo[2]}@${entry.version}`, integrity: entry.integrity },
|
|
61
|
+
}
|
|
62
|
+
}
|