Skip to content

Commit

Permalink
Merge branch 'main' into fix-answers-folder
Browse files Browse the repository at this point in the history
  • Loading branch information
TatianaFokina authored Jul 22, 2024
2 parents c62da02 + 46550dd commit 4d3ffae
Show file tree
Hide file tree
Showing 17 changed files with 1,243 additions and 155 deletions.
140 changes: 83 additions & 57 deletions .github/scripts/update-changelog.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,87 @@
const fs = require('fs')

const addedContent = fs.readFileSync('added-content.txt').toString().split('\n')

const currentDate = new Date()
const currentYear = currentDate.getFullYear()
const monthNames = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь']
const currentMonth = monthNames[currentDate.getMonth()]
const header = `## ${currentMonth} ${currentYear}`

const contentList = addedContent
.map((fileName) => {
if (fs.existsSync(fileName)) {
const url = `https://doka.guide/${fileName.replace('index.md', '')}`
const date = process.argv[2]

const content = fs.readFileSync(fileName).toString()

const title = content
.match(/title: ('|"|).*('|"|)\n/)[0]
.replace(/title: ('|"|)/, '')
.replace(/('|"|)\n/, '')

const authorsSelection = /authors:\n( - .*\n)+(contributors|cover|editors|keywords|related|tags):/
const authors = content
.match(authorsSelection)[0]
.split('\n')
.slice(1, -1)
.map((s) => s.replace(' - ', ''))
.map((a) => {
const authorFileName = `./people/${a}/index.md`
if (fs.existsSync(authorFileName)) {
return fs.readFileSync(authorFileName)
.toString()
.match(/name: ('|"|).*('|"|)\n/)[0]
.replace(/name: ('|"|)/, '')
.replace(/('|"|)\n/, '')
}
return authorFileName
})

return `- ${date}, [${title}](${url}), ${authors.join(', ')}`
const fs = require("fs");

const addedContent = fs
.readFileSync("added-content.txt")
.toString()
.split("\n");

if (
addedContent.length === 0 ||
(addedContent.length > 0 && addedContent[0] === "")
) {
return;
}

const currentDate = new Date();
const currentYear = currentDate.getFullYear();
const monthNames = [
"Январь",
"Февраль",
"Март",
"Апрель",
"Май",
"Июнь",
"Июль",
"Август",
"Сентябрь",
"Октябрь",
"Ноябрь",
"Декабрь",
];
const currentMonth = monthNames[currentDate.getMonth()];
const header = `## ${currentMonth} ${currentYear}`;

const contentList = addedContent.map((fileName) => {
if (fs.existsSync(fileName)) {
const url = `https://doka.guide/${fileName.replace("index.md", "")}`;
const date = process.argv[2];

const content = fs.readFileSync(fileName).toString();

const title = content
.match(/title: ('|"|).*('|"|)\n/)[0]
.replace(/title: ('|"|)/, "")
.replace(/('|"|)\n/, "");

const authorsSelection =
/authors:\n( - .*\n)+(contributors|cover|editors|keywords|related|tags):/;
const authors = content
.match(authorsSelection)[0]
.split("\n")
.slice(1, -1)
.map((s) => s.replace(" - ", ""))
.map((a) => {
const authorFileName = `./people/${a}/index.md`;
if (fs.existsSync(authorFileName)) {
return fs
.readFileSync(authorFileName)
.toString()
.match(/name: ('|"|).*('|"|)\n/)[0]
.replace(/name: ('|"|)/, "")
.replace(/('|"|)\n/, "");
}
return authorFileName;
});

return `- ${date}, [${title}](${url}), ${authors.join(", ")}`;
}
});

if (contentList.length > 0) {
const changelogFileName = "./CHANGELOG.md";
if (fs.existsSync(changelogFileName)) {
const changelog = fs.readFileSync(changelogFileName).toString().split("\n");
if (changelog.filter((s) => s.startsWith("## ")).includes(header)) {
const headerPosition = changelog.findIndex((s) => s === header);
changelog.splice(headerPosition + 2, 0, ...contentList);
} else {
const headerPosition = 4;
changelog.splice(headerPosition, 0, ...[header, "", ""]);
changelog.splice(headerPosition + 2, 0, ...contentList);
}
})

const changelogFileName = './CHANGELOG.md'
if (fs.existsSync(changelogFileName)) {
const changelog = fs.readFileSync(changelogFileName).toString().split('\n')
if (changelog.filter((s) => s.startsWith('## ')).includes(header)) {
const headerPosition = changelog.findIndex((s) => s === header)
changelog.splice(headerPosition + 2, 0, ...contentList)
} else {
const headerPosition = 4
changelog.splice(headerPosition, 0, ...[header, '', ''])
changelog.splice(headerPosition + 2, 0, ...contentList)
fs.writeFileSync(changelogFileName, changelog.join("\n"));
console.log("Записи добавлены в CHANGELOG.md");
}
fs.writeFileSync(changelogFileName, changelog.join('\n'))
console.log('Записи добавлены в CHANGELOG.md');
} else {
console.log('Нечего добавлять в CHANGELOG.md');
console.log("Нечего добавлять в CHANGELOG.md");
}
70 changes: 46 additions & 24 deletions .github/scripts/update-changelog.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,49 @@
#!/bin/bash
git diff --name-status HEAD^ HEAD | grep '^A' | grep -E '(html|css|js|tools|a11y|recipes)\/.*\/index\.md' | sed 's/^A\t//g' > added-content.txt

MONTH_TO_RUS() {
case "$1" in
01) echo "января" ;;
02) echo "февраля" ;;
03) echo "марта" ;;
04) echo "апреля" ;;
05) echo "мая" ;;
06) echo "июня" ;;
07) echo "июля" ;;
08) echo "августа" ;;
09) echo "сентября" ;;
10) echo "октября" ;;
11) echo "ноября" ;;
12) echo "декабря" ;;
esac
}

MERGE_DATE=$(date -u +"%d %m")
DAY=$(echo $MERGE_DATE | cut -d ' ' -f 1)
MONTH=$(echo $MERGE_DATE | cut -d ' ' -f 2)
RUS_MONTH=$(MONTH_TO_RUS $MONTH)
FORMATTED_DATE="$DAY $RUS_MONTH"

node .github/scripts/update-changelog.js "$FORMATTED_DATE"
if [ -s added-content.txt ]; then
MONTH_TO_RUS() {
case "$1" in
01) echo "января" ;;
02) echo "февраля" ;;
03) echo "марта" ;;
04) echo "апреля" ;;
05) echo "мая" ;;
06) echo "июня" ;;
07) echo "июля" ;;
08) echo "августа" ;;
09) echo "сентября" ;;
10) echo "октября" ;;
11) echo "ноября" ;;
12) echo "декабря" ;;
esac
}

MERGE_DATE=$(date -u +"%d %m")
DAY=$(echo $MERGE_DATE | cut -d ' ' -f 1)
MONTH=$(echo $MERGE_DATE | cut -d ' ' -f 2)
RUS_MONTH=$(MONTH_TO_RUS $MONTH)
FORMATTED_DATE="$DAY $RUS_MONTH"

node .github/scripts/update-changelog.js "$FORMATTED_DATE"

rm -f added-content.txt

if [[ -z $(git status -s) ]]
then
echo $(git status)
else
git config --global user.name "Doka Dog"
git config --global user.email "<[email protected]>"

git add CHANGELOG.md
git commit -m "Обновляет CHANGELOG" --author "Doka Dog <[email protected]>"

git pull --rebase
git push origin main

exit
fi
else
echo "Новых материалов не было в предыдущем коммите"
fi
17 changes: 0 additions & 17 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,3 @@ jobs:
node-version: 20
- name: Ищет новые материалы и обновляет CHANGELOG
run: sh .github/scripts/update-changelog.sh
- name: Создание коммита с обновлениями полей
run: |
if [[ -z $(git status -s) ]]
then
echo $(git status)
else
git config --global user.name "Doka Dog"
git config --global user.email "<[email protected]>"
git add CHANGELOG.md
git commit -m "Обновляет CHANGELOG" --author "Doka Dog <[email protected]>"
git pull --rebase
git push origin main
exit
fi
2 changes: 1 addition & 1 deletion .github/workflows/update-dates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Update Dates
on:
workflow_run:
workflows:
- "Frontmatter Lint"
- "Update CHANGELOG"
branches:
- main
types:
Expand Down
23 changes: 2 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,9 @@

## Июль 2024





















- 19 июля, [`.difference()`](https://doka.guide/js/set-difference/), Viktar Nezhbart
- 22 июля, [Стилизация чекбоксов и радиокнопок](https://doka.guide/recipes/checkbox-radio-style/), Михаил Кривдин
- 19 июля, [`.intersection()`](https://doka.guide/js/set-intersection/), Viktar Nezhbart
- 19 июля, [`.difference()`](https://doka.guide/js/set-difference/), Viktar Nezhbart
- 12 июля, [`.union()`](https://doka.guide/js/set-union/), Viktar Nezhbart
- 1 июля, [`.symmetricDifference()`](https://doka.guide/js/set-symmetric-difference/), Viktar Nezhbart

Expand Down
5 changes: 5 additions & 0 deletions js/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ groups:
- set-keys
- set-entries
- set-size
- set-union
- set-difference
- set-intersection
- set-symmetric-difference
- set-is-subset-of
- name: "Обработка исключений"
items:
- try-catch
Expand Down
4 changes: 4 additions & 0 deletions js/set-is-subset-of/index.11tydata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"createdAt": "2024-07-19T23:12:09.819Z",
"updatedAt": "2024-07-19T23:12:09.819Z"
}
1 change: 0 additions & 1 deletion js/set-is-subset-of/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ related:
- js/set
- js/set-entries
- js/array-every
-
tags:
- doka
---
Expand Down
10 changes: 10 additions & 0 deletions people/lonlylokly/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: "Михаил Кривдин"
url: https://github.com/loonlylokly
photo: photo.png
photoAlt: "Инвертированный круг Малевича."
badges:
- first-contribution-small
---

Магистр ордена Дырявой Верстки.
Binary file added people/lonlylokly/photo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4d3ffae

Please sign in to comment.