@invarn/cibuild 1.3.16 → 1.3.18

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 (242) hide show
  1. package/dist/cli.cjs +1 -1
  2. package/dist/src/cli.d.ts +3 -0
  3. package/dist/src/cli.d.ts.map +1 -0
  4. package/dist/src/cli.js +987 -0
  5. package/dist/src/commands/android-scanner.d.ts +32 -0
  6. package/dist/src/commands/android-scanner.d.ts.map +1 -0
  7. package/dist/src/commands/android-scanner.js +667 -0
  8. package/dist/src/commands/build.d.ts +5 -0
  9. package/dist/src/commands/build.d.ts.map +1 -0
  10. package/dist/src/commands/build.js +1096 -0
  11. package/dist/src/commands/edit.d.ts +3 -0
  12. package/dist/src/commands/edit.d.ts.map +1 -0
  13. package/dist/src/commands/edit.js +651 -0
  14. package/dist/src/commands/file-secret-collector.d.ts +37 -0
  15. package/dist/src/commands/file-secret-collector.d.ts.map +1 -0
  16. package/dist/src/commands/file-secret-collector.js +199 -0
  17. package/dist/src/commands/github-workflow.d.ts +5 -0
  18. package/dist/src/commands/github-workflow.d.ts.map +1 -0
  19. package/dist/src/commands/github-workflow.js +45 -0
  20. package/dist/src/commands/ios-scanner.d.ts +27 -0
  21. package/dist/src/commands/ios-scanner.d.ts.map +1 -0
  22. package/dist/src/commands/ios-scanner.js +337 -0
  23. package/dist/src/commands/reset.d.ts +7 -0
  24. package/dist/src/commands/reset.d.ts.map +1 -0
  25. package/dist/src/commands/reset.js +81 -0
  26. package/dist/src/commands/secrets-sync-workflow.d.ts +15 -0
  27. package/dist/src/commands/secrets-sync-workflow.d.ts.map +1 -0
  28. package/dist/src/commands/secrets-sync-workflow.js +255 -0
  29. package/dist/src/commands/secrets-upload.d.ts +21 -0
  30. package/dist/src/commands/secrets-upload.d.ts.map +1 -0
  31. package/dist/src/commands/secrets-upload.js +177 -0
  32. package/dist/src/commands/secrets-upload.test.d.ts +5 -0
  33. package/dist/src/commands/secrets-upload.test.d.ts.map +1 -0
  34. package/dist/src/commands/secrets-upload.test.js +60 -0
  35. package/dist/src/config.d.ts +3 -0
  36. package/dist/src/config.d.ts.map +1 -0
  37. package/dist/src/config.js +47 -0
  38. package/dist/src/envman/cli.d.ts +21 -0
  39. package/dist/src/envman/cli.d.ts.map +1 -0
  40. package/dist/src/envman/cli.js +240 -0
  41. package/dist/src/envman/envman.d.ts +83 -0
  42. package/dist/src/envman/envman.d.ts.map +1 -0
  43. package/dist/src/envman/envman.js +361 -0
  44. package/dist/src/envman/envman.test.d.ts +5 -0
  45. package/dist/src/envman/envman.test.d.ts.map +1 -0
  46. package/dist/src/envman/envman.test.js +236 -0
  47. package/dist/src/envman/index.d.ts +23 -0
  48. package/dist/src/envman/index.d.ts.map +1 -0
  49. package/dist/src/envman/index.js +23 -0
  50. package/dist/src/envman/types.d.ts +55 -0
  51. package/dist/src/envman/types.d.ts.map +1 -0
  52. package/dist/src/envman/types.js +12 -0
  53. package/dist/src/lib.d.ts +27 -0
  54. package/dist/src/lib.d.ts.map +1 -0
  55. package/dist/src/lib.js +32 -0
  56. package/dist/src/pipeline.d.ts +3 -0
  57. package/dist/src/pipeline.d.ts.map +1 -0
  58. package/dist/src/pipeline.js +57 -0
  59. package/dist/src/runner.d.ts +17 -0
  60. package/dist/src/runner.d.ts.map +1 -0
  61. package/dist/src/runner.js +234 -0
  62. package/dist/src/types.d.ts +58 -0
  63. package/dist/src/types.d.ts.map +1 -0
  64. package/dist/src/types.js +2 -0
  65. package/dist/src/yaml/bitrise-compat.d.ts +65 -0
  66. package/dist/src/yaml/bitrise-compat.d.ts.map +1 -0
  67. package/dist/src/yaml/bitrise-compat.js +206 -0
  68. package/dist/src/yaml/bitrise-compat.test.d.ts +5 -0
  69. package/dist/src/yaml/bitrise-compat.test.d.ts.map +1 -0
  70. package/dist/src/yaml/bitrise-compat.test.js +347 -0
  71. package/dist/src/yaml/converter.d.ts +33 -0
  72. package/dist/src/yaml/converter.d.ts.map +1 -0
  73. package/dist/src/yaml/converter.js +222 -0
  74. package/dist/src/yaml/converter.test.d.ts +5 -0
  75. package/dist/src/yaml/converter.test.d.ts.map +1 -0
  76. package/dist/src/yaml/converter.test.js +348 -0
  77. package/dist/src/yaml/e2e.test.d.ts +6 -0
  78. package/dist/src/yaml/e2e.test.d.ts.map +1 -0
  79. package/dist/src/yaml/e2e.test.js +446 -0
  80. package/dist/src/yaml/env-resolver.d.ts +120 -0
  81. package/dist/src/yaml/env-resolver.d.ts.map +1 -0
  82. package/dist/src/yaml/env-resolver.js +405 -0
  83. package/dist/src/yaml/env-resolver.test.d.ts +5 -0
  84. package/dist/src/yaml/env-resolver.test.d.ts.map +1 -0
  85. package/dist/src/yaml/env-resolver.test.js +502 -0
  86. package/dist/src/yaml/interactive-prompts.d.ts +71 -0
  87. package/dist/src/yaml/interactive-prompts.d.ts.map +1 -0
  88. package/dist/src/yaml/interactive-prompts.js +258 -0
  89. package/dist/src/yaml/missing-env-handler.d.ts +45 -0
  90. package/dist/src/yaml/missing-env-handler.d.ts.map +1 -0
  91. package/dist/src/yaml/missing-env-handler.js +64 -0
  92. package/dist/src/yaml/parser.d.ts +33 -0
  93. package/dist/src/yaml/parser.d.ts.map +1 -0
  94. package/dist/src/yaml/parser.js +145 -0
  95. package/dist/src/yaml/pipeline-with-secrets.d.ts +25 -0
  96. package/dist/src/yaml/pipeline-with-secrets.d.ts.map +1 -0
  97. package/dist/src/yaml/pipeline-with-secrets.js +76 -0
  98. package/dist/src/yaml/platform-detector.d.ts +83 -0
  99. package/dist/src/yaml/platform-detector.d.ts.map +1 -0
  100. package/dist/src/yaml/platform-detector.js +188 -0
  101. package/dist/src/yaml/platform-detector.test.d.ts +5 -0
  102. package/dist/src/yaml/platform-detector.test.d.ts.map +1 -0
  103. package/dist/src/yaml/platform-detector.test.js +414 -0
  104. package/dist/src/yaml/preflight-validation.d.ts +40 -0
  105. package/dist/src/yaml/preflight-validation.d.ts.map +1 -0
  106. package/dist/src/yaml/preflight-validation.js +152 -0
  107. package/dist/src/yaml/secrets-manager.d.ts +77 -0
  108. package/dist/src/yaml/secrets-manager.d.ts.map +1 -0
  109. package/dist/src/yaml/secrets-manager.js +219 -0
  110. package/dist/src/yaml/step-validator.d.ts +54 -0
  111. package/dist/src/yaml/step-validator.d.ts.map +1 -0
  112. package/dist/src/yaml/step-validator.js +403 -0
  113. package/dist/src/yaml/steps/android-sign.d.ts +35 -0
  114. package/dist/src/yaml/steps/android-sign.d.ts.map +1 -0
  115. package/dist/src/yaml/steps/android-sign.js +147 -0
  116. package/dist/src/yaml/steps/android-version.d.ts +26 -0
  117. package/dist/src/yaml/steps/android-version.d.ts.map +1 -0
  118. package/dist/src/yaml/steps/android-version.js +128 -0
  119. package/dist/src/yaml/steps/android-version.test.d.ts +5 -0
  120. package/dist/src/yaml/steps/android-version.test.d.ts.map +1 -0
  121. package/dist/src/yaml/steps/android-version.test.js +196 -0
  122. package/dist/src/yaml/steps/android.d.ts +95 -0
  123. package/dist/src/yaml/steps/android.d.ts.map +1 -0
  124. package/dist/src/yaml/steps/android.js +916 -0
  125. package/dist/src/yaml/steps/app-store-deploy.d.ts +48 -0
  126. package/dist/src/yaml/steps/app-store-deploy.d.ts.map +1 -0
  127. package/dist/src/yaml/steps/app-store-deploy.js +162 -0
  128. package/dist/src/yaml/steps/base.d.ts +238 -0
  129. package/dist/src/yaml/steps/base.d.ts.map +1 -0
  130. package/dist/src/yaml/steps/base.js +345 -0
  131. package/dist/src/yaml/steps/bitrise-android-tools.d.ts +26 -0
  132. package/dist/src/yaml/steps/bitrise-android-tools.d.ts.map +1 -0
  133. package/dist/src/yaml/steps/bitrise-android-tools.js +198 -0
  134. package/dist/src/yaml/steps/bitrise-android-tools.test.d.ts +5 -0
  135. package/dist/src/yaml/steps/bitrise-android-tools.test.d.ts.map +1 -0
  136. package/dist/src/yaml/steps/bitrise-android-tools.test.js +280 -0
  137. package/dist/src/yaml/steps/bitrise-apk-info.d.ts +22 -0
  138. package/dist/src/yaml/steps/bitrise-apk-info.d.ts.map +1 -0
  139. package/dist/src/yaml/steps/bitrise-apk-info.js +144 -0
  140. package/dist/src/yaml/steps/bitrise-apk-info.test.d.ts +5 -0
  141. package/dist/src/yaml/steps/bitrise-apk-info.test.d.ts.map +1 -0
  142. package/dist/src/yaml/steps/bitrise-apk-info.test.js +331 -0
  143. package/dist/src/yaml/steps/bitrise-slack.d.ts +49 -0
  144. package/dist/src/yaml/steps/bitrise-slack.d.ts.map +1 -0
  145. package/dist/src/yaml/steps/bitrise-slack.js +280 -0
  146. package/dist/src/yaml/steps/bitrise-slack.test.d.ts +5 -0
  147. package/dist/src/yaml/steps/bitrise-slack.test.d.ts.map +1 -0
  148. package/dist/src/yaml/steps/bitrise-slack.test.js +484 -0
  149. package/dist/src/yaml/steps/bitrise-ssh.d.ts +27 -0
  150. package/dist/src/yaml/steps/bitrise-ssh.d.ts.map +1 -0
  151. package/dist/src/yaml/steps/bitrise-ssh.js +134 -0
  152. package/dist/src/yaml/steps/bitrise-ssh.test.d.ts +5 -0
  153. package/dist/src/yaml/steps/bitrise-ssh.test.d.ts.map +1 -0
  154. package/dist/src/yaml/steps/bitrise-ssh.test.js +205 -0
  155. package/dist/src/yaml/steps/cache.d.ts +52 -0
  156. package/dist/src/yaml/steps/cache.d.ts.map +1 -0
  157. package/dist/src/yaml/steps/cache.js +352 -0
  158. package/dist/src/yaml/steps/fastlane.d.ts +27 -0
  159. package/dist/src/yaml/steps/fastlane.d.ts.map +1 -0
  160. package/dist/src/yaml/steps/fastlane.js +79 -0
  161. package/dist/src/yaml/steps/file.d.ts +27 -0
  162. package/dist/src/yaml/steps/file.d.ts.map +1 -0
  163. package/dist/src/yaml/steps/file.js +35 -0
  164. package/dist/src/yaml/steps/flutter.d.ts +63 -0
  165. package/dist/src/yaml/steps/flutter.d.ts.map +1 -0
  166. package/dist/src/yaml/steps/flutter.js +215 -0
  167. package/dist/src/yaml/steps/git-clone.d.ts +26 -0
  168. package/dist/src/yaml/steps/git-clone.d.ts.map +1 -0
  169. package/dist/src/yaml/steps/git-clone.js +111 -0
  170. package/dist/src/yaml/steps/google-play-deploy.d.ts +37 -0
  171. package/dist/src/yaml/steps/google-play-deploy.d.ts.map +1 -0
  172. package/dist/src/yaml/steps/google-play-deploy.js +193 -0
  173. package/dist/src/yaml/steps/google-play-deploy.test.d.ts +5 -0
  174. package/dist/src/yaml/steps/google-play-deploy.test.d.ts.map +1 -0
  175. package/dist/src/yaml/steps/google-play-deploy.test.js +310 -0
  176. package/dist/src/yaml/steps/index.d.ts +10 -0
  177. package/dist/src/yaml/steps/index.d.ts.map +1 -0
  178. package/dist/src/yaml/steps/index.js +1361 -0
  179. package/dist/src/yaml/steps/ios-deps.d.ts +43 -0
  180. package/dist/src/yaml/steps/ios-deps.d.ts.map +1 -0
  181. package/dist/src/yaml/steps/ios-deps.js +141 -0
  182. package/dist/src/yaml/steps/ios-deps.test.d.ts +5 -0
  183. package/dist/src/yaml/steps/ios-deps.test.d.ts.map +1 -0
  184. package/dist/src/yaml/steps/ios-deps.test.js +90 -0
  185. package/dist/src/yaml/steps/ios-signing.d.ts +31 -0
  186. package/dist/src/yaml/steps/ios-signing.d.ts.map +1 -0
  187. package/dist/src/yaml/steps/ios-signing.js +144 -0
  188. package/dist/src/yaml/steps/ios-version.d.ts +47 -0
  189. package/dist/src/yaml/steps/ios-version.d.ts.map +1 -0
  190. package/dist/src/yaml/steps/ios-version.js +151 -0
  191. package/dist/src/yaml/steps/linting.d.ts +47 -0
  192. package/dist/src/yaml/steps/linting.d.ts.map +1 -0
  193. package/dist/src/yaml/steps/linting.js +148 -0
  194. package/dist/src/yaml/steps/phase2.test.d.ts +6 -0
  195. package/dist/src/yaml/steps/phase2.test.d.ts.map +1 -0
  196. package/dist/src/yaml/steps/phase2.test.js +197 -0
  197. package/dist/src/yaml/steps/phase3.test.d.ts +5 -0
  198. package/dist/src/yaml/steps/phase3.test.d.ts.map +1 -0
  199. package/dist/src/yaml/steps/phase3.test.js +144 -0
  200. package/dist/src/yaml/steps/phase4.test.d.ts +5 -0
  201. package/dist/src/yaml/steps/phase4.test.d.ts.map +1 -0
  202. package/dist/src/yaml/steps/phase4.test.js +166 -0
  203. package/dist/src/yaml/steps/phase5.test.d.ts +6 -0
  204. package/dist/src/yaml/steps/phase5.test.d.ts.map +1 -0
  205. package/dist/src/yaml/steps/phase5.test.js +263 -0
  206. package/dist/src/yaml/steps/registry.d.ts +88 -0
  207. package/dist/src/yaml/steps/registry.d.ts.map +1 -0
  208. package/dist/src/yaml/steps/registry.js +125 -0
  209. package/dist/src/yaml/steps/registry.test.d.ts +5 -0
  210. package/dist/src/yaml/steps/registry.test.d.ts.map +1 -0
  211. package/dist/src/yaml/steps/registry.test.js +235 -0
  212. package/dist/src/yaml/steps/release.d.ts +50 -0
  213. package/dist/src/yaml/steps/release.d.ts.map +1 -0
  214. package/dist/src/yaml/steps/release.js +154 -0
  215. package/dist/src/yaml/steps/script.d.ts +23 -0
  216. package/dist/src/yaml/steps/script.d.ts.map +1 -0
  217. package/dist/src/yaml/steps/script.js +63 -0
  218. package/dist/src/yaml/steps/spec-validation.test.d.ts +6 -0
  219. package/dist/src/yaml/steps/spec-validation.test.d.ts.map +1 -0
  220. package/dist/src/yaml/steps/spec-validation.test.js +130 -0
  221. package/dist/src/yaml/steps/steps.test.d.ts +6 -0
  222. package/dist/src/yaml/steps/steps.test.d.ts.map +1 -0
  223. package/dist/src/yaml/steps/steps.test.js +505 -0
  224. package/dist/src/yaml/steps/test-config.d.ts +3 -0
  225. package/dist/src/yaml/steps/test-config.d.ts.map +1 -0
  226. package/dist/src/yaml/steps/test-config.js +17 -0
  227. package/dist/src/yaml/steps/xcode-new.test.d.ts +5 -0
  228. package/dist/src/yaml/steps/xcode-new.test.d.ts.map +1 -0
  229. package/dist/src/yaml/steps/xcode-new.test.js +211 -0
  230. package/dist/src/yaml/steps/xcode.d.ts +222 -0
  231. package/dist/src/yaml/steps/xcode.d.ts.map +1 -0
  232. package/dist/src/yaml/steps/xcode.js +999 -0
  233. package/dist/src/yaml/types.d.ts +68 -0
  234. package/dist/src/yaml/types.d.ts.map +1 -0
  235. package/dist/src/yaml/types.js +5 -0
  236. package/dist/src/yaml/validation-types.d.ts +96 -0
  237. package/dist/src/yaml/validation-types.d.ts.map +1 -0
  238. package/dist/src/yaml/validation-types.js +8 -0
  239. package/dist/src/yaml/yaml-updater.d.ts +24 -0
  240. package/dist/src/yaml/yaml-updater.d.ts.map +1 -0
  241. package/dist/src/yaml/yaml-updater.js +128 -0
  242. package/package.json +16 -4
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Universal secrets management for CI Build
3
+ * Stores sensitive values by exact variable name — no UUIDs, no YAML modification
4
+ * Supports per-workflow scoping with global fallback
5
+ *
6
+ * File format:
7
+ * {
8
+ * "global": { "VAR_NAME": "value" },
9
+ * "workflows": {
10
+ * "staging-java-17": { "VAR_NAME": "value" }
11
+ * }
12
+ * }
13
+ */
14
+ export interface SecretsFile {
15
+ global: Record<string, string>;
16
+ workflows: Record<string, Record<string, string>>;
17
+ }
18
+ export declare class SecretsManager {
19
+ private secretsFilePath;
20
+ private data;
21
+ private fileLoaded;
22
+ constructor(secretsFilePath?: string);
23
+ private loadSecrets;
24
+ /**
25
+ * Reads structured env vars (CIBUILD_S__* and CIBUILD_SW__*) and decodes them
26
+ * back into a SecretsFile structure. Used when running in CI where secrets
27
+ * were uploaded via `ci secrets upload`.
28
+ */
29
+ private getStructuredEnvSecrets;
30
+ private saveSecrets;
31
+ /**
32
+ * Store a secret by variable name, optionally scoped to a workflow.
33
+ * @returns The variable name (used as the key)
34
+ */
35
+ storeSecret(name: string, value: string, workflow?: string): string;
36
+ private static readonly ENV_PREFIX;
37
+ /**
38
+ * Reads all CIBUILD_-prefixed env vars, stripping the prefix from the keys.
39
+ * e.g. CIBUILD_SSH_RSA_PRIVATE_KEY → SSH_RSA_PRIVATE_KEY
40
+ */
41
+ private getEnvSecrets;
42
+ /**
43
+ * Get a secret value by variable name.
44
+ * Workflow-specific value takes precedence over global.
45
+ * Falls back to CIBUILD_-prefixed env vars when no secrets file is present.
46
+ */
47
+ getSecret(name: string, workflow?: string): string | undefined;
48
+ /**
49
+ * Get all secrets merged: global + workflow-specific (workflow overrides global).
50
+ * Falls back to CIBUILD_-prefixed env vars when no secrets file is present.
51
+ */
52
+ getAll(workflow?: string): Record<string, string>;
53
+ /**
54
+ * Returns the variable name if a secret exists for it, undefined otherwise.
55
+ * Checks workflow scope first, then global.
56
+ * Falls back to CIBUILD_-prefixed env vars when no secrets file is present.
57
+ */
58
+ getSecretIdByName(name: string, workflow?: string): string | undefined;
59
+ /**
60
+ * Returns the name itself (API compatibility).
61
+ */
62
+ getSecretName(id: string): string | undefined;
63
+ /**
64
+ * Check if a secret exists by variable name (global or any workflow).
65
+ */
66
+ hasSecret(name: string, workflow?: string): boolean;
67
+ /**
68
+ * Get all stored variable names (global + all workflows, deduplicated).
69
+ */
70
+ getAllSecretNames(): string[];
71
+ /**
72
+ * Delete a secret by variable name (from workflow scope or global).
73
+ */
74
+ deleteSecret(name: string, workflow?: string): boolean;
75
+ getSecretsFilePath(): string;
76
+ }
77
+ //# sourceMappingURL=secrets-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets-manager.d.ts","sourceRoot":"","sources":["../../../src/yaml/secrets-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACnD;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,UAAU,CAAkB;gBAExB,eAAe,CAAC,EAAE,MAAM;IAMpC,OAAO,CAAC,WAAW;IAqCnB;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,WAAW;IAUnB;;;OAGG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAanE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAc;IAEhD;;;OAGG;IACH,OAAO,CAAC,aAAa;IAUrB;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAU9D;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAWjD;;;;OAIG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAatE;;OAEG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI7C;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IAInD;;OAEG;IACH,iBAAiB,IAAI,MAAM,EAAE;IAQ7B;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IAetD,kBAAkB,IAAI,MAAM;CAG7B"}
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Universal secrets management for CI Build
3
+ * Stores sensitive values by exact variable name — no UUIDs, no YAML modification
4
+ * Supports per-workflow scoping with global fallback
5
+ *
6
+ * File format:
7
+ * {
8
+ * "global": { "VAR_NAME": "value" },
9
+ * "workflows": {
10
+ * "staging-java-17": { "VAR_NAME": "value" }
11
+ * }
12
+ * }
13
+ */
14
+ import * as fs from 'fs';
15
+ import * as path from 'path';
16
+ import { decodeSecretName } from '../commands/secrets-upload.js';
17
+ export class SecretsManager {
18
+ secretsFilePath;
19
+ data;
20
+ fileLoaded = false;
21
+ constructor(secretsFilePath) {
22
+ this.secretsFilePath = secretsFilePath || path.join(process.cwd(), '.cibuild-secrets.json');
23
+ this.data = { global: {}, workflows: {} };
24
+ this.loadSecrets();
25
+ }
26
+ loadSecrets() {
27
+ try {
28
+ if (fs.existsSync(this.secretsFilePath)) {
29
+ const content = fs.readFileSync(this.secretsFilePath, 'utf-8');
30
+ const parsed = JSON.parse(content);
31
+ this.fileLoaded = true;
32
+ // Support both new format and legacy flat format
33
+ if (parsed.global !== undefined || parsed.workflows !== undefined) {
34
+ this.data = {
35
+ global: parsed.global || {},
36
+ workflows: parsed.workflows || {},
37
+ };
38
+ }
39
+ else {
40
+ // Legacy flat format: treat all keys as global
41
+ this.data.global = {};
42
+ for (const [key, value] of Object.entries(parsed)) {
43
+ if (typeof value === 'string') {
44
+ this.data.global[key] = value;
45
+ }
46
+ }
47
+ }
48
+ }
49
+ else {
50
+ // No file — try loading from structured env vars (GitHub environment secrets)
51
+ const envData = this.getStructuredEnvSecrets();
52
+ if (Object.keys(envData.global).length > 0 ||
53
+ Object.keys(envData.workflows).length > 0) {
54
+ this.data = envData;
55
+ this.fileLoaded = true;
56
+ }
57
+ }
58
+ }
59
+ catch (error) {
60
+ console.warn(`Warning: Could not load secrets file: ${error instanceof Error ? error.message : String(error)}`);
61
+ }
62
+ }
63
+ /**
64
+ * Reads structured env vars (CIBUILD_S__* and CIBUILD_SW__*) and decodes them
65
+ * back into a SecretsFile structure. Used when running in CI where secrets
66
+ * were uploaded via `ci secrets upload`.
67
+ */
68
+ getStructuredEnvSecrets() {
69
+ const result = { global: {}, workflows: {} };
70
+ for (const [key, value] of Object.entries(process.env)) {
71
+ if (value === undefined)
72
+ continue;
73
+ const decoded = decodeSecretName(key);
74
+ if (!decoded)
75
+ continue;
76
+ if (decoded.workflow) {
77
+ if (!result.workflows[decoded.workflow]) {
78
+ result.workflows[decoded.workflow] = {};
79
+ }
80
+ result.workflows[decoded.workflow][decoded.varName] = value;
81
+ }
82
+ else {
83
+ result.global[decoded.varName] = value;
84
+ }
85
+ }
86
+ return result;
87
+ }
88
+ saveSecrets() {
89
+ const dir = path.dirname(this.secretsFilePath);
90
+ if (!fs.existsSync(dir)) {
91
+ fs.mkdirSync(dir, { recursive: true });
92
+ }
93
+ fs.writeFileSync(this.secretsFilePath, JSON.stringify(this.data, null, 2), {
94
+ mode: 0o600,
95
+ });
96
+ }
97
+ /**
98
+ * Store a secret by variable name, optionally scoped to a workflow.
99
+ * @returns The variable name (used as the key)
100
+ */
101
+ storeSecret(name, value, workflow) {
102
+ if (workflow) {
103
+ if (!this.data.workflows[workflow]) {
104
+ this.data.workflows[workflow] = {};
105
+ }
106
+ this.data.workflows[workflow][name] = value;
107
+ }
108
+ else {
109
+ this.data.global[name] = value;
110
+ }
111
+ this.saveSecrets();
112
+ return name;
113
+ }
114
+ static ENV_PREFIX = 'CIBUILD_';
115
+ /**
116
+ * Reads all CIBUILD_-prefixed env vars, stripping the prefix from the keys.
117
+ * e.g. CIBUILD_SSH_RSA_PRIVATE_KEY → SSH_RSA_PRIVATE_KEY
118
+ */
119
+ getEnvSecrets() {
120
+ const secrets = {};
121
+ for (const [key, value] of Object.entries(process.env)) {
122
+ if (key.startsWith(SecretsManager.ENV_PREFIX) && value !== undefined) {
123
+ secrets[key.slice(SecretsManager.ENV_PREFIX.length)] = value;
124
+ }
125
+ }
126
+ return secrets;
127
+ }
128
+ /**
129
+ * Get a secret value by variable name.
130
+ * Workflow-specific value takes precedence over global.
131
+ * Falls back to CIBUILD_-prefixed env vars when no secrets file is present.
132
+ */
133
+ getSecret(name, workflow) {
134
+ if (!this.fileLoaded) {
135
+ return process.env[SecretsManager.ENV_PREFIX + name];
136
+ }
137
+ if (workflow && this.data.workflows[workflow]?.[name] !== undefined) {
138
+ return this.data.workflows[workflow][name];
139
+ }
140
+ return this.data.global[name];
141
+ }
142
+ /**
143
+ * Get all secrets merged: global + workflow-specific (workflow overrides global).
144
+ * Falls back to CIBUILD_-prefixed env vars when no secrets file is present.
145
+ */
146
+ getAll(workflow) {
147
+ if (!this.fileLoaded) {
148
+ return this.getEnvSecrets();
149
+ }
150
+ const merged = { ...this.data.global };
151
+ if (workflow && this.data.workflows[workflow]) {
152
+ Object.assign(merged, this.data.workflows[workflow]);
153
+ }
154
+ return merged;
155
+ }
156
+ /**
157
+ * Returns the variable name if a secret exists for it, undefined otherwise.
158
+ * Checks workflow scope first, then global.
159
+ * Falls back to CIBUILD_-prefixed env vars when no secrets file is present.
160
+ */
161
+ getSecretIdByName(name, workflow) {
162
+ if (!this.fileLoaded) {
163
+ return process.env[SecretsManager.ENV_PREFIX + name] !== undefined ? name : undefined;
164
+ }
165
+ if (workflow && this.data.workflows[workflow]?.[name] !== undefined) {
166
+ return name;
167
+ }
168
+ if (this.data.global[name] !== undefined) {
169
+ return name;
170
+ }
171
+ return undefined;
172
+ }
173
+ /**
174
+ * Returns the name itself (API compatibility).
175
+ */
176
+ getSecretName(id) {
177
+ return this.getSecretIdByName(id) ? id : undefined;
178
+ }
179
+ /**
180
+ * Check if a secret exists by variable name (global or any workflow).
181
+ */
182
+ hasSecret(name, workflow) {
183
+ return this.getSecretIdByName(name, workflow) !== undefined;
184
+ }
185
+ /**
186
+ * Get all stored variable names (global + all workflows, deduplicated).
187
+ */
188
+ getAllSecretNames() {
189
+ const names = new Set(Object.keys(this.data.global));
190
+ for (const vars of Object.values(this.data.workflows)) {
191
+ for (const key of Object.keys(vars))
192
+ names.add(key);
193
+ }
194
+ return Array.from(names);
195
+ }
196
+ /**
197
+ * Delete a secret by variable name (from workflow scope or global).
198
+ */
199
+ deleteSecret(name, workflow) {
200
+ let deleted = false;
201
+ if (workflow && this.data.workflows[workflow]) {
202
+ if (name in this.data.workflows[workflow]) {
203
+ delete this.data.workflows[workflow][name];
204
+ deleted = true;
205
+ }
206
+ }
207
+ else if (name in this.data.global) {
208
+ delete this.data.global[name];
209
+ deleted = true;
210
+ }
211
+ if (deleted)
212
+ this.saveSecrets();
213
+ return deleted;
214
+ }
215
+ getSecretsFilePath() {
216
+ return this.secretsFilePath;
217
+ }
218
+ }
219
+ //# sourceMappingURL=secrets-manager.js.map
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Pre-execution validation orchestrator
3
+ *
4
+ * Validates all steps in a workflow BEFORE execution begins.
5
+ * All validation checks are READ-ONLY and safe to run on the user's machine.
6
+ * This enables catching all issues at once instead of failing on the first error.
7
+ */
8
+ import type { YAMLPipeline } from './types.js';
9
+ import type { CIConfig } from '../types.js';
10
+ import type { WorkflowValidationResult } from './validation-types.js';
11
+ /**
12
+ * StepValidator orchestrates pre-execution validation for a workflow.
13
+ * It iterates through all steps, collects validation requirements,
14
+ * runs pre-execution checks, and aggregates all issues.
15
+ */
16
+ export declare class StepValidator {
17
+ private pipeline;
18
+ private workflow;
19
+ private workflowName;
20
+ private config;
21
+ private envResolver;
22
+ private yamlFilePath?;
23
+ private availableOutputs;
24
+ private establishedPlatform;
25
+ constructor(pipeline: YAMLPipeline, workflowName: string, config: CIConfig, yamlFilePath?: string);
26
+ /**
27
+ * Validates all steps in the workflow.
28
+ * Returns a complete validation result with all issues grouped by step and category.
29
+ */
30
+ validateWorkflow(): Promise<WorkflowValidationResult>;
31
+ /**
32
+ * Validates a single requirement and returns an issue if it fails
33
+ */
34
+ private validateRequirement;
35
+ /**
36
+ * Extracts all $VAR and ${VAR} variable names referenced in an object recursively.
37
+ */
38
+ private extractVariableReferences;
39
+ /**
40
+ * Replaces all unresolved $VAR and ${VAR} references with empty string.
41
+ * Used as a lenient fallback when full interpolation fails, so that
42
+ * getValidationRequirements can detect truly-missing variables correctly.
43
+ */
44
+ private stripUnresolvedVars;
45
+ /**
46
+ * Parses a YAML step into a ParsedStep (simplified version of converter logic)
47
+ */
48
+ private parseStep;
49
+ }
50
+ /**
51
+ * Format validation result for console output
52
+ */
53
+ export declare function formatValidationResult(result: WorkflowValidationResult): string;
54
+ //# sourceMappingURL=step-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-validator.d.ts","sourceRoot":"","sources":["../../../src/yaml/step-validator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,YAAY,EAA4B,MAAM,YAAY,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAGV,wBAAwB,EAGzB,MAAM,uBAAuB,CAAC;AAoB/B;;;;GAIG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAe;IAC/B,OAAO,CAAC,QAAQ,CAAe;IAC/B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,YAAY,CAAC,CAAS;IAG9B,OAAO,CAAC,gBAAgB,CAAoE;IAG5F,OAAO,CAAC,mBAAmB,CAA6B;gBAGtD,QAAQ,EAAE,YAAY,EACtB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,QAAQ,EAChB,YAAY,CAAC,EAAE,MAAM;IAwBvB;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAuM3D;;OAEG;YACW,mBAAmB;IAsDjC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAoBjC;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAiB3B;;OAEG;IACH,OAAO,CAAC,SAAS;CA8BlB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,CA4D/E"}