Skip to content

Commit

Permalink
Merge branch 'trunk' into storybook/block-inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
SainathPoojary committed Jan 14, 2025
2 parents 4df7ec8 + b949616 commit d09a854
Show file tree
Hide file tree
Showing 787 changed files with 7,269 additions and 4,138 deletions.
23 changes: 0 additions & 23 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,6 @@
const glob = require( 'glob' ).sync;
const { join } = require( 'path' );

/**
* Internal dependencies
*/
const { version } = require( './package' );

/**
* Regular expression string matching a SemVer string with equal major/minor to
* the current package version. Used in identifying deprecations.
*
* @type {string}
*/
const majorMinorRegExp =
version.replace( /\.\d+$/, '' ).replace( /[\\^$.*+?()[\]{}|]/g, '\\$&' ) +
'(\\.\\d+)?';

/**
* The list of patterns matching files used only for development purposes.
*
Expand Down Expand Up @@ -92,14 +77,6 @@ const restrictedSyntax = [
'ImportDeclaration[source.value=/^@wordpress\\u002F.+\\u002F/]',
message: 'Path access on WordPress dependencies is not allowed.',
},
{
selector:
'CallExpression[callee.name="deprecated"] Property[key.name="version"][value.value=/' +
majorMinorRegExp +
'/]',
message:
'Deprecated functions must be removed before releasing this version.',
},
{
selector:
'CallExpression[callee.object.name="page"][callee.property.name="waitFor"]',
Expand Down
7 changes: 2 additions & 5 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Blocks
/packages/block-library @ajitbohra @fabiankaegy
/packages/block-library/src/gallery @geriux
/packages/block-library/src/gallery
/packages/block-library/src/comment-template @michalczaplinski
/packages/block-library/src/comments @michalczaplinski
/packages/block-library/src/table-of-contents @ZebulanStanphill
Expand Down Expand Up @@ -138,10 +138,7 @@
/lib/compat/*/html-api @dmsnell
/lib/experimental/rest-api.php @timothybjacobs
/lib/experimental/class-wp-rest-* @timothybjacobs
/lib/experimental/class-wp-rest-block-editor-settings-controller.php @timothybjacobs @spacedmonkey @geriux

# Native
/packages/components/src/mobile/global-styles-context @geriux
/lib/experimental/class-wp-rest-block-editor-settings-controller.php @timothybjacobs @spacedmonkey

# Native (Unowned)
*.native.js
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Validate checksums
uses: gradle/actions/wrapper-validation@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
uses: gradle/actions/wrapper-validation@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
4 changes: 2 additions & 2 deletions .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Use desired version of Java
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: 'corretto'
java-version: '17'
Expand All @@ -48,7 +48,7 @@ jobs:
run: npm run native test:e2e:setup

- name: Gradle cache
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2

# AVD cache disabled as it caused emulator termination to hang indefinitely.
# https://github.com/ReactiveCircus/android-emulator-runner/issues/385
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0
- uses: ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4 # v1.207.0
with:
# `.ruby-version` file location
working-directory: packages/react-native-editor/ios
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/storybook-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Check Storybook build

on: pull_request

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Setup Node.js and install dependencies
uses: ./.github/setup-node

- name: Build Storybook
run: npm run storybook:build
4 changes: 2 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ jobs:
# dependency versions are installed and cached.
##
- name: Set up PHP
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2.32.0
with:
php-version: '${{ matrix.php }}'
ini-file: development
Expand Down Expand Up @@ -283,7 +283,7 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Set up PHP
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2.32.0
with:
php-version: '7.4'
coverage: none
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ results
/test/e2e/artifacts
/perf-envs
/composer.lock
/ts-traces

# The /.cache folder is needed for phpcs to cache results between runs, while other .cache folders must be ignored
# It is not possible to re-include a file if a parent directory of that file is excluded
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Gutenberg

Copyright 2016-2024 by the contributors
Copyright 2016-2025 by the contributors

**License for Contributions (on and after April 15, 2021)**

Expand Down
4 changes: 2 additions & 2 deletions backport-changelog/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The filename is the Core PR number.

For example, if your Core PR number is `1234` and is slated to be part of the WordPress 6.9 release, the filename will be `1234.md`, and will be placed in the `/backport-changelog/6.9` directory.

