Skip to content

Commit

Permalink
Merge changes published in the Gutenberg plugin "release/19.6" branch
Browse files Browse the repository at this point in the history
  • Loading branch information
gutenbergplugin committed Oct 30, 2024
1 parent 3c61eb6 commit 41580fe
Show file tree
Hide file tree
Showing 794 changed files with 16,063 additions and 10,119 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,18 +356,6 @@ module.exports = {
],
},
},
{
files: [
// Components package.
'packages/components/src/**/*.[tj]s?(x)',
// Navigation block.
'packages/block-library/src/navigation/**/*.[tj]s?(x)',
],
excludedFiles: [ ...developmentFiles ],
rules: {
'react-hooks/exhaustive-deps': 'error',
},
},
{
files: [ 'packages/jest*/**/*.js', '**/test/**/*.js' ],
excludedFiles: [ 'test/e2e/**/*.js', 'test/performance/**/*.js' ],
Expand Down
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ body:
options:
- label: 'Yes'
required: true

- type: checkboxes
id: themes
attributes:
label: Please confirm which theme type you used for testing.
options:
- label: 'Block'
- label: 'Classic'
- label: 'Hybrid (e.g. classic with theme.json)'
- label: 'Not sure'
4 changes: 2 additions & 2 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ jobs:
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm -v
- name: Compare performance with trunk
- name: Compare performance with base branch
if: github.event_name == 'pull_request'
run: ./bin/plugin/cli.js perf $GITHUB_SHA trunk --tests-branch $GITHUB_SHA
run: ./bin/plugin/cli.js perf $GITHUB_SHA ${{ github.base_ref }} --tests-branch $GITHUB_SHA

- name: Compare performance with current WordPress Core and previous Gutenberg versions
if: github.event_name == 'release'
Expand Down
20 changes: 2 additions & 18 deletions .github/workflows/pull-request-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,8 @@ jobs:
ref: trunk
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Use desired version of Node.js
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version-file: '.nvmrc'
check-latest: true

- name: Cache NPM packages
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node }}-npm-pr-automation-cache-${{ hashFiles('**/package-lock.json') }}

# Changing into the action's directory and running `npm install` is much
# faster than a full project-wide `npm ci`.
- name: Install NPM dependencies
run: npm install
working-directory: packages/project-management-automation
- name: Setup Node.js and install dependencies
uses: ./.github/setup-node

- uses: ./packages/project-management-automation
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: ./.github/setup-node

- name: Restore tests setup cache
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: |
~/.appium
Expand All @@ -50,7 +50,7 @@ jobs:
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0

- name: AVD cache
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: avd-cache
with:
path: |
Expand All @@ -60,7 +60,7 @@ jobs:

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # v2.32.0
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
Expand All @@ -71,7 +71,7 @@ jobs:
script: echo "Generated AVD snapshot for caching."

- name: Run tests
uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # v2.32.0
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # v1.196.0
- uses: ruby/setup-ruby@7bae1d00b5db9166f4f0fc47985a3a5702cb58f0 # v1.197.0
with:
# `.ruby-version` file location
working-directory: packages/react-native-editor/ios
Expand All @@ -42,7 +42,7 @@ jobs:
uses: ./.github/setup-node

- name: Restore tests setup cache
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: |
~/.appium
Expand All @@ -55,15 +55,15 @@ jobs:
run: find package-lock.json packages/react-native-editor/ios packages/react-native-aztec/ios packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt

- name: Restore build cache
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: |
packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app
packages/react-native-editor/ios/build/WDA
key: ${{ runner.os }}-ios-build-${{ matrix.xcode }}-${{ matrix.device }}-${{ hashFiles('ios-checksums.txt') }}

- name: Restore pods cache
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: |
packages/react-native-editor/ios/Pods
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ jobs:
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT

