Skip to content

Commit dfc6547

Browse files
Merge branch 'kiwix:main' into main
2 parents 5592d76 + 8881e6a commit dfc6547

File tree

14 files changed

+210
-159
lines changed

14 files changed

+210
-159
lines changed

.github/workflows/CI.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,24 @@ jobs:
5757
- name: Test a full build of the app
5858
run: npm run build
5959

60-
- name: Test integrity of gitignore.patch
60+
- name: Test integrity of patch_gitignore.sh
6161
run: |
62-
# Check that the /scripts/gitignore patch is still valid (it will be needed for the gh-pages implementation used for unbundled testing)
63-
echo "DEV: If the gitignore patch fails, follow instructions in ADDING_DEPENDENCIES_NODE_MODULES.md to correct it."
64-
git apply ./scripts/gitignore.patch
62+
# Check that the /scripts/patch_gitignore script valid (it will be needed for the gh-pages implementation used for unbundled testing)
63+
echo "DEV: If this patch_gitignore script fails, follow instructions in ADDING_DEPENDENCIES_NODE_MODULES.md to correct it."
64+
chmod +x ./scripts/patch_gitignore.sh
65+
./scripts/patch_gitignore.sh
66+
# Check that .gitignore does NOT contain /dist/
67+
failed=0
68+
if grep -q "^/dist/" .gitignore; then
69+
echo "/dist/ found in .gitignore, so patch failed."
70+
failed=1
71+
fi
72+
# Check that .gitignore DOES contain !/node_modules/
73+
if ! grep -q "^\!/node_modules/" .gitignore; then
74+
echo "!/node_modules/ not found in .gitignore, so patch failed."
75+
failed=1
76+
fi
77+
exit $failed
6578
6679
- name: End-to-end tests on Chrome (Linux)
6780
env:

.github/workflows/publish-extension.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ jobs:
9494
git config user.email "<>"
9595
# Delete gitignore entry for the dist folder
9696
sed -i "/^\/dist\/$/d" .gitignore
97-
# Apply the patch to gitignore to allow some dependencies to be included
98-
git apply ./scripts/gitignore.patch
97+
# Patch gitignore so that files needed for the distribution are exposed
98+
chmod +x ./scripts/patch_gitignore.sh
99+
./scripts/patch_gitignore.sh
99100
if [ ! -z "$(git status --porcelain)" ]; then
100101
git add .
101102
git commit -m "Set GitHub Pages release version"

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,18 @@ build/config/buildinfo.properties
4343

4444
www-built
4545
www-ghdeploy
46-
/node_modules/
4746
/tmp/
4847
/scripts/kiwix-*.pem
4948
/scripts/set_secret_environment_variables.sh
5049
/build/
51-
/dist/
5250
/scripts/travisci_builder_id_key
5351
/scripts/ssh_key
5452
/scripts/secret_files.tar.gz
5553
/reports/
5654

55+
/dist/
56+
/node_modules*/
57+
5758
#Visual Studio
5859
/.vs/
5960
/.vscode/

ADDING_DEPENDENCIES_NODE_MODULES.md

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,29 @@ This syntax is sufficient for the bundler, rollup.js, to pick up the dependency
1010

1111
The problem is that the `node_modules` folder is usually ignored so that developers do not submit dependencies to the Repository: instead, each developer should install dependencies using NPM. But unless we make an exception for dependencies needed in the unbundled version, they won't be available when running it in the browser, so we have to ensure they are added **only** to the version published on the dev server.
1212

13-
## Update the `gitignore.patch` (NOT `.gitignore`)
13+
## Update the `patch_gitignore.sh` (NOT `.gitignore`)
1414

1515
The app is published to the development server from the `gh-pages` branch. To see the process, look at the workflow `publish-extension.yaml`. It installs dependencies and builds the app. In the workflow, you will see the following lines:
1616

