@pmate/cli 0.38.5 → 0.39.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/README.md CHANGED
@@ -270,7 +270,7 @@ Meili's Host may pass `--actor-profile-id` with `PMATE_LOG_DELEGATE_TOKEN` in th
270
270
 
271
271
  Packaged installers are automatically uploaded to Aliyun OSS (`parrot-static`), using the same credentials as Android APK releases. The completion output and build report include public download URLs, SHA-256 checksums, and a `release.json` URL. Configure `oss.public.region` and `aliyun.ak/sk` in your PMate configuration. Conflicting published versions require an app version bump. `--dir` produces local unpacked output only; `--dry-run` does not upload. The CLI owns publication after electron-builder completes; electron-builder receives the immutable generic release URL only to generate valid package metadata and runs with publishing disabled.
272
272
 
273
- `pmate app build <ns:app> --target electron --config <file>` packages a native shell that loads its configured HTTPS origin directly, without building or embedding web resources, and produces macOS DMG/ZIP or Windows NSIS/ZIP artifacts. Packaged releases require a CLI login with admin permission in the app namespace; `--dir` and `--dry-run` stay local. The first build downloads pinned Electron and electron-builder versions. Current targets: macOS and Windows, `arm64` and `x64`; macOS packages require a macOS build host.
273
+ `pmate app build <ns:app>` packages a native shell that loads its configured HTTPS origin directly, without building or embedding web resources, and produces macOS DMG/ZIP or Windows NSIS/ZIP artifacts. Packaged releases require a CLI login with admin permission in the app namespace; `--unsigned`, `--dir` and `--dry-run` stay local. Signed builds are the default; `--signed` remains accepted. Config is discovered from the current directory towards the repository root, checking desktop.config.json and apps/<app-name>/desktop.config.json at each level. Ambiguous matches require --config. Platform and architecture default to the host and Node architecture; output defaults to release/<app-name> at the repository root (or config directory outside a repository). Optional config notaryProfile selects a local Keychain profile; APPLE_KEYCHAIN_PROFILE overrides it. macOS publication requires Developer ID signing, notarization and Gatekeeper acceptance. The first build downloads pinned Electron and electron-builder versions. Current targets: macOS and Windows, `arm64` and `x64`; macOS packages require a macOS build host.
274
274
 
