diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml deleted file mode 100644 index 2d558d6..0000000 --- a/.github/workflows/deploy.yaml +++ /dev/null @@ -1,45 +0,0 @@ -# ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– -# # `deploy.yaml` -# client | Semantyk -# -# Created: Nov 29, 2023 -# Modified: Nov 29, 2023 -# -# Author(s): Semantyk Team -# Maintainer(s): Daniel Bakas -# -# Copyright © Semantyk 2023. All rights reserved. -# ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– - -name: Deploy to Google App Engine - -on: - push: - branches: - - main - - staging - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - # 1. Checkout the Repository - - uses: actions/checkout@v4 - name: Repository Checkout - # 2. Setup Google Cloud SDK - - uses: google-github-actions/setup-gcloud@v1 - name: Cloud SDK Configuration - # 3. Authenticate with Google Cloud - - uses: google-github-actions/auth@v2 - name: GCP Authentication - with: - credentials_json: ${{secrets.GCP_CREDENTIALS}} - # 4. Deploy to Google App Engine - # Deployment to 'main' service - - if: github.ref == 'refs/heads/main' - name: Deploy to Main Service - run: gcloud app deploy app.yaml --project ${{secrets.GCP_PROJECT_ID}} --promote - # Deployment to 'staging' service - - if: github.ref == 'refs/heads/staging' - name: Deploy to Staging Service - run: gcloud app deploy app.yaml --project ${{secrets.GCP_PROJECT_ID}} --no-promote \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/dev.yaml similarity index 65% rename from .github/workflows/test.yaml rename to .github/workflows/dev.yaml index 4979a7f..b33b0a3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/dev.yaml @@ -1,9 +1,9 @@ # ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– -# # `test.yaml` +# # `dev.yaml` # client | Semantyk # # Created: Nov 29, 2023 -# Modified: Nov 29, 2023 +# Modified: Dec 5, 2023 # # Author(s): Semantyk Team # Maintainer(s): Daniel Bakas @@ -11,7 +11,7 @@ # Copyright © Semantyk 2023. All rights reserved. # ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– -name: Build and Test +name: Development CI Workflow on: push: @@ -22,8 +22,35 @@ on: - dev jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [ 20.x ] + steps: + # 1. Checkout the Repository + - uses: actions/checkout@v4 + name: 1. Repository Checkout + # 2. Setup pnpm + - uses: pnpm/action-setup@v2 + name: 2. Setup pnpm + with: + version: 8 + # 3. Setup Node.js + - uses: actions/setup-node@v4 + name: 3. Setup Node.js (v${{ matrix.node-version }}) + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + # 4. Install Dependencies + - run: pnpm install + name: 4. Install Dependencies + # 5. Run Tests + - run: pnpm test + name: 5. Run Tests build: runs-on: ubuntu-latest + needs: test strategy: matrix: node-version: [ 20.x ] @@ -47,7 +74,4 @@ jobs: name: 4. Install Dependencies # 5. Build - run: pnpm run build - name: 5. Build - # 6. Test - - run: pnpm test - name: 6. Test \ No newline at end of file + name: 5. Build \ No newline at end of file diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml new file mode 100644 index 0000000..e1b02a6 --- /dev/null +++ b/.github/workflows/staging.yaml @@ -0,0 +1,101 @@ +# ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– +# # `staging.yaml` +# client | Semantyk +# +# Created: Nov 29, 2023 +# Modified: Dec 5, 2023 +# +# Author(s): Semantyk Team +# Maintainer(s): Daniel Bakas +# +# Copyright © Semantyk 2023. All rights reserved. +# ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– + +name: Staging CI Workflow + +on: + push: + branches: + - staging + pull_request: + branches: + - staging + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [ 20.x ] + steps: + # 1. Checkout the Repository + - uses: actions/checkout@v4 + name: 1. Repository Checkout + # 2. Setup pnpm + - uses: pnpm/action-setup@v2 + name: 2. Setup pnpm + with: + version: 8 + # 3. Setup Node.js + - uses: actions/setup-node@v4 + name: 3. Setup Node.js (v${{ matrix.node-version }}) + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + # 4. Install Dependencies + - run: pnpm install + name: 4. Install Dependencies + # 5. Run Tests + - run: pnpm test + name: 5. Run Tests + build: + runs-on: ubuntu-latest + needs: test + strategy: + matrix: + node-version: [ 20.x ] + steps: + # 1. Checkout the Repository + - uses: actions/checkout@v4 + name: 1. Repository Checkout + # 2. Setup pnpm + - uses: pnpm/action-setup@v2 + name: 2. Setup pnpm + with: + version: 8 + # 3. Setup Node.js + - uses: actions/setup-node@v4 + name: 3. Setup Node.js (v${{ matrix.node-version }}) + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + # 4. Install Dependencies + - run: pnpm install + name: 4. Install Dependencies + # 5. Build + - run: pnpm run build + name: 5. Build + deploy: + runs-on: ubuntu-latest + needs: build + steps: + # 1. Repository Checkout + - uses: actions/checkout@v4 + name: 1. Repository Checkout + # 2. Cloud SDK Configuration + - uses: google-github-actions/setup-gcloud@v1 + name: 2. Cloud SDK Configuration + # 3. Google Cloud Authentication + - uses: google-github-actions/auth@v2 + name: 3. Google Cloud Authentication + with: + credentials_json: ${{secrets.GCP_CREDENTIALS}} + # 4. Deploy to Google App Engine + # - Deployment to 'main' Service + - if: github.ref == 'refs/heads/main' + name: 4. Deployment to 'main' Service + run: gcloud app deploy app.yaml --project ${{secrets.GCP_PROJECT_ID}} --promote + # - Deployment to 'staging' service + - if: github.ref == 'refs/heads/staging' + name: 4. Deploy to Staging Service + run: gcloud app deploy app.yaml --project ${{secrets.GCP_PROJECT_ID}} --no-promote \ No newline at end of file diff --git a/Dockerfile.dev b/Dockerfile.dev index f71b056..b996cf0 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -19,7 +19,7 @@ RUN npm install -g pnpm # Set the working directory WORKDIR /app # Copy package.json and other related files -COPY package.json ./ +COPY package.json pnpm-lock.yaml ./ # Install dependencies RUN pnpm install # Copy the rest of your app's source code diff --git a/app/components/atoms/authButton.jsx b/app/_components/atoms/authButton.jsx similarity index 100% rename from app/components/atoms/authButton.jsx rename to app/_components/atoms/authButton.jsx diff --git a/app/components/atoms/loginButton.jsx b/app/_components/atoms/loginButton.jsx similarity index 95% rename from app/components/atoms/loginButton.jsx rename to app/_components/atoms/loginButton.jsx index ababb29..86c1097 100644 --- a/app/components/atoms/loginButton.jsx +++ b/app/_components/atoms/loginButton.jsx @@ -20,7 +20,7 @@ import React, { useEffect, useState } from "react"; import { LoginButton as SolidLoginButton } from "@inrupt/solid-ui-react"; import { Button } from "react-bootstrap"; //* Local imports -import { getOptions } from "../../logic/auth/service"; +import { getOptions } from "../../_logic/auth/service"; //* Main diff --git a/app/components/atoms/logoutButton.jsx b/app/_components/atoms/logoutButton.jsx similarity index 79% rename from app/components/atoms/logoutButton.jsx rename to app/_components/atoms/logoutButton.jsx index 5bed2c3..562339a 100644 --- a/app/components/atoms/logoutButton.jsx +++ b/app/_components/atoms/logoutButton.jsx @@ -17,13 +17,21 @@ //* Imports import React from "react"; -import { LogoutButton as SolidLogoutButton } from "@inrupt/solid-ui-react"; +import { + LogoutButton as SolidLogoutButton, + useSession +} from "@inrupt/solid-ui-react"; import { Button } from "react-bootstrap"; //* Main export default function LogoutButton() { + // Hooks + const { session } = useSession(); + // Logic + const { webId } = session.info; // Return return (<> +

