Skip to content

Commit

Permalink
Merge pull request #4438 from wordpress-mobile/release/1.69.0
Browse files Browse the repository at this point in the history
Release 1.69.0
  • Loading branch information
ttahmouch authored Jan 8, 2022
2 parents b3e9d75 + abb4678 commit 738ebcc
Show file tree
Hide file tree
Showing 176 changed files with 13,509 additions and 4,649 deletions.
22 changes: 11 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ commands:
- restore_cache:
name: Restore NPM Cache
keys:
- npm-i18n-v4-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
- npm-i18n-v4-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-
- npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
- npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-
- run:
name: NPM Install
command: |
echo "Node version: $(node --version)"
npm ci --prefer-offline --no-audit
- save_cache:
name: Save NPM Cache
key: npm-i18n-v4-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
key: npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
paths:
- ~/.npm
- i18n-cache/data
Expand All @@ -27,16 +27,16 @@ commands:
- restore_cache:
name: Restore NPM Cache
keys:
- npm-i18n-v4-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "gutenberg/package-lock.json" }}
- npm-i18n-v4-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-
- npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "gutenberg/package-lock.json" }}
- npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-
- run:
name: NPM Install Full
command: |
echo "Node version: $(node --version)"
npm install --no-audit
- save_cache:
name: Save NPM Cache
key: npm-i18n-v4-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "gutenberg/package-lock.json" }}
key: npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "gutenberg/package-lock.json" }}
paths:
- ~/.npm
- i18n-cache/data
Expand Down Expand Up @@ -282,16 +282,16 @@ jobs:
- restore_cache:
name: Restore Dependencies Cache
keys:
- dependencies-v4-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}-{{ checksum "gutenberg/package-lock.json" }}
- dependencies-v4-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}
- dependencies-v4-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}
- dependencies-v4-
- dependencies-v5-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}-{{ checksum "gutenberg/package-lock.json" }}
- dependencies-v5-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}
- dependencies-v5-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}
- dependencies-v5-
- run:
name: Build (if needed)
command: test -e gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app || npm run core test:e2e:build-app:ios
- save_cache:
name: Save Dependencies Cache
key: dependencies-v4-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}-{{ checksum "gutenberg/package-lock.json" }}
key: dependencies-v5-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}-{{ checksum "gutenberg/package-lock.json" }}
paths:
- gutenberg/packages/react-native-editor/ios/Pods
- ~/Library/Caches/CocoaPods
Expand Down
24 changes: 23 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,27 @@ module.exports = {
// do not throw an error if imported dependencies are
// declared in `package.json` or `gutenberg/package.json`
"import/no-extraneous-dependencies": ["error", {"packageDir": ['.', './gutenberg/']}]
}
},
overrides: [
{
// Disable rules for tests as we do in Gutenberg.
// Reference: https://git.io/JSMAQ
files: [ 'src/**/test/**/*.js' ],
rules: {
'import/default': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'import/named': 'off',
'@wordpress/data-no-store-string-literals': 'off',
},
},
{
// Workaround for addressing errors when importing react-native components.
// Related issue: https://git.io/JSKeJ
files: [ 'src/**/*.js' ],
settings: {
'import/ignore': [ 'react-native' ],
},
},
],
};
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
labels: "[Type] Bug"
assignees: ''

---
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/sync-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: sync-android
on:
pull_request:
types: [labeled]
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create a WordPress-Android (WPA) PR containing changes from a Gutenberg Mobile (GBM) PR.
env:
PR: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
npm run sync:android -- "--pr=$PR"
if: ${{ github.event_name == 'pull_request' && github.event.label.name == 'sync:android' }}
- name: Create a WordPress-Android (WPA) PR containing changes from a Gutenberg Mobile (GBM) Tag.
env:
TAG: ${{ github.event.release.tag_name }}
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
npm run sync:android -- "--tag=$TAG"
if: ${{ github.event_name == 'release' }}
9 changes: 9 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
Unreleased
---

