@synopackageland/cli 0.3.10 → 0.4.1
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/LICENSE +21 -0
- package/README.md +57 -9
- package/dist/bin.js +1 -2
- package/dist/build-spk/generator.d.ts +0 -3
- package/dist/build-spk/generator.js +138 -287
- package/dist/build-spk/native-lifecycle.js +0 -3
- package/dist/build-spk/native-payload.js +0 -1
- package/dist/build-spk/notices.d.ts +5 -0
- package/dist/build-spk/notices.js +60 -0
- package/dist/cli.js +178 -151
- package/dist/compose/analyze.d.ts +1 -2
- package/dist/compose/analyze.js +5 -48
- package/dist/contract/unsupported-types.d.ts +10 -0
- package/dist/contract/unsupported-types.js +49 -0
- package/dist/contract/validate.js +25 -2
- package/dist/contract/web-launch.js +0 -2
- package/dist/deploy/deploy.d.ts +1 -4
- package/dist/deploy/deploy.js +45 -156
- package/dist/deploy/homes-values.js +1 -1
- package/dist/deploy/plan.d.ts +18 -0
- package/dist/deploy/plan.js +54 -0
- package/dist/deploy/spk-version.d.ts +2 -14
- package/dist/deploy/spk-version.js +25 -111
- package/dist/dev.d.ts +1 -3
- package/dist/dev.js +14 -28
- package/dist/error-registry.js +830 -862
- package/dist/host/dsm-client.js +12 -272
- package/dist/host/dsm-port-profile.d.ts +0 -1
- package/dist/host/dsm-port-profile.js +0 -2
- package/dist/host/types.d.ts +1 -83
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -6
- package/dist/info.d.ts +0 -1
- package/dist/info.js +3 -10
- package/dist/init.d.ts +15 -1
- package/dist/init.js +128 -12
- package/dist/log.js +2 -3
- package/dist/native/validate.js +0 -1
- package/dist/standalone/binary.d.ts +9 -0
- package/dist/standalone/binary.js +67 -0
- package/dist/standalone/build.d.ts +25 -0
- package/dist/standalone/build.js +110 -0
- package/dist/standalone/daemon.d.ts +23 -0
- package/dist/standalone/daemon.js +114 -0
- package/dist/standalone/dsm-window.d.ts +26 -0
- package/dist/standalone/dsm-window.js +291 -0
- package/dist/standalone/helper-inventory.d.ts +16 -0
- package/dist/standalone/helper-inventory.js +2 -0
- package/dist/standalone/helper.d.ts +21 -0
- package/dist/standalone/helper.js +105 -0
- package/dist/standalone/host-adapter.d.ts +5 -0
- package/dist/standalone/host-adapter.js +148 -0
- package/dist/standalone/host-platform.d.ts +13 -0
- package/dist/standalone/host-platform.js +42 -0
- package/dist/standalone/host-types.d.ts +49 -0
- package/dist/standalone/host-types.js +1 -0
- package/dist/standalone/i18n.d.ts +28 -0
- package/dist/standalone/i18n.js +161 -0
- package/dist/standalone/inspect-helper.d.ts +6 -0
- package/dist/standalone/inspect-helper.js +88 -0
- package/dist/standalone/inspect-spk.d.ts +23 -0
- package/dist/standalone/inspect-spk.js +209 -0
- package/dist/standalone/lifecycle-helper.d.ts +2 -0
- package/dist/standalone/lifecycle-helper.js +12 -0
- package/dist/standalone/lifecycle.d.ts +3 -0
- package/dist/standalone/lifecycle.js +53 -0
- package/dist/standalone/manifest.d.ts +73 -0
- package/dist/standalone/manifest.js +279 -0
- package/dist/standalone/reopen-events.d.ts +2 -0
- package/dist/standalone/reopen-events.js +28 -0
- package/dist/standalone/root-messages.d.ts +7 -0
- package/dist/standalone/root-messages.js +259 -0
- package/dist/standalone/root-ops.d.ts +42 -0
- package/dist/standalone/root-ops.js +101 -0
- package/dist/standalone/root-window.d.ts +36 -0
- package/dist/standalone/root-window.js +302 -0
- package/dist/standalone/spk.d.ts +23 -0
- package/dist/standalone/spk.js +192 -0
- package/dist/template-paths.d.ts +2 -0
- package/dist/template-paths.js +9 -0
- package/dist/templates/_daemon/fixture_linux_test.go +15 -0
- package/dist/templates/_daemon/fixture_other_test.go +7 -0
- package/dist/templates/_daemon/go.mod +3 -0
- package/dist/templates/_daemon/main.go +608 -0
- package/dist/templates/_daemon/main_test.go +242 -0
- package/dist/templates/_daemon/process_linux.go +55 -0
- package/dist/templates/_daemon/process_linux_test.go +161 -0
- package/dist/templates/_daemon/process_other.go +14 -0
- package/dist/templates/_daemon/testdata/child.go +41 -0
- package/dist/templates/_shared/GO-LICENSE +27 -0
- package/dist/templates/_shared/GO-PATENTS +22 -0
- package/dist/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/dist/templates/_shared/notice-overrides/index.json +14 -0
- package/dist/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/dist/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/dist/templates/_shared/third-party-notices.mjs +51 -0
- package/dist/templates/binary/synology-app.yaml +7 -0
- package/dist/templates/hello-files/compose.yaml +0 -1
- package/dist/templates/hello-web/compose.yaml +13 -10
- package/dist/templates/hello-web/html/app.js +1 -23
- package/dist/templates/hello-web/html/index.html +1 -3
- package/dist/templates/hello-web-page/compose.yaml +13 -10
- package/dist/templates/hello-web-page/html/app.js +1 -23
- package/dist/templates/hello-web-page/html/index.html +1 -3
- package/dist/templates/native-go/README.md +324 -0
- package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/dist/templates/native-go/backend/cmd/app/main.go +49 -0
- package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/dist/templates/native-go/backend/cmd/helper/main.go +38 -0
- package/dist/templates/native-go/backend/go.mod +7 -0
- package/dist/templates/native-go/backend/go.sum +4 -0
- package/dist/templates/native-go/backend/internal/api/binary.go +154 -0
- package/dist/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/dist/templates/native-go/backend/internal/api/errors.go +33 -0
- package/dist/templates/native-go/backend/internal/api/registry.go +104 -0
- package/dist/templates/native-go/backend/internal/api/registry_test.go +329 -0
- package/dist/templates/native-go/backend/internal/api/server.go +159 -0
- package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/dist/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/dist/templates/native-go/backend/internal/app/root_none.go +9 -0
- package/dist/templates/native-go/backend/internal/app/routes.go +138 -0
- package/dist/templates/native-go/backend/internal/app/routes_test.go +172 -0
- package/dist/templates/native-go/backend/internal/dsm/auth.go +118 -0
- package/dist/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/dist/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/dist/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/control.go +424 -0
- package/dist/templates/native-go/backend/internal/helper/control_test.go +250 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/dist/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/dist/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/dist/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/dist/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/dist/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/dist/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/dist/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/dist/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/dist/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/dist/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/dist/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/dist/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/dist/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/dist/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/dist/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/dist/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/dist/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/dist/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/dist/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/dist/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
- package/dist/templates/native-go/backend/internal/helper/peer_other.go +7 -0
- package/dist/templates/native-go/backend/internal/helper/process_linux.go +177 -0
- package/dist/templates/native-go/backend/internal/helper/process_other.go +5 -0
- package/dist/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/dist/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/dist/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/dist/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/dist/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/dist/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/dist/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/dist/templates/native-go/backend/internal/helper/server_linux.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/status.go +334 -0
- package/dist/templates/native-go/backend/internal/helper/status_test.go +288 -0
- package/dist/templates/native-go/backend/internal/helper/supervision.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +363 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +913 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/dist/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/dist/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/dist/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/dist/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/dist/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/dist/templates/native-go/backend/internal/helper/write.go +77 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/dist/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/dist/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/dist/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/dist/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/dist/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/dist/templates/native-go/dsm-package.yaml +58 -0
- package/dist/templates/native-go/gitignore +1 -0
- package/dist/templates/native-go/i18n/glossary.json +662 -0
- package/dist/templates/native-go/i18n/messages/de.json +28 -0
- package/dist/templates/native-go/i18n/messages/en.json +28 -0
- package/dist/templates/native-go/i18n/messages/es.json +28 -0
- package/dist/templates/native-go/i18n/messages/fr.json +28 -0
- package/dist/templates/native-go/i18n/messages/it.json +28 -0
- package/dist/templates/native-go/i18n/messages/ja.json +28 -0
- package/dist/templates/native-go/i18n/messages/ko.json +28 -0
- package/dist/templates/native-go/i18n/messages/zh-CN.json +28 -0
- package/dist/templates/native-go/i18n/messages/zh-TW.json +28 -0
- package/dist/templates/native-go/ui/app.css +35 -0
- package/dist/templates/native-go/ui/app.js +101 -0
- package/dist/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
- package/dist/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
- package/dist/templates/native-go-better-auth/node/app.mjs +72 -0
- package/dist/templates/native-go-better-auth/node/build.mjs +4 -0
- package/dist/templates/native-go-better-auth/node/package-lock.json +862 -0
- package/dist/templates/native-go-better-auth/node/package.json +1 -0
- package/dist/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
- package/dist/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal.go +203 -0
- package/dist/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
- package/dist/templates/native-go-root/backend/internal/app/root.go +107 -0
- package/dist/templates/native-go-root/backend/internal/app/root_test.go +124 -0
- package/dist/templates/native-go-root/root/whoami.sh +6 -0
- package/dist/templates/native-go-vue/README.md +224 -0
- package/dist/templates/native-go-vue/frontend/DESIGN.md +78 -0
- package/dist/templates/native-go-vue/frontend/package-lock.json +2410 -0
- package/dist/templates/native-go-vue/frontend/package.json +6 -0
- package/dist/templates/native-go-vue/frontend/src/App.vue +159 -0
- package/dist/templates/native-go-vue/frontend/src/context.ts +56 -0
- package/dist/templates/native-go-vue/frontend/src/main.ts +29 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/dist/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/dist/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/dist/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/dist/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/dist/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/dist/templates/native-go-vue/frontend/src/style.css +31 -0
- package/dist/templates/native-go-vue/frontend/test/apps.test.ts +190 -0
- package/dist/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/dist/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/dist/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -0
- package/dist/templates/native-go-vue/frontend/vite.config.ts +10 -0
- package/dist/templates/native-go-vue/gitignore +2 -0
- package/dist/types.d.ts +1 -1
- package/dist/validate.js +11 -7
- package/package.json +5 -8
- package/schema/synology-app.schema.json +36 -37
- package/skills/SKILL.md +4 -48
- package/skills/reference/create.md +11 -83
- package/skills/reference/deploy.md +7 -78
- package/skills/reference/diagnose.md +4 -101
- package/skills/reference/files.md +5 -41
- package/skills/reference/identity.md +3 -29
- package/skills/reference/wrap.md +0 -2
- package/templates/_daemon/fixture_linux_test.go +15 -0
- package/templates/_daemon/fixture_other_test.go +7 -0
- package/templates/_daemon/go.mod +3 -0
- package/templates/_daemon/main.go +608 -0
- package/templates/_daemon/main_test.go +242 -0
- package/templates/_daemon/process_linux.go +55 -0
- package/templates/_daemon/process_linux_test.go +161 -0
- package/templates/_daemon/process_other.go +14 -0
- package/templates/_daemon/testdata/child.go +41 -0
- package/templates/_shared/GO-LICENSE +27 -0
- package/templates/_shared/GO-PATENTS +22 -0
- package/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
- package/templates/_shared/notice-overrides/index.json +14 -0
- package/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
- package/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
- package/templates/_shared/third-party-notices.mjs +51 -0
- package/templates/binary/synology-app.yaml +7 -0
- package/templates/hello-files/compose.yaml +0 -1
- package/templates/hello-web/compose.yaml +13 -10
- package/templates/hello-web/html/app.js +1 -23
- package/templates/hello-web/html/index.html +1 -3
- package/templates/hello-web-page/compose.yaml +13 -10
- package/templates/hello-web-page/html/app.js +1 -23
- package/templates/hello-web-page/html/index.html +1 -3
- package/templates/native-go/README.md +324 -0
- package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
- package/templates/native-go/backend/cmd/app/main.go +49 -0
- package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
- package/templates/native-go/backend/cmd/helper/main.go +38 -0
- package/templates/native-go/backend/go.mod +7 -0
- package/templates/native-go/backend/go.sum +4 -0
- package/templates/native-go/backend/internal/api/binary.go +154 -0
- package/templates/native-go/backend/internal/api/binary_test.go +165 -0
- package/templates/native-go/backend/internal/api/errors.go +33 -0
- package/templates/native-go/backend/internal/api/registry.go +104 -0
- package/templates/native-go/backend/internal/api/registry_test.go +329 -0
- package/templates/native-go/backend/internal/api/server.go +159 -0
- package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
- package/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
- package/templates/native-go/backend/internal/app/root_none.go +9 -0
- package/templates/native-go/backend/internal/app/routes.go +138 -0
- package/templates/native-go/backend/internal/app/routes_test.go +172 -0
- package/templates/native-go/backend/internal/dsm/auth.go +118 -0
- package/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
- package/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
- package/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
- package/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
- package/templates/native-go/backend/internal/helper/cohort.go +393 -0
- package/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
- package/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
- package/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
- package/templates/native-go/backend/internal/helper/control.go +424 -0
- package/templates/native-go/backend/internal/helper/control_test.go +250 -0
- package/templates/native-go/backend/internal/helper/data_contract.go +242 -0
- package/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
- package/templates/native-go/backend/internal/helper/data_decode.go +184 -0
- package/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
- package/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
- package/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
- package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
- package/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
- package/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
- package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
- package/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
- package/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
- package/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
- package/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
- package/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
- package/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
- package/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
- package/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
- package/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
- package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
- package/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
- package/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
- package/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
- package/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
- package/templates/native-go/backend/internal/helper/lease.go +112 -0
- package/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/lease_other.go +8 -0
- package/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
- package/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
- package/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
- package/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
- package/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
- package/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
- package/templates/native-go/backend/internal/helper/native_identity.go +89 -0
- package/templates/native-go/backend/internal/helper/native_provider.go +159 -0
- package/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
- package/templates/native-go/backend/internal/helper/observation.go +204 -0
- package/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
- package/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
- package/templates/native-go/backend/internal/helper/observation_test.go +196 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
- package/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
- package/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
- package/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
- package/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
- package/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
- package/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
- package/templates/native-go/backend/internal/helper/peer_other.go +7 -0
- package/templates/native-go/backend/internal/helper/process_linux.go +177 -0
- package/templates/native-go/backend/internal/helper/process_other.go +5 -0
- package/templates/native-go/backend/internal/helper/publication_test.go +178 -0
- package/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
- package/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
- package/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
- package/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
- package/templates/native-go/backend/internal/helper/readonly.go +105 -0
- package/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
- package/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
- package/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
- package/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
- package/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
- package/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
- package/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
- package/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
- package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
- package/templates/native-go/backend/internal/helper/repair.go +132 -0
- package/templates/native-go/backend/internal/helper/repair_test.go +271 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
- package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
- package/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
- package/templates/native-go/backend/internal/helper/server_linux.go +124 -0
- package/templates/native-go/backend/internal/helper/status.go +334 -0
- package/templates/native-go/backend/internal/helper/status_test.go +288 -0
- package/templates/native-go/backend/internal/helper/supervision.go +107 -0
- package/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
- package/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux.go +363 -0
- package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +913 -0
- package/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
- package/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
- package/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
- package/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
- package/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
- package/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
- package/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
- package/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
- package/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
- package/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
- package/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
- package/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
- package/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
- package/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
- package/templates/native-go/backend/internal/helper/write.go +77 -0
- package/templates/native-go/backend/internal/helper/write_admission.go +260 -0
- package/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
- package/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
- package/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
- package/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
- package/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
- package/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
- package/templates/native-go/backend/internal/helper/write_test.go +53 -0
- package/templates/native-go/dsm-package.yaml +58 -0
- package/templates/native-go/gitignore +1 -0
- package/templates/native-go/i18n/glossary.json +662 -0
- package/templates/native-go/i18n/messages/de.json +28 -0
- package/templates/native-go/i18n/messages/en.json +28 -0
- package/templates/native-go/i18n/messages/es.json +28 -0
- package/templates/native-go/i18n/messages/fr.json +28 -0
- package/templates/native-go/i18n/messages/it.json +28 -0
- package/templates/native-go/i18n/messages/ja.json +28 -0
- package/templates/native-go/i18n/messages/ko.json +28 -0
- package/templates/native-go/i18n/messages/zh-CN.json +28 -0
- package/templates/native-go/i18n/messages/zh-TW.json +28 -0
- package/templates/native-go/ui/app.css +35 -0
- package/templates/native-go/ui/app.js +101 -0
- package/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
- package/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
- package/templates/native-go-better-auth/node/app.mjs +72 -0
- package/templates/native-go-better-auth/node/build.mjs +4 -0
- package/templates/native-go-better-auth/node/package-lock.json +862 -0
- package/templates/native-go-better-auth/node/package.json +1 -0
- package/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
- package/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
- package/templates/native-go-integration/backend/internal/app/personal.go +203 -0
- package/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
- package/templates/native-go-root/backend/internal/app/root.go +107 -0
- package/templates/native-go-root/backend/internal/app/root_test.go +124 -0
- package/templates/native-go-root/root/whoami.sh +6 -0
- package/templates/native-go-vue/README.md +224 -0
- package/templates/native-go-vue/frontend/DESIGN.md +78 -0
- package/templates/native-go-vue/frontend/package-lock.json +2410 -0
- package/templates/native-go-vue/frontend/package.json +6 -0
- package/templates/native-go-vue/frontend/src/App.vue +159 -0
- package/templates/native-go-vue/frontend/src/context.ts +56 -0
- package/templates/native-go-vue/frontend/src/main.ts +29 -0
- package/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
- package/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
- package/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
- package/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
- package/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
- package/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
- package/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
- package/templates/native-go-vue/frontend/src/style.css +31 -0
- package/templates/native-go-vue/frontend/test/apps.test.ts +190 -0
- package/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
- package/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
- package/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
- package/templates/native-go-vue/frontend/tsconfig.json +1 -0
- package/templates/native-go-vue/frontend/vite.config.ts +10 -0
- package/templates/native-go-vue/gitignore +2 -0
- package/dist/attestation/app-package.d.ts +0 -86
- package/dist/attestation/app-package.js +0 -206
- package/dist/attestation/install-on-host.d.ts +0 -14
- package/dist/attestation/install-on-host.js +0 -52
- package/dist/attestation/keyring.d.ts +0 -21
- package/dist/attestation/keyring.js +0 -168
- package/dist/attestation/platform-service.d.ts +0 -70
- package/dist/attestation/platform-service.js +0 -250
- package/dist/build-spk/broker-glue.d.ts +0 -16
- package/dist/build-spk/broker-glue.js +0 -40
- package/dist/deploy/catalog-publish.d.ts +0 -3
- package/dist/deploy/catalog-publish.js +0 -7
- package/dist/doctor.d.ts +0 -22
- package/dist/doctor.js +0 -822
- package/dist/error-collector.d.ts +0 -2
- package/dist/error-collector.js +0 -46
- package/dist/host/broker-paths.d.ts +0 -1
- package/dist/host/broker-paths.js +0 -1
- package/dist/host/broker-upgrade-preflight.d.ts +0 -61
- package/dist/host/broker-upgrade-preflight.js +0 -156
- package/dist/host/digests.d.ts +0 -5
- package/dist/host/digests.js +0 -63
- package/dist/host/fake-nas.d.ts +0 -49
- package/dist/host/fake-nas.js +0 -193
- package/dist/mock-broker/bootstrap.d.ts +0 -2
- package/dist/mock-broker/bootstrap.js +0 -8
- package/dist/mock-broker/files.d.ts +0 -60
- package/dist/mock-broker/files.js +0 -408
- package/dist/mock-broker/oidc.d.ts +0 -31
- package/dist/mock-broker/oidc.js +0 -161
- package/dist/mock-broker/path.d.ts +0 -9
- package/dist/mock-broker/path.js +0 -50
- package/dist/mock-broker/server.d.ts +0 -19
- package/dist/mock-broker/server.js +0 -350
- package/dist/publish/build-ledger.d.ts +0 -22
- package/dist/publish/build-ledger.js +0 -26
- package/dist/publish/community-path.d.ts +0 -6
- package/dist/publish/community-path.js +0 -41
- package/dist/publish/curated-release.d.ts +0 -78
- package/dist/publish/curated-release.js +0 -883
- package/dist/publish/file-build-ledger.d.ts +0 -18
- package/dist/publish/file-build-ledger.js +0 -268
- package/dist/publish/github-pr.d.ts +0 -25
- package/dist/publish/github-pr.js +0 -85
- package/dist/publish/github-repo.d.ts +0 -8
- package/dist/publish/github-repo.js +0 -21
- package/dist/publish/platform-service-release.d.ts +0 -60
- package/dist/publish/platform-service-release.js +0 -333
- package/dist/publish/preflight.d.ts +0 -24
- package/dist/publish/preflight.js +0 -138
- package/dist/publish/publish.d.ts +0 -27
- package/dist/publish/publish.js +0 -136
- package/dist/publish/sync-definition.d.ts +0 -4
- package/dist/publish/sync-definition.js +0 -48
- package/dist/release-bin.d.ts +0 -2
- package/dist/release-bin.js +0 -23
- package/dist/templates/hello-web/html/sdk.js +0 -68
- package/dist/templates/hello-web-page/html/sdk.js +0 -68
- package/dist/templates/native/synology-app.yaml +0 -7
- package/dist/test-host.d.ts +0 -15
- package/dist/test-host.js +0 -37
- package/templates/hello-web/html/sdk.js +0 -68
- package/templates/hello-web-page/html/sdk.js +0 -68
- package/templates/native/synology-app.yaml +0 -7
- /package/dist/templates/{native → binary}/native.yaml +0 -0
- /package/templates/{native → binary}/native.yaml +0 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { renderRootTaskScript, rootTaskHeader, rootTaskName } from "./root-ops.js";
|
|
2
|
+
export function rootTasks(manifest) {
|
|
3
|
+
return (manifest.rootOps ?? []).map((op) => ({
|
|
4
|
+
op: op.name,
|
|
5
|
+
name: rootTaskName(manifest.package, op.name),
|
|
6
|
+
header: rootTaskHeader(manifest.package, op.name),
|
|
7
|
+
script: renderRootTaskScript(manifest, op),
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* `createRootAccess(options)` → `{ state, authorize, run, remove }`, plain
|
|
12
|
+
* ES5 for DSM's desktop. Every DSM call goes through `options.send` (the
|
|
13
|
+
* AppWindow's sendWebAPI) as the signed-in administrator:
|
|
14
|
+
*
|
|
15
|
+
* - authorize: DSM's own password confirmation, then one disabled root task
|
|
16
|
+
* with exactly the embedded script. The one-use token goes into that single
|
|
17
|
+
* create call and is never kept.
|
|
18
|
+
* - run: re-reads the task and runs it only if it is still exactly ours, then
|
|
19
|
+
* waits for its history entry and asks the backend for the output. Repair
|
|
20
|
+
* additionally requires fresh PasswordConfirm and another exact task check.
|
|
21
|
+
* - an older version of our task is "outdated" and never runs; authorizing
|
|
22
|
+
* again replaces it. A same-named task that is not ours is a "conflict" and
|
|
23
|
+
* is never run, replaced or deleted.
|
|
24
|
+
*/
|
|
25
|
+
export const ROOT_RUNTIME = `function createRootAccess(options) {
|
|
26
|
+
var API = "SYNO.Core.TaskScheduler";
|
|
27
|
+
var POLL_MS = 500, POLLS = 60;
|
|
28
|
+
var byOp = {};
|
|
29
|
+
options.tasks.forEach(function (task) { byOp[task.op] = task; });
|
|
30
|
+
|
|
31
|
+
function fail(code) {
|
|
32
|
+
var error = new Error(code);
|
|
33
|
+
error.code = code;
|
|
34
|
+
return error;
|
|
35
|
+
}
|
|
36
|
+
function begin(op) {
|
|
37
|
+
if (!Object.prototype.hasOwnProperty.call(byOp, op)) return Promise.reject(fail("root_unknown_op"));
|
|
38
|
+
if (options.user().admin !== true) return Promise.reject(fail("admin_required"));
|
|
39
|
+
return Promise.resolve(byOp[op]);
|
|
40
|
+
}
|
|
41
|
+
function isRootTask(summary) {
|
|
42
|
+
return summary.owner === "root" && summary.real_owner === "root" && summary.enable === false && summary.type === "script";
|
|
43
|
+
}
|
|
44
|
+
function find(task) {
|
|
45
|
+
return options.send(API, "list", 3, { start: 0, limit: 500 }).then(function (data) {
|
|
46
|
+
if (!data || !Array.isArray(data.tasks)) throw fail("root_bad_response");
|
|
47
|
+
var named = data.tasks.filter(function (summary) { return summary && summary.name === task.name; });
|
|
48
|
+
if (named.length === 0) return { state: "missing" };
|
|
49
|
+
if (named.length > 1 || !isRootTask(named[0])) return { state: "conflict" };
|
|
50
|
+
var ref = { id: named[0].id, real_owner: named[0].real_owner };
|
|
51
|
+
return options.send(API, "get", 4, ref).then(function (detail) {
|
|
52
|
+
var script = detail && detail.extra && detail.extra.script;
|
|
53
|
+
if (!detail || String(detail.id) !== String(ref.id) || detail.name !== task.name
|
|
54
|
+
|| detail.owner !== "root" || detail.enable !== false || detail.type !== "script" || typeof script !== "string") {
|
|
55
|
+
return { state: "conflict" };
|
|
56
|
+
}
|
|
57
|
+
if (script === task.script) return { state: "ready", ref: ref };
|
|
58
|
+
if (script.indexOf(task.header) === 0) return { state: "outdated", ref: ref };
|
|
59
|
+
return { state: "conflict" };
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function definition(task, user) {
|
|
64
|
+
var hours = [];
|
|
65
|
+
for (var h = 1; h <= 23; h++) hours.push(h);
|
|
66
|
+
return {
|
|
67
|
+
name: task.name,
|
|
68
|
+
real_owner: user,
|
|
69
|
+
owner: "root",
|
|
70
|
+
enable: false,
|
|
71
|
+
type: "script",
|
|
72
|
+
schedule: {
|
|
73
|
+
date_type: 0, week_day: "0,1,2,3,4,5,6", repeat_date: 1001, monthly_week: [], hour: 0, minute: 0,
|
|
74
|
+
repeat_hour: 0, repeat_min: 0, last_work_hour: 0,
|
|
75
|
+
repeat_min_store_config: [1, 5, 10, 15, 20, 30], repeat_hour_store_config: hours
|
|
76
|
+
},
|
|
77
|
+
extra: { notify_enable: false, script: task.script, notify_mail: "", notify_if_error: false }
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function newest(history) {
|
|
81
|
+
if (!Array.isArray(history)) throw fail("root_bad_response");
|
|
82
|
+
return history.reduce(function (latest, entry) {
|
|
83
|
+
return entry && (!latest || Number(entry.timestamp) > Number(latest.timestamp)) ? entry : latest;
|
|
84
|
+
}, null);
|
|
85
|
+
}
|
|
86
|
+
function history(ref) {
|
|
87
|
+
return options.send(API, "get_history_status_list", 1, { id: ref.id }).then(newest);
|
|
88
|
+
}
|
|
89
|
+
function waitForRun(ref, before, polls) {
|
|
90
|
+
return history(ref).then(function (latest) {
|
|
91
|
+
var finished = latest && (!before || latest.timestamp !== before.timestamp)
|
|
92
|
+
&& latest.exit_type !== "running" && latest.stop_time;
|
|
93
|
+
if (finished) {
|
|
94
|
+
if (latest.exit_code !== 0) throw fail("root_task_failed");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (polls <= 1) throw fail("root_timeout");
|
|
98
|
+
return options.wait(POLL_MS).then(function () { return waitForRun(ref, before, polls - 1); });
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
state: function (op) {
|
|
104
|
+
return begin(op).then(find).then(function (found) { return found.state; });
|
|
105
|
+
},
|
|
106
|
+
authorize: function (op) {
|
|
107
|
+
return begin(op).then(function (task) {
|
|
108
|
+
return find(task).then(function (found) {
|
|
109
|
+
if (found.state === "ready") return "ready";
|
|
110
|
+
if (found.state === "conflict") throw fail("root_conflict");
|
|
111
|
+
return options.confirmPassword().then(function (token) {
|
|
112
|
+
if (!token) return "cancelled";
|
|
113
|
+
var params = definition(task, options.user().name);
|
|
114
|
+
params.SynoConfirmPWToken = token;
|
|
115
|
+
var replaced = found.state === "outdated"
|
|
116
|
+
? options.send(API, "delete", 2, { tasks: [found.ref] })
|
|
117
|
+
: Promise.resolve();
|
|
118
|
+
return replaced.then(function () {
|
|
119
|
+
return options.send(API + ".Root", "create", 4, params);
|
|
120
|
+
}).then(function () {
|
|
121
|
+
return find(task);
|
|
122
|
+
}).then(function (after) {
|
|
123
|
+
if (after.state !== "ready") throw fail("root_verify_failed");
|
|
124
|
+
return "ready";
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
run: function (op) {
|
|
131
|
+
return begin(op).then(function (task) {
|
|
132
|
+
return find(task).then(function (found) {
|
|
133
|
+
if (found.state !== "ready") throw fail("root_not_ready");
|
|
134
|
+
// Repair requires fresh interactive consent even for a retained task.
|
|
135
|
+
// Confirmation tokens are never cached or reused as scheduler tokens.
|
|
136
|
+
var consent = op === "helper_repair" ? options.confirmPassword() : Promise.resolve(true);
|
|
137
|
+
return consent.then(function (token) {
|
|
138
|
+
if (!token) throw fail("root_cancelled");
|
|
139
|
+
// The user may leave the dialog open while the scheduler changes.
|
|
140
|
+
return op === "helper_repair" ? begin(op).then(find) : found;
|
|
141
|
+
}).then(function (verified) {
|
|
142
|
+
if (verified.state !== "ready") throw fail("root_not_ready");
|
|
143
|
+
return history(verified.ref).then(function (before) {
|
|
144
|
+
return options.send(API, "run", 2, { tasks: [verified.ref] }).then(function () {
|
|
145
|
+
return waitForRun(verified.ref, before, POLLS);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}).then(function () {
|
|
150
|
+
return options.call("root.output", { op: op });
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
remove: function (op) {
|
|
155
|
+
return begin(op).then(function (task) {
|
|
156
|
+
return find(task).then(function (found) {
|
|
157
|
+
if (found.state === "missing") return "missing";
|
|
158
|
+
if (found.state === "conflict") throw fail("root_conflict");
|
|
159
|
+
return options.send(API, "delete", 2, { tasks: [found.ref] }).then(function () {
|
|
160
|
+
return find(task);
|
|
161
|
+
}).then(function (after) {
|
|
162
|
+
if (after.state !== "missing") throw fail("root_verify_failed");
|
|
163
|
+
return "missing";
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
output: function (op) {
|
|
169
|
+
return begin(op).then(function () {
|
|
170
|
+
return options.call("root.output", { op: op });
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}`;
|
|
175
|
+
/**
|
|
176
|
+
* The authorization panel the window shows above the app for each root
|
|
177
|
+
* operation, identical in every package. `rootPanelView(model)` decides what
|
|
178
|
+
* it shows; `mountRootPanel(host, access, i18n, tasks, admin)` draws it with
|
|
179
|
+
* DOM text nodes only (no HTML from data).
|
|
180
|
+
*/
|
|
181
|
+
export const ROOT_PANEL = `function rootPanelShowsResult(state) {
|
|
182
|
+
return state === "ready" || state === "outdated";
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function rootPanelView(model) {
|
|
186
|
+
if (!model.admin) return { status: null, buttons: [], message: { key: "admin_only" } };
|
|
187
|
+
function buttons(actions) {
|
|
188
|
+
return actions.map(function (action) { return { action: action, disabled: model.busy === true }; });
|
|
189
|
+
}
|
|
190
|
+
if (model.error) {
|
|
191
|
+
return {
|
|
192
|
+
status: "state." + model.state, buttons: buttons(["retry"]),
|
|
193
|
+
message: { key: "error." + model.error, params: { name: model.name, code: model.error } }
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
var message = model.notice ? { key: model.notice } : null;
|
|
197
|
+
switch (model.state) {
|
|
198
|
+
case "missing":
|
|
199
|
+
return { status: "state.missing", buttons: buttons(["authorize"]), message: message };
|
|
200
|
+
case "outdated":
|
|
201
|
+
return { status: "state.outdated", buttons: buttons(["authorize", "remove"]), message: message };
|
|
202
|
+
case "ready":
|
|
203
|
+
return { status: "state.ready", buttons: buttons(["run", "remove"]), message: message };
|
|
204
|
+
case "conflict":
|
|
205
|
+
return { status: "state.conflict", buttons: buttons(["retry"]), message: { key: "error.root_conflict", params: { name: model.name } } };
|
|
206
|
+
default:
|
|
207
|
+
return { status: "state.checking", buttons: [], message: null };
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function mountRootPanel(host, access, i18n, tasks, admin) {
|
|
212
|
+
var t = i18n.t;
|
|
213
|
+
function el(tag, className, text) {
|
|
214
|
+
var node = document.createElement(tag);
|
|
215
|
+
if (className) node.className = className;
|
|
216
|
+
if (text !== undefined) node.textContent = text;
|
|
217
|
+
return node;
|
|
218
|
+
}
|
|
219
|
+
function say(message) {
|
|
220
|
+
if (!message) return "";
|
|
221
|
+
var text = t(message.key, message.params);
|
|
222
|
+
return text === message.key && message.key.indexOf("error.") === 0 ? t("error.default", message.params) : text;
|
|
223
|
+
}
|
|
224
|
+
tasks.forEach(function (task) {
|
|
225
|
+
var model = { admin: admin, name: task.name, state: "checking", busy: false, error: null, notice: null };
|
|
226
|
+
var result = null;
|
|
227
|
+
var section = el("section", "dsmapp-rootpanel");
|
|
228
|
+
host.appendChild(section);
|
|
229
|
+
|
|
230
|
+
function render() {
|
|
231
|
+
var view = rootPanelView(model);
|
|
232
|
+
while (section.firstChild) section.removeChild(section.firstChild);
|
|
233
|
+
section.appendChild(el("h2", null, t("title")));
|
|
234
|
+
section.appendChild(el("p", null, t("intro", { op: task.op })));
|
|
235
|
+
if (view.status) {
|
|
236
|
+
var facts = el("dl");
|
|
237
|
+
facts.appendChild(el("dt", null, t("status")));
|
|
238
|
+
facts.appendChild(el("dd", "dsmapp-rootpanel-state", t(view.status, { name: task.name })));
|
|
239
|
+
facts.appendChild(el("dt", null, t("last_run")));
|
|
240
|
+
facts.appendChild(el("dd", null, result && result.modified
|
|
241
|
+
? new Date(result.modified * 1000).toLocaleString(i18n.locale) : t("never")));
|
|
242
|
+
section.appendChild(facts);
|
|
243
|
+
}
|
|
244
|
+
if (view.message) section.appendChild(el("p", "dsmapp-rootpanel-message", say(view.message)));
|
|
245
|
+
if (result && typeof result.output === "string") {
|
|
246
|
+
section.appendChild(el("div", "dsmapp-rootpanel-label", t("output")));
|
|
247
|
+
section.appendChild(el("pre", "dsmapp-rootpanel-output", result.output));
|
|
248
|
+
}
|
|
249
|
+
var actions = el("div", "dsmapp-rootpanel-actions");
|
|
250
|
+
view.buttons.forEach(function (button) {
|
|
251
|
+
var node = el("button", button.action === "remove" ? null : "dsmapp-rootpanel-primary", t(button.action));
|
|
252
|
+
node.type = "button";
|
|
253
|
+
node.disabled = button.disabled;
|
|
254
|
+
node.onclick = function () { act(button.action); };
|
|
255
|
+
actions.appendChild(node);
|
|
256
|
+
});
|
|
257
|
+
section.appendChild(actions);
|
|
258
|
+
if (admin && rootPanelShowsResult(model.state)) section.appendChild(el("p", "dsmapp-rootpanel-hint", t("uninstall_hint")));
|
|
259
|
+
}
|
|
260
|
+
function settle(promise, notice) {
|
|
261
|
+
model.busy = true;
|
|
262
|
+
model.error = null;
|
|
263
|
+
model.notice = null;
|
|
264
|
+
render();
|
|
265
|
+
return promise.then(function (value) {
|
|
266
|
+
model.notice = typeof notice === "function" ? notice(value) : notice;
|
|
267
|
+
}, function (error) {
|
|
268
|
+
if (error && error.code === "root_cancelled") model.notice = "cancelled";
|
|
269
|
+
else model.error = (error && error.code) || "unknown";
|
|
270
|
+
}).then(function () {
|
|
271
|
+
model.busy = false;
|
|
272
|
+
render();
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function refresh(notice) {
|
|
276
|
+
return settle(access.state(task.op).then(function (state) {
|
|
277
|
+
model.state = state;
|
|
278
|
+
if (!rootPanelShowsResult(state)) return;
|
|
279
|
+
return access.output(task.op).then(function (out) { result = out; });
|
|
280
|
+
}), notice);
|
|
281
|
+
}
|
|
282
|
+
function refreshAfterChange() {
|
|
283
|
+
return model.error ? null : refresh(model.notice);
|
|
284
|
+
}
|
|
285
|
+
function act(action) {
|
|
286
|
+
if (action === "retry") return refresh(null);
|
|
287
|
+
if (action === "authorize") {
|
|
288
|
+
return settle(access.authorize(task.op), function (outcome) {
|
|
289
|
+
return outcome === "cancelled" ? "cancelled" : null;
|
|
290
|
+
}).then(refreshAfterChange);
|
|
291
|
+
}
|
|
292
|
+
if (action === "run") {
|
|
293
|
+
return settle(access.run(task.op).then(function (out) { result = out; }), "completed");
|
|
294
|
+
}
|
|
295
|
+
if (action === "remove") {
|
|
296
|
+
return settle(access.remove(task.op).then(function () { result = null; }), null).then(refreshAfterChange);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
render();
|
|
300
|
+
if (admin) refresh(null);
|
|
301
|
+
});
|
|
302
|
+
}`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type NativeArchFamily } from "../build-spk/dsm-arch.js";
|
|
2
|
+
import type { StandaloneManifest } from "./manifest.js";
|
|
3
|
+
import type { HelperArtifact } from "./helper.js";
|
|
4
|
+
export declare const LIFECYCLE_SCRIPTS: readonly ["preinst", "postinst", "preuninst", "postuninst", "preupgrade", "postupgrade", "start-stop-status"];
|
|
5
|
+
export declare class StandaloneBuildError extends Error {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
constructor(code: string, message: string);
|
|
8
|
+
}
|
|
9
|
+
export interface AssembleOptions {
|
|
10
|
+
manifest: StandaloneManifest;
|
|
11
|
+
arch: NativeArchFamily;
|
|
12
|
+
/** The compiled or prebuilt CGI executable, already checked. */
|
|
13
|
+
cgiPath: string;
|
|
14
|
+
outputPath: string;
|
|
15
|
+
helper?: HelperArtifact;
|
|
16
|
+
daemonControl?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Packs an unsigned Standalone Package SPK. DSM runs installation/lifecycle
|
|
20
|
+
* as the package account, including an optional foreground daemon. Root
|
|
21
|
+
* integration remains separate and requires explicit administrator approval.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assembleStandaloneSpk(options: AssembleOptions): Promise<void>;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { chmodSync, copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync, } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { dirname, join, relative, isAbsolute } from "node:path";
|
|
5
|
+
import { infoArchValue } from "../build-spk/dsm-arch.js";
|
|
6
|
+
import { writeDsmWindowIcons, writePackageCenterIcons } from "../build-spk/dsm-icons.js";
|
|
7
|
+
import { renderNativePrivilege } from "../build-spk/native-lifecycle.js";
|
|
8
|
+
import { createReproducibleTar } from "../build-spk/reproducible-archive.js";
|
|
9
|
+
import { renderStandaloneScript } from "./lifecycle.js";
|
|
10
|
+
import { DSM_LANGS, LOCALES } from "./i18n.js";
|
|
11
|
+
import { CGI_PAYLOAD_PATH, renderUiConfig, renderWindowScript, windowScriptName } from "./dsm-window.js";
|
|
12
|
+
import { copyStandaloneNotices } from "../build-spk/notices.js";
|
|
13
|
+
import { hostScriptName, renderHostAdapterScript } from "./host-adapter.js";
|
|
14
|
+
import { copyDaemonPayload } from "./daemon.js";
|
|
15
|
+
const FILE_MODE = 0o644;
|
|
16
|
+
const EXEC_MODE = 0o755;
|
|
17
|
+
const MAX_UI_BYTES = 64 * 1024 * 1024;
|
|
18
|
+
export const LIFECYCLE_SCRIPTS = [
|
|
19
|
+
"preinst",
|
|
20
|
+
"postinst",
|
|
21
|
+
"preuninst",
|
|
22
|
+
"postuninst",
|
|
23
|
+
"preupgrade",
|
|
24
|
+
"postupgrade",
|
|
25
|
+
"start-stop-status",
|
|
26
|
+
];
|
|
27
|
+
export class StandaloneBuildError extends Error {
|
|
28
|
+
code;
|
|
29
|
+
constructor(code, message) {
|
|
30
|
+
super(`[${code}] ${message}`);
|
|
31
|
+
this.code = code;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Packs an unsigned Standalone Package SPK. DSM runs installation/lifecycle
|
|
36
|
+
* as the package account, including an optional foreground daemon. Root
|
|
37
|
+
* integration remains separate and requires explicit administrator approval.
|
|
38
|
+
*/
|
|
39
|
+
export async function assembleStandaloneSpk(options) {
|
|
40
|
+
const { manifest } = options;
|
|
41
|
+
const staging = mkdtempSync(join(tmpdir(), "syno-standalone-spk-"));
|
|
42
|
+
try {
|
|
43
|
+
const uiRoot = join(staging, "package", "ui");
|
|
44
|
+
const appDir = join(uiRoot, "app");
|
|
45
|
+
copyUiTree(manifest.ui.dir, appDir);
|
|
46
|
+
const assetVersion = digestTree(appDir).slice(0, 12);
|
|
47
|
+
writeFile(join(uiRoot, "config"), renderUiConfig(manifest));
|
|
48
|
+
writeFile(join(uiRoot, windowScriptName(manifest)), renderWindowScript(manifest, assetVersion));
|
|
49
|
+
writeFile(join(uiRoot, hostScriptName(manifest.build)), renderHostAdapterScript(manifest.package));
|
|
50
|
+
writeDsmWindowIcons(uiRoot);
|
|
51
|
+
const cgiTarget = join(staging, "package", CGI_PAYLOAD_PATH);
|
|
52
|
+
mkdirSync(dirname(cgiTarget), { recursive: true });
|
|
53
|
+
copyFileSync(options.cgiPath, cgiTarget);
|
|
54
|
+
chmodSync(cgiTarget, EXEC_MODE);
|
|
55
|
+
if (manifest.daemon) {
|
|
56
|
+
if (!options.daemonControl)
|
|
57
|
+
throw new StandaloneBuildError("STANDALONE_DAEMON_ARTIFACT_REQUIRED", "daemon controller artifact required.");
|
|
58
|
+
copyDaemonPayload(manifest, options.arch, join(staging, "package", "daemon"), options.daemonControl);
|
|
59
|
+
}
|
|
60
|
+
if (manifest.integration && !options.helper)
|
|
61
|
+
throw new StandaloneBuildError("HELPER_ARTIFACT_REQUIRED", "integration SPK 缺少已建置的 helper inventory。");
|
|
62
|
+
if (options.helper) {
|
|
63
|
+
const dir = join(staging, "package", "integration");
|
|
64
|
+
mkdirSync(dir, { recursive: true });
|
|
65
|
+
copyFileSync(options.helper.binary, join(dir, "helper"));
|
|
66
|
+
copyFileSync(new URL("../../templates/native-go/backend/THIRD_PARTY_NOTICES.txt", import.meta.url), join(dir, "THIRD_PARTY_NOTICES.txt"));
|
|
67
|
+
chmodSync(join(dir, "helper"), EXEC_MODE);
|
|
68
|
+
writeFile(join(dir, "inventory.json"), JSON.stringify(options.helper.inventory));
|
|
69
|
+
writeFile(join(dir, "workers.json"), JSON.stringify(options.helper.workers.map(({ id, digest }) => ({ id, digest }))));
|
|
70
|
+
mkdirSync(join(dir, "workers"));
|
|
71
|
+
for (const worker of options.helper.workers) {
|
|
72
|
+
writeFileSync(join(dir, "workers", worker.id), worker.bytes, { mode: FILE_MODE });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (manifest.integration?.identity === "better-auth") {
|
|
76
|
+
const source = join(manifest.root, "node", "dist", "app.mjs");
|
|
77
|
+
const rel = relative(realpathSync(manifest.root), realpathSync(source));
|
|
78
|
+
if (rel.startsWith("..") || isAbsolute(rel) || !lstatSync(source).isFile() || lstatSync(source).size > 16 * 1024 * 1024)
|
|
79
|
+
throw new StandaloneBuildError("STANDALONE_IDENTITY_PAYLOAD_INVALID", "Better Auth bundle must be a bounded regular file inside the project.");
|
|
80
|
+
const target = join(staging, "package", "integration", "identity", "app.mjs");
|
|
81
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
82
|
+
copyFileSync(source, target);
|
|
83
|
+
chmodSync(target, FILE_MODE);
|
|
84
|
+
}
|
|
85
|
+
copyStandaloneNotices(manifest.root, manifest.ui.dir, join(staging, 'package'), manifest.backend.kind === 'go' || Boolean(manifest.daemon), Boolean(options.helper), manifest.integration?.identity === 'better-auth', manifest.backend.kind === 'go' ? manifest.backend.dir : undefined);
|
|
86
|
+
if (manifest.daemon)
|
|
87
|
+
copyFileSync(new URL('../../templates/_shared/LICENSES/TEMPLATE.txt', import.meta.url), join(staging, 'package', 'LICENSES', 'DAEMON-LICENSE.txt'));
|
|
88
|
+
const packageTgz = join(staging, "package.tgz");
|
|
89
|
+
await createReproducibleTar(join(staging, "package"), packageTgz, { gzip: true });
|
|
90
|
+
rmSync(join(staging, "package"), { recursive: true, force: true });
|
|
91
|
+
const checksum = createHash("md5").update(readFileSync(packageTgz)).digest("hex");
|
|
92
|
+
writeFile(join(staging, "INFO"), renderInfo(manifest, options.arch, checksum));
|
|
93
|
+
mkdirSync(join(staging, "conf"));
|
|
94
|
+
writeFile(join(staging, "conf", "privilege"), renderNativePrivilege());
|
|
95
|
+
mkdirSync(join(staging, "scripts"));
|
|
96
|
+
for (const name of LIFECYCLE_SCRIPTS) {
|
|
97
|
+
writeFile(join(staging, "scripts", name), renderStandaloneScript(name, manifest), EXEC_MODE);
|
|
98
|
+
}
|
|
99
|
+
writePackageCenterIcons(staging);
|
|
100
|
+
mkdirSync(dirname(options.outputPath), { recursive: true });
|
|
101
|
+
await createReproducibleTar(staging, options.outputPath);
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
rmSync(staging, { recursive: true, force: true });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function writeFile(path, content, mode = FILE_MODE) {
|
|
108
|
+
writeFileSync(path, content, "utf8");
|
|
109
|
+
chmodSync(path, mode);
|
|
110
|
+
}
|
|
111
|
+
function quote(value) {
|
|
112
|
+
return `"${value}"`;
|
|
113
|
+
}
|
|
114
|
+
/** Manifest validation already refused quotes, backslashes and newlines. */
|
|
115
|
+
function renderInfo(manifest, arch, checksum) {
|
|
116
|
+
const fields = [
|
|
117
|
+
["package", manifest.package],
|
|
118
|
+
["version", manifest.spkVersion],
|
|
119
|
+
["displayname", manifest.displayname],
|
|
120
|
+
["description", manifest.description],
|
|
121
|
+
["maintainer", manifest.maintainer],
|
|
122
|
+
["arch", infoArchValue(arch)],
|
|
123
|
+
["os_min_ver", manifest.os_min_ver],
|
|
124
|
+
["dsmuidir", "ui"],
|
|
125
|
+
["dsmappname", `SYNO.SDS.${manifest.package}.Instance`],
|
|
126
|
+
["thirdparty", "yes"],
|
|
127
|
+
["startable", "yes"],
|
|
128
|
+
["checksum", checksum],
|
|
129
|
+
];
|
|
130
|
+
if (manifest.integration || manifest.daemon)
|
|
131
|
+
fields.push(["precheckstartstop", "yes"]);
|
|
132
|
+
if (manifest.integration?.identity === "better-auth")
|
|
133
|
+
fields.push(["install_dep_packages", "Node.js_v22"]);
|
|
134
|
+
for (const locale of LOCALES) {
|
|
135
|
+
const text = manifest.i18n?.info[locale];
|
|
136
|
+
if (text?.displayname)
|
|
137
|
+
fields.push([`displayname_${DSM_LANGS[locale]}`, text.displayname]);
|
|
138
|
+
if (text?.description)
|
|
139
|
+
fields.push([`description_${DSM_LANGS[locale]}`, text.description]);
|
|
140
|
+
}
|
|
141
|
+
return fields.map(([key, value]) => `${key}=${quote(value)}\n`).join("");
|
|
142
|
+
}
|
|
143
|
+
function copyUiTree(source, target) {
|
|
144
|
+
for (const entry of ["app.js", "app.css"]) {
|
|
145
|
+
if (!existsSync(join(source, entry))) {
|
|
146
|
+
throw new StandaloneBuildError("STANDALONE_UI_ENTRY_MISSING", `UI 目錄缺少 ${entry}:${source}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
let total = 0;
|
|
150
|
+
const walk = (from, to) => {
|
|
151
|
+
mkdirSync(to, { recursive: true });
|
|
152
|
+
chmodSync(to, EXEC_MODE);
|
|
153
|
+
for (const name of readdirSync(from).sort()) {
|
|
154
|
+
const src = join(from, name);
|
|
155
|
+
const stat = lstatSync(src);
|
|
156
|
+
if (stat.isSymbolicLink()) {
|
|
157
|
+
throw new StandaloneBuildError("STANDALONE_UI_SYMLINK", `UI 目錄不可含 symlink:${src}`);
|
|
158
|
+
}
|
|
159
|
+
if (stat.isDirectory()) {
|
|
160
|
+
walk(src, join(to, name));
|
|
161
|
+
}
|
|
162
|
+
else if (stat.isFile()) {
|
|
163
|
+
total += stat.size;
|
|
164
|
+
if (total > MAX_UI_BYTES) {
|
|
165
|
+
throw new StandaloneBuildError("STANDALONE_UI_TOO_LARGE", "UI 目錄超過 64 MiB。");
|
|
166
|
+
}
|
|
167
|
+
copyFileSync(src, join(to, name));
|
|
168
|
+
chmodSync(join(to, name), FILE_MODE);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
throw new StandaloneBuildError("STANDALONE_UI_SPECIAL_FILE", `UI 目錄只可含一般檔案與目錄:${src}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
walk(source, target);
|
|
176
|
+
}
|
|
177
|
+
function digestTree(root) {
|
|
178
|
+
const hash = createHash("sha256");
|
|
179
|
+
const walk = (dir, prefix) => {
|
|
180
|
+
for (const name of readdirSync(dir).sort()) {
|
|
181
|
+
const path = join(dir, name);
|
|
182
|
+
if (lstatSync(path).isDirectory()) {
|
|
183
|
+
walk(path, `${prefix}${name}/`);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
hash.update(`${prefix}${name}\0`).update(readFileSync(path));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
walk(root, "");
|
|
191
|
+
return hash.digest("hex");
|
|
192
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
/** Both source execution and the published CLI resolve the same bundled templates. */
|
|
5
|
+
export function templatesRoot() {
|
|
6
|
+
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const distTemplates = join(moduleDir, "templates");
|
|
8
|
+
return existsSync(distTemplates) ? distTemplates : join(moduleDir, "..", "templates");
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//go:build linux
|
|
2
|
+
|
|
3
|
+
package main
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"os"
|
|
7
|
+
"os/exec"
|
|
8
|
+
"syscall"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
func dropFixtureUser(cmd *exec.Cmd) {
|
|
12
|
+
if os.Geteuid() == 0 {
|
|
13
|
+
cmd.SysProcAttr = &syscall.SysProcAttr{Credential: &syscall.Credential{Uid: 65534, Gid: 65534, Groups: []uint32{65534}}}
|
|
14
|
+
}
|
|
15
|
+
}
|