ÿØÿà JFIF    ÿÛ „  ( %!1"%)+...383-7(-.+  -%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ     ÿÄ @    !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ    ÿÄ '   1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ϗ -3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéߦ$$½—šÙÜCC¯¶è8β–Åkèwx LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2޿د­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÁ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’שT ] ªb—ÊîKC^×M“xùäñz¬zJ× {4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi [0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú Ò˜Æ}2VE•Ѐp¡Ô3Úº …h³^LJºçì¥Ánó|˜ÖˆÎˆ+« ¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<̉Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈ Àá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ ƒÜÒ? :õdsÀ –3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LǐÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl Í›G¹ÀPá¼Nc¡šÒ…ÙWͳœ±vÊáЄ×9‹P‰cEØ‘™›µŸP<×g1 º©Ø¬wiÁ^l5× I/';Ë+´Z‡ÓÄFÕp[Èð’ HÄ ó 9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ QãñQtIeórVB,ÏÂf‹4#Μc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ  ÷jsςҒKÈcø(é›;k(’#ôŒQ ™C> õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~Ȧ—’-$fe«"FâUˆÊwµPÏu w+"åÉó¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ɏdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt ·K¢ÅÅ·¥RÄÊÉbKn N­R2g$VµÕó Qr#–ÓZUÏð0ÎtÙÀœz ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Δâ‘ËØ´IˆÓ°Ë‰ÞM3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z à¾] üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.ž„æ“I[ ª+·zÐÒÚ,½Ð»¶€C›7jk$๖€Ž¾ÅÙpp¶ÍþéΤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ćf× æ¢ƱqWı[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGށ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ ƈæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„ g01¬„åEM蛇Ã\6µE›‘fÙO k÷CºnÓ1`iîÒ² áÂ!ÑLÄÿ ³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#» Ç\……ßïIœÉ$¸ÎñÍ®ÔHÇ Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡ —JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ 5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*禌Éù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnݳvðÖKE¼‚ »mà ÷f®:Ë ™–4rð¡4` ܹçž~‹C=œ…¾Ïj|VDtK.ƒ"9 Ï ­–éXá³6WÒïIL-Ї Ç home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/.grunt/notes/src/generate.mjs000064400000026024152266421150024332 0ustar00#!/usr/bin/env node // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . import chalk from 'chalk'; import { getAllComponents } from './components.mjs'; import { getCombinedNotesByComponent, deleteAllNotes } from './note.mjs'; import { getNoteName } from './noteTypes.mjs'; import { writeFile, readFile, unlink } from 'fs/promises'; import { join as joinPath } from 'path'; import logger from './logger.mjs'; import { getCurrentVersion } from './helpers.mjs'; /** * Helper to fetch the current notes from a file. * * @param {string} file * @returns {Promise} */ const getCurrentNotes = async (file) => { try { return await readFile(file, 'utf8'); } catch (error) { return null; } } /** * Update the UPGRADING.md file. * * @param {string} upgradeNotes * @param {Object} options * @param {boolean} options.deleteNotes * @returns {Promise} */ const updateUpgradeNotes = async (upgradeNotes, options) => { const fileName = 'UPGRADING.md'; // Write the notes to a file. logger.info(`Writing notes to ${chalk.underline(chalk.bold(fileName))}`); // Prepend to the existing file. const existingContent = await getCurrentNotes(fileName); if (existingContent) { await writeFile(fileName, getUpdatedNotes(existingContent, upgradeNotes)); } else { // This should not normally happen. await writeFile(fileName, upgradeNotes); } if (options.deleteNotes) { logger.warn(`>>> Deleting all notes <<<`) // Delete the notes. deleteAllNotes(); } }; /** * Create the current summary notes. * * @param {string} upgradeNotes * @returns {Promise} */ const createCurrentSummary = async (upgradeNotes) => { const fileName = 'UPGRADING-CURRENT.md'; const notes = `# Moodle upgrade notes\n\n${upgradeNotes}`; await writeFile(fileName, notes); logger.info(`Running upgrade notes written to ${chalk.underline(chalk.bold(fileName))}`); }; /** * Get the indexes of the lines that contain the version headings. * * @param {array} lines * @returns {array} */ const getVersionLineIndexes = (lines) => { const h2Indexes = []; lines.forEach((line, index) => { const matches = line.match(/^##\s(?.*)$/); if (matches) { h2Indexes.push({ index, line, version: matches.groups.version, }); } }); return h2Indexes; }; /** * Find the index of the Unreleased heading. * * @param {array} versionHeadings * @returns {number} */ const findUnreleasedHeadingIndex = (versionHeadings) => versionHeadings.findIndex((heading) => { if (heading.version === 'Unreleased') { // Used if version cannot be guessed. return true; } if (heading.version.endsWith('+')) { // Weekly release for a stable branch. return true; } if (heading.version.match(/beta|rc\d/)) { // Beta and RC rolls are treated as weeklies. return true; } if (heading.version.endsWith('dev')) { // Development version. return true; } return false; }); /** * Get the before and after content, to facilitate replacing any existing Unreleased notes. * * @param {array} lines * @returns {Object} {beforeContent: string, afterContent: string} */ const getBeforeAndAfterContent = (lines) => { const existingLines = lines.split('\n'); const versionHeadings = getVersionLineIndexes(existingLines); if (versionHeadings.length > 0) { const unreleasedHeadingIndex = findUnreleasedHeadingIndex(versionHeadings); if (unreleasedHeadingIndex !== -1) { const beforeContent = existingLines.slice(0, versionHeadings[unreleasedHeadingIndex].index).join('\n'); if (versionHeadings.length > unreleasedHeadingIndex + 1) { const afterContent = existingLines.slice(versionHeadings[unreleasedHeadingIndex + 1].index).join('\n'); return { beforeContent, afterContent, }; } return { beforeContent, afterContent: '', }; } return { beforeContent: existingLines.slice(0, versionHeadings[0].index).join('\n'), afterContent: existingLines.slice(versionHeadings[0].index).join('\n'), }; } return { beforeContent: existingLines.join('\n'), afterContent: '', } }; /** * Get the notes for the component. * * @param {string} types * @param {Number} headingLevel * @returns {string} */ const getNotesForComponent = (types, headingLevel) => { let upgradeNotes = ''; Object.entries(types).forEach(([type, notes]) => { upgradeNotes += '#'.repeat(headingLevel); upgradeNotes += ` ${getNoteName(type)}\n\n`; notes.forEach(({ message, issueNumber }) => { // Split the message into lines, removing empty lines. const messageLines = message .split('\n') // Remove empty lines between tables, and list entries, but not after lists. .filter((line, index, lines) => { if (line.trim().length === 0) { // This line is empty. // If it's the first line in the file, remove it. if (index === 0) { return false; } // This is the last line in the file, remove it. if (index === lines.length - 1) { return false; } // If the previous line relates to a table, remove this line. if (lines[index - 1].match(/^\s*\|/)) { return false; } // If the next line is also empty, do not remove this line. if (lines[index + 1].trim().length === 0) { return true; } // Do not remove the line if the previous line was a list item. if (lines[index - 1].match(/^\s*[-*]\s/)) { return true; } if (lines[index - 1].match(/^\s*\d+\.\s/)) { return true; } // Preserve all other empty lines by default. return true; } // Keep any line which has content. return true; }); const firstLine = messageLines.shift().trim(); upgradeNotes += `- ${firstLine}\n`; messageLines .forEach((line) => { upgradeNotes += ` ${line}`.trimEnd() + `\n`; }); upgradeNotes += `\n For more information see [${issueNumber}](https://tracker.moodle.org/browse/${issueNumber})\n`; }); upgradeNotes += '\n'; }); return upgradeNotes; }; /** * Get the updated notes mixed with existing content. * * @param {string} existingContent * @param {string} upgradeNotes */ const getUpdatedNotes = (existingContent, upgradeNotes) => { const { beforeContent, afterContent } = getBeforeAndAfterContent(existingContent); const newContent = `${beforeContent}\n${upgradeNotes}\n${afterContent}` .split('\n') .filter((line, index, lines) => { if (line === '' && lines[index - 1] === '') { // Remove multiple consecutive empty lines. return false; } return true; }) .join('\n'); return newContent; }; /** * Update the notes for each component. */ const updateComponentNotes = ( notes, version, notesFileName = 'UPGRADING.md', removeEmpty = false, ) => { return getAllComponents().map(async (component) => { logger.verbose(`Updating notes for ${component.name} into ${component.path}`); const fileName = joinPath(component.path, notesFileName); const existingContent = await getCurrentNotes(fileName); if (!existingContent) { if (!notes[component.value]) { // No existing notes, and no new notes to add. return; } } else { if (!notes[component.value]) { // There is existing content, but nothing to add. if (removeEmpty) { logger.verbose(`Removing empty notes file ${fileName}`); await unlink(fileName); } return; } } const componentNotes = notes[component.value]; let upgradeNotes = `## ${version}\n\n`; upgradeNotes += getNotesForComponent(componentNotes, 3); if (existingContent) { await writeFile(fileName, getUpdatedNotes(existingContent, upgradeNotes)); } else { await writeFile( fileName, `# ${component.name} Upgrade notes\n\n${upgradeNotes}`, ); } }); } /** * Generate the upgrade notes for a new release. * * @param {string|undefined} version * @param {Object} options * @param {boolean} options.generateUpgradeNotes * @param {boolean} options.deleteNotes * @returns {Promise} */ export default async (version, options = {}) => { const notes = await getCombinedNotesByComponent(); if (Object.keys(notes).length === 0) { logger.warn('No notes to generate'); return; } if (!version) { version = await getCurrentVersion(); } // Generate the upgrade notes for this release. // We have // - a title with the release name // - the change types // - which contain the components // - which document each change let upgradeNotes = `## ${version}\n\n`; Object.entries(notes).forEach(([component, types]) => { upgradeNotes += `### ${component}\n\n`; upgradeNotes += getNotesForComponent(types, 4); }); await Promise.all([ createCurrentSummary(upgradeNotes), ...updateComponentNotes(notes, version, 'UPGRADING-CURRENT.md', true), ]); if (options.generateUpgradeNotes) { await Promise.all(updateComponentNotes(notes, version)); await updateUpgradeNotes(upgradeNotes, options); } };