@synopackageland/cli 0.52.6 → 0.52.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.52.7
4
+
5
+ - Throttle NAS image pull progress, retain phase changes and completion, and omit the unverified byte count
6
+ - Show the requested registry once per image and keep URL punctuation intact in diagnostics
7
+ - Include an Open URL in installed package status when DSM declares an unambiguous App entry
8
+
3
9
  ## 0.52.6
4
10
 
5
11
  - Report executor approval as not-required in build and inspect for SDK packages without an executor (#192)
package/README.md CHANGED
@@ -506,7 +506,7 @@ variables also work in `.env`; timeout/interval values accept integer seconds fr
506
506
  | `DSM_INSTALL_MAX_POLLS` | 10000 | Per-package polling attempts across initial checks, pre-pull and install/start verification |
507
507
  | `DSM_UNINSTALL_TIMEOUT_SECONDS` | 1800 | State check, stop and uninstall together |
508
508
  | `DSM_POLL_INTERVAL_SECONDS` | 5 | Package-state polling interval |
509
- | `DSM_IMAGE_PULL_STALL_TIMEOUT_SECONDS` | 1200 | No increase in NAS pull bytes; status heartbeats do not reset this budget |
509
+ | `DSM_IMAGE_PULL_STALL_TIMEOUT_SECONDS` | 1200 | No increase in the NAS pull progress counter; status heartbeats do not reset this budget |
510
510
 
511
511
  Install/upgrade waiting has no default elapsed-time deadline. Slow successful work
512
512
  continues until the polling limit (an integer from 1 to 1000000), cancellation or a DSM failure.
@@ -515,7 +515,10 @@ requests retain their timeouts; timed-out status requests count toward the polli
515
515
  Press Ctrl-C to stop waiting; this does not cancel the NAS operation.
516
516
  Container Apps pre-pull their inspected, locked image references on the NAS before
517
517
  SPK upload. An exact local repository digest skips the registry pull; an image
518
- configuration ID or a remote update digest is not sufficient proof. Progress includes bytes; failures name the image, requested registry
518
+ configuration ID or a remote update digest is not sufficient proof. Pull progress reports phase changes, updates at most once every five seconds within
519
+ a phase, and always reports completion. The DSM `downloaded` counter has no verified
520
+ byte unit and is used only for stall detection. The requested registry is shown once
521
+ per image; failures name the image, requested registry
519
522
  and daemon cause/endpoint when DSM provides them. Configure a reachable mirror,
520
523
  trust an inspecting CA in Container Manager, or use `images pin` and preload the
521
524
  pinned image. Pinning alone does not download layers onto the NAS. Pull tasks
@@ -546,6 +549,9 @@ unknown; a generic `install_corruption` does not prove a registry failure.
546
549
  Stopping/removal reports `state: "stopping"` or `"uninstalling"` until DSM verifies completion.
547
550
  It never reports `installed:false` for those transitions: an upgrade retains
548
551
  `installed:true`; a fresh install without a verified payload uses `installed:null`.
552
+ `status <package-id>` includes `openUrl` when DSM supplies a primary App launch
553
+ name or one unambiguous App entry. It opens on the configured DSM origin, preserving
554
+ HTTPS and its port. Missing, denied or ambiguous launch metadata leaves the field absent.
549
555
  `status` carries the effective DSM/CLI status. The result contract is
550
556
  [schema/package-state.schema.json](schema/package-state.schema.json).
551
557
 
@@ -17,6 +17,11 @@ export function containerImageReferences(report) {
17
17
  }
18
18
  const hint = 'Configure a reachable registry mirror, trust the inspecting CA in Container Manager, or use images pin on a trusted host and preload the pinned image on the NAS. Check Container Manager before retrying; pull tasks may still be running.';
19
19
  const causePattern = /error|fail|denied|forbidden|unauthorized|x509|certificate|tls|timeout|timed out|refused|no such host|not found|too many requests|429|403|unexpected.*status/i;
20
+ const progressIntervalMs = 5_000;
21
+ function pullPhase(detail) {
22
+ // Layer IDs, counters and heartbeat text are not phase changes.
23
+ return /\b(pulling fs layer|waiting|downloading|verifying checksum|download complete|extracting|pull complete|already exists)\b/i.exec(detail)?.[1].toLowerCase() ?? 'pulling';
24
+ }
20
25
  /** Pull on the NAS, before Package Center can turn a registry failure into broken/150. */
21
26
  export async function pullContainerImages(options) {
22
27
  const deadline = options.deadlineMs === undefined ? Infinity : Date.now() + options.deadlineMs;
@@ -30,9 +35,21 @@ export async function pullContainerImages(options) {
30
35
  throw new CtlError('CONTAINER_PULL_FAILED', 'Invalid container image reference', hint);
31
36
  // Do not apply build-host mirror overrides here: the inspected reference is authoritative.
32
37
  const requested = registryBaseUrl(parsed.registry, {});
33
- const context = `Image ${image} (requested registry ${requested}; actual endpoint appears in the daemon detail when available)`;
34
- const fail = (code, detail) => new CtlError(code, maskDiagnostic(`${context}: ${detail}`), hint);
38
+ const context = `Image ${image}`;
39
+ // Separate punctuation from the URL so diagnostic URL normalization cannot
40
+ // interpret a semicolon as part of the registry hostname.
41
+ const registryNote = `requested registry ${requested} — the actual endpoint appears in the daemon detail when available`;
42
+ const fail = (code, detail) => new CtlError(code, maskDiagnostic(`${context} (${registryNote}): ${detail}`), hint);
35
43
  let lastAdvance = Date.now(), downloaded = -1;
44
+ let lastPhase, lastReport = -Infinity;
45
+ const report = (phase, detail, finished = false) => {
46
+ const now = Date.now();
47
+ if (!finished && phase === lastPhase && now - lastReport < progressIntervalMs)
48
+ return;
49
+ lastPhase = phase;
50
+ lastReport = now;
51
+ progress(maskDiagnostic(`${context}: ${detail}`));
52
+ };
36
53
  const remaining = () => {
37
54
  if (options.signal?.aborted)
38
55
  throw installCanceled();
@@ -57,7 +74,7 @@ export async function pullContainerImages(options) {
57
74
  }
58
75
  return body.data;
59
76
  };
60
- progress(`${context}: starting NAS image pull…`);
77
+ progress(maskDiagnostic(`${context}: starting NAS image pull… (${registryNote})`));
61
78
  try {
62
79
  if (parsed.digest) {
63
80
  const inventory = await call('list', { offset: '0', limit: '-1' });
@@ -103,7 +120,7 @@ export async function pullContainerImages(options) {
103
120
  catch (error) {
104
121
  if (!isHostTimeout(error))
105
122
  throw error;
106
- progress(`${context}: status request timed out; checking existing pull task…`);
123
+ report('status timeout', 'status request timed out; checking existing pull task…');
107
124
  }
108
125
  if (state !== undefined) {
109
126
  if (typeof state?.finished !== 'boolean')
@@ -115,7 +132,9 @@ export async function pullContainerImages(options) {
115
132
  downloaded = state.downloaded;
116
133
  lastAdvance = Date.now();
117
134
  }
118
- progress(maskDiagnostic(`${context}: ${state.finished ? 'pull complete' : 'pulling'} (${Math.max(0, downloaded)} bytes)${detail ? ` — ${detail}` : ''}`));
135
+ // DSM supplies an advancing downloaded counter, but its contract does
136
+ // not establish a byte unit or total. Use it for liveness only.
137
+ report(pullPhase(detail), `${state.finished ? 'pull complete' : 'pulling'}${detail ? ` — ${detail}` : ''}`, state.finished);
119
138
  remaining();
120
139
  if (state.finished)
121
140
  break;
@@ -1,3 +1,5 @@
1
+ /** Use DSM's declared entry, without guessing a package's app name or port. */
2
+ export declare function appUrlFromPackageInfo(dsmOrigin: string, packageId: string, info: unknown): string | undefined;
1
3
  export declare function appOriginFromContract(dsmOrigin: string, contract: {
2
4
  package?: unknown;
3
5
  adminprotocol?: unknown;
@@ -1,4 +1,29 @@
1
1
  import { gatewayEntryPath, usesAuthGateway, webStationAlias } from "../contract/web-launch.js";
2
+ /** Use DSM's declared entry, without guessing a package's app name or port. */
3
+ export function appUrlFromPackageInfo(dsmOrigin, packageId, info) {
4
+ if (!info || typeof info !== 'object' || Array.isArray(info))
5
+ return undefined;
6
+ const data = info;
7
+ if (data.id !== packageId)
8
+ return undefined;
9
+ const primary = data.additional?.dsm_app_launch_name;
10
+ const apps = typeof data.additional?.dsm_apps === 'string' ? data.additional.dsm_apps.trim().split(/\s+/) : [];
11
+ // Multiple entries may include portals or auxiliary windows. Only fall back
12
+ // when DSM reports one unambiguous entry.
13
+ const app = typeof primary === 'string' && primary.trim() ? primary.trim() : apps.length === 1 ? apps[0] : undefined;
14
+ if (!app || !/^[A-Za-z][A-Za-z0-9_.-]*$/.test(app))
15
+ return undefined;
16
+ try {
17
+ const url = new URL('/', dsmOrigin);
18
+ if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password)
19
+ return undefined;
20
+ url.searchParams.set('launchApp', app);
21
+ return url.href;
22
+ }
23
+ catch {
24
+ return undefined;
25
+ }
26
+ }
2
27
  export function appOriginFromContract(dsmOrigin, contract) {
3
28
  if (contract.adminport === undefined || contract.adminport === null || contract.adminport === "") {
4
29
  return undefined;
@@ -76,6 +76,7 @@ export declare function uninstallPackage(id: string, options?: {
76
76
  export declare function packageStatus(id: string, host?: string, connection?: NasConnection): Promise<{
77
77
  recommendedCommand?: string | undefined;
78
78
  message?: string | undefined;
79
+ openUrl?: string | undefined;
79
80
  broken: boolean;
80
81
  installed: boolean | null;
81
82
  state?: "installing" | "upgrading" | "starting" | "stopping" | "uninstalling" | "unknown";
@@ -5,6 +5,7 @@ import { createInterface } from "node:readline/promises";
5
5
  import { CtlError } from "../ctl/errors.js";
6
6
  import { inspectAnySpk } from "../spk/inspect.js";
7
7
  import { containerImageReferences } from './container-pull.js';
8
+ import { appUrlFromPackageInfo } from './open-url.js';
8
9
  import { connectNas, requireAdministrator, } from "./connection.js";
9
10
  import { fetchPackageSource } from "../package-source.js";
10
11
  import { fetchInstalledPackageState, packageStateFromRecord, packageIsBroken, installPackageFromLocalSpk, uninstallPackageFromDsm, } from "./catalog-install.js";
@@ -241,8 +242,20 @@ export async function packageStatus(id, host, connection) {
241
242
  if (!state)
242
243
  throw fail("PACKAGE_STATUS_UNKNOWN", "DSM did not return a verifiable package state");
243
244
  const broken = packageIsBroken(state);
245
+ let openUrl;
246
+ if (state.installed === true) {
247
+ try {
248
+ const info = await nas.call('SYNO.Core.Package', 'get', 1, {
249
+ id,
250
+ additional: JSON.stringify(['dsm_app_launch_name', 'dsm_apps']),
251
+ });
252
+ openUrl = appUrlFromPackageInfo(nas.session.origin, id, info);
253
+ }
254
+ catch { /* Optional launch metadata must not hide a verified package status. */ }
255
+ }
244
256
  const quotedHost = "'" + nas.name.replace(/'/g, "'\\''") + "'";
245
257
  return { host: nas.name, package: id, ...state, broken,
258
+ ...(openUrl ? { openUrl } : {}),
246
259
  ...(broken && state.version && /^[0-9][0-9._-]*$/.test(state.version) && !state.state ? {
247
260
  recommendedCommand: `synopkgland install ${id}@${state.version}${nas.name === "env" ? "" : ` --host ${quotedHost}`} --yes`,
248
261
  message: "Package is broken; reinstall the same release to repair it while retaining data",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.52.6",
3
+ "version": "0.52.7",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -156,11 +156,13 @@
156
156
  "arrayEnums": {
157
157
  "additional": [
158
158
  "status",
159
- "dsm_apps"
159
+ "dsm_apps",
160
+ "dsm_app_launch_name"
160
161
  ]
161
162
  },
162
163
  "sources": [
163
- "host/catalog-install.ts"
164
+ "host/catalog-install.ts",
165
+ "host/package-commands.ts"
164
166
  ],
165
167
  "hubConfirmed": [
166
168
  "7.4"
@@ -1127,11 +1129,11 @@
1127
1129
  "error-registry.ts": "91f2de89bf98750a09fce54420e3a25e3527980be175ed704890a520181f1dc9",
1128
1130
  "host/catalog-install.ts": "df27409d835a901658dae7c2048c9028c2dc886e17575fe9189e88ae705c0fd2",
1129
1131
  "host/compose-project-recovery.ts": "c76efa505f8ba14f50a8705b63d0f9f8a022b70505fe6a5f5976146afae17532",
1130
- "host/container-pull.ts": "d85314dd265f7609ab1fda87e23cce0fa81165baeeaf79a792d7bb6dc10338e3",
1132
+ "host/container-pull.ts": "09908f48133ecc2580001afb4f7f0b6a949e4f35df1229e1e0860e37f2aa9a46",
1131
1133
  "host/dsm-client.ts": "52c34d520154e43d823a64dbb0ff7f3ae40e427fb835a5136ab6d847827a4b7a",
1132
1134
  "host/dsm-compound.ts": "5674b6f11d2b36a86a97ac7edf590abb34bd72f441c1f43ab057a43cfb5d7e88",
1133
1135
  "host/dsm-port-profile.ts": "9ebd06bbbc918267ef2d8a4ff9737b9d35579e45224dd4de362389921446ae8d",
1134
- "host/package-commands.ts": "ba1debaee82b19f310efe59eb0692a6495282e0e5e2ac2b474a8b85465eadafc",
1136
+ "host/package-commands.ts": "2e54eeea40cdf3221d277697ab9b02b43377e58bd81b64d4507f85d4039a08e8",
1135
1137
  "host/port-info-lookup.ts": "b7af19dd8194bc424eb2100ce5953cf0737e8158da373e93b66627c6a7028c8e",
1136
1138
  "host/port-info.ts": "9ab70c37860df681bee70039aebda9ad974fbd2e200fc2741daf9aacf7943905",
1137
1139
  "host/share-lookup.ts": "c158baffc774cb7b5b36a82b633bc48f7b8522f67972ef09ab1a15a8b4609196",