Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move tributejs to new workflow #12731

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},
"dependencies": {
"@sentry/browser": "8.33.1",
"jquery": "3.7.1"
"jquery": "3.7.1",
"tributejs": "5.1.3"
},
"devDependencies": {
"terser-webpack-plugin": "5.3.10",
Expand Down
7 changes: 7 additions & 0 deletions client/src/tribute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright © Michal Čihař <[email protected]>
//
// SPDX-License-Identifier: GPL-3.0-or-later

import Tribute from "tributejs";

window.Tribute = Tribute;
12 changes: 10 additions & 2 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,25 @@ SPDX-License-Identifier: ${licenses}
`;
}
// REUSE-IgnoreEnd

function mainLicenseTransform(packages) {
return genericTransform(packages, (pkg) => !pkg.name.startsWith("@sentry"));
const excludePrefixes = ["@sentry", "tributejs"];
return genericTransform(
packages,
(pkg) => !excludePrefixes.some((prefix) => pkg.name.startsWith(prefix)),
);
}
function sentryLicenseTransform(packages) {
return genericTransform(packages, (pkg) => pkg.name.startsWith("@sentry"));
}
function tributeLicenseTransform(packages) {
return genericTransform(packages, (pkg) => pkg.name.startsWith("tributejs"));
}

module.exports = {
entry: {
main: "./src/main.js",
sentry: "./src/sentry.js",
tribute: "./src/tribute.js",
},
mode: "production",
optimization: {
Expand All @@ -65,6 +72,7 @@ module.exports = {
additionalFiles: {
"main.js.license": mainLicenseTransform,
"sentry.js.license": sentryLicenseTransform,
"tribute.js.license": tributeLicenseTransform,
},
}),
],
Expand Down
5 changes: 5 additions & 0 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,11 @@ terser@^5.26.0:
commander "^2.20.0"
source-map-support "~0.5.20"

tributejs@^5.1.3:
version "5.1.3"
resolved "https://registry.yarnpkg.com/tributejs/-/tributejs-5.1.3.tgz#980600fc72865be5868893078b4bfde721129eae"
integrity sha512-B5CXihaVzXw+1UHhNFyAwUTMDk1EfoLP5Tj1VhD9yybZ1I8DZJEv8tZ1l0RJo0t0tk9ZhR8eG5tEsaCvRigmdQ==

undici-types@~6.19.2:
version "6.19.8"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02"
Expand Down
5 changes: 4 additions & 1 deletion docs/contributing/frontend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ Then, there are two ways to import the library:

2. If it is page-specific library (library is used in a specific page or template):
- Create a new file named ``src/<lib-name>.js``.
- Import the library in it.
- Import the library in it. Then inject it into the ``window`` object to be globally accessible.
- Add an entry in ``webpack.config.js``:
``<lib-name>: "src/<lib-name>.js"``.
- Add library name in ``excludePrefixes`` array in ``mainLicenseTransform`` in ``webpack.config.js``.
- Add license file name in ``additionalFiles`` in ``LicensePlugin`` in ``plugins`` array in ``webpack.config.js``.
- Create a ``<lib-name>LicenseTransfrom`` function for the license file introduced in the previous steps and use it.

Note: Replace ``<lib-name>`` with the actual name of the 3rd party library.

Expand Down
3 changes: 0 additions & 3 deletions scripts/yarn-update
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ cp node_modules/mousetrap/mousetrap.js ../../weblate/static/vendor/
# Mousetrap global bind
cp node_modules/mousetrap-global-bind/mousetrap-global-bind.js ../../weblate/static/vendor/

# Tribute
cp node_modules/tributejs/dist/tribute.js ../../weblate/static/vendor/

# Prismjs
cp node_modules/prismjs/components/prism-core.js ../../weblate/static/vendor/prism/
cp node_modules/prismjs/components/prism-markup.js ../../weblate/static/vendor/prism/
Expand Down
3 changes: 1 addition & 2 deletions scripts/yarn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"prismjs": "1.29.0",
"slugify": "1.6.6",
"source-code-pro": "2.38.0",
"source-sans": "3.46.0",
"tributejs": "5.1.3"
"source-sans": "3.46.0"
}
}
5 changes: 0 additions & 5 deletions scripts/yarn/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,3 @@ [email protected]:
version "3.46.0"
resolved "https://registry.yarnpkg.com/source-sans/-/source-sans-3.46.0.tgz#6af0a47ead682fa8971f0c83e9692e75ef3cbb86"
integrity sha512-bVC2YX4VNiv5vMcy77dL0XKsNp794ThfynNsr+FqSAwk8TGG0pZsg7eUQi6yHwaRBMVmZ3Aaf4FY46dxIIGgsg==

[email protected]:
version "5.1.3"
resolved "https://registry.yarnpkg.com/tributejs/-/tributejs-5.1.3.tgz#980600fc72865be5868893078b4bfde721129eae"
integrity sha512-B5CXihaVzXw+1UHhNFyAwUTMDk1EfoLP5Tj1VhD9yybZ1I8DZJEv8tZ1l0RJo0t0tk9ZhR8eG5tEsaCvRigmdQ==
1 change: 1 addition & 0 deletions weblate/static/js/vendor/tribute.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions weblate/static/js/vendor/tribute.js.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Copyright (c) 2017-2020 ZURB, Inc.

SPDX-License-Identifier: MIT
Loading
Loading