Skip to content

Commit

Permalink
chore: Move prismjs lib to new build workflow (#13072)
Browse files Browse the repository at this point in the history
Co-authored-by: Michal Čihař <[email protected]>
  • Loading branch information
meel-hd and nijel authored Nov 19, 2024
1 parent ecda987 commit c26317e
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 2,235 deletions.
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"mousetrap": "1.6.5",
"mousetrap-global-bind": "1.1.0",
"multi.js": "0.5.3",
"prismjs": "1.29.0",
"slugify": "1.6.6",
"tributejs": "5.1.3"
},
Expand Down
11 changes: 11 additions & 0 deletions client/src/prismjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright © Michal Čihař <[email protected]>
//
// SPDX-License-Identifier: GPL-3.0-or-later

import Prism from "prismjs";
import "prismjs/components/prism-markup";
import "prismjs/components/prism-rest";
import "prismjs/components/prism-markdown";
import "prismjs/components/prism-icu-message-format";

window.Prism = Prism;
7 changes: 7 additions & 0 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function mainLicenseTransform(packages) {
"autosize",
"multi.js",
"mousetrap",
"prismjs",
"@altcha",
"altcha",
];
Expand All @@ -72,6 +73,10 @@ function multiJsLicenseTransform(packages) {
return genericTransform(packages, (pkg) => pkg.name.startsWith("multi.js"));
}

function prismJsLicenseTransform(packages) {
return genericTransform(packages, (pkg) => pkg.name.startsWith("prismjs"));
}

function altchaLicenseTransform(packages) {
return genericTransform(
packages,
Expand Down Expand Up @@ -124,6 +129,7 @@ module.exports = {
autosize: "./src/autosize.js",
multi: "./src/multi.js",
mousetrap: "./src/mousetrap.js",
prismjs: "./src/prismjs.js",
altcha: "./src/altcha.js",
},
mode: "production",
Expand Down Expand Up @@ -159,6 +165,7 @@ module.exports = {
"multi.js.license": multiJsLicenseTransform,
"multi.css.license": multiJsLicenseTransform,
"mousetrap.js.license": mousetrapLicenseTransform,
"prismjs.js.license": prismJsLicenseTransform,
"altcha.js.license": altchaLicenseTransform,
},
}),
Expand Down
5 changes: 5 additions & 0 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ postcss@^8.4.33:
picocolors "^1.1.1"
source-map-js "^1.2.1"

[email protected]:
version "1.29.0"
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.29.0.tgz#f113555a8fa9b57c35e637bba27509dcf802dd12"
integrity sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==

punycode@^2.1.0:
version "2.3.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5"
Expand Down
7 changes: 0 additions & 7 deletions scripts/yarn-update
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ cd scripts/yarn/

yarn install --check-files

# 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/
cp node_modules/prismjs/components/prism-rest.js ../../weblate/static/vendor/prism/
cp node_modules/prismjs/components/prism-markdown.js ../../weblate/static/vendor/prism/
cp node_modules/prismjs/components/prism-icu-message-format.js ../../weblate/static/vendor/prism/

# Source Sans/Code Pro fonts
sed '/font-family/ a font-display: swap;' < node_modules/source-sans/source-sans-3.css > ../../weblate/static/vendor/font-source/source-sans-3.css
sed '/font-family/ a font-display: swap;' < node_modules/source-code-pro/source-code-pro.css > ../../weblate/static/vendor/font-source/source-code-pro.css
Expand Down
1 change: 0 additions & 1 deletion scripts/yarn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"main": "index.js",
"license": "GPL-3.0+",
"dependencies": {
"prismjs": "1.29.0",
"source-code-pro": "2.38.0",
"source-sans": "3.46.0"
}
Expand Down
5 changes: 0 additions & 5 deletions scripts/yarn/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# yarn lockfile v1


[email protected]:
version "1.29.0"
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.29.0.tgz#f113555a8fa9b57c35e637bba27509dcf802dd12"
integrity sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==

[email protected]:
version "2.38.0"
resolved "https://registry.yarnpkg.com/source-code-pro/-/source-code-pro-2.38.0.tgz#85c57689f7386bb9d0515fb00ba4845bfb7b485b"
Expand Down
1 change: 1 addition & 0 deletions weblate/static/js/vendor/prismjs.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions weblate/static/js/vendor/prismjs.js.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Copyright (c) 2012 Lea Verou

SPDX-License-Identifier: MIT
Loading

0 comments on commit c26317e

Please sign in to comment.