@cbnventures/nova 0.19.0 → 0.21.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 (536) hide show
  1. package/README.md +10 -0
  2. package/bin/nova.mjs +3 -3
  3. package/build/package.json +14 -10
  4. package/build/src/cli/generate/github/funding.js +2 -2
  5. package/build/src/cli/generate/github/funding.js.map +1 -1
  6. package/build/src/cli/generate/github/issue-template.d.ts.map +1 -1
  7. package/build/src/cli/generate/github/issue-template.js +6 -95
  8. package/build/src/cli/generate/github/issue-template.js.map +1 -1
  9. package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts +12 -0
  10. package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts.map +1 -0
  11. package/build/src/cli/generate/github/workflows-blueprint-validate.js +535 -0
  12. package/build/src/cli/generate/github/workflows-blueprint-validate.js.map +1 -0
  13. package/build/src/cli/generate/github/workflows-blueprint-variables.d.ts +9 -0
  14. package/build/src/cli/generate/github/workflows-blueprint-variables.d.ts.map +1 -0
  15. package/build/src/cli/generate/github/workflows-blueprint-variables.js +117 -0
  16. package/build/src/cli/generate/github/workflows-blueprint-variables.js.map +1 -0
  17. package/build/src/cli/generate/github/workflows-blueprint.d.ts +60 -0
  18. package/build/src/cli/generate/github/workflows-blueprint.d.ts.map +1 -0
  19. package/build/src/cli/generate/github/workflows-blueprint.js +2251 -0
  20. package/build/src/cli/generate/github/workflows-blueprint.js.map +1 -0
  21. package/build/src/cli/generate/must-haves/agent-conventions.d.ts.map +1 -1
  22. package/build/src/cli/generate/must-haves/agent-conventions.js +14 -5
  23. package/build/src/cli/generate/must-haves/agent-conventions.js.map +1 -1
  24. package/build/src/cli/generate/must-haves/dotenv.d.ts +5 -7
  25. package/build/src/cli/generate/must-haves/dotenv.d.ts.map +1 -1
  26. package/build/src/cli/generate/must-haves/dotenv.js +146 -417
  27. package/build/src/cli/generate/must-haves/dotenv.js.map +1 -1
  28. package/build/src/cli/generate/must-haves/editorconfig.js +2 -2
  29. package/build/src/cli/generate/must-haves/editorconfig.js.map +1 -1
  30. package/build/src/cli/generate/must-haves/gitignore.d.ts +0 -8
  31. package/build/src/cli/generate/must-haves/gitignore.d.ts.map +1 -1
  32. package/build/src/cli/generate/must-haves/gitignore.js +9 -397
  33. package/build/src/cli/generate/must-haves/gitignore.js.map +1 -1
  34. package/build/src/cli/generate/must-haves/license.d.ts.map +1 -1
  35. package/build/src/cli/generate/must-haves/license.js +4 -4
  36. package/build/src/cli/generate/must-haves/license.js.map +1 -1
  37. package/build/src/cli/generate/must-haves/read-me.d.ts +6 -2
  38. package/build/src/cli/generate/must-haves/read-me.d.ts.map +1 -1
  39. package/build/src/cli/generate/must-haves/read-me.js +103 -63
  40. package/build/src/cli/generate/must-haves/read-me.js.map +1 -1
  41. package/build/src/cli/index.js +108 -2
  42. package/build/src/cli/index.js.map +1 -1
  43. package/build/src/cli/recipe/github/sync-features.d.ts.map +1 -1
  44. package/build/src/cli/recipe/github/sync-features.js +5 -3
  45. package/build/src/cli/recipe/github/sync-features.js.map +1 -1
  46. package/build/src/cli/recipe/github/sync-identity.d.ts.map +1 -1
  47. package/build/src/cli/recipe/github/sync-identity.js +6 -4
  48. package/build/src/cli/recipe/github/sync-identity.js.map +1 -1
  49. package/build/src/cli/recipe/github/sync-policies.d.ts.map +1 -1
  50. package/build/src/cli/recipe/github/sync-policies.js +13 -4
  51. package/build/src/cli/recipe/github/sync-policies.js.map +1 -1
  52. package/build/src/cli/recipe/index.d.ts.map +1 -1
  53. package/build/src/cli/recipe/index.js +32 -0
  54. package/build/src/cli/recipe/index.js.map +1 -1
  55. package/build/src/cli/recipe/license/update-copyright.d.ts +7 -0
  56. package/build/src/cli/recipe/license/update-copyright.d.ts.map +1 -0
  57. package/build/src/cli/recipe/license/update-copyright.js +191 -0
  58. package/build/src/cli/recipe/license/update-copyright.js.map +1 -0
  59. package/build/src/cli/recipe/package-json/cleanup.d.ts.map +1 -1
  60. package/build/src/cli/recipe/package-json/cleanup.js +14 -13
  61. package/build/src/cli/recipe/package-json/cleanup.js.map +1 -1
  62. package/build/src/cli/recipe/package-json/normalize-artifacts.d.ts.map +1 -1
  63. package/build/src/cli/recipe/package-json/normalize-artifacts.js +11 -6
  64. package/build/src/cli/recipe/package-json/normalize-artifacts.js.map +1 -1
  65. package/build/src/cli/recipe/package-json/normalize-bundler.d.ts.map +1 -1
  66. package/build/src/cli/recipe/package-json/normalize-bundler.js +11 -6
  67. package/build/src/cli/recipe/package-json/normalize-bundler.js.map +1 -1
  68. package/build/src/cli/recipe/package-json/normalize-dependencies.d.ts.map +1 -1
  69. package/build/src/cli/recipe/package-json/normalize-dependencies.js +18 -10
  70. package/build/src/cli/recipe/package-json/normalize-dependencies.js.map +1 -1
  71. package/build/src/cli/recipe/package-json/normalize-modules.d.ts.map +1 -1
  72. package/build/src/cli/recipe/package-json/normalize-modules.js +11 -6
  73. package/build/src/cli/recipe/package-json/normalize-modules.js.map +1 -1
  74. package/build/src/cli/recipe/package-json/normalize-tooling.d.ts.map +1 -1
  75. package/build/src/cli/recipe/package-json/normalize-tooling.js +12 -7
  76. package/build/src/cli/recipe/package-json/normalize-tooling.js.map +1 -1
  77. package/build/src/cli/recipe/package-json/sync-environment.d.ts.map +1 -1
  78. package/build/src/cli/recipe/package-json/sync-environment.js +46 -14
  79. package/build/src/cli/recipe/package-json/sync-environment.js.map +1 -1
  80. package/build/src/cli/recipe/package-json/sync-identity.d.ts.map +1 -1
  81. package/build/src/cli/recipe/package-json/sync-identity.js +29 -16
  82. package/build/src/cli/recipe/package-json/sync-identity.js.map +1 -1
  83. package/build/src/cli/recipe/package-json/sync-ownership.d.ts.map +1 -1
  84. package/build/src/cli/recipe/package-json/sync-ownership.js +18 -11
  85. package/build/src/cli/recipe/package-json/sync-ownership.js.map +1 -1
  86. package/build/src/cli/recipe/read-me/update-badges.d.ts +6 -0
  87. package/build/src/cli/recipe/read-me/update-badges.d.ts.map +1 -0
  88. package/build/src/cli/recipe/read-me/update-badges.js +115 -0
  89. package/build/src/cli/recipe/read-me/update-badges.js.map +1 -0
  90. package/build/src/cli/recipe/read-me/update-credits.d.ts +6 -0
  91. package/build/src/cli/recipe/read-me/update-credits.d.ts.map +1 -0
  92. package/build/src/cli/recipe/read-me/update-credits.js +115 -0
  93. package/build/src/cli/recipe/read-me/update-credits.js.map +1 -0
  94. package/build/src/cli/recipe/read-me/update-documentation.d.ts +6 -0
  95. package/build/src/cli/recipe/read-me/update-documentation.d.ts.map +1 -0
  96. package/build/src/cli/recipe/read-me/update-documentation.js +115 -0
  97. package/build/src/cli/recipe/read-me/update-documentation.js.map +1 -0
  98. package/build/src/cli/recipe/read-me/update-header.d.ts +6 -0
  99. package/build/src/cli/recipe/read-me/update-header.d.ts.map +1 -0
  100. package/build/src/cli/recipe/read-me/update-header.js +115 -0
  101. package/build/src/cli/recipe/read-me/update-header.js.map +1 -0
  102. package/build/src/cli/recipe/read-me/update-introduction.d.ts +6 -0
  103. package/build/src/cli/recipe/read-me/update-introduction.d.ts.map +1 -0
  104. package/build/src/cli/recipe/read-me/update-introduction.js +115 -0
  105. package/build/src/cli/recipe/read-me/update-introduction.js.map +1 -0
  106. package/build/src/cli/scaffold/starter/base.js +1 -1
  107. package/build/src/cli/scaffold/starter/base.js.map +1 -1
  108. package/build/src/cli/utility/changelog.d.ts +2 -0
  109. package/build/src/cli/utility/changelog.d.ts.map +1 -1
  110. package/build/src/cli/utility/changelog.js +159 -3
  111. package/build/src/cli/utility/changelog.js.map +1 -1
  112. package/build/src/cli/utility/initialize.d.ts +9 -0
  113. package/build/src/cli/utility/initialize.d.ts.map +1 -1
  114. package/build/src/cli/utility/initialize.js +978 -111
  115. package/build/src/cli/utility/initialize.js.map +1 -1
  116. package/build/src/cli/utility/run-scripts.d.ts.map +1 -1
  117. package/build/src/cli/utility/run-scripts.js +4 -4
  118. package/build/src/cli/utility/run-scripts.js.map +1 -1
  119. package/build/src/cli/utility/transpile.js +1 -1
  120. package/build/src/cli/utility/transpile.js.map +1 -1
  121. package/build/src/cli/utility/type-check.js +1 -1
  122. package/build/src/cli/utility/type-check.js.map +1 -1
  123. package/build/src/cli/utility/version.js +1 -1
  124. package/build/src/cli/utility/version.js.map +1 -1
  125. package/build/src/lib/dotenv.d.ts +3 -0
  126. package/build/src/lib/dotenv.d.ts.map +1 -0
  127. package/build/src/lib/dotenv.js +66 -0
  128. package/build/src/lib/dotenv.js.map +1 -0
  129. package/build/src/lib/env-github.d.ts +4 -0
  130. package/build/src/lib/env-github.d.ts.map +1 -0
  131. package/build/src/lib/env-github.js +57 -0
  132. package/build/src/lib/env-github.js.map +1 -0
  133. package/build/src/lib/env-managed-set.d.ts +3 -0
  134. package/build/src/lib/env-managed-set.d.ts.map +1 -0
  135. package/build/src/lib/env-managed-set.js +102 -0
  136. package/build/src/lib/env-managed-set.js.map +1 -0
  137. package/build/src/lib/env-namespace.d.ts +3 -0
  138. package/build/src/lib/env-namespace.d.ts.map +1 -0
  139. package/build/src/lib/env-namespace.js +11 -0
  140. package/build/src/lib/env-namespace.js.map +1 -0
  141. package/build/src/lib/env-reconcile.d.ts +3 -0
  142. package/build/src/lib/env-reconcile.d.ts.map +1 -0
  143. package/build/src/lib/env-reconcile.js +109 -0
  144. package/build/src/lib/env-reconcile.js.map +1 -0
  145. package/build/src/lib/env-status.d.ts +3 -0
  146. package/build/src/lib/env-status.d.ts.map +1 -0
  147. package/build/src/lib/env-status.js +113 -0
  148. package/build/src/lib/env-status.js.map +1 -0
  149. package/build/src/lib/file-discovery.d.ts +3 -0
  150. package/build/src/lib/file-discovery.d.ts.map +1 -0
  151. package/build/src/lib/file-discovery.js +32 -0
  152. package/build/src/lib/file-discovery.js.map +1 -0
  153. package/build/src/lib/item.d.ts +4 -1
  154. package/build/src/lib/item.d.ts.map +1 -1
  155. package/build/src/lib/item.js +35 -0
  156. package/build/src/lib/item.js.map +1 -1
  157. package/build/src/lib/markdown-slug.d.ts +4 -0
  158. package/build/src/lib/markdown-slug.d.ts.map +1 -0
  159. package/build/src/lib/markdown-slug.js +25 -0
  160. package/build/src/lib/markdown-slug.js.map +1 -0
  161. package/build/src/lib/nova-config.d.ts +14 -2
  162. package/build/src/lib/nova-config.d.ts.map +1 -1
  163. package/build/src/lib/nova-config.js +507 -78
  164. package/build/src/lib/nova-config.js.map +1 -1
  165. package/build/src/lib/read-me-regions.d.ts +4 -0
  166. package/build/src/lib/read-me-regions.d.ts.map +1 -0
  167. package/build/src/lib/read-me-regions.js +33 -0
  168. package/build/src/lib/read-me-regions.js.map +1 -0
  169. package/build/src/lib/regex.d.ts +73 -0
  170. package/build/src/lib/regex.d.ts.map +1 -1
  171. package/build/src/lib/regex.js +75 -2
  172. package/build/src/lib/regex.js.map +1 -1
  173. package/build/src/lib/scaffold.d.ts.map +1 -1
  174. package/build/src/lib/scaffold.js +33 -14
  175. package/build/src/lib/scaffold.js.map +1 -1
  176. package/build/src/lib/type-declaration-engine.d.ts +32 -0
  177. package/build/src/lib/type-declaration-engine.d.ts.map +1 -0
  178. package/build/src/lib/type-declaration-engine.js +796 -0
  179. package/build/src/lib/type-declaration-engine.js.map +1 -0
  180. package/build/src/lib/utility.d.ts +2 -1
  181. package/build/src/lib/utility.d.ts.map +1 -1
  182. package/build/src/lib/utility.js +47 -15
  183. package/build/src/lib/utility.js.map +1 -1
  184. package/build/src/lib/workflow-templates.d.ts.map +1 -1
  185. package/build/src/lib/workflow-templates.js +86 -60
  186. package/build/src/lib/workflow-templates.js.map +1 -1
  187. package/build/src/presets/eslint/dx-code-style.d.ts.map +1 -1
  188. package/build/src/presets/eslint/dx-code-style.js +6 -0
  189. package/build/src/presets/eslint/dx-code-style.js.map +1 -1
  190. package/build/src/presets/eslint/fw-astro.d.ts +4 -0
  191. package/build/src/presets/eslint/fw-astro.d.ts.map +1 -0
  192. package/build/src/presets/eslint/fw-astro.js +13 -0
  193. package/build/src/presets/eslint/fw-astro.js.map +1 -0
  194. package/build/src/presets/eslint/index.d.ts +1 -0
  195. package/build/src/presets/eslint/index.d.ts.map +1 -1
  196. package/build/src/presets/eslint/index.js +1 -0
  197. package/build/src/presets/eslint/index.js.map +1 -1
  198. package/build/src/presets/tsconfig/fw-astro.json +15 -0
  199. package/build/src/rules/eslint/conventions/no-implicit-boolean.d.ts.map +1 -1
  200. package/build/src/rules/eslint/conventions/no-implicit-boolean.js +3 -2
  201. package/build/src/rules/eslint/conventions/no-implicit-boolean.js.map +1 -1
  202. package/build/src/rules/eslint/conventions/require-hash-private.js +1 -1
  203. package/build/src/rules/eslint/conventions/require-hash-private.js.map +1 -1
  204. package/build/src/rules/eslint/conventions/require-kebab-case-filename.d.ts.map +1 -1
  205. package/build/src/rules/eslint/conventions/require-kebab-case-filename.js +4 -1
  206. package/build/src/rules/eslint/conventions/require-kebab-case-filename.js.map +1 -1
  207. package/build/src/rules/eslint/conventions/require-node-protocol.d.ts +11 -0
  208. package/build/src/rules/eslint/conventions/require-node-protocol.d.ts.map +1 -0
  209. package/build/src/rules/eslint/conventions/require-node-protocol.js +76 -0
  210. package/build/src/rules/eslint/conventions/require-node-protocol.js.map +1 -0
  211. package/build/src/rules/eslint/formatting/no-raw-text-in-code.d.ts.map +1 -1
  212. package/build/src/rules/eslint/formatting/no-raw-text-in-code.js +2 -1
  213. package/build/src/rules/eslint/formatting/no-raw-text-in-code.js.map +1 -1
  214. package/build/src/rules/eslint/formatting/require-padding-lines.d.ts.map +1 -1
  215. package/build/src/rules/eslint/formatting/require-padding-lines.js +7 -3
  216. package/build/src/rules/eslint/formatting/require-padding-lines.js.map +1 -1
  217. package/build/src/rules/eslint/formatting/require-ternary-parens.d.ts.map +1 -1
  218. package/build/src/rules/eslint/formatting/require-ternary-parens.js +7 -17
  219. package/build/src/rules/eslint/formatting/require-ternary-parens.js.map +1 -1
  220. package/build/src/rules/eslint/index.d.ts +4 -0
  221. package/build/src/rules/eslint/index.d.ts.map +1 -1
  222. package/build/src/rules/eslint/index.js +4 -0
  223. package/build/src/rules/eslint/index.js.map +1 -1
  224. package/build/src/rules/eslint/jsdoc/require-jsdoc-body.d.ts +3 -2
  225. package/build/src/rules/eslint/jsdoc/require-jsdoc-body.d.ts.map +1 -1
  226. package/build/src/rules/eslint/jsdoc/require-jsdoc-body.js +22 -0
  227. package/build/src/rules/eslint/jsdoc/require-jsdoc-body.js.map +1 -1
  228. package/build/src/rules/eslint/jsdoc/require-jsdoc-hierarchy.d.ts +2 -1
  229. package/build/src/rules/eslint/jsdoc/require-jsdoc-hierarchy.d.ts.map +1 -1
  230. package/build/src/rules/eslint/jsdoc/require-jsdoc-hierarchy.js +19 -4
  231. package/build/src/rules/eslint/jsdoc/require-jsdoc-hierarchy.js.map +1 -1
  232. package/build/src/rules/eslint/jsdoc/require-jsdoc-param-alignment.d.ts.map +1 -1
  233. package/build/src/rules/eslint/jsdoc/require-jsdoc-param-alignment.js +3 -2
  234. package/build/src/rules/eslint/jsdoc/require-jsdoc-param-alignment.js.map +1 -1
  235. package/build/src/rules/eslint/jsdoc/require-jsdoc-param-name.d.ts.map +1 -1
  236. package/build/src/rules/eslint/jsdoc/require-jsdoc-param-name.js +10 -6
  237. package/build/src/rules/eslint/jsdoc/require-jsdoc-param-name.js.map +1 -1
  238. package/build/src/rules/eslint/jsdoc/require-jsdoc-presence.d.ts +12 -0
  239. package/build/src/rules/eslint/jsdoc/require-jsdoc-presence.d.ts.map +1 -0
  240. package/build/src/rules/eslint/jsdoc/require-jsdoc-presence.js +169 -0
  241. package/build/src/rules/eslint/jsdoc/require-jsdoc-presence.js.map +1 -0
  242. package/build/src/rules/eslint/jsdoc/require-jsdoc-returns.d.ts +11 -0
  243. package/build/src/rules/eslint/jsdoc/require-jsdoc-returns.d.ts.map +1 -0
  244. package/build/src/rules/eslint/jsdoc/require-jsdoc-returns.js +80 -0
  245. package/build/src/rules/eslint/jsdoc/require-jsdoc-returns.js.map +1 -0
  246. package/build/src/rules/eslint/jsdoc/require-jsdoc-since.d.ts +1 -1
  247. package/build/src/rules/eslint/jsdoc/require-jsdoc-since.d.ts.map +1 -1
  248. package/build/src/rules/eslint/jsdoc/require-jsdoc-since.js +102 -6
  249. package/build/src/rules/eslint/jsdoc/require-jsdoc-since.js.map +1 -1
  250. package/build/src/rules/eslint/jsdoc/require-jsdoc-tag-order.d.ts +15 -0
  251. package/build/src/rules/eslint/jsdoc/require-jsdoc-tag-order.d.ts.map +1 -0
  252. package/build/src/rules/eslint/jsdoc/require-jsdoc-tag-order.js +290 -0
  253. package/build/src/rules/eslint/jsdoc/require-jsdoc-tag-order.js.map +1 -0
  254. package/build/src/rules/eslint/patterns/no-await-in-loop.js +1 -1
  255. package/build/src/rules/eslint/patterns/no-await-in-loop.js.map +1 -1
  256. package/build/src/rules/eslint/patterns/no-bracket-method-call.d.ts.map +1 -1
  257. package/build/src/rules/eslint/patterns/no-bracket-method-call.js +4 -0
  258. package/build/src/rules/eslint/patterns/no-bracket-method-call.js.map +1 -1
  259. package/build/src/rules/eslint/regex/no-regex-literals.d.ts +1 -0
  260. package/build/src/rules/eslint/regex/no-regex-literals.d.ts.map +1 -1
  261. package/build/src/rules/eslint/regex/no-regex-literals.js +39 -1
  262. package/build/src/rules/eslint/regex/no-regex-literals.js.map +1 -1
  263. package/build/src/rules/eslint/typescript/no-inline-type-annotation.d.ts.map +1 -1
  264. package/build/src/rules/eslint/typescript/no-inline-type-annotation.js +4 -1
  265. package/build/src/rules/eslint/typescript/no-inline-type-annotation.js.map +1 -1
  266. package/build/src/rules/eslint/typescript/require-bracket-property-access.d.ts.map +1 -1
  267. package/build/src/rules/eslint/typescript/require-bracket-property-access.js +8 -1
  268. package/build/src/rules/eslint/typescript/require-bracket-property-access.js.map +1 -1
  269. package/build/src/rules/eslint/typescript/require-type-naming.js +2 -2
  270. package/build/src/rules/eslint/typescript/require-type-naming.js.map +1 -1
  271. package/build/src/rules/vitest/active-vitest.d.ts +5 -0
  272. package/build/src/rules/vitest/active-vitest.d.ts.map +1 -0
  273. package/build/src/rules/vitest/active-vitest.js +19 -0
  274. package/build/src/rules/vitest/active-vitest.js.map +1 -0
  275. package/build/src/rules/vitest/dotenv/register.d.ts +3 -0
  276. package/build/src/rules/vitest/dotenv/register.d.ts.map +1 -0
  277. package/build/src/rules/vitest/dotenv/register.js +22 -0
  278. package/build/src/rules/vitest/dotenv/register.js.map +1 -0
  279. package/build/src/rules/vitest/dotenv/rules.d.ts +3 -0
  280. package/build/src/rules/vitest/dotenv/rules.d.ts.map +1 -0
  281. package/build/src/rules/vitest/dotenv/rules.js +32 -0
  282. package/build/src/rules/vitest/dotenv/rules.js.map +1 -0
  283. package/build/src/rules/vitest/enable.d.ts +3 -0
  284. package/build/src/rules/vitest/enable.d.ts.map +1 -0
  285. package/build/src/rules/vitest/enable.js +7 -0
  286. package/build/src/rules/vitest/enable.js.map +1 -0
  287. package/build/src/rules/vitest/frontmatter/register.d.ts +3 -0
  288. package/build/src/rules/vitest/frontmatter/register.d.ts.map +1 -0
  289. package/build/src/rules/vitest/frontmatter/register.js +52 -0
  290. package/build/src/rules/vitest/frontmatter/register.js.map +1 -0
  291. package/build/src/rules/vitest/frontmatter/rules.d.ts +15 -0
  292. package/build/src/rules/vitest/frontmatter/rules.d.ts.map +1 -0
  293. package/build/src/rules/vitest/frontmatter/rules.js +498 -0
  294. package/build/src/rules/vitest/frontmatter/rules.js.map +1 -0
  295. package/build/src/rules/vitest/index.d.ts +8 -0
  296. package/build/src/rules/vitest/index.d.ts.map +1 -0
  297. package/build/src/rules/vitest/index.js +7 -0
  298. package/build/src/rules/vitest/index.js.map +1 -0
  299. package/build/src/rules/vitest/link/register.d.ts +3 -0
  300. package/build/src/rules/vitest/link/register.d.ts.map +1 -0
  301. package/build/src/rules/vitest/link/register.js +44 -0
  302. package/build/src/rules/vitest/link/register.js.map +1 -0
  303. package/build/src/rules/vitest/link/rules.d.ts +12 -0
  304. package/build/src/rules/vitest/link/rules.d.ts.map +1 -0
  305. package/build/src/rules/vitest/link/rules.js +313 -0
  306. package/build/src/rules/vitest/link/rules.js.map +1 -0
  307. package/build/src/rules/vitest/markdown-table/register.d.ts +3 -0
  308. package/build/src/rules/vitest/markdown-table/register.d.ts.map +1 -0
  309. package/build/src/rules/vitest/markdown-table/register.js +26 -0
  310. package/build/src/rules/vitest/markdown-table/register.js.map +1 -0
  311. package/build/src/rules/vitest/markdown-table/rules.d.ts +3 -0
  312. package/build/src/rules/vitest/markdown-table/rules.d.ts.map +1 -0
  313. package/build/src/rules/vitest/markdown-table/rules.js +99 -0
  314. package/build/src/rules/vitest/markdown-table/rules.js.map +1 -0
  315. package/build/src/rules/vitest/terminology/register.d.ts +3 -0
  316. package/build/src/rules/vitest/terminology/register.d.ts.map +1 -0
  317. package/build/src/rules/vitest/terminology/register.js +39 -0
  318. package/build/src/rules/vitest/terminology/register.js.map +1 -0
  319. package/build/src/rules/vitest/terminology/rules.d.ts +10 -0
  320. package/build/src/rules/vitest/terminology/rules.d.ts.map +1 -0
  321. package/build/src/rules/vitest/terminology/rules.js +202 -0
  322. package/build/src/rules/vitest/terminology/rules.js.map +1 -0
  323. package/build/src/rules/vitest/type-declarations/register.d.ts +3 -0
  324. package/build/src/rules/vitest/type-declarations/register.d.ts.map +1 -0
  325. package/build/src/rules/vitest/type-declarations/register.js +33 -0
  326. package/build/src/rules/vitest/type-declarations/register.js.map +1 -0
  327. package/build/src/rules/vitest/type-declarations/rules.d.ts +13 -0
  328. package/build/src/rules/vitest/type-declarations/rules.d.ts.map +1 -0
  329. package/build/src/rules/vitest/type-declarations/rules.js +736 -0
  330. package/build/src/rules/vitest/type-declarations/rules.js.map +1 -0
  331. package/build/src/toolkit/index.d.ts +1 -0
  332. package/build/src/toolkit/index.d.ts.map +1 -1
  333. package/build/src/toolkit/index.js +1 -0
  334. package/build/src/toolkit/index.js.map +1 -1
  335. package/build/src/toolkit/logger.d.ts.map +1 -1
  336. package/build/src/toolkit/logger.js +3 -1
  337. package/build/src/toolkit/logger.js.map +1 -1
  338. package/build/src/toolkit/markdown-table.js +1 -1
  339. package/build/src/toolkit/markdown-table.js.map +1 -1
  340. package/build/src/toolkit/nova-identity.d.ts +19 -0
  341. package/build/src/toolkit/nova-identity.d.ts.map +1 -0
  342. package/build/src/toolkit/nova-identity.js +141 -0
  343. package/build/src/toolkit/nova-identity.js.map +1 -0
  344. package/build/src/types/cli/generate/github/funding.d.ts +4 -4
  345. package/build/src/types/cli/generate/github/issue-template.d.ts +15 -35
  346. package/build/src/types/cli/generate/github/workflows-blueprint-validate.d.ts +351 -0
  347. package/build/src/types/cli/generate/github/workflows-blueprint-variables.d.ts +131 -0
  348. package/build/src/types/cli/generate/github/workflows-blueprint.d.ts +1180 -0
  349. package/build/src/types/cli/generate/must-haves/agent-conventions.d.ts +9 -2
  350. package/build/src/types/cli/generate/must-haves/dotenv.d.ts +101 -314
  351. package/build/src/types/cli/generate/must-haves/editorconfig.d.ts +2 -2
  352. package/build/src/types/cli/generate/must-haves/gitignore.d.ts +13 -343
  353. package/build/src/types/cli/generate/must-haves/license.d.ts +5 -5
  354. package/build/src/types/cli/generate/must-haves/read-me.d.ts +136 -88
  355. package/build/src/types/cli/index.d.ts +14 -0
  356. package/build/src/types/cli/recipe/github/handle-gh-failure.d.ts +2 -2
  357. package/build/src/types/cli/recipe/github/sync-features.d.ts +20 -13
  358. package/build/src/types/cli/recipe/github/sync-identity.d.ts +20 -13
  359. package/build/src/types/cli/recipe/github/sync-policies.d.ts +24 -15
  360. package/build/src/types/cli/recipe/index.d.ts +7 -3
  361. package/build/src/types/cli/recipe/license/update-copyright.d.ts +142 -0
  362. package/build/src/types/cli/recipe/package-json/cleanup.d.ts +26 -22
  363. package/build/src/types/cli/recipe/package-json/normalize-artifacts.d.ts +22 -16
  364. package/build/src/types/cli/recipe/package-json/normalize-bundler.d.ts +20 -14
  365. package/build/src/types/cli/recipe/package-json/normalize-dependencies.d.ts +31 -19
  366. package/build/src/types/cli/recipe/package-json/normalize-modules.d.ts +20 -14
  367. package/build/src/types/cli/recipe/package-json/normalize-tooling.d.ts +20 -14
  368. package/build/src/types/cli/recipe/package-json/sync-environment.d.ts +46 -22
  369. package/build/src/types/cli/recipe/package-json/sync-identity.d.ts +36 -19
  370. package/build/src/types/cli/recipe/package-json/sync-ownership.d.ts +33 -23
  371. package/build/src/types/cli/recipe/read-me/update-badges.d.ts +77 -0
  372. package/build/src/types/cli/recipe/read-me/update-credits.d.ts +77 -0
  373. package/build/src/types/cli/recipe/read-me/update-documentation.d.ts +77 -0
  374. package/build/src/types/cli/recipe/read-me/update-header.d.ts +77 -0
  375. package/build/src/types/cli/recipe/read-me/update-introduction.d.ts +77 -0
  376. package/build/src/types/cli/scaffold/starter/base.d.ts +2 -2
  377. package/build/src/types/cli/utility/changelog.d.ts +165 -73
  378. package/build/src/types/cli/utility/initialize.d.ts +1007 -350
  379. package/build/src/types/cli/utility/run-scripts.d.ts +1 -1
  380. package/build/src/types/cli/utility/transpile.d.ts +8 -3
  381. package/build/src/types/cli/utility/type-check.d.ts +9 -3
  382. package/build/src/types/cli/utility/version.d.ts +32 -32
  383. package/build/src/types/lib/constants.d.ts +1 -1
  384. package/build/src/types/lib/dotenv.d.ts +67 -0
  385. package/build/src/types/lib/env-github.d.ts +67 -0
  386. package/build/src/types/lib/env-managed-set.d.ts +90 -0
  387. package/build/src/types/lib/env-namespace.d.ts +22 -0
  388. package/build/src/types/lib/env-reconcile.d.ts +71 -0
  389. package/build/src/types/lib/env-status.d.ts +102 -0
  390. package/build/src/types/lib/file-discovery.d.ts +40 -0
  391. package/build/src/types/lib/item.d.ts +42 -0
  392. package/build/src/types/lib/markdown-slug.d.ts +25 -0
  393. package/build/src/types/lib/nova-config.d.ts +455 -68
  394. package/build/src/types/lib/read-me-regions.d.ts +51 -0
  395. package/build/src/types/lib/regex.d.ts +193 -18
  396. package/build/src/types/lib/scaffold.d.ts +43 -23
  397. package/build/src/types/lib/type-declaration-engine.d.ts +1052 -0
  398. package/build/src/types/lib/utility.d.ts +40 -6
  399. package/build/src/types/lib/workflow-templates.d.ts +11 -75
  400. package/build/src/types/presets/eslint/fw-astro.d.ts +8 -0
  401. package/build/src/types/rules/eslint/conventions/no-implicit-boolean.d.ts +7 -0
  402. package/build/src/types/rules/eslint/conventions/require-naming-convention.d.ts +8 -4
  403. package/build/src/types/rules/eslint/conventions/require-node-protocol.d.ts +56 -0
  404. package/build/src/types/rules/eslint/formatting/require-padding-lines.d.ts +2 -0
  405. package/build/src/types/rules/eslint/formatting/require-ternary-parens.d.ts +8 -3
  406. package/build/src/types/rules/eslint/jsdoc/require-jsdoc-body.d.ts +16 -0
  407. package/build/src/types/rules/eslint/jsdoc/require-jsdoc-hierarchy.d.ts +19 -15
  408. package/build/src/types/rules/eslint/jsdoc/require-jsdoc-param-name.d.ts +3 -1
  409. package/build/src/types/rules/eslint/jsdoc/require-jsdoc-presence.d.ts +125 -0
  410. package/build/src/types/rules/eslint/jsdoc/require-jsdoc-returns.d.ts +48 -0
  411. package/build/src/types/rules/eslint/jsdoc/require-jsdoc-since.d.ts +71 -1
  412. package/build/src/types/rules/eslint/jsdoc/require-jsdoc-tag-order.d.ts +204 -0
  413. package/build/src/types/rules/eslint/patterns/no-await-in-loop.d.ts +1 -1
  414. package/build/src/types/rules/eslint/patterns/no-bracket-method-call.d.ts +1 -1
  415. package/build/src/types/rules/eslint/regex/no-regex-literals.d.ts +44 -0
  416. package/build/src/types/rules/eslint/typescript/require-bracket-property-access.d.ts +19 -7
  417. package/build/src/types/rules/eslint/typescript/require-type-naming.d.ts +3 -3
  418. package/build/src/types/rules/vitest/active-vitest.d.ts +31 -0
  419. package/build/src/types/rules/vitest/dotenv/register.d.ts +31 -0
  420. package/build/src/types/rules/vitest/dotenv/rules.d.ts +29 -0
  421. package/build/src/types/rules/vitest/enable.d.ts +12 -0
  422. package/build/src/types/rules/vitest/frontmatter/register.d.ts +63 -0
  423. package/build/src/types/rules/vitest/frontmatter/rules.d.ts +430 -0
  424. package/build/src/types/rules/vitest/index.d.ts +419 -0
  425. package/build/src/types/rules/vitest/link/register.d.ts +79 -0
  426. package/build/src/types/rules/vitest/link/rules.d.ts +368 -0
  427. package/build/src/types/rules/vitest/markdown-table/register.d.ts +33 -0
  428. package/build/src/types/rules/vitest/markdown-table/rules.d.ts +55 -0
  429. package/build/src/types/rules/vitest/terminology/register.d.ts +48 -0
  430. package/build/src/types/rules/vitest/terminology/rules.d.ts +190 -0
  431. package/build/src/types/rules/vitest/type-declarations/register.d.ts +46 -0
  432. package/build/src/types/rules/vitest/type-declarations/rules.d.ts +894 -0
  433. package/build/src/types/shared.d.ts +727 -26
  434. package/build/src/types/tests/cli/generate/github/funding.test.d.ts +14 -10
  435. package/build/src/types/tests/cli/generate/github/issue-template.test.d.ts +38 -17
  436. package/build/src/types/tests/cli/generate/github/workflows-blueprint-generate.test.d.ts +199 -0
  437. package/build/src/types/tests/cli/generate/github/workflows-blueprint-parity.test.d.ts +75 -0
  438. package/build/src/types/tests/cli/generate/github/workflows-blueprint-publish-parity.test.d.ts +295 -0
  439. package/build/src/types/tests/cli/generate/github/workflows-blueprint-validate.test.d.ts +901 -0
  440. package/build/src/types/tests/cli/generate/github/workflows-blueprint-variables.test.d.ts +144 -0
  441. package/build/src/types/tests/cli/generate/github/workflows-blueprint.test.d.ts +332 -0
  442. package/build/src/types/tests/cli/generate/must-haves/agent-conventions.test.d.ts +83 -11
  443. package/build/src/types/tests/cli/generate/must-haves/dotenv.test.d.ts +142 -12
  444. package/build/src/types/tests/cli/generate/must-haves/editorconfig.test.d.ts +12 -8
  445. package/build/src/types/tests/cli/generate/must-haves/gitignore.test.d.ts +14 -19
  446. package/build/src/types/tests/cli/generate/must-haves/read-me.test.d.ts +33 -10
  447. package/build/src/types/tests/cli/recipe/github/handle-gh-failure.test.d.ts +28 -24
  448. package/build/src/types/tests/cli/recipe/github/sync-features.test.d.ts +115 -111
  449. package/build/src/types/tests/cli/recipe/github/sync-identity.test.d.ts +192 -142
  450. package/build/src/types/tests/cli/recipe/github/sync-policies.test.d.ts +199 -126
  451. package/build/src/types/tests/cli/recipe/license/update-copyright.test.d.ts +617 -0
  452. package/build/src/types/tests/cli/recipe/package-json/normalize-dependencies.test.d.ts +27 -0
  453. package/build/src/types/tests/cli/recipe/package-json/sync-environment.test.d.ts +21 -0
  454. package/build/src/types/tests/cli/recipe/package-json/sync-identity.test.d.ts +52 -0
  455. package/build/src/types/tests/cli/recipe/read-me/update-badges.test.d.ts +258 -0
  456. package/build/src/types/tests/cli/recipe/read-me/update-credits.test.d.ts +258 -0
  457. package/build/src/types/tests/cli/recipe/read-me/update-documentation.test.d.ts +258 -0
  458. package/build/src/types/tests/cli/recipe/read-me/update-header.test.d.ts +258 -0
  459. package/build/src/types/tests/cli/recipe/read-me/update-introduction.test.d.ts +258 -0
  460. package/build/src/types/tests/cli/scaffold/docs/docusaurus.test.d.ts +4 -0
  461. package/build/src/types/tests/cli/utility/changelog.test.d.ts +293 -0
  462. package/build/src/types/tests/cli/utility/initialize.test.d.ts +148 -1
  463. package/build/src/types/tests/lib/dotenv.test.d.ts +95 -0
  464. package/build/src/types/tests/lib/file-discovery.test.d.ts +37 -0
  465. package/build/src/types/tests/lib/item.test.d.ts +21 -0
  466. package/build/src/types/tests/lib/markdown-slug.test.d.ts +24 -0
  467. package/build/src/types/tests/lib/nova-config.test.d.ts +503 -83
  468. package/build/src/types/tests/lib/read-me-regions.test.d.ts +43 -0
  469. package/build/src/types/tests/lib/regex.test.d.ts +252 -0
  470. package/build/src/types/tests/lib/utility.test.d.ts +35 -0
  471. package/build/src/types/tests/lib/workflow-templates.test.d.ts +18 -2
  472. package/build/src/types/tests/rules/eslint/conventions/require-node-protocol.test.d.ts +8 -0
  473. package/build/src/types/tests/rules/eslint/jsdoc/require-jsdoc-presence.test.d.ts +8 -0
  474. package/build/src/types/tests/rules/eslint/jsdoc/require-jsdoc-returns.test.d.ts +8 -0
  475. package/build/src/types/tests/rules/eslint/jsdoc/require-jsdoc-since.test.d.ts +18 -0
  476. package/build/src/types/tests/rules/eslint/jsdoc/require-jsdoc-tag-order.test.d.ts +8 -0
  477. package/build/src/types/tests/rules/vitest/active-vitest.test.d.ts +56 -0
  478. package/build/src/types/tests/rules/vitest/dotenv.test.d.ts +19 -0
  479. package/build/src/types/tests/rules/vitest/enable.test.d.ts +27 -0
  480. package/build/src/types/tests/rules/vitest/frontmatter.test.d.ts +22 -0
  481. package/build/src/types/tests/rules/vitest/link.test.d.ts +74 -0
  482. package/build/src/types/tests/rules/vitest/markdown-table.test.d.ts +28 -0
  483. package/build/src/types/tests/rules/vitest/terminology.test.d.ts +43 -0
  484. package/build/src/types/tests/rules/vitest/type-declarations.test.d.ts +10 -0
  485. package/build/src/types/tests/scaffold-version-drift.test.d.ts +42 -0
  486. package/build/src/types/tests/since-version.test.d.ts +137 -0
  487. package/build/src/types/tests/toolkit/logger.test.d.ts +70 -5
  488. package/build/src/types/tests/toolkit/nova-identity.test.d.ts +118 -0
  489. package/build/src/types/tests/type-declarations.test.d.ts +40 -1813
  490. package/build/src/types/toolkit/logger.d.ts +4 -0
  491. package/build/src/types/toolkit/nova-identity.d.ts +313 -0
  492. package/build/templates/generators/github/workflows/check-sponsor-gated-issues/base.yml +1 -1
  493. package/build/templates/generators/github/workflows/publish/base.yml +3 -1
  494. package/build/templates/generators/github/workflows/publish/targets/cloudflare-pages-docusaurus.yml +1 -1
  495. package/build/templates/generators/github/workflows/publish/targets/cloudflare-workers.yml +36 -0
  496. package/build/templates/generators/github/workflows/publish/targets/docker-hub.yml +1 -1
  497. package/build/templates/generators/github/workflows/publish/targets/ghcr.yml +1 -1
  498. package/build/templates/generators/github/workflows/publish/targets/github-action.yml +1 -1
  499. package/build/templates/generators/github/workflows/publish/targets/github-packages.yml +1 -1
  500. package/build/templates/generators/github/workflows/publish/targets/github-pages-docusaurus.yml +4 -4
  501. package/build/templates/generators/github/workflows/publish/targets/npm.yml +1 -1
  502. package/build/templates/generators/github/workflows/publish/targets/vercel-nextjs.yml +1 -1
  503. package/build/templates/generators/must-haves/agent-conventions/AGENTS.md +1 -2
  504. package/build/templates/generators/must-haves/agent-conventions/CLAUDE.md +1 -2
  505. package/build/templates/generators/must-haves/agent-conventions/conventions/java.md +5 -5
  506. package/build/templates/generators/must-haves/agent-conventions/conventions/kotlin.md +4 -4
  507. package/build/templates/generators/must-haves/agent-conventions/conventions/php.md +2 -2
  508. package/build/templates/generators/must-haves/agent-conventions/conventions/typescript.md +6 -6
  509. package/build/templates/generators/must-haves/agent-conventions/conventions/universal.md +2 -0
  510. package/build/templates/generators/must-haves/dotenv/env +5 -2
  511. package/build/templates/generators/must-haves/dotenv/env.sample +6 -3
  512. package/build/templates/generators/must-haves/gitignore/gitignore +6 -0
  513. package/build/templates/scaffold/app/express/package.json +5 -5
  514. package/build/templates/scaffold/app/nextjs/package.json +7 -7
  515. package/build/templates/scaffold/app/vite/package.json +3 -3
  516. package/build/templates/scaffold/app/workers/package.json +3 -3
  517. package/build/templates/scaffold/docs/docusaurus/docs/intro.md +6 -0
  518. package/build/templates/scaffold/docs/docusaurus/docusaurus.config.ts +9 -3
  519. package/build/templates/scaffold/docs/docusaurus/package.json +14 -7
  520. package/build/templates/scaffold/docs/docusaurus/src/tests/frontmatter.test.ts +25 -0
  521. package/build/templates/scaffold/docs/docusaurus/src/tests/link.test.ts +16 -0
  522. package/build/templates/scaffold/docs/docusaurus/src/tests/markdown-table.test.ts +16 -0
  523. package/build/templates/scaffold/docs/docusaurus/src/tests/terminology.test.ts +16 -0
  524. package/build/templates/scaffold/docs/docusaurus/src/tests/type-declarations.test.ts +17 -0
  525. package/build/templates/scaffold/docs/docusaurus/vitest.config.ts +22 -0
  526. package/build/templates/scaffold/docs/docusaurus/vitest.setup.ts +26 -0
  527. package/package.json +14 -10
  528. package/build/src/cli/generate/github/workflows.d.ts +0 -17
  529. package/build/src/cli/generate/github/workflows.d.ts.map +0 -1
  530. package/build/src/cli/generate/github/workflows.js +0 -856
  531. package/build/src/cli/generate/github/workflows.js.map +0 -1
  532. package/build/src/types/cli/generate/github/workflows.d.ts +0 -596
  533. package/build/src/types/tests/cli/generate/github/workflows-helpers.test.d.ts +0 -239
  534. package/build/src/types/tests/cli/generate/github/workflows.test.d.ts +0 -587
  535. package/build/templates/generators/github/workflows/publish/targets/aws-amplify-nextjs.yml +0 -32
  536. package/build/templates/generators/must-haves/agent-conventions/cursorrules +0 -55
