MDL-76919 editor_tiny: Improve import instructions

This includes a number of changes to improve how we manage the import of
security patches and repeatability of the build.
This commit is contained in:
Andrew Nicols
2023-03-03 10:57:38 +08:00
parent 1f9cf76c53
commit 4113ab2f5e
+93 -22
View File
@@ -1,45 +1,73 @@
# This is a description for the TinyMCE 6 library integration with Moodle.
Please note that we have a clone of the official TinyMCE repository which contains the working build and branch for each release. This ensures build repeatability and gives us the ability to patch stable versions of Moodle for security fixes where relevant.
Each Moodle branch has a similar branch in the https://github.com/moodlehq/tinymce.
The Moodle `master` branch is named as the upcoming STABLE branch name, for example during the development of Moodle 4.2.0, the upcoming STABLE branch name will be MOODLE_402_STABLE.
## Upgrade procedure for TinyMCE Editor
1. Store an environment variable to the Tiny directory in the Moodle repository (the current directory).
```
MOODLEDIR=`pwd`
MOODLEDIR=`pwd`
```
2. Check out a clean copy of TinyMCE of the target version.
```
tinymce=`mktemp -d`
cd "${tinymce}"
git clone https://github.com/tinymce/tinymce.git
cd tinymce
git checkout [version]
tinymce=`mktemp -d`
cd "${tinymce}"
git clone https://github.com/tinymce/tinymce.git
cd tinymce
git checkout -b MOODLE_402_STABLE
git reset --hard [desired version]
```
3. Update the typescript configuration to generate ES6 modules with ES2020 target.
```
sed -i 's/"module".*es.*",/"module": "es6",/' tsconfig.shared.json
sed -i 's/"target.*es.*",/"target": "es2020",/' tsconfig.shared.json
sed -i 's/"module".*es.*",/"module": "es6",/' tsconfig.shared.json
sed -i 's/"target.*es.*",/"target": "es2020",/' tsconfig.shared.json
```
4. Rebuild TinyMCE
4. Install dependencies
```
yarn
yarn build
yarn
```
5. Remove the old TinyMCE configuration and replace it with the newly built version.
5. Check in the base changes
```
rm -rf "${MOODLEDIR}/js"
cp -r modules/tinymce/js "${MOODLEDIR}/js"
git commit -m 'MDL: Add build configuration'
```
6. Check the (Release notes)[https://www.tiny.cloud/docs/tinymce/6/release-notes/] for any new plugins, premium plugins, menu items, or buttons and add them to classes/manager.php
6. Apply any necessary security patches.
7. Rebuild TinyMCE
```
yarn
yarn build
```
8. Remove the old TinyMCE configuration and replace it with the newly built version.
```
rm -rf "${MOODLEDIR}/js"
cp -r modules/tinymce/js "${MOODLEDIR}/js"
```
9. Push the build to MoodleHQ for future change support
```
# Tag the next Moodle version.
git tag v4.2.0
git remote add moodlehq --tags
git push moodlehq MOODLE_402_STABLE
```
10. Check the (Release notes)[https://www.tiny.cloud/docs/tinymce/6/release-notes/] for any new plugins, premium plugins, menu items, or buttons and add them to classes/manager.php
## Update procedure for included TinyMCE translations
@@ -48,15 +76,15 @@
3. Unzip the translation into a new directory:
```bash
langdir=`mktemp -d`
cd "${langdir}"
unzip path/to/langs.zip
langdir=`mktemp -d`
cd "${langdir}"
unzip path/to/langs.zip
```
4. Run the translation tool:
```bash
node "${MOODLEDIR}/tools/createLangStrings.mjs"
node "${MOODLEDIR}/tools/createLangStrings.mjs"
```
This will generate a language file for each available Language, as well as a `tinystrings.json`, and a `strings.php` which will be used in the subsequent steps.
@@ -64,14 +92,14 @@
5. Copy the `tinystrings.json` file into the Moodle directory
```
cp tinystrings.json "${MOODLEDIR}/tinystrings.json"
cp tinystrings.json "${MOODLEDIR}/tinystrings.json"
```
6. Copy the content of the `strings.php` file over the existing tiny strings:
```
sed -i "/string\['tiny:/d" "${MOODLEDIR}/lang/en/editor_tiny.php"
cat strings.php >> "${MOODLEDIR}/lang/en/editor_tiny.php"
sed -i "/string\['tiny:/d" "${MOODLEDIR}/lang/en/editor_tiny.php"
cat strings.php >> "${MOODLEDIR}/lang/en/editor_tiny.php"
```
7. Commit changes. Note: You may need to review individual language changes which do not meet Moodle's guidelines.
@@ -84,3 +112,46 @@
**Note:** You will need to manually check for any Moodle-updated language strings as part of this change (for example any from the en_fixes).
---
## Security fix procedure for TinyMCE Editor
1. Store an environment variable to the Tiny directory in the Moodle repository (the current directory).
```
MOODLEDIR=`pwd`
```
2. Check out a clean copy of TinyMCE of the target version.
```
tinymce=`mktemp -d`
cd "${tinymce}"
git clone https://github.com/tinymce/tinymce.git
cd tinymce
git remote add moodlehq https://github.com/moodlehq/tinymce
git fetch moodlehq
git checkout -b MOODLE_402_STABLE moodlehq/MOODLE_402_STABLE
```
3. Apply any necessary security patches.
4. Rebuild TinyMCE
```
yarn
yarn build
```
5. Remove the old TinyMCE configuration and replace it with the newly built version.
```
rm -rf "${MOODLEDIR}/js"
cp -r modules/tinymce/js "${MOODLEDIR}/js"
```
---
**Note:** You may need to remove some parts of some patches, such as tests, changelog entries, etc. to get the patch to apply.
**Note:** The generated code may be significantly larger than the source patch
---