WebID: {webId}

diff --git a/app/components/molecules/footer/component.jsx b/app/_components/molecules/footer/component.jsx similarity index 96% rename from app/components/molecules/footer/component.jsx rename to app/_components/molecules/footer/component.jsx index ccbd434..cbdcfce 100644 --- a/app/components/molecules/footer/component.jsx +++ b/app/_components/molecules/footer/component.jsx @@ -18,7 +18,7 @@ //* Imports import Link from "next/link"; //* Local Imports -import useData from "../../../logic/data/hook"; +import useData from "../../../_logic/data/hook"; import FooterLayout from "./layout"; diff --git a/app/components/molecules/footer/layout.jsx b/app/_components/molecules/footer/layout.jsx similarity index 100% rename from app/components/molecules/footer/layout.jsx rename to app/_components/molecules/footer/layout.jsx diff --git a/app/logic/auth/service.js b/app/_logic/auth/service.js similarity index 71% rename from app/logic/auth/service.js rename to app/_logic/auth/service.js index 1ba5d11..a7dd861 100644 --- a/app/logic/auth/service.js +++ b/app/_logic/auth/service.js @@ -14,12 +14,17 @@ */ //* Imports -import { CLIENT_ID, POD_URI } from "../../services/app/nodes"; +import { CLIENT_ID, POD_PROVIDER_URI } from "../../_services/app/nodes"; export async function getOptions() { + // Logic + const clientId = CLIENT_ID.value; + const oidcIssuer = POD_PROVIDER_URI.value; + const redirectUrl = window.location.href; + // Return return { - authOptions: { clientId: CLIENT_ID }, - oidcIssuer: POD_URI, - redirectUrl: window.location.href + authOptions: { clientId }, + oidcIssuer, + redirectUrl }; } \ No newline at end of file diff --git a/app/logic/data/hook.js b/app/_logic/data/hook.js similarity index 100% rename from app/logic/data/hook.js rename to app/_logic/data/hook.js diff --git a/app/logic/data/service.js b/app/_logic/data/service.js similarity index 77% rename from app/logic/data/service.js rename to app/_logic/data/service.js index abfd5fd..2be1a68 100644 --- a/app/logic/data/service.js +++ b/app/_logic/data/service.js @@ -16,15 +16,17 @@ //* Imports //* Local Imports -import { APP_WEBID, APP_WEBID_DOC } from "../../services/app/nodes"; -import { getProperties, getThing } from "../../services/solid/service"; -import { appShape } from "../../services/app/shape"; +import { APP_WEBID, APP_WEBID_DOC } from "../../_services/app/nodes"; +import { getProperties, getThing } from "../../_services/solid/service"; +import { appShape } from "../../_services/app/shape"; //* Main export async function getData(fetch) { // Logic - const thing = await getThing(fetch, APP_WEBID_DOC, APP_WEBID); + const document = APP_WEBID_DOC.value; + const uri = APP_WEBID.value; + const thing = await getThing(fetch, document, uri); const lang = "en"; const properties = getProperties(thing, appShape, lang); // Props diff --git a/app/logic/metadata/service.js b/app/_logic/metadata/service.js similarity index 97% rename from app/logic/metadata/service.js rename to app/_logic/metadata/service.js index 20f7193..f66e5df 100644 --- a/app/logic/metadata/service.js +++ b/app/_logic/metadata/service.js @@ -34,7 +34,7 @@ export async function getMetadata() { } }, applicationName: app.name, - authors: [{ name: app.author, url: app.webId }], + authors: [{ name: app.author }], category: "technology", creator: app.creator, description: `${app.slogan} | ${app.description}`, diff --git a/app/logic/state/manager.jsx b/app/_logic/state/manager.jsx similarity index 78% rename from app/logic/state/manager.jsx rename to app/_logic/state/manager.jsx index 2a78257..5e099e6 100644 --- a/app/logic/state/manager.jsx +++ b/app/_logic/state/manager.jsx @@ -17,12 +17,16 @@ //* Imports import React from "react"; -import { SessionProvider } from "@inrupt/solid-ui-react"; +import { SessionProvider, useSession } from "@inrupt/solid-ui-react"; function StateManager({ children }) { + // Hooks + const { session } = useSession(); + // Logic + const { sessionId } = session.info; // Return return ( - + {children} ); diff --git a/app/services/app/namespaces.js b/app/_services/app/namespaces.js similarity index 100% rename from app/services/app/namespaces.js rename to app/_services/app/namespaces.js diff --git a/app/services/app/nodes.js b/app/_services/app/nodes.js similarity index 92% rename from app/services/app/nodes.js rename to app/_services/app/nodes.js index 8bd5b2a..05c3dbf 100644 --- a/app/services/app/nodes.js +++ b/app/_services/app/nodes.js @@ -20,4 +20,4 @@ import { NamedNode } from "rdflib"; export const APP_WEBID = NamedNode.fromValue("https://id.inrupt.com/semantyk"); export const APP_WEBID_DOC = NamedNode.fromValue("https://storage.inrupt.com/93eee8ab-4002-4bbf-a457-38eab9979cc8/public/profile/card"); export const CLIENT_ID = NamedNode.fromValue("https://id.www.semantyk.com"); -export const POD_URI = NamedNode.fromValue("https://id.inrupt.com/semantyk"); \ No newline at end of file +export const POD_PROVIDER_URI = NamedNode.fromValue("https://pod.danielbakas.com"); \ No newline at end of file diff --git a/app/services/app/shape.js b/app/_services/app/shape.js similarity index 100% rename from app/services/app/shape.js rename to app/_services/app/shape.js diff --git a/app/services/solid/namespaces.js b/app/_services/solid/namespaces.js similarity index 100% rename from app/services/solid/namespaces.js rename to app/_services/solid/namespaces.js diff --git a/app/services/solid/service.js b/app/_services/solid/service.js similarity index 97% rename from app/services/solid/service.js rename to app/_services/solid/service.js index a4212ba..852ae1e 100644 --- a/app/services/solid/service.js +++ b/app/_services/solid/service.js @@ -4,7 +4,7 @@ * client | Semantyk * * Created: Dec 05, 2023 - * Modified: Dec 05, 2023 + * Modified: Dec 06, 2023 * * Author(s): Semantyk Team * Maintainer(s): @@ -53,7 +53,7 @@ export const getProperty = (thing, type, property, locale) => { export const getProperties = (thing, shape, locale) => { let properties = {}; for (const { ns, fragment, type } of shape) { - const property = ns(fragment); + const property = ns(fragment).value; properties[fragment] = getProperty(thing, type, property, locale); } return properties; diff --git a/app/layout.jsx b/app/layout.jsx index b1a1941..6ba8327 100644 --- a/app/layout.jsx +++ b/app/layout.jsx @@ -17,7 +17,8 @@ import "bootstrap/dist/css/bootstrap.min.css"; import React from "react"; //* Local Imports -import { getMetadata } from "./logic/metadata/service"; +import { getMetadata } from "./_logic/metadata/service"; +import StateManager from "./_logic/state/manager"; //* Main @@ -28,7 +29,9 @@ export default function RootLayout({ children }) { return ( - {children} + + {children} + ); diff --git a/app/layout.test.jsx b/app/layout.test.jsx index db751f0..8759433 100644 --- a/app/layout.test.jsx +++ b/app/layout.test.jsx @@ -24,11 +24,12 @@ import RootLayout from "./layout"; // Mocking Solid UI React's SessionProvider vi.mock("@inrupt/solid-ui-react", () => ({ ...vi.importActual("@inrupt/solid-ui-react"), - SessionProvider: ({ children }) => <>{children} + SessionProvider: ({ children }) => <>{children}, + useSession: () => ({ session: { info: { webId: "https://id.example.com" } } }) })); // Mocking the getMetadata function -vi.mock("./logic/metadata/service", () => ({ +vi.mock("./_logic/metadata/service", () => ({ getMetadata: vi.fn().mockResolvedValue({ /* mock metadata object */ }) })); diff --git a/app/not-found.jsx b/app/not-found.jsx new file mode 100644 index 0000000..f1ae4db --- /dev/null +++ b/app/not-found.jsx @@ -0,0 +1,27 @@ +/* + * ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– + * # `not-found.jsx` + * client | Semantyk + * + * Created: Dec 06, 2023 + * Modified: Dec 06, 2023 + * + * Author(s): Semantyk Team + * Maintainer(s): + * + * Copyright © Semantyk 2023. All rights reserved. + * ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– + */ + +//* Imports +import Page from "./page"; + +//* Main +export default function NotFound() { + return ( + +

404 - Not Found

+

Could not find requested resource

+
+ ); +} \ No newline at end of file diff --git a/app/page.jsx b/app/page.jsx index 252d546..8917cc8 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -4,7 +4,7 @@ * client | Semantyk * * Created: Nov 30, 2023 - * Modified: Dic 5, 2023 + * Modified: Dic 6, 2023 * * Author(s): Semantyk Team * Maintainer(s): Daniel Bakas @@ -17,18 +17,18 @@ import React from "react"; //* Local Imports import "./page.css"; -import Footer from "./components/molecules/footer/component"; -import StateManager from "./logic/state/manager"; +import Footer from "./_components/molecules/footer/component"; +import AuthButton from "./_components/atoms/authButton"; //* Main -export default function Page() { +export default function Page({ children }) { // Return return ( - -
-
-
-
+
+ {children} + +
); } \ No newline at end of file