@synopackageland/cli 0.52.8 → 0.52.9
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 +11 -0
- package/assets/go/compose-admin/go.mod +22 -0
- package/assets/go/compose-admin/go.sum +40 -0
- package/assets/go/compose-admin/main.go +443 -0
- package/assets/go/compose-admin/main_test.go +173 -0
- package/dist/build-spk/resource-worker.d.ts +3 -0
- package/dist/build-spk/resource-worker.js +20 -1
- package/dist/cli.js +9 -0
- package/dist/host/catalog-install.d.ts +1 -0
- package/dist/host/catalog-install.js +113 -6
- package/dist/host/compose-admin-build.d.ts +6 -0
- package/dist/host/compose-admin-build.js +17 -0
- package/dist/host/compose-admin.d.ts +22 -0
- package/dist/host/compose-admin.js +119 -0
- package/dist/host/compose-project-recovery.d.ts +2 -0
- package/dist/host/compose-project-recovery.js +2 -0
- package/dist/host/package-commands.d.ts +1 -1
- package/dist/host/package-commands.js +32 -2
- package/dist/load-env.js +1 -1
- package/dist/native-http-schema/source.json +1 -1
- package/dist/runtime/sdk-source.d.ts +1 -1
- package/dist/runtime/sdk-source.js +1 -1
- package/dist/standalone/inspect-spk.js +2 -1
- package/docs/compose-admin.md +82 -0
- package/package.json +3 -2
- package/schema/dsm-api-contract.json +23 -4
|
@@ -5,6 +5,8 @@ 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 { composeAdminConfigured, composeAdminWarning } from './compose-admin.js';
|
|
9
|
+
import { progressReporter } from '../terminal-output.js';
|
|
8
10
|
import { appUrlFromPackageInfo } from './open-url.js';
|
|
9
11
|
import { connectNas, requireAdministrator, } from "./connection.js";
|
|
10
12
|
import { fetchPackageSource } from "../package-source.js";
|
|
@@ -213,9 +215,9 @@ export async function installPackage(spec, options = {}, connection) {
|
|
|
213
215
|
rmSync(stage, { recursive: true, force: true });
|
|
214
216
|
}
|
|
215
217
|
}
|
|
216
|
-
export async function uninstallPackage(id, options = {}) {
|
|
218
|
+
export async function uninstallPackage(id, options = {}, connection) {
|
|
217
219
|
packageId(id);
|
|
218
|
-
const nas = await connectNas(options.host);
|
|
220
|
+
const nas = connection ?? await connectNas(options.host);
|
|
219
221
|
const state = await fetchInstalledPackageState(nas.session.origin, nas.session.cookie, id);
|
|
220
222
|
if (!state)
|
|
221
223
|
throw fail('PACKAGE_STATUS_UNKNOWN', 'DSM did not return a verifiable package state');
|
|
@@ -228,7 +230,35 @@ export async function uninstallPackage(id, options = {}) {
|
|
|
228
230
|
return { dryRun: true, host: nas.name, package: id, action: "uninstall" };
|
|
229
231
|
await requireAdministrator(nas);
|
|
230
232
|
await confirm(`Uninstall ${id} (package uninstall hooks may remove data)`, options.yes);
|
|
233
|
+
let composeProject;
|
|
234
|
+
try {
|
|
235
|
+
const packages = await inventory(nas);
|
|
236
|
+
if (packages.has('ContainerManager')) {
|
|
237
|
+
const projects = await nas.call('SYNO.Docker.Project', 'list', 1);
|
|
238
|
+
if (!projects || typeof projects !== 'object' || Array.isArray(projects))
|
|
239
|
+
throw fail('COMPOSE_PROJECT_INVENTORY_INVALID', 'Cannot verify installed Compose project inventory');
|
|
240
|
+
const matches = Object.values(projects).filter((p) => p?.package_name === id ||
|
|
241
|
+
p?.path === `/var/packages/${id}/target/compose` ||
|
|
242
|
+
typeof p?.path === 'string' && /^\/volume[1-9][0-9]*\/@appstore\/([^/]+)\/compose$/.exec(p.path)?.[1] === id);
|
|
243
|
+
if (matches.length > 1)
|
|
244
|
+
throw fail('COMPOSE_PROJECT_CONFLICT', 'Ambiguous installed Compose project');
|
|
245
|
+
if (matches.length) {
|
|
246
|
+
const p = matches[0];
|
|
247
|
+
if (p.is_package !== true || typeof p.name !== 'string' || !/^[a-z0-9][a-z0-9_-]*$/.test(p.name))
|
|
248
|
+
throw fail('COMPOSE_PROJECT_CONFLICT', 'Cannot verify installed Compose project');
|
|
249
|
+
composeProject = p.name;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
// Without a native channel this optional lookup must not block the normal
|
|
255
|
+
// DSM uninstall path. Configured channels retain strict inventory checks.
|
|
256
|
+
if (composeAdminConfigured())
|
|
257
|
+
throw error;
|
|
258
|
+
progressReporter()(composeAdminWarning(id));
|
|
259
|
+
}
|
|
231
260
|
await uninstallPackageFromDsm({
|
|
261
|
+
composeProject,
|
|
232
262
|
dsmOrigin: nas.session.origin,
|
|
233
263
|
cookieHeader: nas.session.cookie,
|
|
234
264
|
packageId: id,
|
package/dist/load-env.js
CHANGED
|
@@ -19,7 +19,7 @@ export function loadDotEnv(fromDir = process.cwd()) {
|
|
|
19
19
|
}
|
|
20
20
|
const key = trimmed.slice(0, eq).trim();
|
|
21
21
|
const value = trimmed.slice(eq + 1).trim();
|
|
22
|
-
if (DOTENV_KEY.test(key) && process.env[key] === undefined) {
|
|
22
|
+
if (DOTENV_KEY.test(key) && key !== 'SYNOPKGLAND_COMPOSE_ADMIN_COMMAND' && process.env[key] === undefined) {
|
|
23
23
|
process.env[key] = value;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"0.53.
|
|
1
|
+
{"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"0.53.11","local":false}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { goPrivateCovers } from './go-env.js';
|
|
2
2
|
import { type ExecutorManifest } from './sdk-executor-manifest.js';
|
|
3
3
|
/** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
|
|
4
|
-
export declare const DEFAULT_SDK_VERSION = "0.53.
|
|
4
|
+
export declare const DEFAULT_SDK_VERSION = "0.53.11";
|
|
5
5
|
export declare const SDK_PACKAGE = "@synopackageland/sdk";
|
|
6
6
|
export declare const SDK_MODULE = "github.com/synopackageland/syno-pkg-land-sdk";
|
|
7
7
|
export declare const EXECUTOR_MODULE = "github.com/synopackageland/syno-pkg-land-sdk/executor";
|
|
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';
|
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { readExecutorManifest, predatesExecutorManifest } from './sdk-executor-manifest.js';
|
|
7
7
|
/** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
|
|
8
|
-
export const DEFAULT_SDK_VERSION = '0.53.
|
|
8
|
+
export const DEFAULT_SDK_VERSION = '0.53.11';
|
|
9
9
|
export const SDK_PACKAGE = '@synopackageland/sdk';
|
|
10
10
|
export const SDK_MODULE = 'github.com/synopackageland/syno-pkg-land-sdk';
|
|
11
11
|
export const EXECUTOR_MODULE = `${SDK_MODULE}/executor`;
|
|
@@ -43,6 +43,7 @@ import { DELETE_STATE_KEY } from "../build-spk/uninstall-wizard.js";
|
|
|
43
43
|
import { readUninstallRecord, stateItemTexts } from "./uninstall.js";
|
|
44
44
|
import { DSM_LANGS } from "./i18n.js";
|
|
45
45
|
import { BACKGROUND_UNIT_DIR, BACKGROUND_WORKER_PAYLOAD, BRIDGE_WORKER_ARGS, backgroundUnitName, renderBackgroundUnit, } from "./background.js";
|
|
46
|
+
import { matchesComposeWorkerResource } from '../build-spk/resource-worker.js';
|
|
46
47
|
import { renderStandaloneResource } from "./resource.js";
|
|
47
48
|
import { recoverSharedFolder, renderUpgradeWizardFiles, sharedFolderInstallSteps, SHARED_FOLDER_MARKER, } from "./shared-folder.js";
|
|
48
49
|
import { renderInstallWizardFiles, integrationWizardSteps, renderNativeInstallWizard, } from "../build-spk/install-wizard.js";
|
|
@@ -859,7 +860,7 @@ async function inspectUnifiedCompose(dir, payload, metadata, findings) {
|
|
|
859
860
|
throw new Error(`unexpected WIZARD_UIFILES/${name}; native share selection must match the declaration`);
|
|
860
861
|
}
|
|
861
862
|
const resource = renderStandaloneResource(manifest);
|
|
862
|
-
if (readOptional(join(dir, "conf/resource"))
|
|
863
|
+
if (!matchesComposeWorkerResource(readOptional(join(dir, "conf/resource")), resource))
|
|
863
864
|
throw new Error("unexpected worker resource; unapproved Shares must never auto-acquire");
|
|
864
865
|
if (readdirSync(join(dir, "conf")).some((n) => !["privilege", ...(resource ? ["resource"] : [])].includes(n)))
|
|
865
866
|
throw new Error("unexpected Compose resource");
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Compose administrator helper
|
|
2
|
+
|
|
3
|
+
Compose install, upgrade and uninstall work with the normal DSM administrator
|
|
4
|
+
HTTP session. When `SYNOPKGLAND_COMPOSE_ADMIN_COMMAND` is unset or empty, the CLI
|
|
5
|
+
continues the standard DSM lifecycle and prints one warning: verified
|
|
6
|
+
container/profile cleanup is disabled, so stale Container Manager profiles may
|
|
7
|
+
remain. The warning points here to enable verified cleanup and profile recovery.
|
|
8
|
+
No native helper or root/SSH channel is required for the standard workflow.
|
|
9
|
+
|
|
10
|
+
An explicitly configured native administrator channel enables installed ownership
|
|
11
|
+
inspection, SDK reconciliation and exact orphan cleanup. The HTTP APIs do not
|
|
12
|
+
expose trustworthy stored profile IDs. Once configured, invalid commands,
|
|
13
|
+
missing evidence and helper failures stop the operation; the CLI does not fall
|
|
14
|
+
back after an administrator action may have started. App hooks stay nonroot.
|
|
15
|
+
|
|
16
|
+
Build the adapter with the CLI and Go toolchain:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
synopkgland compose-admin-helper --arch x86_64 --output ./compose-admin
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Use `aarch64` for that NAS architecture. Install the reviewed executable in a
|
|
23
|
+
root-owned directory on the intended NAS. Configure an existing authenticated
|
|
24
|
+
administrator channel that executes it as root, for example an SSH alias with
|
|
25
|
+
key authentication and a restricted, passwordless sudo rule:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
export SYNOPKGLAND_COMPOSE_ADMIN_COMMAND='["ssh","-T","my-nas","sudo","-n","/opt/synopkgland/compose-admin","--origin","https://my-nas.example:5001"]'
|
|
29
|
+
synopkgland install ./MyApp.spk --yes
|
|
30
|
+
synopkgland uninstall MyApp --yes
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The configured command is a JSON argument array, never a shell fragment. The
|
|
34
|
+
helper's `--origin` must exactly match the DSM origin used for the operation.
|
|
35
|
+
Supply this setting through the administrator's process environment; project
|
|
36
|
+
`.env` files cannot set it. Use a channel scoped to that specific NAS. The CLI
|
|
37
|
+
sends no DSM credentials to this command. Authenticate SSH/sudo through your
|
|
38
|
+
existing credential mechanism; never put passwords in command arguments.
|
|
39
|
+
The CLI does not install an SSH server, change accounts or create sudo rules.
|
|
40
|
+
|
|
41
|
+
The helper is shipped as locked Go source in the CLI package and uses the same
|
|
42
|
+
pinned SDK release as the CLI. Build it for the NAS separately from an App; do
|
|
43
|
+
not put it in the SPK. Keep Container Manager edits and other package tools idle
|
|
44
|
+
during the operation. The helper holds a NAS package lock until the CLI completes
|
|
45
|
+
or closes the channel; concurrent CLI operations also share a local
|
|
46
|
+
origin/package lock.
|
|
47
|
+
|
|
48
|
+
With the native channel enabled, the helper captures the installed package
|
|
49
|
+
target, Compose lock services, CM package/project association and full container
|
|
50
|
+
labels before STOP. The CLI stops the package, waits for stopped readback, then
|
|
51
|
+
invokes `RemoveStoppedWorkerContainers` before upload/upgrade or uninstall.
|
|
52
|
+
Writable container layers are replaced; declared volumes and bind data are
|
|
53
|
+
retained. The worker uses `force_recreate: false`; image/config changes still
|
|
54
|
+
cause normal replacement. This flag alone does not repair existing profile
|
|
55
|
+
damage.
|
|
56
|
+
|
|
57
|
+
For a docker-project worker failure with code 272 and no native channel, the CLI
|
|
58
|
+
reports the original DSM error with channel-enablement guidance. It does not
|
|
59
|
+
infer that a profile is missing or attempt `RefreshWorkerProfiles` or a recovery
|
|
60
|
+
start. Enable the channel above, inspect the package's current state, then retry
|
|
61
|
+
the same-version repair with the inspected SPK or store release:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
synopkgland status MyApp
|
|
65
|
+
synopkgland install ./MyApp.spk --yes
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
With the channel enabled, only a confirmed docker-project worker failure, the
|
|
69
|
+
selected installed version and verified lower-level missing/stale profile
|
|
70
|
+
evidence can invoke `RefreshWorkerProfiles`. After successful profile readback,
|
|
71
|
+
the CLI starts that version once. It never retries an uncertain write. Project
|
|
72
|
+
get error 2105, foreign ownership, unknown paths, unreadable profiles and
|
|
73
|
+
incomplete inventory stop the operation. Check DSM state before retrying after
|
|
74
|
+
any such failure.
|
|
75
|
+
|
|
76
|
+
Orphan cleanup only considers containers completely inspected earlier in the
|
|
77
|
+
same locked helper session. It checks their exact prior profile IDs and a full
|
|
78
|
+
all-container inventory to exclude any same-name resource, then uses Container
|
|
79
|
+
delete with `force=false` and `preserve_profile=false`, followed by readback.
|
|
80
|
+
It does not scan name prefixes or remove CM configuration files directly.
|
|
81
|
+
Existing orphan profiles without this prior inventory require administrator
|
|
82
|
+
investigation; the CLI cannot infer ownership from a filename.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synopackageland/cli",
|
|
3
|
-
"version": "0.52.
|
|
3
|
+
"version": "0.52.9",
|
|
4
4
|
"description": "Syno Package Land Developer Kit CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"docs/path-ingress.md",
|
|
22
22
|
"skills",
|
|
23
23
|
"docs/shared-folders.md",
|
|
24
|
-
"docs/daemon-nofile.md"
|
|
24
|
+
"docs/daemon-nofile.md",
|
|
25
|
+
"docs/compose-admin.md"
|
|
25
26
|
],
|
|
26
27
|
"scripts": {
|
|
27
28
|
"check:docs": "node --test scripts/check-doc-versions.test.mjs && node scripts/check-doc-versions.mjs",
|
|
@@ -421,6 +421,25 @@
|
|
|
421
421
|
"7.4"
|
|
422
422
|
]
|
|
423
423
|
},
|
|
424
|
+
{
|
|
425
|
+
"api": "SYNO.Core.Package.Control",
|
|
426
|
+
"method": "start",
|
|
427
|
+
"version": 1,
|
|
428
|
+
"dsm": {
|
|
429
|
+
"7.2": "unverified",
|
|
430
|
+
"7.3": "unverified",
|
|
431
|
+
"7.4": "confirmed"
|
|
432
|
+
},
|
|
433
|
+
"parameters": {
|
|
434
|
+
"id": {}
|
|
435
|
+
},
|
|
436
|
+
"sources": [
|
|
437
|
+
"host/catalog-install.ts"
|
|
438
|
+
],
|
|
439
|
+
"hubConfirmed": [
|
|
440
|
+
"7.4"
|
|
441
|
+
]
|
|
442
|
+
},
|
|
424
443
|
{
|
|
425
444
|
"api": "SYNO.Core.Package.Uninstallation",
|
|
426
445
|
"method": "uninstall",
|
|
@@ -1114,7 +1133,7 @@
|
|
|
1114
1133
|
"sourceAudit": {
|
|
1115
1134
|
"build-spk/share-combobox.ts": "797cd3eea347e7fe57946f9584f725d6faef79fe9c56b690e1199ea7489fa973",
|
|
1116
1135
|
"build-spk/share-validation.ts": "a51b160cea9bea096e6efb45879abbf6d0dfecf21c761dca7cd06647d44cef62",
|
|
1117
|
-
"cli.ts": "
|
|
1136
|
+
"cli.ts": "61cd00cb0f7dc1836717cc2ee666e93c3396ba79bc3bc30aad2a4fec85a661ad",
|
|
1118
1137
|
"ctl/cli.ts": "97d218069c6fac42f64573c68c354d7a0e549ca2900b9d8b2935c9786bc5d11d",
|
|
1119
1138
|
"ctl/external.ts": "f66490ded838f934a0cf373f284418d4d02441edc8c8365066fc45b898ba81dc",
|
|
1120
1139
|
"ctl/flows.ts": "0f35d03176655bfe1d1df5d02ea36199e05973634dffcc6710112b7c8ce78b7e",
|
|
@@ -1127,13 +1146,13 @@
|
|
|
1127
1146
|
"e2e/certificates.ts": "e9801e5f4d326d31c3c281e5106f34138493e26cd7f0ad2b1dd3f6a566832389",
|
|
1128
1147
|
"e2e/dsm.ts": "66c9b3f6d907a8069202c5f88f13f8051c07b099de66d3ebce5de51c6374201f",
|
|
1129
1148
|
"error-registry.ts": "91f2de89bf98750a09fce54420e3a25e3527980be175ed704890a520181f1dc9",
|
|
1130
|
-
"host/catalog-install.ts": "
|
|
1131
|
-
"host/compose-project-recovery.ts": "
|
|
1149
|
+
"host/catalog-install.ts": "13908fd47d75f8a2f4ed412c9310b80b2d0a1d190ce46db34f15850c2ed45578",
|
|
1150
|
+
"host/compose-project-recovery.ts": "51f93197898677b5daebd745ef848e07b7d6454fc86b5d4e1fa210fe089ac414",
|
|
1132
1151
|
"host/container-pull.ts": "09908f48133ecc2580001afb4f7f0b6a949e4f35df1229e1e0860e37f2aa9a46",
|
|
1133
1152
|
"host/dsm-client.ts": "52c34d520154e43d823a64dbb0ff7f3ae40e427fb835a5136ab6d847827a4b7a",
|
|
1134
1153
|
"host/dsm-compound.ts": "5674b6f11d2b36a86a97ac7edf590abb34bd72f441c1f43ab057a43cfb5d7e88",
|
|
1135
1154
|
"host/dsm-port-profile.ts": "9ebd06bbbc918267ef2d8a4ff9737b9d35579e45224dd4de362389921446ae8d",
|
|
1136
|
-
"host/package-commands.ts": "
|
|
1155
|
+
"host/package-commands.ts": "8a171c2ac3613697f52d81af3469250b7b28b190fcb7e863368876e056d189e7",
|
|
1137
1156
|
"host/port-info-lookup.ts": "b7af19dd8194bc424eb2100ce5953cf0737e8158da373e93b66627c6a7028c8e",
|
|
1138
1157
|
"host/port-info.ts": "9ab70c37860df681bee70039aebda9ad974fbd2e200fc2741daf9aacf7943905",
|
|
1139
1158
|
"host/share-lookup.ts": "c158baffc774cb7b5b36a82b633bc48f7b8522f67972ef09ab1a15a8b4609196",
|