Clean Makefile

This commit is contained in:
Romain Vigier
2021-08-17 19:15:25 +02:00
parent a0f6a508d2
commit aaf94fe8c1
4 changed files with 31 additions and 63 deletions
+2 -2
View File
@@ -23,8 +23,8 @@ test:
paths:
- node_modules
script:
- make deps-install
- make test
- npm install
- npm run test
build:
stage: build
+18 -15
View File
@@ -15,6 +15,7 @@ You're welcome to contribute to the [code](#contributing-to-the-code) or to the
- [Coding style](#coding-style)
- [Copyright notice](#copyright-notice)
- [Themes and unit tests](#themes-and-unit-tests)
- [Localized strings](#localized-strings)
- [Contributing to the translations](#contributing-to-the-translations)
---
@@ -24,23 +25,11 @@ You're welcome to contribute to the [code](#contributing-to-the-code) or to the
You'll need `make` and [NPM](https://www.npmjs.com/) to install the development dependencies:
```bash
make deps-install
npm install --save-dev
```
Create a new branch describing what your're working on, for example `feature/{name-of-the-feature}` or `theme/{name-of-the-theme}`.
To make sure your code passes basic checks, run:
```bash
make test
```
If you modify localized strings, make your changed available for translation:
```bash
make pot
```
When you're done, commit all your changes and create a new merge request. Choose the appropriate merge request template.
### Coding style
@@ -50,13 +39,19 @@ We follow the [GNOME Shell coding style](https://gitlab.gnome.org/GNOME/gnome-sh
To make sure your code follows it:
```bash
make test-lint
npm run test-lint
```
### Copyright notice
If you make changes to a file, please your copyright notice to the top of the file, or in a separate file (named `original-file.ext.license`), following the [SPDX specification](https://spdx.dev/).
Run [`reuse`](https://reuse.software/) to check that all the needed information is present:
```bash
reuse lint
```
### Themes and unit tests
If you add support for a theme, please write a unit test for each of its variants, in the `tests` directory, with the theme name as filename. Unit tests are written for [AVA](https://github.com/avajs/ava).
@@ -64,7 +59,15 @@ If you add support for a theme, please write a unit test for each of its variant
To run the tests:
```bash
make test-variants
npm run test-variants
```
### Localized strings
If you modify localized strings, make your changes available for translation:
```bash
make pot
```
## Contributing to the translations
+7 -45
View File
@@ -1,9 +1,6 @@
# SPDX-FileCopyrightText: 2019-2021 Romain Vigier <contact AT romainvigier.fr>
# SPDX-License-Identifier: GPL-3.0-or-later
COPYRIGHT_YEAR = 2019-2021
AUTHOR_NAME = Romain Vigier
AUTHOR_EMAIL =
NAME = $(shell grep '"name"' ./src/metadata.json | sed 's/\s"name":\s"\(.\+\)",\?/\1/')
UUID = $(shell grep '"uuid"' ./src/metadata.json | sed 's/\s"uuid":\s"\(.\+\)",\?/\1/')
@@ -11,9 +8,10 @@ VERSION = $(shell grep '"version"' ./src/metadata.json | sed 's/\s"version":\s\(
.PHONY: build
build: build-clean
build:
mkdir -p ./build
gnome-extensions pack \
--force \
--extra-source=../LICENSE \
--extra-source=./config.js \
--extra-source=./utils.js \
@@ -27,70 +25,34 @@ build: build-clean
--out-dir=./build \
./src
.PHONY: build-clean
.PHONY: clean
build-clean:
-rm -rf ./build
find ./src/ -type f -name "*.ui~" -delete
.PHONY: install
install: uninstall
gnome-extensions install ./build/$(UUID).shell-extension.zip
gnome-extensions install --force ./build/$(UUID).shell-extension.zip
.PHONY: uninstall
uninstall:
-gnome-extensions uninstall $(UUID)
.PHONY: clean
clean: build-clean deps-clean
.PHONY: test
test: test-lint test-variants
.PHONY: test-lint
test-lint:
npx eslint .
.PHONY: test-variants
test-variants:
cat ./src/modules/GtkVariants.js ./tests/gtk_themes/_variants.js.template > ./tests/gtk_themes/_variants.js
cat ./src/modules/ShellVariants.js ./tests/shell_themes/_variants.js.template > ./tests/shell_themes/_variants.js
test:
reuse lint
npm run test
.PHONY: deps-install
deps-install:
npm install
.PHONY: deps-clean
deps-clean:
-rm -rf ./node_modules
.PHONY: pot
pot:
mkdir -p ./src/po
xgettext \
--from-code=UTF-8 \
--keyword=_ \
--package-name="$(NAME)" \
--package-version="$(VERSION)" \
--output=./src/po/$(UUID).pot \
./src/*.js ./src/**/*.js ./src/schemas/*.xml ./src/preferences/ui/*.ui
sed -i '1,4s/SOME DESCRIPTIVE TITLE./$(NAME)/g' ./src/po/$(UUID).pot
sed -i '1,4s/YEAR/$(COPYRIGHT_YEAR)/' ./src/po/$(UUID).pot
sed -i "1,4s/THE PACKAGE'S COPYRIGHT HOLDER/$(AUTHOR_NAME)/" ./src/po/$(UUID).pot
sed -i "1,4s/FIRST AUTHOR/$(AUTHOR_NAME)/" ./src/po/$(UUID).pot
sed -i "1,4s/EMAIL@ADDRESS/$(AUTHOR_EMAIL)/" ./src/po/$(UUID).pot
.PHONY: add-po
add-po:
ifdef LANGUAGE_CODE
msginit --no-translator --input=src/po/$(UUID).pot --output=src/po/$(LANGUAGE_CODE).po --locale=$(LANGUAGE_CODE)
else
@echo "Please specify the code of the language you want to add, for example:"
@echo " make add-po LANGUAGE_CODE=fr"
endif
.PHONY: update-po
update-po:
for po_file in $(wildcard ./src/po/*.po); do \
msgmerge --update --no-fuzzy-matching --backup=none $$po_file src/po/$(UUID).pot; \
msgmerge --update $$po_file src/po/$(UUID).pot; \
done
+4 -1
View File
@@ -5,7 +5,10 @@
},
"license": "GPL-3.0-or-later",
"scripts": {
"test": "ava"
"test-lint": "eslint .",
"pretest-variants": "cat ./src/modules/GtkVariants.js ./tests/gtk_themes/_variants.js.template > ./tests/gtk_themes/_variants.js & cat ./src/modules/ShellVariants.js ./tests/shell_themes/_variants.js.template > ./tests/shell_themes/_variants.js",
"test-variants": "ava",
"test": "npm run test-lint && npm run test-variants"
},
"devDependencies": {
"ava": "^3.13.0",