diff --git a/.gitignore b/.gitignore index 1ccf4fbf..a43e95e9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ \.DS_Store scripts/node_modules scripts/learningpath +scripts/newsite scripts/.env \ No newline at end of file diff --git a/config/urls.yaml b/config/urls.yaml index 55604915..45a7ff28 100644 --- a/config/urls.yaml +++ b/config/urls.yaml @@ -9,6 +9,8 @@ video: # URL on the innersourcecommons.org site. isc: https://innersourcecommons.org/resources/learningpath/introduction/index + # URL on the innersourcecommons.net site. + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/01 # URL on the O'Reilly learning plarform. oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321606 # URL on YouTube. @@ -20,255 +22,307 @@ github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/01-introduction.asciidoc # URL on the innersourcecommons.org site. isc: https://innersourcecommons.org/resources/learningpath/introduction/index + # URL on the innersourcecommons.net site. + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/01 # URL on the O'Reilly learning plarform. oreilly: '' - section: introduction video: isc: https://innersourcecommons.org/resources/learningpath/introduction/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/02/ oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321607 youtube: https://www.youtube.com/watch?v=v9fL-E3ZVdc article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/02-problems-solved.asciidoc isc: https://innersourcecommons.org/resources/learningpath/introduction/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/02/ oreilly: '' - section: introduction video: isc: https://innersourcecommons.org/resources/learningpath/introduction/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/03/ oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321608 youtube: https://www.youtube.com/watch?v=jPPwnaEBd8U article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/03-how-works.asciidoc isc: https://innersourcecommons.org/resources/learningpath/introduction/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/03/ oreilly: '' - section: introduction video: isc: https://innersourcecommons.org/resources/learningpath/introduction/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/04/ oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321609 youtube: https://www.youtube.com/watch?v=PFLmOWCEpi4 article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/04-benefits.asciidoc isc: https://innersourcecommons.org/resources/learningpath/introduction/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/04/ oreilly: '' - section: introduction video: isc: https://innersourcecommons.org/resources/learningpath/introduction/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/05/ oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321610 youtube: https://www.youtube.com/watch?v=rLiDsM3w5YM article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/05-principles.asciidoc isc: https://innersourcecommons.org/resources/learningpath/introduction/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/05/ oreilly: '' - section: introduction video: isc: https://innersourcecommons.org/resources/learningpath/introduction/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/06/ oreilly: https://learning.oreilly.com/videos/introduction-to-innersource/9781492041504/9781492041504-video321611 youtube: https://www.youtube.com/watch?v=cFmg-c9IunM article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/introduction/06-conclusion.asciidoc isc: https://innersourcecommons.org/resources/learningpath/introduction/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/introduction/06/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/index + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/01 oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323925 youtube: https://www.youtube.com/watch?v=2FdD9Gup6Yc article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/01-introduction.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/index + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/01 oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/02/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323926 youtube: https://www.youtube.com/watch?v=QQ1z9DHlbhg article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/02-ensuring-product-quality.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/02/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/03/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323927 youtube: https://www.youtube.com/watch?v=aLGtTTzkQec article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/03-keeping-the-community-healthy.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/03/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/04/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323928 youtube: https://www.youtube.com/watch?v=452IVT7TKsE article: anchor: pass:[#upleveling] github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/04-uplevelling-community-members.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/04/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/05/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323929 youtube: https://www.youtube.com/watch?v=0Ztb6k5Y17o article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/05-lowering-the-barriers-to-entry.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/05/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/06/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323930 youtube: https://www.youtube.com/watch?v=sqE-Uif_giA article: anchor: pass:[#advocating] github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/06-advocating-for-the-communitys-needs.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/06/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/07/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/07/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323931 youtube: https://www.youtube.com/watch?v=nZp8jlr9l-k article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/07-becoming-a-trusted-committer.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/07/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/07/ oreilly: '' - section: trusted committer video: isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/08/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/08/ oreilly: https://learning.oreilly.com/videos/the-trusted-committer/9781492047599/9781492047599-video323932 youtube: https://www.youtube.com/watch?v=qlVpZn_2KMs article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/trusted-committer/08-conclusion.asciidoc isc: https://innersourcecommons.org/resources/learningpath/trusted-committer/08/ + isc.net: https://innersourcecommons.net/learn/learning-path/trusted-committer/08/ oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/index + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/01 oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325229 youtube: https://www.youtube.com/watch?v=urbkSMsJXZ0 article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/01-opening-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/index + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/01 oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/02/ oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325230 youtube: https://www.youtube.com/watch?v=PQwlatm5Kak article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/02-how-difficult-it-is-to-be-a-middle-manager-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/02/ oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/03/ oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325231 youtube: https://www.youtube.com/watch?v=UGX7khGbtx0 article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/03-major-benefits-are-built-into-the-innersource-process-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/03/ oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/04/ oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325232 youtube: https://www.youtube.com/watch?v=afXNJjt2ReI article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/04-new-roles-and-responsibilities-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/04/ oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/05/ oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325233 youtube: https://www.youtube.com/watch?v=LO5ouFdgyBY article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/05-recap-takeaways-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/05/ oreilly: '' - section: product owner video: isc: https://innersourcecommons.org/resources/learningpath/product-owner/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/06/ oreilly: https://learning.oreilly.com/videos/innersource-product-owners/9781492046707/9781492046707-video325234 youtube: https://www.youtube.com/watch?v=0beNc9V-tro article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/product-owner/06-closing-and-contact-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/product-owner/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/product-owner/06/ oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/index + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/01 oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329499 youtube: https://www.youtube.com/watch?v=ncPO1fz5fRg article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/01-introduction-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/index + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/01 oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/02/ oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329500 youtube: https://www.youtube.com/watch?v=v3aRZkbTSmY article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/02-becoming-a-contributor-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/02/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/02/ oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/03/ oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329501 youtube: https://www.youtube.com/watch?v=iQu-l3j2kCg article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/03-contributor-ethos-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/03/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/03/ oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/04/ oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329502 youtube: https://www.youtube.com/watch?v=wv3uylJC4K0 article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/04-mechanics-of-contributing-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/04/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/04/ oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/05/ oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329503 youtube: https://www.youtube.com/watch?v=HMBW0B1XPi0 article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/05-benefits-of-contribution-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/05/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/05/ oreilly: '' - section: contributor video: isc: https://innersourcecommons.org/resources/learningpath/contributor/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/06/ oreilly: https://learning.oreilly.com/learning-paths/learning-path-the/0636920338833/0636920338802-video329504 youtube: https://www.youtube.com/watch?v=5SztKQyeUiM article: anchor: '' github: https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/contributor/06-conclusion-article.asciidoc isc: https://innersourcecommons.org/resources/learningpath/contributor/06/ + isc.net: https://innersourcecommons.net/learn/learning-path/contributor/06/ oreilly: '' diff --git a/scripts/.node-version b/scripts/.node-version new file mode 100644 index 00000000..3cacc0b9 --- /dev/null +++ b/scripts/.node-version @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/scripts/README.md b/scripts/README.md index decd70b7..d997c465 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -15,11 +15,11 @@ For example, to point all links to innersourcecommons.org: node substitute_article_urls.js isc ``` -## generate_learning_path_markdown.js +## generate_jekyll_learning_path_markdown.js, generate_hugo_learning_path_markdown.js -A node script to generate markdown files required for hosting Learning Path on innersourcecommons.org. +Node scripts to generate markdown files required for hosting Learning Path on innersourcecommons.org and innersourcecommons.net. -This script requires a [GitHub access token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token), as it uses the GitHub API to get Learning Path contributors. Your token does not require any scopes, as the Learning Path is Open Source. To provide this, create a `.env` file in this directory in the following format: +These scripts require a [GitHub access token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token), as they use the GitHub API to get Learning Path contributors. Your token does not require any scopes, as the Learning Path is Open Source. To provide this, create a `.env` file in this directory in the following format: ``` TOKEN= ``` @@ -27,7 +27,8 @@ TOKEN= ### Usage: ``` npm ci -node generate_learning_path_markdown.js +node generate_jekyll_learning_path_markdown.js +node generate_hugo_learning_path_markdown.js ``` ## How to update innersourcecommons.org with new articles @@ -38,17 +39,35 @@ Anytime there are _new_ articles written, you need to run the script that genera 1. Is this the first time that articles have been written for this section in this language? If so, then do both of the following: - * update the ["sections" config](https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/scripts/generate_learning_path_markdown.js#L37) with the language code of the articles for the appropriate section. + * update the ["sections" config](https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/scripts/section_data.json) with the language code of the articles for the appropriate section. Open a pull request for the change. * update the [Learning Path landing page](https://github.com/InnerSourceCommons/innersourcecommons.org/blob/master/resources/learningpath/index.md) with a link to your new language pages. -3. Run **generate_learning_path_markdown.js** as described above. +3. Run **generate_jekyll_learning_path_markdown.js** as described above. 3. `cp -r learningpath/* /resources/learningpath/`. 3. Open a pull request with the modified files in the [InnerSourceCommons/innersourcecommons.org] repo. Note that these steps only needs to happen when there are new articles written. Changes to existing articles will automatically show up on the [innersourcecommons.org] site. -[innersourcecommons.org]: http://www.innersourcecommons.org/ +## How to update innersourcecommons.net + +Anytime there are _any changes_, you need to run the script that generates the updated pages on the [innersourcecommons.net] site. + +1. Clone the [InnerSourceCommons/InnerSourceLearningPath] and [InnerSourceCommons/innersourcecommons.net] repos. +1. Is this the first time that articles have been written for this section in this language? +If so, then do both of the following: + + * update the ["sections" config](https://github.com/InnerSourceCommons/InnerSourceLearningPath/blob/master/scripts/section_data.json) with the language code of the articles for the appropriate section and open a pull request for the change + * make sure this language appears in the [website config](https://github.com/InnerSourceCommons/innersourcecommons.net/blob/master/config.yaml) and there are the relevant [index pages](https://github.com/InnerSourceCommons/innersourcecommons.net/blob/master/content/learn/_index.ru.md) + +3. Run `node substitute_article_urls.js isc.net` as described above. This changes the asciidoc source files' links to point at [innnersourcecommons.net] - do not commit this change! +3. Run **generate_hugo_learning_path_markdown.js** as described above. +3. `cp -r newsite/ /content/learn/learning-path/`. +3. Open a pull request with the modified files in the [InnerSourceCommons/innersourcecommons.net] repo. + +[innersourcecommons.org]: https://innersourcecommons.org/ +[innersourcecommons.net]: https://innersourcecommons.net/ [InnerSourceCommons/InnerSourceLearningPath]: https://github.com/InnerSourceCommons/InnerSourceLearningPath/ [InnerSourceCommons/innersourcecommons.org]: https://github.com/InnerSourceCommons/innersourcecommons.org +[InnerSourceCommons/innersourcecommons.net]: https://github.com/InnerSourceCommons/innersourcecommons.net diff --git a/scripts/generate_hugo_learning_path_markdown.js b/scripts/generate_hugo_learning_path_markdown.js new file mode 100644 index 00000000..bca764b9 --- /dev/null +++ b/scripts/generate_hugo_learning_path_markdown.js @@ -0,0 +1,55 @@ +// TODO: GitHub Actions - more pertinent now article is rendered at build time not run time + +(async() => { + const fs = require('fs') + const YAML = require('yaml') + const { join } = require('path') + const asciidoctor = require('asciidoctor')() + const writeMarkdownFile = require('./write_markdown_file') + const generate = require('./generate_learning_path_markdown') + + const urls = YAML.parse(fs.readFileSync(join('..', 'config', 'urls.yaml'), 'utf-8')) + + const getYouTubeCode = (section, articleNumber) => { + const firstEntryOfGroupIndex = urls.findIndex(entry => entry.section === section.toLowerCase()) + const currentPageIndexOffset = articleNumber - 1 + const youtubeUrl = urls[firstEntryOfGroupIndex + currentPageIndexOffset].video.youtube + return youtubeUrl.replace('https://www.youtube.com/watch?v=', '') + } + + const generatorFn = ({ isTranslation, baseWritePath, articleNumber, translation, articleTitle, contributors, image, section, article}) => { + const fileName = isTranslation ? join(baseWritePath, [articleNumber, translation, 'md'].join('.')) : join(baseWritePath, [articleNumber, 'md'].join('.')) + const weight = parseInt(articleNumber) + const youtubeCode = getYouTubeCode(section.learning_path_group, weight) + + const frontMatter = { + title: articleTitle, + contributors, + image: `https://img.youtube.com/vi/${youtubeCode}/mqdefault.jpg`, + featured: weight === 1, + weight, + youtubeCode + } + + const titleStripped = article.asciiDoc.replace(/== (.*)/, '') + const body = section.renderArticles || isTranslation ? asciidoctor.convert(titleStripped) : '' + + writeMarkdownFile(fileName, frontMatter, body) + } + + const workbookFn = ({ workbookFileName, contributors, section, workbookPosition }) => { + const workbookFrontMatter = { + title: 'Workbook', + contributors, + image: section.image, + weight: workbookPosition + } + + const workbookReadPath = join('..', 'workbook', section.workbook) + const body = asciidoctor.convert(fs.readFileSync(workbookReadPath, 'utf-8')) + + writeMarkdownFile(workbookFileName, workbookFrontMatter, body) + } + + generate('newsite', generatorFn, workbookFn, false) +})() diff --git a/scripts/generate_jekyll_learning_path_markdown.js b/scripts/generate_jekyll_learning_path_markdown.js new file mode 100644 index 00000000..f17db471 --- /dev/null +++ b/scripts/generate_jekyll_learning_path_markdown.js @@ -0,0 +1,43 @@ +(async() => { + const writeMarkdownFile = require('./write_markdown_file') + const generate = require('./generate_learning_path_markdown') + const path = require('path') + + const generatorFn = ({ isTranslation, writePath, articleNumber, translation, articleTitle, contributors, section, article}) => { + const fileName = articleNumber === '01' ? path.join(writePath, 'index.md') : path.join(writePath, `${articleNumber}.md`) + + const frontMatter = { + layout: 'learning-path-page', + show_meta: false, + title: `Learning Path - ${section.learning_path_group} - ${articleTitle}`, + learning_path_article: section.renderArticles || isTranslation ? path.relative('..', article.filePath) : undefined, + learning_path_group: section.learning_path_group, + learning_path_menu_title: `${articleNumber} - ${articleTitle}`, + learning_path_position: parseInt(articleNumber), + learning_path_translation: translation, + no_video: isTranslation, // Videos not available translated. + contributors + } + + writeMarkdownFile(fileName, frontMatter) + } + + const workbookFn = ({ workbookFileName, contributors, section, workbookPosition }) => { + const workbookFrontMatter = { + layout: 'learning-path-page', + show_meta: false, + title: `Learning Path - ${section.learning_path_group} - Workbook`, + learning_path_article: `workbook/${section.workbook}`, + learning_path_group: section.learning_path_group, + learning_path_menu_title: `${section.learning_path_group} Workbook`, + learning_path_position: workbookPosition, + learning_path_translation: '', + no_video: true, + contributors + } + + writeMarkdownFile(workbookFileName, workbookFrontMatter) + } + + generate('learningpath', generatorFn, workbookFn, true) +})() diff --git a/scripts/generate_learning_path_markdown.js b/scripts/generate_learning_path_markdown.js index 7ea9d703..88133d2f 100644 --- a/scripts/generate_learning_path_markdown.js +++ b/scripts/generate_learning_path_markdown.js @@ -1,127 +1,57 @@ -(async() => { - const fs = require('fs') - const YAML = require('yaml') - const { EOL } = require('os') - const { join } = require('path') - const getContributors = require('./get_contributors') +const { join, basename, relative } = require('path') +const getContributors = require('./get_contributors') +const mkdirSync = require('./mkdir_sync') +const getArticleFiles = require('./get_article_files') - const mkdirSync = (dir) => { - try { - fs.mkdirSync(dir) - } catch (e) { - if (e.code !== 'EEXIST') { - console.log(e) - } - } - } - - const getArticleFiles = (path) => { - return fs.readdirSync(path).reduce((articles, filename) => { - const filePath = `${path}/${filename}` - if (filePath.match(/\d\d/) && !filePath.includes('-script.asciidoc')) { - return [...articles, { - filePath, - asciiDoc: fs.readFileSync(filePath, 'utf-8') - }] - } else { - return articles - } - }, []) - } - - const writeMarkdownFile = (filePath, frontMatter) => { - const frontMatterTerminator = '---' - const originStatement = '' - const output = [frontMatterTerminator, YAML.stringify(frontMatter).trim(), frontMatterTerminator, originStatement].join(EOL) - fs.writeFileSync(filePath, output) - } +const sections = require('./section_data.json') - const sections = [ - { - learning_path_group: 'Introduction', - dirName: 'introduction', - workbook: '01-introduction.asciidoc', - translations: ['de', 'it', 'ja', 'zh', 'ru'], - renderArticles: true - }, - { - learning_path_group: 'Trusted Committer', - dirName: 'trusted-committer', - workbook: '02-trusted-committer.asciidoc', - translations: ['de', 'zh'], - renderArticles: true - }, - { - learning_path_group: 'Contributor', - dirName: 'contributor', - workbook: '04-contributor.asciidoc', - translations: ['it', 'ja', 'zh'], - renderArticles: true - }, - { - learning_path_group: 'Product Owner', - dirName: 'product-owner', - workbook: '03-product-owner.asciidoc', - translations: ['zh'], - renderArticles: true - }, - ] +module.exports = async (writeDir, generatorFn, workbookFn, createTranslationFolder) => { + mkdirSync(join('.', writeDir)) - mkdirSync('./learningpath') - - sections.forEach(({ learning_path_group, dirName, workbook, translations, renderArticles }) => { - const baseReadPath = `../${dirName}` - const baseWritePath = `./learningpath/${dirName}` + sections.forEach(section => { + const { dirName, translations } = section + const baseReadPath = join('..', dirName) + const baseWritePath = join('.', writeDir, dirName) mkdirSync(baseWritePath) translations.concat('' /* The English original */).forEach(async (translation) => { const isTranslation = translation !== '' const writePath = join(baseWritePath, translation) - mkdirSync(writePath) + if (createTranslationFolder) mkdirSync(writePath) const readPath = join(baseReadPath, translation) const articles = getArticleFiles(readPath) articles.forEach(async (article) => { const articleTitle = article.asciiDoc.match(/== (.*)/)[1] - const articleNumber = article.filePath.split('/').pop().split('-')[0] - const fileName = articleNumber === '01' ? `${writePath}/index.md` : `${writePath}/${articleNumber}.md` - const contributors = await getContributors(article.filePath.replace('../', '')) - const frontMatter = { - layout: 'learning-path-page', - show_meta: false, - title: `Learning Path - ${learning_path_group} - ${articleTitle}`, - learning_path_article: renderArticles ? article.filePath.replace('../', '') : undefined, - learning_path_group, - learning_path_menu_title: `${articleNumber} - ${articleTitle}`, - learning_path_position: parseInt(articleNumber), - learning_path_translation: translation, - no_video: isTranslation, // Videos not available translated. - contributors - } - - writeMarkdownFile(fileName, frontMatter) + const articleNumber = basename(article.filePath).split('-')[0] + const contributors = await getContributors(relative('..', article.filePath)) + + generatorFn({ + section, + articleTitle, + articleNumber, + isTranslation, + article, + translation, + contributors, + writePath, + baseWritePath + }) }) // Workbooks not translated. if (!isTranslation) { - const workbookFileName = `${writePath}/workbook.md` - const contributors = await getContributors(`workbook/${workbook}`) - console.log('workbookFileName', workbookFileName) - const workbookFrontMatter = { - layout: 'learning-path-page', - show_meta: false, - title: `Learning Path - ${learning_path_group} - Workbook`, - learning_path_article: `workbook/${workbook}`, - learning_path_group, - learning_path_menu_title: `${learning_path_group} Workbook`, - learning_path_position: articles.length - articles.filter(Array.isArray).length + 1, - learning_path_translation: translation, - no_video: true, - contributors - } - - writeMarkdownFile(workbookFileName, workbookFrontMatter) + const workbookFileName = join(baseWritePath, 'workbook.md') + const contributors = await getContributors(`workbook/${section.workbook}`) + const workbookPosition = articles.length + 1 + + workbookFn({ + section, + workbookFileName, + contributors, + workbookPosition + }) } }) }) -})() +} diff --git a/scripts/get_article_files.js b/scripts/get_article_files.js new file mode 100644 index 00000000..798a3ee6 --- /dev/null +++ b/scripts/get_article_files.js @@ -0,0 +1,16 @@ +const fs = require('fs') +const { join } = require('path') + +module.exports = getArticleFiles = (path) => { + return fs.readdirSync(path).reduce((articles, filename) => { + const filePath = join(path, filename) + if (filePath.match(/\d\d/) && !filePath.includes('-script.asciidoc')) { + return [...articles, { + filePath, + asciiDoc: fs.readFileSync(filePath, 'utf-8') + }] + } else { + return articles + } + }, []) +} \ No newline at end of file diff --git a/scripts/mkdir_sync.js b/scripts/mkdir_sync.js new file mode 100644 index 00000000..3d273b36 --- /dev/null +++ b/scripts/mkdir_sync.js @@ -0,0 +1,11 @@ +const fs = require('fs') + +module.exports = mkdirSync = (dir) => { + try { + fs.mkdirSync(dir) + } catch (e) { + if (e.code !== 'EEXIST') { + console.log(e) + } + } +} \ No newline at end of file diff --git a/scripts/package-lock.json b/scripts/package-lock.json index 9d57dfb2..f6f275f1 100644 --- a/scripts/package-lock.json +++ b/scripts/package-lock.json @@ -4,6 +4,15 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@asciidoctor/core": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@asciidoctor/core/-/core-2.2.1.tgz", + "integrity": "sha512-wdVseZjCcBvFfWSsCGyyvJkSQJ9UmXDdTDKnL+HerM12XQq4eWtk7lniSIKO459ipqImcsrueib47EtkzzRjLw==", + "requires": { + "asciidoctor-opal-runtime": "0.3.0", + "unxhr": "1.0.1" + } + }, "@octokit/endpoint": { "version": "6.0.9", "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.9.tgz", @@ -62,6 +71,99 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.6.tgz", "integrity": "sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw==" }, + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "asciidoctor": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/asciidoctor/-/asciidoctor-2.2.1.tgz", + "integrity": "sha512-adH/pDPDZCd4eb1ku7N8WepN+O6Yl0lVQPWE/ep7+0BFkBm4P/Sx8DUqzZ+X+nG6WSZlma5Uu0gNuDgrc7etFg==", + "requires": { + "@asciidoctor/cli": "3.4.0", + "@asciidoctor/core": "2.2.1" + }, + "dependencies": { + "@asciidoctor/cli": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@asciidoctor/cli/-/cli-3.4.0.tgz", + "integrity": "sha512-jOtxA0I6zB+6z+GGwm9+xhlmGTqCTkFPE902L6fauFlE6v7LxjhLYNxvjDVyn0zMrFLybvoSRcAnM3DcticNoQ==", + "requires": { + "yargs": "15.3.1" + } + } + } + }, + "asciidoctor-opal-runtime": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/asciidoctor-opal-runtime/-/asciidoctor-opal-runtime-0.3.0.tgz", + "integrity": "sha512-YapVwl2qbbs6sIe1dvAlMpBzQksFVTSa2HOduOKFNhZlE9bNmn+moDgGVvjWPbzMPo/g8gItyTHfWB2u7bQxag==", + "requires": { + "glob": "7.1.3", + "unxhr": "1.0.1" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" + }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, "deprecation": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", @@ -72,11 +174,83 @@ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, "is-plain-object": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "requires": { + "p-locate": "^4.1.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, "node-fetch": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", @@ -90,20 +264,136 @@ "wrappy": "1" } }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "requires": { + "ansi-regex": "^5.0.0" + } + }, "universal-user-agent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" }, + "unxhr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/unxhr/-/unxhr-1.0.1.tgz", + "integrity": "sha512-MAhukhVHyaLGDjyDYhy8gVjWJyhTECCdNsLwlMoGFoNJ3o79fpQhtQuzmAE4IxCMDwraF4cW8ZjpAV0m9CRQbg==" + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, + "y18n": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", + "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==" + }, "yaml": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.0.tgz", "integrity": "sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==" + }, + "yargs": { + "version": "15.3.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.3.1.tgz", + "integrity": "sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==", + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.1" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } } } } diff --git a/scripts/package.json b/scripts/package.json index d436ee54..3fead96c 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -5,6 +5,7 @@ "main": "substitute_article_urls.js", "dependencies": { "@octokit/graphql": "^4.5.7", + "asciidoctor": "^2.2.1", "dotenv": "^8.2.0", "yaml": "^1.10.0" }, diff --git a/scripts/section_data.json b/scripts/section_data.json new file mode 100644 index 00000000..7cda7be5 --- /dev/null +++ b/scripts/section_data.json @@ -0,0 +1,34 @@ +[ + { + "learning_path_group": "Introduction", + "dirName": "introduction", + "workbook": "01-introduction.asciidoc", + "translations": ["de", "it", "ja", "zh", "ru"], + "image": "images/learn/LP_thumbnail_introduction.jpg", + "renderArticles": true + }, + { + "learning_path_group": "Trusted Committer", + "dirName": "trusted-committer", + "workbook": "02-trusted-committer.asciidoc", + "translations": ["de", "zh"], + "image": "images/learn/LP_thumbnail_trustedcommitter.jpg", + "renderArticles": true + }, + { + "learning_path_group": "Contributor", + "dirName": "contributor", + "workbook": "04-contributor.asciidoc", + "translations": ["it", "ja", "zh"], + "image": "images/learn/LP_thumbnail_contributor.jpg", + "renderArticles": true + }, + { + "learning_path_group": "Product Owner", + "dirName": "product-owner", + "workbook": "03-product-owner.asciidoc", + "translations": ["zh"], + "image": "images/learn/LP_thumbnail_productowner.jpg", + "renderArticles": false + } +] \ No newline at end of file diff --git a/scripts/substitute_article_urls.js b/scripts/substitute_article_urls.js index 4de8cada..e5559389 100644 --- a/scripts/substitute_article_urls.js +++ b/scripts/substitute_article_urls.js @@ -1,14 +1,15 @@ const fs = require('fs') const YAML = require('yaml') +const { join } = require('path') const target = process.argv[2] -const urlsFile = fs.readFileSync('../config/urls.yaml', 'utf8') +const urlsFile = fs.readFileSync(join('..', 'config', 'urls.yaml'), 'utf8') const urls = YAML.parse(urlsFile).map(({ video, article }) => [video, article]).flat() const getArticleFiles = (path) => { return fs.readdirSync(path).map((filename) => { - const filePath = `${path}/${filename}` + const filePath = join(path, filename) if (fs.lstatSync(filePath).isDirectory()) { return getArticleFiles(filePath) } else { @@ -19,7 +20,7 @@ const getArticleFiles = (path) => { } }).flat() } -const articleFiles = [getArticleFiles('../introduction'), getArticleFiles('../product-owner'), getArticleFiles('../trusted-committer'), getArticleFiles('../contributor')].flat() +const articleFiles = [getArticleFiles(join('..', 'introduction')), getArticleFiles(join('..', 'product-owner')), getArticleFiles(join('..', 'trusted-committer')), getArticleFiles(join('..', 'contributor'))].flat() const substituted = articleFiles.map((articleFile) => { let asciiDoc = articleFile.asciiDoc diff --git a/scripts/write_markdown_file.js b/scripts/write_markdown_file.js new file mode 100644 index 00000000..c2a5189f --- /dev/null +++ b/scripts/write_markdown_file.js @@ -0,0 +1,10 @@ +const fs = require('fs') +const YAML = require('yaml') +const { EOL } = require('os') + +module.exports = writeMarkdownFile = (filePath, frontMatter, body) => { + const frontMatterTerminator = '---' + const originStatement = '' + const output = [frontMatterTerminator, YAML.stringify(frontMatter).trim(), frontMatterTerminator, body, originStatement].filter(item => !!item).join(EOL) + fs.writeFileSync(filePath, output) +} \ No newline at end of file