@@ -0,0 +1,2251 @@
1
+ import { promises as fs } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import chalk from 'chalk';
4
+ import { libEnvNamespace } from '../../../lib/env-namespace.js';
5
+ import { Runner as LibNovaConfig } from '../../../lib/nova-config.js';
6
+ import { LIB_REGEX_CHARACTER_BACKSLASH, LIB_REGEX_CHARACTER_BACKTICK, LIB_REGEX_CHARACTER_DOLLAR, LIB_REGEX_CHARACTER_DOUBLE_QUOTE, LIB_REGEX_CHARACTER_FORWARD_SLASH, LIB_REGEX_PATTERN_LEADING_DOT_SLASH, } from '../../../lib/regex.js';
7
+ import { isProjectRoot, pathExists, renameFileWithDate, saveGeneratedFile, } from '../../../lib/utility.js';
8
+ import { Logger } from '../../../toolkit/index.js';
9
+ import { Runner as Validator } from './workflows-blueprint-validate.js';
10
+ import { Runner as Variables } from './workflows-blueprint-variables.js';
11
+ export class Runner {
12
+ static async generate(options) {
13
+ const currentDirectory = process.cwd();
14
+ const isAtProjectRoot = await isProjectRoot(currentDirectory);
15
+ if (isAtProjectRoot !== true) {
16
+ process.exitCode = 1;
17
+ return 'cancelled';
18
+ }
19
+ const isDryRun = options['dryRun'] === true;
20
+ const isReplaceFile = options['replaceFile'] === true;
21
+ if (isDryRun === true) {
22
+ Logger.customize({
23
+ name: 'Runner.generate',
24
+ purpose: 'options',
25
+ }).warn('Dry run enabled. File changes will not be made in this session.');
26
+ }
27
+ if (isReplaceFile === true) {
28
+ const replaceFileNotice = (isDryRun === true) ? 'This option has no effect during a dry run session.' : 'Backup file will not be created.';
29
+ Logger.customize({
30
+ name: 'Runner.generate',
31
+ purpose: 'options',
32
+ }).warn(`Replace file enabled. ${replaceFileNotice}`);
33
+ }
34
+ const config = await new LibNovaConfig().load();
35
+ const workspaces = config['workspaces'] ?? {};
36
+ const environment = config['environment'] ?? {};
37
+ const configPath = join(currentDirectory, 'nova.config.json');
38
+ let rawConfig = {};
39
+ try {
40
+ const rawContent = await fs.readFile(configPath, 'utf-8');
41
+ rawConfig = JSON.parse(rawContent);
42
+ }
43
+ catch {
44
+ Logger.customize({
45
+ name: 'Runner.generate',
46
+ purpose: 'config',
47
+ }).error('Failed to read or parse "nova.config.json".');
48
+ process.exitCode = 1;
49
+ return 'cancelled';
50
+ }
51
+ const rawWorkflows = rawConfig['workflows'];
52
+ if (Array.isArray(rawWorkflows) === false || rawWorkflows.length === 0) {
53
+ Logger.customize({
54
+ name: 'Runner.generate',
55
+ purpose: 'skip',
56
+ }).info('No workflows configured.');
57
+ return 'completed';
58
+ }
59
+ const validation = Validator.validate(rawWorkflows, workspaces);
60
+ const validatedWorkflows = validation['workflows'];
61
+ for (const diagnosticEntry of validation['diagnostics']) {
62
+ const diagnostic = diagnosticEntry;
63
+ Logger.customize({
64
+ name: 'Runner.generate',
65
+ purpose: 'validate',
66
+ }).error(diagnostic['message']);
67
+ }
68
+ if (validation['diagnostics'].length > 0) {
69
+ process.exitCode = 1;
70
+ }
71
+ const workflowsDirectory = join(currentDirectory, '.github', 'workflows');
72
+ const generatedSet = new Set();
73
+ const setupLines = [];
74
+ const useTurbo = await pathExists(join(currentDirectory, 'turbo.json'));
75
+ for (const workflowEntry of validatedWorkflows) {
76
+ const entry = workflowEntry;
77
+ const template = entry['template'];
78
+ const suffix = entry['name'];
79
+ const outputFileName = (suffix !== undefined) ? `nova-${template}-${suffix}.yml` : `nova-${template}.yml`;
80
+ const serialized = Runner.dispatch(entry, workspaces, environment, validatedWorkflows, useTurbo);
81
+ const entrySetupLines = Variables.collectSetupLines(entry, outputFileName, environment);
82
+ generatedSet.add(outputFileName);
83
+ setupLines.push(...entrySetupLines);
84
+ if (isDryRun === true) {
85
+ Logger.customize({
86
+ name: 'Runner.generate',
87
+ purpose: 'dry-run',
88
+ }).info(`Would generate ${chalk.cyan(`".github/workflows/${outputFileName}"`)}.`);
89
+ continue;
90
+ }
91
+ const targetPath = join(workflowsDirectory, outputFileName);
92
+ await saveGeneratedFile(targetPath, serialized, isReplaceFile);
93
+ }
94
+ if (isDryRun !== true
95
+ && validation['diagnostics'].length === 0
96
+ && await pathExists(workflowsDirectory) === true) {
97
+ let existingEntries = [];
98
+ try {
99
+ existingEntries = await fs.readdir(workflowsDirectory, { withFileTypes: true });
100
+ }
101
+ catch {
102
+ }
103
+ for (const existingEntry of existingEntries) {
104
+ const existingDirent = existingEntry;
105
+ if (existingDirent.isFile() !== true) {
106
+ continue;
107
+ }
108
+ const isOrphan = existingDirent.name.startsWith('nova-') === true
109
+ && existingDirent.name.endsWith('.yml') === true
110
+ && generatedSet.has(existingDirent.name) === false;
111
+ const isBackup = existingDirent.name.includes('.nova-backup.') === true;
112
+ if (isOrphan !== true || isBackup === true) {
113
+ continue;
114
+ }
115
+ const orphanPath = join(workflowsDirectory, existingDirent.name);
116
+ if (isReplaceFile === true) {
117
+ await fs.unlink(orphanPath);
118
+ Logger.customize({
119
+ name: 'Runner.generate',
120
+ purpose: 'cleanup',
121
+ }).info(`Deleted orphan ${chalk.cyan(`"${existingDirent.name}"`)}.`);
122
+ }
123
+ else {
124
+ await renameFileWithDate(orphanPath);
125
+ Logger.customize({
126
+ name: 'Runner.generate',
127
+ purpose: 'cleanup',
128
+ }).info(`Backed up orphan ${chalk.cyan(`"${existingDirent.name}"`)}.`);
129
+ }
130
+ }
131
+ }
132
+ if (setupLines.length > 0) {
133
+ const setupMessage = [
134
+ 'Setup:',
135
+ setupLines.join('\n'),
136
+ ].join('\n');
137
+ Logger.customize({
138
+ name: 'Runner.generate',
139
+ purpose: 'setup',
140
+ padTop: 1,
141
+ }).info(setupMessage);
142
+ }
143
+ return 'completed';
144
+ }
145
+ static dispatch(entry, workspaces, environment = {}, siblings = [], useTurbo = true) {
146
+ const template = entry['template'];
147
+ let workflow = undefined;
148
+ if (template === 'check-sponsor-gated-issues') {
149
+ workflow = Runner.buildCheckSponsorGatedIssues(entry, environment);
150
+ }
151
+ else if (template === 'lock-inactive-issues') {
152
+ workflow = Runner.buildLockInactiveIssues(entry, environment);
153
+ }
154
+ else {
155
+ workflow = Runner.buildPublish(entry, workspaces, environment, siblings, useTurbo);
156
+ }
157
+ return Runner.serialize(workflow);
158
+ }
159
+ static serialize(workflow) {
160
+ const lines = [];
161
+ lines.push(...Runner.serializeHeader());
162
+ lines.push('');
163
+ lines.push(`name: ${Runner.quote(workflow['name'])}`);
164
+ lines.push('');
165
+ lines.push(`run-name: ${Runner.quote(workflow['runName'])}`);
166
+ lines.push('');
167
+ lines.push(...Runner.serializeOn(workflow['on']));
168
+ lines.push('');
169
+ lines.push('permissions:');
170
+ lines.push(...Runner.serializePermissions(workflow['permissions'], ' '));
171
+ lines.push('');
172
+ lines.push('concurrency:');
173
+ lines.push(` group: ${Runner.quote(workflow['concurrency']['group'])}`);
174
+ lines.push(` cancel-in-progress: ${Runner.serializeScalar(workflow['concurrency']['cancelInProgress'])}`);
175
+ lines.push('');
176
+ lines.push(...Runner.serializeEnv(workflow['env']));
177
+ lines.push('');
178
+ lines.push(...Runner.serializeJobs(workflow['jobs']));
179
+ return `${lines.join('\n')}\n`;
180
+ }
181
+ static buildCheckSponsorGatedIssues(entry, environment = {}) {
182
+ const suffix = entry['name'];
183
+ const workflowId = Runner.resolveWorkflowId(suffix);
184
+ const workflowEnvironments = environment['workflows'];
185
+ const workflowEnvironment = (workflowEnvironments === undefined) ? undefined : workflowEnvironments[suffix];
186
+ const prefix = (workflowEnvironment === undefined) ? undefined : workflowEnvironment['prefix'];
187
+ const on = [];
188
+ for (const trigger of entry['triggers']) {
189
+ if (trigger === 'issue-comment') {
190
+ on.push(Runner.buildIssueCommentTrigger());
191
+ }
192
+ if (trigger === 'issues') {
193
+ on.push(Runner.buildIssuesTrigger());
194
+ }
195
+ }
196
+ const workflowSettings = entry['with'];
197
+ const metadata = Variables.getTemplateMetadata('check-sponsor-gated-issues');
198
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
199
+ const env = [
200
+ {
201
+ key: 'ISSUE_LABELS',
202
+ value: Runner.resolveVariableExpr(variables, 'ISSUE_LABELS', undefined, workflowSettings, prefix),
203
+ },
204
+ {
205
+ key: 'ISSUE_LIMIT_COMMENTER',
206
+ value: Runner.resolveVariableExpr(variables, 'ISSUE_LIMIT_COMMENTER', undefined, workflowSettings, prefix),
207
+ },
208
+ {
209
+ key: 'ISSUE_LOCK_ON_CLOSE',
210
+ value: Runner.resolveVariableExpr(variables, 'ISSUE_LOCK_ON_CLOSE', undefined, workflowSettings, prefix),
211
+ },
212
+ {
213
+ key: 'ISSUE_MESSAGE_NOT_SPONSOR',
214
+ value: Runner.resolveVariableExpr(variables, 'ISSUE_MESSAGE_NOT_SPONSOR', undefined, workflowSettings, prefix),
215
+ },
216
+ {
217
+ key: 'ISSUE_MESSAGE_WELCOME',
218
+ value: Runner.resolveVariableExpr(variables, 'ISSUE_MESSAGE_WELCOME', undefined, workflowSettings, prefix),
219
+ },
220
+ {
221
+ key: 'IS_ORGANIZATION',
222
+ value: Runner.resolveVariableExpr(variables, 'IS_ORGANIZATION', undefined, workflowSettings, prefix),
223
+ },
224
+ {
225
+ key: 'SPONSOR_ACTIVE_ONLY',
226
+ value: Runner.resolveVariableExpr(variables, 'SPONSOR_ACTIVE_ONLY', undefined, workflowSettings, prefix),
227
+ },
228
+ {
229
+ key: 'SPONSOR_EXEMPT_FILE_LOCATION',
230
+ value: Runner.resolveVariableExpr(variables, 'SPONSOR_EXEMPT_FILE_LOCATION', undefined, workflowSettings, prefix),
231
+ },
232
+ {
233
+ key: 'SPONSOR_MINIMUM',
234
+ value: Runner.resolveVariableExpr(variables, 'SPONSOR_MINIMUM', undefined, workflowSettings, prefix),
235
+ },
236
+ ];
237
+ const step = {
238
+ name: 'Check support issues',
239
+ uses: 'mrjackyliang/sponsor-gated-support@v1.0.1',
240
+ env: [
241
+ {
242
+ key: 'GITHUB_TOKEN',
243
+ value: Runner.resolveVariableExpr(variables, 'GITHUB_TOKEN', undefined, workflowSettings, prefix),
244
+ },
245
+ {
246
+ key: 'PERSONAL_ACCESS_TOKEN',
247
+ value: Runner.resolveVariableExpr(variables, 'PERSONAL_ACCESS_TOKEN', undefined, workflowSettings, prefix),
248
+ },
249
+ ],
250
+ with: [
251
+ {
252
+ key: 'GITHUB_PERSONAL_ACCESS_TOKEN',
253
+ value: Runner.expr('env.PERSONAL_ACCESS_TOKEN'),
254
+ },
255
+ {
256
+ key: 'GITHUB_WORKFLOW_TOKEN',
257
+ value: Runner.expr('env.GITHUB_TOKEN'),
258
+ },
259
+ {
260
+ key: 'ISSUE_LABELS',
261
+ value: Runner.expr('env.ISSUE_LABELS'),
262
+ },
263
+ {
264
+ key: 'ISSUE_LIMIT_COMMENTER',
265
+ value: Runner.expr('env.ISSUE_LIMIT_COMMENTER'),
266
+ },
267
+ {
268
+ key: 'ISSUE_LOCK_ON_CLOSE',
269
+ value: Runner.expr('env.ISSUE_LOCK_ON_CLOSE'),
270
+ },
271
+ {
272
+ key: 'ISSUE_MESSAGE_NOT_SPONSOR',
273
+ value: Runner.expr('env.ISSUE_MESSAGE_NOT_SPONSOR'),
274
+ },
275
+ {
276
+ key: 'ISSUE_MESSAGE_WELCOME',
277
+ value: Runner.expr('env.ISSUE_MESSAGE_WELCOME'),
278
+ },
279
+ {
280
+ key: 'IS_ORGANIZATION',
281
+ value: Runner.expr('env.IS_ORGANIZATION'),
282
+ },
283
+ {
284
+ key: 'SPONSOR_ACTIVE_ONLY',
285
+ value: Runner.expr('env.SPONSOR_ACTIVE_ONLY'),
286
+ },
287
+ {
288
+ key: 'SPONSOR_EXEMPT_FILE_LOCATION',
289
+ value: Runner.expr('env.SPONSOR_EXEMPT_FILE_LOCATION'),
290
+ },
291
+ {
292
+ key: 'SPONSOR_MINIMUM',
293
+ value: Runner.expr('env.SPONSOR_MINIMUM'),
294
+ },
295
+ ],
296
+ };
297
+ const job = {
298
+ id: 'check-issues',
299
+ runsOn: 'ubuntu-latest',
300
+ timeoutMinutes: 5,
301
+ permissions: {
302
+ contents: 'read',
303
+ issues: 'write',
304
+ },
305
+ steps: [
306
+ {
307
+ name: 'Checkout repository',
308
+ uses: 'actions/checkout@v7',
309
+ },
310
+ step,
311
+ ],
312
+ };
313
+ return {
314
+ name: `Check Sponsor Gated Issues${workflowId}`,
315
+ runName: Runner.expr('github.event_name == \'issues\' && format(\'Analyzing issue #{0}\', github.event.issue.number) || format(\'Analyzing comment on issue #{0}\', github.event.issue.number)'),
316
+ on,
317
+ permissions: {
318
+ contents: 'read',
319
+ },
320
+ concurrency: {
321
+ group: `${Runner.expr('github.workflow')}-${Runner.expr('github.event.issue.number')}`,
322
+ cancelInProgress: false,
323
+ },
324
+ env,
325
+ jobs: [job],
326
+ };
327
+ }
328
+ static buildLockInactiveIssues(entry, environment = {}) {
329
+ const suffix = entry['name'];
330
+ const workflowId = Runner.resolveWorkflowId(suffix);
331
+ const workflowEnvironments = environment['workflows'];
332
+ const workflowEnvironment = (workflowEnvironments === undefined) ? undefined : workflowEnvironments[suffix];
333
+ const prefix = (workflowEnvironment === undefined) ? undefined : workflowEnvironment['prefix'];
334
+ const on = [];
335
+ for (const trigger of entry['triggers']) {
336
+ if (trigger === 'schedule-weekly') {
337
+ on.push(Runner.buildScheduleWeeklyTrigger());
338
+ }
339
+ if (trigger === 'schedule-daily') {
340
+ on.push(Runner.buildScheduleDailyTrigger());
341
+ }
342
+ if (trigger === 'schedule-monthly') {
343
+ on.push(Runner.buildScheduleMonthlyTrigger());
344
+ }
345
+ }
346
+ const dispatchInput = {
347
+ event: 'workflow_dispatch',
348
+ inputs: [{
349
+ name: 'dry-run',
350
+ description: 'Run without making changes',
351
+ required: false,
352
+ type: 'boolean',
353
+ default: true,
354
+ }],
355
+ };
356
+ on.push(dispatchInput);
357
+ const env = [{
358
+ key: 'DRY_RUN',
359
+ value: Runner.expr('github.event_name == \'workflow_dispatch\' && inputs.dry-run || \'false\''),
360
+ }];
361
+ const workflowSettings = entry['with'];
362
+ const metadata = Variables.getTemplateMetadata('lock-inactive-issues');
363
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
364
+ const step = {
365
+ name: 'Lock inactive threads',
366
+ uses: 'mrjackyliang/lock-inactive-threads@v1',
367
+ env: [{
368
+ key: 'GITHUB_TOKEN',
369
+ value: Runner.resolveVariableExpr(variables, 'GITHUB_TOKEN', undefined, workflowSettings, prefix),
370
+ }],
371
+ with: [
372
+ {
373
+ key: 'GITHUB_TOKEN',
374
+ value: Runner.expr('env.GITHUB_TOKEN'),
375
+ },
376
+ {
377
+ key: 'ISSUE_COMMENT',
378
+ value: 'Due to inactivity, this issue will be locked and marked as resolved. If you have any further questions or inquiries, please feel free to open a new issue.',
379
+ },
380
+ {
381
+ key: 'ISSUE_INACTIVE_DAYS',
382
+ value: '30',
383
+ },
384
+ {
385
+ key: 'ISSUE_LOCK_REASON',
386
+ value: 'resolved',
387
+ },
388
+ {
389
+ key: 'PR_COMMENT',
390
+ value: 'Due to inactivity, this pull request will be locked and marked as resolved. If you have any further questions or inquiries, please feel free to open a new pull request.',
391
+ },
392
+ {
393
+ key: 'PR_INACTIVE_DAYS',
394
+ value: '30',
395
+ },
396
+ {
397
+ key: 'PR_LOCK_REASON',
398
+ value: 'resolved',
399
+ },
400
+ {
401
+ key: 'LOG_OUTPUT',
402
+ value: 'true',
403
+ },
404
+ {
405
+ key: 'DRY_RUN',
406
+ value: Runner.expr('env.DRY_RUN'),
407
+ },
408
+ ],
409
+ };
410
+ const job = {
411
+ id: 'lock-inactive-issues',
412
+ runsOn: 'ubuntu-latest',
413
+ timeoutMinutes: 5,
414
+ steps: [step],
415
+ };
416
+ return {
417
+ name: `Lock Inactive Issues${workflowId}`,
418
+ runName: `Locking inactive issues${workflowId}\${{ github.event_name == 'workflow_dispatch' && inputs.dry-run && ' (dry run)' || '' }}`,
419
+ on,
420
+ permissions: {
421
+ issues: 'write',
422
+ },
423
+ concurrency: {
424
+ group: Runner.expr('github.workflow'),
425
+ cancelInProgress: false,
426
+ },
427
+ env,
428
+ jobs: [job],
429
+ };
430
+ }
431
+ static buildPublish(entry, workspaces, environment = {}, siblings = [], useTurbo = true) {
432
+ const suffix = entry['name'];
433
+ const workflowId = Runner.resolveWorkflowId(suffix);
434
+ const on = [];
435
+ const publishConditionParts = [];
436
+ const runNameParts = [];
437
+ const triggers = entry['triggers'];
438
+ const dependsOn = [];
439
+ for (const dependsOnTriggerValue of triggers) {
440
+ const dependsOnTrigger = dependsOnTriggerValue;
441
+ if (typeof dependsOnTrigger === 'string') {
442
+ continue;
443
+ }
444
+ if (dependsOnTrigger['name'] === 'workflow-run-success'
445
+ || dependsOnTrigger['name'] === 'workflow-run-any'
446
+ || dependsOnTrigger['name'] === 'workflow-run-failure') {
447
+ for (const workflowReference of dependsOnTrigger['workflows'] ?? []) {
448
+ dependsOn.push(workflowReference);
449
+ }
450
+ break;
451
+ }
452
+ }
453
+ const dependsOnNames = [];
454
+ for (const dependsOnReference of dependsOn) {
455
+ const reference = dependsOnReference;
456
+ const referenced = siblings.find((sibling) => `${sibling['template']}-${sibling['name']}` === reference);
457
+ if (referenced === undefined) {
458
+ continue;
459
+ }
460
+ dependsOnNames.push(Runner.resolveWorkflowDisplayName(referenced['template'], referenced['name']));
461
+ }
462
+ let hasWorkflowRunNode = false;
463
+ let jobsCondition = undefined;
464
+ for (const triggerEntry of triggers) {
465
+ const trigger = triggerEntry;
466
+ const triggerName = (typeof trigger === 'string') ? trigger : trigger['name'];
467
+ if (triggerName === 'release') {
468
+ on.push(Runner.buildReleaseTrigger());
469
+ publishConditionParts.push('github.event_name == \'release\'');
470
+ runNameParts.push('github.event.release.tag_name');
471
+ }
472
+ if (triggerName === 'tag-push') {
473
+ const tagPushTags = (typeof trigger === 'string') ? undefined : trigger['tags'];
474
+ on.push(Runner.buildTagPushTrigger(tagPushTags));
475
+ publishConditionParts.push('github.event_name == \'push\' && startsWith(github.ref, \'refs/tags/\')');
476
+ runNameParts.push('github.event_name == \'push\' && startsWith(github.ref, \'refs/tags/\') && github.ref_name');
477
+ }
478
+ if (triggerName === 'push' && typeof trigger !== 'string') {
479
+ on.push(Runner.buildPushTrigger(trigger['branches'] ?? [], trigger['paths']));
480
+ publishConditionParts.push('github.event_name == \'push\' && startsWith(github.ref, \'refs/heads/\')');
481
+ runNameParts.push('github.event_name == \'push\' && startsWith(github.ref, \'refs/heads/\') && github.ref_name');
482
+ }
483
+ if (triggerName === 'workflow-run-success'
484
+ || triggerName === 'workflow-run-any'
485
+ || triggerName === 'workflow-run-failure') {
486
+ if (hasWorkflowRunNode === false) {
487
+ on.push(Runner.buildWorkflowRunTrigger(dependsOnNames));
488
+ publishConditionParts.push('github.event_name == \'workflow_run\'');
489
+ runNameParts.push('github.event.workflow_run.head_branch');
490
+ hasWorkflowRunNode = true;
491
+ }
492
+ if (jobsCondition === undefined && triggerName === 'workflow-run-success') {
493
+ jobsCondition = Runner.expr('github.event_name != \'workflow_run\' || github.event.workflow_run.conclusion == \'success\'');
494
+ }
495
+ if (jobsCondition === undefined && triggerName === 'workflow-run-failure') {
496
+ jobsCondition = Runner.expr('github.event_name != \'workflow_run\' || github.event.workflow_run.conclusion == \'failure\'');
497
+ }
498
+ }
499
+ }
500
+ const mergedOn = [];
501
+ let mergedPush = undefined;
502
+ for (const onEntry of on) {
503
+ const onNode = onEntry;
504
+ if (onNode['event'] !== 'push') {
505
+ mergedOn.push(onNode);
506
+ continue;
507
+ }
508
+ if (mergedPush === undefined) {
509
+ mergedPush = onNode;
510
+ mergedOn.push(mergedPush);
511
+ continue;
512
+ }
513
+ const mergedBranches = [
514
+ ...(mergedPush['branches'] ?? []),
515
+ ...(onNode['branches'] ?? []),
516
+ ];
517
+ const mergedTags = [
518
+ ...(mergedPush['tags'] ?? []),
519
+ ...(onNode['tags'] ?? []),
520
+ ];
521
+ const mergedPaths = [
522
+ ...(mergedPush['paths'] ?? []),
523
+ ...(onNode['paths'] ?? []),
524
+ ];
525
+ if (mergedBranches.length > 0) {
526
+ Reflect.set(mergedPush, 'branches', mergedBranches);
527
+ }
528
+ if (mergedTags.length > 0) {
529
+ Reflect.set(mergedPush, 'tags', mergedTags);
530
+ }
531
+ if (mergedPaths.length > 0) {
532
+ Reflect.set(mergedPush, 'paths', mergedPaths);
533
+ }
534
+ }
535
+ mergedOn.push({
536
+ event: 'workflow_dispatch',
537
+ inputs: [{
538
+ name: 'dry-run',
539
+ description: 'Run without making changes',
540
+ required: false,
541
+ type: 'boolean',
542
+ default: true,
543
+ }],
544
+ });
545
+ const publishCondition = [
546
+ ...publishConditionParts.map((part) => ((part.includes('&&') === true) ? `(${part})` : part)),
547
+ '(github.event_name == \'workflow_dispatch\' && !inputs.dry-run)',
548
+ ].join(' || ');
549
+ const runNameLabel = [
550
+ ...runNameParts.map((part) => ((part.includes('&&') === true) ? `(${part})` : part)),
551
+ '\'manually\'',
552
+ ].join(' || ');
553
+ const runName = `Publishing ${Runner.expr(runNameLabel)}${workflowId}\${{ github.event_name == 'workflow_dispatch' && inputs.dry-run && ' (dry run)' || '' }}`;
554
+ const workflowSettings = entry['with'];
555
+ const metadata = Variables.getTemplateMetadata('publish');
556
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
557
+ const rootWorkingDirMeta = variables['ROOT_WORKING_DIR'] ?? { format: 'literal' };
558
+ const resolvedRootDir = Variables.resolve('ROOT_WORKING_DIR', undefined, workflowSettings, rootWorkingDirMeta);
559
+ const rootDir = (resolvedRootDir === 'ROOT_WORKING_DIR') ? './' : resolvedRootDir;
560
+ const env = [
561
+ {
562
+ key: 'PUBLISH',
563
+ value: Runner.expr(publishCondition),
564
+ },
565
+ {
566
+ key: 'ROOT_DIR',
567
+ value: rootDir,
568
+ },
569
+ ];
570
+ const scopes = entry['build'] ?? [];
571
+ const names = scopes.map((scope) => {
572
+ const workspace = workspaces[scope];
573
+ return workspace['name'];
574
+ });
575
+ const checkCommand = Runner.buildScopeCommand('check', names, useTurbo);
576
+ const buildCommand = Runner.buildScopeCommand('build', names, useTurbo);
577
+ const steps = [
578
+ {
579
+ name: 'Checkout repository',
580
+ uses: 'actions/checkout@v7',
581
+ with: [{
582
+ key: 'fetch-depth',
583
+ value: 0,
584
+ }],
585
+ },
586
+ {
587
+ name: 'Setup Node.js',
588
+ uses: 'actions/setup-node@v6',
589
+ with: [
590
+ {
591
+ key: 'node-version-file',
592
+ value: `${Runner.expr('env.ROOT_DIR')}/package.json`,
593
+ },
594
+ {
595
+ key: 'package-manager-cache',
596
+ value: false,
597
+ },
598
+ ],
599
+ },
600
+ {
601
+ name: 'Install packages',
602
+ run: Runner.installPackagesRun(),
603
+ workingDirectory: Runner.expr('env.ROOT_DIR'),
604
+ },
605
+ ];
606
+ for (const scope of scopes) {
607
+ const buildValues = Runner.appBuildValues(environment, scope);
608
+ if (buildValues.length === 0) {
609
+ continue;
610
+ }
611
+ const writeEnvStep = {
612
+ name: `Write environment file (${Runner.slugifyWorkingDir(scope)})`,
613
+ env: buildValues.map((buildValue) => ({
614
+ key: buildValue['key'],
615
+ value: (buildValue['secret'] === true) ? Runner.expr(`secrets.${buildValue['name']}`) : Runner.expr(`vars.${buildValue['name']}`),
616
+ })),
617
+ run: Runner.writeEnvRun(buildValues),
618
+ runBlock: true,
619
+ workingDirectory: scope,
620
+ };
621
+ steps.push(writeEnvStep);
622
+ }
623
+ steps.push({
624
+ name: 'Check project',
625
+ run: checkCommand,
626
+ runBlock: true,
627
+ workingDirectory: Runner.expr('env.ROOT_DIR'),
628
+ });
629
+ steps.push({
630
+ name: 'Build project',
631
+ run: buildCommand,
632
+ runBlock: true,
633
+ workingDirectory: Runner.expr('env.ROOT_DIR'),
634
+ });
635
+ const targets = entry['deploy'] ?? [];
636
+ for (const target of targets) {
637
+ const uploadTarget = target;
638
+ const uploadMetadata = Variables.getTargetMetadata('publish', uploadTarget['to']);
639
+ const uploadArtifactPaths = (uploadMetadata === undefined) ? ['{workingDir}/build'] : uploadMetadata['artifactPaths'];
640
+ if (uploadArtifactPaths.length === 0) {
641
+ continue;
642
+ }
643
+ const uploadWorkingDir = uploadTarget['path'].replace(LIB_REGEX_PATTERN_LEADING_DOT_SLASH, '');
644
+ const uploadPath = uploadArtifactPaths.map((artifactPath) => artifactPath.replace('{workingDir}', uploadWorkingDir)).join('\n');
645
+ const artifactName = `build-${uploadTarget['to']}-${Runner.slugifyWorkingDir(uploadTarget['path'])}`;
646
+ const uploadStep = {
647
+ name: `Upload build artifacts (${uploadTarget['to']}/${Runner.slugifyWorkingDir(uploadTarget['path'])})`,
648
+ uses: 'actions/upload-artifact@v7',
649
+ with: [
650
+ {
651
+ key: 'name',
652
+ value: artifactName,
653
+ },
654
+ {
655
+ key: 'retention-days',
656
+ value: 1,
657
+ },
658
+ {
659
+ key: 'path',
660
+ value: uploadPath,
661
+ block: true,
662
+ },
663
+ ],
664
+ };
665
+ steps.push(uploadStep);
666
+ }
667
+ const buildJob = {
668
+ id: 'build',
669
+ runsOn: 'ubuntu-latest',
670
+ timeoutMinutes: 15,
671
+ permissions: {
672
+ contents: 'read',
673
+ },
674
+ steps,
675
+ };
676
+ const jobs = [buildJob];
677
+ for (const target of targets) {
678
+ const deployTarget = target;
679
+ const targetSettings = deployTarget['with'];
680
+ const context = {
681
+ workingDir: deployTarget['path'],
682
+ artifactName: `build-${deployTarget['to']}-${Runner.slugifyWorkingDir(deployTarget['path'])}`,
683
+ needs: Runner.resolveDeployNeeds(deployTarget),
684
+ targetSettings,
685
+ workflowSettings,
686
+ workspace: workspaces[deployTarget['path']],
687
+ environment,
688
+ };
689
+ if (deployTarget['to'] === 'npm') {
690
+ jobs.push(Runner.buildNpmTarget(context));
691
+ }
692
+ else if (deployTarget['to'] === 'github-packages') {
693
+ jobs.push(Runner.buildGithubPackagesTarget(context));
694
+ }
695
+ else if (deployTarget['to'] === 'cloudflare-pages-docusaurus') {
696
+ jobs.push(Runner.buildCloudflarePagesDocusaurusTarget(context));
697
+ }
698
+ else if (deployTarget['to'] === 'cloudflare-workers') {
699
+ jobs.push(Runner.buildCloudflareWorkersTarget(context));
700
+ }
701
+ else if (deployTarget['to'] === 'docker-hub') {
702
+ jobs.push(Runner.buildDockerHubTarget(context));
703
+ }
704
+ else if (deployTarget['to'] === 'ghcr') {
705
+ jobs.push(Runner.buildGhcrTarget(context));
706
+ }
707
+ else if (deployTarget['to'] === 'github-pages-docusaurus') {
708
+ jobs.push(Runner.buildGithubPagesDocusaurusTarget(context));
709
+ }
710
+ else if (deployTarget['to'] === 'github-action') {
711
+ jobs.push(Runner.buildGithubActionTarget(context));
712
+ }
713
+ else if (deployTarget['to'] === 'vercel-nextjs') {
714
+ jobs.push(Runner.buildVercelNextjsTarget(context));
715
+ }
716
+ }
717
+ if (jobsCondition !== undefined) {
718
+ for (const gatedJob of jobs) {
719
+ Reflect.set(gatedJob, 'if', jobsCondition);
720
+ }
721
+ }
722
+ return {
723
+ name: `Publish${workflowId}`,
724
+ runName,
725
+ on: mergedOn,
726
+ permissions: {
727
+ contents: 'read',
728
+ },
729
+ concurrency: {
730
+ group: `${Runner.expr('github.workflow')}-${Runner.expr('github.ref')}`,
731
+ cancelInProgress: false,
732
+ },
733
+ env,
734
+ jobs,
735
+ };
736
+ }
737
+ static buildReleaseTrigger() {
738
+ return {
739
+ event: 'release',
740
+ types: ['published'],
741
+ };
742
+ }
743
+ static buildTagPushTrigger(tags = ['v*']) {
744
+ return {
745
+ event: 'push',
746
+ tags,
747
+ };
748
+ }
749
+ static buildPushTrigger(branches, paths) {
750
+ if (paths === undefined) {
751
+ return {
752
+ event: 'push',
753
+ branches,
754
+ };
755
+ }
756
+ return {
757
+ event: 'push',
758
+ branches,
759
+ paths,
760
+ };
761
+ }
762
+ static buildWorkflowRunTrigger(workflows) {
763
+ return {
764
+ event: 'workflow_run',
765
+ workflows,
766
+ types: ['completed'],
767
+ };
768
+ }
769
+ static buildNpmTarget(context) {
770
+ const targetSettings = context['targetSettings'];
771
+ const workflowSettings = context['workflowSettings'];
772
+ const metadata = Variables.getTargetMetadata('publish', 'npm');
773
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
774
+ const environment = context['environment'];
775
+ const appPath = context['workingDir'];
776
+ return {
777
+ id: `publish-npm-${Runner.slugifyWorkingDir(context['workingDir'])}`,
778
+ needs: context['needs'],
779
+ runsOn: 'ubuntu-latest',
780
+ timeoutMinutes: 10,
781
+ permissions: {
782
+ 'contents': 'read',
783
+ 'id-token': 'write',
784
+ },
785
+ steps: [
786
+ {
787
+ name: 'Checkout repository',
788
+ uses: 'actions/checkout@v7',
789
+ },
790
+ {
791
+ name: 'Setup Node.js',
792
+ uses: 'actions/setup-node@v6',
793
+ with: [
794
+ {
795
+ key: 'node-version-file',
796
+ value: `${Runner.expr('env.ROOT_DIR')}/package.json`,
797
+ },
798
+ {
799
+ key: 'package-manager-cache',
800
+ value: false,
801
+ },
802
+ {
803
+ key: 'registry-url',
804
+ value: 'https://registry.npmjs.org',
805
+ },
806
+ ],
807
+ },
808
+ {
809
+ name: 'Remove deprecated .npmrc entries',
810
+ run: Runner.removeDeprecatedNpmrcRun(),
811
+ },
812
+ {
813
+ name: 'Download build artifacts',
814
+ uses: 'actions/download-artifact@v8',
815
+ with: [
816
+ {
817
+ key: 'name',
818
+ value: context['artifactName'],
819
+ },
820
+ {
821
+ key: 'path',
822
+ value: `${context['workingDir']}/build`,
823
+ },
824
+ ],
825
+ },
826
+ {
827
+ name: 'Configure authentication',
828
+ env: [{
829
+ key: 'NPM_TOKEN',
830
+ value: Runner.resolveScopedCredExpr(variables, 'NPM_TOKEN', targetSettings, workflowSettings, environment, appPath),
831
+ }],
832
+ run: Runner.npmAuthRun(),
833
+ },
834
+ {
835
+ name: 'Publish package to npm',
836
+ run: Runner.npmPublishRun(),
837
+ workingDirectory: context['workingDir'],
838
+ },
839
+ ],
840
+ };
841
+ }
842
+ static buildGithubPackagesTarget(context) {
843
+ const targetSettings = context['targetSettings'];
844
+ const workflowSettings = context['workflowSettings'];
845
+ const metadata = Variables.getTargetMetadata('publish', 'github-packages');
846
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
847
+ return {
848
+ id: `publish-github-packages-${Runner.slugifyWorkingDir(context['workingDir'])}`,
849
+ needs: context['needs'],
850
+ runsOn: 'ubuntu-latest',
851
+ timeoutMinutes: 10,
852
+ permissions: {
853
+ 'contents': 'read',
854
+ 'packages': 'write',
855
+ 'id-token': 'write',
856
+ },
857
+ steps: [
858
+ {
859
+ name: 'Checkout repository',
860
+ uses: 'actions/checkout@v7',
861
+ },
862
+ {
863
+ name: 'Setup Node.js',
864
+ uses: 'actions/setup-node@v6',
865
+ with: [
866
+ {
867
+ key: 'node-version-file',
868
+ value: `${Runner.expr('env.ROOT_DIR')}/package.json`,
869
+ },
870
+ {
871
+ key: 'package-manager-cache',
872
+ value: false,
873
+ },
874
+ ],
875
+ },
876
+ {
877
+ name: 'Configure registry for GitHub Packages',
878
+ uses: 'actions/setup-node@v6',
879
+ with: [
880
+ {
881
+ key: 'node-version-file',
882
+ value: `${Runner.expr('env.ROOT_DIR')}/package.json`,
883
+ },
884
+ {
885
+ key: 'package-manager-cache',
886
+ value: false,
887
+ },
888
+ {
889
+ key: 'registry-url',
890
+ value: 'https://npm.pkg.github.com',
891
+ },
892
+ {
893
+ key: 'scope',
894
+ value: `@${Runner.expr('github.repository_owner')}`,
895
+ },
896
+ ],
897
+ },
898
+ {
899
+ name: 'Remove deprecated .npmrc entries',
900
+ run: Runner.removeDeprecatedNpmrcRun(),
901
+ },
902
+ {
903
+ name: 'Download build artifacts',
904
+ uses: 'actions/download-artifact@v8',
905
+ with: [
906
+ {
907
+ key: 'name',
908
+ value: context['artifactName'],
909
+ },
910
+ {
911
+ key: 'path',
912
+ value: `${context['workingDir']}/build`,
913
+ },
914
+ ],
915
+ },
916
+ {
917
+ name: 'Change to scoped package name',
918
+ run: Runner.scopePackageNameRun(),
919
+ workingDirectory: context['workingDir'],
920
+ },
921
+ {
922
+ name: 'Configure authentication',
923
+ env: [{
924
+ key: 'GITHUB_TOKEN',
925
+ value: Runner.resolveVariableExpr(variables, 'GITHUB_TOKEN', targetSettings, workflowSettings),
926
+ }],
927
+ run: Runner.githubAuthRun(),
928
+ },
929
+ {
930
+ name: 'Publish package to GitHub Packages',
931
+ run: Runner.githubPublishRun(),
932
+ workingDirectory: context['workingDir'],
933
+ },
934
+ {
935
+ name: 'Restore package name',
936
+ if: Runner.expr('always() && env.PACKAGE_NAME'),
937
+ run: 'npm pkg set name="$PACKAGE_NAME"',
938
+ runBlock: true,
939
+ workingDirectory: context['workingDir'],
940
+ },
941
+ ],
942
+ };
943
+ }
944
+ static buildCloudflarePagesDocusaurusTarget(context) {
945
+ const targetSettings = context['targetSettings'];
946
+ const workflowSettings = context['workflowSettings'];
947
+ const metadata = Variables.getTargetMetadata('publish', 'cloudflare-pages-docusaurus');
948
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
949
+ const environment = context['environment'];
950
+ const appPath = context['workingDir'];
951
+ return {
952
+ id: `publish-cloudflare-pages-docusaurus-${Runner.slugifyWorkingDir(context['workingDir'])}`,
953
+ needs: context['needs'],
954
+ runsOn: 'ubuntu-latest',
955
+ timeoutMinutes: 10,
956
+ permissions: {
957
+ contents: 'read',
958
+ },
959
+ steps: [
960
+ {
961
+ name: 'Checkout repository',
962
+ uses: 'actions/checkout@v7',
963
+ },
964
+ {
965
+ name: 'Download build artifacts',
966
+ uses: 'actions/download-artifact@v8',
967
+ with: [
968
+ {
969
+ key: 'name',
970
+ value: context['artifactName'],
971
+ },
972
+ {
973
+ key: 'path',
974
+ value: `${context['workingDir']}/build`,
975
+ },
976
+ ],
977
+ },
978
+ {
979
+ name: 'Deploy to Cloudflare Pages',
980
+ if: Runner.expr('env.PUBLISH == \'true\''),
981
+ uses: 'cloudflare/wrangler-action@v3',
982
+ env: [{
983
+ key: 'CLOUDFLARE_API_TOKEN',
984
+ value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_API_TOKEN', targetSettings, workflowSettings, environment, appPath),
985
+ }],
986
+ with: [
987
+ {
988
+ key: 'apiToken',
989
+ value: Runner.expr('env.CLOUDFLARE_API_TOKEN'),
990
+ },
991
+ {
992
+ key: 'accountId',
993
+ value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_ACCOUNT_ID', targetSettings, workflowSettings, environment, appPath),
994
+ },
995
+ {
996
+ key: 'command',
997
+ value: `pages deploy ${context['workingDir']}/build --project-name=${Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_PROJECT_NAME', targetSettings, workflowSettings, environment, appPath)} --branch=${Runner.expr('github.event.repository.default_branch')}`,
998
+ },
999
+ ],
1000
+ },
1001
+ ],
1002
+ };
1003
+ }
1004
+ static buildCloudflareWorkersTarget(context) {
1005
+ const targetSettings = context['targetSettings'];
1006
+ const workflowSettings = context['workflowSettings'];
1007
+ const metadata = Variables.getTargetMetadata('publish', 'cloudflare-workers');
1008
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
1009
+ const environment = context['environment'];
1010
+ const appPath = context['workingDir'];
1011
+ const runtimeValues = Runner.appRuntimeValues(environment, appPath);
1012
+ const steps = [
1013
+ {
1014
+ name: 'Checkout repository',
1015
+ uses: 'actions/checkout@v7',
1016
+ },
1017
+ {
1018
+ name: 'Setup Node.js',
1019
+ uses: 'actions/setup-node@v6',
1020
+ with: [
1021
+ {
1022
+ key: 'node-version-file',
1023
+ value: `${Runner.expr('env.ROOT_DIR')}/package.json`,
1024
+ },
1025
+ {
1026
+ key: 'package-manager-cache',
1027
+ value: false,
1028
+ },
1029
+ ],
1030
+ },
1031
+ {
1032
+ name: 'Install packages',
1033
+ run: Runner.installPackagesRun(),
1034
+ workingDirectory: Runner.expr('env.ROOT_DIR'),
1035
+ },
1036
+ {
1037
+ name: 'Download build artifacts',
1038
+ uses: 'actions/download-artifact@v8',
1039
+ with: [
1040
+ {
1041
+ key: 'name',
1042
+ value: context['artifactName'],
1043
+ },
1044
+ {
1045
+ key: 'path',
1046
+ value: `${context['workingDir']}/build`,
1047
+ },
1048
+ ],
1049
+ },
1050
+ {
1051
+ name: 'Deploy to Cloudflare Workers',
1052
+ if: Runner.expr('env.PUBLISH == \'true\''),
1053
+ env: [
1054
+ {
1055
+ key: 'CLOUDFLARE_API_TOKEN',
1056
+ value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_API_TOKEN', targetSettings, workflowSettings, environment, appPath),
1057
+ },
1058
+ {
1059
+ key: 'CLOUDFLARE_ACCOUNT_ID',
1060
+ value: Runner.resolveScopedCredExpr(variables, 'CLOUDFLARE_ACCOUNT_ID', targetSettings, workflowSettings, environment, appPath),
1061
+ },
1062
+ ],
1063
+ run: 'npm run deploy',
1064
+ workingDirectory: context['workingDir'],
1065
+ },
1066
+ ];
1067
+ const syncStep = Runner.emitRuntimeSyncStep({
1068
+ vendor: 'cloudflare',
1069
+ runtimeValues,
1070
+ workingDir: context['workingDir'],
1071
+ extraEnv: [],
1072
+ });
1073
+ if (syncStep !== undefined) {
1074
+ steps.push(syncStep);
1075
+ }
1076
+ return {
1077
+ id: `publish-cloudflare-workers-${Runner.slugifyWorkingDir(context['workingDir'])}`,
1078
+ needs: context['needs'],
1079
+ runsOn: 'ubuntu-latest',
1080
+ timeoutMinutes: 10,
1081
+ permissions: {
1082
+ contents: 'read',
1083
+ },
1084
+ steps,
1085
+ };
1086
+ }
1087
+ static buildDockerHubTarget(context) {
1088
+ const targetSettings = context['targetSettings'];
1089
+ const workflowSettings = context['workflowSettings'];
1090
+ const metadata = Variables.getTargetMetadata('publish', 'docker-hub');
1091
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
1092
+ const environment = context['environment'];
1093
+ const appPath = context['workingDir'];
1094
+ const imageTags = [
1095
+ `${Runner.expr('github.repository')}:latest`,
1096
+ `${Runner.expr('github.repository')}:${Runner.expr('github.event.release.tag_name || \'manual\'')}`,
1097
+ ].join('\n');
1098
+ return {
1099
+ id: `publish-docker-hub-${Runner.slugifyWorkingDir(context['workingDir'])}`,
1100
+ needs: context['needs'],
1101
+ runsOn: 'ubuntu-latest',
1102
+ timeoutMinutes: 15,
1103
+ permissions: {
1104
+ 'contents': 'read',
1105
+ 'attestations': 'write',
1106
+ 'id-token': 'write',
1107
+ },
1108
+ steps: [
1109
+ {
1110
+ name: 'Checkout repository',
1111
+ uses: 'actions/checkout@v7',
1112
+ },
1113
+ {
1114
+ name: 'Set up QEMU',
1115
+ uses: 'docker/setup-qemu-action@v3',
1116
+ with: [{
1117
+ key: 'platforms',
1118
+ value: 'linux/amd64,linux/arm64',
1119
+ }],
1120
+ },
1121
+ {
1122
+ name: 'Set up Docker Buildx',
1123
+ uses: 'docker/setup-buildx-action@v3',
1124
+ },
1125
+ {
1126
+ name: 'Login to Docker Hub',
1127
+ uses: 'docker/login-action@v3',
1128
+ env: [{
1129
+ key: 'DOCKERHUB_TOKEN',
1130
+ value: Runner.resolveScopedCredExpr(variables, 'DOCKERHUB_TOKEN', targetSettings, workflowSettings, environment, appPath),
1131
+ }],
1132
+ with: [
1133
+ {
1134
+ key: 'username',
1135
+ value: Runner.resolveScopedCredExpr(variables, 'DOCKERHUB_USERNAME', targetSettings, workflowSettings, environment, appPath),
1136
+ },
1137
+ {
1138
+ key: 'password',
1139
+ value: Runner.expr('env.DOCKERHUB_TOKEN'),
1140
+ },
1141
+ ],
1142
+ },
1143
+ {
1144
+ name: 'Build and push',
1145
+ id: 'build-push',
1146
+ uses: 'docker/build-push-action@v6',
1147
+ with: [
1148
+ {
1149
+ key: 'context',
1150
+ value: context['workingDir'],
1151
+ },
1152
+ {
1153
+ key: 'platforms',
1154
+ value: 'linux/amd64,linux/arm64',
1155
+ },
1156
+ {
1157
+ key: 'push',
1158
+ value: Runner.expr('env.PUBLISH'),
1159
+ },
1160
+ {
1161
+ key: 'tags',
1162
+ value: imageTags,
1163
+ block: true,
1164
+ },
1165
+ ],
1166
+ },
1167
+ {
1168
+ name: 'Generate build provenance',
1169
+ if: Runner.expr('env.PUBLISH == \'true\''),
1170
+ uses: 'actions/attest-build-provenance@v2',
1171
+ with: [
1172
+ {
1173
+ key: 'subject-name',
1174
+ value: `docker.io/${Runner.expr('github.repository')}`,
1175
+ },
1176
+ {
1177
+ key: 'subject-digest',
1178
+ value: Runner.expr('steps.build-push.outputs.digest'),
1179
+ },
1180
+ {
1181
+ key: 'push-to-registry',
1182
+ value: true,
1183
+ },
1184
+ ],
1185
+ },
1186
+ ],
1187
+ };
1188
+ }
1189
+ static buildGhcrTarget(context) {
1190
+ const targetSettings = context['targetSettings'];
1191
+ const workflowSettings = context['workflowSettings'];
1192
+ const metadata = Variables.getTargetMetadata('publish', 'ghcr');
1193
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
1194
+ const imageTags = [
1195
+ `ghcr.io/${Runner.expr('github.repository')}:latest`,
1196
+ `ghcr.io/${Runner.expr('github.repository')}:${Runner.expr('github.event.release.tag_name || \'manual\'')}`,
1197
+ ].join('\n');
1198
+ return {
1199
+ id: `publish-ghcr-${Runner.slugifyWorkingDir(context['workingDir'])}`,
1200
+ needs: context['needs'],
1201
+ runsOn: 'ubuntu-latest',
1202
+ timeoutMinutes: 15,
1203
+ permissions: {
1204
+ 'contents': 'read',
1205
+ 'packages': 'write',
1206
+ 'attestations': 'write',
1207
+ 'id-token': 'write',
1208
+ },
1209
+ steps: [
1210
+ {
1211
+ name: 'Checkout repository',
1212
+ uses: 'actions/checkout@v7',
1213
+ },
1214
+ {
1215
+ name: 'Set up QEMU',
1216
+ uses: 'docker/setup-qemu-action@v3',
1217
+ with: [{
1218
+ key: 'platforms',
1219
+ value: 'linux/amd64,linux/arm64',
1220
+ }],
1221
+ },
1222
+ {
1223
+ name: 'Set up Docker Buildx',
1224
+ uses: 'docker/setup-buildx-action@v3',
1225
+ },
1226
+ {
1227
+ name: 'Login to GitHub Container Registry',
1228
+ uses: 'docker/login-action@v3',
1229
+ with: [
1230
+ {
1231
+ key: 'registry',
1232
+ value: 'ghcr.io',
1233
+ },
1234
+ {
1235
+ key: 'username',
1236
+ value: Runner.expr('github.repository_owner'),
1237
+ },
1238
+ {
1239
+ key: 'password',
1240
+ value: Runner.resolveVariableExpr(variables, 'GITHUB_TOKEN', targetSettings, workflowSettings),
1241
+ },
1242
+ ],
1243
+ },
1244
+ {
1245
+ name: 'Build and push',
1246
+ id: 'build-push',
1247
+ uses: 'docker/build-push-action@v6',
1248
+ with: [
1249
+ {
1250
+ key: 'context',
1251
+ value: context['workingDir'],
1252
+ },
1253
+ {
1254
+ key: 'platforms',
1255
+ value: 'linux/amd64,linux/arm64',
1256
+ },
1257
+ {
1258
+ key: 'push',
1259
+ value: Runner.expr('env.PUBLISH'),
1260
+ },
1261
+ {
1262
+ key: 'tags',
1263
+ value: imageTags,
1264
+ block: true,
1265
+ },
1266
+ ],
1267
+ },
1268
+ {
1269
+ name: 'Generate build provenance',
1270
+ if: Runner.expr('env.PUBLISH == \'true\''),
1271
+ uses: 'actions/attest-build-provenance@v2',
1272
+ with: [
1273
+ {
1274
+ key: 'subject-name',
1275
+ value: `ghcr.io/${Runner.expr('github.repository')}`,
1276
+ },
1277
+ {
1278
+ key: 'subject-digest',
1279
+ value: Runner.expr('steps.build-push.outputs.digest'),
1280
+ },
1281
+ {
1282
+ key: 'push-to-registry',
1283
+ value: true,
1284
+ },
1285
+ ],
1286
+ },
1287
+ ],
1288
+ };
1289
+ }
1290
+ static buildGithubPagesDocusaurusTarget(context) {
1291
+ const targetSettings = context['targetSettings'];
1292
+ const workflowSettings = context['workflowSettings'];
1293
+ const metadata = Variables.getTargetMetadata('publish', 'github-pages-docusaurus');
1294
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
1295
+ const pagesStatusRun = [
1296
+ `if gh api "repos/${Runner.expr('github.repository')}/pages" > /dev/null 2>&1; then`,
1297
+ ' echo "[Pages] GitHub Pages is enabled."',
1298
+ ' echo "PAGES_ENABLED=true" >> "$GITHUB_ENV"',
1299
+ 'else',
1300
+ ' echo "[Pages] GitHub Pages is not enabled. Skipping deployment."',
1301
+ ' echo "PAGES_ENABLED=false" >> "$GITHUB_ENV"',
1302
+ 'fi',
1303
+ ].join('\n');
1304
+ return {
1305
+ id: `publish-github-pages-docusaurus-${Runner.slugifyWorkingDir(context['workingDir'])}`,
1306
+ needs: context['needs'],
1307
+ runsOn: 'ubuntu-latest',
1308
+ timeoutMinutes: 10,
1309
+ permissions: {
1310
+ 'contents': 'read',
1311
+ 'pages': 'write',
1312
+ 'id-token': 'write',
1313
+ },
1314
+ steps: [
1315
+ {
1316
+ name: 'Checkout repository',
1317
+ uses: 'actions/checkout@v7',
1318
+ },
1319
+ {
1320
+ name: 'Download build artifacts',
1321
+ uses: 'actions/download-artifact@v8',
1322
+ with: [
1323
+ {
1324
+ key: 'name',
1325
+ value: context['artifactName'],
1326
+ },
1327
+ {
1328
+ key: 'path',
1329
+ value: `${context['workingDir']}/build`,
1330
+ },
1331
+ ],
1332
+ },
1333
+ {
1334
+ name: 'Check GitHub Pages status',
1335
+ env: [{
1336
+ key: 'GITHUB_TOKEN',
1337
+ value: Runner.resolveVariableExpr(variables, 'GITHUB_TOKEN', targetSettings, workflowSettings),
1338
+ }],
1339
+ envAfterRun: true,
1340
+ run: pagesStatusRun,
1341
+ },
1342
+ {
1343
+ name: 'Setup GitHub Pages',
1344
+ if: Runner.expr('env.PUBLISH == \'true\' && env.PAGES_ENABLED == \'true\''),
1345
+ uses: 'actions/configure-pages@v6',
1346
+ },
1347
+ {
1348
+ name: 'Upload artifact to GitHub Pages',
1349
+ if: Runner.expr('env.PUBLISH == \'true\' && env.PAGES_ENABLED == \'true\''),
1350
+ uses: 'actions/upload-pages-artifact@v5',
1351
+ with: [{
1352
+ key: 'path',
1353
+ value: `${context['workingDir']}/build`,
1354
+ }],
1355
+ },
1356
+ {
1357
+ name: 'Deploy to GitHub Pages',
1358
+ if: Runner.expr('env.PUBLISH == \'true\' && env.PAGES_ENABLED == \'true\''),
1359
+ uses: 'actions/deploy-pages@v5',
1360
+ },
1361
+ ],
1362
+ };
1363
+ }
1364
+ static buildGithubActionTarget(context) {
1365
+ const targetSettings = context['targetSettings'];
1366
+ const workflowSettings = context['workflowSettings'];
1367
+ const metadata = Variables.getTargetMetadata('publish', 'github-action');
1368
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
1369
+ const escapedNewline = [
1370
+ '\\',
1371
+ 'n',
1372
+ ].join('');
1373
+ const actionEntryPoint = Runner.resolveVariableExpr(variables, 'ACTION_ENTRY_POINT', targetSettings, workflowSettings);
1374
+ const actionOutputPath = Runner.resolveVariableExpr(variables, 'ACTION_OUTPUT_PATH', targetSettings, workflowSettings);
1375
+ const actionYmlPath = Runner.resolveVariableExpr(variables, 'ACTION_YML_PATH', targetSettings, workflowSettings);
1376
+ const releaseBranchName = Runner.resolveVariableExpr(variables, 'RELEASE_BRANCH_NAME', targetSettings, workflowSettings);
1377
+ const configureGitIdentityRun = [
1378
+ 'set -euo pipefail',
1379
+ 'git config --global user.name "github-actions[bot]"',
1380
+ 'git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"',
1381
+ ].join('\n');
1382
+ const verifyReleaseContextRun = [
1383
+ 'set -euo pipefail',
1384
+ 'if [ -z "$TAG_NAME" ]; then',
1385
+ ' echo "::error::The github-action target requires a release.published event with a tag name. Manual workflow_dispatch with dry-run=false is not supported."',
1386
+ ' exit 1',
1387
+ 'fi',
1388
+ ].join('\n');
1389
+ const initializeReleaseWorkspaceRun = [
1390
+ 'set -euo pipefail',
1391
+ 'rm -rf "$RUNNER_TEMP/release"',
1392
+ 'mkdir -p "$RUNNER_TEMP/release"',
1393
+ 'cd "$RUNNER_TEMP/release"',
1394
+ `git init -b "${releaseBranchName}"`,
1395
+ `git remote add origin "https://github.com/${Runner.expr('github.repository')}.git"`,
1396
+ `git config --local http.https://github.com/.extraheader "Authorization: basic $(printf 'x-access-token:%s' "$GITHUB_TOKEN" | base64 | tr -d '${escapedNewline}')"`,
1397
+ '',
1398
+ '# If the release branch exists remotely, fetch and reset to it so the new commit lands on top.',
1399
+ `if git ls-remote --exit-code --heads origin "${releaseBranchName}" > /dev/null; then`,
1400
+ ` git fetch origin "${releaseBranchName}"`,
1401
+ ` git reset --hard "origin/${releaseBranchName}"`,
1402
+ ' git rm -rf . > /dev/null 2>&1 || true',
1403
+ 'fi',
1404
+ ].join('\n');
1405
+ const stageReleaseTreeRun = [
1406
+ 'set -euo pipefail',
1407
+ 'cd "$GITHUB_WORKSPACE"',
1408
+ 'STAGE="$RUNNER_TEMP/release"',
1409
+ '',
1410
+ '# Required: action.yml and the built action directory.',
1411
+ `cp "${actionYmlPath}" "$STAGE/action.yml"`,
1412
+ 'mkdir -p "$STAGE/action"',
1413
+ `cp -R "${actionOutputPath}/." "$STAGE/action/"`,
1414
+ '',
1415
+ '# Repoint action.yml at the bundled entry in the flattened release tree. The',
1416
+ '# source action.yml resolves runs.main against the working layout; the published',
1417
+ '# tree carries only action.yml plus the bundle under action/, so runs.main must',
1418
+ '# resolve there instead. Only the main key inside the runs block is rewritten.',
1419
+ `sed -i -E '/^runs:/,$ s#^([[:space:]]+main:[[:space:]]*).*#\\1"action/${actionEntryPoint}"#' "$STAGE/action.yml"`,
1420
+ '',
1421
+ '# Optional: common community-repo files. Copy if present on main, skip silently if not.',
1422
+ 'for optional in README.md LICENSE SECURITY.md NOTICE CHANGELOG.md; do',
1423
+ ' if [ -f "$optional" ]; then',
1424
+ ' cp "$optional" "$STAGE/$optional"',
1425
+ ' fi',
1426
+ 'done',
1427
+ ].join('\n');
1428
+ const commitAndPushReleaseRun = [
1429
+ 'set -euo pipefail',
1430
+ 'cd "$RUNNER_TEMP/release"',
1431
+ 'git add -A',
1432
+ 'git commit -m "Release $TAG_NAME"',
1433
+ `git push origin "${releaseBranchName}" --force`,
1434
+ ].join('\n');
1435
+ const forceRetagRun = [
1436
+ 'set -euo pipefail',
1437
+ 'cd "$RUNNER_TEMP/release"',
1438
+ '',
1439
+ '# Re-point the semver tag onto the orphan commit (GitHub created it on main; we move it).',
1440
+ 'git tag -f "$TAG_NAME"',
1441
+ 'git push origin "refs/tags/$TAG_NAME" --force',
1442
+ '',
1443
+ '# Derive floating major (e.g., v2.1.3 -> v2; primary-v1.2.3 -> primary-v1).',
1444
+ '# Skips the major retag when the tag isn\'t <prefix->v<digits> shaped or when',
1445
+ '# the release is marked as a prerelease — the floating major should only',
1446
+ '# track stable releases.',
1447
+ 'MAJOR="$(printf \'%s\' "$TAG_NAME" | sed -E \'s/^(([a-zA-Z][a-zA-Z0-9_-]*-)?v[0-9]+).*/\\1/\')"',
1448
+ 'if [ "$IS_PRERELEASE" = "true" ]; then',
1449
+ ' echo "Release $TAG_NAME is marked as a prerelease; skipping floating major retag."',
1450
+ 'elif [ "$MAJOR" = "$TAG_NAME" ]; then',
1451
+ ' echo "Tag $TAG_NAME is not v-prefixed semver; skipping floating major retag."',
1452
+ 'else',
1453
+ ' git tag -f "$MAJOR"',
1454
+ ' git push origin "refs/tags/$MAJOR" --force',
1455
+ 'fi',
1456
+ ].join('\n');
1457
+ return {
1458
+ id: `publish-github-action-${Runner.slugifyWorkingDir(context['workingDir'])}`,
1459
+ needs: context['needs'],
1460
+ runsOn: 'ubuntu-latest',
1461
+ timeoutMinutes: 10,
1462
+ permissions: {
1463
+ 'contents': 'write',
1464
+ 'id-token': 'write',
1465
+ 'attestations': 'write',
1466
+ },
1467
+ steps: [
1468
+ {
1469
+ name: 'Checkout repository',
1470
+ uses: 'actions/checkout@v7',
1471
+ with: [{
1472
+ key: 'persist-credentials',
1473
+ value: false,
1474
+ }],
1475
+ },
1476
+ {
1477
+ name: 'Download build artifacts',
1478
+ uses: 'actions/download-artifact@v8',
1479
+ with: [
1480
+ {
1481
+ key: 'name',
1482
+ value: context['artifactName'],
1483
+ },
1484
+ {
1485
+ key: 'path',
1486
+ value: actionOutputPath,
1487
+ },
1488
+ ],
1489
+ },
1490
+ {
1491
+ name: 'Configure git identity',
1492
+ if: Runner.expr('env.PUBLISH == \'true\''),
1493
+ run: configureGitIdentityRun,
1494
+ },
1495
+ {
1496
+ name: 'Verify release context',
1497
+ if: Runner.expr('env.PUBLISH == \'true\''),
1498
+ env: [{
1499
+ key: 'TAG_NAME',
1500
+ value: Runner.expr('github.event.release.tag_name'),
1501
+ }],
1502
+ run: verifyReleaseContextRun,
1503
+ },
1504
+ {
1505
+ name: 'Initialize release workspace',
1506
+ if: Runner.expr('env.PUBLISH == \'true\''),
1507
+ env: [{
1508
+ key: 'GITHUB_TOKEN',
1509
+ value: Runner.expr('secrets.GITHUB_TOKEN'),
1510
+ }],
1511
+ run: initializeReleaseWorkspaceRun,
1512
+ },
1513
+ {
1514
+ name: 'Stage release tree',
1515
+ if: Runner.expr('env.PUBLISH == \'true\''),
1516
+ run: stageReleaseTreeRun,
1517
+ },
1518
+ {
1519
+ name: 'Commit and push release',
1520
+ if: Runner.expr('env.PUBLISH == \'true\''),
1521
+ env: [{
1522
+ key: 'TAG_NAME',
1523
+ value: Runner.expr('github.event.release.tag_name'),
1524
+ }],
1525
+ run: commitAndPushReleaseRun,
1526
+ },
1527
+ {
1528
+ name: 'Force-retag semver and floating major',
1529
+ if: Runner.expr('env.PUBLISH == \'true\''),
1530
+ env: [
1531
+ {
1532
+ key: 'TAG_NAME',
1533
+ value: Runner.expr('github.event.release.tag_name'),
1534
+ },
1535
+ {
1536
+ key: 'IS_PRERELEASE',
1537
+ value: Runner.expr('github.event.release.prerelease'),
1538
+ },
1539
+ ],
1540
+ run: forceRetagRun,
1541
+ },
1542
+ {
1543
+ name: 'Attest build provenance',
1544
+ if: Runner.expr('env.PUBLISH == \'true\''),
1545
+ uses: 'actions/attest-build-provenance@v2',
1546
+ with: [{
1547
+ key: 'subject-path',
1548
+ value: `${actionOutputPath}/${actionEntryPoint}`,
1549
+ }],
1550
+ },
1551
+ ],
1552
+ };
1553
+ }
1554
+ static buildVercelNextjsTarget(context) {
1555
+ const targetSettings = context['targetSettings'];
1556
+ const workflowSettings = context['workflowSettings'];
1557
+ const metadata = Variables.getTargetMetadata('publish', 'vercel-nextjs');
1558
+ const variables = (metadata === undefined) ? {} : metadata['variables'];
1559
+ const environment = context['environment'];
1560
+ const appPath = context['workingDir'];
1561
+ const dollar = Runner.dollar();
1562
+ const runtimeValues = Runner.appRuntimeValues(environment, appPath);
1563
+ const steps = [
1564
+ {
1565
+ name: 'Checkout repository',
1566
+ uses: 'actions/checkout@v7',
1567
+ },
1568
+ {
1569
+ name: 'Setup Node.js',
1570
+ uses: 'actions/setup-node@v6',
1571
+ with: [
1572
+ {
1573
+ key: 'node-version-file',
1574
+ value: `${Runner.expr('env.ROOT_DIR')}/package.json`,
1575
+ },
1576
+ {
1577
+ key: 'package-manager-cache',
1578
+ value: false,
1579
+ },
1580
+ ],
1581
+ },
1582
+ {
1583
+ name: 'Download build artifacts',
1584
+ uses: 'actions/download-artifact@v8',
1585
+ with: [{
1586
+ key: 'name',
1587
+ value: context['artifactName'],
1588
+ }],
1589
+ },
1590
+ {
1591
+ name: 'Install Vercel CLI',
1592
+ if: Runner.expr('env.PUBLISH == \'true\''),
1593
+ run: 'npm install -g vercel@latest',
1594
+ runPlain: true,
1595
+ },
1596
+ {
1597
+ name: 'Pull Vercel environment',
1598
+ if: Runner.expr('env.PUBLISH == \'true\''),
1599
+ env: [
1600
+ {
1601
+ key: 'VERCEL_TOKEN',
1602
+ value: Runner.resolveScopedCredExpr(variables, 'VERCEL_TOKEN', targetSettings, workflowSettings, environment, appPath),
1603
+ },
1604
+ {
1605
+ key: 'VERCEL_ORG_ID',
1606
+ value: Runner.resolveScopedCredExpr(variables, 'VERCEL_ORG_ID', targetSettings, workflowSettings, environment, appPath),
1607
+ },
1608
+ {
1609
+ key: 'VERCEL_PROJECT_ID',
1610
+ value: Runner.resolveScopedCredExpr(variables, 'VERCEL_PROJECT_ID', targetSettings, workflowSettings, environment, appPath),
1611
+ },
1612
+ ],
1613
+ run: `vercel pull --yes --environment=production --token="${dollar}VERCEL_TOKEN}"`,
1614
+ runBlock: true,
1615
+ workingDirectory: context['workingDir'],
1616
+ },
1617
+ ];
1618
+ const deployStep = {
1619
+ name: 'Deploy to Vercel',
1620
+ if: Runner.expr('env.PUBLISH == \'true\''),
1621
+ env: [
1622
+ {
1623
+ key: 'VERCEL_TOKEN',
1624
+ value: Runner.resolveScopedCredExpr(variables, 'VERCEL_TOKEN', targetSettings, workflowSettings, environment, appPath),
1625
+ },
1626
+ {
1627
+ key: 'VERCEL_ORG_ID',
1628
+ value: Runner.resolveScopedCredExpr(variables, 'VERCEL_ORG_ID', targetSettings, workflowSettings, environment, appPath),
1629
+ },
1630
+ {
1631
+ key: 'VERCEL_PROJECT_ID',
1632
+ value: Runner.resolveScopedCredExpr(variables, 'VERCEL_PROJECT_ID', targetSettings, workflowSettings, environment, appPath),
1633
+ },
1634
+ ],
1635
+ run: `vercel deploy --prebuilt --prod --token="${dollar}VERCEL_TOKEN}"`,
1636
+ runBlock: true,
1637
+ workingDirectory: context['workingDir'],
1638
+ };
1639
+ const syncStep = Runner.emitRuntimeSyncStep({
1640
+ vendor: 'vercel',
1641
+ runtimeValues,
1642
+ workingDir: context['workingDir'],
1643
+ extraEnv: [{
1644
+ key: 'VERCEL_TOKEN',
1645
+ value: Runner.resolveScopedCredExpr(variables, 'VERCEL_TOKEN', targetSettings, workflowSettings, environment, appPath),
1646
+ }],
1647
+ });
1648
+ if (syncStep !== undefined) {
1649
+ steps.push(syncStep);
1650
+ }
1651
+ steps.push(deployStep);
1652
+ return {
1653
+ id: `publish-vercel-nextjs-${Runner.slugifyWorkingDir(context['workingDir'])}`,
1654
+ needs: context['needs'],
1655
+ runsOn: 'ubuntu-latest',
1656
+ timeoutMinutes: 15,
1657
+ permissions: {
1658
+ contents: 'read',
1659
+ },
1660
+ steps,
1661
+ };
1662
+ }
1663
+ static buildScopeCommand(scriptName, workspaceNames, useTurbo) {
1664
+ if (useTurbo === true) {
1665
+ const turboFlags = workspaceNames.map((name) => `--filter=${name}`);
1666
+ return `npx turbo run ${scriptName} ${turboFlags.join(' ')} --concurrency=2`;
1667
+ }
1668
+ const npmFlags = workspaceNames.map((name) => `-w ${name}`);
1669
+ return `npm run ${scriptName} ${npmFlags.join(' ')}`;
1670
+ }
1671
+ static installPackagesRun() {
1672
+ return [
1673
+ 'npm install -g npm@latest',
1674
+ 'npm install',
1675
+ ].join('\n');
1676
+ }
1677
+ static removeDeprecatedNpmrcRun() {
1678
+ const dollar = Runner.dollar();
1679
+ return [
1680
+ `npmrc="${dollar}NPM_CONFIG_USERCONFIG:-$HOME/.npmrc}"`,
1681
+ '',
1682
+ 'if [ -f "$npmrc" ]; then',
1683
+ ' sed -i \'/^always-auth=/d\' "$npmrc"',
1684
+ 'fi',
1685
+ ].join('\n');
1686
+ }
1687
+ static npmAuthRun() {
1688
+ const dollar = Runner.dollar();
1689
+ return [
1690
+ `if [ -n "${dollar}NPM_TOKEN}" ]; then`,
1691
+ ' echo "[Auth] Using NPM_TOKEN (token-based)."',
1692
+ ` echo "NODE_AUTH_TOKEN=${dollar}NPM_TOKEN}" >> "$GITHUB_ENV"`,
1693
+ 'else',
1694
+ ' echo "[Auth] Using trusted publishing (OIDC)."',
1695
+ '',
1696
+ ` npmrc="${dollar}NPM_CONFIG_USERCONFIG:-$HOME/.npmrc}"`,
1697
+ '',
1698
+ ' if [ -f "$npmrc" ]; then',
1699
+ ' sed -i \'/^\\/\\/registry\\.npmjs\\.org\\/:_authToken/d\' "$npmrc"',
1700
+ ' echo "[Auth] Removed _authToken entry from .npmrc."',
1701
+ ' fi',
1702
+ 'fi',
1703
+ ].join('\n');
1704
+ }
1705
+ static npmPublishRun() {
1706
+ const dollar = Runner.dollar();
1707
+ return [
1708
+ `if [ "${dollar}PUBLISH}" = "true" ]; then`,
1709
+ ' echo "[Publish] Production."',
1710
+ ' npm publish --provenance --access public',
1711
+ 'else',
1712
+ ' echo "[Publish] Dry run."',
1713
+ ' npm publish --dry-run',
1714
+ 'fi',
1715
+ ].join('\n');
1716
+ }
1717
+ static scopePackageNameRun() {
1718
+ const dollar = Runner.dollar();
1719
+ return [
1720
+ `REPOSITORY_OWNER="@$(echo '${Runner.expr('github.repository_owner')}' | tr '[:upper:]' '[:lower:]')"`,
1721
+ 'PACKAGE_NAME=$(npm pkg get name --workspaces=false | jq -r \'.\')',
1722
+ '',
1723
+ `echo "[Scope] Owner is \\"${dollar}REPOSITORY_OWNER}\\" and package is \\"${dollar}PACKAGE_NAME}\\"."`,
1724
+ '',
1725
+ 'echo "PACKAGE_NAME=$PACKAGE_NAME" >> "$GITHUB_ENV"',
1726
+ '',
1727
+ 'if [[ "$PACKAGE_NAME" != "$REPOSITORY_OWNER/"* ]]; then',
1728
+ ` BASE=${dollar}PACKAGE_NAME##*/}`,
1729
+ ' NEW_NAME="$REPOSITORY_OWNER/$BASE"',
1730
+ '',
1731
+ ` echo "[Scope] Scoping package name to \\"${dollar}NEW_NAME}\\"."`,
1732
+ '',
1733
+ ' npm pkg set name="$NEW_NAME"',
1734
+ 'else',
1735
+ ' echo "[Scope] Already scoped. No changes needed."',
1736
+ 'fi',
1737
+ ].join('\n');
1738
+ }
1739
+ static githubAuthRun() {
1740
+ const dollar = Runner.dollar();
1741
+ return [
1742
+ 'echo "[Auth] Using GITHUB_TOKEN."',
1743
+ `echo "NODE_AUTH_TOKEN=${dollar}GITHUB_TOKEN}" >> "$GITHUB_ENV"`,
1744
+ ].join('\n');
1745
+ }
1746
+ static githubPublishRun() {
1747
+ const dollar = Runner.dollar();
1748
+ return [
1749
+ `if [ "${dollar}PUBLISH}" = "true" ]; then`,
1750
+ ' echo "[Publish] Production."',
1751
+ ' npm publish',
1752
+ 'else',
1753
+ ' echo "[Publish] Dry run."',
1754
+ ' npm publish --dry-run',
1755
+ 'fi',
1756
+ ].join('\n');
1757
+ }
1758
+ static slugifyWorkingDir(workingDir) {
1759
+ const withoutPrefix = workingDir.replace(LIB_REGEX_PATTERN_LEADING_DOT_SLASH, '');
1760
+ return withoutPrefix.replace(new RegExp(LIB_REGEX_CHARACTER_FORWARD_SLASH.source, 'g'), '-');
1761
+ }
1762
+ static emitRuntimeSyncStep(options) {
1763
+ const vendor = options['vendor'];
1764
+ const runtimeValues = options['runtimeValues'];
1765
+ const workingDir = options['workingDir'];
1766
+ const extraEnv = options['extraEnv'];
1767
+ if (runtimeValues.length === 0) {
1768
+ return undefined;
1769
+ }
1770
+ const secretValues = runtimeValues.filter((value) => value['secret'] === true);
1771
+ const variableValues = runtimeValues.filter((value) => value['secret'] === false);
1772
+ const env = [
1773
+ ...extraEnv,
1774
+ ...runtimeValues.map((value) => ({
1775
+ key: value['key'],
1776
+ value: (value['secret'] === true) ? Runner.expr(`secrets.${value['name']}`) : Runner.expr(`vars.${value['name']}`),
1777
+ })),
1778
+ ];
1779
+ const lines = [];
1780
+ if (vendor === 'cloudflare') {
1781
+ if (secretValues.length > 0) {
1782
+ const secretDeclared = secretValues.map((value) => value['key']).join(' ');
1783
+ const jqObject = secretValues.map((value) => value['key']).join(', ');
1784
+ lines.push(`DECLARED="${secretDeclared}"`);
1785
+ lines.push('wrangler secret list | jq -r \'.[].name\' | while read -r name; do');
1786
+ lines.push(' case " $DECLARED " in');
1787
+ lines.push(' *" $name "*) ;;');
1788
+ lines.push(' *) echo "Removing undeclared secret: $name"; wrangler secret delete "$name" --force ;;');
1789
+ lines.push(' esac');
1790
+ lines.push('done');
1791
+ lines.push('echo "Syncing declared secrets: $DECLARED"');
1792
+ lines.push(`jq -n 'env | {${jqObject}}' | wrangler secret bulk /dev/stdin`);
1793
+ }
1794
+ if (variableValues.length > 0) {
1795
+ const varDeclared = variableValues.map((value) => value['key']).join(' ');
1796
+ const varFlags = variableValues.map((value) => `--var ${value['key']}:"$${value['key']}"`).join(' ');
1797
+ lines.push(`echo "Syncing declared vars: ${varDeclared}"`);
1798
+ lines.push(`wrangler deploy ${varFlags}`);
1799
+ }
1800
+ }
1801
+ else {
1802
+ const declared = runtimeValues.map((value) => value['key']).join(' ');
1803
+ lines.push(`DECLARED="${declared}"`);
1804
+ lines.push('vercel env ls production --token="$VERCEL_TOKEN" | tail -n +2 | awk \'{print $1}\' | while read -r name; do');
1805
+ lines.push(' case " $DECLARED " in');
1806
+ lines.push(' *" $name "*) ;;');
1807
+ lines.push(' *) [ -n "$name" ] && { echo "Removing undeclared env: $name"; vercel env rm "$name" production --yes --token="$VERCEL_TOKEN"; } ;;');
1808
+ lines.push(' esac');
1809
+ lines.push('done');
1810
+ if (secretValues.length > 0) {
1811
+ const vercelSecretDeclared = secretValues.map((value) => value['key']).join(' ');
1812
+ lines.push(`SECRET_DECLARED="${vercelSecretDeclared}"`);
1813
+ lines.push('for name in $SECRET_DECLARED; do');
1814
+ lines.push(' echo "Syncing env: $name"');
1815
+ lines.push(' vercel env rm "$name" production --yes --token="$VERCEL_TOKEN" 2>/dev/null || true');
1816
+ lines.push(' printf \'%s\' "$(eval "echo \\$$name")" | vercel env add "$name" production --sensitive --token="$VERCEL_TOKEN"');
1817
+ lines.push('done');
1818
+ }
1819
+ if (variableValues.length > 0) {
1820
+ const vercelVarDeclared = variableValues.map((value) => value['key']).join(' ');
1821
+ lines.push(`VAR_DECLARED="${vercelVarDeclared}"`);
1822
+ lines.push('for name in $VAR_DECLARED; do');
1823
+ lines.push(' echo "Syncing env: $name"');
1824
+ lines.push(' vercel env rm "$name" production --yes --token="$VERCEL_TOKEN" 2>/dev/null || true');
1825
+ lines.push(' printf \'%s\' "$(eval "echo \\$$name")" | vercel env add "$name" production --token="$VERCEL_TOKEN"');
1826
+ lines.push('done');
1827
+ }
1828
+ }
1829
+ const run = lines.join('\n');
1830
+ return {
1831
+ name: (vendor === 'cloudflare') ? 'Sync worker runtime secrets' : 'Sync Vercel runtime environment',
1832
+ if: Runner.expr('env.PUBLISH == \'true\''),
1833
+ env,
1834
+ run,
1835
+ workingDirectory: workingDir,
1836
+ };
1837
+ }
1838
+ static appBuildValues(environment, appPath) {
1839
+ const results = [];
1840
+ if (environment === undefined) {
1841
+ return results;
1842
+ }
1843
+ const apps = environment['apps'];
1844
+ if (apps === undefined) {
1845
+ return results;
1846
+ }
1847
+ const app = apps[appPath];
1848
+ if (app === undefined) {
1849
+ return results;
1850
+ }
1851
+ const prefix = app['prefix'];
1852
+ for (const variable of app['variables'] ?? []) {
1853
+ if (variable['buildOnly'] !== true) {
1854
+ continue;
1855
+ }
1856
+ const buildValue = {
1857
+ key: variable['key'],
1858
+ name: libEnvNamespace.githubName(prefix, variable['key']),
1859
+ secret: variable['secret'],
1860
+ };
1861
+ if (variable['defaultValue'] !== undefined) {
1862
+ buildValue.defaultValue = variable['defaultValue'];
1863
+ }
1864
+ results.push(buildValue);
1865
+ }
1866
+ return results;
1867
+ }
1868
+ static appRuntimeValues(environment, appPath) {
1869
+ const results = [];
1870
+ if (environment === undefined) {
1871
+ return results;
1872
+ }
1873
+ const apps = environment['apps'];
1874
+ if (apps === undefined) {
1875
+ return results;
1876
+ }
1877
+ const app = apps[appPath];
1878
+ if (app === undefined) {
1879
+ return results;
1880
+ }
1881
+ const prefix = app['prefix'];
1882
+ for (const variable of app['variables'] ?? []) {
1883
+ if (variable['buildOnly'] !== false) {
1884
+ continue;
1885
+ }
1886
+ results.push({
1887
+ key: variable['key'],
1888
+ name: libEnvNamespace.githubName(prefix, variable['key']),
1889
+ secret: variable['secret'],
1890
+ });
1891
+ }
1892
+ return results;
1893
+ }
1894
+ static writeEnvRun(variables) {
1895
+ const lines = ['{'];
1896
+ const dollar = Runner.dollar();
1897
+ for (const variable of variables) {
1898
+ if (variable['defaultValue'] !== undefined) {
1899
+ const escapedDefault = Runner.escapeShellDefault(variable['defaultValue']);
1900
+ lines.push(` echo "${variable['key']}=${dollar}${variable['key']}:-${escapedDefault}}"`);
1901
+ continue;
1902
+ }
1903
+ lines.push(` echo "${variable['key']}=$${variable['key']}"`);
1904
+ }
1905
+ lines.push('} > .env');
1906
+ return lines.join('\n');
1907
+ }
1908
+ static resolveDeployJobId(type, workingDir) {
1909
+ return `publish-${type}-${Runner.slugifyWorkingDir(workingDir)}`;
1910
+ }
1911
+ static resolveDeployNeeds(target) {
1912
+ const needs = ['build'];
1913
+ const dependencies = target['after'] ?? [];
1914
+ for (const dependencyValue of dependencies) {
1915
+ const dependency = dependencyValue;
1916
+ needs.push(Runner.resolveDeployJobId(target['to'], dependency));
1917
+ }
1918
+ return needs;
1919
+ }
1920
+ static buildIssuesTrigger() {
1921
+ return {
1922
+ event: 'issues',
1923
+ types: [
1924
+ 'opened',
1925
+ 'closed',
1926
+ ],
1927
+ };
1928
+ }
1929
+ static buildIssueCommentTrigger() {
1930
+ return {
1931
+ event: 'issue_comment',
1932
+ types: [
1933
+ 'created',
1934
+ 'edited',
1935
+ ],
1936
+ };
1937
+ }
1938
+ static buildScheduleWeeklyTrigger() {
1939
+ return {
1940
+ event: 'schedule',
1941
+ cron: '0 0 * * 0',
1942
+ };
1943
+ }
1944
+ static buildScheduleDailyTrigger() {
1945
+ return {
1946
+ event: 'schedule',
1947
+ cron: '0 0 * * *',
1948
+ };
1949
+ }
1950
+ static buildScheduleMonthlyTrigger() {
1951
+ return {
1952
+ event: 'schedule',
1953
+ cron: '0 0 1 * *',
1954
+ };
1955
+ }
1956
+ static serializeHeader() {
1957
+ return [
1958
+ '# This file is generated by @cbnventures/nova.',
1959
+ '# Do not edit manually.',
1960
+ '#',
1961
+ '# Run `nova generate github workflows` to regenerate.',
1962
+ '# See: https://nova.cbnventures.io/docs/cli/generators/github/workflows',
1963
+ ];
1964
+ }
1965
+ static serializeOn(on) {
1966
+ const lines = [];
1967
+ lines.push('on:');
1968
+ for (const trigger of on) {
1969
+ if (trigger['event'] === 'release') {
1970
+ lines.push(' release:');
1971
+ lines.push(' types:');
1972
+ for (const type of trigger['types']) {
1973
+ lines.push(` - ${Runner.quote(type)}`);
1974
+ }
1975
+ }
1976
+ if (trigger['event'] === 'push') {
1977
+ lines.push(' push:');
1978
+ if (trigger['branches'] !== undefined) {
1979
+ lines.push(' branches:');
1980
+ for (const branch of trigger['branches']) {
1981
+ lines.push(` - ${Runner.quote(branch)}`);
1982
+ }
1983
+ }
1984
+ if (trigger['tags'] !== undefined) {
1985
+ lines.push(' tags:');
1986
+ for (const tag of trigger['tags']) {
1987
+ lines.push(` - ${Runner.quote(tag)}`);
1988
+ }
1989
+ }
1990
+ if (trigger['paths'] !== undefined) {
1991
+ lines.push(' paths:');
1992
+ for (const path of trigger['paths']) {
1993
+ lines.push(` - ${Runner.quote(path)}`);
1994
+ }
1995
+ }
1996
+ }
1997
+ if (trigger['event'] === 'issues' || trigger['event'] === 'issue_comment') {
1998
+ lines.push(` ${trigger['event']}:`);
1999
+ lines.push(' types:');
2000
+ for (const type of trigger['types']) {
2001
+ lines.push(` - ${Runner.quote(type)}`);
2002
+ }
2003
+ }
2004
+ if (trigger['event'] === 'schedule') {
2005
+ lines.push(' schedule:');
2006
+ lines.push(` - cron: ${Runner.quote(trigger['cron'])}`);
2007
+ }
2008
+ if (trigger['event'] === 'workflow_run') {
2009
+ lines.push(' workflow_run:');
2010
+ lines.push(' workflows:');
2011
+ for (const workflowName of trigger['workflows']) {
2012
+ lines.push(` - ${Runner.quote(workflowName)}`);
2013
+ }
2014
+ lines.push(' types:');
2015
+ for (const type of trigger['types']) {
2016
+ lines.push(` - ${Runner.quote(type)}`);
2017
+ }
2018
+ }
2019
+ if (trigger['event'] === 'workflow_dispatch') {
2020
+ lines.push(' workflow_dispatch:');
2021
+ lines.push(' inputs:');
2022
+ for (const input of trigger['inputs']) {
2023
+ lines.push(` ${input['name']}:`);
2024
+ lines.push(` description: ${Runner.quote(input['description'])}`);
2025
+ lines.push(` required: ${Runner.serializeScalar(input['required'])}`);
2026
+ lines.push(` type: ${Runner.quote(input['type'])}`);
2027
+ lines.push(` default: ${Runner.serializeScalar(input['default'])}`);
2028
+ }
2029
+ }
2030
+ }
2031
+ return lines;
2032
+ }
2033
+ static serializePermissions(permissions, indent) {
2034
+ const lines = [];
2035
+ for (const scope of Object.keys(permissions)) {
2036
+ const value = permissions[scope];
2037
+ lines.push(`${indent}${scope}: ${Runner.quote(value)}`);
2038
+ }
2039
+ return lines;
2040
+ }
2041
+ static serializeEnv(env) {
2042
+ const lines = [];
2043
+ lines.push('env:');
2044
+ for (const entry of env) {
2045
+ lines.push(` ${entry['key']}: ${Runner.quote(entry['value'])}`);
2046
+ }
2047
+ return lines;
2048
+ }
2049
+ static serializeJobs(jobs) {
2050
+ const lines = [];
2051
+ lines.push('jobs:');
2052
+ for (const job of jobs) {
2053
+ lines.push(` ${job['id']}:`);
2054
+ const jobNeeds = job['needs'];
2055
+ if (jobNeeds !== undefined) {
2056
+ lines.push(` needs: ${Runner.serializeNeeds(jobNeeds)}`);
2057
+ }
2058
+ lines.push(` runs-on: ${Runner.quote(job['runsOn'])}`);
2059
+ lines.push(` timeout-minutes: ${Runner.serializeScalar(job['timeoutMinutes'])}`);
2060
+ const jobPermissions = job['permissions'];
2061
+ if (jobPermissions !== undefined) {
2062
+ lines.push(' permissions:');
2063
+ lines.push(...Runner.serializePermissions(jobPermissions, ' '));
2064
+ }
2065
+ const jobIf = job['if'];
2066
+ if (jobIf !== undefined) {
2067
+ lines.push(` if: ${Runner.quote(jobIf)}`);
2068
+ }
2069
+ lines.push(' steps:');
2070
+ const jobSteps = job['steps'];
2071
+ for (const step of jobSteps) {
2072
+ lines.push(` - name: ${Runner.quote(step['name'])}`);
2073
+ const stepId = step['id'];
2074
+ if (stepId !== undefined) {
2075
+ lines.push(` id: ${Runner.quote(stepId)}`);
2076
+ }
2077
+ const stepIf = step['if'];
2078
+ if (stepIf !== undefined) {
2079
+ lines.push(` if: ${Runner.quote(stepIf)}`);
2080
+ }
2081
+ const stepUses = step['uses'];
2082
+ if (stepUses !== undefined) {
2083
+ lines.push(` uses: ${Runner.quote(stepUses)}`);
2084
+ }
2085
+ const stepEnv = step['env'];
2086
+ const isEnvAfterRun = step['envAfterRun'] === true;
2087
+ if (stepEnv !== undefined && isEnvAfterRun === false) {
2088
+ lines.push(' env:');
2089
+ for (const entry of stepEnv) {
2090
+ lines.push(` ${entry['key']}: ${Runner.quote(entry['value'])}`);
2091
+ }
2092
+ }
2093
+ const stepWith = step['with'];
2094
+ if (stepWith !== undefined) {
2095
+ lines.push(' with:');
2096
+ lines.push(...Runner.serializeWith(stepWith, ' '));
2097
+ }
2098
+ const stepRun = step['run'];
2099
+ if (stepRun !== undefined) {
2100
+ lines.push(...Runner.serializeRun(stepRun, ' ', step['runBlock'] === true, step['runPlain'] === true));
2101
+ }
2102
+ if (stepEnv !== undefined && isEnvAfterRun === true) {
2103
+ lines.push(' env:');
2104
+ for (const entry of stepEnv) {
2105
+ lines.push(` ${entry['key']}: ${Runner.quote(entry['value'])}`);
2106
+ }
2107
+ }
2108
+ const stepWorkingDirectory = step['workingDirectory'];
2109
+ if (stepWorkingDirectory !== undefined) {
2110
+ lines.push(` working-directory: ${Runner.quote(stepWorkingDirectory)}`);
2111
+ }
2112
+ if (step !== jobSteps[jobSteps.length - 1]) {
2113
+ lines.push('');
2114
+ }
2115
+ }
2116
+ if (job !== jobs[jobs.length - 1]) {
2117
+ lines.push('');
2118
+ }
2119
+ }
2120
+ return lines;
2121
+ }
2122
+ static serializeNeeds(needs) {
2123
+ const quoted = needs.map((need) => Runner.quote(need));
2124
+ if (quoted.length === 1) {
2125
+ return quoted.join('');
2126
+ }
2127
+ return `[${quoted.join(', ')}]`;
2128
+ }
2129
+ static serializeRun(run, indent, block, plain) {
2130
+ const lines = [];
2131
+ if (run.includes('\n') === false && block === false) {
2132
+ if (plain === true) {
2133
+ lines.push(`${indent}run: ${run}`);
2134
+ }
2135
+ else {
2136
+ lines.push(`${indent}run: ${Runner.quote(run)}`);
2137
+ }
2138
+ return lines;
2139
+ }
2140
+ lines.push(`${indent}run: |`);
2141
+ for (const bodyLine of run.split('\n')) {
2142
+ if (bodyLine === '') {
2143
+ lines.push('');
2144
+ }
2145
+ else {
2146
+ lines.push(`${indent} ${bodyLine}`);
2147
+ }
2148
+ }
2149
+ return lines;
2150
+ }
2151
+ static serializeWith(withMap, indent) {
2152
+ const lines = [];
2153
+ for (const entry of withMap) {
2154
+ const value = entry['value'];
2155
+ if (entry['block'] === true) {
2156
+ lines.push(`${indent}${entry['key']}: |`);
2157
+ const blockValue = `${value}`;
2158
+ for (const blockLine of blockValue.split('\n')) {
2159
+ lines.push(`${indent} ${blockLine}`);
2160
+ }
2161
+ }
2162
+ else {
2163
+ lines.push(`${indent}${entry['key']}: ${Runner.serializeScalar(value)}`);
2164
+ }
2165
+ }
2166
+ return lines;
2167
+ }
2168
+ static serializeScalar(value) {
2169
+ if (typeof value === 'number') {
2170
+ return `${value}`;
2171
+ }
2172
+ if (typeof value === 'boolean') {
2173
+ return (value === true) ? 'true' : 'false';
2174
+ }
2175
+ return Runner.quote(value);
2176
+ }
2177
+ static quote(value) {
2178
+ return `"${value}"`;
2179
+ }
2180
+ static resolveWorkflowId(suffix) {
2181
+ if (suffix === undefined) {
2182
+ return '';
2183
+ }
2184
+ return ` (${suffix})`;
2185
+ }
2186
+ static resolveWorkflowDisplayName(template, suffix) {
2187
+ const workflowId = Runner.resolveWorkflowId(suffix);
2188
+ if (template === 'check-sponsor-gated-issues') {
2189
+ return `Check Sponsor Gated Issues${workflowId}`;
2190
+ }
2191
+ if (template === 'lock-inactive-issues') {
2192
+ return `Lock Inactive Issues${workflowId}`;
2193
+ }
2194
+ return `Publish${workflowId}`;
2195
+ }
2196
+ static expr(inner) {
2197
+ const dollarBrace = [
2198
+ '$',
2199
+ '{',
2200
+ ].join('');
2201
+ return `${dollarBrace}{ ${inner} }}`;
2202
+ }
2203
+ static resolveScopedCredExpr(variables, variableName, targetSettings, workflowSettings, environment, appPath) {
2204
+ const variableMeta = variables[variableName] ?? { format: 'literal' };
2205
+ const scope = variableMeta['scope'];
2206
+ let prefix = undefined;
2207
+ if (scope === 'account' && environment !== undefined) {
2208
+ const global = environment['global'];
2209
+ const globalPrefix = (global === undefined) ? undefined : global['prefix'];
2210
+ if (globalPrefix !== undefined && globalPrefix !== '') {
2211
+ prefix = globalPrefix;
2212
+ }
2213
+ }
2214
+ else if (scope === 'app' && environment !== undefined) {
2215
+ const apps = environment['apps'];
2216
+ const app = (apps === undefined) ? undefined : apps[appPath];
2217
+ const appPrefix = (app === undefined) ? undefined : app['prefix'];
2218
+ if (appPrefix !== undefined && appPrefix !== '') {
2219
+ prefix = appPrefix;
2220
+ }
2221
+ }
2222
+ return Runner.resolveVariableExpr(variables, variableName, targetSettings, workflowSettings, prefix);
2223
+ }
2224
+ static resolveVariableExpr(variables, variableName, targetSettings, workflowSettings, prefix = undefined) {
2225
+ const variableMeta = variables[variableName] ?? { format: 'literal' };
2226
+ const isPrefixable = (prefix !== undefined
2227
+ && prefix !== ''
2228
+ && variableMeta['auto'] !== true
2229
+ && variableMeta['format'] !== 'literal');
2230
+ const resolvedName = (isPrefixable === true && prefix !== undefined) ? libEnvNamespace.githubName(prefix, variableName) : Variables.resolve(variableName, targetSettings, workflowSettings, variableMeta);
2231
+ return Variables.resolveExpr(variableMeta['format'], resolvedName);
2232
+ }
2233
+ static dollar() {
2234
+ return [
2235
+ '$',
2236
+ '{',
2237
+ ].join('');
2238
+ }
2239
+ static escapeShellDefault(value) {
2240
+ const backslashPattern = new RegExp(LIB_REGEX_CHARACTER_BACKSLASH.source, 'g');
2241
+ const backtickPattern = new RegExp(LIB_REGEX_CHARACTER_BACKTICK.source, 'g');
2242
+ const dollarPattern = new RegExp(LIB_REGEX_CHARACTER_DOLLAR.source, 'g');
2243
+ const doubleQuotePattern = new RegExp(LIB_REGEX_CHARACTER_DOUBLE_QUOTE.source, 'g');
2244
+ return value
2245
+ .replace(backslashPattern, '\\\\')
2246
+ .replace(backtickPattern, '\\`')
2247
+ .replace(dollarPattern, '\\$')
2248
+ .replace(doubleQuotePattern, '\\"');
2249
+ }
2250
+ }
2251
+ //# sourceMappingURL=workflows-blueprint.js.map