@webboxes/plugin-hub 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +8 -2
- package/dist/contract.d.ts +63 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +310 -0
- package/dist/contract.js.map +1 -0
- package/dist/folders.d.ts +28 -0
- package/dist/folders.d.ts.map +1 -0
- package/dist/folders.js +88 -0
- package/dist/folders.js.map +1 -0
- package/dist/github-cli.d.ts +18 -0
- package/dist/github-cli.d.ts.map +1 -0
- package/dist/github-cli.js +140 -0
- package/dist/github-cli.js.map +1 -0
- package/dist/http.d.ts +17 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +59 -0
- package/dist/http.js.map +1 -0
- package/dist/hub.d.ts +129 -0
- package/dist/hub.d.ts.map +1 -0
- package/dist/hub.js +148 -0
- package/dist/hub.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/name.d.ts +31 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +57 -0
- package/dist/name.js.map +1 -0
- package/dist/npm-cli.d.ts +11 -0
- package/dist/npm-cli.d.ts.map +1 -0
- package/dist/npm-cli.js +102 -0
- package/dist/npm-cli.js.map +1 -0
- package/dist/npm-publish.d.ts +36 -0
- package/dist/npm-publish.d.ts.map +1 -0
- package/dist/npm-publish.js +63 -0
- package/dist/npm-publish.js.map +1 -0
- package/dist/pack.d.ts +32 -0
- package/dist/pack.d.ts.map +1 -0
- package/dist/pack.js +137 -0
- package/dist/pack.js.map +1 -0
- package/dist/pull.d.ts +55 -0
- package/dist/pull.d.ts.map +1 -0
- package/dist/pull.js +127 -0
- package/dist/pull.js.map +1 -0
- package/dist/save.d.ts +10 -0
- package/dist/save.d.ts.map +1 -0
- package/dist/save.js +15 -0
- package/dist/save.js.map +1 -0
- package/dist/share.d.ts +72 -0
- package/dist/share.d.ts.map +1 -0
- package/dist/share.js +136 -0
- package/dist/share.js.map +1 -0
- package/dist/source.d.ts +38 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +122 -0
- package/dist/source.js.map +1 -0
- package/dist/store.d.ts +43 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +112 -0
- package/dist/store.js.map +1 -0
- package/dist/tarball.d.ts +16 -0
- package/dist/tarball.d.ts.map +1 -0
- package/dist/tarball.js +138 -0
- package/dist/tarball.js.map +1 -0
- package/dist/version.d.ts +16 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +69 -0
- package/dist/version.js.map +1 -0
- package/package.json +44 -3
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// The share ports over the user's own `gh` and `git` (spec 044 guards: credentials stay with the user's tools; nothing waits on a prompt).
|
|
2
|
+
// In the shipped app these come from the user's machine: a missing tool or a missing login is reported with what to do, never worked around.
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
export class ToolError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'ToolError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const HINT = {
|
|
11
|
+
gh: 'install GitHub CLI (https://cli.github.com) and sign in with: gh auth login',
|
|
12
|
+
git: 'install git (https://git-scm.com)',
|
|
13
|
+
};
|
|
14
|
+
/** What to do when the tool is there but its login is not: only the sign-in step. */
|
|
15
|
+
const SIGN_IN = {
|
|
16
|
+
gh: 'sign in with: gh auth login',
|
|
17
|
+
git: 'sign in to the git host (for GitHub: gh auth login, then gh auth setup-git)',
|
|
18
|
+
};
|
|
19
|
+
function run(command, args, cwd) {
|
|
20
|
+
const result = spawnSync(command, [...args], { cwd, encoding: 'utf8', env: { ...process.env, GIT_TERMINAL_PROMPT: '0', GH_PROMPT_DISABLED: '1' }, maxBuffer: 64 * 1024 * 1024 });
|
|
21
|
+
if (result.error !== undefined)
|
|
22
|
+
throw new ToolError(`${command} is not available here: ${HINT[command] ?? result.error.message}`);
|
|
23
|
+
return { status: result.status ?? 1, stdout: result.stdout ?? '', stderr: result.stderr ?? '' };
|
|
24
|
+
}
|
|
25
|
+
function must(command, args, cwd) {
|
|
26
|
+
const result = run(command, args, cwd);
|
|
27
|
+
if (result.status !== 0) {
|
|
28
|
+
const last = result.stderr.trim().split('\n').at(-1) ?? `exit ${String(result.status)}`;
|
|
29
|
+
throw new ToolError(`${command} ${args.slice(0, 2).join(' ')} failed: ${last}${/auth|login|credential|HTTP 401/iu.test(result.stderr) ? ` (${SIGN_IN[command] ?? ''})` : ''}`);
|
|
30
|
+
}
|
|
31
|
+
return result.stdout;
|
|
32
|
+
}
|
|
33
|
+
export function githubCli() {
|
|
34
|
+
return {
|
|
35
|
+
login: () => must('gh', ['api', 'user', '--jq', '.login']).trim(),
|
|
36
|
+
repository(owner, repo) {
|
|
37
|
+
const result = run('gh', ['repo', 'view', `${owner}/${repo}`, '--json', 'visibility,url']);
|
|
38
|
+
if (result.status !== 0) {
|
|
39
|
+
if (/could not resolve to a repository|not found/iu.test(result.stderr))
|
|
40
|
+
return undefined;
|
|
41
|
+
throw new ToolError(`gh repo view ${owner}/${repo} failed: ${result.stderr.trim().split('\n').at(-1) ?? ''}`);
|
|
42
|
+
}
|
|
43
|
+
const body = JSON.parse(result.stdout);
|
|
44
|
+
return { visibility: body.visibility?.toLowerCase() === 'public' ? 'public' : 'private', url: body.url ?? `https://github.com/${owner}/${repo}` };
|
|
45
|
+
},
|
|
46
|
+
createRepository(owner, repo, visibility, description) {
|
|
47
|
+
must('gh', ['repo', 'create', `${owner}/${repo}`, `--${visibility}`, '--description', description]);
|
|
48
|
+
},
|
|
49
|
+
setVisibility(owner, repo, visibility) {
|
|
50
|
+
must('gh', ['repo', 'edit', `${owner}/${repo}`, '--visibility', visibility, '--accept-visibility-change-consequences']);
|
|
51
|
+
},
|
|
52
|
+
addTopics(owner, repo, topics) {
|
|
53
|
+
must('gh', ['repo', 'edit', `${owner}/${repo}`, ...topics.flatMap(topic => ['--add-topic', topic])]);
|
|
54
|
+
},
|
|
55
|
+
releaseExists: (owner, repo, tag) => run('gh', ['release', 'view', tag, '-R', `${owner}/${repo}`, '--json', 'tagName']).status === 0,
|
|
56
|
+
createRelease(owner, repo, tag, title, notes, assetPath) {
|
|
57
|
+
return must('gh', ['release', 'create', tag, assetPath, '-R', `${owner}/${repo}`, '--title', title, '--notes', notes, '--verify-tag']).trim();
|
|
58
|
+
},
|
|
59
|
+
cloneUrl: (owner, repo) => `https://github.com/${owner}/${repo}.git`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function gitCli() {
|
|
63
|
+
return {
|
|
64
|
+
clone(url, dir) { must('git', ['clone', '--quiet', url, dir]); },
|
|
65
|
+
commitAll(dir, message) {
|
|
66
|
+
must('git', ['add', '--all', '.'], dir);
|
|
67
|
+
if (run('git', ['diff', '--cached', '--quiet'], dir).status === 0)
|
|
68
|
+
return false;
|
|
69
|
+
must('git', ['commit', '--quiet', '-m', message], dir);
|
|
70
|
+
return true;
|
|
71
|
+
},
|
|
72
|
+
tag(dir, tag, message) { must('git', ['tag', '-a', tag, '-m', message], dir); },
|
|
73
|
+
push(dir, tag, fallbackBranch) {
|
|
74
|
+
const branch = run('git', ['symbolic-ref', '--short', 'HEAD'], dir).stdout.trim() || fallbackBranch;
|
|
75
|
+
must('git', ['push', '--quiet', 'origin', `HEAD:refs/heads/${branch}`], dir);
|
|
76
|
+
must('git', ['push', '--quiet', 'origin', `refs/tags/${tag}`], dir);
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* GitHub releases through the user's own `gh` login: what a pull of a private repository needs (an anonymous request cannot see it). Assets
|
|
82
|
+
* are fetched by their API address with `Accept: application/octet-stream`, which works for private and public repositories alike.
|
|
83
|
+
*/
|
|
84
|
+
export function githubReleasesViaGh() {
|
|
85
|
+
return {
|
|
86
|
+
async release(owner, repo, tag) {
|
|
87
|
+
const path = tag === undefined ? 'releases/latest' : `releases/tags/${encodeURIComponent(tag)}`;
|
|
88
|
+
const result = run('gh', ['api', `repos/${owner}/${repo}/${path}`]);
|
|
89
|
+
if (result.status !== 0) {
|
|
90
|
+
if (/HTTP 404|Not Found/iu.test(result.stderr))
|
|
91
|
+
return undefined;
|
|
92
|
+
throw new ToolError(`gh api repos/${owner}/${repo}/${path} failed: ${result.stderr.trim().split('\n').at(-1) ?? ''}`);
|
|
93
|
+
}
|
|
94
|
+
const body = JSON.parse(result.stdout);
|
|
95
|
+
if (typeof body.tag_name !== 'string' || !Array.isArray(body.assets))
|
|
96
|
+
throw new ToolError(`gh returned an unexpected release for ${owner}/${repo}`);
|
|
97
|
+
return { tag: body.tag_name, assets: body.assets.flatMap(asset => (typeof asset.name === 'string' && typeof asset.url === 'string' ? [{ name: asset.name, url: asset.url, ...(typeof asset.digest === 'string' ? { digest: asset.digest } : {}) }] : [])) };
|
|
98
|
+
},
|
|
99
|
+
async download(url) {
|
|
100
|
+
const result = spawnSync('gh', ['api', '-H', 'Accept: application/octet-stream', url], { env: { ...process.env, GH_PROMPT_DISABLED: '1' }, maxBuffer: 64 * 1024 * 1024 });
|
|
101
|
+
if (result.error !== undefined)
|
|
102
|
+
throw new ToolError(`gh is not available here: ${HINT['gh'] ?? ''}`);
|
|
103
|
+
if (result.status !== 0)
|
|
104
|
+
throw new ToolError(`gh could not download ${url}: ${String(result.stderr).trim().split('\n').at(-1) ?? ''}`);
|
|
105
|
+
return new Uint8Array(result.stdout);
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Releases from the first port that sees the repository: anonymous HTTPS for a public one, then the user's `gh` for a private one. Downloads
|
|
111
|
+
* go to the port that answered for the release, since only it can fetch its asset addresses.
|
|
112
|
+
*/
|
|
113
|
+
export function firstReleasePort(...ports) {
|
|
114
|
+
const answered = new Map();
|
|
115
|
+
return {
|
|
116
|
+
async release(owner, repo, tag) {
|
|
117
|
+
let lastError;
|
|
118
|
+
for (const port of ports) {
|
|
119
|
+
try {
|
|
120
|
+
const found = await port.release(owner, repo, tag);
|
|
121
|
+
if (found !== undefined) {
|
|
122
|
+
for (const asset of found.assets)
|
|
123
|
+
answered.set(asset.url, port);
|
|
124
|
+
return found;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (cause) {
|
|
128
|
+
lastError = cause;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (lastError !== undefined)
|
|
132
|
+
throw lastError;
|
|
133
|
+
return undefined;
|
|
134
|
+
},
|
|
135
|
+
async download(url) {
|
|
136
|
+
return (answered.get(url) ?? ports[0]).download(url);
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=github-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-cli.js","sourceRoot":"","sources":["../src/github-cli.ts"],"names":[],"mappings":"AAAA,2IAA2I;AAC3I,6IAA6I;AAC7I,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAI9C,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA;IACzB,CAAC;CACF;AAED,MAAM,IAAI,GAA2B;IACnC,EAAE,EAAE,6EAA6E;IACjF,GAAG,EAAE,mCAAmC;CACzC,CAAA;AACD,qFAAqF;AACrF,MAAM,OAAO,GAA2B;IACtC,EAAE,EAAE,6BAA6B;IACjC,GAAG,EAAE,6EAA6E;CACnF,CAAA;AAED,SAAS,GAAG,CAAC,OAAe,EAAE,IAAuB,EAAE,GAAY;IACjE,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,QAA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AC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG;YAC5B,IAAI,SAAkB,CAAA;YACtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC;oBACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;oBAClD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;wBACxB,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM;4BAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;wBAC/D,OAAO,KAAK,CAAA;oBACd,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAAC,SAAS,GAAG,KAAK,CAAA;gBAAC,CAAC;YACvC,CAAC;YACD,IAAI,SAAS,KAAK,SAAS;gBAAE,MAAM,SAAS,CAAA;YAC5C,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,GAAG;YAChB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QACvD,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RegistryPort, ReleasePort } from './pull.js';
|
|
2
|
+
export type Fetch = (url: string, init?: {
|
|
3
|
+
readonly headers?: Record<string, string>;
|
|
4
|
+
readonly signal?: AbortSignal;
|
|
5
|
+
}) => Promise<{
|
|
6
|
+
readonly ok: boolean;
|
|
7
|
+
readonly status: number;
|
|
8
|
+
json(): Promise<unknown>;
|
|
9
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
10
|
+
}>;
|
|
11
|
+
/** GitHub releases of public repositories, through api.github.com. */
|
|
12
|
+
export declare function githubReleasesOverHttps(fetchImpl?: Fetch, api?: string): ReleasePort;
|
|
13
|
+
/** The public npm registry (or another registry URL). */
|
|
14
|
+
export declare function npmRegistryOverHttps(fetchImpl?: Fetch, registry?: string): RegistryPort;
|
|
15
|
+
/** A plain https download, for a tarball-URL source. */
|
|
16
|
+
export declare function httpsDownload(fetchImpl?: Fetch): (url: string) => Promise<Uint8Array>;
|
|
17
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAe,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvE,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,KAAK,OAAO,CAAC;IAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC,CAAA;AAenP,sEAAsE;AACtE,wBAAgB,uBAAuB,CAAC,SAAS,GAAE,KAAiC,EAAE,GAAG,SAA2B,GAAG,WAAW,CAiBjI;AAED,yDAAyD;AACzD,wBAAgB,oBAAoB,CAAC,SAAS,GAAE,KAAiC,EAAE,QAAQ,SAA+B,GAAG,YAAY,CAcxI;AAED,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,SAAS,GAAE,KAAiC,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAEhH"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const MAX_DOWNLOAD_BYTES = 64 * 1024 * 1024;
|
|
2
|
+
const TIMEOUT_MS = 30_000;
|
|
3
|
+
const USER_AGENT = 'acryl-plugin-hub';
|
|
4
|
+
async function downloadBytes(fetchImpl, url) {
|
|
5
|
+
if (!url.startsWith('https://'))
|
|
6
|
+
throw new Error(`refusing a non-https download: ${url}`);
|
|
7
|
+
const response = await fetchImpl(url, { headers: { 'User-Agent': USER_AGENT, Accept: 'application/octet-stream' }, signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
8
|
+
if (!response.ok)
|
|
9
|
+
throw new Error(`${url} answered ${response.status}`);
|
|
10
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
11
|
+
if (bytes.length > MAX_DOWNLOAD_BYTES)
|
|
12
|
+
throw new Error(`${url} is larger than ${MAX_DOWNLOAD_BYTES} bytes`);
|
|
13
|
+
return bytes;
|
|
14
|
+
}
|
|
15
|
+
/** GitHub releases of public repositories, through api.github.com. */
|
|
16
|
+
export function githubReleasesOverHttps(fetchImpl = fetch, api = 'https://api.github.com') {
|
|
17
|
+
return {
|
|
18
|
+
async release(owner, repo, tag) {
|
|
19
|
+
const path = tag === undefined ? 'releases/latest' : `releases/tags/${encodeURIComponent(tag)}`;
|
|
20
|
+
const response = await fetchImpl(`${api}/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/${path}`, { headers: { 'User-Agent': USER_AGENT, Accept: 'application/vnd.github+json' }, signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
21
|
+
if (response.status === 404)
|
|
22
|
+
return undefined;
|
|
23
|
+
if (!response.ok)
|
|
24
|
+
throw new Error(`GitHub answered ${response.status} for ${owner}/${repo}`);
|
|
25
|
+
const body = await response.json();
|
|
26
|
+
if (typeof body.tag_name !== 'string' || !Array.isArray(body.assets))
|
|
27
|
+
throw new Error(`GitHub returned an unexpected release for ${owner}/${repo}`);
|
|
28
|
+
const assets = body.assets.flatMap((asset) => typeof asset.name === 'string' && typeof asset.browser_download_url === 'string'
|
|
29
|
+
? [{ name: asset.name, url: asset.browser_download_url, ...(typeof asset.digest === 'string' ? { digest: asset.digest } : {}) }]
|
|
30
|
+
: []);
|
|
31
|
+
return { tag: body.tag_name, assets };
|
|
32
|
+
},
|
|
33
|
+
download: url => downloadBytes(fetchImpl, url),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** The public npm registry (or another registry URL). */
|
|
37
|
+
export function npmRegistryOverHttps(fetchImpl = fetch, registry = 'https://registry.npmjs.org') {
|
|
38
|
+
return {
|
|
39
|
+
async resolve(name, version) {
|
|
40
|
+
const response = await fetchImpl(`${registry.replace(/\/$/u, '')}/${name.replace('/', '%2F')}`, { headers: { 'User-Agent': USER_AGENT, Accept: 'application/json' }, signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
41
|
+
if (response.status === 404)
|
|
42
|
+
return undefined;
|
|
43
|
+
if (!response.ok)
|
|
44
|
+
throw new Error(`the registry answered ${response.status} for ${name}`);
|
|
45
|
+
const body = await response.json();
|
|
46
|
+
const chosen = version ?? body['dist-tags']?.['latest'];
|
|
47
|
+
const dist = chosen === undefined ? undefined : body.versions?.[chosen]?.dist;
|
|
48
|
+
if (chosen === undefined || typeof dist?.tarball !== 'string')
|
|
49
|
+
return undefined;
|
|
50
|
+
return { version: chosen, tarball: dist.tarball, ...(typeof dist.integrity === 'string' ? { integrity: dist.integrity } : {}) };
|
|
51
|
+
},
|
|
52
|
+
download: url => downloadBytes(fetchImpl, url),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** A plain https download, for a tarball-URL source. */
|
|
56
|
+
export function httpsDownload(fetchImpl = fetch) {
|
|
57
|
+
return url => downloadBytes(fetchImpl, url);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts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AE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;QACjI,CAAC;QACD,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC;KAC/C,CAAA;AACH,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,aAAa,CAAC,YAAmB,KAAyB;IACxE,OAAO,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;AAC7C,CAAC"}
|
package/dist/hub.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { type RegistryPort, type ReleasePort } from './pull.js';
|
|
2
|
+
import { type NpmPublishOptions, type NpmPublishPort, type NpmPublishResult } from './npm-publish.js';
|
|
3
|
+
import { type PublishGitPort, type RepositoryHostPort, type ShareOptions, type ShareResult } from './share.js';
|
|
4
|
+
import type { PluginStore, StoredVersion } from './store.js';
|
|
5
|
+
import { type VersionBump } from './version.js';
|
|
6
|
+
/** The outcome an installer reports, in the shape DSH's `pluginManager` returns (`ChangeResult`), reduced to what the hub reads. */
|
|
7
|
+
export interface InstallOutcome {
|
|
8
|
+
readonly application: 'applied' | 'restart-required' | 'overridden' | 'failed' | 'cancelled';
|
|
9
|
+
readonly error?: {
|
|
10
|
+
readonly code: string;
|
|
11
|
+
};
|
|
12
|
+
readonly packageResult?: {
|
|
13
|
+
readonly output: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** What installs a stored tarball into the running app and lists what is installed: DSH's `pluginManager` in a DSH-based app. */
|
|
17
|
+
export interface InstallerPort {
|
|
18
|
+
installBundle(tarballPath: string): Promise<InstallOutcome>;
|
|
19
|
+
listBundles(): Promise<readonly {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly version?: string;
|
|
22
|
+
readonly enabled: boolean;
|
|
23
|
+
readonly installed: boolean;
|
|
24
|
+
readonly removable: boolean;
|
|
25
|
+
}[]>;
|
|
26
|
+
}
|
|
27
|
+
export interface HubPorts {
|
|
28
|
+
readonly store: PluginStore;
|
|
29
|
+
readonly releases?: ReleasePort;
|
|
30
|
+
readonly registry?: RegistryPort;
|
|
31
|
+
readonly download?: (url: string) => Promise<Uint8Array>;
|
|
32
|
+
/** Whether the app provides a service on the host side, for the service contract check. */
|
|
33
|
+
readonly has: (service: string) => boolean;
|
|
34
|
+
/** The installer, read when needed (it may load after the hub); undefined when the app has none. */
|
|
35
|
+
readonly installer: () => InstallerPort | undefined;
|
|
36
|
+
/** The git host and git for sharing (the user's own `gh` and `git`); without them sharing is unavailable and says so. */
|
|
37
|
+
readonly share?: {
|
|
38
|
+
readonly host: RepositoryHostPort;
|
|
39
|
+
readonly git: PublishGitPort;
|
|
40
|
+
};
|
|
41
|
+
/** npm for publishing (the user's own `npm`); without it publishing to npm is unavailable and says so. */
|
|
42
|
+
readonly npm?: NpmPublishPort;
|
|
43
|
+
}
|
|
44
|
+
export type PullStatus = 'installed' | 'restart-required' | 'stored' | 'missing-services' | 'install-failed' | 'overridden' | 'cancelled';
|
|
45
|
+
export interface PullResult {
|
|
46
|
+
readonly status: PullStatus;
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly version: string;
|
|
49
|
+
readonly integrity: string;
|
|
50
|
+
readonly path: string;
|
|
51
|
+
/** False when the store already held these exact bytes. */
|
|
52
|
+
readonly added: boolean;
|
|
53
|
+
readonly fetchedFrom: string;
|
|
54
|
+
/** Whether the plugin declares a host service contract the hub could check (a stock DSH plugin usually has none). */
|
|
55
|
+
readonly contractChecked: boolean;
|
|
56
|
+
/** The required host services this app lacks; the plugin is kept but not installed. */
|
|
57
|
+
readonly missing?: readonly string[];
|
|
58
|
+
/** Why it is only stored, when it is. */
|
|
59
|
+
readonly reason?: string;
|
|
60
|
+
readonly outcome?: InstallOutcome;
|
|
61
|
+
}
|
|
62
|
+
export interface SaveResult {
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly version: string;
|
|
65
|
+
readonly integrity: string;
|
|
66
|
+
readonly path: string;
|
|
67
|
+
readonly files: readonly string[];
|
|
68
|
+
readonly added: boolean;
|
|
69
|
+
}
|
|
70
|
+
export type UpdateResult = {
|
|
71
|
+
readonly status: 'updated' | 'restart-required';
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly from?: string;
|
|
74
|
+
readonly to: string;
|
|
75
|
+
readonly source: string;
|
|
76
|
+
readonly pull: PullResult;
|
|
77
|
+
} | {
|
|
78
|
+
readonly status: 'up-to-date';
|
|
79
|
+
readonly name: string;
|
|
80
|
+
readonly version: string;
|
|
81
|
+
readonly source: string;
|
|
82
|
+
} | {
|
|
83
|
+
readonly status: 'not-updatable';
|
|
84
|
+
readonly name: string;
|
|
85
|
+
readonly reason: string;
|
|
86
|
+
} | {
|
|
87
|
+
readonly status: 'failed';
|
|
88
|
+
readonly name: string;
|
|
89
|
+
readonly source: string;
|
|
90
|
+
readonly pull: PullResult;
|
|
91
|
+
};
|
|
92
|
+
export interface InstalledPlugin {
|
|
93
|
+
readonly name: string;
|
|
94
|
+
readonly version?: string;
|
|
95
|
+
readonly enabled: boolean;
|
|
96
|
+
readonly removable: boolean;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The host half of a plugin's service contract against an app: the services its `acryl.requires.host` names that the app does not provide.
|
|
100
|
+
* A plugin without a contract is not refused; `checked` says so, and a missing service would then show as PENDING after install.
|
|
101
|
+
*/
|
|
102
|
+
export declare function missingHostServices(manifest: Readonly<Record<string, unknown>>, has: (service: string) => boolean): {
|
|
103
|
+
readonly checked: boolean;
|
|
104
|
+
readonly missing: readonly string[];
|
|
105
|
+
};
|
|
106
|
+
/** A source folder by absolute path, or by its package name or folder name under one of the app's source roots. */
|
|
107
|
+
export declare function findSourceFolder(nameOrFolder: string, sourceRoots: readonly (string | undefined)[]): string | undefined;
|
|
108
|
+
export interface PluginHub {
|
|
109
|
+
readonly store: PluginStore;
|
|
110
|
+
saved(): StoredVersion[];
|
|
111
|
+
save(folder: string): SaveResult;
|
|
112
|
+
bump(folder: string, bump: VersionBump): {
|
|
113
|
+
readonly name: string;
|
|
114
|
+
readonly from: string;
|
|
115
|
+
readonly to: string;
|
|
116
|
+
};
|
|
117
|
+
pull(source: string, options?: {
|
|
118
|
+
readonly install?: boolean;
|
|
119
|
+
readonly expectIntegrity?: string;
|
|
120
|
+
}): Promise<PullResult>;
|
|
121
|
+
installed(): Promise<InstalledPlugin[] | undefined>;
|
|
122
|
+
share(folder: string, options?: ShareOptions): Promise<ShareResult>;
|
|
123
|
+
/** Pull and install the newest release of an installed plugin from where it was pulled before (the store records that). */
|
|
124
|
+
update(name: string): Promise<UpdateResult>;
|
|
125
|
+
/** Publish a plugin to an npm registry (the public one unless `registry` names another). */
|
|
126
|
+
publishNpm(folder: string, options?: NpmPublishOptions): Promise<NpmPublishResult>;
|
|
127
|
+
}
|
|
128
|
+
export declare function createPluginHub(ports: HubPorts): PluginHub;
|
|
129
|
+
//# sourceMappingURL=hub.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../src/hub.ts"],"names":[],"mappings":"AAKA,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAA;AAG3E,OAAO,EAAgB,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnH,OAAO,EAAe,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAC3H,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAA8C,KAAK,WAAW,EAAE,M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AgF1D"}
|
package/dist/hub.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// The plugin hub: the one set of operations every face drives (a chat command, a CLI verb, an agent tool, the Plugins page), so a result is the
|
|
2
|
+
// same whichever face asked (spec 044 lifecycle.md, "One service, four faces"). Host-independent: the app supplies what it has through ports
|
|
3
|
+
// (which services it provides, its installer, its source folders), and an app without an installer still saves and pulls into the store.
|
|
4
|
+
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { isAbsolute, join } from 'node:path';
|
|
6
|
+
import { pullPlugin } from './pull.js';
|
|
7
|
+
import { formatPluginSource, parsePluginSource } from './source.js';
|
|
8
|
+
import { savePlugin } from './save.js';
|
|
9
|
+
import { publishToNpm } from './npm-publish.js';
|
|
10
|
+
import { sharePlugin } from './share.js';
|
|
11
|
+
import { bumpVersion, compareVersions, parseVersion } from './version.js';
|
|
12
|
+
/** The same source without a version, so it names the newest release; undefined for a file, URL or folder, which have no newer release. */
|
|
13
|
+
function followLatest(source) {
|
|
14
|
+
switch (source.kind) {
|
|
15
|
+
case 'github': return { kind: 'github', owner: source.owner, repo: source.repo };
|
|
16
|
+
case 'npm': return { kind: 'npm', name: source.name };
|
|
17
|
+
case 'name': return { kind: 'name', name: source.name };
|
|
18
|
+
case 'store':
|
|
19
|
+
case 'tarball-file':
|
|
20
|
+
case 'tarball-url':
|
|
21
|
+
case 'folder': return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The host half of a plugin's service contract against an app: the services its `acryl.requires.host` names that the app does not provide.
|
|
26
|
+
* A plugin without a contract is not refused; `checked` says so, and a missing service would then show as PENDING after install.
|
|
27
|
+
*/
|
|
28
|
+
export function missingHostServices(manifest, has) {
|
|
29
|
+
const acryl = manifest['acryl'];
|
|
30
|
+
const required = acryl?.requires?.host;
|
|
31
|
+
if (!Array.isArray(required))
|
|
32
|
+
return { checked: false, missing: [] };
|
|
33
|
+
return { checked: true, missing: required.filter((service) => typeof service === 'string' && !has(service)) };
|
|
34
|
+
}
|
|
35
|
+
/** A source folder by absolute path, or by its package name or folder name under one of the app's source roots. */
|
|
36
|
+
export function findSourceFolder(nameOrFolder, sourceRoots) {
|
|
37
|
+
if (isAbsolute(nameOrFolder))
|
|
38
|
+
return existsSync(join(nameOrFolder, 'package.json')) ? nameOrFolder : undefined;
|
|
39
|
+
for (const root of sourceRoots) {
|
|
40
|
+
if (root === undefined || !existsSync(root))
|
|
41
|
+
continue;
|
|
42
|
+
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
43
|
+
if (!entry.isDirectory())
|
|
44
|
+
continue;
|
|
45
|
+
const dir = join(root, entry.name);
|
|
46
|
+
try {
|
|
47
|
+
const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
|
|
48
|
+
if (pkg.name === nameOrFolder || entry.name === nameOrFolder)
|
|
49
|
+
return dir;
|
|
50
|
+
}
|
|
51
|
+
catch { /* not a plugin folder */ }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
export function createPluginHub(ports) {
|
|
57
|
+
const { store } = ports;
|
|
58
|
+
const hub = {
|
|
59
|
+
store,
|
|
60
|
+
saved: () => store.list(),
|
|
61
|
+
save(folder) {
|
|
62
|
+
const { packed, stored, added } = savePlugin(folder, store);
|
|
63
|
+
return { name: stored.name, version: stored.version, integrity: stored.integrity, path: stored.path, files: packed.files, added };
|
|
64
|
+
},
|
|
65
|
+
bump(folder, bump) {
|
|
66
|
+
const file = join(folder, 'package.json');
|
|
67
|
+
const text = readFileSync(file, 'utf8');
|
|
68
|
+
const pkg = JSON.parse(text);
|
|
69
|
+
if (typeof pkg['version'] !== 'string')
|
|
70
|
+
throw new Error(`${file} has no "version"`);
|
|
71
|
+
const next = bumpVersion(pkg['version'], bump);
|
|
72
|
+
const indent = /^(\s+)"/mu.exec(text)?.[1] ?? ' ';
|
|
73
|
+
writeFileSync(file, `${JSON.stringify({ ...pkg, version: next }, null, indent)}\n`);
|
|
74
|
+
return { name: String(pkg['name']), from: pkg['version'], to: next };
|
|
75
|
+
},
|
|
76
|
+
async pull(argument, options = {}) {
|
|
77
|
+
const pulled = await pullPlugin(parsePluginSource(argument), {
|
|
78
|
+
store,
|
|
79
|
+
...(ports.releases === undefined ? {} : { releases: ports.releases }),
|
|
80
|
+
...(ports.registry === undefined ? {} : { registry: ports.registry }),
|
|
81
|
+
...(ports.download === undefined ? {} : { download: ports.download }),
|
|
82
|
+
}, options.expectIntegrity === undefined ? {} : { expectIntegrity: options.expectIntegrity });
|
|
83
|
+
const base = { name: pulled.stored.name, version: pulled.stored.version, integrity: pulled.stored.integrity, path: pulled.stored.path, added: pulled.added, fetchedFrom: pulled.fetchedFrom };
|
|
84
|
+
const contract = missingHostServices(pulled.manifest, ports.has);
|
|
85
|
+
if (contract.missing.length > 0)
|
|
86
|
+
return { ...base, status: 'missing-services', contractChecked: true, missing: contract.missing };
|
|
87
|
+
if (options.install === false)
|
|
88
|
+
return { ...base, status: 'stored', contractChecked: contract.checked };
|
|
89
|
+
const installer = ports.installer();
|
|
90
|
+
if (installer === undefined)
|
|
91
|
+
return { ...base, status: 'stored', contractChecked: contract.checked, reason: 'this app has no plugin installer (DSH\'s plugin manager is not loaded)' };
|
|
92
|
+
const outcome = await installer.installBundle(pulled.stored.path);
|
|
93
|
+
const status = outcome.error !== undefined || outcome.application === 'failed' ? 'install-failed' : outcome.application === 'applied' ? 'installed' : outcome.application;
|
|
94
|
+
return { ...base, status, contractChecked: contract.checked, outcome };
|
|
95
|
+
},
|
|
96
|
+
async share(folder, options = {}) {
|
|
97
|
+
if (ports.share === undefined)
|
|
98
|
+
return { status: 'refused', reason: 'sharing is not available in this app (no git host connection)' };
|
|
99
|
+
return sharePlugin(folder, options, { host: ports.share.host, git: ports.share.git, store });
|
|
100
|
+
},
|
|
101
|
+
async publishNpm(folder, options = {}) {
|
|
102
|
+
if (ports.npm === undefined)
|
|
103
|
+
return { status: 'refused', reason: 'publishing to npm is not available in this app' };
|
|
104
|
+
return publishToNpm(folder, options, { npm: ports.npm, store });
|
|
105
|
+
},
|
|
106
|
+
async update(name) {
|
|
107
|
+
const installedVersion = (await hub.installed())?.find(plugin => plugin.name === name)?.version;
|
|
108
|
+
const records = store.list().filter(entry => entry.name === name);
|
|
109
|
+
const record = records.find(entry => entry.version === installedVersion) ?? records[0];
|
|
110
|
+
if (record === undefined)
|
|
111
|
+
return { status: 'not-updatable', name, reason: `${name} was not pulled through the plugin hub, so where its newer versions are is not known; pull it once from its source (github:, npm:)` };
|
|
112
|
+
let latest;
|
|
113
|
+
try {
|
|
114
|
+
latest = followLatest(parsePluginSource(record.from));
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
latest = undefined;
|
|
118
|
+
}
|
|
119
|
+
if (latest === undefined)
|
|
120
|
+
return { status: 'not-updatable', name, reason: `${name} came from ${record.from}, which has no newer releases; pull a newer file or release explicitly` };
|
|
121
|
+
const source = formatPluginSource(latest);
|
|
122
|
+
const current = parseVersion(installedVersion ?? record.version);
|
|
123
|
+
const fetched = await hub.pull(source, { install: false });
|
|
124
|
+
const newest = parseVersion(fetched.version);
|
|
125
|
+
if (current !== undefined && newest !== undefined && compareVersions(newest, current) <= 0)
|
|
126
|
+
return { status: 'up-to-date', name, version: current.text, source };
|
|
127
|
+
if (fetched.status === 'missing-services')
|
|
128
|
+
return { status: 'failed', name, source, pull: fetched };
|
|
129
|
+
const pulled = await hub.pull(`store:${name}@${fetched.version}`);
|
|
130
|
+
const from = installedVersion ?? record.version;
|
|
131
|
+
if (pulled.status === 'installed')
|
|
132
|
+
return { status: 'updated', name, from, to: pulled.version, source, pull: pulled };
|
|
133
|
+
if (pulled.status === 'restart-required')
|
|
134
|
+
return { status: 'restart-required', name, from, to: pulled.version, source, pull: pulled };
|
|
135
|
+
return { status: 'failed', name, source, pull: pulled };
|
|
136
|
+
},
|
|
137
|
+
async installed() {
|
|
138
|
+
const installer = ports.installer();
|
|
139
|
+
if (installer === undefined)
|
|
140
|
+
return undefined;
|
|
141
|
+
return (await installer.listBundles()).filter(bundle => bundle.installed).map(bundle => ({
|
|
142
|
+
name: bundle.name, ...(bundle.version === undefined ? {} : { version: bundle.version }), enabled: bundle.enabled, removable: bundle.removable,
|
|
143
|
+
}));
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
return hub;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=hub.js.map
|
package/dist/hub.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hub.js","sourceRoot":"","sources":["../src/hub.ts"],"names":[],"mappings":"AAAA,gJAAgJ;AAChJ,6IAA6I;AAC7I,yIAAyI;AACzI,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC9E,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAuC,MAAM,WAAW,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAqB,MAAM,aAAa,CAAA;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,YAAY,EAAsE,MAAM,kBAAkB,CAAA;AACnH,OAAO,EAAE,WAAW,EAAqF,MAAM,YAAY,CAAA;AAE3H,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAoB,MAAM,cAAc,CAAA;AAiE3F,2IAA2I;AAC3I,SAAS,YAAY,CAAC,MAAoB;IACxC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,QAAQ,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;QAChF,KAAK,KAAK,CAAC,CAAC,OAAO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CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS;aAC9I,CAAC,CAAC,CAAA;QACL,CAAC;KACF,CAAA;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { InvalidPluginNameError, parsePluginName, pluginNameOf, storeDirectoryOf, type PluginName } from './name.js';
|
|
2
|
+
export { bumpVersion, compareVersions, newestVersion, parseVersion, type Version, type VersionBump } from './version.js';
|
|
3
|
+
export { formatPluginSource, InvalidPluginSourceError, parsePluginSource, type PluginSource } from './source.js';
|
|
4
|
+
export { integrityOf, readTarball, writeTarball, type TarballFile } from './tarball.js';
|
|
5
|
+
export { bundleProblem, manifestOfTarball, packageFiles, packFolder, PackError, type PackedPlugin } from './pack.js';
|
|
6
|
+
export { PluginStore, StoreConflictError, type StoredVersion, type StoreRecord } from './store.js';
|
|
7
|
+
export { currentSourcePath, HOME_PLUGINS_FOLDER, homePluginsDir, moveFolder, PROJECT_PLUGINS_FOLDER, projectPluginsDir, STORE_FOLDER, storeRootOf, type FolderMove, type MoveReporter } from './folders.js';
|
|
8
|
+
export { savePlugin, type SavedPlugin } from './save.js';
|
|
9
|
+
export { pullPlugin, PullError, type PulledPlugin, type PullOptions, type PullPorts, type RegistryPort, type ReleaseInfo, type ReleasePort } from './pull.js';
|
|
10
|
+
export { githubReleasesOverHttps, httpsDownload, npmRegistryOverHttps, type Fetch } from './http.js';
|
|
11
|
+
export { createPluginHub, findSourceFolder, missingHostServices, type HubPorts, type InstalledPlugin, type InstallerPort, type InstallOutcome, type PluginHub, type PullResult, type PullStatus, type SaveResult, type UpdateResult } from './hub.js';
|
|
12
|
+
export { checkContractShape, clientInjectFromSource, hostEntryOf, hostInjectFromSource, providedServices, readServiceContract, slotsInSource, syncServiceContract, type ServiceContract, type Side, type SideLists } from './contract.js';
|
|
13
|
+
export { PLUGIN_LABELS, type PluginKind, sharePlugin, type PublishGitPort, type RepositoryHostPort, type ShareOptions, type ShareResult, type Visibility } from './share.js';
|
|
14
|
+
export { firstReleasePort, gitCli, githubCli, githubReleasesViaGh, ToolError } from './github-cli.js';
|
|
15
|
+
export { NPM_REGISTRY, publishToNpm, type NpmPublishOptions, type NpmPublishPort, type NpmPublishResult } from './npm-publish.js';
|
|
16
|
+
export { firstRegistryPort, npmCli, npmRegistryViaCli } from './npm-cli.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAA;AACpH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AACxH,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAChH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AACvF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AACpH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAClG,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,UAAU,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AAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACjI,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @webboxes/plugin-hub: saving, sharing and pulling Cordis plugins, host-independent (spec 044 lifecycle.md, "Built to be extracted into
|
|
2
|
+
// ACRYL Blends", layer 1). The Cordis service that offers these to an app, and its faces, live in the app; this package has no Cordis, DSH or
|
|
3
|
+
// surface dependency, so the engine, a catalog's CI and other runtimes can use it.
|
|
4
|
+
export { InvalidPluginNameError, parsePluginName, pluginNameOf, storeDirectoryOf } from './name.js';
|
|
5
|
+
export { bumpVersion, compareVersions, newestVersion, parseVersion } from './version.js';
|
|
6
|
+
export { formatPluginSource, InvalidPluginSourceError, parsePluginSource } from './source.js';
|
|
7
|
+
export { integrityOf, readTarball, writeTarball } from './tarball.js';
|
|
8
|
+
export { bundleProblem, manifestOfTarball, packageFiles, packFolder, PackError } from './pack.js';
|
|
9
|
+
export { PluginStore, StoreConflictError } from './store.js';
|
|
10
|
+
export { currentSourcePath, HOME_PLUGINS_FOLDER, homePluginsDir, moveFolder, PROJECT_PLUGINS_FOLDER, projectPluginsDir, STORE_FOLDER, storeRootOf } from './folders.js';
|
|
11
|
+
export { savePlugin } from './save.js';
|
|
12
|
+
export { pullPlugin, PullError } from './pull.js';
|
|
13
|
+
export { githubReleasesOverHttps, httpsDownload, npmRegistryOverHttps } from './http.js';
|
|
14
|
+
export { createPluginHub, findSourceFolder, missingHostServices } from './hub.js';
|
|
15
|
+
export { checkContractShape, clientInjectFromSource, hostEntryOf, hostInjectFromSource, providedServices, readServiceContract, slotsInSource, syncServiceContract } from './contract.js';
|
|
16
|
+
export { PLUGIN_LABELS, sharePlugin } from './share.js';
|
|
17
|
+
export { firstReleasePort, gitCli, githubCli, githubReleasesViaGh, ToolError } from './github-cli.js';
|
|
18
|
+
export { NPM_REGISTRY, publishToNpm } from './npm-publish.js';
|
|
19
|
+
export { firstRegistryPort, npmCli, npmRegistryViaCli } from './npm-cli.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yIAAyI;AACzI,8IAA8I;AAC9I,mFAAmF;AACnF,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAmB,MAAM,WAAW,CAAA;AACpH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAkC,MAAM,cAAc,CAAA;AACxH,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,iBAAiB,EAAqB,MAAM,aAAa,CAAA;AAChH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAoB,MAAM,cAAc,CAAA;AACvF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAqB,MAAM,WAAW,CAAA;AACpH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAwC,MAAM,YAAY,CAAA;AAClG,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,UAAU,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,YAAY,EAAE,WAAW,EAAsC,MAAM,cAAc,CAAA;AAC3M,OAAO,EAAE,UAAU,EAAoB,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,SAAS,EAA8G,MAAM,WAAW,CAAA;AAC7J,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,oBAAoB,EAAc,MAAM,WAAW,CAAA;AACpG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAsK,MAAM,UAAU,CAAA;AACrP,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,WAAW,EAAE,oBA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