Skip to content

jstnm-versioning : init #238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@ docs/public/
# Typedoc generated files
modules/**/generated/

# ignore branch specific content files that are generated
branch_content

# PyCharm
.idea
3 changes: 3 additions & 0 deletions build-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"branches": ["10.5.0.cl"]
}
86 changes: 47 additions & 39 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ exports.createPages = async function ({ actions, graphql }) {
relativePath
}
}

}
}
}
Expand All @@ -39,58 +38,67 @@ exports.createPages = async function ({ actions, graphql }) {

const namePageIdMap = {};
data.allAsciidoc.edges.forEach((e) => {
const { sourceInstanceName: sourceName, relativePath : relPath } = e.node.parent;
const {
sourceInstanceName: sourceName,
relativePath: relPath,
} = e.node.parent;
const pageId = e.node.pageAttributes.pageid;
if (sourceName === 'tutorials'){
const relPathSplit = relPath.split('/');
const pageIdSplit = pageId.split('__');
let finalPageId = pageId;
if( pageIdSplit.length > 1) {
if (sourceName === 'tutorials') {
const relPathSplit = relPath.split('/');
const pageIdSplit = pageId.split('__');
let finalPageId = pageId;
if (pageIdSplit.length > 1) {
finalPageId = pageIdSplit[1];
}
let mapPageId = `tutorials/` + finalPageId;
if(relPathSplit.length > 1) {
mapPageId = `tutorials/${relPathSplit[0]}/` + finalPageId;
}
namePageIdMap[e.node.parent.name] =
mapPageId || NOT_FOUND_PAGE_ID;
}

else {
}
let mapPageId = `tutorials/${finalPageId}`;
if (relPathSplit.length > 1) {
mapPageId = `tutorials/${relPathSplit[0]}/${finalPageId}`;
}
namePageIdMap[e.node.parent.name] = mapPageId || NOT_FOUND_PAGE_ID;
} else {
namePageIdMap[e.node.parent.name] =
e.node.pageAttributes.pageid || NOT_FOUND_PAGE_ID;
}
});

data.allAsciidoc.edges.forEach((edge) => {
const { pageid: pageId } = edge.node.pageAttributes;
const { sourceInstanceName: sourceName, relativePath : relPath } = edge.node.parent;
const {
sourceInstanceName: sourceName,
relativePath: relPath,
} = edge.node.parent;

// Tutorials module pageids follow pattern {subdirectory}_{final_url_stub} to give unique IDs in system but allow directory structure in URL
if (sourceName === 'tutorials'){
// One-level of subdirectory part of stub
const relPathSplit = relPath.split('/');
const pageIdSplit = pageId.split('__');
let finalPageId = pageId;
if( pageIdSplit.length > 1) {
if (sourceName === 'tutorials') {
// One-level of subdirectory part of stub
const relPathSplit = relPath.split('/');
const pageIdSplit = pageId.split('__');
let finalPageId = pageId;
if (pageIdSplit.length > 1) {
finalPageId = pageIdSplit[1];
}
}

let finalPath = `/tutorials/${finalPageId}`;
if(relPathSplit.length > 1) {
finalPath = `/tutorials/${relPathSplit[0]}/${finalPageId}`;
}

actions.createPage({
path: finalPath,
component: require.resolve(
'./src/components/DevDocTemplate/index.tsx',
),
context: { pageId, navId: DOC_NAV_PAGE_ID, namePageIdMap },
});
}
let finalPath = `/tutorials/${finalPageId}`;
if (relPathSplit.length > 1) {
finalPath = `/tutorials/${relPathSplit[0]}/${finalPageId}`;
}

else {
actions.createPage({
path: finalPath,
component: require.resolve(
'./src/components/DevDocTemplate/index.tsx',
),
context: { pageId, navId: DOC_NAV_PAGE_ID, namePageIdMap },
});
} else if (relPath.startsWith('10.5')) {
actions.createPage({
path: `/10.5/${pageId}`,
component: require.resolve(
'./src/components/DevDocTemplate/index.tsx',
),
context: { pageId, navId: DOC_NAV_PAGE_ID, namePageIdMap },
});
} else {
actions.createPage({
path: `/${pageId}`,
component: require.resolve(
Expand Down
85 changes: 85 additions & 0 deletions scripts/pre-build/stage-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

# Color codes for better logging visibility
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
RESET='\033[0m'

# This script is executed before the build starts.

# Function to install packages with retry and logging
install_deps() {
local dependencies=("$@")

for dep in "${dependencies[@]}"; do
echo -e "${BLUE}Installing package: $dep...${RESET}"

# First try apt-get installation
if apt-get update && apt-get install -y "$dep"; then
echo -e "${GREEN}$dep installed successfully with apt-get.${RESET}"
else
echo -e "${RED}apt-get failed. Trying to install $dep with brew...${RESET}"

# Fallback to brew if apt-get fails
if command -v brew &> /dev/null; then
if brew install "$dep"; then
echo -e "${GREEN}$dep installed successfully with brew.${RESET}"
else
echo -e "${RED}Failed to install $dep with brew.${RESET}"
exit 1
fi
else
echo -e "${RED}brew is not installed. Failed to install $dep.${RESET}"
exit 1
fi
fi
done
}

# Main script execution
echo -e "${BLUE}Starting package installations...${RESET}"

# List of dependencies to install
dependencies=("jq")

install_deps "${dependencies[@]}" # Pass the list of dependencies to the function

# install jq if not already installed via install_deps
echo -e "${YELLOW}Installing jq...${RESET}"
apt-get update && apt-get install -y jq

# Get the current git branch
current_branch=$(git branch --show-current)

# 0. Get a list of branches as an array of strings from the config file
branches=($(jq -r '.branches[]' build-config.json))

# Clean the branch_content folder
echo -e "\n${YELLOW}Cleaning the branch_content folder...${RESET}"
mkdir -p branch_content
echo -e "${GREEN}Cleaning branch_content folder completed.${RESET}"

# 1. Copy the modules from other git branches
for branch in "${branches[@]}"
do
echo -e "\n${BLUE}Processing branch: $branch...${RESET}"
git fetch origin $branch
rm -rf modules/ROOT/pages
echo -e "${YELLOW}Copying modules from branch: $branch...${RESET}"
git checkout $branch -- modules/ROOT/pages
mkdir -p branch_content/$branch
cp -r modules/ROOT/pages/* branch_content/$branch
echo -e "${GREEN}Completed processing for branch: $branch.${RESET}"
git checkout $current_branch -- modules/ROOT/pages
# 3. Update the path variable in the ascidoc file (you can add the code for this here)
done

# 4. Copy the modules from branch_content to the modules folder
echo -e "\n${BLUE}Copying the modules from branch_content to modules folder...${RESET}"
cp -r branch_content modules/ROOT/pages
echo -e "${GREEN}Copying modules from branch_content to modules folder completed.${RESET}"


echo -e "${GREEN}Script execution completed.${RESET}"
Loading