@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
package/dist/init.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { mkdirSync,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, join, relative } from "node:path";
|
|
3
|
+
import { templatesRoot } from "./template-paths.js";
|
|
4
4
|
const TEMPLATE_NAMES = [
|
|
5
5
|
"hello-web",
|
|
6
6
|
"hello-web-page",
|
|
7
7
|
"hello-files",
|
|
8
8
|
"compose-import",
|
|
9
|
-
"
|
|
9
|
+
"binary",
|
|
10
|
+
"native-go",
|
|
10
11
|
];
|
|
11
12
|
export function isTemplateName(value) {
|
|
12
13
|
return TEMPLATE_NAMES.includes(value);
|
|
@@ -14,19 +15,134 @@ export function isTemplateName(value) {
|
|
|
14
15
|
export function listTemplates() {
|
|
15
16
|
return [...TEMPLATE_NAMES];
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
/**
|
|
19
|
+
* native-go --privilege root: files laid over the native-go template, and the
|
|
20
|
+
* files they replace.
|
|
21
|
+
*/
|
|
22
|
+
const ROOT_OVERLAY = "native-go-root";
|
|
23
|
+
const ROOT_REPLACED = ["backend/internal/app/root_none.go"];
|
|
24
|
+
/** Templates whose identity is filled in at init (placeholders in these files). */
|
|
25
|
+
const SUBSTITUTED = {
|
|
26
|
+
"native-go": ["dsm-package.yaml", "README.md"],
|
|
27
|
+
};
|
|
28
|
+
const PACKAGE_ID = /^[A-Za-z][A-Za-z0-9]{1,63}$/;
|
|
29
|
+
/** npm never publishes files named .gitignore, so templates ship them as `gitignore`. */
|
|
30
|
+
const RENAMED = { gitignore: ".gitignore" };
|
|
31
|
+
function words(dir) {
|
|
32
|
+
return basename(dir).split(/[^A-Za-z0-9]+/).filter(Boolean);
|
|
33
|
+
}
|
|
34
|
+
function defaultPackageId(dir) {
|
|
35
|
+
const id = words(dir).map((w) => w[0].toUpperCase() + w.slice(1)).join("");
|
|
36
|
+
return PACKAGE_ID.test(id) ? id : "MyPackage";
|
|
37
|
+
}
|
|
38
|
+
function defaultDisplayName(dir) {
|
|
39
|
+
const name = words(dir).map((w) => w[0].toUpperCase() + w.slice(1)).join(" ");
|
|
40
|
+
return name || "My Package";
|
|
41
|
+
}
|
|
42
|
+
function templateFiles(root, dir = root) {
|
|
43
|
+
return readdirSync(dir).flatMap((name) => {
|
|
44
|
+
const path = join(dir, name);
|
|
45
|
+
return statSync(path).isDirectory() ? templateFiles(root, path) : [relative(root, path)];
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function targetName(file) {
|
|
49
|
+
return RENAMED[file] ?? file;
|
|
24
50
|
}
|
|
25
|
-
export function initFromTemplate(template, targetDir) {
|
|
51
|
+
export function initFromTemplate(template, targetDir, options = {}) {
|
|
26
52
|
const source = join(templatesRoot(), template);
|
|
27
53
|
if (!existsSync(source)) {
|
|
28
54
|
throw new Error(`找不到模板:${template}`);
|
|
29
55
|
}
|
|
56
|
+
const substitutions = substitutionsFor(template, targetDir, options);
|
|
57
|
+
const privilege = options.privilege ?? (options.integration ? "root" : "none");
|
|
58
|
+
const overlays = [
|
|
59
|
+
...(privilege === "root" ? [ROOT_OVERLAY] : []),
|
|
60
|
+
...(options.ui === "vue" ? ["native-go-vue"] : []),
|
|
61
|
+
...(options.integration ? ["native-go-integration"] : []),
|
|
62
|
+
...(options.integration === "better-auth" ? ["native-go-better-auth"] : []),
|
|
63
|
+
].map(name => join(templatesRoot(), name));
|
|
64
|
+
// Shared legal resources also live in the CLI package; only the template
|
|
65
|
+
// terms are an unconditional part of a generated project.
|
|
66
|
+
const shared = join(templatesRoot(), "_shared");
|
|
67
|
+
const files = [...templateFiles(source), "LICENSES/TEMPLATE.txt", ...overlays.flatMap(root => templateFiles(root)),
|
|
68
|
+
...(options.ui === "vue" ? ["frontend/third-party-notices.mjs"] : []),
|
|
69
|
+
...(options.integration === "better-auth" ? ["node/third-party-notices.mjs", ...templateFiles(join(shared, 'notice-overrides')).map(file => `node/notice-overrides/${file}`)] : [])];
|
|
70
|
+
const collisions = files.map(targetName).filter((file) => existsSync(join(targetDir, file)));
|
|
71
|
+
if (collisions.length > 0) {
|
|
72
|
+
throw new Error(`[INIT_TARGET_NOT_EMPTY] ${targetDir} 已有 ${collisions.join(", ")};init 不會覆蓋既有檔案。請改用空目錄。`);
|
|
73
|
+
}
|
|
30
74
|
mkdirSync(targetDir, { recursive: true });
|
|
31
75
|
cpSync(source, targetDir, { recursive: true });
|
|
76
|
+
mkdirSync(join(targetDir, "LICENSES"), { recursive: true });
|
|
77
|
+
cpSync(join(shared, "LICENSES/TEMPLATE.txt"), join(targetDir, "LICENSES/TEMPLATE.txt"));
|
|
78
|
+
for (const overlay of overlays)
|
|
79
|
+
cpSync(overlay, targetDir, { recursive: true });
|
|
80
|
+
for (const dir of [...(options.ui === "vue" ? ["frontend"] : []), ...(options.integration === "better-auth" ? ["node"] : [])]) {
|
|
81
|
+
cpSync(join(shared, "third-party-notices.mjs"), join(targetDir, dir, "third-party-notices.mjs"));
|
|
82
|
+
}
|
|
83
|
+
if (options.integration === "better-auth")
|
|
84
|
+
cpSync(join(shared, 'notice-overrides'), join(targetDir, 'node/notice-overrides'), { recursive: true });
|
|
85
|
+
if (privilege === "root")
|
|
86
|
+
ROOT_REPLACED.forEach(file => rmSync(join(targetDir, file)));
|
|
87
|
+
for (const [from, to] of Object.entries(RENAMED)) {
|
|
88
|
+
if (files.includes(from)) {
|
|
89
|
+
renameSync(join(targetDir, from), join(targetDir, to));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
for (const file of new Set([...(SUBSTITUTED[template] ?? []), ...overlays.flatMap(root => templateFiles(root))])) {
|
|
93
|
+
const path = join(targetDir, targetName(file));
|
|
94
|
+
let text = readFileSync(path, "utf8");
|
|
95
|
+
for (const [token, value] of Object.entries(substitutions)) {
|
|
96
|
+
text = text.replaceAll(token, value);
|
|
97
|
+
}
|
|
98
|
+
writeFileSync(path, text);
|
|
99
|
+
}
|
|
100
|
+
if (options.ui === "vue") {
|
|
101
|
+
const manifest = join(targetDir, "dsm-package.yaml");
|
|
102
|
+
writeFileSync(manifest, readFileSync(manifest, "utf8").replace(" dir: ui", " dir: frontend/dist\n build: {cwd: frontend, command: [npm, run, build]}"));
|
|
103
|
+
rmSync(join(targetDir, "ui"), { recursive: true });
|
|
104
|
+
}
|
|
105
|
+
if (options.integration === "better-auth")
|
|
106
|
+
rmSync(join(targetDir, "backend/internal/app/identity_none.go"));
|
|
107
|
+
if (options.integration) {
|
|
108
|
+
const mod = join(targetDir, "backend/go.mod");
|
|
109
|
+
writeFileSync(mod, readFileSync(mod, "utf8").replace("go 1.24", "go 1.25"));
|
|
110
|
+
const manifest = join(targetDir, "dsm-package.yaml");
|
|
111
|
+
writeFileSync(manifest, readFileSync(manifest, "utf8") + `\nintegration:\n protocol: ${options.integrationProtocol ?? 1}\n workers: {}\n` + (options.integration === "better-auth" ? " identity: better-auth\n" : "") + (options.dataAccess ? ` dataAccess: ${options.dataAccess}\n` : ""));
|
|
112
|
+
const routes = join(targetDir, "backend/internal/app/routes.go");
|
|
113
|
+
writeFileSync(routes, readFileSync(routes, "utf8").replace("return append(routes, cfg.rootRoutes()...)", "routes = append(routes, cfg.integrationRoutes()...)\n\treturn append(routes, cfg.rootRoutes()...)"));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function substitutionsFor(template, targetDir, options) {
|
|
117
|
+
if (options.privilege !== undefined && template !== "native-go") {
|
|
118
|
+
throw new Error("[INIT_PRIVILEGE_UNSUPPORTED] --privilege 只適用於 -t native-go。");
|
|
119
|
+
}
|
|
120
|
+
if ((options.ui !== undefined || options.integration !== undefined) && template !== "native-go")
|
|
121
|
+
throw new Error("[INIT_OPTIONS_UNSUPPORTED] --ui/--integration 只適用於 native-go。");
|
|
122
|
+
if (options.ui !== undefined && !["plain", "vue"].includes(options.ui))
|
|
123
|
+
throw new Error("[INIT_UI_INVALID] --ui 只接受 plain 或 vue。");
|
|
124
|
+
if (options.integration !== undefined && !["go", "better-auth"].includes(options.integration))
|
|
125
|
+
throw new Error("[INIT_INTEGRATION_INVALID] --integration 只接受 go 或 better-auth。");
|
|
126
|
+
if (options.dataAccess !== undefined && (!options.integration || options.integrationProtocol !== 2 || !["unavailable", "relaxed"].includes(options.dataAccess)))
|
|
127
|
+
throw new Error("[INIT_DATA_ACCESS_INVALID] --data-access 只接受 unavailable 或 relaxed,且需要 --integration 與 --integration-protocol 2;缺少已認證 adapter 仍拒絕 NAS 操作。");
|
|
128
|
+
if (options.integrationProtocol !== undefined && (!options.integration || ![1, 2].includes(options.integrationProtocol)))
|
|
129
|
+
throw new Error("[INIT_INTEGRATION_PROTOCOL_INVALID] --integration-protocol 只接受 1 或 2,且需要 --integration;protocol 2 不啟用 NAS data path。");
|
|
130
|
+
if (options.integration && (options.ui !== "vue" || options.privilege === "none"))
|
|
131
|
+
throw new Error("[INIT_INTEGRATION_OPTIONS] integration 需要 --ui vue 與 root privilege(自動選用)。");
|
|
132
|
+
const privilege = options.privilege ?? (options.integration ? "root" : "none");
|
|
133
|
+
if (privilege !== "none" && privilege !== "root") {
|
|
134
|
+
throw new Error(`[INIT_PRIVILEGE_INVALID] --privilege 只接受 none 或 root,收到「${String(privilege)}」。`);
|
|
135
|
+
}
|
|
136
|
+
if (!SUBSTITUTED[template]) {
|
|
137
|
+
return {};
|
|
138
|
+
}
|
|
139
|
+
const packageId = options.packageId ?? defaultPackageId(targetDir);
|
|
140
|
+
if (!PACKAGE_ID.test(packageId)) {
|
|
141
|
+
throw new Error(`[INIT_PACKAGE_INVALID] package「${packageId}」必須以英文字母開頭,只含英數字(2–64 字),例如 PhotoTagger。`);
|
|
142
|
+
}
|
|
143
|
+
const displayName = options.displayName ?? defaultDisplayName(targetDir);
|
|
144
|
+
if (displayName.trim() === "" || /[\r\n"\\]/.test(displayName)) {
|
|
145
|
+
throw new Error("[INIT_DISPLAY_NAME_INVALID] 顯示名稱必須是單行,且不含 \" 或 \\。");
|
|
146
|
+
}
|
|
147
|
+
return { __PACKAGE__: packageId, __DISPLAY_NAME__: displayName, __PRIVILEGE__: privilege };
|
|
32
148
|
}
|
package/dist/log.js
CHANGED
|
@@ -6,14 +6,13 @@ export async function followProjectLogs(options) {
|
|
|
6
6
|
return { ok: false, lines: [], diagnostics: { code: "NOT_INSTALLED" } };
|
|
7
7
|
}
|
|
8
8
|
const lines = await options.host.fetchContainerLogs(identity.packageId);
|
|
9
|
-
const info = await options.host.
|
|
9
|
+
const info = await options.host.getInstalledPackageState?.(identity.packageId);
|
|
10
10
|
return {
|
|
11
11
|
ok: true,
|
|
12
12
|
lines,
|
|
13
13
|
diagnostics: {
|
|
14
14
|
packageIdentity: identity.packageId,
|
|
15
|
-
|
|
16
|
-
readiness: info.readiness,
|
|
15
|
+
readiness: info?.status,
|
|
17
16
|
redacted: true,
|
|
18
17
|
},
|
|
19
18
|
};
|
package/dist/native/validate.js
CHANGED
|
@@ -11,7 +11,6 @@ function nativeSpan(file, doc, pathSegments, pathString) {
|
|
|
11
11
|
return { file, line: pos.line, column: pos.column, path: dotPath };
|
|
12
12
|
}
|
|
13
13
|
const HEX64_REGEX = /^[0-9a-fA-F]{64}$/;
|
|
14
|
-
const FORBIDDEN_SERVICE_FIELDS = ["user", "command", "pre_start", "post_start", "shell"];
|
|
15
14
|
export function validateNative(parsed, nativeFile, options = {}) {
|
|
16
15
|
const errors = [];
|
|
17
16
|
const profile = options.profile ?? "personal";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NativeArchFamily } from "../build-spk/dsm-arch.js";
|
|
2
|
+
import type { StandaloneError } from "./manifest.js";
|
|
3
|
+
/**
|
|
4
|
+
* Checks a prebuilt CGI before it is packaged: a regular file inside the
|
|
5
|
+
* project, a 64-bit little-endian ELF for `arch`, and statically linked
|
|
6
|
+
* (no PT_INTERP), because DSM models ship different libc versions.
|
|
7
|
+
* Returns undefined when the file is acceptable.
|
|
8
|
+
*/
|
|
9
|
+
export declare function checkCgiBinary(projectRoot: string, file: string, arch: NativeArchFamily): StandaloneError | undefined;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { closeSync, lstatSync, openSync, readSync, realpathSync } from "node:fs";
|
|
2
|
+
import { relative } from "node:path";
|
|
3
|
+
const ELF_MACHINE = { x86_64: 62, aarch64: 183 };
|
|
4
|
+
const PT_INTERP = 3;
|
|
5
|
+
const MAX_BINARY_BYTES = 256 * 1024 * 1024;
|
|
6
|
+
const HEADER_BYTES = 64 * 1024;
|
|
7
|
+
function fail(code, message) {
|
|
8
|
+
return { code, message };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Checks a prebuilt CGI before it is packaged: a regular file inside the
|
|
12
|
+
* project, a 64-bit little-endian ELF for `arch`, and statically linked
|
|
13
|
+
* (no PT_INTERP), because DSM models ship different libc versions.
|
|
14
|
+
* Returns undefined when the file is acceptable.
|
|
15
|
+
*/
|
|
16
|
+
export function checkCgiBinary(projectRoot, file, arch) {
|
|
17
|
+
let stat;
|
|
18
|
+
try {
|
|
19
|
+
stat = lstatSync(file);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return fail("STANDALONE_BINARY_MISSING", `找不到 ${arch} 的 backend 執行檔:${file}`);
|
|
23
|
+
}
|
|
24
|
+
if (!stat.isFile()) {
|
|
25
|
+
return fail("STANDALONE_BINARY_NOT_REGULAR", `${file} 必須是一般檔案(不可是 symlink 或目錄)。`);
|
|
26
|
+
}
|
|
27
|
+
const rel = relative(realpathSync(projectRoot), realpathSync(file));
|
|
28
|
+
if (rel.startsWith("..")) {
|
|
29
|
+
return fail("STANDALONE_PATH_OUTSIDE_PROJECT", `${file} 實際位於專案目錄之外。`);
|
|
30
|
+
}
|
|
31
|
+
if (stat.size > MAX_BINARY_BYTES) {
|
|
32
|
+
return fail("STANDALONE_BINARY_TOO_LARGE", `${file} 超過 256 MiB。`);
|
|
33
|
+
}
|
|
34
|
+
return checkElf(readHeader(file), file, arch);
|
|
35
|
+
}
|
|
36
|
+
function readHeader(file) {
|
|
37
|
+
const fd = openSync(file, "r");
|
|
38
|
+
try {
|
|
39
|
+
const buf = Buffer.alloc(HEADER_BYTES);
|
|
40
|
+
return buf.subarray(0, readSync(fd, buf, 0, HEADER_BYTES, 0));
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
closeSync(fd);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function checkElf(buf, file, arch) {
|
|
47
|
+
const notElf = fail("STANDALONE_BINARY_NOT_ELF", `${file} 不是 64-bit little-endian Linux ELF 執行檔。`);
|
|
48
|
+
if (buf.length < 64 || buf.toString("latin1", 0, 4) !== "\x7fELF" || buf[4] !== 2 || buf[5] !== 1) {
|
|
49
|
+
return notElf;
|
|
50
|
+
}
|
|
51
|
+
const machine = buf.readUInt16LE(18);
|
|
52
|
+
if (machine !== ELF_MACHINE[arch]) {
|
|
53
|
+
return fail("STANDALONE_BINARY_ARCH_MISMATCH", `${file} 的 ELF machine 是 ${machine},不是 ${arch}。`);
|
|
54
|
+
}
|
|
55
|
+
const phoff = Number(buf.readBigUInt64LE(32));
|
|
56
|
+
const phentsize = buf.readUInt16LE(54);
|
|
57
|
+
const phnum = buf.readUInt16LE(56);
|
|
58
|
+
if (phentsize < 4 || phoff + phentsize * phnum > buf.length) {
|
|
59
|
+
return notElf;
|
|
60
|
+
}
|
|
61
|
+
for (let i = 0; i < phnum; i++) {
|
|
62
|
+
if (buf.readUInt32LE(phoff + i * phentsize) === PT_INTERP) {
|
|
63
|
+
return fail("STANDALONE_BINARY_DYNAMIC", `${file} 是動態連結執行檔。請改用靜態連結(Go:CGO_ENABLED=0;Rust:*-unknown-linux-musl)。`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { NativeArchFamily } from "../build-spk/dsm-arch.js";
|
|
2
|
+
export interface CommandResult {
|
|
3
|
+
status: number | null;
|
|
4
|
+
stderr: string;
|
|
5
|
+
/** The program itself was not found. */
|
|
6
|
+
missing?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export type CommandRunner = (command: string, args: string[], options: {
|
|
9
|
+
cwd: string;
|
|
10
|
+
env: Record<string, string | undefined>;
|
|
11
|
+
}) => CommandResult;
|
|
12
|
+
export interface StandaloneBuildOptions {
|
|
13
|
+
root: string;
|
|
14
|
+
/** Defaults to every arch in the manifest. */
|
|
15
|
+
arches?: NativeArchFamily[];
|
|
16
|
+
/** Defaults to `<root>/dist`. */
|
|
17
|
+
outDir?: string;
|
|
18
|
+
run?: CommandRunner;
|
|
19
|
+
}
|
|
20
|
+
/** Argv only, never a shell; output streams to the terminal except stderr, which is also kept. */
|
|
21
|
+
export declare const runCommand: CommandRunner;
|
|
22
|
+
/** `build-spk` for a Standalone Package: build the UI, compile the CGI, pack one SPK per arch. */
|
|
23
|
+
export declare function buildStandalone(options: StandaloneBuildOptions): Promise<{
|
|
24
|
+
outputs: string[];
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { checkCgiBinary } from "./binary.js";
|
|
6
|
+
import { loadStandaloneManifest } from "./manifest.js";
|
|
7
|
+
import { assembleStandaloneSpk, StandaloneBuildError } from "./spk.js";
|
|
8
|
+
import { buildHelper } from "./helper.js";
|
|
9
|
+
import { buildDaemonControl } from "./daemon.js";
|
|
10
|
+
const GOARCH = { x86_64: "amd64", aarch64: "arm64" };
|
|
11
|
+
/** Argv only, never a shell; output streams to the terminal except stderr, which is also kept. */
|
|
12
|
+
export const runCommand = (command, args, options) => {
|
|
13
|
+
const result = spawnSync(command, args, {
|
|
14
|
+
cwd: options.cwd,
|
|
15
|
+
env: options.env,
|
|
16
|
+
stdio: ["ignore", "inherit", "pipe"],
|
|
17
|
+
encoding: "utf8",
|
|
18
|
+
});
|
|
19
|
+
if (result.stderr) {
|
|
20
|
+
process.stderr.write(result.stderr);
|
|
21
|
+
}
|
|
22
|
+
const missing = result.error?.code === "ENOENT";
|
|
23
|
+
return { status: result.status, stderr: result.stderr ?? "", missing };
|
|
24
|
+
};
|
|
25
|
+
/** `build-spk` for a Standalone Package: build the UI, compile the CGI, pack one SPK per arch. */
|
|
26
|
+
export async function buildStandalone(options) {
|
|
27
|
+
const loaded = loadStandaloneManifest(options.root);
|
|
28
|
+
if (!loaded.ok) {
|
|
29
|
+
const [first] = loaded.errors;
|
|
30
|
+
throw new StandaloneBuildError(first.code, loaded.errors.map((e) => `[${e.code}] ${e.message}`).join("\n"));
|
|
31
|
+
}
|
|
32
|
+
const manifest = loaded.manifest;
|
|
33
|
+
const run = options.run ?? runCommand;
|
|
34
|
+
const arches = options.arches ?? manifest.arches;
|
|
35
|
+
for (const arch of arches) {
|
|
36
|
+
if (!manifest.arches.includes(arch)) {
|
|
37
|
+
throw new StandaloneBuildError("STANDALONE_ARCH_NOT_DECLARED", `${arch} 不在 dsm-package.yaml 的 arches 內。`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
buildUi(manifest, run);
|
|
41
|
+
if (manifest.integration?.identity === "better-auth") {
|
|
42
|
+
const result = run("npm", ["run", "build"], { cwd: join(manifest.root, "node"), env: { ...process.env } });
|
|
43
|
+
if (result.missing || result.status !== 0)
|
|
44
|
+
throw new StandaloneBuildError("STANDALONE_IDENTITY_BUILD_FAILED", `Optional Better Auth build failed.\n${result.stderr}`);
|
|
45
|
+
}
|
|
46
|
+
const outDir = options.outDir ?? join(options.root, "dist");
|
|
47
|
+
const work = mkdtempSync(join(tmpdir(), "syno-standalone-build-"));
|
|
48
|
+
try {
|
|
49
|
+
const outputs = [];
|
|
50
|
+
for (const arch of arches) {
|
|
51
|
+
const helper = buildHelper(manifest, arch, work, run);
|
|
52
|
+
if (helper) {
|
|
53
|
+
const problem = checkCgiBinary(work, helper.binary, arch);
|
|
54
|
+
if (problem)
|
|
55
|
+
throw new StandaloneBuildError(problem.code, problem.message);
|
|
56
|
+
}
|
|
57
|
+
const cgiPath = backendFor(manifest, arch, work, run, helper);
|
|
58
|
+
const problem = checkCgiBinary(manifest.backend.kind === "go" ? work : manifest.root, cgiPath, arch);
|
|
59
|
+
if (problem) {
|
|
60
|
+
throw new StandaloneBuildError(problem.code, problem.message);
|
|
61
|
+
}
|
|
62
|
+
const outputPath = join(outDir, `${manifest.package}-${manifest.spkVersion}-${arch}.spk`);
|
|
63
|
+
const daemonControl = buildDaemonControl(manifest, arch, work, run);
|
|
64
|
+
const builtManifest = helper ? { ...manifest, rootOps: [...(manifest.rootOps ?? []), ...helper.ops] } : manifest;
|
|
65
|
+
await assembleStandaloneSpk({ manifest: builtManifest, arch, cgiPath, outputPath, helper, daemonControl });
|
|
66
|
+
outputs.push(outputPath);
|
|
67
|
+
}
|
|
68
|
+
return { outputs };
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
rmSync(work, { recursive: true, force: true });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function buildUi(manifest, run) {
|
|
75
|
+
const build = manifest.ui.build;
|
|
76
|
+
if (!build) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const [command, ...args] = build.command;
|
|
80
|
+
const result = run(command, args, { cwd: build.cwd, env: { ...process.env } });
|
|
81
|
+
if (result.missing || result.status !== 0) {
|
|
82
|
+
throw new StandaloneBuildError("STANDALONE_UI_BUILD_FAILED", `UI build(${build.command.join(" ")})失敗。\n${result.stderr}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function backendFor(manifest, arch, work, run, helper) {
|
|
86
|
+
const backend = manifest.backend;
|
|
87
|
+
if (backend.kind === "binary") {
|
|
88
|
+
return backend.files[arch];
|
|
89
|
+
}
|
|
90
|
+
const out = join(work, `api-${arch}.cgi`);
|
|
91
|
+
const ldflags = [
|
|
92
|
+
"-s",
|
|
93
|
+
"-w",
|
|
94
|
+
"-buildid=",
|
|
95
|
+
`-X main.packageID=${manifest.package}`,
|
|
96
|
+
`-X main.version=${manifest.spkVersion}`,
|
|
97
|
+
...(helper ? [`-X 'main.helperInventory=${JSON.stringify(helper.inventory)}'`] : []),
|
|
98
|
+
].join(" ");
|
|
99
|
+
const result = run("go", ["build", "-trimpath", "-buildvcs=false", "-ldflags", ldflags, "-o", out, backend.main], {
|
|
100
|
+
cwd: backend.dir,
|
|
101
|
+
env: { ...process.env, CGO_ENABLED: "0", GOOS: "linux", GOARCH: GOARCH[arch] },
|
|
102
|
+
});
|
|
103
|
+
if (result.missing) {
|
|
104
|
+
throw new StandaloneBuildError("STANDALONE_GO_MISSING", "找不到 go 指令。請安裝 Go 1.24 以上版本(https://go.dev/dl/),或改用 backend.binary 打包既有執行檔。");
|
|
105
|
+
}
|
|
106
|
+
if (result.status !== 0) {
|
|
107
|
+
throw new StandaloneBuildError("STANDALONE_GO_BUILD_FAILED", `go build(${arch})失敗。\n${result.stderr}`);
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NativeArchFamily } from "../build-spk/dsm-arch.js";
|
|
2
|
+
import type { CommandRunner } from "./build.js";
|
|
3
|
+
import type { StandaloneError, StandaloneManifest } from "./manifest.js";
|
|
4
|
+
export interface Daemon {
|
|
5
|
+
/** Fixed foreground executable relative to daemon/payload. */
|
|
6
|
+
exec: string;
|
|
7
|
+
/** Architecture-specific project directories, copied without links. */
|
|
8
|
+
targets: Partial<Record<NativeArchFamily, string>>;
|
|
9
|
+
args: string[];
|
|
10
|
+
/** Optional fixed executable argv, after stop, only on uninstall. */
|
|
11
|
+
uninstall_args?: string[];
|
|
12
|
+
/** The only application environment inherited beyond PATH/HOME/TMPDIR. */
|
|
13
|
+
env: Record<string, string>;
|
|
14
|
+
timeouts: {
|
|
15
|
+
start: number;
|
|
16
|
+
stop: number;
|
|
17
|
+
status: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare function readDaemon(value: unknown, root: string, arches: NativeArchFamily[], fail: (error: StandaloneError) => void): Daemon | undefined;
|
|
21
|
+
export declare function daemonConfig(manifest: StandaloneManifest): string;
|
|
22
|
+
export declare function buildDaemonControl(manifest: StandaloneManifest, arch: NativeArchFamily, work: string, run: CommandRunner): string | undefined;
|
|
23
|
+
export declare function copyDaemonPayload(manifest: StandaloneManifest, arch: NativeArchFamily, target: string, controller: string): void;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { chmodSync, copyFileSync, lstatSync, mkdirSync, readdirSync, realpathSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
3
|
+
import { templatesRoot } from "../template-paths.js";
|
|
4
|
+
import { checkCgiBinary } from "./binary.js";
|
|
5
|
+
import { StandaloneBuildError } from "./spk.js";
|
|
6
|
+
const fields = new Set(["exec", "targets", "args", "env", "timeouts", "uninstall_args"]);
|
|
7
|
+
const record = (v) => Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
8
|
+
const token = (v) => typeof v === "string" && Buffer.byteLength(v) <= 4096 && !v.includes("\0")
|
|
9
|
+
&& !v.replaceAll("${SYNOPKG_PKGDEST}", "").replaceAll("${SYNOPKG_PKGVAR}", "").includes("${");
|
|
10
|
+
const envKey = (k) => /^[A-Z][A-Z0-9_]{0,63}$/.test(k)
|
|
11
|
+
&& !/^(PATH|HOME|TMPDIR|ENV|BASH_ENV|SHELLOPTS|BASHOPTS|GODEBUG|GOTRACEBACK|LD_.*|DYLD_.*|SYNOPKG_.*)$/.test(k);
|
|
12
|
+
export function readDaemon(value, root, arches, fail) {
|
|
13
|
+
if (value === undefined)
|
|
14
|
+
return undefined;
|
|
15
|
+
const invalid = () => { fail({ code: "STANDALONE_DAEMON_INVALID", message: "daemon 只接受固定 exec、targets、args、env 與 timeouts;路徑須在專案內,環境不接受 loader/shell/system 變數。" }); return undefined; };
|
|
16
|
+
if (!record(value) || Object.keys(value).some(k => !fields.has(k)))
|
|
17
|
+
return invalid();
|
|
18
|
+
if (typeof value.exec !== "string" || !/^[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_.-]+)*$/.test(value.exec)
|
|
19
|
+
|| value.exec.split("/").some(p => p === "." || p === "..") || value.exec.length > 200)
|
|
20
|
+
return invalid();
|
|
21
|
+
if (!record(value.targets) || Object.keys(value.targets).length !== arches.length)
|
|
22
|
+
return invalid();
|
|
23
|
+
const targets = {};
|
|
24
|
+
for (const arch of arches) {
|
|
25
|
+
const path = value.targets[arch];
|
|
26
|
+
if (typeof path !== "string" || !path.trim() || path.includes("\0") || isAbsolute(path) || path.split(/[\\/]/).includes(".."))
|
|
27
|
+
return invalid();
|
|
28
|
+
const resolved = resolve(root, path), rel = relative(root, resolved);
|
|
29
|
+
if (!rel || rel.startsWith("..") || isAbsolute(rel))
|
|
30
|
+
return invalid();
|
|
31
|
+
targets[arch] = resolved;
|
|
32
|
+
}
|
|
33
|
+
const args = value.args ?? [];
|
|
34
|
+
if (!Array.isArray(args) || args.length > 64 || !args.every(token))
|
|
35
|
+
return invalid();
|
|
36
|
+
const uninstall = value.uninstall_args;
|
|
37
|
+
if (uninstall !== undefined && (!Array.isArray(uninstall) || !uninstall.length || uninstall.length > 64 || !uninstall.every(token)))
|
|
38
|
+
return invalid();
|
|
39
|
+
const env = value.env ?? {};
|
|
40
|
+
if (!record(env) || Object.keys(env).length > 64 || Object.entries(env).some(([k, v]) => !envKey(k) || !token(v)))
|
|
41
|
+
return invalid();
|
|
42
|
+
const limits = value.timeouts ?? {};
|
|
43
|
+
if (!record(limits) || Object.keys(limits).some(k => !["start", "stop", "status"].includes(k)))
|
|
44
|
+
return invalid();
|
|
45
|
+
const timeouts = { start: limits.start ?? 5, stop: limits.stop ?? 10, status: limits.status ?? 2 };
|
|
46
|
+
for (const [key, v] of Object.entries(timeouts)) {
|
|
47
|
+
if (!Number.isInteger(v) || v < (key === "start" ? 2 : key === "stop" ? 2 : 1) || v > (key === "status" ? 10 : 120))
|
|
48
|
+
return invalid();
|
|
49
|
+
}
|
|
50
|
+
return { exec: value.exec, targets, args, ...(uninstall ? { uninstall_args: uninstall } : {}), env: Object.fromEntries(Object.keys(env).sort().map(key => [key, env[key]])), timeouts: timeouts };
|
|
51
|
+
}
|
|
52
|
+
export function daemonConfig(manifest) {
|
|
53
|
+
const { exec, args, uninstall_args, env, timeouts } = manifest.daemon;
|
|
54
|
+
return JSON.stringify({ package: manifest.package, exec, args, ...(uninstall_args ? { uninstall_args } : {}), env, timeouts }) + "\n";
|
|
55
|
+
}
|
|
56
|
+
export function buildDaemonControl(manifest, arch, work, run) {
|
|
57
|
+
if (!manifest.daemon)
|
|
58
|
+
return undefined;
|
|
59
|
+
const out = join(work, `daemon-control-${arch}`);
|
|
60
|
+
const result = run("go", ["build", "-trimpath", "-buildvcs=false", "-ldflags", "-s -w -buildid=", "-o", out, "."], {
|
|
61
|
+
cwd: join(templatesRoot(), "_daemon"), env: { ...process.env, CGO_ENABLED: "0", GOOS: "linux", GOARCH: arch === "x86_64" ? "amd64" : "arm64" },
|
|
62
|
+
});
|
|
63
|
+
if (result.missing || result.status !== 0)
|
|
64
|
+
throw new StandaloneBuildError("STANDALONE_DAEMON_BUILD_FAILED", `daemon controller build 需要 Go 1.24 以上。\n${result.stderr}`);
|
|
65
|
+
const problem = checkCgiBinary(work, out, arch);
|
|
66
|
+
if (problem)
|
|
67
|
+
throw new StandaloneBuildError(problem.code, problem.message);
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
export function copyDaemonPayload(manifest, arch, target, controller) {
|
|
71
|
+
const daemon = manifest.daemon;
|
|
72
|
+
const source = daemon.targets[arch];
|
|
73
|
+
const invalid = (message) => { throw new StandaloneBuildError("STANDALONE_DAEMON_PAYLOAD_INVALID", message); };
|
|
74
|
+
let total = 0;
|
|
75
|
+
const walk = (from, to) => {
|
|
76
|
+
const stat = lstatSync(from);
|
|
77
|
+
const rel = relative(realpathSync(manifest.root), realpathSync(from));
|
|
78
|
+
if (rel.startsWith("..") || isAbsolute(rel) || stat.isSymbolicLink())
|
|
79
|
+
invalid(`daemon payload 路徑不可含 symlink 或跳出專案:${from}`);
|
|
80
|
+
if (stat.isDirectory()) {
|
|
81
|
+
mkdirSync(to, { recursive: true });
|
|
82
|
+
chmodSync(to, 0o755);
|
|
83
|
+
for (const name of readdirSync(from).sort())
|
|
84
|
+
walk(join(from, name), join(to, name));
|
|
85
|
+
}
|
|
86
|
+
else if (stat.isFile()) {
|
|
87
|
+
total += stat.size;
|
|
88
|
+
if (total > 512 * 1024 * 1024 || (stat.mode & 0o6000))
|
|
89
|
+
invalid(`daemon payload 不接受 setid 或超過 512 MiB:${from}`);
|
|
90
|
+
copyFileSync(from, to);
|
|
91
|
+
chmodSync(to, stat.mode & 0o111 ? 0o755 : 0o644);
|
|
92
|
+
}
|
|
93
|
+
else
|
|
94
|
+
invalid(`daemon payload 只接受一般檔案及目錄:${from}`);
|
|
95
|
+
};
|
|
96
|
+
try {
|
|
97
|
+
if (!lstatSync(source).isDirectory())
|
|
98
|
+
invalid("daemon.targets 必須指向目錄。");
|
|
99
|
+
walk(source, join(target, "payload"));
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (error instanceof StandaloneBuildError)
|
|
103
|
+
throw error;
|
|
104
|
+
invalid(`無法讀取 daemon payload:${String(error)}`);
|
|
105
|
+
}
|
|
106
|
+
const exec = join(source, daemon.exec);
|
|
107
|
+
const problem = checkCgiBinary(manifest.root, exec, arch);
|
|
108
|
+
if (problem)
|
|
109
|
+
throw new StandaloneBuildError(problem.code, problem.message);
|
|
110
|
+
chmodSync(join(target, "payload", daemon.exec), 0o755);
|
|
111
|
+
copyFileSync(controller, join(target, "control"));
|
|
112
|
+
chmodSync(join(target, "control"), 0o755);
|
|
113
|
+
writeFileSync(join(target, "config.json"), daemonConfig(manifest), { mode: 0o644 });
|
|
114
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StandaloneManifest } from "./manifest.js";
|
|
2
|
+
/** Same path the generated wrapper POSTs to, and the payload location of the CGI. */
|
|
3
|
+
export declare const CGI_PAYLOAD_PATH = "ui/cgi/api.cgi";
|
|
4
|
+
export declare function cgiUrl(packageId: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* `createI18n(dsmLang, catalogs)` → `{ locale, t }`, plain ES5 so it runs in
|
|
7
|
+
* DSM's desktop as is. The DSM language picks a shipped catalog (else
|
|
8
|
+
* English); missing keys fall back to English, then to the key itself.
|
|
9
|
+
* `t(key, { count })` looks up `key.one` / `key.other` via Intl.PluralRules.
|
|
10
|
+
*/
|
|
11
|
+
export declare const I18N_RUNTIME: string;
|
|
12
|
+
/**
|
|
13
|
+
* The wrapper file name carries the build so DSM never serves a wrapper
|
|
14
|
+
* cached from the previous version after an upgrade.
|
|
15
|
+
*/
|
|
16
|
+
export declare function windowScriptName(manifest: Pick<StandaloneManifest, "build">): string;
|
|
17
|
+
/** `ui/config`: registers the DSM main-menu app and its window class. */
|
|
18
|
+
export declare function renderUiConfig(manifest: StandaloneManifest): string;
|
|
19
|
+
/**
|
|
20
|
+
* The DSM AppWindow that hosts the project's UI. It loads app/app.js and
|
|
21
|
+
* app/app.css once, then calls the app's mount(root, ctx). `ctx.call` is the
|
|
22
|
+
* only transport: same-origin POST with DSM's session cookie and SynoToken.
|
|
23
|
+
* `ctx.t` / `ctx.locale` translate with the catalogs embedded at build time.
|
|
24
|
+
* `assetVersion` busts browser caches when the UI changes.
|
|
25
|
+
*/
|
|
26
|
+
export declare function renderWindowScript(manifest: StandaloneManifest, assetVersion: string): string;
|