The content of the markdown file should be the Github URL of the Core PR, followed by a list of Gutenberg PR Github URLs whose changes are backported in the Core PR.
The content of the markdown file should be the GitHub URL of the Core PR, followed by a list of Gutenberg PR GitHub URLs whose changes are backported in the Core PR.

A single Core PR may contain changes from one or multiple Gutenberg PRs.

Expand Down Expand Up @@ -51,7 +51,7 @@ For the backport changelog, Gutenberg uses individual files as opposed to a sing

Some Gutenberg PRs may be flagged as needing a core backport PR when they don't, for example when the PR contains minor comment changes, or the changes already exist in Core.

For individual PRs, there are two Github labels that can be used to exclude a PR from the backport changelog CI check:
For individual PRs, there are two GitHub labels that can be used to exclude a PR from the backport changelog CI check:

- `Backport from WordPress Core` - Indicates that the PR is a backport from WordPress Core and doesn't need a Core PR.
- `No Core Sync Required` - Indicates that any changes do not need to be synced to WordPress Core.
Expand Down
4 changes: 2 additions & 2 deletions bin/api-docs/gen-block-lib-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ function processObjWithInnerKeys( obj ) {
* not disabled. So adding { color: 'link' } support also brings along
* background and text.
*
* @param {Object} supports - keys supported by blokc
* @param {Object} supports - keys supported by block
* @return {Object} supports augmented with defaults
*/
function augmentSupports( supports ) {
if ( 'color' in supports ) {
// If backgroud or text is not specified (true or false)
// If background or text is not specified (true or false)
// then add it as true.a
if ( ! ( 'background' in supports.color ) ) {
supports.color.background = true;
Expand Down
30 changes: 30 additions & 0 deletions bin/api-docs/gen-components-docs/get-tags-from-storybook.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* External dependencies
*/
import fs from 'node:fs/promises';
import babel from '@babel/core';

/**
* Returns `meta.tags` from a Storybook file.
*
* @param {string} filePath
* @return {Promise<string[]>} Array of tags.
*/
export async function getTagsFromStorybook( filePath ) {
const fileContent = await fs.readFile( filePath, 'utf8' );
const parsedFile = babel.parse( fileContent, {
filename: filePath,
} );

const meta = parsedFile.program.body.find(
( node ) =>
node.type === 'VariableDeclaration' &&
node.declarations[ 0 ].id.name === 'meta'
);

return (
meta.declarations[ 0 ].init.properties
.find( ( node ) => node.key.name === 'tags' )
?.value.elements.map( ( node ) => node.value ) ?? []
);
}
9 changes: 9 additions & 0 deletions bin/api-docs/gen-components-docs/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import path from 'path';
*/
import { generateMarkdownDocs } from './markdown/index.mjs';
import { getDescriptionsForSubcomponents } from './get-subcomponent-descriptions.mjs';
import { getTagsFromStorybook } from './get-tags-from-storybook.mjs';

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

Expand Down Expand Up @@ -113,9 +114,17 @@ await Promise.all(
} ) ?? []
);

const tags = await getTagsFromStorybook(
path.resolve(
path.dirname( manifestPath ),
'stories/index.story.tsx'
)
);

const docs = generateMarkdownDocs( {
typeDocs,
subcomponentTypeDocs,
tags,
} );
const outputFile = path.resolve(
path.dirname( manifestPath ),
Expand Down
11 changes: 10 additions & 1 deletion bin/api-docs/gen-components-docs/markdown/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ json2md.converters.md = ( input ) => {
return input?.trim() || '';
};

export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
export function generateMarkdownDocs( {
typeDocs,
subcomponentTypeDocs,
tags,
} ) {
const mainDocsJson = [
{ h1: typeDocs.displayName },
'<!-- This file is generated automatically and cannot be edited directly. Make edits via TypeScript types and TSDocs. -->',
tags.includes( 'status-private' ) && [
{
p: '🔒 This component is locked as a [private API](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-private-apis/). We do not yet recommend using this outside of the Gutenberg project.',
},
],
{
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
2 changes: 2 additions & 0 deletions bin/generate-gutenberg-php.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
/**
* Prints `define` statements for the production version of `gutenberg.php`
* (the plugin entry point).
*
* @global string $plugin_version The version number of the plugin.
*/
function print_production_defines() {
global $plugin_version;
Expand Down
8 changes: 4 additions & 4 deletions bin/plugin/commands/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const LABEL_TYPE_MAPPING = {
};

/**
* Mapping of label names to arbitary features in the release notes.
* Mapping of label names to arbitrary features in the release notes.
*
* Mapping a given label to a feature will guarantee it will be categorised
* under that feature name in the changelog within each section.
Expand Down Expand Up @@ -274,7 +274,7 @@ function mapLabelsToFeatures( labels ) {
*
* @param {string[]} labels Label names.
*
* @return {boolean} whether or not the issue's is labbeled as block specific
* @return {boolean} whether or not the issue's is labeled as block specific
*/
function getIsBlockSpecificIssue( labels ) {
return !! labels.find( ( label ) => label.startsWith( '[Block] ' ) );
Expand Down Expand Up @@ -343,7 +343,7 @@ function getIssueFeature( issue ) {

// 1. Prefer explicit mapping of label to feature.
if ( featureCandidates.length ) {
// Get occurances of the feature labels.
// Get occurrences of the feature labels.
const featureCounts = featureCandidates.reduce(
/**
* @param {Record<string,number>} acc Accumulator
Expand Down Expand Up @@ -941,7 +941,7 @@ function skipCreatedByBots( pullRequests ) {
}

/**
* Produces the formatted markdown for the contributor props seciton.
* Produces the formatted markdown for the contributor props section.
*
* @param {IssuesListForRepoResponseItem[]} pullRequests List of pull requests.
*
Expand Down
2 changes: 1 addition & 1 deletion bin/plugin/commands/test/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ describe( 'getIssueFeature', () => {
name: '[Package] This package',
},
{
name: '[Feature] Cool Feature', // Should have priority despite prescence of block specific label.
name: '[Feature] Cool Feature', // Should have priority despite presence of block specific label.
},
{
name: '[Package] Another One',
Expand Down
4 changes: 2 additions & 2 deletions bin/test-create-block.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if [ "$expected" -ne "$actual" ]; then
exit 1
fi
expected=7
actual=$( find src -maxdepth 1 -type f | wc -l )
actual=$( find src -maxdepth 2 -type f | wc -l )
if [ "$expected" -ne "$actual" ]; then
error "Expected $expected files in the \`src\` directory, but found $actual."
exit 1
Expand All @@ -70,7 +70,7 @@ status "Building block..."

status "Verifying build..."
expected=9
actual=$( find build -maxdepth 1 -type f | wc -l )
actual=$( find build -maxdepth 2 -type f | wc -l )
if [ "$expected" -ne "$actual" ]; then
error "Expected $expected files in the \`build\` directory, but found $actual."
exit 1
Expand Down
1 change: 1 addition & 0 deletions bin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"noEmit": true,
"outDir": ".cache"
},
"include": [],
"files": [
"./api-docs/update-api-docs.js",
"./plugin/config.js",
Expand Down
35 changes: 27 additions & 8 deletions bin/validate-tsconfig.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,33 @@ for ( const packageName of packagesWithTypes ) {
hasErrors = true;
}

const packageJson = JSON.parse(
readFileSync( `packages/${ packageName }/package.json`, 'utf8' )
);
const tsconfigJson = JSON.parse(
stripJsonComments(
readFileSync( `packages/${ packageName }/tsconfig.json`, 'utf8' )
)
);
let packageJson;
try {
packageJson = JSON.parse(
readFileSync( `packages/${ packageName }/package.json`, 'utf8' )
);
} catch ( e ) {
console.error(
`Error parsing package.json for package ${ packageName }`
);
throw e;
}
let tsconfigJson;
try {
tsconfigJson = JSON.parse(
stripJsonComments(
readFileSync(
`packages/${ packageName }/tsconfig.json`,
'utf8'
)
)
);
} catch ( e ) {
console.error(
`Error parsing tsconfig.json for package ${ packageName }`
);
throw e;
}
if ( packageJson.dependencies ) {
for ( const dependency of Object.keys( packageJson.dependencies ) ) {
if ( dependency.startsWith( '@wordpress/' ) ) {
Expand Down
Loading

0 comments on commit d09a854

Please sign in to comment.