Skip to content

Commit

Permalink
Merge branch 'main' into related_items
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleybl authored Dec 18, 2024
2 parents fd2a660 + 09b88e6 commit ce0ce54
Show file tree
Hide file tree
Showing 240 changed files with 7,398 additions and 5,836 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,49 @@
name: Deployment Tests
name: API-first story Tests
on: [push, pull_request]

env:
node-version: 22.x

jobs:
vitessr:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
config:
runs-on: ubuntu-latest
outputs:
ENVIRONMENT: ${{ steps.vars.outputs.ENVIRONMENT }}
STACK_NAME: ${{ steps.vars.outputs.STACK_NAME }}
nextjs: ${{ steps.filter.outputs.nextjs }}
remix: ${{ steps.filter.outputs.remix }}
rr7: ${{ steps.filter.outputs.rr7 }}
tss: ${{ steps.filter.outputs.tss }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set Env Vars
id: vars
run: |
ENVIRONMENT=${{ vars.LIVE_ENV }}
echo "ENVIRONMENT=${ENVIRONMENT}" >> $GITHUB_OUTPUT
echo "STACK_NAME=${ENVIRONMENT//./-}" >> $GITHUB_OUTPUT
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
nextjs:
- 'apps/nextjs/**'
- '.github/workflows/api-first.yml'
remix:
- 'apps/remix/**'
- '.github/workflows/api-first.yml'
rr7:
- 'apps/rr7/**'
- '.github/workflows/api-first.yml'
tss:
- 'apps/vite-ssr/**'
- '.github/workflows/api-first.yml'
tss:
if: ${{ needs.config.outputs.tss == 'true' }} && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
runs-on: ubuntu-latest
name: Vite SSR
timeout-minutes: 5
Expand Down Expand Up @@ -68,7 +105,8 @@ jobs:
run: make backend-docker-detached-stop

nextjs:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
# if: ${{ needs.config.outputs.nextjs == 'true' }} && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
if: false
runs-on: ubuntu-latest
name: Next.JS
timeout-minutes: 5
Expand Down Expand Up @@ -130,7 +168,7 @@ jobs:
run: make backend-docker-detached-stop

remix:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
if: ${{ needs.config.outputs.remix == 'true' }} && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
runs-on: ubuntu-latest
name: Remix
timeout-minutes: 5
Expand Down Expand Up @@ -174,7 +212,63 @@ jobs:
run: pnpm --filter plone-remix build

- name: Start server
run: nohup pnpm --filter plone-remix start:prod &
run: PLONE_API_PATH=http://localhost:8080/Plone nohup pnpm --filter plone-remix start:prod &

- name: Wait
run: packages/scripts/node_modules/.bin/wait-on --httpTimeout 20000 http-get://127.0.0.1:8080/Plone

- name: Run tests
run: node packages/scripts/check_deployment.js

- name: Stop backend
run: make backend-docker-detached-stop

rr7:
if: ${{ needs.config.outputs.rr7 == 'true' }} && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
runs-on: ubuntu-latest
name: ReactRouter 7
timeout-minutes: 5
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}

- name: Enable corepack
run: corepack enable

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build dependencies
run: pnpm build:all

- name: Start backend
run: make backend-docker-detached-start

- name: Build
run: pnpm --filter plone-rr7 build

- name: Start server
run: PLONE_API_PATH=http://localhost:8080/Plone nohup pnpm --filter plone-rr7 start:prod &

- name: Wait
run: packages/scripts/node_modules/.bin/wait-on --httpTimeout 20000 http-get://127.0.0.1:8080/Plone
Expand Down
32 changes: 31 additions & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install towncrier
run: pip install towncrier

- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
Expand All @@ -42,6 +42,12 @@ jobs:
- 'packages/scripts/**'
voltoSlate:
- 'packages/volto-slate/**'
blocks:
- 'packages/blocks/**'
slots:
- 'packages/slots/**'
theming:
- 'packages/theming/**'
wrongNews:
- added|modified: 'news/**'
Expand Down Expand Up @@ -120,6 +126,30 @@ jobs:
env:
BASE_BRANCH: ${{ github.base_ref }}

