@synopackageland/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +13 -0
  2. package/dist/attestation/app-package.d.ts +86 -0
  3. package/dist/attestation/app-package.js +199 -0
  4. package/dist/attestation/install-on-host.d.ts +14 -0
  5. package/dist/attestation/install-on-host.js +52 -0
  6. package/dist/attestation/keyring.d.ts +21 -0
  7. package/dist/attestation/keyring.js +168 -0
  8. package/dist/bin.d.ts +2 -0
  9. package/dist/bin.js +14 -0
  10. package/dist/build-spk/dsm-arch.d.ts +4 -0
  11. package/dist/build-spk/dsm-arch.js +32 -0
  12. package/dist/build-spk/dsm-icons.d.ts +2 -0
  13. package/dist/build-spk/dsm-icons.js +67 -0
  14. package/dist/build-spk/generator.d.ts +43 -0
  15. package/dist/build-spk/generator.js +653 -0
  16. package/dist/build-spk/native-payload.d.ts +22 -0
  17. package/dist/build-spk/native-payload.js +654 -0
  18. package/dist/build-spk/reproducible-archive.d.ts +8 -0
  19. package/dist/build-spk/reproducible-archive.js +34 -0
  20. package/dist/cli.d.ts +1 -0
  21. package/dist/cli.js +345 -0
  22. package/dist/compose/analyze.d.ts +25 -0
  23. package/dist/compose/analyze.js +346 -0
  24. package/dist/compose/env.d.ts +7 -0
  25. package/dist/compose/env.js +36 -0
  26. package/dist/compose/privilege.d.ts +14 -0
  27. package/dist/compose/privilege.js +102 -0
  28. package/dist/compose/runner.d.ts +32 -0
  29. package/dist/compose/runner.js +84 -0
  30. package/dist/contract/load.d.ts +25 -0
  31. package/dist/contract/load.js +87 -0
  32. package/dist/contract/schema-validate.d.ts +3 -0
  33. package/dist/contract/schema-validate.js +50 -0
  34. package/dist/contract/validate.d.ts +3 -0
  35. package/dist/contract/validate.js +80 -0
  36. package/dist/contract/web-launch.d.ts +19 -0
  37. package/dist/contract/web-launch.js +94 -0
  38. package/dist/deploy/catalog-publish.d.ts +3 -0
  39. package/dist/deploy/catalog-publish.js +7 -0
  40. package/dist/deploy/deploy.d.ts +22 -0
  41. package/dist/deploy/deploy.js +136 -0
  42. package/dist/deploy/identity-shared.d.ts +3 -0
  43. package/dist/deploy/identity-shared.js +14 -0
  44. package/dist/deploy/identity.d.ts +7 -0
  45. package/dist/deploy/identity.js +20 -0
  46. package/dist/deploy/package-source.d.ts +7 -0
  47. package/dist/deploy/package-source.js +17 -0
  48. package/dist/deploy/run-as-values.d.ts +18 -0
  49. package/dist/deploy/run-as-values.js +48 -0
  50. package/dist/deploy/share-values.d.ts +20 -0
  51. package/dist/deploy/share-values.js +60 -0
  52. package/dist/deploy/spk-info.d.ts +12 -0
  53. package/dist/deploy/spk-info.js +41 -0
  54. package/dist/deploy/spk-version.d.ts +4 -0
  55. package/dist/deploy/spk-version.js +64 -0
  56. package/dist/dev.d.ts +13 -0
  57. package/dist/dev.js +31 -0
  58. package/dist/discovery.d.ts +8 -0
  59. package/dist/discovery.js +22 -0
  60. package/dist/errors.d.ts +6 -0
  61. package/dist/errors.js +18 -0
  62. package/dist/host/broker-paths.d.ts +1 -0
  63. package/dist/host/broker-paths.js +1 -0
  64. package/dist/host/catalog-install.d.ts +59 -0
  65. package/dist/host/catalog-install.js +326 -0
  66. package/dist/host/credentials.d.ts +2 -0
  67. package/dist/host/credentials.js +37 -0
  68. package/dist/host/digests.d.ts +5 -0
  69. package/dist/host/digests.js +55 -0
  70. package/dist/host/dsm-client.d.ts +6 -0
  71. package/dist/host/dsm-client.js +290 -0
  72. package/dist/host/dsm-http.d.ts +1 -0
  73. package/dist/host/dsm-http.js +87 -0
  74. package/dist/host/fake-nas.d.ts +16 -0
  75. package/dist/host/fake-nas.js +116 -0
  76. package/dist/host/open-url.d.ts +5 -0
  77. package/dist/host/open-url.js +13 -0
  78. package/dist/host/share-lookup.d.ts +3 -0
  79. package/dist/host/share-lookup.js +144 -0
  80. package/dist/host/types.d.ts +67 -0
  81. package/dist/host/types.js +1 -0
  82. package/dist/index.d.ts +19 -0
  83. package/dist/index.js +14 -0
  84. package/dist/info.d.ts +17 -0
  85. package/dist/info.js +34 -0
  86. package/dist/init.d.ts +4 -0
  87. package/dist/init.js +31 -0
  88. package/dist/inspect.d.ts +13 -0
  89. package/dist/inspect.js +102 -0
  90. package/dist/load-env.d.ts +1 -0
  91. package/dist/load-env.js +31 -0
  92. package/dist/log.d.ts +13 -0
  93. package/dist/log.js +20 -0
  94. package/dist/mock-broker/bootstrap.d.ts +2 -0
  95. package/dist/mock-broker/bootstrap.js +8 -0
  96. package/dist/mock-broker/files.d.ts +60 -0
  97. package/dist/mock-broker/files.js +408 -0
  98. package/dist/mock-broker/oidc.d.ts +31 -0
  99. package/dist/mock-broker/oidc.js +161 -0
  100. package/dist/mock-broker/path.d.ts +9 -0
  101. package/dist/mock-broker/path.js +50 -0
  102. package/dist/mock-broker/server.d.ts +19 -0
  103. package/dist/mock-broker/server.js +350 -0
  104. package/dist/publish/build-ledger.d.ts +22 -0
  105. package/dist/publish/build-ledger.js +26 -0
  106. package/dist/publish/community-path.d.ts +6 -0
  107. package/dist/publish/community-path.js +41 -0
  108. package/dist/publish/curated-release.d.ts +78 -0
  109. package/dist/publish/curated-release.js +693 -0
  110. package/dist/publish/file-build-ledger.d.ts +18 -0
  111. package/dist/publish/file-build-ledger.js +268 -0
  112. package/dist/publish/github-pr.d.ts +25 -0
  113. package/dist/publish/github-pr.js +85 -0
  114. package/dist/publish/github-repo.d.ts +8 -0
  115. package/dist/publish/github-repo.js +21 -0
  116. package/dist/publish/publish.d.ts +23 -0
  117. package/dist/publish/publish.js +128 -0
  118. package/dist/publish/sync-definition.d.ts +4 -0
  119. package/dist/publish/sync-definition.js +48 -0
  120. package/dist/skill.d.ts +10 -0
  121. package/dist/skill.js +50 -0
  122. package/dist/templates/compose-import/compose.yaml +11 -0
  123. package/dist/templates/compose-import/synology-app.yaml +15 -0
  124. package/dist/templates/hello-files/com.synology.hello.files.dev.spk +0 -0
  125. package/dist/templates/hello-files/compose.yaml +8 -0
  126. package/dist/templates/hello-files/synology-app.yaml +13 -0
  127. package/dist/templates/hello-web/compose.yaml +7 -0
  128. package/dist/templates/hello-web/html/app.js +23 -0
  129. package/dist/templates/hello-web/html/index.html +15 -0
  130. package/dist/templates/hello-web/html/sdk.js +68 -0
  131. package/dist/templates/hello-web/synology-app.yaml +13 -0
  132. package/dist/templates/hello-web-page/com.synology.hello.web.page.dev.spk +0 -0
  133. package/dist/templates/hello-web-page/compose.yaml +7 -0
  134. package/dist/templates/hello-web-page/html/app.js +23 -0
  135. package/dist/templates/hello-web-page/html/index.html +15 -0
  136. package/dist/templates/hello-web-page/html/sdk.js +68 -0
  137. package/dist/templates/hello-web-page/synology-app.yaml +13 -0
  138. package/dist/test-command.d.ts +13 -0
  139. package/dist/test-command.js +26 -0
  140. package/dist/test-host.d.ts +13 -0
  141. package/dist/test-host.js +24 -0
  142. package/dist/types.d.ts +59 -0
  143. package/dist/types.js +1 -0
  144. package/dist/validate.d.ts +8 -0
  145. package/dist/validate.js +103 -0
  146. package/package.json +38 -0
  147. package/schema/synology-app.schema.json +137 -0
  148. package/skills/SKILL.md +51 -0
  149. package/skills/reference/create.md +34 -0
  150. package/skills/reference/deploy.md +41 -0
  151. package/skills/reference/diagnose.md +42 -0
  152. package/skills/reference/files.md +37 -0
  153. package/skills/reference/identity.md +31 -0
  154. package/skills/reference/wrap.md +35 -0
  155. package/templates/compose-import/compose.yaml +11 -0
  156. package/templates/compose-import/synology-app.yaml +15 -0
  157. package/templates/hello-files/com.synology.hello.files.dev.spk +0 -0
  158. package/templates/hello-files/compose.yaml +8 -0
  159. package/templates/hello-files/synology-app.yaml +13 -0
  160. package/templates/hello-web/compose.yaml +7 -0
  161. package/templates/hello-web/html/app.js +23 -0
  162. package/templates/hello-web/html/index.html +15 -0
  163. package/templates/hello-web/html/sdk.js +68 -0
  164. package/templates/hello-web/synology-app.yaml +13 -0
  165. package/templates/hello-web-page/com.synology.hello.web.page.dev.spk +0 -0
  166. package/templates/hello-web-page/compose.yaml +7 -0
  167. package/templates/hello-web-page/html/app.js +23 -0
  168. package/templates/hello-web-page/html/index.html +15 -0
  169. package/templates/hello-web-page/html/sdk.js +68 -0
  170. package/templates/hello-web-page/synology-app.yaml +13 -0
