-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-answers-folder
- Loading branch information
Showing
17 changed files
with
1,243 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ related: | |
- js/set | ||
- js/set-entries | ||
- js/array-every | ||
- | ||
tags: | ||
- doka | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
--- | ||
|
||
Магистр ордена Дырявой Верстки. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.