@verentis/cli 0.2.13 → 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
@@ -173,7 +173,9 @@ verentis publisher logo remove
173
173
  verentis keygen # Ed25519 signing key + register public half
174
174
  verentis init my-app --kind application
175
175
  verentis pack # signed .vpkg (--encrypt seals the payload)
176
- 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
177
179
  verentis package list # your packages
178
180
  verentis package versions acme/my-app
179
181
  verentis package deprecate my-app --message "use my-app-2"
@@ -225,8 +227,10 @@ node after installation. See the platform docs (`marketplace/packaging`) for the
225
227
 
226
228
  Packing behaviour:
227
229
  - `packaging.files` globs select the payload; without them, applications automatically include every `./…` schema `source` referenced by the manifest.
228
- - `pack --env production` merges `environments/production.yaml`; `--overlay <path>` selects an
229
- 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`
230
234
  accepts the same overlay selectors.
231
235
  - Marketplace files are selected independently of `packaging.files` and written to deterministic,
232
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';
@@ -895,6 +895,24 @@ async function loadManifest(path) {
895
895
  }
896
896
  return manifest;
897
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
+ }
898
916
  function validateApplicationSplashSection(kind, spec) {
899
917
  if (kind !== "Application" || !spec || typeof spec !== "object" || Array.isArray(spec)) return [];
900
918
  const applicationSpec = spec;
@@ -1029,6 +1047,7 @@ function validateManifest(manifest) {
1029
1047
  if (!meta[field]) error(`metadata.${field} is required`);
1030
1048
  }
1031
1049
  const spec = manifest.spec ?? {};
1050
+ validateManifestIcons(meta, spec, issues);
1032
1051
  const launchKindError = validateLaunchManifestKind(kind, spec);
1033
1052
  if (launchKindError) error(launchKindError);
1034
1053
  if (kind === "ExecutionEngine") {
@@ -1069,6 +1088,29 @@ function validateManifest(manifest) {
1069
1088
  if (!packaging.publisher) warning("packaging.publisher is not set \u2014 `verentis pack`/`publish` will refuse the package");
1070
1089
  return issues;
1071
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
+ }
1072
1114
  function validateApplicationLaunch(spec, issues) {
1073
1115
  const launch = spec.launch;
1074
1116
  if (launch === void 0) return;
@@ -2427,9 +2469,17 @@ async function pack(options) {
2427
2469
  const manifestPath = resolve(options.manifestPath);
2428
2470
  const projectDir = dirname(manifestPath);
2429
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
+ }
2430
2475
  const overlayPath = resolveOverlayPath(projectDir, { env: options.env, overlay: options.overlay });
2431
- let manifest = overlayPath ? applyOverlay(base, await loadOverlay(overlayPath)) : base;
2432
- 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;
2433
2483
  if (options.version !== void 0) {
2434
2484
  manifest = { ...manifest, metadata: { ...manifest.metadata, version: options.version } };
2435
2485
  overrideApplied = true;
@@ -2503,7 +2553,8 @@ async function pack(options) {
2503
2553
  }
2504
2554
  const outDir = resolve(options.outDir ?? projectDir);
2505
2555
  await mkdir(outDir, { recursive: true });
2506
- const outFile = join(outDir, `${name}-${version}.vpkg`);
2556
+ const environmentSuffix = options.env ? `-${options.env}` : "";
2557
+ const outFile = join(outDir, `${name}${environmentSuffix}-${version}.vpkg`);
2507
2558
  const entries = [
2508
2559
  "manifest.yaml",
2509
2560
  ".verentis/package.yaml",
@@ -2676,7 +2727,7 @@ async function readJsonIfExists(path) {
2676
2727
 
2677
2728
  // src/commands/pack.ts
2678
2729
  function registerPack(program2) {
2679
- 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) => {
2680
2731
  const projectDir = resolve(dir ?? ".");
2681
2732
  const manifestPath = options.manifest ? resolve(options.manifest) : await findManifest(projectDir);
2682
2733
  const manifest = await loadManifest(manifestPath);
@@ -2714,6 +2765,7 @@ function registerPack(program2) {
2714
2765
  env: options.env,
2715
2766
  overlay: options.overlay,
2716
2767
  version: options.setVersion,
2768
+ bumpVersion: options.bumpVersion || options.bump,
2717
2769
  outDir: options.out,
2718
2770
  signingKey,
2719
2771
  encryptFor
@@ -2988,9 +3040,71 @@ async function uploadPublisherLogo(api, publisherId, path) {
2988
3040
  contentType: logo.contentType
2989
3041
  });
2990
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
+ }
2991
3104
  function registerRegistry(program2) {
2992
- 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) => {
2993
- 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);
2994
3108
  if (contents.digestErrors.length > 0) {
2995
3109
  throw new Error(`Refusing to publish: package failed digest verification:
