Skip to content

Commit

Permalink
chore: update jaen version
Browse files Browse the repository at this point in the history
  • Loading branch information
kleberbaum committed Apr 24, 2024
1 parent afa7f3a commit 9263c13
Show file tree
Hide file tree
Showing 333 changed files with 60,788 additions and 6,208 deletions.
Binary file renamed src/.DS_Store → .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion .env.public
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
GATSBY_SQ_DEBUG=true
GATSBY_LENS_API_URL=https://api.lens.walther.exp.univie.ac.at:8080/graphql
GATSBY_ORIGIN_API_URL=https://services.photonq.org/graphql
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ permissions:
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
branches: ['main', 'dev']
# Allows you to run this workflow from another workflow
workflow_call:
# Allows you to run this workflow manually from the Actions tab
Expand All @@ -29,7 +29,7 @@ jobs:
uses: atsnek/jaen/.github/workflows/jaen-deploy.yaml@main
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow
with:
CLOUDFLARE_PROJECT_NAME: 'fhkit'
CLOUDFLARE_PROJECT_NAME: 'netsnek'
secrets:
GATSBY_MYSHOPIFY_URL: ${{ secrets.GATSBY_MYSHOPIFY_URL }}
GATSBY_STOREFRONT_API_KEY: ${{ secrets.GATSBY_STOREFRONT_API_KEY }}
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/jaen-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Workflow that receives a migrationUrl via a dispatch event

name: Publish

# https://help.github.com/en/articles/workflow-syntax-for-github-actions#on
on:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
repository_dispatch:
types: [UPDATE_JAEN_RESOURCE]

jobs:
migrate:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: ubuntu-latest
defaults:
run:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#
working-directory: ${{github.event.client_payload.cwd}}

steps:
# https://github.com/actions/checkout
- name: Checkout 🛎️
uses: actions/checkout@v3
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepswith
with:
# Relative path under $GITHUB_WORKSPACE to place the repository
path: '.'

# https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsid
- name: Configure GitHub Authentication 🔧
# https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsrun
run: |
# Git: set identity
git config user.name "snekmin"
git config user.email "[email protected]"
# Git: set remote
# https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#http-based-git-access-by-an-installation
git remote set-url origin "https://x-access-token:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git"
- name: Migrate Jaen Data 📝
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#
working-directory: ${{github.event.client_payload.cwd}}
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsif
if: ${{github.event.client_payload.migrationURL}}
# https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsrun
run: |
# Create gh-pages branch without history
#git checkout --orphan gh-pages
git checkout main
echo "${{github.event.client_payload.migrationURL}}" >> ./jaen-data/patches.txt
# Git: add, commit, and push changes
git add .
git commit -m "jaen-publish: migrate jaen-data" || echo "Nothing to commit, working tree clean."
GIT_TRACE=1 git push -f --verbose origin main
build:
needs: migrate
uses: ./.github/workflows/deploy.yaml
secrets: inherit
46 changes: 46 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: publish

on: [push]
env:
IMAGE_NAME: photonq-gatsby

jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
publish-container:
runs-on: ubuntu-latest
environment: photonq-internal
env:
GATSBY_ORIGIN_API_URL: ${{ vars.GATSBY_ORIGIN_API_URL }}
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
# SPDX-License-Identifier: (EUPL-1.2)
# Copyright © 2019-2022 snek.at
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ node_modules

**/dist

**/tsconfig.tsbuildinfo
**/tsconfig.tsbuildinfo
src/.DS_Store

.vscode/tasks.json
10 changes: 6 additions & 4 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"bracketSpacing": true,
"arrowParens": "avoid",
"bracketSameLine": true,
"jsxBracketSameLine": true
"jsxBracketSameLine": false,
"importOrder": ["^@(.*)$", "^[./]"],
"importOrderSeparation": true,
"experimentalBabelParserPluginsList": ["jsx", "typescript"]
}
9 changes: 3 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"editor.codeActionsOnSave": {
// For ESLint
"source.fixAll.eslint": true,
// For TSLint
"source.fixAll.tslint": true,
// For Stylelint
"source.fixAll.stylelint": true
"source.fixAll.eslint": "explicit",
"source.fixAll.tslint": "explicit",
"source.fixAll.stylelint": "explicit"
}
}
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Use a specific version of Node as the base image
FROM node:18-bullseye-slim

# Set the working directory in the container
WORKDIR /app

# Copy package.json and yarn.lock first to leverage Docker caching for dependencies
COPY package.json yarn.lock ./

# Install dependencies only if package.json or yarn.lock changes
RUN yarn install --frozen-lockfile