1.69.0
---
* [*] Give multi-line block names central alignment in inserter [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4343]
* [**] Fix missing translations by refactoring the editor initialization code [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4332]
* [**] Add Jetpack and Layout Grid translations [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4359]
* [**] Fix text formatting mode lost after backspace is used [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4423]
* [*] Add missing translations of unsupported block editor modal [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4410]

1.68.0
---
* [**] Fix undo/redo functionality in links when applying text format [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4290]
* [**] [iOS] Fix scroll update when typing in RichText component [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4299]
* [*] [Preformatted block] Fix an issue where the background color is not showing up for standard themes [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4292]
* [**] Update Gallery Block to default to the new format and auto-convert old galleries to the new format [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4315]
* [***] Highlight text - enables color customization for specific text within a Paragraph block [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4175]
* [**] Fix empty line appearing when splitting heading blocks on Android 12 [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4365]

1.67.0
---
Expand Down
2 changes: 1 addition & 1 deletion RNTAztecView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Pod::Spec.new do |s|
s.xcconfig = {'OTHER_LDFLAGS' => '-lxml2',
'HEADER_SEARCH_PATHS' => '/usr/include/libxml2'}
s.dependency 'React-Core'
s.dependency 'WordPress-Aztec-iOS', '~> 1.19.6'
s.dependency 'WordPress-Aztec-iOS', '~> 1.19.7'

end
10 changes: 7 additions & 3 deletions bin/generate-podspecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ function warn_missing_tag_commit() {
RED="\033[0;31m"
NO_COLOR="\033[0m"
PODSPEC_HAS_TAG_OR_COMMIT=$(jq '.source | has("tag") or has("commit")' "$DEST/$pod.podspec.json")
if [[ $PODSPEC_HAS_TAG_OR_COMMIT == "false" ]]; then
printf "${RED}WARNING! $pod.podspec doesn't have a 'tag' or 'commit' field. Either modify this script to add a patch during the podspec generation or modify the original $pod.podspec in the source repo.${NO_COLOR}\n"
# If the source points to an HTTP endpoint and SHA, we consider it versioned
PODSPEC_HAS_HTTP_AND_SHA=$(jq '.source | has("http") and (has("sha256") or has("sha1"))' "$DEST/$pod.podspec.json")

if [[ $PODSPEC_HAS_TAG_OR_COMMIT == "false" && $PODSPEC_HAS_HTTP_AND_SHA == "false" ]]; then
printf "${RED}WARNING! $pod.podspec doesn't have a 'tag' or 'commit' field, or doesn't point to a SHA verified file. Either modify this script to add a patch during the podspec generation or modify the original $pod.podspec in the source repo.${NO_COLOR}\n"
exit 1
fi
}
Expand Down Expand Up @@ -51,6 +54,7 @@ EXTERNAL_PODSPECS=$(find "$NODE_MODULES_DIR/react-native/third-party-podspecs" \
"$NODE_MODULES_DIR/@react-native-community/blur" \
"$NODE_MODULES_DIR/@react-native-community/masked-view" \
"$NODE_MODULES_DIR/@react-native-community/slider" \
"$NODE_MODULES_DIR/@react-native-clipboard/clipboard" \
"$NODE_MODULES_DIR/react-native-gesture-handler" \
"$NODE_MODULES_DIR/react-native-get-random-values" \
"$NODE_MODULES_DIR/react-native-keyboard-aware-scroll-view" \
Expand Down Expand Up @@ -130,7 +134,7 @@ do
# They are normally generated during compile time using a Script Phase in FBReactNativeSpec added via the `use_react_native_codegen` function.
# This script is inside node_modules/react-native/scripts folder. Since we don't have the node_modules when compiling WPiOS,
# we're calling the script here manually to generate these files ahead of time.
CODEGEN_MODULES_OUTPUT_DIR=$DEST/FBReactNativeSpec ./scripts/generate-specs.sh
MODULES_OUTPUT_DIR=$DEST/FBReactNativeSpec ./scripts/generate-specs.sh

# Removing 'script_phases' that shouldn't be needed anymore.
# Removing 'prepare_command' that includes additional steps to create intermediate folders to keep generated files which won't be needed.
Expand Down
127 changes: 127 additions & 0 deletions bin/i18n-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/bin/bash
#
# Handles the process of updating the i18n localizations of plugins, including Gutenberg.
# The main goals of this command are:
#
# 1. Download translation files and optimize them by filtering out the unused strings,
# previously extracted from the source map files of React Native bundle.
#
# This step produces the following output files:
# - src/i18n-cache/{PLUGIN_NAME}/data/{LOCALE}.json [Translation files]
# - src/i18n-cache/{PLUGIN_NAME}/data/index.js [JS file to import translations]
#
# 2. Generate localization strings files that include the strings only used in native JS
# source code files ("native.js", "ios.js or "android.js"). The translations of these
# strings are not included in the GlotPress projects of their plugins hence, they require
# to be requested as part of the main apps’ strings.
#
# This step produces the following output files:
# - bundle/android/strings.xml [Localization strings files for Android platform]
# - bundle/ios/GutenbergNativeTranslations.swift [Localization strings files for iOS platform]

# Exit if any command fails
set -euo pipefail

# Get arguments
while test $# -gt 0; do
case "$1" in
-h|--help)
echo "options:"
echo "-h, --help show brief help"
echo "-p, --path local path for generating files (by default a temp folder will be used)"
echo "-d, --debug print extra info for debugging"
exit 0
;;
-p|--path*)
shift
LOCAL_PATH=$1
shift
;;
-d|--debug*)
shift
DEBUG='true'
;;
*)
break
;;
esac
done

