Skip to content
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

SLB-201: remove copy operations and streamline artefacts #129

Merged
merged 15 commits into from
Jan 24, 2024
Merged
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
4 changes: 4 additions & 0 deletions apps/cms/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ generated/translations.json
# GraphQL autoload registry
autoload.json

# Stylesheet symlinks into the ui package
!/web/gutenberg.css
!/web/iframe.css

# A workaround to avoid turbo caching locally.
turbo-seed.txt
4 changes: 2 additions & 2 deletions apps/cms/config/sync/graphql.graphql_servers.main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
uuid: f31854e4-2c2b-4687-9553-9f2d1f87028c
langcode: en
status: true
dependencies: { }
dependencies: {}
name: main
label: Main
endpoint: /graphql
Expand All @@ -15,7 +15,7 @@ query_complexity: null
schema_configuration:
directable:
schema_definition: ../node_modules/@custom/schema/build/schema.graphql
autoload_registry: ../autoload.json
autoload_registry: ../node_modules/@custom/schema/build/drupal-autoload.json
extensions:
silverback_campaign_urls: silverback_campaign_urls
silverback_gatsby: silverback_gatsby
Expand Down
3 changes: 2 additions & 1 deletion apps/cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@custom/custom_heavy": "workspace:*",
"@custom/gutenberg_blocks": "workspace:*",
"@custom/schema": "workspace:*",
"@custom/test_content": "workspace:*"
"@custom/test_content": "workspace:*",
"@custom/ui": "workspace:*"
}
}
1 change: 1 addition & 0 deletions apps/cms/web/gutenberg.css
1 change: 1 addition & 0 deletions apps/cms/web/iframe.css
2 changes: 0 additions & 2 deletions apps/website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@
public
styles.css
persisted-store

autoload.mjs
2 changes: 1 addition & 1 deletion apps/website/gatsby-browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import './styles.css';
import '@custom/ui/styles.css';

import { registerExecutor } from '@custom/schema';
import { GatsbyBrowser } from 'gatsby';
Expand Down
15 changes: 13 additions & 2 deletions apps/website/gatsby-config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
// pick it up instead of the JS file.

import { getPages } from '@custom/decap';
import autoload from '@custom/schema/gatsby-autoload';
import { resolve } from 'path';

import autoload from './autoload.mjs';

const dir = resolve('node_modules/@custom/decap/data/page');

