kardalum 0.15.0 → 0.16.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/dist/dev/sandbox.d.ts +11 -1
- package/dist/dev/sandbox.js +28 -5
- package/dist/plugin/build-reference.d.ts +9 -5
- package/dist/plugin/build-reference.js +15 -38
- package/dist/plugin/build.js +6 -0
- package/dist/plugin/checks/install-options.d.ts +3 -0
- package/dist/plugin/checks/install-options.js +41 -0
- package/dist/plugin/checks/locale-parity.d.ts +2 -0
- package/dist/plugin/checks/locale-parity.js +76 -0
- package/dist/plugin/checks/locales.d.ts +2 -0
- package/dist/plugin/checks/locales.js +66 -0
- package/dist/plugin/checks/package-contract.d.ts +2 -0
- package/dist/plugin/checks/package-contract.js +16 -2
- package/dist/plugin/checks/templates.d.ts +7 -6
- package/dist/plugin/checks/templates.js +38 -124
- package/dist/plugin/copy-locales.d.ts +13 -0
- package/dist/plugin/copy-locales.js +31 -0
- package/dist/plugin/copy-templates.d.ts +1 -1
- package/dist/plugin/copy-templates.js +9 -19
- package/dist/plugin/validate.js +11 -1
- package/dist/plugin/write-manifest-json.d.ts +2 -2
- package/dist/plugin/write-manifest-json.js +13 -7
- package/dist/vite.d.ts +24 -0
- package/dist/vite.js +46 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +43 -25
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +60 -8
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +12 -8
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +11 -7
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +107 -57
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +96 -60
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +39 -28
- package/node_modules/@kardalum/api-schemas/dist/index.js +19 -13
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +302 -1
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +78 -6
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +38 -30
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +2 -2
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +82 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +88 -5
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +79 -17
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +585 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +536 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +213 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +25 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +21 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +16 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +162 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +11 -1
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +4 -4
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +35 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +79 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +36 -6
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -5
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +8 -8
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +8 -8
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +2 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +11 -3
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +5 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +111 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +61 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +351 -0
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +3 -1
- package/node_modules/@kardalum/plugin-package/dist/index.js +2 -1
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +6 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +20 -1
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +56 -16
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +4 -6
- package/node_modules/@kardalum/plugin-package/dist/types.js +15 -1
- package/node_modules/@kardalum/plugin-package/package.json +5 -0
- package/package.json +8 -3
package/dist/dev/sandbox.d.ts
CHANGED
|
@@ -62,6 +62,15 @@ export interface StandaloneSandboxDeps {
|
|
|
62
62
|
pluginBuildPollIntervalMs?: number;
|
|
63
63
|
pluginBuildMaxMs?: number;
|
|
64
64
|
}
|
|
65
|
+
/** S293: the answers file a plugin project may keep at its root, which the
|
|
66
|
+
* sandbox's install takes (the register script's fourth argument). */
|
|
67
|
+
export declare const INSTALL_ANSWERS_FILE = "install-answers.json";
|
|
68
|
+
export declare function installAnswersPath(cwd: string): string | undefined;
|
|
69
|
+
/** The register script's arguments, `<pluginDir> <remoteUrl> [packagePath|-]
|
|
70
|
+
* [answersPath]`. "-" stands in for a missing package path when the answers
|
|
71
|
+
* path follows, because the checkout spawn runs through a shell, where an
|
|
72
|
+
* empty argument vanishes. */
|
|
73
|
+
export declare function registerArgs(cwd: string, remoteUrl: string, packagePath: string | undefined): string[];
|
|
65
74
|
export interface CheckoutRegistrationDeps {
|
|
66
75
|
spawnSyncImpl?: SpawnSyncImpl;
|
|
67
76
|
warnImpl?: (message: string) => void;
|
|
@@ -71,7 +80,8 @@ export interface CheckoutRegistrationDeps {
|
|
|
71
80
|
* (bundlePluginServerModule), then runs the server's register script from
|
|
72
81
|
* source through tsx, passing the bundle's path as the third argument when
|
|
73
82
|
* there is one, so the row gets a packagePath and the running server
|
|
74
|
-
* attaches the plugin at boot
|
|
83
|
+
* attaches the plugin at boot, and (S293) the project's install-answers.json
|
|
84
|
+
* fourth when it keeps one (registerArgs). A failed bundle only warns; a failed
|
|
75
85
|
* registration is fatal, as it always was. Exported so sandbox.test.ts can
|
|
76
86
|
* inject the sync spawn; startCheckoutSandbox is its only production
|
|
77
87
|
* caller. */
|
package/dist/dev/sandbox.js
CHANGED
|
@@ -37,6 +37,11 @@ function sandboxEnv(config, jwtSecret) {
|
|
|
37
37
|
// explicitly off. Plugin-dev flows use kardalum dev's own local
|
|
38
38
|
// marketplace tooling, not the in-CMS marketplace browse/detail proxy.
|
|
39
39
|
KARDALUM_MARKETPLACE_URL: "off",
|
|
40
|
+
// S299: the server serves its internal OpenAPI explorer (/api/docs) only
|
|
41
|
+
// when NODE_ENV is development or this switch is on, and the sandbox sets
|
|
42
|
+
// no NODE_ENV. A sandbox is a development server, and the explorer is how a
|
|
43
|
+
// plugin author sees their own routes documented, so it is turned on here.
|
|
44
|
+
KARDALUM_INTERNAL_DOCS: "true",
|
|
40
45
|
};
|
|
41
46
|
}
|
|
42
47
|
// S196 Task 8: when the detected plugin project is template-bearing
|
|
@@ -306,6 +311,8 @@ function standaloneEnv(config, jwtSecret) {
|
|
|
306
311
|
// Same offline/deterministic pin sandboxEnv() uses for checkout mode —
|
|
307
312
|
// see its own comment.
|
|
308
313
|
env.KARDALUM_MARKETPLACE_URL = "off";
|
|
314
|
+
// The internal explorer on, as sandboxEnv() turns it on: see its comment.
|
|
315
|
+
env.KARDALUM_INTERNAL_DOCS = "true";
|
|
309
316
|
delete env.KARDALUM_ADMIN_DIR;
|
|
310
317
|
delete env.DATABASE_URL;
|
|
311
318
|
delete env.KARDALUM_PRISMA_CLIENT_DIR;
|
|
@@ -566,12 +573,30 @@ function bundlePluginServerModule(cwd, stateDir, spawnSyncImpl, warnImpl) {
|
|
|
566
573
|
"(validate, isEmpty, serialize, deserialize) will NOT run.");
|
|
567
574
|
return undefined;
|
|
568
575
|
}
|
|
576
|
+
/** S293: the answers file a plugin project may keep at its root, which the
|
|
577
|
+
* sandbox's install takes (the register script's fourth argument). */
|
|
578
|
+
export const INSTALL_ANSWERS_FILE = "install-answers.json";
|
|
579
|
+
export function installAnswersPath(cwd) {
|
|
580
|
+
const path = join(cwd, INSTALL_ANSWERS_FILE);
|
|
581
|
+
return existsSync(path) ? path : undefined;
|
|
582
|
+
}
|
|
583
|
+
/** The register script's arguments, `<pluginDir> <remoteUrl> [packagePath|-]
|
|
584
|
+
* [answersPath]`. "-" stands in for a missing package path when the answers
|
|
585
|
+
* path follows, because the checkout spawn runs through a shell, where an
|
|
586
|
+
* empty argument vanishes. */
|
|
587
|
+
export function registerArgs(cwd, remoteUrl, packagePath) {
|
|
588
|
+
const answers = installAnswersPath(cwd);
|
|
589
|
+
if (answers === undefined)
|
|
590
|
+
return packagePath === undefined ? [cwd, remoteUrl] : [cwd, remoteUrl, packagePath];
|
|
591
|
+
return [cwd, remoteUrl, packagePath ?? "-", answers];
|
|
592
|
+
}
|
|
569
593
|
/** S284 (D7): checkout mode's registration step. It bundles the plugin's
|
|
570
594
|
* server module first, exactly as standalone mode does
|
|
571
595
|
* (bundlePluginServerModule), then runs the server's register script from
|
|
572
596
|
* source through tsx, passing the bundle's path as the third argument when
|
|
573
597
|
* there is one, so the row gets a packagePath and the running server
|
|
574
|
-
* attaches the plugin at boot
|
|
598
|
+
* attaches the plugin at boot, and (S293) the project's install-answers.json
|
|
599
|
+
* fourth when it keeps one (registerArgs). A failed bundle only warns; a failed
|
|
575
600
|
* registration is fatal, as it always was. Exported so sandbox.test.ts can
|
|
576
601
|
* inject the sync spawn; startCheckoutSandbox is its only production
|
|
577
602
|
* caller. */
|
|
@@ -586,9 +611,7 @@ export function registerCheckoutPlugin(config, env, remoteUrl, deps = {}) {
|
|
|
586
611
|
"exec",
|
|
587
612
|
"tsx",
|
|
588
613
|
"src/sandbox/register-local-plugin.ts",
|
|
589
|
-
config.cwd,
|
|
590
|
-
remoteUrl,
|
|
591
|
-
...(packagePath === undefined ? [] : [packagePath]),
|
|
614
|
+
...registerArgs(config.cwd, remoteUrl, packagePath),
|
|
592
615
|
], { shell: true, stdio: "inherit", cwd: config.repoRoot, env });
|
|
593
616
|
if (result.status !== 0) {
|
|
594
617
|
throw new SandboxError(`register local plugin failed (exit ${result.status}). See output above.`);
|
|
@@ -902,7 +925,7 @@ async function startStandaloneSandbox(config, deps = {}) {
|
|
|
902
925
|
registerEnv.KARDALUM_PUBLIC_DIR = publicDir;
|
|
903
926
|
}
|
|
904
927
|
console.log("[kardalum dev] register local plugin…");
|
|
905
|
-
const registerResult = registerImpl(registerScript,
|
|
928
|
+
const registerResult = registerImpl(registerScript, registerArgs(config.cwd, remoteUrl, pluginPackagePath), {
|
|
906
929
|
shell: false,
|
|
907
930
|
stdio: "inherit",
|
|
908
931
|
cwd: config.stateDir,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { PluginManifest } from "@kardalum/plugin-sdk/manifest";
|
|
2
|
+
/** The first five issues of a failed reference parse, each as `path: message`,
|
|
3
|
+
* shared by the write below and `validate`'s reference check. */
|
|
4
|
+
export declare function referenceIssues(issues: ReadonlyArray<{
|
|
5
|
+
path: ReadonlyArray<PropertyKey>;
|
|
6
|
+
message: string;
|
|
7
|
+
}>): string;
|
|
8
|
+
/** S289: the file is parsed before it is written, so a manifest that yields
|
|
9
|
+
* an invalid reference fails here, not at the marketplace door. */
|
|
6
10
|
export declare function writeReferenceJson(manifest: PluginManifest, outDir: string): void;
|
|
@@ -1,43 +1,20 @@
|
|
|
1
1
|
import { writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const contributions = manifest.contributions;
|
|
13
|
-
return {
|
|
14
|
-
actions: manifest.actions ?? [],
|
|
15
|
-
roles: manifest.roles ?? [],
|
|
16
|
-
apiRoutes: (contributions.apiRoutes ?? []).map((route) => ({
|
|
17
|
-
method: route.method,
|
|
18
|
-
path: route.path,
|
|
19
|
-
// Anything but the three named tiers falls back to "admin" at dispatch.
|
|
20
|
-
access: route.access ?? "admin",
|
|
21
|
-
...(route.action ? { action: route.action } : {}),
|
|
22
|
-
})),
|
|
23
|
-
capabilities: plain(deriveCapabilities(manifest)),
|
|
24
|
-
documentTypes: plain(contributions.documentTypes ?? []),
|
|
25
|
-
dataTypes: (contributions.dataTypes ?? []).map((type) => plain({
|
|
26
|
-
id: type.id,
|
|
27
|
-
name: type.name,
|
|
28
|
-
icon: type.icon,
|
|
29
|
-
version: type.version,
|
|
30
|
-
schema: type.schema,
|
|
31
|
-
settingsSchema: type.settingsSchema,
|
|
32
|
-
defaultSettings: type.defaultSettings,
|
|
33
|
-
})),
|
|
34
|
-
settingsPages: (contributions.settingsPages ?? []).map((page) => ({
|
|
35
|
-
id: page.id,
|
|
36
|
-
name: page.name,
|
|
37
|
-
action: page.action,
|
|
38
|
-
})),
|
|
39
|
-
};
|
|
3
|
+
import { PluginReferenceSchema } from "@kardalum/api-schemas";
|
|
4
|
+
import { buildReference } from "@kardalum/plugin-package/reference";
|
|
5
|
+
/** The first five issues of a failed reference parse, each as `path: message`,
|
|
6
|
+
* shared by the write below and `validate`'s reference check. */
|
|
7
|
+
export function referenceIssues(issues) {
|
|
8
|
+
return issues
|
|
9
|
+
.slice(0, 5)
|
|
10
|
+
.map((issue) => `${issue.path.map(String).join(".") || "(root)"}: ${issue.message}`)
|
|
11
|
+
.join("; ");
|
|
40
12
|
}
|
|
13
|
+
/** S289: the file is parsed before it is written, so a manifest that yields
|
|
14
|
+
* an invalid reference fails here, not at the marketplace door. */
|
|
41
15
|
export function writeReferenceJson(manifest, outDir) {
|
|
42
|
-
|
|
16
|
+
const parsed = PluginReferenceSchema.safeParse(buildReference(manifest));
|
|
17
|
+
if (!parsed.success)
|
|
18
|
+
throw new Error(`reference.json would not be valid: ${referenceIssues(parsed.error.issues)}`);
|
|
19
|
+
writeFileSync(join(outDir, "reference.json"), JSON.stringify(parsed.data, null, 2));
|
|
43
20
|
}
|
package/dist/plugin/build.js
CHANGED
|
@@ -3,6 +3,7 @@ import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
|
3
3
|
import { buildFederationBundleTo } from "./build-federation-bundle.js";
|
|
4
4
|
import { bundleServerManifest } from "./bundle-server-manifest.js";
|
|
5
5
|
import { copyPackageContractFiles } from "./copy-package-contract.js";
|
|
6
|
+
import { copyLocalesIfPresent } from "./copy-locales.js";
|
|
6
7
|
import { copySampleContentIfPresent } from "./copy-sample-content.js";
|
|
7
8
|
import { copyMediaIfPresent, copyPublicIfPresent, copyTemplatesIfPresent } from "./copy-templates.js";
|
|
8
9
|
import { loadManifest } from "./load-manifest.js";
|
|
@@ -288,5 +289,10 @@ export async function buildPlugin(pluginDir, outDir) {
|
|
|
288
289
|
// (only ever adds files, never at risk from/of clobbering the federation
|
|
289
290
|
// build's emptyOutDir step).
|
|
290
291
|
copyMediaIfPresent(pluginDir, resolvedOutDir);
|
|
292
|
+
// S290: copies <pluginDir>/locales/ into outDir when present: the plugin's
|
|
293
|
+
// own strings, which the admin fetches from beside remoteEntry.js. Same
|
|
294
|
+
// ordering safety as every step above (only adds files, after the
|
|
295
|
+
// federation build's emptyOutDir).
|
|
296
|
+
copyLocalesIfPresent(pluginDir, resolvedOutDir);
|
|
291
297
|
return { pluginDir, outDir: resolvedOutDir, validation };
|
|
292
298
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { installInterfaceFor, installOptionNeedsAnswer } from "@kardalum/api-schemas";
|
|
2
|
+
import { readShippedInstallFacts } from "@kardalum/plugin-package";
|
|
3
|
+
import { hasSampleContentConsumer } from "../copy-sample-content.js";
|
|
4
|
+
// S292 (2026-10-13-s292-what-the-wizard-may-ask-design.md, design 3.7): what an
|
|
5
|
+
// install of this plugin will ask, derived the way the install screen derives
|
|
6
|
+
// it (installInterfaceFor over the manifest and what the package ships). The
|
|
7
|
+
// declaration itself is the manifest schema's to refuse, so `manifest schema
|
|
8
|
+
// valid` names any issue in it. This check fails one case only: a
|
|
9
|
+
// sample-content.json nothing consumes, which `build` refuses and an install
|
|
10
|
+
// could never add. A required option is a legitimate design, so it is counted,
|
|
11
|
+
// never warned about.
|
|
12
|
+
function count(n, one, many) {
|
|
13
|
+
return `${n} ${n === 1 ? one : many}`;
|
|
14
|
+
}
|
|
15
|
+
export function checkInstallOptions(pluginDir, result) {
|
|
16
|
+
const name = "install options";
|
|
17
|
+
if (!result.ok)
|
|
18
|
+
return { name, passed: false, message: "cannot check: manifest schema invalid" };
|
|
19
|
+
const shipped = readShippedInstallFacts(pluginDir);
|
|
20
|
+
if (shipped.sampleContent && !hasSampleContentConsumer(result.manifest)) {
|
|
21
|
+
return {
|
|
22
|
+
name,
|
|
23
|
+
passed: false,
|
|
24
|
+
message: "sample-content.json ships, but nothing in the manifest consumes it: declare documentTypes or a bundledTemplate, or remove the file",
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const asks = installInterfaceFor(result.manifest, shipped);
|
|
28
|
+
const parts = [];
|
|
29
|
+
if (asks.sampleContent)
|
|
30
|
+
parts.push("add the sample content (yes by default)");
|
|
31
|
+
if (asks.roles.length > 0)
|
|
32
|
+
parts.push(`create ${count(asks.roles.length, "offered role", "offered roles")} (no by default)`);
|
|
33
|
+
if (asks.steps.length > 0) {
|
|
34
|
+
const options = asks.steps.flatMap((step) => step.options);
|
|
35
|
+
const needingAnswer = options.filter((option) => installOptionNeedsAnswer(option)).length;
|
|
36
|
+
parts.push(`${count(asks.steps.length, "step", "steps")} with ${count(options.length, "option", "options")}${needingAnswer > 0 ? `, ${needingAnswer} needing an answer` : ""}`);
|
|
37
|
+
}
|
|
38
|
+
if (parts.length === 0)
|
|
39
|
+
return { name, passed: true, message: "the install asks nothing: no steps declared, no sample content, no offered roles" };
|
|
40
|
+
return { name, passed: true, message: `the install asks: ${parts.join("; ")}` };
|
|
41
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { lstatSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { PLUGIN_LOCALE_MAX_BYTES, compareLocaleFiles, parsePluginLocaleFile, pluginLocaleFileLanguage, } from "@kardalum/api-schemas";
|
|
4
|
+
// S291: every locale file but en.json, held to en.json. A key English does
|
|
5
|
+
// not have fails (no screen asks for it; usually a typo), and so does a
|
|
6
|
+
// value whose {{placeholders}} differ from the English value's (the
|
|
7
|
+
// sentence renders with a hole or a stray brace). A key a language lacks
|
|
8
|
+
// only warns, with the count: the admin shows the plugin's English for it.
|
|
9
|
+
// The comparison is compareLocaleFiles from @kardalum/api-schemas, the one
|
|
10
|
+
// the marketplace's language line and the admin's own locale-parity test
|
|
11
|
+
// use. A file the `locales` check refuses is skipped here, so one problem is
|
|
12
|
+
// reported once.
|
|
13
|
+
/** How many keys a message names before it says "and N more". */
|
|
14
|
+
const LISTED_KEYS_MAX = 5;
|
|
15
|
+
function listKeys(keys) {
|
|
16
|
+
const shown = keys.slice(0, LISTED_KEYS_MAX).join(", ");
|
|
17
|
+
return keys.length > LISTED_KEYS_MAX ? `${shown} and ${keys.length - LISTED_KEYS_MAX} more` : shown;
|
|
18
|
+
}
|
|
19
|
+
/** A locale file read the way checkLocales accepts one (a regular file, not
|
|
20
|
+
* a link, within the size limit, passing the S290 rules), or null. */
|
|
21
|
+
function readBundle(dir, fileName) {
|
|
22
|
+
const path = join(dir, fileName);
|
|
23
|
+
try {
|
|
24
|
+
const stats = lstatSync(path);
|
|
25
|
+
if (!stats.isFile() || stats.size > PLUGIN_LOCALE_MAX_BYTES)
|
|
26
|
+
return null;
|
|
27
|
+
const parsed = parsePluginLocaleFile(readFileSync(path, "utf8"));
|
|
28
|
+
return parsed.ok ? parsed.bundle : null;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function checkLocaleParity(pluginDir) {
|
|
35
|
+
const name = "locale parity";
|
|
36
|
+
const dir = join(pluginDir, "locales");
|
|
37
|
+
let fileNames;
|
|
38
|
+
try {
|
|
39
|
+
if (!lstatSync(dir).isDirectory())
|
|
40
|
+
return { name, passed: true, message: "nothing to compare: locales is not a folder (see locales)" };
|
|
41
|
+
fileNames = readdirSync(dir).sort();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return { name, passed: true, message: "no locales/ folder: nothing to compare" };
|
|
45
|
+
}
|
|
46
|
+
const en = readBundle(dir, "en.json");
|
|
47
|
+
if (en === null)
|
|
48
|
+
return { name, passed: true, message: "nothing to compare: locales/en.json is missing or refused (see locales)" };
|
|
49
|
+
const total = Object.keys(en).length;
|
|
50
|
+
const failures = [];
|
|
51
|
+
const warnings = [];
|
|
52
|
+
const matching = [];
|
|
53
|
+
for (const fileName of fileNames) {
|
|
54
|
+
if (fileName === "en.json" || pluginLocaleFileLanguage(fileName) === null)
|
|
55
|
+
continue;
|
|
56
|
+
const bundle = readBundle(dir, fileName);
|
|
57
|
+
if (bundle === null)
|
|
58
|
+
continue;
|
|
59
|
+
const { extra, missing, mismatched } = compareLocaleFiles(en, bundle);
|
|
60
|
+
if (extra.length > 0)
|
|
61
|
+
failures.push(`${fileName}: ${extra.length} ${extra.length === 1 ? "key" : "keys"} en.json lacks: ${listKeys(extra)}`);
|
|
62
|
+
if (mismatched.length > 0)
|
|
63
|
+
failures.push(`${fileName}: placeholders differ from en.json in ${listKeys(mismatched)}`);
|
|
64
|
+
if (missing.length > 0)
|
|
65
|
+
warnings.push(`${fileName}: ${missing.length} of ${total} keys missing, those show English`);
|
|
66
|
+
if (extra.length === 0 && mismatched.length === 0 && missing.length === 0)
|
|
67
|
+
matching.push(fileName);
|
|
68
|
+
}
|
|
69
|
+
if (failures.length > 0)
|
|
70
|
+
return { name, passed: false, message: [...failures, ...warnings].join("; ") };
|
|
71
|
+
if (warnings.length > 0)
|
|
72
|
+
return { name, passed: false, severity: "warning", message: warnings.join("; ") };
|
|
73
|
+
if (matching.length === 0)
|
|
74
|
+
return { name, passed: true, message: "English only: nothing to compare" };
|
|
75
|
+
return { name, passed: true, message: `${matching.join(", ")}: every one of en.json's ${total} keys, placeholders matching` };
|
|
76
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { lstatSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { PLUGIN_LOCALE_MAX_BYTES, parsePluginLocaleFile, pluginLocaleFileLanguage } from "@kardalum/api-schemas";
|
|
4
|
+
// S290: a plugin's own strings ship as locales/<language>.json. The folder
|
|
5
|
+
// is optional (a plugin whose screens hold no words of their own needs
|
|
6
|
+
// none). When it exists, English is what every other language falls back
|
|
7
|
+
// to, so en.json is required, and every file must pass the rules the admin
|
|
8
|
+
// applies when it fetches one (parsePluginLocaleFile in
|
|
9
|
+
// @kardalum/api-schemas). Whether two languages carry the same keys is
|
|
10
|
+
// S291's parity check, not this one.
|
|
11
|
+
export function checkLocales(pluginDir) {
|
|
12
|
+
const name = "locales";
|
|
13
|
+
const dir = join(pluginDir, "locales");
|
|
14
|
+
// lstat, never stat: a symbolic link would pass as the folder or file it
|
|
15
|
+
// points at, the build would carry the link into the package, and the
|
|
16
|
+
// host's extraction refuses a link.
|
|
17
|
+
let folder;
|
|
18
|
+
try {
|
|
19
|
+
folder = lstatSync(dir);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return { name, passed: true, message: "no locales/ folder: the plugin's screens show the strings in its code" };
|
|
23
|
+
}
|
|
24
|
+
if (folder.isSymbolicLink())
|
|
25
|
+
return { name, passed: false, message: "locales is a symbolic link" };
|
|
26
|
+
if (!folder.isDirectory())
|
|
27
|
+
return { name, passed: false, message: "locales is not a folder" };
|
|
28
|
+
const problems = [];
|
|
29
|
+
const languages = [];
|
|
30
|
+
const entries = readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
31
|
+
for (const entry of entries) {
|
|
32
|
+
if (entry.isSymbolicLink()) {
|
|
33
|
+
problems.push(`locales/${entry.name} is a symbolic link`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (!entry.isFile()) {
|
|
37
|
+
problems.push(`locales/${entry.name} is not a file`);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const language = pluginLocaleFileLanguage(entry.name);
|
|
41
|
+
if (language === null) {
|
|
42
|
+
problems.push(`locales/${entry.name} is not named <language>.json (for example de.json)`);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const path = join(dir, entry.name);
|
|
46
|
+
const size = statSync(path).size;
|
|
47
|
+
if (size > PLUGIN_LOCALE_MAX_BYTES) {
|
|
48
|
+
problems.push(`locales/${entry.name}: ${size} bytes, over the ${PLUGIN_LOCALE_MAX_BYTES}-byte limit`);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const parsed = parsePluginLocaleFile(readFileSync(path, "utf8"));
|
|
52
|
+
if (!parsed.ok) {
|
|
53
|
+
problems.push(`locales/${entry.name}: ${parsed.issue}`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
languages.push(language);
|
|
57
|
+
}
|
|
58
|
+
// By name: an en.json that is a link or a folder is reported as that,
|
|
59
|
+
// not also as missing.
|
|
60
|
+
if (!entries.some((entry) => entry.name === "en.json")) {
|
|
61
|
+
problems.unshift("locales/en.json is missing: English is what every other language falls back to");
|
|
62
|
+
}
|
|
63
|
+
if (problems.length > 0)
|
|
64
|
+
return { name, passed: false, message: problems.join("; ") };
|
|
65
|
+
return { name, passed: true, message: `${languages.length} language${languages.length === 1 ? "" : "s"}: ${languages.join(", ")}` };
|
|
66
|
+
}
|
|
@@ -25,3 +25,5 @@ export declare function checkDocs(pluginDir: string, result: ValidatePluginManif
|
|
|
25
25
|
* shown to a reader as plain words, so the author is told, but the package
|
|
26
26
|
* still passes. */
|
|
27
27
|
export declare function checkDocsLinks(pluginDir: string, result: ValidatePluginManifestResult): CheckResult;
|
|
28
|
+
/** S289: the reference the build would write, parsed, with the pages it gives. */
|
|
29
|
+
export declare function checkReference(result: ValidatePluginManifestResult): CheckResult;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { docsFactsFrom, effectiveDocsPages, referencePageSlugs } from "@kardalum/api-schemas";
|
|
1
|
+
import { docsFactsFrom, effectiveDocsPages, PluginReferenceSchema, referencePageSlugs } from "@kardalum/api-schemas";
|
|
2
2
|
import { capViolations, checkCoverContract, checkDocsContract, checkReadmeContract, countRemoteImages, COVER_HEIGHT, COVER_PATH, COVER_WIDTH, pngSize, } from "@kardalum/plugin-package";
|
|
3
|
-
import { buildReference } from "
|
|
3
|
+
import { buildReference } from "@kardalum/plugin-package/reference";
|
|
4
|
+
import { referenceIssues } from "../build-reference.js";
|
|
4
5
|
// Task 2 (package format follow-up): a plugin's own package is now the
|
|
5
6
|
// source of truth for how it appears in the marketplace listing, so a
|
|
6
7
|
// README and a fixed-size cover image are required package contents —
|
|
@@ -90,3 +91,16 @@ export function checkDocsLinks(pluginDir, result) {
|
|
|
90
91
|
return { name, passed: true, message: "every docs link renders as a link" };
|
|
91
92
|
return { name, passed: false, severity: "warning", message: capViolations(warnings).join("; ") };
|
|
92
93
|
}
|
|
94
|
+
/** S289: the reference the build would write, parsed, with the pages it gives. */
|
|
95
|
+
export function checkReference(result) {
|
|
96
|
+
const name = "reference";
|
|
97
|
+
if (!result.ok)
|
|
98
|
+
return cannotCheck(name);
|
|
99
|
+
const parsed = PluginReferenceSchema.safeParse(buildReference(result.manifest));
|
|
100
|
+
if (!parsed.success)
|
|
101
|
+
return { name, passed: false, message: `the manifest yields an invalid reference.json: ${referenceIssues(parsed.error.issues)}` };
|
|
102
|
+
const slugs = referencePageSlugs(parsed.data);
|
|
103
|
+
if (slugs.length === 0)
|
|
104
|
+
return { name, passed: true, message: "no generated pages" };
|
|
105
|
+
return { name, passed: true, message: `${slugs.length} page${slugs.length === 1 ? "" : "s"}: ${slugs.join(", ")}` };
|
|
106
|
+
}
|
|
@@ -29,18 +29,19 @@ export declare function checkAssetsDeclaredExist(pluginDir: string, result: Vali
|
|
|
29
29
|
/**
|
|
30
30
|
* sample-content.json (<pluginDir>/sample-content.json, S149's package data
|
|
31
31
|
* file) is optional: absent is a passing no-op even for a plugin that
|
|
32
|
-
* declares document types, since not every template ships seed data. When
|
|
33
|
-
*
|
|
34
|
-
* entry in this manifest's own documentTypes
|
|
35
|
-
* cross-check seed-template-content.ts performs at
|
|
36
|
-
* so a designer catches it locally instead of at
|
|
32
|
+
* declares document types, since not every template ships seed data. When
|
|
33
|
+
* present, it must match SampleContentFileSchema AND every node's
|
|
34
|
+
* documentType must name an entry in this manifest's own documentTypes
|
|
35
|
+
* contribution (the same cross-check seed-template-content.ts performs at
|
|
36
|
+
* seed time, done here so a designer catches it locally instead of at
|
|
37
|
+
* install).
|
|
37
38
|
*
|
|
38
39
|
* S199 review Finding 2: every declared `media[].file` must also exist on
|
|
39
40
|
* disk (checked against pluginDir, since `file` is already "media/..."
|
|
40
41
|
* package-relative). Without this, a typo'd `media/post-helo.png` built
|
|
41
42
|
* cleanly and only silently no-op'd at install (copy-templates.ts's
|
|
42
43
|
* copyMediaIfPresent throws MissingMediaFileError for the same gap at
|
|
43
|
-
* build time
|
|
44
|
+
* build time; this is the validate-time mirror of that check).
|
|
44
45
|
*/
|
|
45
46
|
export declare function checkSampleContentValid(pluginDir: string, result: ValidatePluginManifestResult): CheckResult;
|
|
46
47
|
/**
|