gen-release-notes.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. // METADATA // {"ai-commented":{"service":"claude"}}
  2. /*
  3. * Copyright (C) 2024-present Puter Technologies Inc.
  4. *
  5. * This file is part of Puter.
  6. *
  7. * Puter is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as published
  9. * by the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. import { simpleGit } from 'simple-git';
  21. // GitHub repository URL for generating commit links in release notes
  22. const REPO_URL = 'https://github.com/HeyPuter/puter';
  23. const params = {
  24. from: 'v2.5.0',
  25. to: 'v2.5.1',
  26. date: '2025-02-13',
  27. };
  28. const git = simpleGit();
  29. const log = await git.log({ from: params.from });
  30. const commits = log.all;
  31. // Array of all commits from git log between specified versions
  32. const CC_REGEX = /^([a-z0-9]+)(\([a-z0-9]+\))?:\s(.*)/;
  33. const parse_conventional_commit = message => {
  34. const parts = CC_REGEX.exec(message);
  35. if ( ! parts ) return null;
  36. let [match, type, scope, summary] = parts;
  37. if ( ! match ) return null;
  38. if ( scope ) scope = scope.slice(1, -1);
  39. return { type, scope, summary };
  40. };
  41. const types = {
  42. feat: {
  43. label: 'Features'
  44. },
  45. i18n: {
  46. label: 'Translations'
  47. },
  48. fix: {
  49. label: 'Bug Fixes'
  50. },
  51. };
  52. const scopes = {
  53. puter: {
  54. label: 'Puter'
  55. },
  56. phoenix: {
  57. label: 'Phoenix Shell'
  58. },
  59. git: {
  60. label: 'Puter Git'
  61. },
  62. backend: {
  63. label: 'Backend'
  64. },
  65. api: {
  66. label: 'API',
  67. },
  68. gui: {
  69. label: 'GUI'
  70. },
  71. puterjs: {
  72. label: 'Puter JS'
  73. },
  74. tools: {
  75. ignore: true,
  76. },
  77. security: {
  78. label: 'Security',
  79. },
  80. ai: {
  81. label: 'AI',
  82. },
  83. putility: {
  84. label: 'Putility',
  85. },
  86. docker: {
  87. label: 'Docker',
  88. },
  89. };
  90. const scope_aliases = {
  91. main: 'puter',
  92. ui: 'gui',
  93. parsely: 'phoenix',
  94. };
  95. const complicated_cases = [
  96. /**
  97. * Handles special cases for commit message transformations
  98. * @type {Array<function>}
  99. */
  100. function fix_i18n ({ commit, meta }) {
  101. if ( meta.scope === 'i18n' ) {
  102. meta.type = 'i18n';
  103. meta.scope = undefined;
  104. }
  105. },
  106. function deps_scope ({ commit, meta }) {
  107. if ( meta.scope === 'deps' ) {
  108. meta.type = 'chore';
  109. meta.scope = undefined;
  110. }
  111. },
  112. function puterai_is_ai ({ commit, meta }) {
  113. const ai_scopes = ['puterai', 'puerai', 'puter-ai'];
  114. if ( ai_scopes.includes(meta.scope) ) {
  115. meta.scope = 'ai';
  116. }
  117. },
  118. function doc_scopes ({ commit, meta }) {
  119. const doc_scopes = ['readme'];
  120. if ( doc_scopes.includes(meta.scope) ) {
  121. meta.type = 'doc';
  122. meta.scope = undefined;
  123. }
  124. }
  125. ];
  126. const retro_prefixes_0 = {
  127. i18n: [
  128. '883601142873f10d69c84874499065a7d29af054',
  129. '17145d0be6a9a1445947cc0c4bec8f16a475144c',
  130. 'e61039faf409b0ad85c7513b0123f3f2e92ebe32',
  131. 'bffa192805216fc17045cd8d629f34784dca7f3f',
  132. 'fe5be7f3cf7f336730137293ba86a637e8d8591d',
  133. '78a0acea6980b6d491da4874edbd98e17c0d9577',
  134. 'a96abb5793528d0dc56d75f95d771e1dcf5960d1',
  135. 'f5a8ee1c6ab950d62c90b6257791f026a508b4e4',
  136. '47ec74f0aa6adb3952e6460909029a4acb0c3039',
  137. '473b6512c697854e3f3badae1eb7b87742954da5',
  138. '8440f566b91c9eb4f01addcb850061e3fbe3afc7',
  139. '92abc9947f811f94f17a5ee5a4b73ee2b210900a',
  140. 'cff488f4f4378ca6c7568a585a665f2a3b87b89c',
  141. '3b8af7cc5c1be8ed67be827360bbfe0f0b5027e9',
  142. '84e31eff2f58584d8fab7dd10606f2f6ced933a2',
  143. '81781f80afc07cd1e6278906cdc68c8092fbfedf',
  144. '56820cf6ee56ff810a6b495a281ccbb2e7f9d8fb',
  145. '69a80ab3d2c94ee43d96021c3bcbdab04a4b5dc6',
  146. '8e297cd7e30757073e2f96593c363a273b639466',
  147. '151527825f1eb4b060aaf97feb7d18af4fcddbf2',
  148. '8bece96f6224a060d5b408e08c58865fadb8b79c',
  149. '333d6e3b651e460caca04a896cbc8c175555b79b',
  150. '8a3d0430f39f872b8a460c344cce652c340b700b',
  151. 'b9e73b7288aebb14e6bbf1915743e9157fc950b1',
  152. 'c2d3d69dbe33f36fcae13bcbc8e2a31a86025af9',
  153. '382fb24dbb1737a8a54ed2491f80b2e2276cde61',
  154. ],
  155. fix: [
  156. '535475b3c36a37e3319ed067a24fb671790dcda3',
  157. '45f131f8eaf94cf3951ca7ffeb6f311590233b8a',
  158. '02e1b1e8f5f8e22d7ab39ebff99f7dd8e08a4221',
  159. ],
  160. doc: [
  161. '338004474f078a00608af1d0ebf8a7f9534bad28',
  162. '6c4c73a9e85ff8eb5e7663dcce11f4d1f824032b',
  163. 'c19c18bfcf163b37e3d173b8fa50393dfb9f540f',
  164. ],
  165. feat: [
  166. '8e7306c23be01ee6c31cdb4c99f2fb1f71a2247f',
  167. ],
  168. meta: [
  169. 'b3c1b128e2d8519bc816cdcd3220c8f40e05bb01',
  170. '452b7495b1736df90bc748dbf818407488875754',
  171. ],
  172. };
  173. const message_changes = {
  174. '1f7f094282fae915a2436701cfb756444cd3f781': 'feat: add new file templates',
  175. '64e4299ac0a4c9e1de7a9d089e2d7529a9530818': 'doc: docker instructions for Windows',
  176. 'f897e844989083b0b369ba0ce4d2c5a9f3db5ad8': 'fix: #432',
  177. };
  178. const retro_prefixes = {};
  179. for ( const prefix in retro_prefixes_0 ) {
  180. for ( const commit_hash of retro_prefixes_0[prefix] ) {
  181. console.log('PREFIX', commit_hash, prefix);
  182. retro_prefixes[commit_hash] = prefix;
  183. }
  184. }
  185. const data = {};
  186. const ensure_scope = name => {
  187. if ( data[name] ) return;
  188. const o = data[name] = {};
  189. for ( const k in types ) o[k] = [];
  190. };
  191. for ( const commit of commits ) {
  192. if ( message_changes.hasOwnProperty(commit.hash) ) {
  193. commit.message = message_changes[commit.hash];
  194. }
  195. if ( retro_prefixes.hasOwnProperty(commit.hash) ) {
  196. commit.message = retro_prefixes[commit.hash] + ': ' +
  197. commit.message;
  198. }
  199. const meta = parse_conventional_commit(commit.message);
  200. if ( ! meta ) continue;
  201. for ( const transformer of complicated_cases ) {
  202. transformer({ commit, meta });
  203. }
  204. let scope = meta.scope ?? 'puter';
  205. while ( scope in scope_aliases ) {
  206. scope = scope_aliases[scope];
  207. }
  208. if ( ! scopes[scope] ) {
  209. console.log(commit);
  210. throw new Error(`missing scope: ${scope}`);
  211. }
  212. if ( scopes[scope].ignore ) continue;
  213. ensure_scope(scope);
  214. if ( types.hasOwnProperty(meta.type) ) {
  215. data[scope][meta.type].push({ meta, commit });
  216. }
  217. }
  218. let s = '';
  219. s += `## ${params.to} (${params.date})\n\n`;
  220. for ( const scope_name in data ) {
  221. const scope = data[scope_name];
  222. s += `### ${scopes[scope_name].label}\n\n`;
  223. for ( const type_name in types ) {
  224. const type = types[type_name];
  225. const items = scope[type_name];
  226. if ( items.length == 0 ) continue;
  227. s += `\n#### ${type.label}\n\n`;
  228. for ( const { meta, commit } of items ) {
  229. const shorthash = commit.hash.slice(0,7)
  230. s += `- ${meta.summary} ([${shorthash}](${REPO_URL}/commit/${commit.hash}))\n`;
  231. }
  232. }
  233. }
  234. console.log(s);