@surnie/plugin-kit 0.2.5 → 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/dist/cli.js +34 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -617,6 +617,16 @@ function parseManifest(input, { contracts = [PLUGIN_CONTRACT] } = {}) {
|
|
|
617
617
|
}
|
|
618
618
|
function manifestTexts(m) {
|
|
619
619
|
const out = [];
|
|
620
|
+
const str2 = (v) => typeof v === "string" ? [v] : [];
|
|
621
|
+
for (const item of [...m.model?.collections ?? [], ...m.model?.singleTypes ?? [], ...m.model?.components ?? []]) {
|
|
622
|
+
const t = item;
|
|
623
|
+
out.push(...str2(t.labelSingular), ...str2(t.labelPlural), ...str2(t.label));
|
|
624
|
+
for (const f of Object.values(item.fields ?? {})) {
|
|
625
|
+
const field3 = f;
|
|
626
|
+
out.push(...str2(field3.label), ...str2(field3.description), ...str2(field3.placeholder));
|
|
627
|
+
for (const o of Array.isArray(field3.options) ? field3.options : []) out.push(...str2(o?.label));
|
|
628
|
+
}
|
|
629
|
+
}
|
|
620
630
|
for (const p of [...m.permissions.required, ...m.permissions.optional]) out.push(p.purpose);
|
|
621
631
|
for (const st of m.settings) {
|
|
622
632
|
out.push(st.label);
|
|
@@ -879,6 +889,7 @@ var num = { type: "number" };
|
|
|
879
889
|
var bool = { type: "boolean" };
|
|
880
890
|
var json = (max, ts) => ({ type: "json", max, ts });
|
|
881
891
|
var field2 = { name: s(80), label: s(120), required: bool, error: s(300), disabled: bool, hint: s(300) };
|
|
892
|
+
var UI_MAX_FILE_BYTES = 5 * 1024 * 1024;
|
|
882
893
|
var UI_COMPONENTS = [
|
|
883
894
|
// Colocar
|
|
884
895
|
{ tag: "surnie-stack", properties: { gap: oneOf("s", "m", "l") }, events: [], children: true },
|
|
@@ -946,6 +957,15 @@ var UI_COMPONENTS = [
|
|
|
946
957
|
details: { change: "{ checked: boolean }" },
|
|
947
958
|
children: false
|
|
948
959
|
},
|
|
960
|
+
// Un fichero de texto (CSV, TSV, JSON o TXT, hasta 5 MB) que elige quien mira: `change` lleva su
|
|
961
|
+
// nombre, su tamaño y su texto (UTF-8). accept: ".csv", ".csv,.tsv"… (solo esos tipos)
|
|
962
|
+
{
|
|
963
|
+
tag: "surnie-filefield",
|
|
964
|
+
properties: { ...field2, accept: s(60) },
|
|
965
|
+
events: ["change"],
|
|
966
|
+
details: { change: "{ name: string; size: number; text: string }" },
|
|
967
|
+
children: false
|
|
968
|
+
},
|
|
949
969
|
// value: "AAAA-MM-DD"
|
|
950
970
|
{ tag: "surnie-datefield", properties: { ...field2, value: s(10) }, events: ["change"], details: { change: "{ value: string }" }, children: false },
|
|
951
971
|
{
|
|
@@ -1107,6 +1127,11 @@ type SurnieUiContext = {
|
|
|
1107
1127
|
navigate(to: SurnieLink): void;
|
|
1108
1128
|
/** Deja el estado de la pantalla en la direcci\xF3n (p\xE1gina, pesta\xF1a\u2026), para enlazarla y recargarla; null lo quita. */
|
|
1109
1129
|
setParams(params: Record<string, string | number | null>): void;
|
|
1130
|
+
/**
|
|
1131
|
+
* Da a quien mira un fichero para guardar: texto (CSV, TSV, JSON o TXT por la extensi\xF3n de
|
|
1132
|
+
* \`filename\`), hasta 5 MB. Se descarga, nunca se abre.
|
|
1133
|
+
*/
|
|
1134
|
+
download(filename: string, content: string): Promise<void>;
|
|
1110
1135
|
};
|
|
1111
1136
|
|
|
1112
1137
|
/** Una pantalla o un widget: dibuja en \`root\` con los componentes de Surnie (surnie-*). */
|
|
@@ -1790,7 +1815,7 @@ function yarnrc(dir, pm) {
|
|
|
1790
1815
|
}
|
|
1791
1816
|
function installEnv() {
|
|
1792
1817
|
const env = {};
|
|
1793
|
-
for (const [k, v] of Object.entries(process.env)) if (!/^npm_|^NPM_CONFIG_|^YARN_|^BUN_CONFIG_
|
|
1818
|
+
for (const [k, v] of Object.entries(process.env)) if (!/^npm_|^NPM_CONFIG_|^YARN_|^BUN_CONFIG_|^NODE_ENV$/i.test(k)) env[k] = v;
|
|
1794
1819
|
return {
|
|
1795
1820
|
...env,
|
|
1796
1821
|
CI: "1",
|
|
@@ -2392,7 +2417,7 @@ async function publish(dir, opts) {
|
|
|
2392
2417
|
opts.log?.(`Enviando ${namespace} ${version} (${build.pkg.length} B y la fuente, ${build.source.length} B)\u2026`);
|
|
2393
2418
|
const response = await call(opts, "PUT", `/v1/plugins/${namespace}/versions/${version}`, {
|
|
2394
2419
|
body: form,
|
|
2395
|
-
headers: { "Surnie-Kit-Version": build.kit }
|
|
2420
|
+
headers: { "Surnie-Kit-Version": build.kit, ...opts.security ? { "Surnie-Security": "1" } : {} }
|
|
2396
2421
|
});
|
|
2397
2422
|
return follow(dir, build, opts, await response.json());
|
|
2398
2423
|
}
|
|
@@ -2484,7 +2509,11 @@ function inspectPackage(gz, approvalRaw) {
|
|
|
2484
2509
|
}
|
|
2485
2510
|
|
|
2486
2511
|
// src/cli.ts
|
|
2487
|
-
var USAGE = `Uso: surnie-plugin keygen | dev | types | pack | sign | inspect <paquete.tgz> | publish | status
|
|
2512
|
+
var USAGE = `Uso: surnie-plugin keygen | dev | types | pack | sign | inspect <paquete.tgz> | publish [--security] | status
|
|
2513
|
+
|
|
2514
|
+
publish --security
|
|
2515
|
+
la versi\xF3n arregla un fallo de seguridad: la revisa siempre una persona y, aprobada, llega sin
|
|
2516
|
+
espera a las instalaciones que actualizan el plugin solo en "solo seguridad"
|
|
2488
2517
|
|
|
2489
2518
|
dev [--port <n>] [--image <imagen>] [--reset] [--no-docker]
|
|
2490
2519
|
--port puerto del panel en esta m\xE1quina (${DEV_PORT})
|
|
@@ -2524,7 +2553,7 @@ function report(r) {
|
|
|
2524
2553
|
if (r.outcome === "approved") {
|
|
2525
2554
|
console.log(`
|
|
2526
2555
|
\u2714 ${namespace} ${version} publicado. Su aprobaci\xF3n: ${r.approvalFile}`);
|
|
2527
|
-
console.log(" Para instalarlo a mano, sube el paquete y ese fichero en
|
|
2556
|
+
console.log(" Para instalarlo a mano, sube el paquete y ese fichero en Plugins \u2192 Instalar desde un paquete.\n");
|
|
2528
2557
|
return 0;
|
|
2529
2558
|
}
|
|
2530
2559
|
if (r.outcome === "review") {
|
|
@@ -2590,7 +2619,7 @@ async function main(argv) {
|
|
|
2590
2619
|
const token = await publishToken();
|
|
2591
2620
|
const opts = { token, platformUrl: url };
|
|
2592
2621
|
if (cmd === "status") return report(await status(process.cwd(), opts));
|
|
2593
|
-
return report(await publish(process.cwd(), { ...opts, log: (line) => console.log(line) }));
|
|
2622
|
+
return report(await publish(process.cwd(), { ...opts, security: argv.includes("--security"), log: (line) => console.log(line) }));
|
|
2594
2623
|
}
|
|
2595
2624
|
if (cmd === "inspect" && arg) {
|
|
2596
2625
|
const approvalPath = arg.replace(/\.tgz$/, ".approval.json");
|