function error() {
echo -e "\033[0;31m$1\033[0m"
exit 1
}

function arrayLength() { echo "$#"; }

function fetch_translations() {
local plugin_name=$1
local output_path=$2
local used_strings_file=$3

echo -e "\n\033[1mDownload I18n translations for \"$plugin_name\" plugin\033[0m"
node gutenberg/packages/react-native-editor/bin/i18n-translations-download "$plugin_name" "$output_path" "$used_strings_file"

if [[ "$plugin_name" == "gutenberg" ]]; then
echo "Update \"react-native-editor\" package i18n cache"
cp -r "$output_path/gutenberg/data" gutenberg/packages/react-native-editor/i18n-cache
cp "$output_path/gutenberg/index.js" gutenberg/packages/react-native-editor/i18n-cache/index.native.js
fi
}

# Set target path
if [[ -n "${LOCAL_PATH:-}" ]]; then
TARGET_PATH=$LOCAL_PATH
else
TARGET_PATH=$(mktemp -d)
trap '{ rm -rf -- "$TARGET_PATH"; }' EXIT
fi

# Get parameters
PLUGINS=( "$@" )

echo -e "\n\033[1m== Updating i18n localizations ==\033[0m"

# Validate parameters
if [[ $((${#PLUGINS[@]}%2)) -ne 0 ]]; then
error "Plugin arguments must be supplied as tuples (i.e. domain path/to/plugin)."
fi

for (( index=0; index<${#PLUGINS[@]}; index+=2 )); do
PLUGIN_FOLDER=${PLUGINS[index+1]}

if [[ ! -d $PLUGIN_FOLDER ]]; then
NOT_FOUND_PLUGIN_FOLDERS+=( $PLUGIN_FOLDER )
echo -e "\033[0;31mPlugin folder \"$PLUGIN_FOLDER\" doesn't exist.\033[0m"
fi
done
if [[ $(arrayLength "${NOT_FOUND_PLUGIN_FOLDERS[@]+"${NOT_FOUND_PLUGIN_FOLDERS[@]}"}") -gt 0 ]]; then
exit 1
fi

# Set used strings target
USED_STRINGS_PATH="$TARGET_PATH/used-strings.json"

# Build Gutenberg
echo -e "\n\033[1mBuild Gutenberg packages\033[0m"
npm run build:gutenberg

# Extract used strings for plugins
METRO_CONFIG="metro.config.js" node gutenberg/packages/react-native-editor/bin/extract-used-strings "$USED_STRINGS_PATH" "${PLUGINS[@]}"

# Download translations of plugins (i.e. Jetpack)
TRANSLATIONS_OUTPUT_PATH="src/i18n-cache"
for (( index=0; index<${#PLUGINS[@]}; index+=2 )); do
PLUGIN_NAME=${PLUGINS[index]}

fetch_translations "$PLUGIN_NAME" "$TRANSLATIONS_OUTPUT_PATH" "$USED_STRINGS_PATH"
done

# Download translations of Gutenberg
fetch_translations "gutenberg" "$TRANSLATIONS_OUTPUT_PATH" "$USED_STRINGS_PATH"

echo -e "\n\033[1mGenerating localization strings files\033[0m"

# Generate localization strings files
./bin/strings2android.js bundle/android/strings.xml "$USED_STRINGS_PATH"
./bin/strings2swift.js bundle/ios/GutenbergNativeTranslations.swift "$USED_STRINGS_PATH"
17 changes: 10 additions & 7 deletions bin/po2android.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ const getUniqueName = ( function() {
};
}() );

function po2Android( poInput ) {
const po = gettextParser.po.parse( poInput );
const translations = po.translations[ '' ];
function po2Android( potFilesContent ) {
const translations = potFilesContent.reduce( (result, content) => {
const po = gettextParser.po.parse( content );
return { ...result, ...po.translations[ '' ] };
}, {});

const androidResourcesMap = Object.values( translations ).reduce( ( result, translation ) => {
if ( ! translation.msgid ) {
return result;
Expand Down Expand Up @@ -117,10 +120,10 @@ ${ indent }</string-array>

if ( require.main === module ) {
if ( process.stdin.isTTY ) {
const potFileName = process.argv[ 2 ];
const destination = process.argv[ 3 ];
const potFileContent = fs.readFileSync( potFileName );
const xmlOutput = po2Android( potFileContent, process.argv[ 3 ] );
const destination = process.argv[ 2 ];
const potFiles = process.argv.slice( 3 );
const potFilesContent = potFiles.map( (file) => fs.readFileSync( file ) );
const xmlOutput = po2Android( potFilesContent );
fs.writeFileSync( destination, xmlOutput );
} else {
let inputData = '';
Expand Down
17 changes: 10 additions & 7 deletions bin/po2swift.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
const gettextParser = require( 'gettext-parser' ),
fs = require( 'fs' );

function po2Swift( poInput ) {
const po = gettextParser.po.parse( poInput );
const translations = po.translations[ '' ];
function po2Swift( potFilesContent ) {
const translations = potFilesContent.reduce( (result, content) => {
const po = gettextParser.po.parse( content );
return { ...result, ...po.translations[ '' ] };
}, {});

const swiftStringsMap = Object.values( translations ).reduce( ( result, translation ) => {
if ( ! translation.msgid ) {
return result;
Expand All @@ -23,10 +26,10 @@ function po2Swift( poInput ) {

if ( require.main === module ) {
if ( process.stdin.isTTY ) {
const potFileName = process.argv[ 2 ];
const destination = process.argv[ 3 ];
const potFileContent = fs.readFileSync( potFileName );
const swiftOutput = po2Swift( potFileContent, process.argv[ 3 ] );
const destination = process.argv[ 2 ];
const potFiles = process.argv.slice( 3 );
const potFilesContent = potFiles.map( (file) => fs.readFileSync( file ) );
const swiftOutput = po2Swift( potFilesContent );
fs.writeFileSync( destination, swiftOutput );
} else {
let inputData = '';
Expand Down
Loading

0 comments on commit 738ebcc

Please sign in to comment.