2996
3110
  ${contents.digestErrors.join("\n ")}`);
@@ -3013,7 +3127,7 @@ function registerRegistry(program2) {
3013
3127
  console.log(`Created package ${publisher.name}/${contents.metadata.name} (${visibility.toLowerCase()}).`);
3014
3128
  pkg = { id };
3015
3129
  }
3016
- const version = await uploadVersion(api, pkg.id, resolve(vpkgPath));
3130
+ const version = await uploadVersion(api, pkg.id, selectedPath);
3017
3131
  console.log(`Published ${publisher.name}/${contents.metadata.name}@${version.version} \u2192 ${version.status}`);
3018
3132
  if (version.status === "Submitted") {
3019
3133
  console.log("The version is queued for moderation; it becomes installable once approved and published.");
@@ -3181,48 +3295,6 @@ async function fetchLatestVersion(options = {}) {
3181
3295
  clearTimeout(timer);
3182
3296
  }
3183
3297
  }
3184
-
3185
- // src/update/semver.ts
3186
- function isNewerVersion(candidate, base) {
3187
- return compareVersions(candidate, base) > 0;
3188
- }
3189
- function compareVersions(a, b) {
3190
- const pa = parse5(a);
3191
- const pb = parse5(b);
3192
- for (let i = 0; i < 3; i++) {
3193
- if (pa.main[i] !== pb.main[i]) return pa.main[i] < pb.main[i] ? -1 : 1;
3194
- }
3195
- if (pa.pre.length === 0 && pb.pre.length === 0) return 0;
3196
- if (pa.pre.length === 0) return 1;
3197
- if (pb.pre.length === 0) return -1;
3198
- const len = Math.max(pa.pre.length, pb.pre.length);
3199
- for (let i = 0; i < len; i++) {
3200
- if (i >= pa.pre.length) return -1;
3201
- if (i >= pb.pre.length) return 1;
3202
- const x = pa.pre[i];
3203
- const y = pb.pre[i];
3204
- const xNum = /^\d+$/.test(x);
3205
- const yNum = /^\d+$/.test(y);
3206
- if (xNum && yNum) {
3207
- const nx = Number(x);
3208
- const ny = Number(y);
3209
- if (nx !== ny) return nx < ny ? -1 : 1;
3210
- } else if (xNum !== yNum) {
3211
- return xNum ? -1 : 1;
3212
- } else if (x !== y) {
3213
- return x < y ? -1 : 1;
3214
- }
3215
- }
3216
- return 0;
3217
- }
3218
- function parse5(version) {
3219
- const cleaned = version.trim().replace(/^v/i, "").split("+", 1)[0];
3220
- const dash = cleaned.indexOf("-");
3221
- const core = dash === -1 ? cleaned : cleaned.slice(0, dash);
3222
- const pre = dash === -1 ? "" : cleaned.slice(dash + 1);
3223
- const parts = core.split(".").map((n) => Number.parseInt(n, 10) || 0);
3224
- return { main: [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0], pre: pre ? pre.split(".") : [] };
3225
- }
3226
3298
  var DEFAULT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
3227
3299
  var statePath = () => join(configDir(), "update-check.json");
3228
3300
  async function readUpdateState() {