forked from lucee/lucee-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Added_a_examples_08-11-23
- Loading branch information
Showing
439 changed files
with
17,615 additions
and
307 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
const crypto = require('crypto'); | ||
|
||
async function generateIndex() { | ||
const recipesDir = path.join(__dirname, '../../docs/recipes'); | ||
const outputPath = path.join(recipesDir, 'index.json'); | ||
const readmePath = path.join(recipesDir, 'README.md'); | ||
const files = await fs.readdir(recipesDir); | ||
const index = []; | ||
let readmeContent = '# Recipes\n\n'; | ||
|
||
console.log('Generating index and README...'); | ||
console.log(`Reading files from ${recipesDir}`); | ||
|
||
for (const file of files) { | ||
if (file.endsWith('.md') && file !== 'README.md') { | ||
console.log(`Processing file: ${file}`); | ||
const filePath = path.join(recipesDir, file); | ||
const content = await fs.readFile(filePath, 'utf-8'); | ||
const titleMatch = content.match(/^#\s+(.+)$/m); | ||
const title = titleMatch ? titleMatch[1] : 'Untitled'; | ||
const hash = crypto.createHash('md5').update(content).digest('hex'); | ||
|
||
// Extract metadata from the comment block | ||
const metadataMatch = content.match(/<!--\s*({[^]*?})\s*-->/); | ||
let description = 'No description available.'; | ||
let keywords = []; | ||
if (metadataMatch) { | ||
const metadata = JSON.parse(metadataMatch[1]); | ||
if (metadata.description) { | ||
description = metadata.description; | ||
} | ||
if (metadata.keywords) { | ||
keywords = metadata.keywords; | ||
} | ||
} | ||
|
||
index.push({ | ||
file: file, | ||
title: title, | ||
path: `/docs/recipes/${file}`, | ||
hash: hash, | ||
keywords: keywords | ||
}); | ||
|
||
readmeContent += `## [${title}](/docs/recipes/${file})\n\n${description}\n\n`; | ||
} | ||
} | ||
|
||
console.log(`Writing index to ${outputPath}`); | ||
await fs.writeJson(outputPath, index, { spaces: 2 }); | ||
|
||
console.log(`Writing README to ${readmePath}`); | ||
await fs.writeFile(readmePath, readmeContent.trim(), 'utf-8'); | ||
|
||
const readmeExists = await fs.pathExists(readmePath); | ||
console.log(`README exists: ${readmeExists}`); | ||
|
||
console.log('Index and README generation complete.'); | ||
} | ||
|
||
generateIndex().catch(err => { | ||
console.error('Error generating index and README:', err); | ||
process.exit(1); | ||
}); |
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,43 @@ | ||
name: Generate Recipes Index | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
paths: | ||
- "docs/recipes/**" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
generate-index: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
|
||
- name: Install dependencies | ||
run: | | ||
npm install fs-extra | ||
- name: Generate index | ||
run: | | ||
node .github/scripts/generate-index-recipes.js | ||
- name: Commit and push changes | ||
run: | | ||
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/}) | ||
if [ -n "$(git status --porcelain)" ]; then | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "Lucee Docs GitHub Action" | ||
git add docs/recipes/index.json docs/recipes/README.md | ||
git commit -m "Update recipes index and README" | ||
git push origin $BRANCH_NAME | ||
else | ||
echo "No changes found to commit" | ||
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 |
---|---|---|
|
@@ -7,9 +7,9 @@ jobs: | |
name: 🧹 Markdown Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- name: 🥝 Use Node.js | ||
uses: actions/setup-node@v3.5.1 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '12.x' | ||
- run: npm install -g [email protected] | ||
|
@@ -19,7 +19,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- name: 🍉 Check Out | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
- name: 🥥 Install | ||
run: | | ||
wget -O - -q https://git.io/misspell | sh -s -- -b . | ||
|
@@ -30,8 +30,8 @@ jobs: | |
name: 🧹 YAML Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4.3.0 | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax | ||
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified | ||
|
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
jmimemagic.log | ||
.exitcode | ||
node_modules | ||
.vscode | ||
jmimemagic.log | ||
.exitcode | ||
node_modules | ||
.vscode | ||
package-lock.json | ||
|
||
server/server-luceedocslocalserver.json | ||
server-luceedocsbuilder.json | ||
.commandbox | ||
server/performance.log | ||
server/performance.log | ||
/commandbox-luceedocslocalserver |
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
Oops, something went wrong.