@verentis/cli 0.2.12 → 0.2.14

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/README.md CHANGED
@@ -140,6 +140,7 @@ Applications that can open without a selected file opt in through their manifest
140
140
  ```yaml
141
141
  spec:
142
142
  entry: https://app.example.com
143
+ splash: /splash.svg
143
144
  launch:
144
145
  enabled: true
145
146
  entry-point: home
@@ -147,13 +148,16 @@ spec:
147
148
  entry-points:
148
149
  - id: home
149
150
  route: /workspace
151
+ splash: ./workspace-splash.svg
150
152
  ```
151
153
 
152
154
  `verentis init <name> --kind application` includes a commented launch template.
153
155
  `verentis validate` verifies that `launch` is an object, `pinnable` is used only
154
156
  with `enabled`, the selected entry-point id exists, and the launch resolves to
155
- an absolute HTTP(S) iframe URL. Omit `spec.launch` for contextual file handlers
156
- and headless apps.
157
+ an absolute HTTP(S) iframe URL. Splash values must be non-empty URL strings. An
158
+ entry-point splash overrides `spec.splash`; relative values resolve against the
159
+ selected iframe entry URL. Omit `spec.launch` for contextual file handlers and
160
+ headless apps.
157
161
 
158
162
  At runtime this is still an iframe launch: the SDK receives
159
163
  `context.surface === 'workspace'`, a resolved entry point, and no file context.
@@ -169,7 +173,9 @@ verentis publisher logo remove
169
173
  verentis keygen # Ed25519 signing key + register public half
170
174
  verentis init my-app --kind application
171
175
  verentis pack # signed .vpkg (--encrypt seals the payload)
172
- verentis publish my-app-0.1.0.vpkg
176
+ verentis pack . --env production # writes my-app-production-<version>.vpkg
177
+ verentis pack . --bump-version # increments metadata.version.patch in the manifest
178
+ verentis publish # publishes the highest-version .vpkg in the current directory
173
179
  verentis package list # your packages
174
180
  verentis package versions acme/my-app
175
181
  verentis package deprecate my-app --message "use my-app-2"
@@ -221,8 +227,10 @@ node after installation. See the platform docs (`marketplace/packaging`) for the
221
227
 
222
228
  Packing behaviour:
223
229
  - `packaging.files` globs select the payload; without them, applications automatically include every `./…` schema `source` referenced by the manifest.
224
- - `pack --env production` merges `environments/production.yaml`; `--overlay <path>` selects an
225
- explicit overlay, and `--version <version>` overrides the packed manifest version. `validate`
230
+ - `pack --env production` merges `environments/production.yaml` and includes `production` in the
231
+ output filename; `--overlay <path>` selects an explicit overlay, `--set-version <version>`
232
+ overrides the packed manifest version, and `--bump-version` increments the authored patch version.
233
+ `publish` without a file selects the highest-version `.vpkg` in the current directory. `validate`
226
234
  accepts the same overlay selectors.
227
235
  - Marketplace files are selected independently of `packaging.files` and written to deterministic,
228
236
  content-addressed `catalog/assets/**` and `catalog/docs/**` entries described by
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { tmpdir, homedir } from 'os';
5
5
  import { resolve, basename, dirname, posix, join, isAbsolute, extname, relative, sep } from 'path';
6
6
  import { spawn, spawnSync } from 'child_process';
7
7
  import { generateKeyPairSync, createHash, randomUUID, randomBytes, createCipheriv, createPublicKey, verify, diffieHellman, hkdfSync, sign, createPrivateKey } from 'crypto';
8
- import { parse, stringify } from 'yaml';
8
+ import { parse, stringify, parseDocument } from 'yaml';
9
9
  import { createWriteStream, readFileSync, createReadStream } from 'fs';
10
10
  import { Readable } from 'stream';
11
11
  import { pipeline } from 'stream/promises';
@@ -885,12 +885,54 @@ async function loadManifest(path) {
885
885
  const kind = normalizeKind(manifest.kind);
886
886
  const launchKindError = validateLaunchManifestKind(kind, manifest.spec);
887
887
  if (launchKindError) throw new Error(`Invalid manifest at ${path}: ${launchKindError}.`);
888
+ const splashErrors = validateApplicationSplashSection(kind, manifest.spec);
889
+ if (splashErrors.length > 0) {
890
+ throw new Error(`Invalid manifest at ${path}: ${splashErrors.join(" ")}`);
891
+ }
888
892
  const marketplaceErrors = validateMarketplaceSection(manifest.marketplace);
889
893
  if (marketplaceErrors.length > 0) {
890
894
  throw new Error(`Invalid marketplace section in ${path}: ${marketplaceErrors.join(" ")}`);
891
895
  }
892
896
  return manifest;
893
897
  }