- name: Cache PHPCS scan cache
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: .cache/phpcs.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
[![React Native E2E Tests (iOS)](<https://github.com/WordPress/gutenberg/workflows/React%20Native%20E2E%20Tests%20(iOS)/badge.svg>)](https://github.com/WordPress/gutenberg/actions?query=workflow%3A%22React+Native+E2E+Tests+%28iOS%29%22+branch%3Atrunk)
[![React Native E2E Tests (Android)](<https://github.com/WordPress/gutenberg/workflows/React%20Native%20E2E%20Tests%20(Android)/badge.svg>)](https://github.com/WordPress/gutenberg/actions?query=workflow%3A%22React+Native+E2E+Tests+%28Android%29%22+branch%3Atrunk)

<a href="https://wordpress.github.io/gutenberg/" target="_blank"><img src="https://raw.githubusercontent.com/storybooks/brand/master/badge/badge-storybook.svg" alt="Storybook Badge" /></a>

[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org)

![Screenshot of the Gutenberg Editor, editing a post in WordPress](https://user-images.githubusercontent.com/1204802/100067796-fc3e8700-2e36-11eb-993b-6b80b4310b87.png)
Expand Down
4 changes: 4 additions & 0 deletions backport-changelog/6.7/7661.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
https://github.com/WordPress/wordpress-develop/pull/7661

* https://github.com/WordPress/gutenberg/pull/66468
* https://github.com/WordPress/gutenberg/pull/66543
3 changes: 3 additions & 0 deletions backport-changelog/6.8/7488.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7488

* https://github.com/WordPress/gutenberg/pull/60622
3 changes: 3 additions & 0 deletions backport-changelog/6.8/7498.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7498

* https://github.com/WordPress/gutenberg/pull/60622
5 changes: 5 additions & 0 deletions backport-changelog/6.8/7604.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
https://github.com/WordPress/wordpress-develop/pull/7604

* https://github.com/WordPress/gutenberg/pull/66285
* https://github.com/WordPress/gutenberg/pull/66302
* https://github.com/WordPress/gutenberg/pull/66306
3 changes: 3 additions & 0 deletions backport-changelog/6.8/7643.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7643

* https://github.com/WordPress/gutenberg/pull/66432
46 changes: 46 additions & 0 deletions bin/api-docs/gen-components-docs/get-subcomponent-descriptions.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* External dependencies
*/
import fs from 'node:fs/promises';
import babel from '@babel/core';
import { parse as commentParser } from 'comment-parser';

/**
* Try to get subcomponent descriptions from the main component Object.assign() call.
*/
export async function getDescriptionsForSubcomponents(
filePath,
mainComponentName
) {
const fileContent = await fs.readFile( filePath, 'utf8' );
const parsedFile = babel.parse( fileContent, {
filename: filePath,
} );
const mainComponent = parsedFile.program.body
.filter( ( node ) => node.type === 'ExportNamedDeclaration' )
.flatMap( ( node ) => node.declaration?.declarations )
.find( ( node ) => node?.id.name === mainComponentName );

if (
! (
// If the main component export has `Object.assign( ... )`
(
mainComponent?.init?.type === 'CallExpression' &&
mainComponent?.init?.callee?.object?.name === 'Object' &&
mainComponent?.init?.callee?.property?.name === 'assign'
)
)
) {
return;
}

const properties = mainComponent?.init?.arguments[ 1 ]?.properties.map(
( node ) => [
node.key.name,
commentParser( `/*${ node.leadingComments?.[ 0 ].value }*/`, {
spacing: 'preserve',
} )?.[ 0 ]?.description,
]
);
return Object.fromEntries( properties );
}
30 changes: 26 additions & 4 deletions bin/api-docs/gen-components-docs/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import path from 'path';
* Internal dependencies
*/
import { generateMarkdownDocs } from './markdown/index.mjs';
import { getDescriptionsForSubcomponents } from './get-subcomponent-descriptions.mjs';

const MANIFEST_GLOB = 'packages/components/src/**/docs-manifest.json';

Expand Down Expand Up @@ -79,8 +80,10 @@ await Promise.all(
displayName: manifest.displayName,
} );

const subcomponentTypeDocs = manifest.subcomponents?.map(
( subcomponent ) => {
let subcomponentDescriptions;

const subcomponentTypeDocs = await Promise.all(
manifest.subcomponents?.map( async ( subcomponent ) => {
const docs = getTypeDocsForComponent( {
manifestPath,
componentFilePath: subcomponent.filePath,
Expand All @@ -91,10 +94,29 @@ await Promise.all(
docs.displayName = subcomponent.preferredDisplayName;
}

if ( ! subcomponent.description ) {
subcomponentDescriptions ??=
getDescriptionsForSubcomponents(
path.resolve(
path.dirname( manifestPath ),
manifest.filePath
),
manifest.displayName
);

docs.description = ( await subcomponentDescriptions )?.[
subcomponent.displayName
];
}

return docs;
}
} ) ?? []
);
const docs = generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } );

const docs = generateMarkdownDocs( {
typeDocs,
subcomponentTypeDocs,
} );
const outputFile = path.resolve(
path.dirname( manifestPath ),
'./README.md'
Expand Down
2 changes: 1 addition & 1 deletion bin/api-docs/gen-components-docs/markdown/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { generateMarkdownPropsJson } from './props.mjs';

export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
const mainDocsJson = [
'<!-- This file is generated automatically and cannot be edited directly. -->\n',
{ h1: typeDocs.displayName },
'<!-- This file is generated automatically and cannot be edited directly. Make edits via TypeScript types and TSDocs. -->',
{
p: `<p class="callout callout-info">See the <a href="https://wordpress.github.io/gutenberg/?path=/docs/components-${ typeDocs.displayName.toLowerCase() }--docs">WordPress Storybook</a> for more detailed, interactive documentation.</p>`,
},
Expand Down
29 changes: 14 additions & 15 deletions bin/api-docs/gen-theme-reference.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
import fs from 'node:fs/promises';
import $RefParser from '@apidevtools/json-schema-ref-parser';
import { fileURLToPath } from 'node:url';

/**
* @typedef {import('@apidevtools/json-schema-ref-parser').JSONSchema} JSONSchema
Expand All @@ -19,19 +20,20 @@ import $RefParser from '@apidevtools/json-schema-ref-parser';
*
* @type {URL}
*/
const THEME_JSON_SCHEMA_URL = new URL(
'../../schemas/json/theme.json',
import.meta.url
const THEME_JSON_SCHEMA_PATH = fileURLToPath(
new URL( '../../schemas/json/theme.json', import.meta.url )
);

/**
* Path to docs file.
*
* @type {URL}
*/
const REFERENCE_DOC_URL = new URL(
'../../docs/reference-guides/theme-json-reference/theme-json-living.md',
import.meta.url
const REFERENCE_DOC_PATH = fileURLToPath(
new URL(
'../../docs/reference-guides/theme-json-reference/theme-json-living.md',
import.meta.url
)
);

/**
Expand Down Expand Up @@ -265,15 +267,12 @@ function generateDocs( themeJson ) {
* Main function.
*/
async function main() {
const themeJson = await $RefParser.dereference(
THEME_JSON_SCHEMA_URL.pathname,
{
parse: { binary: false, text: false, yaml: false },
resolve: { external: false },
}
);
const themeJson = await $RefParser.dereference( THEME_JSON_SCHEMA_PATH, {
parse: { binary: false, text: false, yaml: false },
resolve: { external: false },
} );

const themeJsonReference = await fs.readFile( REFERENCE_DOC_URL, {
const themeJsonReference = await fs.readFile( REFERENCE_DOC_PATH, {
encoding: 'utf8',
flag: 'r',
} );
Expand All @@ -285,7 +284,7 @@ async function main() {
`${ START_TOKEN }\n${ generatedDocs }\n${ END_TOKEN }`
);

await fs.writeFile( REFERENCE_DOC_URL, updatedThemeJsonReference, {
await fs.writeFile( REFERENCE_DOC_PATH, updatedThemeJsonReference, {
encoding: 'utf8',
} );
}
Expand Down
Loading

0 comments on commit 41580fe

Please sign in to comment.