From af0293f4f812f6829fced1e6c050d715170dbede Mon Sep 17 00:00:00 2001 From: arthur791004 Date: Tue, 6 Aug 2024 00:30:36 +0800 Subject: [PATCH 1/3] Revert "MU WPCOM: Port the newspack blocks from the ETK (#38454)" This reverts commit 71819c1d506db8c9fa97a4d53bfc102e110418e9. --- pnpm-lock.yaml | 99 ----------- .../packages/jetpack-mu-wpcom/.gitattributes | 3 +- projects/packages/jetpack-mu-wpcom/.gitignore | 1 - .../jetpack-mu-wpcom/.phan/config.php | 3 - .../packages/jetpack-mu-wpcom/.phpcs.dir.xml | 4 +- .../bin/sync-newspack-blocks-formatter.js | 46 ------ .../bin/sync-newspack-blocks.sh | 156 ------------------ .../packages/jetpack-mu-wpcom/package.json | 7 +- .../src/class-jetpack-mu-wpcom.php | 1 - .../src/features/newspack-blocks/README.md | 50 ------ .../newspack-blocks/blog-posts/editor.js | 36 ---- .../newspack-blocks/blog-posts/view.js | 1 - .../newspack-blocks/carousel/editor.js | 24 --- .../features/newspack-blocks/carousel/view.js | 1 - .../src/features/newspack-blocks/consts.js | 4 - .../src/features/newspack-blocks/index.php | 122 -------------- .../packages/jetpack-mu-wpcom/src/utils.php | 2 - .../jetpack-mu-wpcom/webpack.config.js | 26 --- .../changelog/mu-wpcom-newspack-blocks | 5 - .../changelog/mu-wpcom-newspack-blocks#2 | 5 - .../changelog/mu-wpcom-newspack-blocks#3 | 5 - 21 files changed, 3 insertions(+), 598 deletions(-) delete mode 100644 projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks-formatter.js delete mode 100755 projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh delete mode 100644 projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/README.md delete mode 100644 projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/blog-posts/editor.js delete mode 100644 projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/blog-posts/view.js delete mode 100644 projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/carousel/editor.js delete mode 100644 projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/carousel/view.js delete mode 100644 projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/consts.js delete mode 100644 projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/index.php delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#2 delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#3 diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9591209e2002f..5126267ce8f36 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2281,12 +2281,6 @@ importers: redux: specifier: ^4.2.1 version: 4.2.1 - redux-saga: - specifier: ^1.3.0 - version: 1.3.0 - swiper: - specifier: ^8.4.5 - version: 8.4.7 wpcom-proxy-request: specifier: ^7.0.3 version: 7.0.5 @@ -2325,9 +2319,6 @@ importers: babel-plugin-transform-rename-properties: specifier: 0.1.0 version: 0.1.0(@babel/core@7.24.7) - pkg-dir: - specifier: ^5.0.0 - version: 5.0.0 sass: specifier: 1.64.1 version: 1.64.1 @@ -6675,24 +6666,6 @@ packages: react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 - '@redux-saga/core@1.3.0': - resolution: {integrity: sha512-L+i+qIGuyWn7CIg7k1MteHGfttKPmxwZR5E7OsGikCL2LzYA0RERlaUY00Y3P3ZV2EYgrsYlBrGs6cJP5OKKqA==} - - '@redux-saga/deferred@1.2.1': - resolution: {integrity: sha512-cmin3IuuzMdfQjA0lG4B+jX+9HdTgHZZ+6u3jRAOwGUxy77GSlTi4Qp2d6PM1PUoTmQUR5aijlA39scWWPF31g==} - - '@redux-saga/delay-p@1.2.1': - resolution: {integrity: sha512-MdiDxZdvb1m+Y0s4/hgdcAXntpUytr9g0hpcOO1XFVyyzkrDu3SKPgBFOtHn7lhu7n24ZKIAT1qtKyQjHqRd+w==} - - '@redux-saga/is@1.1.3': - resolution: {integrity: sha512-naXrkETG1jLRfVfhOx/ZdLj0EyAzHYbgJWkXbB3qFliPcHKiWbv/ULQryOAEKyjrhiclmr6AMdgsXFyx7/yE6Q==} - - '@redux-saga/symbols@1.1.3': - resolution: {integrity: sha512-hCx6ZvU4QAEUojETnX8EVg4ubNLBFl1Lps4j2tX7o45x/2qg37m3c6v+kSp8xjDJY+2tJw4QB3j8o8dsl1FDXg==} - - '@redux-saga/types@1.2.1': - resolution: {integrity: sha512-1dgmkh+3so0+LlBWRhGA33ua4MYr7tUOj+a9Si28vUi0IUFNbff1T3sgpeDJI/LaC75bBYnQ0A3wXjn0OrRNBA==} - '@remix-run/router@1.14.0': resolution: {integrity: sha512-WOHih+ClN7N8oHk9N4JUiMxQJmRVaOxcg8w7F/oHUXzJt920ekASLI/7cYX8XkntDWRhLZtsk6LbGrkgOAvi5A==} engines: {node: '>=14.0.0'} @@ -9526,9 +9499,6 @@ packages: dom7@3.0.0: resolution: {integrity: sha512-oNlcUdHsC4zb7Msx7JN3K0Nro1dzJ48knvBOnDPKJ2GV9wl1i5vydJZUSyOfrkKFDZEud/jBsTk92S/VGSAe/g==} - dom7@4.0.6: - resolution: {integrity: sha512-emjdpPLhpNubapLFdjNL9tP06Sr+GZkrIHEXLWvOGsytACUrkbeIdjO5g77m00BrHTznnlcNqgmn7pCN192TBA==} - domelementtype@1.3.1: resolution: {integrity: sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==} @@ -13089,9 +13059,6 @@ packages: resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} engines: {node: '>=8'} - redux-saga@1.3.0: - resolution: {integrity: sha512-J9RvCeAZXSTAibFY0kGw6Iy4EdyDNW7k6Q+liwX+bsck7QVsU78zz8vpBRweEfANxnnlG/xGGeOvf6r8UXzNJQ==} - redux-thunk@2.3.0: resolution: {integrity: sha512-km6dclyFnmcvxhAcrQV2AkZmPQjzPDjgVlQtR0EQjxZPyJ0BnMf3in1ryuR8A2qU0HldVRfxYXbFSKlI3N7Slw==} peerDependencies: @@ -13605,9 +13572,6 @@ packages: ssr-window@3.0.0: resolution: {integrity: sha512-q+8UfWDg9Itrg0yWK7oe5p/XRCJpJF9OBtXfOPgSJl+u3Xd5KI328RUEvUqSMVM9CiQUEf1QdBzJMkYGErj9QA==} - ssr-window@4.0.2: - resolution: {integrity: sha512-ISv/Ch+ig7SOtw7G2+qkwfVASzazUnvlDTwypdLoPoySv+6MqlOV10VwPSE6EWkGjhW50lUmghPmpYZXMu/+AQ==} - stack-trace@0.0.10: resolution: {integrity: sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==} @@ -13879,10 +13843,6 @@ packages: resolution: {integrity: sha512-zCfvWn7H7mCq7jgVurckhAwkjPUeMCkdC4rA7lagvaD3mIrNhKiaYYo2+nkxMVpiaWuCQ38e44Mya/dKb7HpyQ==} engines: {node: '>= 4.7.0'} - swiper@8.4.7: - resolution: {integrity: sha512-VwO/KU3i9IV2Sf+W2NqyzwWob4yX9Qdedq6vBtS0rFqJ6Fa5iLUJwxQkuD4I38w0WDJwmFl8ojkdcRFPHWD+2g==} - engines: {node: '>= 4.7.0'} - symbol-observable@1.2.0: resolution: {integrity: sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==} engines: {node: '>=0.10.0'} @@ -14163,15 +14123,6 @@ packages: typedarray-to-buffer@3.1.5: resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==} - typescript-compare@0.0.2: - resolution: {integrity: sha512-8ja4j7pMHkfLJQO2/8tut7ub+J3Lw2S3061eJLFQcvs3tsmJKp8KG5NtpLn7KcY2w08edF74BSVN7qJS0U6oHA==} - - typescript-logic@0.0.0: - resolution: {integrity: sha512-zXFars5LUkI3zP492ls0VskH3TtdeHCqu0i7/duGt60i5IGPIpAHE/DWo5FqJ6EjQ15YKXrt+AETjv60Dat34Q==} - - typescript-tuple@2.2.1: - resolution: {integrity: sha512-Zcr0lbt8z5ZdEzERHAMAniTiIKerFCMgd7yjq1fPnDJ43et/k9twIFQMUYff9k5oXcsQ0WpvFcgzK2ZKASoW6Q==} - typescript@5.0.4: resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} engines: {node: '>=12.20'} @@ -17018,31 +16969,6 @@ snapshots: react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - '@redux-saga/core@1.3.0': - dependencies: - '@babel/runtime': 7.24.7 - '@redux-saga/deferred': 1.2.1 - '@redux-saga/delay-p': 1.2.1 - '@redux-saga/is': 1.1.3 - '@redux-saga/symbols': 1.1.3 - '@redux-saga/types': 1.2.1 - typescript-tuple: 2.2.1 - - '@redux-saga/deferred@1.2.1': {} - - '@redux-saga/delay-p@1.2.1': - dependencies: - '@redux-saga/symbols': 1.1.3 - - '@redux-saga/is@1.1.3': - dependencies: - '@redux-saga/symbols': 1.1.3 - '@redux-saga/types': 1.2.1 - - '@redux-saga/symbols@1.1.3': {} - - '@redux-saga/types@1.2.1': {} - '@remix-run/router@1.14.0': {} '@remix-run/router@1.2.1': {} @@ -22023,10 +21949,6 @@ snapshots: dependencies: ssr-window: 3.0.0 - dom7@4.0.6: - dependencies: - ssr-window: 4.0.2 - domelementtype@1.3.1: {} domelementtype@2.3.0: {} @@ -26398,10 +26320,6 @@ snapshots: indent-string: 4.0.0 strip-indent: 3.0.0 - redux-saga@1.3.0: - dependencies: - '@redux-saga/core': 1.3.0 - redux-thunk@2.3.0(redux@4.0.5): dependencies: redux: 4.0.5 @@ -26984,8 +26902,6 @@ snapshots: ssr-window@3.0.0: {} - ssr-window@4.0.2: {} - stack-trace@0.0.10: {} stack-utils@2.0.6: @@ -27290,11 +27206,6 @@ snapshots: dom7: 3.0.0 ssr-window: 3.0.0 - swiper@8.4.7: - dependencies: - dom7: 4.0.6 - ssr-window: 4.0.2 - symbol-observable@1.2.0: {} symbol-tree@3.2.4: {} @@ -27585,16 +27496,6 @@ snapshots: dependencies: is-typedarray: 1.0.0 - typescript-compare@0.0.2: - dependencies: - typescript-logic: 0.0.0 - - typescript-logic@0.0.0: {} - - typescript-tuple@2.2.1: - dependencies: - typescript-compare: 0.0.2 - typescript@5.0.4: {} uc.micro@2.1.0: {} diff --git a/projects/packages/jetpack-mu-wpcom/.gitattributes b/projects/packages/jetpack-mu-wpcom/.gitattributes index bb39b0ced174e..4aa9283e17c75 100644 --- a/projects/packages/jetpack-mu-wpcom/.gitattributes +++ b/projects/packages/jetpack-mu-wpcom/.gitattributes @@ -6,8 +6,7 @@ package.json export-ignore # Files to include in the mirror repo, but excluded via gitignore # Remember to end all directories with `/**` to properly tag every file. # /src/js/example.min.js production-include -src/build/** production-include -src/features/newspack-blocks/synced-newspack-blocks/** production-include +src/build/** production-include # Files to exclude from the mirror repo, but included in the monorepo. # Remember to end all directories with `/**` to properly tag every file. diff --git a/projects/packages/jetpack-mu-wpcom/.gitignore b/projects/packages/jetpack-mu-wpcom/.gitignore index 4a17a341d86cd..b8c2e07945268 100644 --- a/projects/packages/jetpack-mu-wpcom/.gitignore +++ b/projects/packages/jetpack-mu-wpcom/.gitignore @@ -5,4 +5,3 @@ node_modules/ wordpress/ playwright-report/ src/features/help-center/languages/ -src/features/newspack-blocks/synced-newspack-blocks diff --git a/projects/packages/jetpack-mu-wpcom/.phan/config.php b/projects/packages/jetpack-mu-wpcom/.phan/config.php index d2fb4ef5f636c..1c6422d32b63f 100644 --- a/projects/packages/jetpack-mu-wpcom/.phan/config.php +++ b/projects/packages/jetpack-mu-wpcom/.phan/config.php @@ -33,9 +33,6 @@ // This file breaks analysis, Phan gets lost recursing in trying to figure out some types. // @todo Add type declarations so Phan won't have to do it itself. Or update to a modern less lib. 'src/features/custom-css/custom-css/preprocessors/lessc.inc.php', - - // The synced newspack blocks files break analysis. - 'src/features/newspack-blocks/synced-newspack-blocks', ), ) ); diff --git a/projects/packages/jetpack-mu-wpcom/.phpcs.dir.xml b/projects/packages/jetpack-mu-wpcom/.phpcs.dir.xml index a9493cb9481de..07259f7161752 100644 --- a/projects/packages/jetpack-mu-wpcom/.phpcs.dir.xml +++ b/projects/packages/jetpack-mu-wpcom/.phpcs.dir.xml @@ -16,9 +16,7 @@ - - - + diff --git a/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks-formatter.js b/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks-formatter.js deleted file mode 100644 index 46fbbff4156d4..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks-formatter.js +++ /dev/null @@ -1,46 +0,0 @@ -module.exports = function transformer( file, api ) { - const j = api.jscodeshift; - - return j( file.source ) - .find( j.ConditionalExpression ) - .filter( path => { - const { consequent, alternate } = path.value; - - // Check if the consequent or alternate is a function call to targetFunctionName - return ( - isFunctionCallWithName( consequent, '__' ) || isFunctionCallWithName( alternate, '__' ) - ); - } ) - .forEach( path => { - const { alternate } = path.value; - - // Add the new argument to the alternate function call - const newAlternateArguments = [ - ...alternate.arguments, - j.literal( 0 ), // Create a literal AST node for the new argument - ]; - - // Create a new CallExpression node with the updated arguments - const newAlternate = j.callExpression( alternate.callee, newAlternateArguments ); - - // Update the alternate branch of the ternary expression - path.value.alternate = newAlternate; - } ) - .toSource(); -}; - -/** - * Whether the node is a function call with the specific name - * - * @param node - The AST node - * @param functionName - The function name we want to check - */ -function isFunctionCallWithName( node, functionName ) { - return ( - node && - node.type === 'CallExpression' && - node.callee && - node.callee.type === 'Identifier' && - node.callee.name === functionName - ); -} diff --git a/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh b/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh deleted file mode 100755 index 319249c9a6aa6..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env bash - -# sed -i behaves differently between macos and linux platforms. -# See https://stackoverflow.com/a/51060063 -# To use this, do `sed "${sedi[@]}" -e $sed_expression` -sedi=(-i) -# macOS version of sed doesn't support `--version` param and exits with code 1 -sed --version > /dev/null 2>&1 -if [ $? -eq 1 ] -then - # For macOS, use two parameters - sedi=(-i "") -fi - -# pick up value considering that the argument -# has the --key=value shape. -key_value=$(echo ${1} | cut -d'=' -f 2) -# Set mode depending on first argument -if [[ $1 =~ ^--release= ]] -then - MODE=release - NAME=${key_value} - URL=https://github.com/Automattic/newspack-blocks/releases/download/$NAME/newspack-blocks.zip -elif [[ $1 =~ ^--branch= ]] -then - MODE=branch - NAME=${key_value} - URL=https://github.com/Automattic/newspack-blocks/archive/$NAME.zip -elif [[ $1 =~ ^--path= ]] -then - MODE=path -elif [[ $1 =~ ^--nodemodules ]] -# try whether user passed --nodemodules -then - MODE=npm -fi - -# print usage is no mode matched -if [ -z "$MODE" ] -then - echo "Usage: pnpm run sync:newspack-blocks [arguments]" - echo - echo Possible arguments: - echo --branch=master - echo "--nodemodules (to use defined in package.json)" - echo "--path=/path/to/newspack-blocks" - echo --release=v2.0.0 - echo - echo You can find the latest release ID on https://github.com/Automattic/newspack-blocks/releases/latest - echo - exit 1 -fi - -TARGET=./src/features/newspack-blocks/synced-newspack-blocks -ENTRY=./src/features/newspack-blocks/index.php - -if [[ ( "$MODE" != "path" ) && ( "$MODE" != "npm" ) ]]; -then - # return early if the version is the same - if [ -f $TARGET/package.json ]; then - CURRENT_VERSION=v`jq -r .version $TARGET/package.json` - - if [[ "$CURRENT_VERSION" == "$NAME" ]]; then - echo "The current version $CURRENT_VERSION of the newspack-blocks is synced." - exit 0 - fi - fi - - # make a temp directory - TEMP_DIR=`mktemp -d` - CODE=$TEMP_DIR/code - - # download zip file - echo Downloading $MODE $NAME into $TEMP_DIR - (cd $TEMP_DIR && curl -L --fail -s -O $URL) - - # handle download error - ZIPS=( $TEMP_DIR/*.zip ) - ZIP=${ZIPS[0]} - if [ ! -f "$ZIP" ]; then - echo "Tried to download $URL" - echo - echo "Error: Could not download the zip file." - if [ "$MODE" = 'release' ]; then - echo Is the release ID correct? Does the release contain artifact newspack-blocks.zip? - else - echo Is the branch name correct? - fi - exit 1 - fi - - # extract zip - echo Extracting into $CODE - mkdir -p $CODE - unzip -q $ZIP -d $CODE - - # find the main file and use its directory as the root of our source dir - MAIN_FILE=`find $CODE -name "newspack-blocks.php"` - CODE=`dirname $MAIN_FILE` - - # handle unzip error - if [ ! -f "$CODE/newspack-blocks.php" ]; then - echo - echo "Error: Could not extract files from newspack-blocks.zip" - exit 1 - fi -elif [ "$MODE" = "path" ] ; then - CODE=${key_value} -elif [ "$MODE" = "npm" ] ; then - # Way back to wp-calypso root: - CODE="../../node_modules/@automattic/newspack-blocks" -fi - -if [ ! -d "$CODE" ] ; then - echo "Nothing at the specified path to the code ($CODE)." - exit 1 -fi - -echo Syncing files to jetpack-mu-wpcom... - -# Remove the target dir so that we start on a clean slate. -rm -rf "$TARGET" - -# ensure target dirs exist -mkdir -p $TARGET/blocks -mkdir -p $TARGET/components -mkdir -p $TARGET/shared -mkdir -p $TARGET/types - -# copy files and directories -cp $CODE/package.json $TARGET/ -cp $CODE/includes/class-newspack-blocks-api.php $TARGET/ -cp $CODE/includes/class-newspack-blocks.php $TARGET/ -cp -R $CODE/src/blocks/homepage-articles $TARGET/blocks/ -cp -R $CODE/src/blocks/carousel $TARGET/blocks/ -cp -R $CODE/src/shared $TARGET/ -cp -R $CODE/src/components $TARGET/ - -# Get Typescript working by copying the main type defs over. -cp $CODE/src/types/index.d.ts $TARGET/types/ -# Function types need to be capitalized in our system. We only match " function" -# beginning with a space to avoid matching it as a substring. (Not perfect, but -# imperfections will be caught by CI with failing tsc, etc.) -sed "${sedi[@]}" -e "s| function| Function|g" "$TARGET/types/index.d.ts" - -# Note: I would have used eslint-nibble, but it doesn't support autofixing via the CLI. -echo "Changing JS textdomain to match jetpack-mu-wpcom..." -pnpm --package=eslint@8.57.0 dlx eslint --no-ignore --rule '"@wordpress/i18n-text-domain":["error",{"allowedTextDomain":"jetpack-mu-wpcom"}]' --fix $TARGET > /dev/null - -echo "Changing JS translation function call to avoid bad minification..." -pnpm --package=jscodeshift dlx jscodeshift -t ./bin/sync-newspack-blocks-formatter.js --extensions=js $TARGET - -echo "Changing PHP textdomain to match jetpack-mu-wpcom..." -../../../vendor/bin/phpcbf --standard=./.phpcs.dir.xml --filter=../../../vendor/automattic/jetpack-phpcs-filter/src/PhpcsFilter.php --runtime-set jetpack-filter-no-ignore -q $TARGET - -echo Sync done. diff --git a/projects/packages/jetpack-mu-wpcom/package.json b/projects/packages/jetpack-mu-wpcom/package.json index 2e0df8f63149c..8bc5ab1db2c16 100644 --- a/projects/packages/jetpack-mu-wpcom/package.json +++ b/projects/packages/jetpack-mu-wpcom/package.json @@ -19,12 +19,10 @@ "build-js": "pnpm clean && webpack", "build-production": "echo 'Not implemented.'", "build-production-js": "NODE_ENV=production BABEL_ENV=production pnpm build-js", - "postinstall": "pnpm run sync:newspack-blocks", "lint": "eslint --ext .js,.jsx,.cjs,.mjs,.ts,.tsx .", "clean": "rm -rf src/build/", "watch": "pnpm run build-production-js && pnpm webpack watch", - "e2e-tests": "playwright test --config src/features/verbum-comments/playwright.config.ts", - "sync:newspack-blocks": "./bin/sync-newspack-blocks.sh --release=v3.5.0" + "e2e-tests": "playwright test --config src/features/verbum-comments/playwright.config.ts" }, "optionalDependencies": { "react": "^18.2.0", @@ -40,7 +38,6 @@ "@types/react": "^18.2.28", "@types/react-dom": "18.3.0", "babel-plugin-transform-rename-properties": "0.1.0", - "pkg-dir": "^5.0.0", "sass": "1.64.1", "sass-loader": "12.4.0", "typescript": "^5.0.4", @@ -79,8 +76,6 @@ "react-dom": "^18.2.0", "react-popper": "^2.3.0", "redux": "^4.2.1", - "redux-saga": "^1.3.0", - "swiper": "^8.4.5", "wpcom-proxy-request": "^7.0.3" } } diff --git a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php index 46dffa5819705..5de3cb5afa867 100644 --- a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php +++ b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php @@ -162,7 +162,6 @@ public static function load_etk_features() { require_once __DIR__ . '/features/hide-homepage-title/hide-homepage-title.php'; require_once __DIR__ . '/features/jetpack-global-styles/class-global-styles.php'; require_once __DIR__ . '/features/mailerlite/subscriber-popup.php'; - require_once __DIR__ . '/features/newspack-blocks/index.php'; require_once __DIR__ . '/features/override-preview-button-url/override-preview-button-url.php'; require_once __DIR__ . '/features/paragraph-block-placeholder/paragraph-block-placeholder.php'; require_once __DIR__ . '/features/tags-education/tags-education.php'; diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/README.md b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/README.md deleted file mode 100644 index 8e5e8295c9961..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# Newspack Blocks - -Some of the Newspack blocks were added to this repository in order to make it available to other parts of the FSE plugin, such as Starter Page Templates where these blocks will be used. - -## Block Posts Block - -This block allows you to list your posts in various layouts and filter them by criteria like category, tag or author. - -It originally comes from the [Newspack Blocks collection](https://github.com/automattic/newspack-blocks) and the block is still being developed there. - -## Post Carousel Block - -This block allows you to create a carousel of post's featured images and filter them by criteria like category, tag or author. - -It originally comes from the [Newspack Blocks collection](https://github.com/automattic/newspack-blocks) and the block is still being developed there. - -## Structure - -``` -index.php — main entry file, registers the blocks on backend -blog-posts-block-editor.min.js — assets for the blog-posts-block editor -blog-posts-block-view.min.js — assets for the blog-posts-block rendered on frontend -carousel-block-editor.min.js — assets for the carousel-block editor -carousel-block-view.min.js — assets for the carousel-block rendered on frontend -synced-newspack-blocks/** — source code synced from the Newspack Blocks repository, not tracked in Jetpack git repo -``` - -`blog-posts-block-editor.min.js`, `blog-posts-block-view.min.js`, `carousel-block-editor.min.js`, `carousel-block-view.min.js` and `index.php` are files written in order to bridge the parent plugin with the Newspack Blocks. It changes the block names to an `a8c/` namespace and does things like registering REST fields or styles and scripts. In these files we are free to do all those changes because they are not shared with Newspack and only live here in this repository. - -### Synchronizing the code - -You can see that `synced-newspack-blocks` is being synced with the Newspack Blocks repository. Please make all improvements and additions on the Newspack side. Please don't make any direct changes to files in this directory as the next synchronization will overwrite them. Synced files are not being tracked in git and they are always downloaded fresh using the sync script explained further in this document. - -Once your changes land on the Newspack side, coordinate with the team (over issues/PRs) to [make a new release](https://github.com/Automattic/newspack-blocks/releases) and once you have the release ID, you can pull the code into here. - -While being in `projects/packages/jetpack-mu-wpcom` directory, you can run: - -``` -pnpm run sync:newspack-blocks -``` - -This will pull the code from the release and integrate it into this repository. Please review changes, make sure to update `NEWSPACK_BLOCKS__VERSION` in [index.php](./index.php) and commit. - -### Local development - -Sometimes, probably, you will need to sync the NHA code straight in your local environment. It means you will get working on both projects at the same time. For this situation, you'd like to reference the code source through the `path` bin script argument. - -``` -pnpm run sync:newspack-blocks --path=/Absolute/path/of/newspack-blocks/ -``` diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/blog-posts/editor.js b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/blog-posts/editor.js deleted file mode 100644 index 747ad9a856587..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/blog-posts/editor.js +++ /dev/null @@ -1,36 +0,0 @@ -import { registerBlockType } from '@wordpress/blocks'; -import { addFilter } from '@wordpress/hooks'; -import { __ } from '@wordpress/i18n'; -import { CAROUSEL_BLOCK_NAME } from '../consts'; -import { settings } from '../synced-newspack-blocks/blocks/homepage-articles'; -import { registerQueryStore } from '../synced-newspack-blocks/blocks/homepage-articles/store'; - -/** - * Block name in the A8C\FSE context. - */ -const blockName = 'a8c/blog-posts'; - -/** - * Set the name of the block transformation - * - * @param name - The name of the block - */ -function setBlockTransformationName( name ) { - return name !== 'newspack-blocks/homepage-articles' ? name : blockName; -} - -addFilter( - 'blocks.transforms_from_name', - 'set-transformed-block-name', - setBlockTransformationName -); - -registerBlockType( blockName, { - ...settings, - title: __( 'Blog Posts', 'jetpack-mu-wpcom' ), - category: 'widgets', -} ); - -// The Blog Posts block and Carousel block should use the same store, so that deduplication is handled -// between these blocks. -registerQueryStore( [ blockName, CAROUSEL_BLOCK_NAME ] ); diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/blog-posts/view.js b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/blog-posts/view.js deleted file mode 100644 index 6a58b21d1e329..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/blog-posts/view.js +++ /dev/null @@ -1 +0,0 @@ -import '../synced-newspack-blocks/blocks/homepage-articles/view'; diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/carousel/editor.js b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/carousel/editor.js deleted file mode 100644 index 5bef920682dc0..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/carousel/editor.js +++ /dev/null @@ -1,24 +0,0 @@ -import { registerBlockType } from '@wordpress/blocks'; -import { addFilter } from '@wordpress/hooks'; -import { CAROUSEL_BLOCK_NAME } from '../consts'; -import { settings } from '../synced-newspack-blocks/blocks/carousel'; - -/** - * Set the name of the block transformation - * - * @param name - The name of the block - */ -function setBlockTransformationName( name ) { - return name !== 'newspack-blocks/carousel' ? name : CAROUSEL_BLOCK_NAME; -} - -addFilter( - 'blocks.transforms_from_name', - 'set-transformed-block-name', - setBlockTransformationName -); - -registerBlockType( CAROUSEL_BLOCK_NAME, { - ...settings, - category: 'widgets', -} ); diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/carousel/view.js b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/carousel/view.js deleted file mode 100644 index 12fdf0189d6c9..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/carousel/view.js +++ /dev/null @@ -1 +0,0 @@ -import '../synced-newspack-blocks/blocks/carousel/view'; diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/consts.js b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/consts.js deleted file mode 100644 index 97a6195f06502..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/consts.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Block name in the A8C\FSE context. - */ -export const CAROUSEL_BLOCK_NAME = 'a8c/posts-carousel'; diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/index.php b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/index.php deleted file mode 100644 index 20a813374aee5..0000000000000 --- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/index.php +++ /dev/null @@ -1,122 +0,0 @@ -register_routes(); -} -add_action( 'rest_api_init', __NAMESPACE__ . '\register_rest_routes' ); - -/** - * Filters block name. - * - * @param string $name Block name. - * @return string - */ -function blog_posts_block_name( $name ) { - if ( 'newspack-blocks/homepage-articles' === $name ) { - return 'a8c/blog-posts'; - } - - if ( 'newspack-blocks/carousel' === $name ) { - return 'a8c/posts-carousel'; - } - - return $name; -} -add_filter( 'newspack_blocks_block_name', __NAMESPACE__ . '\blog_posts_block_name' ); - -/** - * Enqueue the data of the newspack blocks. - * - * @param string $handle The name of the script to add the data of the newspack blocks to. - */ -function enqueue_newspack_blocks_data( $handle ) { - $newspack_blocks_data = wp_json_encode( - array( - 'posts_rest_url' => rest_url( 'newspack-blocks/v1/newspack-blocks-posts' ), - 'specific_posts_rest_url' => rest_url( 'newspack-blocks/v1/newspack-blocks-specific-posts' ), - // Define URL to core one to make autocomplete working for newspack-blocks installed via jetpack-mu-wpcom. - 'authors_rest_url' => rest_url() . 'wp/v2/users', - 'custom_taxonomies' => array(), - ) - ); - - wp_add_inline_script( - $handle, - "window.newspack_blocks_data = window.newspack_blocks_data ?? $newspack_blocks_data;", - 'before' - ); -} - -/** - * Can be used to disable the Blog Posts Block. - */ -$disable_blog_posts_block = apply_filters( 'a8c_disable_blog_posts_block', false ); -if ( ! $disable_blog_posts_block ) { - require_once __DIR__ . '/synced-newspack-blocks/blocks/homepage-articles/view.php'; - - add_action( - 'newspack_blocks_render_homepage_articles', - function () { - if ( ! is_admin() ) { - \jetpack_mu_wpcom_enqueue_assets( 'newspack-blocks-blog-posts-view', array( 'js', 'css' ) ); - } - } - ); - - add_action( - is_admin() ? 'enqueue_block_assets' : 'enqueue_block_editor_assets', - function () { - $handle = \jetpack_mu_wpcom_enqueue_assets( 'newspack-blocks-blog-posts-editor', array( 'js', 'css' ) ); - enqueue_newspack_blocks_data( $handle ); - wp_set_script_translations( $handle, 'jetpack-mu-wpcom' ); - } - ); -} - -/** - * Can be used to disable the Post Carousel Block. - */ -$disable_posts_carousel_block = apply_filters( 'a8c_disable_posts_carousel_block', false ) || apply_filters( 'a8c_disable_post_carousel_block', false ); -if ( ! $disable_posts_carousel_block ) { - require_once __DIR__ . '/synced-newspack-blocks/blocks/carousel/view.php'; - - add_action( - 'newspack_blocks_render_post_carousel', - function () { - if ( ! is_admin() ) { - \jetpack_mu_wpcom_enqueue_assets( 'newspack-blocks-carousel-view', array( 'js', 'css' ) ); - } - } - ); - - add_action( - is_admin() ? 'enqueue_block_assets' : 'enqueue_block_editor_assets', - function () { - $handle = \jetpack_mu_wpcom_enqueue_assets( 'newspack-blocks-carousel-editor', array( 'js', 'css' ) ); - enqueue_newspack_blocks_data( $handle ); - wp_set_script_translations( $handle, 'jetpack-mu-wpcom' ); - } - ); -} diff --git a/projects/packages/jetpack-mu-wpcom/src/utils.php b/projects/packages/jetpack-mu-wpcom/src/utils.php index 5a55dcf9d8d81..93bce198060c1 100644 --- a/projects/packages/jetpack-mu-wpcom/src/utils.php +++ b/projects/packages/jetpack-mu-wpcom/src/utils.php @@ -87,8 +87,6 @@ function wpcom_get_calypso_origin() { * * @param string $asset_name The name of the asset. * @param array $asset_types The types of the asset. - * - * @return string */ function jetpack_mu_wpcom_enqueue_assets( $asset_name, $asset_types = array() ) { $asset_handle = "jetpack-mu-wpcom-$asset_name"; diff --git a/projects/packages/jetpack-mu-wpcom/webpack.config.js b/projects/packages/jetpack-mu-wpcom/webpack.config.js index cfdb59d970f19..4ac6d3c108575 100644 --- a/projects/packages/jetpack-mu-wpcom/webpack.config.js +++ b/projects/packages/jetpack-mu-wpcom/webpack.config.js @@ -1,7 +1,6 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const path = require( 'path' ); const jetpackWebpackConfig = require( '@automattic/jetpack-webpack-config/webpack' ); -const pkgDir = require( 'pkg-dir' ); const verbumConfig = require( './verbum.webpack.config.js' ); module.exports = [ @@ -21,10 +20,6 @@ module.exports = [ 'jetpack-global-styles-customizer-fonts': './src/features/jetpack-global-styles/customizer-fonts/index.js', 'mailerlite-subscriber-popup': './src/features/mailerlite/subscriber-popup.js', - 'newspack-blocks-blog-posts-editor': './src/features/newspack-blocks/blog-posts/editor.js', - 'newspack-blocks-blog-posts-view': './src/features/newspack-blocks/blog-posts/view.js', - 'newspack-blocks-carousel-editor': './src/features/newspack-blocks/carousel/editor.js', - 'newspack-blocks-carousel-view': './src/features/newspack-blocks/carousel/view.js', 'override-preview-button-url': './src/features/override-preview-button-url/override-preview-button-url.js', 'paragraph-block-placeholder': @@ -63,8 +58,6 @@ module.exports = [ alias: { ...jetpackWebpackConfig.resolve.alias, '@automattic/calypso-config': '@automattic/calypso-config/src/client.js', - /** Replace the classnames used by @automattic/newspack-blocks with clsx because we changed to use clsx */ - classnames: findPackage( 'clsx' ), }, }, node: false, @@ -109,22 +102,3 @@ module.exports = [ }, }, ]; - -/** - * Given a package name, finds the absolute path for it. - * - * require.resolve() will resolve to the main file of the package, using Node's resolution algorithm to find - * a `package.json` and looking at the field `main`. This function will return the folder that contains `package.json` - * instead of trying to resolve the main file. - * - * Example: `@wordpress/data` may resolve to `/home/myUser/wp-calypso/node_modules/@wordpress/data`. - * - * Note this is not the same as looking for `__dirname+'/node_modules/'+pkgName`, as the package may be in a parent - * `node_modules` - * @param {string} pkgName - Name of the package to search for. - */ -function findPackage( pkgName ) { - const fullPath = require.resolve( pkgName ); - const packagePath = pkgDir.sync( fullPath ); - return packagePath; -} diff --git a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks b/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks deleted file mode 100644 index 9aa70e3ec1f75..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: changed -Comment: Updated composer.lock. - - diff --git a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#2 b/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#2 deleted file mode 100644 index 9aa70e3ec1f75..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#2 +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: changed -Comment: Updated composer.lock. - - diff --git a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#3 b/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#3 deleted file mode 100644 index 9aa70e3ec1f75..0000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/mu-wpcom-newspack-blocks#3 +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: changed -Comment: Updated composer.lock. - - From 7d7ad0318e1c27c19a0bb511a78aab2e383f9eb5 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Mon, 5 Aug 2024 19:44:43 +0300 Subject: [PATCH 2/3] Changelog. --- .../changelog/revert-38454-mu-wpcom-newspack-blocks | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/revert-38454-mu-wpcom-newspack-blocks diff --git a/projects/packages/jetpack-mu-wpcom/changelog/revert-38454-mu-wpcom-newspack-blocks b/projects/packages/jetpack-mu-wpcom/changelog/revert-38454-mu-wpcom-newspack-blocks new file mode 100644 index 0000000000000..451984b4a040b --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/revert-38454-mu-wpcom-newspack-blocks @@ -0,0 +1,5 @@ +Significance: patch +Type: removed +Comment: Reverted a previous change. + + From a4e738bc53a8b7f6c4ab682c9d42f0e02fa95776 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Mon, 5 Aug 2024 19:50:52 +0300 Subject: [PATCH 3/3] Fixed versions. --- projects/packages/jetpack-mu-wpcom/package.json | 2 +- .../packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/packages/jetpack-mu-wpcom/package.json b/projects/packages/jetpack-mu-wpcom/package.json index 8bc5ab1db2c16..43e335f667483 100644 --- a/projects/packages/jetpack-mu-wpcom/package.json +++ b/projects/packages/jetpack-mu-wpcom/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-mu-wpcom", - "version": "5.53.0", + "version": "5.53.1-alpha", "description": "Enhances your site with features powered by WordPress.com", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/jetpack-mu-wpcom/#readme", "bugs": { diff --git a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php index 5de3cb5afa867..9b1c1cf3fb217 100644 --- a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php +++ b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php @@ -13,7 +13,7 @@ * Jetpack_Mu_Wpcom main class. */ class Jetpack_Mu_Wpcom { - const PACKAGE_VERSION = '5.53.0'; + const PACKAGE_VERSION = '5.53.1-alpha'; const PKG_DIR = __DIR__ . '/../'; const BASE_DIR = __DIR__ . '/'; const BASE_FILE = __FILE__;