275
275
  ```sh
276
276
  pmate app build pmate:hello --target electron --config apps/hello/desktop.config.json --platform mac --arch arm64 --out-dir release/desktop
@@ -341,3 +341,5 @@ Register an `ios` service with `repository` and `dir`. `--cwd` overrides the rep
341
341
  The first invocation for each marketing version requires `--last-build <highest-used-build-for-this-version>` (0 only for a new version). The next Build is one greater than the maximum of the project value, imported value and locally reserved sequence for that version. Reservations, including failed builds, are kept separately per version. To migrate published date-based numbers, first increase MARKETING_VERSION and set CURRENT_PROJECT_VERSION to 0, then import 0 for the new version to start at Build 1. Import the current Apple maximum again after uploads outside this CLI or on another machine; this command does not query Apple build history. Do not lower or delete the sequence to reuse a number. Burgess performs the Apple history check and version migration automatically.
342
342
 
343
343
  Sequences, retained archives, derived data and logs live in `~/.pmate/ios-builds/`. Project/source version files are not changed. A bundle-level exclusive lock prevents simultaneous builds on the same machine; it does not coordinate different machines. Build/upload failures keep the reserved number and logs; retry consumes the next number. After an interrupted process, remove a leftover `.lock` file only after confirming no build is still running. Builds require automatic signing; resolve Apple account/certificate/profile errors in Xcode. Extension or App targets with fixed plist versions must produce matching archive metadata or the upload is stopped.
344
+
345
+ `pmate service deploy <ns:service>` defaults to `--env prod` for every service. Use explicit `--env preview` or `--env dev` to override it. For example, `pmate service deploy pmate:merry` deploys the production site https://merry.pmate.chat.
package/dist/index.d.ts CHANGED
@@ -820,10 +820,10 @@ type AppCommandArgs = {
820
820
  action: "build";
821
821
  id: string;
822
822
  target: "electron";
823
- config: string;
823
+ config?: string;
824
824
  platform: string;
825
825
  arch: string;
826
- outDir: string;
826
+ outDir?: string;
827
827
  dryRun: boolean;
828
828
  signed: boolean;
829
829
  dir: boolean;
package/dist/index.js CHANGED
@@ -17599,9 +17599,72 @@ function readDesktopConfig(file, appId) {
17599
17599
  c.authOrigins.forEach(origin);
17600
17600
  if (c.externalOrigins !== void 0 && !Array.isArray(c.externalOrigins)) throw new Error("externalOrigins must be an array");
17601
17601
  c.externalOrigins?.forEach(origin);
17602
+ if (c.notaryProfile !== void 0 && (typeof c.notaryProfile !== "string" || !c.notaryProfile.trim())) throw new Error("Invalid notaryProfile");
17602
17603
  if ("web" in c) throw new Error("Remote desktop builds do not accept web build configuration; remove web");
17603
17604
  return c;
17604
17605
  }
17606
+ function repositoryRoot(cwd) {
17607
+ let dir = import_node_path24.default.resolve(cwd);
17608
+ while (true) {
17609
+ if ((0, import_node_fs19.existsSync)(import_node_path24.default.join(dir, ".git"))) return dir;
17610
+ const parent = import_node_path24.default.dirname(dir);
17611
+ if (parent === dir) return void 0;
17612
+ dir = parent;
17613
+ }
17614
+ }
17615
+ function resolveDesktopPaths(args, cwd = process.cwd()) {
17616
+ const root = repositoryRoot(cwd);
17617
+ const name = args.id.split(":")[1];
17618
+ let file = args.config ? import_node_path24.default.resolve(cwd, args.config) : void 0;
17619
+ if (!file) {
17620
+ let dir = import_node_path24.default.resolve(cwd);
17621
+ while (true) {
17622
+ const candidates = [.../* @__PURE__ */ new Set([import_node_path24.default.join(dir, "desktop.config.json"), import_node_path24.default.join(dir, "apps", name, "desktop.config.json")])];
17623
+ const matches = candidates.filter((candidate) => (0, import_node_fs19.existsSync)(candidate) && JSON.parse((0, import_node_fs19.readFileSync)(candidate, "utf8")).app === args.id);
17624
+ if (matches.length > 1) throw new Error("Ambiguous desktop config; specify --config");
17625
+ if (matches.length === 1) {
17626
+ file = matches[0];
17627
+ break;
17628
+ }
17629
+ const parent = import_node_path24.default.dirname(dir);
17630
+ if (dir === root || parent === dir) break;
17631
+ dir = parent;
17632
+ }
17633
+ }
17634
+ if (!file) throw new Error(`No desktop config for ${args.id}; specify --config`);
17635
+ return { file, output: args.outDir ? import_node_path24.default.resolve(cwd, args.outDir) : import_node_path24.default.join(root ?? import_node_path24.default.dirname(file), "release", name) };
17636
+ }
17637
+ function desktopBuildEnvironment(config, env = process.env) {
17638
+ return { ...env, ...env.APPLE_KEYCHAIN_PROFILE ? {} : config.notaryProfile ? { APPLE_KEYCHAIN_PROFILE: config.notaryProfile } : {} };
17639
+ }
17640
+ function requireNotaryCredentials(env) {
17641
+ if (env.APPLE_ID || env.APPLE_APP_SPECIFIC_PASSWORD) {
17642
+ if (env.APPLE_ID && env.APPLE_APP_SPECIFIC_PASSWORD && env.APPLE_TEAM_ID) return;
17643
+ } else if (env.APPLE_API_KEY || env.APPLE_API_KEY_ID || env.APPLE_API_ISSUER) {
17644
+ if (env.APPLE_API_KEY && env.APPLE_API_KEY_ID && env.APPLE_API_ISSUER) return;
17645
+ } else if (env.APPLE_KEYCHAIN_PROFILE) return;
17646
+ throw new Error("macOS signed builds require complete Apple notarization credentials or APPLE_KEYCHAIN_PROFILE");
17647
+ }
17648
+ function requireSigningIdentity(env, inspect = () => (0, import_node_child_process9.execFileSync)("security", ["find-identity", "-v", "-p", "codesigning"], { encoding: "utf8" })) {
17649
+ if (env.CSC_LINK) return;
17650
+ if (!inspect().includes("Developer ID Application:")) throw new Error("No Developer ID Application signing identity available");
17651
+ }
17652
+ async function publishVerifiedDesktop(args, artifacts, config, verify = verifyMacRelease, upload = uploadDesktopArtifacts) {
17653
+ if (args.signed && args.platform === "mac") await verify(artifacts);
17654
+ if (args.dir || !args.signed) return void 0;
17655
+ return upload(artifacts, config.app, config.version, args.platform, args.arch);
17656
+ }
17657
+ async function verifyMacRelease(artifacts, run = runBuildCommand, inspect = (app) => (0, import_node_child_process9.spawnSync)("codesign", ["-dv", "--verbose=4", app], { encoding: "utf8" })) {
17658
+ const apps = (0, import_node_fs19.readdirSync)(artifacts, { recursive: true, withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".app")).map((entry) => import_node_path24.default.join(entry.parentPath, entry.name)).filter((file) => !file.slice(0, -4).includes(".app/"));
17659
+ if (!apps.length) throw new Error("No packaged macOS app found; refusing publication");
17660
+ for (const app of apps) {
17661
+ await run(["codesign", "--verify", "--deep", "--strict", app], artifacts);
17662
+ const signature = inspect(app);
17663
+ if (signature.status !== 0 || !signature.stderr.includes("Authority=Developer ID Application:")) throw new Error("Packaged app lacks Developer ID Application signature");
17664
+ await run(["xcrun", "stapler", "validate", app], artifacts);
17665
+ await run(["spctl", "--assess", "--type", "execute", "--verbose=2", app], artifacts);
17666
+ }
17667
+ }
17605
17668
  async function runBuildCommand(command, cwd, env = process.env) {
17606
17669
  await new Promise((resolve, reject) => {
17607
17670
  const child = (0, import_node_child_process9.spawn)(command[0], command.slice(1), { cwd, env, stdio: "inherit", shell: false });
@@ -17610,17 +17673,21 @@ async function runBuildCommand(command, cwd, env = process.env) {
17610
17673
  });
17611
17674
  }
17612
17675
  async function buildDesktop(args) {
17613
- const file = import_node_path24.default.resolve(args.config);
17676
+ const { file, output } = resolveDesktopPaths(args);
17614
17677
  const c = readDesktopConfig(file, args.id);
17615
17678
  const base = import_node_path24.default.dirname(file);
17616
17679
  const icon = import_node_path24.default.resolve(base, c.icon);
17617
- const output = import_node_path24.default.resolve(args.outDir);
17680
+ const env = desktopBuildEnvironment(c);
17618
17681
  if (!(0, import_node_fs19.existsSync)(icon) || !(0, import_node_fs19.statSync)(icon).isFile()) throw new Error(`Desktop icon not found: ${icon}`);
17619
17682
  if (!["mac", "win"].includes(args.platform) || !["arm64", "x64"].includes(args.arch)) throw new Error("Supported target: mac|win --arch arm64|x64");
17620
17683
  if (args.platform === "mac" && process.platform !== "darwin") throw new Error("macOS desktop packaging requires a macOS build host");
17621
- const plan = { app: c.app, productName: c.productName, version: c.version, target: args.platform, arch: args.arch, contentSource: "remote", origin: c.origin, output, electron: ELECTRON_VERSION, builder: BUILDER_VERSION, signed: args.signed };
17684
+ const plan = { config: file, notaryProfile: env.APPLE_KEYCHAIN_PROFILE, app: c.app, productName: c.productName, version: c.version, target: "electron", platform: args.platform, arch: args.arch, contentSource: "remote", origin: c.origin, output, electron: ELECTRON_VERSION, builder: BUILDER_VERSION, signed: args.signed };
17622
17685
  console.log(JSON.stringify({ phase: "plan", ...plan }, null, 2));
17623
17686
  if (args.dryRun) return;
17687
+ if (args.signed && args.platform === "mac") {
17688
+ requireNotaryCredentials(env);
17689
+ requireSigningIdentity(env);
17690
+ }
17624
17691
  (0, import_node_fs19.mkdirSync)(output, { recursive: true });
17625
17692
  const staging = (0, import_node_fs19.mkdtempSync)(import_node_path24.default.join(output, ".desktop-build-"));
17626
17693
  const appDir = import_node_path24.default.join(staging, "app");
@@ -17652,10 +17719,10 @@ async function buildDesktop(args) {
17652
17719
  };
17653
17720
  const configPath = import_node_path24.default.join(staging, "builder.json");
17654
17721
  (0, import_node_fs19.writeFileSync)(configPath, JSON.stringify(builderConfig));
17655
- await runBuildCommand([process.execPath, import_node_path24.default.join(cache, "node_modules", "electron-builder", "cli.js"), "--config", configPath, args.platform === "mac" ? "--mac" : "--win", `--${args.arch}`, "--publish", "never"], appDir, { ...process.env, ...args.signed ? {} : { CSC_IDENTITY_AUTO_DISCOVERY: "false" } });
17656
- const result = { ...plan, signature: args.signed ? args.platform === "mac" ? "configured-signing-required; verify notarization before distribution" : "configured-signing-required; verify Authenticode before distribution" : args.platform === "mac" ? "ad-hoc; local development" : "unsigned; local development", artifacts: import_node_path24.default.join(staging, "artifacts") };
17722
+ await runBuildCommand([process.execPath, import_node_path24.default.join(cache, "node_modules", "electron-builder", "cli.js"), "--config", configPath, args.platform === "mac" ? "--mac" : "--win", `--${args.arch}`, "--publish", "never"], appDir, { ...env, ...args.signed ? {} : { CSC_IDENTITY_AUTO_DISCOVERY: "false" } });
17723
+ const result = { ...plan, signature: args.signed ? args.platform === "mac" ? "Developer ID signed; notarization and Gatekeeper required before publication" : "configured-signing-required; verify Authenticode before distribution" : args.platform === "mac" ? "ad-hoc; local development" : "unsigned; local development", artifacts: import_node_path24.default.join(staging, "artifacts") };
17657
17724
  (0, import_node_fs19.writeFileSync)(import_node_path24.default.join(staging, "build-report.json"), JSON.stringify(result, null, 2));
17658
- const publication = args.dir ? void 0 : await uploadDesktopArtifacts(result.artifacts, c.app, c.version, args.platform, args.arch);
17725
+ const publication = await publishVerifiedDesktop(args, result.artifacts, c);
17659
17726
  (0, import_node_fs19.writeFileSync)(import_node_path24.default.join(staging, "build-report.json"), JSON.stringify({ ...result, publication }, null, 2));
17660
17727
  console.log(JSON.stringify({ phase: "complete", report: import_node_path24.default.join(staging, "build-report.json"), artifacts: result.artifacts, signature: result.signature, publication }, null, 2));
17661
17728
  }
@@ -23752,7 +23819,7 @@ function parseAppArgs(tokens) {
23752
23819
  const switches = /* @__PURE__ */ new Set();
23753
23820
  while (rest.length) {
23754
23821
  const key = rest.shift();
23755
- if (["--dry-run", "--signed", "--dir", "--json"].includes(key)) {
23822
+ if (["--dry-run", "--signed", "--unsigned", "--dir", "--json"].includes(key)) {
23756
23823
  if (switches.has(key)) throw new Error(`Duplicate option: ${key}`);
23757
23824
  switches.add(key);
23758
23825
  } else if (["--target", "--config", "--platform", "--arch", "--out-dir"].includes(key)) {
@@ -23760,11 +23827,12 @@ function parseAppArgs(tokens) {
23760
23827
  options[key] = requireValue3(rest, key);
23761
23828
  } else throw new Error(`Unknown app build option: ${key}`);
23762
23829
  }
23763
- if (options["--target"] !== "electron" || !options["--config"]) throw new Error("Use app build <ns:app> --target electron --config <file>");
23830
+ if (options["--target"] && options["--target"] !== "electron") throw new Error("Supported target: electron");
23831
+ if (switches.has("--signed") && switches.has("--unsigned")) throw new Error("--signed and --unsigned cannot be combined");
23764
23832
  const platform = options["--platform"] ?? (process.platform === "darwin" ? "mac" : process.platform === "win32" ? "win" : process.platform);
23765
23833
  const arch = options["--arch"] ?? process.arch;
23766
23834
  if (!["mac", "win"].includes(platform) || !["arm64", "x64"].includes(arch)) throw new Error("Supported target: --platform mac|win --arch arm64|x64");
23767
- return { type: "app" /* App */, action, id, target: "electron", config: options["--config"], platform, arch, outDir: options["--out-dir"] ?? "release/desktop", dryRun: switches.has("--dry-run"), signed: switches.has("--signed"), dir: switches.has("--dir"), json: switches.has("--json") };
23835
+ return { type: "app" /* App */, action, id, target: "electron", config: options["--config"], platform, arch, outDir: options["--out-dir"], dryRun: switches.has("--dry-run"), signed: !switches.has("--unsigned"), dir: switches.has("--dir"), json: switches.has("--json") };
23768
23836
  }
23769
23837
  let baseUrl;
23770
23838
  let json = false;
@@ -24434,9 +24502,7 @@ function parseServiceArgs(tokens) {
24434
24502
  return { type: "service" /* Service */, action, namespace, name, env, page, baseUrl, json };
24435
24503
  }
24436
24504
  if (action === "deploy" || action === "stop") {
24437
- if (action === "deploy" && !env) {
24438
- throw new Error("Missing required option --env for service deploy");
24439
- }
24505
+ if (action === "deploy") env ??= "prod";
24440
24506
  return { type: "service" /* Service */, action, namespace, name, env, ...cwd ? { cwd } : {}, baseUrl, json };
24441
24507
  }
24442
24508
  if (action === "init") {
@@ -26759,7 +26825,7 @@ var HELP_TEXT = [
26759
26825
  ` ${import_chalk4.default.gray(" kv list|get|exists|set|delete <name> [options]")}`,
26760
26826
  ` ${import_chalk4.default.gray(" defaults: chain=pmate namespace=pmate env base URLs from BLOCKCHAIN_BASE_URL / INDEXER_BASE_URL")}`,
26761
26827
  ` ${import_chalk4.default.cyan("app")} Manage app registry entries via apps-api`,
26762
- ` ${import_chalk4.default.gray(" build <ns:app> --target electron --config <file> [--platform mac] [--arch arm64|x64] [--out-dir <dir>] [--dir] [--dry-run] [--signed]")}`,
26828
+ ` ${import_chalk4.default.gray(" build <ns:app> [--target electron] [--config <file>] [--platform mac|win] [--arch arm64|x64] [--out-dir <dir>] [--dir] [--dry-run] [--unsigned|--signed]")}`,
26763
26829
  ` ${import_chalk4.default.gray(" list [--ns <namespace>] [--all] [--base-url <url>] [--json]")}`,
26764
26830
  ` ${import_chalk4.default.gray(" get <ns:objectId> [--base-url <url>] [--json]")}`,
26765
26831
  ` ${import_chalk4.default.gray(" view <ns:objectId> [--base-url <url>]")}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.38.5",
3
+ "version": "0.39.0",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {