@acryldev/blends-frame 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app-plugins.d.ts +3 -3
- package/lib/client.js +10 -3
- package/lib/client.js.map +1 -1
- package/lib/contract.d.ts +5 -0
- package/lib/index.js +26 -11
- package/lib/index.js.map +1 -1
- package/lib/types/contract.d.ts +5 -0
- package/package.json +3 -3
package/lib/contract.d.ts
CHANGED
|
@@ -247,6 +247,11 @@ export interface SharePlan {
|
|
|
247
247
|
readonly license?: string;
|
|
248
248
|
/** The public registry (cordisplugins.github.io) lists it: the share sets the `cordis-plugin` topic. Only a public share can be listed. */
|
|
249
249
|
readonly registry?: boolean;
|
|
250
|
+
/** Where the registry lists it (category slugs of acrylblends.github.io/blends): the app's own store place, written as package.json keywords. */
|
|
251
|
+
readonly placement?: {
|
|
252
|
+
readonly category: string;
|
|
253
|
+
readonly subcategory?: string;
|
|
254
|
+
};
|
|
250
255
|
}
|
|
251
256
|
/** @throws when the value is not a share plan. */
|
|
252
257
|
export declare function parseSharePlan(value: unknown): SharePlan;
|
package/lib/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "nod
|
|
|
7
7
|
import { Acryl } from "@acryldev/blends";
|
|
8
8
|
import { error } from "@acryldev/loopback-http";
|
|
9
9
|
import { INVALID_JSON, jsonBody, ownPage, privateApi, readJson } from "@acryldev/loopback-http/router";
|
|
10
|
-
import { PluginStore, StoreConflictError, bumpVersion, gitCli, githubCli, parseVersion, savePlugin, sharePlugin, storeRootOf } from "@acryldev/plugin-hub-core";
|
|
10
|
+
import { PluginStore, StoreConflictError, bumpVersion, gitCli, githubCli, parseVersion, placementOf, savePlugin, sharePlugin, storeRootOf, withPlacement } from "@acryldev/plugin-hub-core";
|
|
11
11
|
import { GitRunner, Versions } from "@acryldev/versions";
|
|
12
12
|
import * as workspaceHost from "@acryldev/workspace";
|
|
13
13
|
import { promisify } from "node:util";
|
|
@@ -195,13 +195,18 @@ const GITHUB_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/u;
|
|
|
195
195
|
/** @throws when the value is not a share plan. */
|
|
196
196
|
function parseSharePlan(value) {
|
|
197
197
|
if (!isRecord$2(value)) throw new Error("share plan: not a plan");
|
|
198
|
-
const { owner, repo, version, visibility, createsRepository, released, license, registry } = value;
|
|
198
|
+
const { owner, repo, version, visibility, createsRepository, released, license, registry, placement } = value;
|
|
199
199
|
if (typeof owner !== "string" || !GITHUB_NAME.test(owner) || typeof repo !== "string" || !GITHUB_NAME.test(repo)) throw new Error("share plan: repository");
|
|
200
200
|
if (typeof version !== "string" || version === "" || released !== void 0 && (typeof released !== "string" || released === "")) throw new Error("share plan: version");
|
|
201
201
|
if (visibility !== "private" && visibility !== "public" || typeof createsRepository !== "boolean") throw new Error("share plan: visibility");
|
|
202
202
|
if (license !== void 0 && (typeof license !== "string" || !/^[A-Za-z0-9.+-]+$/u.test(license))) throw new Error("share plan: license");
|
|
203
203
|
if (registry !== void 0 && typeof registry !== "boolean") throw new Error("share plan: registry");
|
|
204
204
|
if (registry === true && visibility !== "public") throw new Error("share plan: only a public share can be listed in the registry");
|
|
205
|
+
const place = placement === void 0 ? void 0 : isRecord$2(placement) && typeof placement.category === "string" && (placement.subcategory === void 0 || typeof placement.subcategory === "string") ? {
|
|
206
|
+
category: placement.category,
|
|
207
|
+
...typeof placement.subcategory === "string" ? { subcategory: placement.subcategory } : {}
|
|
208
|
+
} : null;
|
|
209
|
+
if (place === null) throw new Error("share plan: placement");
|
|
205
210
|
return {
|
|
206
211
|
owner,
|
|
207
212
|
repo,
|
|
@@ -210,12 +215,13 @@ function parseSharePlan(value) {
|
|
|
210
215
|
createsRepository,
|
|
211
216
|
...released === void 0 ? {} : { released },
|
|
212
217
|
...license === void 0 ? {} : { license },
|
|
213
|
-
...registry === true ? { registry } : {}
|
|
218
|
+
...registry === true ? { registry } : {},
|
|
219
|
+
...place === void 0 ? {} : { placement: place }
|
|
214
220
|
};
|
|
215
221
|
}
|
|
216
222
|
/** The same plan: what the person confirmed is what would be published now. */
|
|
217
223
|
function samePlan(a, b) {
|
|
218
|
-
return a.owner === b.owner && a.repo === b.repo && a.version === b.version && a.visibility === b.visibility && a.createsRepository === b.createsRepository && a.released === b.released && a.license === b.license && a.registry === true === (b.registry === true);
|
|
224
|
+
return a.owner === b.owner && a.repo === b.repo && a.version === b.version && a.visibility === b.visibility && a.createsRepository === b.createsRepository && a.released === b.released && a.license === b.license && a.registry === true === (b.registry === true) && a.placement?.category === b.placement?.category && a.placement?.subcategory === b.placement?.subcategory;
|
|
219
225
|
}
|
|
220
226
|
const FRAME_FEEDBACK_PATH = `${FRAME_API_PREFIX}/feedback`;
|
|
221
227
|
const FRAME_FEEDBACK_SEEN_PATH = `${FRAME_API_PREFIX}/feedback/seen`;
|
|
@@ -624,7 +630,7 @@ async function readFramePlugins(root, rows) {
|
|
|
624
630
|
}
|
|
625
631
|
/** The package.json a local plugin is shared with: the fields the builder's package_plugin writes (plugins/builder/index.ts), plus the Loader
|
|
626
632
|
* patch the plugin-hub's share requires so the package can also be installed as a row. */
|
|
627
|
-
function pluginPackageManifest(name, description, version = "0.1.0", license) {
|
|
633
|
+
function pluginPackageManifest(name, description, version = "0.1.0", license, placement) {
|
|
628
634
|
return {
|
|
629
635
|
name,
|
|
630
636
|
version,
|
|
@@ -642,11 +648,11 @@ function pluginPackageManifest(name, description, version = "0.1.0", license) {
|
|
|
642
648
|
"cordis.patch.yml"
|
|
643
649
|
],
|
|
644
650
|
peerDependencies: { "@deepseek-ai/cordis": "4.0.4" },
|
|
645
|
-
keywords: [
|
|
651
|
+
keywords: withPlacement([
|
|
646
652
|
"cordis",
|
|
647
653
|
"cordis-plugin",
|
|
648
654
|
"acrylblends"
|
|
649
|
-
],
|
|
655
|
+
], placement),
|
|
650
656
|
dsh: { bundle: { patch: "./cordis.patch.yml" } }
|
|
651
657
|
};
|
|
652
658
|
}
|
|
@@ -687,7 +693,7 @@ async function recordShare(file, name, shared) {
|
|
|
687
693
|
/** Where the frame packages the plugins it shares: under the app's home, never in the app's folder, so a share leaves no file to save. */
|
|
688
694
|
const pluginPackagesOf = (home) => join(home, "plugin-packages");
|
|
689
695
|
/** Copy one local plugin into its package folder under `packages`, the way the builder's package_plugin does; answers the folder. */
|
|
690
|
-
async function packageAppPlugin(root, name, packages, license) {
|
|
696
|
+
async function packageAppPlugin(root, name, packages, license, placement) {
|
|
691
697
|
if (!(await madePlugins(root)).includes(name)) throw new Error(`plugins/ has no local plugin "${name}"`);
|
|
692
698
|
const source = join(root, "plugins", name);
|
|
693
699
|
const target = join(packages, name);
|
|
@@ -706,7 +712,7 @@ async function packageAppPlugin(root, name, packages, license) {
|
|
|
706
712
|
filter: (path) => !/(^|[\\/])(node_modules|\.git)([\\/]|$)/u.test(path.slice(source.length))
|
|
707
713
|
});
|
|
708
714
|
const description = await packageDescription(source);
|
|
709
|
-
writeFileSync(join(target, "package.json"), `${JSON.stringify(pluginPackageManifest(name, description, version, license), null, 2)}\n`);
|
|
715
|
+
writeFileSync(join(target, "package.json"), `${JSON.stringify(pluginPackageManifest(name, description, version, license, placement), null, 2)}\n`);
|
|
710
716
|
writeFileSync(join(target, "cordis.patch.yml"), `- insert:\n - id: ${name}\n name: ./index.ts\n`);
|
|
711
717
|
if (!existsSync(join(target, "README.md"))) writeFileSync(join(target, "README.md"), `# ${name}\n\n${description}\n\nA Cordis plugin. In an ACRYLBLENDS app: \`acrylblends add <this folder>\`.\n`);
|
|
712
718
|
return target;
|
|
@@ -776,7 +782,8 @@ async function planAppPluginShare(root, home, name, options, ports) {
|
|
|
776
782
|
const registry = options.registry === true;
|
|
777
783
|
const visibility = registry ? "public" : options.visibility ?? "private";
|
|
778
784
|
const license = visibility === "public" ? options.license ?? "MIT" : void 0;
|
|
779
|
-
const
|
|
785
|
+
const placement = registry ? appPlacement(root) : void 0;
|
|
786
|
+
const dir = await packageAppPlugin(root, name, pluginPackagesOf(home), license, placement);
|
|
780
787
|
const manifest = JSON.parse(await readFile(join(dir, "package.json"), "utf8"));
|
|
781
788
|
const current = typeof manifest.version === "string" && parseVersion(manifest.version) !== void 0 ? manifest.version : void 0;
|
|
782
789
|
if (current === void 0) throw new Error(`${name}: its package has no semantic version`);
|
|
@@ -792,9 +799,17 @@ async function planAppPluginShare(root, home, name, options, ports) {
|
|
|
792
799
|
createsRepository: existing === void 0,
|
|
793
800
|
...released ? { released: current } : {},
|
|
794
801
|
...license === void 0 ? {} : { license },
|
|
795
|
-
...registry ? { registry } : {}
|
|
802
|
+
...registry ? { registry } : {},
|
|
803
|
+
...placement === void 0 ? {} : { placement }
|
|
796
804
|
};
|
|
797
805
|
}
|
|
806
|
+
function appPlacement(root) {
|
|
807
|
+
try {
|
|
808
|
+
return placementOf(JSON.parse(readFileSync(join(root, "package.json"), "utf8")).keywords);
|
|
809
|
+
} catch {
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
798
813
|
/**
|
|
799
814
|
* Share one local plugin through the plugin-hub path, exactly as the person confirmed it: the plan is read again, and when it no longer matches
|
|
800
815
|
* (another account signed in, the repository made meanwhile, a version released) nothing is sent and the error says to look again. The hub then
|