@@ -0,0 +1,67 @@
1
+ import { deflateSync } from "node:zlib";
2
+ import { chmodSync, mkdirSync, writeFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ const ICON_SIZES = [16, 24, 32, 48, 64, 72, 256];
5
+ const ICON_RGB = [0x1a, 0x73, 0xe8];
6
+ function crc32(data) {
7
+ let crc = 0xffffffff;
8
+ for (const byte of data) {
9
+ crc ^= byte;
10
+ for (let i = 0; i < 8; i++) {
11
+ crc = (crc >>> 1) ^ (crc & 1 ? 0xedb88320 : 0);
12
+ }
13
+ }
14
+ return (crc ^ 0xffffffff) >>> 0;
15
+ }
16
+ function pngChunk(type, data) {
17
+ const length = Buffer.alloc(4);
18
+ length.writeUInt32BE(data.length);
19
+ const typeBuf = Buffer.from(type, "ascii");
20
+ const crc = Buffer.alloc(4);
21
+ crc.writeUInt32BE(crc32(Buffer.concat([typeBuf, data])));
22
+ return Buffer.concat([length, typeBuf, data, crc]);
23
+ }
24
+ function solidPng(size) {
25
+ const stride = size * 3 + 1;
26
+ const raw = Buffer.alloc(stride * size);
27
+ for (let y = 0; y < size; y++) {
28
+ const row = y * stride;
29
+ raw[row] = 0;
30
+ for (let x = 0; x < size; x++) {
31
+ const i = row + 1 + x * 3;
32
+ raw[i] = ICON_RGB[0];
33
+ raw[i + 1] = ICON_RGB[1];
34
+ raw[i + 2] = ICON_RGB[2];
35
+ }
36
+ }
37
+ const ihdr = Buffer.alloc(13);
38
+ ihdr.writeUInt32BE(size, 0);
39
+ ihdr.writeUInt32BE(size, 4);
40
+ ihdr[8] = 8;
41
+ ihdr[9] = 2;
42
+ return Buffer.concat([
43
+ Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]),
44
+ pngChunk("IHDR", ihdr),
45
+ pngChunk("IDAT", deflateSync(raw, { level: 9 })),
46
+ pngChunk("IEND", Buffer.alloc(0)),
47
+ ]);
48
+ }
49
+ export function writeDsmWindowIcons(uiDir) {
50
+ const imagesDir = join(uiDir, "images");
51
+ mkdirSync(imagesDir, { recursive: true });
52
+ for (const size of ICON_SIZES) {
53
+ const path = join(imagesDir, `app_${size}.png`);
54
+ writeFileSync(path, solidPng(size));
55
+ chmodSync(path, 0o644);
56
+ }
57
+ }
58
+ export function writePackageCenterIcons(spkRoot) {
59
+ for (const [name, size] of [
60
+ ["PACKAGE_ICON.PNG", 64],
61
+ ["PACKAGE_ICON_256.PNG", 256],
62
+ ]) {
63
+ const path = join(spkRoot, name);
64
+ writeFileSync(path, solidPng(size));
65
+ chmodSync(path, 0o644);
66
+ }
67
+ }
@@ -0,0 +1,43 @@
1
+ import type { ProjectRoot } from "../discovery.js";
2
+ import { type NativeArchFamily } from "./dsm-arch.js";
3
+ export declare const EMBEDDED_ATTESTATION_RELATIVE_PATH = ".synopkgland/attestation.jwt";
4
+ export interface BuildSpkOptions {
5
+ project: ProjectRoot;
6
+ outputPath?: string;
7
+ archFamily?: NativeArchFamily;
8
+ packageIdentity?: string;
9
+ displayname?: string;
10
+ /** Overrides contract version before INFO is rendered (e.g. `1.0.0-0002`). */
11
+ spkVersion?: string;
12
+ /** v2 Curated App Package Attestation to place in the App Bundle. */
13
+ embeddedAttestationToken?: string;
14
+ }
15
+ export interface BuildSpkResult {
16
+ ok: boolean;
17
+ outputPath?: string;
18
+ errors: string[];
19
+ }
20
+ export declare function buildSpk(options: BuildSpkOptions): Promise<BuildSpkResult>;
21
+ export declare function digestSpkPayload(spkPath: string): Promise<string>;
22
+ export declare function extractSpk(spkPath: string, targetDir: string): Promise<void>;
23
+ export declare function readInfoPackage(spkDir: string): string | null;
24
+ export declare function collectWizardTexts(spkDir: string): string;
25
+ export declare function readInstallWizard(spkDir: string): {
26
+ items: Array<{
27
+ type?: string;
28
+ desc?: string;
29
+ subitems?: Array<{
30
+ key: string;
31
+ }>;
32
+ }>;
33
+ };
34
+ export declare function readUpgradeWizard(spkDir: string): {
35
+ items: Array<{
36
+ type?: string;
37
+ desc?: string;
38
+ subitems?: Array<{
39
+ key: string;
40
+ }>;
41
+ }>;
42
+ };
43
+ export declare function scriptModeInSpk(spkDir: string, scriptName: string): number;