- name: Blocks changelog check
if: steps.filter.outputs.blocks == 'true'
run: |
git fetch --no-tags origin main
towncrier check --compare-with origin/main --dir packages/blocks
env:
BASE_BRANCH: ${{ github.base_ref }}

- name: Slots changelog check
if: steps.filter.outputs.slots == 'true'
run: |
git fetch --no-tags origin main
towncrier check --compare-with origin/main --dir packages/slots
env:
BASE_BRANCH: ${{ github.base_ref }}

- name: Theming changelog check
if: steps.filter.outputs.theming == 'true'
run: |
git fetch --no-tags origin main
towncrier check --compare-with origin/main --dir packages/theming
env:
BASE_BRANCH: ${{ github.base_ref }}

- name: Wrong location of news changelog check
if: steps.filter.outputs.wrongNews == 'true'
run: echo "News items should be moved from the repository root to the appropriate package root in `packages/package-name`." && exit 1
Expand Down
3 changes: 3 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
dist
docs
node_modules
packages/registry/lib
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ You can build your own or choose from the community released ones:
You can try a Volto online demo at [https://demo.plone.org/](https://demo.plone.org/).


## Monorepo structure

Since version 18.0.0-alpha4, the Volto core repository has had the shape of a monorepo, where "mono" means "single" and "repo" is short for "repository".
This means that several apps and libraries related to each other are stored in the same repository.
They are managed together but released individually.
This allows the code to be shared effectively, and unifies tracking of changes across all of the apps and libraries.

| Package | Location |
|---|---|
| [`@plone/client`](https://www.npmjs.com/package/@plone/client) | [`packages/client`](https://github.com/plone/volto/tree/main/packages/client#readme) |
| [`@plone/components`](https://www.npmjs.com/package/@plone/components) | [`packages/components`](https://github.com/plone/volto/tree/main/packages/components#readme) |
| [`@plone/generator-volto`](https://www.npmjs.com/package/@plone/generator-volto) | [`packages/generator-volto`](https://github.com/plone/volto/tree/main/packages/generator-volto#readme) |
| [`@plone/helpers`](https://www.npmjs.com/package/@plone/helpers) | [`packages/helpers`](https://github.com/plone/volto/tree/main/packages/helpers#readme) |
| [`@plone/providers`](https://www.npmjs.com/package/@plone/providers) | [`packages/providers`](https://github.com/plone/volto/tree/main/packages/providers#readme) |
| [`@plone/registry`](https://www.npmjs.com/package/@plone/registry) | [`packages/registry`](https://github.com/plone/volto/tree/main/packages/registry#readme) |
| [`@plone/scripts`](https://www.npmjs.com/package/@plone/scripts) | [`packages/scripts`](https://github.com/plone/volto/tree/main/packages/scripts#readme) |
| [`@plone/types`](https://www.npmjs.com/package/@plone/types) | [`packages/types`](https://github.com/plone/volto/tree/main/packages/types#readme) |
| none | [`packages/volto-guillotina`](https://github.com/plone/volto/tree/main/packages/volto-guillotina) |
| [`@plone/volto-slate`](https://www.npmjs.com/package/@plone/volto-slate) | [`packages/volto-slate`](https://github.com/plone/volto/tree/main/packages/volto-slate#readme) |
| [`@plone/volto-testing`](https://www.npmjs.com/package/@plone/volto-testing) | [`packages/volto-testing`](https://github.com/plone/volto/tree/main/packages/volto-testing) |

See also [Monorepo structure](https://6.docs.plone.org/volto/contributing/developing-core.html#monorepo-structure).


## Create a Volto project

To start a new project using Volto, follow the [Plone installation documentation](https://6.docs.plone.org/install/create-project.html).
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@tanstack/react-query": "^5.59.0",
"next": "14.2.14",
"react": "^18",
"react-aria-components": "^1.4.0",
"react-aria-components": "^1.5.0",
"react-dom": "^18"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions apps/remix/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
/build
/public/build
.env
.registry.loader.js
2 changes: 1 addition & 1 deletion apps/remix/app/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ploneClient from '@plone/client';
import config from '@plone/registry';

const cli = ploneClient.initialize({
apiPath: config.settings.apiPath,
apiPath: config.settings.internalApiPath || config.settings.apiPath,
});

export { cli as ploneClient };
28 changes: 14 additions & 14 deletions apps/remix/app/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import config from '@plone/registry';
import { blocksConfig, slate } from '@plone/blocks';

const settings = {
apiPath: 'http://localhost:8080/Plone',
slate,
};

// @ts-expect-error We need to fix typing
config.set('settings', settings);

// @ts-expect-error We need to fix typing
config.set('blocks', { blocksConfig });

export default config;
import applyAddonConfiguration from '@plone/registry/addons-loader';

export default function install() {
applyAddonConfiguration(config);
config.settings.apiPath =
process.env.PLONE_API_PATH || 'http://localhost:3000';
config.settings.internalApiPath = process.env.PLONE_INTERNAL_API_PATH || '';
console.log('API_PATH is:', config.settings.apiPath);
console.log(
'INTERNAL_API_PATH is:',
config.settings.internalApiPath || 'not set',
);
return config;
}
34 changes: 14 additions & 20 deletions apps/remix/app/routes/_index.tsx → apps/remix/app/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import {
dehydrate,
QueryClient,
HydrationBoundary,
useQueryClient,
useQuery,
} from '@tanstack/react-query';
import { flattenToAppURL } from '../utils';
import { flattenToAppURL } from './utils';
import { useLoaderData, useLocation } from '@remix-run/react';
import { usePloneClient } from '@plone/providers';
import { Breadcrumbs, RenderBlocks } from '@plone/components';
import config from '@plone/registry';
import { ploneClient } from '../client';
// import { Breadcrumbs, RenderBlocks } from '@plone/components';
// import config from '@plone/registry';
import { ploneClient } from './client';
import App from '@plone/slots/components/App';

export const meta: MetaFunction = () => {
return [
Expand All @@ -23,7 +25,7 @@ export const meta: MetaFunction = () => {
];
};

const expand = ['breadcrumbs', 'navigation'];
const expand = ['navroot', 'breadcrumbs', 'navigation'];

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const loader = async ({ params, request }: LoaderFunctionArgs) => {
Expand All @@ -40,39 +42,31 @@ export const loader = async ({ params, request }: LoaderFunctionArgs) => {
const { getContentQuery } = ploneClient;

await queryClient.prefetchQuery(
getContentQuery({ path: flattenToAppURL(request.url), expand }),
getContentQuery({ path: flattenToAppURL(request.url || '/'), expand }),
);

return json({ dehydratedState: dehydrate(queryClient) });
};

function Page() {
const { getContentQuery } = usePloneClient();
const pathname = useLocation().pathname;
const { data } = useQuery(getContentQuery({ path: pathname, expand }));
const { pathname } = useLocation();
const { data } = useQuery(getContentQuery({ path: pathname || '/', expand }));

if (!data) return null;
return (
<>
<Breadcrumbs
items={data['@components'].breadcrumbs.items || []}
root={data['@components'].breadcrumbs.root}
includeRoot
/>
<RenderBlocks
content={data}
blocksConfig={config.blocks.blocksConfig}
pathname="/"
/>
<App content={data} location={{ pathname: '/' }} />
</>
);
}

export default function Index() {
export default function Content() {
const { dehydratedState } = useLoaderData<typeof loader>();
const queryClient = useQueryClient();

return (
<HydrationBoundary state={dehydratedState}>
<HydrationBoundary state={dehydratedState} queryClient={queryClient}>
<Page />
</HydrationBoundary>
);
Expand Down
5 changes: 3 additions & 2 deletions apps/remix/app/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/file-conventions/entry.client
*/

import install from './config';
import { RemixBrowser } from '@remix-run/react';
import { startTransition, StrictMode } from 'react';
import { hydrateRoot } from 'react-dom/client';
import './config';

install();

startTransition(() => {
hydrateRoot(
Expand Down
4 changes: 3 additions & 1 deletion apps/remix/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import { createReadableStreamFromReadable } from '@remix-run/node';
import { RemixServer } from '@remix-run/react';
import { isbot } from 'isbot';
import { renderToPipeableStream } from 'react-dom/server';
import './config';
import install from './config';

const ABORT_DELAY = 5_000;

install();

export default function handleRequest(
request: Request,
responseStatusCode: number,
Expand Down
Loading

0 comments on commit ce0ce54

Please sign in to comment.