# Copy the rest of the application code (e)
COPY . .

# Build the application
RUN yarn build

# Expose the port that the app will run on
EXPOSE 9000

# Set the entry point for the container
ENTRYPOINT ["yarn", "gatsby", "serve", "-H", "0.0.0.0"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# jaen-template
# jaen-template
1 change: 1 addition & 0 deletions gatsby-browser.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './src/styles/global.css';
46 changes: 40 additions & 6 deletions gatsby-config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,56 @@
import type {GatsbyConfig} from 'gatsby'
import type { GatsbyConfig } from 'gatsby';

require('dotenv').config({
path: `.env.public`
});

const config: GatsbyConfig = {
siteMetadata: {
siteUrl: `https://www.yourdomain.tld`
},
// More easily incorporate content into your pages through automatic TypeScript type generation and better GraphQL IntelliSense.
// If you use VSCode you can also use the GraphQL plugin
// Learn more at: https://gatsby.dev/graphql-typegen
graphqlTypegen: true,
flags: {
DEV_SSR: true
DEV_SSR: false
},
jsxRuntime: 'automatic',
plugins: [
`gatsby-plugin-cloudflare-pages`,
{
resolve: `gatsby-plugin-jaen`,
options: {
snekResourceId: `0ee5d9f5-7580-4787-855f-4fc8bd89d3bf`
pylonUrl: 'https://pylons.photonq.org/jaen-agent/graphql',
remote: {
repository: 'netsnek/fhkit.at'
},
zitadel: {
organizationId: '263581005107959413',
clientId: '263491440007517793@services',
authority: 'https://accounts.photonq.org',
redirectUri:
process.env.NODE_ENV === 'production'
? 'https://fhkit.com'
: 'https://opulent-carnival-pg7v6wp7prhr556-8000.app.github.dev',
projectIds: ['263491274097563233']
},
// sentry: {
// org: 'photonq',
// project: 'website',
// dsn: 'https://[email protected]/10'
// },
googleAnalytics: {
trackingIds: ['G-M58K75M9PG']
}
}
},
{
resolve: `gatsby-jaen-mailpress`,
options: {
pylonUrl: 'https://pylons.photonq.org/mailpress/graphql'
}
}
]
}
};

export default config
export default config;
114 changes: 114 additions & 0 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import { PageConfig } from '@atsnek/jaen';
import { GatsbyNode } from 'gatsby';
import path from 'path';
import fs from 'fs';
import { buildSearchIndex } from './src/utils/search/build-search-index';

export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = ({
actions
}) => {
actions.setWebpackConfig({
resolve: {
alias: {
'@/clients': path.resolve(__dirname, 'src/clients')
}
}
});
};

export const onPostBuild: GatsbyNode['onPostBuild'] = async ({
graphql,
reporter
}) => {
const result = await graphql<{
allJaenPage: {
nodes: Array<{
id: string;
slug: string;
parentPage: {
id: string;
} | null;
template: string | null;
jaenPageMetadata: {
title: string;
};
jaenFields: Record<string, any> | null;
pageConfig: PageConfig | null;
buildPath: string;
}>;
};
}>(`
query {
allJaenPage {
nodes {
id
slug
parentPage {
id
}
template
jaenPageMetadata {
title
}
jaenFields
pageConfig
buildPath
}
}
}
`);

if (result.errors || !result.data) {
reporter.panicOnBuild(
`Error while running GraphQL query. ${result.errors}`
);

return;
}

const { allJaenPage } = result.data;

await preparePagesAndBuildSearch(allJaenPage);
};

async function preparePagesAndBuildSearch(allJaenPage: {
nodes: Array<{
id: string;
slug: string;
parentPage: {
id: string;
} | null;
template: string | null;
jaenPageMetadata: {
title: string;
};
jaenFields: Record<string, any> | null;
pageConfig: PageConfig | null;
buildPath: string;
}>;
}) {
const nodesForSearchIndex = allJaenPage.nodes.map(node => {
const originPath = node.buildPath;

let type = node.template;

if (type && path.extname(type)) {
type = path.basename(type, path.extname(type));
}

return {
id: node.id,
path: originPath,
jaenPageMetadata: node.jaenPageMetadata,
jaenFields: node.jaenFields,
type
};
});

const searchIndex = await buildSearchIndex(nodesForSearchIndex as any);

await fs.promises.writeFile(
path.join('public', 'search-index.json'),
JSON.stringify(searchIndex)
);
}
1 change: 1 addition & 0 deletions gatsby-ssr.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './src/styles/global.css';
Loading

0 comments on commit 9263c13

Please sign in to comment.