GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — update ci scripts for flags docs gen · gridaco/code@165ed07

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • docs-deploy.yml
  • docs/flags
    • .gitignore
    • README.md
  • scripts
    • docs-copy
      • flags-api-docs.js
    • docs-deploy
      • pre-deploy.sh
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/docs-deploy.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/docs-deploy.yml
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v2
10+
- name: run pre-deploy (build docs and more)
11+
run: |
12+
chmod +x ./scripts/docs-deploy/pre-deploy.sh
13+
./scripts/docs-deploy/pre-deploy.sh
14+
shell: bash
1015
- name: copy docs to gridaco/grida.co
1116
uses: DevOpenWRT-Router/github-action-push-to-another-repository@main
1217
env:
Collapse file

‎docs/flags/.gitignore‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Learn more at scripts/docs-copy/flags-api-docs.js
2+
# custom
3+
----ignore.md
4+
---custom.md
5+
6+
# flags api docs
7+
--*.md
Collapse file

‎docs/flags/README.md‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Flags Documentation directory.
2+
3+
Go to [Index](./index.md)
4+
5+
## Flags Api references are copied from support-flags package via script - `/scripts/docs-copy/flags-api-docs.sh`
Collapse file

‎scripts/docs-copy/flags-api-docs.js‎

Copy file name to clipboard
+64Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
const origin = "./packages/support-flags";
5+
const target = "./docs/flags";
6+
const github_base_url =
7+
"https://github.com/gridaco/designto-code/tree/main/packages/support-flags";
8+
/**
9+
* copies the README.md file under each directory under "origin" to "target"
10+
* the README.md content will be preserved, but the file name will be changed to current folder name
11+
* for example, if the file is `--action/README.md`, the file will be copied and renamed to `--action.md`
12+
*
13+
* the origin directory will have multiple subdirectory with one README.md file.
14+
* these files under each subdirectory will be copied directly under "target" with above new file name.
15+
*/
16+
function copy() {
17+
const files = [];
18+
19+
// read all directories under origin directory with pattern that matches regex `/^--[a-z]+(.*?)$/` as prefix
20+
// add README.md files to files array
21+
fs.readdirSync(origin).forEach((dir) => {
22+
if (dir.match(/^--[a-z]+(.*?)$/)) {
23+
const dirPath = path.join(origin, dir);
24+
const filesInDir = fs.readdirSync(dirPath);
25+
filesInDir.forEach((file) => {
26+
if (file === "README.md") {
27+
files.push(path.join(dirPath, file));
28+
}
29+
});
30+
}
31+
});
32+
33+
// these are custom directories under origin. [`----disable`, `---custom`]
34+
// add README.md under these directory, add to files array
35+
["----disable", "---custom"].forEach((dir) => {
36+
const dirPath = path.join(origin, dir);
37+
const filesInDir = fs.readdirSync(dirPath);
38+
filesInDir.forEach((file) => {
39+
if (file === "README.md") {
40+
files.push(path.join(dirPath, file));
41+
}
42+
});
43+
});
44+
45+
// read the content and extension of each file, save it to a map. where key being the file path, value being the content and extension
46+
const fileMap = new Map();
47+
files.forEach((file) => {
48+
const content = fs.readFileSync(file, "utf8");
49+
const ext = path.extname(file);
50+
// make a key. the key is extracted from var - file, which is a paht. extract last directory name and use it as key. e.g. "../../--action/README.md" -> "--action"
51+
const key = path.basename(path.dirname(file));
52+
fileMap.set(key, { content, ext });
53+
});
54+
55+
// copy each file to target directory
56+
fileMap.forEach((value, key) => {
57+
const newFile = path.join(target, `${key}${value.ext}`);
58+
fs.writeFileSync(newFile, value.content);
59+
});
60+
}
61+
62+
if (require.main === module) {
63+
copy();
64+
}
Collapse file

‎scripts/docs-deploy/pre-deploy.sh‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node ../docs-copy/flags-api-docs.js

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.