process.env.GATSBY_DRUPAL_URL =
Expand Down Expand Up @@ -39,9 +38,21 @@ export default {
siteUrl: process.env.NETLIFY_URL,
},
plugins: [
'gatsby-plugin-uninline-styles',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plugin does the same thing you did in the beginning? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the filename already contains the hash. I see.

'gatsby-plugin-pnpm',
'gatsby-plugin-layout',
'gatsby-plugin-sharp',
{
resolve: '@amazeelabs/gatsby-plugin-static-dirs',
options: {
directories: {
'node_modules/@custom/ui/build/styles.css': '/styles.css',
'node_modules/@custom/ui/static/public': '/',
'node_modules/@custom/decap/dist': '/admin',
'node_modules/@custom/decap/media': '/media',
},
},
},
{
resolve: '@amazeelabs/gatsby-plugin-operations',
options: {
Expand Down
28 changes: 1 addition & 27 deletions apps/website/gatsby-node.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { graphqlQuery } from '@amazeelabs/gatsby-plugin-operations';
import { IndexPagesQuery, ListPagesQuery, Locale } from '@custom/schema';
import { cpSync } from 'fs';
import { resolve } from 'path';
import serve from 'serve-static';

/**
* @type {import('gatsby').GatsbyNode['onCreateWebpackConfig']}
Expand Down Expand Up @@ -160,28 +158,4 @@ export const createPages = async ({ actions }) => {
/**
* @type Record<string, string>
*/
const staticDirectories = {
'node_modules/@custom/ui/static/public': '/',
'node_modules/@custom/decap/dist': '/admin',
'node_modules/@custom/decap/media': '/media',
};

/**
* @type {import('gatsby').GatsbyNode['onPostBuild']}
*/
export const onPostBuild = () => {
Object.keys(staticDirectories).forEach((src) => {
const dest = staticDirectories[src];
cpSync(src, `public${dest}`, { force: true, recursive: true });
});
};

/**
* @type {import('gatsby').GatsbyNode['onCreateDevServer']}
*/
export const onCreateDevServer = ({ app }) => {
Object.keys(staticDirectories).forEach((src) => {
const dest = staticDirectories[src];
app.use(dest, serve(src));
});
};
const staticDirectories = {};
2 changes: 0 additions & 2 deletions apps/website/gatsby-ssr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './styles.css';

import { Locale, registerExecutor } from '@custom/schema';
import { GatsbySSR } from 'gatsby';

Expand Down
8 changes: 3 additions & 5 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@amazeelabs/bridge-gatsby": "^1.2.7",
"@amazeelabs/cloudinary-responsive-image": "^1.6.15",
"@amazeelabs/gatsby-plugin-operations": "^1.1.3",
"@amazeelabs/gatsby-silverback-cloudinary": "^1.2.7",
"@amazeelabs/gatsby-plugin-static-dirs": "^1.0.1",
"@amazeelabs/gatsby-source-silverback": "^1.13.10",
"@amazeelabs/publisher": "^2.4.17",
"@amazeelabs/strangler-netlify": "^1.1.9",
Expand All @@ -20,13 +20,13 @@
"gatsby-plugin-robots-txt": "^1.8.0",
"gatsby-plugin-sharp": "^5.13.0",
"gatsby-plugin-sitemap": "^6.13.0",
"gatsby-plugin-uninline-styles": "^0.2.0",
"gatsby-source-filesystem": "^5.13.0",
"image-size": "^1.1.1",
"mime-types": "^2.1.35",
"netlify-cli": "^17.11.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"serve-static": "^1.15.0"
"react-dom": "^18.2.0"
},
"devDependencies": {
"@testing-library/react": "^14.1.2",
Expand All @@ -39,8 +39,6 @@
},
"scripts": {
"test:static": "tsc --noEmit && eslint '**/*.{ts,tsx,js,jsx}' --ignore-path='./.gitignore'",
"prep": "pnpm run prep:styles",
"prep:styles": "rm -f styles.css && cp node_modules/@custom/ui/build/styles.css styles.css",
"build:gatsby": "pnpm build:dotenv && gatsby build",
"build:dotenv": "rm -rf .env && echo \"DRUPAL_EXTERNAL_URL='$DRUPAL_EXTERNAL_URL'\nDRUPAL_INTERNAL_URL='$DRUPAL_INTERNAL_URL'\" >> .env",
"rebuild": "gatsby build",
Expand Down
1 change: 0 additions & 1 deletion packages/drupal-themes/custom_iframe/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
global:
css:
theme:
styles.css: { preprocess: false }
/iframe.css: { preprocess: false }
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
edit:
version: VERSION
js:
js/gutenberg_blocks.umd.js: { }
js/gutenberg_blocks.umd.js: {}
css:
theme:
css/edit.css: { }
css/edit.css: {}
dependencies:
- gutenberg/edit-node
- silverback_gutenberg/base
customisations:
css:
theme:
css/ui.css: { preprocess: false }
/gutenberg.css: { preprocess: false }
dependencies:
- core/drupalSettings
- core/drupalSettings

2 changes: 1 addition & 1 deletion packages/schema/.graphqlrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://unpkg.com/[email protected]/config-schema.json",
"schema": [
"../../apps/website/node_modules/@amazeelabs/*/directives.graphql",
"node_modules/@amazeelabs/*/directives.graphql",
"../../apps/cms/web/modules/contrib/*/directives.graphql",
"../../apps/cms/web/modules/custom/*/directives.graphql",
"src/schema.graphql"
Expand Down
4 changes: 2 additions & 2 deletions packages/schema/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const config: CodegenConfig = {
plugins: ['@amazeelabs/codegen-operation-ids'],
},
// Directive autoloader for Gatsby.
'../../apps/website/autoload.mjs': {
'build/gatsby-autoload.mjs': {
plugins: ['@amazeelabs/codegen-autoloader'],
config: {
mode: 'js',
Expand All @@ -41,7 +41,7 @@ const config: CodegenConfig = {
},
},
// Directive autoloader for Drupla.
'../../apps/cms/autoload.json': {
'build/drupal-autoload.json': {
plugins: ['@amazeelabs/codegen-autoloader'],
config: {
mode: 'drupal',
Expand Down
14 changes: 13 additions & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
],
"./operations": [
"./build/operations.json"
],
"./gatsby-autoload": [
"./build/gatsby-autoload.mjs"
]
},
"typesVersions": {
Expand All @@ -24,6 +27,9 @@
],
"/source": [
"build/generated/source.d.ts"
],
"gatsby-autoload": [
"src/types/gatsby-autoload.d.ts"
]
}
},
Expand All @@ -43,14 +49,20 @@
"@graphql-codegen/typescript-operations": "^4.0.1",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.67",
"@types/image-size": "^0.8.0",
"@types/node": "^18",
"concurrently": "^8.2.2",
"graphql": "16.8.1",
"typescript": "^5.3.3"
},
"dependencies": {
"@amazeelabs/executors": "^1.1.0",
"@amazeelabs/gatsby-silverback-cloudinary": "^1.2.7",
"@amazeelabs/gatsby-source-silverback": "^1.13.10",
"@amazeelabs/scalars": "^1.6.13",
"@swc/cli": "^0.1.63",
"@swc/core": "^1.3.102"
"@swc/core": "^1.3.102",
"image-size": "^1.1.1",
"mime-types": "^2.1.35"
}
}
12 changes: 5 additions & 7 deletions apps/website/image.mjs → packages/schema/src/image.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { GraphQLFieldResolver } from 'graphql';
import sizeOf from 'image-size';
import mime from 'mime-types';
import { lookup } from 'mime-types';

/**
* @param {string | undefined} source
*/
export function imageProps(source) {
export const imageProps: GraphQLFieldResolver<string, any> = (source) => {
// If its a decap image, process it.
// Otherwise, it comes from Drupal and
// already has all necessary props.
Expand All @@ -20,8 +18,8 @@ export function imageProps(source) {
originalSrc: imageSrc,
width: dimensions.width || 0,
height: dimensions.height || 0,
mime: mime.lookup(relativeSource) || 'application/octet-stream',
mime: lookup(relativeSource) || 'application/octet-stream',
});
}
return source;
}
};
2 changes: 1 addition & 1 deletion packages/schema/src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ scalar ImageSource @default @value(json: "\"\"")
Retrieve the properties of an image.
TODO: Move to a shared "image" package.

implementation(gatsby): ./image.mjs#imageProps
implementation(gatsby): ./image.js#imageProps
"""
directive @imageProps repeatable on FIELD_DEFINITION | SCALAR | UNION | ENUM | INTERFACE | OBJECT

Expand Down
3 changes: 3 additions & 0 deletions packages/schema/src/types/gatsby-autoload.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { GraphQLFieldResolver } from 'graphql';

export default Record<string, GraphQLFieldResolver<any, any>>;
3 changes: 2 additions & 1 deletion packages/schema/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationDir": "build",
"outDir": "build"
"outDir": "build",
"lib": ["ES2015"]
},
"include": ["src"]
}
6 changes: 1 addition & 5 deletions packages/schema/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
".graphqlrc.json",
"tsconfig.json"
],
"outputs": [
"build/**",
"../../apps/website/autoload.mjs",
"../../apps/cms/autoload.json"
]
"outputs": ["build/**"]
}
}
}
File renamed without changes.
9 changes: 7 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
"private": true,
"version": "1.0.0",
"type": "module",
"sideEffects": false,
"sideEffects": [
"styles.css"
],
"exports": {
"./intl": [
"./build/utils/intl/index.js"
],
"./routes/*": [
"./build/components/Routes/*.js"
],
"./styles.css": [
"./build/styles.css"
]
},
"typesVersions": {
Expand All @@ -26,7 +31,7 @@
"prep:types": "tsc --emitDeclarationOnly",
"prep:scripts": "swc ./src -d ./build",
"prep:styles": "NODE_ENV=production pnpm postcss tailwind.css -o build/styles.css",
"prep:cms-css": "NODE_ENV=production pnpm postcss cms.css -o ../drupal-themes/custom_iframe/styles.css",
"prep:iframe": "NODE_ENV=production pnpm postcss iframe.css -o build/iframe.css",
"prep:gutenberg": "NODE_ENV=production PREFIX=gutenberg pnpm postcss tailwind.css -o build/gutenberg.css",
"prep:i18n": "formatjs extract 'src/**/*.ts*' --ignore='**/*.d.ts' --ignore='**/*.stories.ts*' --out-file build/translatables.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'\n",
"build": "storybook build",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/postcss.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
plugins: {
'postcss-import-ext-glob': {},
'postcss-import': {},
tailwindcss: {},
tailwindcss: require('./tailwind.config.cjs'),
autoprefixer: {},
'postcss-prefix-selector': {
prefix:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Url } from '@custom/schema';
import { Meta, StoryObj } from '@storybook/react';

import cmsCss from '../../../../cms.css?inline';
import cmsCss from '../../../../iframe.css?inline';
import { BlockForm } from './BlockForm';

export default {
Expand Down
Loading
Loading