Skip to content

Commit

Permalink
Merge branch 'lagoon-voyager' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
chindris committed Sep 21, 2024
2 parents 04b4a5e + a3cc765 commit 9391545
Show file tree
Hide file tree
Showing 18 changed files with 3,504 additions and 3,215 deletions.
6 changes: 5 additions & 1 deletion apps/cms/scaffold/settings.php.append.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ $config['silverback_external_preview.settings'] = [

$config['graphql.graphql_servers.main']['schema_configuration']['directable']['build_webhook'] = $publisherUrl . '/___status/build';
$config['graphql.graphql_servers.main']['schema_configuration']['directable']['update_webhook'] = $publisherUrl . '/___status/update';
$config['graphql.graphql_servers.main']['schema_configuration']['directable']['build_url'] = $netlifyUrl;
if (getenv('SB_ENVIRONMENT')) {
$config['graphql.graphql_servers.main']['schema_configuration']['directable']['build_url'] = $publisherUrl;
} else {
$config['graphql.graphql_servers.main']['schema_configuration']['directable']['build_url'] = $netlifyUrl;
}

$settings['silverback_graphql_persisted_map'] = '../node_modules/@custom/schema/build/operations.json';

Expand Down
24 changes: 24 additions & 0 deletions apps/voyager/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
28 changes: 28 additions & 0 deletions apps/voyager/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from '@eslint/js';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
);
12 changes: 12 additions & 0 deletions apps/voyager/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voyager</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions apps/voyager/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@custom/voyager",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"test:static": "tsc --noEmit && eslint \"**/*.{ts,tsx,js,jsx}\" --ignore-path=\"./.gitignore\"",
"dev": "vite",
"build": "tsc -b && vite build",
"prep": "vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@custom/schema": "workspace:^",
"graphql": "16.8.1",
"graphql-voyager": "^2.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"eslint": "^9.9.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.9.0",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.1",
"vite": "^5.4.1"
}
}
18 changes: 18 additions & 0 deletions apps/voyager/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'graphql-voyager/dist/voyager.css';

import { buildSchema } from 'graphql';
import { Voyager } from 'graphql-voyager';

import sdlString from '../node_modules/@custom/schema/build/schema.graphql?raw';

const schema = buildSchema(sdlString);

function App() {
return (
<>
<Voyager introspection={schema} />
</>
);
}

export default App;
68 changes: 68 additions & 0 deletions apps/voyager/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
12 changes: 12 additions & 0 deletions apps/voyager/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import './index.css';

import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

import App from './App.tsx';

createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
);
1 change: 1 addition & 0 deletions apps/voyager/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
24 changes: 24 additions & 0 deletions apps/voyager/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
7 changes: 7 additions & 0 deletions apps/voyager/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
22 changes: 22 additions & 0 deletions apps/voyager/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts"]
}
10 changes: 10 additions & 0 deletions apps/voyager/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
build: {
assetsDir: '__voyager_assets',
},
});
4 changes: 4 additions & 0 deletions apps/website/.lagoon.env
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ PUBLISHER_OAUTH2_ENVIRONMENT_TYPE=development
# DRUPAL_EXTERNAL_URL is used by default, but can be overridden
# to match the Drupal production url, without the nginx prefix.
PUBLISHER_OAUTH2_TOKEN_HOST="${DRUPAL_EXTERNAL_URL}"

# We want voyager app to be available on all instances, excepting PROD (for that
# this env var should be set to false in lagoon.env.prod)
VOYAGER_ENABLE=true
3 changes: 3 additions & 0 deletions apps/website/.lagoon.env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ PUBLISHER_OAUTH2_ENVIRONMENT_TYPE=production
# DRUPAL_EXTERNAL_URL is used by default, but can be overridden
# to match the Drupal production url, without the nginx prefix.
PUBLISHER_OAUTH2_TOKEN_HOST="${DRUPAL_EXTERNAL_URL}"

# We do not want the voyager app on production.
VOYAGER_ENABLE=false
13 changes: 13 additions & 0 deletions apps/website/gatsby-config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ const plugins = [
'node_modules/@custom/ui/build/styles.css': '/styles.css',
'node_modules/@custom/ui/build/iframe.css': '/iframe.css',
'node_modules/@custom/ui/static/public': '/',
// The assets in the generated index.html are loaded from a path
// relative to the base url, so we need to exract the assets into the
// root folder of gatsby as well, otherwise they won't be loaded.
// If we do not do that, then the assets will exist in
// /__voyager/__voyager_assets but the index.html loads them from
// "/__voyager_assets".
...(process.env.VOYAGER_ENABLE === 'true'
? {
'node_modules/@custom/voyager/dist/__voyager_assets':
'/__voyager_assets',
'node_modules/@custom/voyager/dist': '/__voyager',
}
: {}),
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
"@amazeelabs/gatsby-plugin-operations": "^1.1.3",
"@amazeelabs/gatsby-plugin-static-dirs": "^1.0.1",
"@amazeelabs/gatsby-source-silverback": "^1.14.0",
"@amazeelabs/publisher": "^2.4.35",
"@amazeelabs/publisher": "^2.4.36",
"@amazeelabs/strangler-netlify": "^1.1.9",
"@amazeelabs/token-auth-middleware": "^1.1.1",
"@custom/cms": "workspace:*",
"@custom/decap": "workspace:*",
"@custom/schema": "workspace:*",
"@custom/ui": "workspace:*",
"@custom/voyager": "workspace:*",
"gatsby": "^5.13.1",
"gatsby-plugin-layout": "^4.13.0",
"gatsby-plugin-manifest": "^5.13.0",
Expand Down
Loading

0 comments on commit 9391545

Please sign in to comment.