898
+ function bumpPatchVersion(version) {
899
+ const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version.trim());
900
+ if (!match) {
901
+ throw new Error(`Cannot bump version '${version}' \u2014 expected a semantic version like 1.2.3.`);
902
+ }
903
+ return `${match[1]}.${match[2]}.${Number(match[3]) + 1}`;
904
+ }
905
+ async function bumpManifestPatchVersion(path, currentVersion) {
906
+ const text = await readFile(path, "utf8");
907
+ const nextVersion = bumpPatchVersion(currentVersion);
908
+ const document = parseDocument(text);
909
+ if (document.errors.length > 0) {
910
+ throw new Error(`Failed to parse manifest at ${path}: ${document.errors.map((error) => error.message).join(" ")}`);
911
+ }
912
+ document.setIn(["metadata", "version"], nextVersion);
913
+ await writeFile(path, document.toString());
914
+ return nextVersion;
915
+ }
916
+ function validateApplicationSplashSection(kind, spec) {
917
+ if (kind !== "Application" || !spec || typeof spec !== "object" || Array.isArray(spec)) return [];
918
+ const applicationSpec = spec;
919
+ const errors = [];
920
+ const splash = applicationSpec.splash;
921
+ if (splash !== void 0 && (typeof splash !== "string" || splash.trim().length === 0)) {
922
+ errors.push("spec.splash must be a non-empty URL string.");
923
+ }
924
+ const entryPoints = applicationSpec["entry-points"];
925
+ if (Array.isArray(entryPoints)) {
926
+ entryPoints.forEach((value, index) => {
927
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
928
+ const entryPointSplash = value.splash;
929
+ if (entryPointSplash !== void 0 && (typeof entryPointSplash !== "string" || entryPointSplash.trim().length === 0)) {
930
+ errors.push(`spec.entry-points[${index}].splash must be a non-empty URL string.`);
931
+ }
932
+ });
933
+ }
934
+ return errors;
935
+ }
894
936
  function validateMarketplaceSection(marketplace2) {
895
937
  if (marketplace2 === void 0) return [];
896
938
  if (!marketplace2 || typeof marketplace2 !== "object" || Array.isArray(marketplace2)) {
@@ -1005,6 +1047,7 @@ function validateManifest(manifest) {
1005
1047
  if (!meta[field]) error(`metadata.${field} is required`);
1006
1048
  }
1007
1049
  const spec = manifest.spec ?? {};
1050
+ validateManifestIcons(meta, spec, issues);
1008
1051
  const launchKindError = validateLaunchManifestKind(kind, spec);
1009
1052
  if (launchKindError) error(launchKindError);
1010
1053
  if (kind === "ExecutionEngine") {
@@ -1035,6 +1078,7 @@ function validateManifest(manifest) {
1035
1078
  "an Application must declare at least one contribution: spec.entry / spec.entry-points[] (iframe UI), spec.install[] (installed files), or spec.scopes[] (identity)"
1036
1079
  );
1037
1080
  }
1081
+ for (const message of validateApplicationSplashSection(kind, spec)) error(message);
1038
1082
  validateApplicationLaunch(spec, issues);
1039
1083
  }
1040
1084
  validateInstallDirectives(spec.install, issues);
@@ -1044,6 +1088,29 @@ function validateManifest(manifest) {
1044
1088
  if (!packaging.publisher) warning("packaging.publisher is not set \u2014 `verentis pack`/`publish` will refuse the package");
1045
1089
  return issues;
1046
1090
  }
1091
+ function validateManifestIcons(metadata, spec, issues) {
1092
+ validateOptionalIcon(metadata.icon, "metadata.icon", issues);
1093
+ validateBindingIcons(spec["mime-types"], "spec.mime-types", issues);
1094
+ validateBindingIcons(spec["file-types"], "spec.file-types", issues);
1095
+ if (!Array.isArray(spec["entry-points"])) return;
1096
+ spec["entry-points"].forEach((value, index) => {
1097
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
1098
+ validateOptionalIcon(value.icon, `spec.entry-points[${index}].icon`, issues);
1099
+ validateBindingIcons(value["mime-types"], `spec.entry-points[${index}].mime-types`, issues);
1100
+ });
1101
+ }
1102
+ function validateBindingIcons(bindings, path, issues) {
1103
+ if (!Array.isArray(bindings)) return;
1104
+ bindings.forEach((value, index) => {
1105
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
1106
+ validateOptionalIcon(value.icon, `${path}[${index}].icon`, issues);
1107
+ });
1108
+ }
1109
+ function validateOptionalIcon(value, path, issues) {
1110
+ if (value !== void 0 && !isNonEmptyString(value)) {
1111
+ issues.push({ level: "error", message: `${path} must be a non-empty string` });
1112
+ }
1113
+ }
1047
1114
  function validateApplicationLaunch(spec, issues) {
1048
1115
  const launch = spec.launch;
1049
1116
  if (launch === void 0) return;
@@ -2402,9 +2469,17 @@ async function pack(options) {
2402
2469
  const manifestPath = resolve(options.manifestPath);
2403
2470
  const projectDir = dirname(manifestPath);
2404
2471
  const base = await loadManifest(manifestPath);
2472
+ if (options.version !== void 0 && options.bumpVersion) {
2473
+ throw new Error("Use either --set-version or --bump-version, not both.");
2474
+ }
2405
2475
  const overlayPath = resolveOverlayPath(projectDir, { env: options.env, overlay: options.overlay });
2406
- let manifest = overlayPath ? applyOverlay(base, await loadOverlay(overlayPath)) : base;
2407
- let overrideApplied = overlayPath !== void 0;
2476
+ const overlay = overlayPath ? await loadOverlay(overlayPath) : void 0;
2477
+ if (options.bumpVersion) {
2478
+ const nextVersion = await bumpManifestPatchVersion(manifestPath, base.metadata.version);
2479
+ base.metadata.version = nextVersion;
2480
+ }
2481
+ let manifest = overlay ? applyOverlay(base, overlay) : base;
2482
+ let overrideApplied = overlayPath !== void 0 || options.bumpVersion === true;
2408
2483
  if (options.version !== void 0) {
2409
2484
  manifest = { ...manifest, metadata: { ...manifest.metadata, version: options.version } };
2410
2485
  overrideApplied = true;
@@ -2478,7 +2553,8 @@ async function pack(options) {
2478
2553
  }
2479
2554
  const outDir = resolve(options.outDir ?? projectDir);
2480
2555
  await mkdir(outDir, { recursive: true });
2481
- const outFile = join(outDir, `${name}-${version}.vpkg`);
2556
+ const environmentSuffix = options.env ? `-${options.env}` : "";
2557
+ const outFile = join(outDir, `${name}${environmentSuffix}-${version}.vpkg`);
2482
2558
  const entries = [
2483
2559
  "manifest.yaml",
2484
2560
  ".verentis/package.yaml",
@@ -2651,7 +2727,7 @@ async function readJsonIfExists(path) {
2651
2727
 
2652
2728
  // src/commands/pack.ts
2653
2729
  function registerPack(program2) {
2654
- program2.command("pack [dir]").description("Build a signed .vpkg from a project directory").option("--manifest <path>", "manifest path (default: auto-detected in the project directory)").option("--publisher <name>", "publisher name (default: packaging.publisher in the manifest)").option("--name <name>", "override the package name").option("--env <name>", "merge a per-environment overlay (environments/<name>.yaml) before packing").option("--overlay <path>", "merge an explicit overlay file before packing (wins over --env)").option("--set-version <version>", "override metadata.version (e.g. a CI-derived build number)").option("--out <dir>", "output directory (default: the project directory)").option("--key <name>", "signing key name (default: the configured default key)").option("--no-sign", "produce an unsigned package").option("--encrypt", "seal the payload (AES-256-GCM); requires at least one recipient").option("--recipient <id=base64key...>", "additional X25519 recipient (repeatable)", collectRecipients, []).action(async (dir, options) => {
2730
+ program2.command("pack [dir]").description("Build a signed .vpkg from a project directory").option("--manifest <path>", "manifest path (default: auto-detected in the project directory)").option("--publisher <name>", "publisher name (default: packaging.publisher in the manifest)").option("--name <name>", "override the package name").option("--env <name>", "merge a per-environment overlay (environments/<name>.yaml) before packing").option("--overlay <path>", "merge an explicit overlay file before packing (wins over --env)").option("--set-version <version>", "override metadata.version (e.g. a CI-derived build number)").option("--bump-version", "increment metadata.version.patch and update the manifest").option("--bump", "alias for --bump-version").option("--out <dir>", "output directory (default: the project directory)").option("--key <name>", "signing key name (default: the configured default key)").option("--no-sign", "produce an unsigned package").option("--encrypt", "seal the payload (AES-256-GCM); requires at least one recipient").option("--recipient <id=base64key...>", "additional X25519 recipient (repeatable)", collectRecipients, []).action(async (dir, options) => {
2655
2731
  const projectDir = resolve(dir ?? ".");
2656
2732
  const manifestPath = options.manifest ? resolve(options.manifest) : await findManifest(projectDir);
2657
2733
  const manifest = await loadManifest(manifestPath);
@@ -2689,6 +2765,7 @@ function registerPack(program2) {
2689
2765
  env: options.env,
2690
2766
  overlay: options.overlay,
2691
2767
  version: options.setVersion,
2768
+ bumpVersion: options.bumpVersion || options.bump,
2692
2769
  outDir: options.out,
2693
2770
  signingKey,
2694
2771
  encryptFor
@@ -2963,9 +3040,71 @@ async function uploadPublisherLogo(api, publisherId, path) {
2963
3040
  contentType: logo.contentType
2964
3041
  });
2965
3042
  }
3043
+
3044
+ // src/update/semver.ts
3045
+ function isNewerVersion(candidate, base) {
3046
+ return compareVersions(candidate, base) > 0;
3047
+ }
3048
+ function compareVersions(a, b) {
3049
+ const pa = parse5(a);
3050
+ const pb = parse5(b);
3051
+ for (let i = 0; i < 3; i++) {
3052
+ if (pa.main[i] !== pb.main[i]) return pa.main[i] < pb.main[i] ? -1 : 1;
3053
+ }
3054
+ if (pa.pre.length === 0 && pb.pre.length === 0) return 0;
3055
+ if (pa.pre.length === 0) return 1;
3056
+ if (pb.pre.length === 0) return -1;
3057
+ const len = Math.max(pa.pre.length, pb.pre.length);
3058
+ for (let i = 0; i < len; i++) {
3059
+ if (i >= pa.pre.length) return -1;
3060
+ if (i >= pb.pre.length) return 1;
3061
+ const x = pa.pre[i];
3062
+ const y = pb.pre[i];
3063
+ const xNum = /^\d+$/.test(x);
3064
+ const yNum = /^\d+$/.test(y);
3065
+ if (xNum && yNum) {
3066
+ const nx = Number(x);
3067
+ const ny = Number(y);
3068
+ if (nx !== ny) return nx < ny ? -1 : 1;
3069
+ } else if (xNum !== yNum) {
3070
+ return xNum ? -1 : 1;
3071
+ } else if (x !== y) {
3072
+ return x < y ? -1 : 1;
3073
+ }
3074
+ }
3075
+ return 0;
3076
+ }
3077
+ function parse5(version) {
3078
+ const cleaned = version.trim().replace(/^v/i, "").split("+", 1)[0];
3079
+ const dash = cleaned.indexOf("-");
3080
+ const core = dash === -1 ? cleaned : cleaned.slice(0, dash);
3081
+ const pre = dash === -1 ? "" : cleaned.slice(dash + 1);
3082
+ const parts = core.split(".").map((n) => Number.parseInt(n, 10) || 0);
3083
+ return { main: [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0], pre: pre ? pre.split(".") : [] };
3084
+ }
3085
+
3086
+ // src/commands/registry.ts
3087
+ async function findLatestLocalVpkg(directory) {
3088
+ const entries = await readdir(directory, { withFileTypes: true });
3089
+ const candidates = entries.filter((entry) => entry.isFile() && entry.name.endsWith(".vpkg")).map((entry) => resolve(directory, entry.name));
3090
+ if (candidates.length === 0) {
3091
+ throw new Error(`No .vpkg files found in ${directory}. Pack a package first.`);
3092
+ }
3093
+ let latest;
3094
+ for (const path of candidates) {
3095
+ const contents = await readVpkg(path);
3096
+ const comparison = latest ? compareVersions(contents.metadata.version, latest.version) : 1;
3097
+ if (!latest || comparison > 0 || comparison === 0 && path > latest.path) {
3098
+ latest = { path, version: contents.metadata.version };
3099
+ }
3100
+ }
3101
+ if (!latest) throw new Error(`No readable .vpkg files found in ${directory}.`);
3102
+ return latest.path;
3103
+ }
2966
3104
  function registerRegistry(program2) {
2967
- program2.command("publish <vpkg>").description("Upload a packed .vpkg to the marketplace registry (creates the package on first publish)").option("--visibility <visibility>", "catalog visibility for a newly created package: Public | Private", "Private").action(async (vpkgPath, options) => {
2968
- const contents = await readVpkg(resolve(vpkgPath));
3105
+ program2.command("publish [vpkg]").description("Upload a packed .vpkg to the marketplace registry (creates the package on first publish)").option("--visibility <visibility>", "catalog visibility for a newly created package: Public | Private", "Private").action(async (vpkgPath, options) => {
3106
+ const selectedPath = vpkgPath ? resolve(vpkgPath) : await findLatestLocalVpkg(process.cwd());
3107
+ const contents = await readVpkg(selectedPath);
2969
3108
  if (contents.digestErrors.length > 0) {
2970
3109
  throw new Error(`Refusing to publish: package failed digest verification:
2971
3110
  ${contents.digestErrors.join("\n ")}`);
@@ -2988,7 +3127,7 @@ function registerRegistry(program2) {
2988
3127
  console.log(`Created package ${publisher.name}/${contents.metadata.name} (${visibility.toLowerCase()}).`);
2989
3128
  pkg = { id };
2990
3129
  }
2991
- const version = await uploadVersion(api, pkg.id, resolve(vpkgPath));
3130
+ const version = await uploadVersion(api, pkg.id, selectedPath);
2992
3131
  console.log(`Published ${publisher.name}/${contents.metadata.name}@${version.version} \u2192 ${version.status}`);
2993
3132
  if (version.status === "Submitted") {
2994
3133
  console.log("The version is queued for moderation; it becomes installable once approved and published.");
@@ -3156,48 +3295,6 @@ async function fetchLatestVersion(options = {}) {
3156
3295
  clearTimeout(timer);
3157
3296
  }
3158
3297
  }
3159
-
3160
- // src/update/semver.ts
3161
- function isNewerVersion(candidate, base) {
3162
- return compareVersions(candidate, base) > 0;
3163
- }
3164
- function compareVersions(a, b) {
3165
- const pa = parse5(a);
3166
- const pb = parse5(b);
3167
- for (let i = 0; i < 3; i++) {
3168
- if (pa.main[i] !== pb.main[i]) return pa.main[i] < pb.main[i] ? -1 : 1;
3169
- }
3170
- if (pa.pre.length === 0 && pb.pre.length === 0) return 0;
3171
- if (pa.pre.length === 0) return 1;
3172
- if (pb.pre.length === 0) return -1;
3173
- const len = Math.max(pa.pre.length, pb.pre.length);
3174
- for (let i = 0; i < len; i++) {
3175
- if (i >= pa.pre.length) return -1;
3176
- if (i >= pb.pre.length) return 1;
3177
- const x = pa.pre[i];
3178
- const y = pb.pre[i];
3179
- const xNum = /^\d+$/.test(x);
3180
- const yNum = /^\d+$/.test(y);
3181
- if (xNum && yNum) {
3182
- const nx = Number(x);
3183
- const ny = Number(y);
3184
- if (nx !== ny) return nx < ny ? -1 : 1;
3185
- } else if (xNum !== yNum) {
3186
- return xNum ? -1 : 1;
3187
- } else if (x !== y) {
3188
- return x < y ? -1 : 1;
3189
- }
3190
- }
3191
- return 0;
3192
- }
3193
- function parse5(version) {
3194
- const cleaned = version.trim().replace(/^v/i, "").split("+", 1)[0];
3195
- const dash = cleaned.indexOf("-");
3196
- const core = dash === -1 ? cleaned : cleaned.slice(0, dash);
3197
- const pre = dash === -1 ? "" : cleaned.slice(dash + 1);
3198
- const parts = core.split(".").map((n) => Number.parseInt(n, 10) || 0);
3199
- return { main: [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0], pre: pre ? pre.split(".") : [] };
3200
- }
3201
3298
  var DEFAULT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
3202
3299
  var statePath = () => join(configDir(), "update-check.json");
3203
3300
  async function readUpdateState() {