1717
```
18-
# Apply the patch to gitignore to allow some dependencies to be included
19-
git apply ./scripts/gitignore.patch
18+
# Patch gitignore so that files needed for the distribution are exposed
19+
chmod +x ./scripts/patch_gitignore.sh
20+
./scripts/patch_gitignore.sh
2021
```
22+
As this implies, you will need to add your new dependency to the `patch_gitignore.sh` script so that `.gitignore` on the `gh-pages` branch is altered, and the dependency is included in the files published to the server. N.B., you must NOT directly commit the changes to `.gitignore` itself, because we do not want multiple versions of dependencies committed to the Repo on every branch and kept forever. The only branch that should have these dependencies committed is `gh-pages`, and that branch is force-pushed each time that the app is published, so only the latest versions of dependencies are committed and kept.
2123

22-
As this implies, you will need to add your new dependency to the `gitignore.patch` so that `.gitignore` on the `gh-pages` branch is altered, and the dependency is included in the files published to the server. N.B., you must NOT directly commit the changes to `.gitignore` itself, because we do not want multiple versions of dependencies committed to the Repo on every branch and kept forever. The only branch that should have these dependencies committed is `gh-pages`, and that branch is force-pushed each time that the app is published, so only the latest versions of dependencies are committed and kept.
24+
To update the patch, you will need to follow this procedure:
2325

24-
To update the patch, you will need the help of the git software to generate the patch, like this:
26+
1. Edit `patch_gitignore.sh` following the example below:
2527

26-
1. On your PR branch make sure your working tree is clean (that you have committed other irrelevant changes -- it's not necessary to have pushed the changes as well);
27-
2. Then run the exising patch with `git apply ./scripts/gitignore.patch`. Do NOT commit the changes to `.gitignore` that this will produce, but do save those changes;
28-
3. Now add your your dependency directly into `.gitignore`, putting it in alphabetical order into the existing block of changes, e.g.:
2928
```
30-
!/node_modules/i18next
31-
/node_modules/i18next/*
32-
!/node_modules/i18next/dist
33-
/node_modules/i18next/dist/*
34-
!/node_modules/i18next/dist/es
35-
!/node_modules/i18next/dist/es/*
29+
!/node_modules/i18next\
30+
/node_modules/i18next/*\
31+
!/node_modules/i18next/dist\
32+
/node_modules/i18next/dist/*\
33+
!/node_modules/i18next/dist/es\
34+
!/node_modules/i18next/dist/es/*\
3635
```
37-
This unwieldy syntax is necessary to exclude all the contents of each folder other than the file(s) you wish to include. Note that the `!` at the start of some lines means "do not ignore this folder" (or file). A line without `!` means that the files listed or globbed will all be ignored;
38-
4. Save the file (but don't commit it);
39-
5. Run something like `git diff > mypatch.patch`;
40-
6. Take the code in `mypatch.patch` and overwrite the code (but not the comment) in the current `./scripts/gitignore.patch`;
41-
7. Save the chnages to `gitignore.patch`, and discard the changes to `.gitignore` and `mypatch.patch` (when you discard `.gitignore`, the unignored `node_modules` dependencies should no longer appear as unsstaged changes in your PR);
42-
8. Test your patch works with `git apply ./scripts/gitignore.patch`;
43-
9. If it works, discard the changed `.gitignore` again, and you can finally push (just) the edited `gitignore.patch` to your PR.
36+
This unwieldy syntax is necessary to exclude all the contents of each folder other than the file(s) you wish to include. Note that the `!` at the start of some lines means "do not ignore this folder" (or file). A line without `!` means that the files listed or globbed will all be ignored.
37+
2. Test your patch works by running the script manually (you may need to do `chmod +x` first). You should see the relevant file(s) now appearing as a dirty change in git. DO NOT COMMIT THIS CHANGE!
38+
3. If it works, discard the changed `.gitignore` again, and you can finally push (just) the edited `patch_gitignoe.sh` script to your PR.

i18n/en.jsonp.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

i18n/es.jsonp.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)