| 1 |
import fs from 'node:fs'; |
| 2 |
import path from 'node:path'; |
| 3 |
import process from 'node:process'; |
| 4 |
|
| 5 |
const info = { |
| 6 |
entries: [ |
| 7 |
"base1/cockpit.js", |
| 8 |
"apps/apps.jsx", |
| 9 |
"kdump/kdump.js", |
| 10 |
// do *not* call this metrics/metrics -- uBlock origin etc. like to block metrics.{css,js} |
| 11 |
"metrics/index.js", |
| 12 |
|
| 13 |
"networkmanager/networkmanager.jsx", |
| 14 |
"networkmanager/firewall.jsx", |
| 15 |
|
| 16 |
"playground/index.js", |
| 17 |
"playground/exception.js", |
| 18 |
"playground/metrics.js", |
| 19 |
"playground/pkgs.js", |
| 20 |
"playground/plot.js", |
| 21 |
"playground/react-patterns.tsx", |
| 22 |
"playground/service.js", |
| 23 |
"playground/speed.js", |
| 24 |
"playground/test.js", |
| 25 |
"playground/translate.js", |
| 26 |
"playground/preloaded.js", |
| 27 |
"playground/notifications-receiver.js", |
| 28 |
"playground/journal.jsx", |
| 29 |
"playground/remote.tsx", |
| 30 |
"playground/terminal.tsx", |
| 31 |
"playground/packagemanager.tsx", |
| 32 |
"playground/dialog.tsx", |
| 33 |
|
| 34 |
"selinux/selinux.js", |
| 35 |
"shell/shell.jsx", |
| 36 |
"sosreport/sosreport.jsx", |
| 37 |
"static/login.js", |
| 38 |
"storaged/storaged.jsx", |
| 39 |
|
| 40 |
"systemd/services.jsx", |
| 41 |
"systemd/logs.jsx", |
| 42 |
"systemd/overview.jsx", |
| 43 |
"systemd/terminal.jsx", |
| 44 |
"systemd/hwinfo.jsx", |
| 45 |
|
| 46 |
"packagekit/updates.jsx", |
| 47 |
"users/users.js", |
| 48 |
], |
| 49 |
|
| 50 |
tests: [ |
| 51 |
"base1/test-base64.js", |
| 52 |
"base1/test-browser-storage.js", |
| 53 |
"base1/test-cache.js", |
| 54 |
"base1/test-chan.js", |
| 55 |
"base1/test-channel.ts", |
| 56 |
"base1/test-dbus-address.js", |
| 57 |
"base1/test-dbus-framed.js", |
| 58 |
"base1/test-dbus.js", |
| 59 |
"base1/test-echo.js", |
| 60 |
"base1/test-events.js", |
| 61 |
"base1/test-external.ts", |
| 62 |
"base1/test-file.ts", |
| 63 |
"base1/test-format.ts", |
| 64 |
"base1/test-framed-cache.js", |
| 65 |
"base1/test-framed.js", |
| 66 |
"base1/test-fsinfo.ts", |
| 67 |
"base1/test-http.js", |
| 68 |
"base1/test-info.ts", |
| 69 |
"base1/test-journal-renderer.js", |
| 70 |
"base1/test-locale.js", |
| 71 |
"base1/test-location.js", |
| 72 |
"base1/test-metrics.js", |
| 73 |
"base1/test-path.ts", |
| 74 |
"base1/test-permissions.js", |
| 75 |
"base1/test-promise.ts", |
| 76 |
"base1/test-protocol.ts", |
| 77 |
"base1/test-series.js", |
| 78 |
"base1/test-spawn-proc.ts", |
| 79 |
"base1/test-spawn.js", |
| 80 |
"base1/test-stream.ts", |
| 81 |
"base1/test-timeformat.ts", |
| 82 |
"base1/test-types.ts", |
| 83 |
"base1/test-user.js", |
| 84 |
"base1/test-websocket.js", |
| 85 |
"base1/test-import-json.ts", |
| 86 |
|
| 87 |
"kdump/test-config-client.js", |
| 88 |
|
| 89 |
"networkmanager/test-utils.js", |
| 90 |
|
| 91 |
"shell/machines/test-machines.js", |
| 92 |
|
| 93 |
"storaged/test-util.js", |
| 94 |
], |
| 95 |
|
| 96 |
// esbuild will already copy assets that are explicitly imported from JavaScript. |
| 97 |
// The others (top-level files, images, etc.) need to be listed explicitly |
| 98 |
files: [ |
| 99 |
"apps/index.html", |
| 100 |
"apps/default.png", |
| 101 |
|
| 102 |
"kdump/index.html", |
| 103 |
|
| 104 |
"metrics/index.html", |
| 105 |
|
| 106 |
"networkmanager/index.html", |
| 107 |
"networkmanager/firewall.html", |
| 108 |
|
| 109 |
"packagekit/index.html", |
| 110 |
|
| 111 |
"playground/index.html", |
| 112 |
"playground/exception.html", |
| 113 |
"playground/hammer.gif", |
| 114 |
"playground/metrics.html", |
| 115 |
"playground/pkgs.html", |
| 116 |
"playground/plot.html", |
| 117 |
"playground/react-patterns.html", |
| 118 |
"playground/service.html", |
| 119 |
"playground/speed.html", |
| 120 |
"playground/test.html", |
| 121 |
"playground/translate.html", |
| 122 |
"playground/preloaded.html", |
| 123 |
"playground/notifications-receiver.html", |
| 124 |
"playground/journal.html", |
| 125 |
"playground/remote.html", |
| 126 |
"playground/terminal.html", |
| 127 |
"playground/packagemanager.html", |
| 128 |
"playground/dialog.html", |
| 129 |
|
| 130 |
"selinux/index.html", |
| 131 |
|
| 132 |
"shell/images/server-error.png", |
| 133 |
"shell/images/server-large.png", |
| 134 |
"shell/images/server-small.png", |
| 135 |
"shell/images/cockpit-icon.svg", |
| 136 |
"shell/images/cockpit-icon-gray.svg", |
| 137 |
"shell/index.html", |
| 138 |
"shell/shell.html", |
| 139 |
|
| 140 |
"sosreport/index.html", |
| 141 |
"sosreport/sosreport.png", |
| 142 |
|
| 143 |
"static/login.html", |
| 144 |
|
| 145 |
"storaged/index.html", |
| 146 |
|
| 147 |
"systemd/index.html", |
| 148 |
"systemd/logs.html", |
| 149 |
"systemd/services.html", |
| 150 |
"systemd/terminal.html", |
| 151 |
"systemd/hwinfo.html", |
| 152 |
|
| 153 |
"users/index.html", |
| 154 |
] |
| 155 |
}; |
| 156 |
|
| 157 |
const srcdir = process.env.SRCDIR || '.'; |
| 158 |
const nodedir = path.relative(process.cwd(), path.resolve(srcdir, "node_modules")); |
| 159 |
|
| 160 |
export const all_subdirs = Array.from(new Set(info.entries.map(key => key.split('/')[0]))); |
| 161 |
|
| 162 |
// These are the fonts we used up until migrating to Patternfly v6 |
| 163 |
// It is kept here to make sure all dependencies of the fonts works like in |
| 164 |
// third-party plugins etc. |
| 165 |
|
| 166 |
// With the PF6 migration we now want to use Variable Fonts (VF) to ensure better |
| 167 |
// Patternfly visuals, and we will use a new directory structure to avoid hardcoding |
| 168 |
// @font-face. |
| 169 |
// |
| 170 |
// This copies all non-VF Red Hat fonts to our `static/fonts/` directory. |
| 171 |
const redhat_fonts = [ |
| 172 |
"Text-Bold", "Text-BoldItalic", "Text-Italic", "Text-Medium", "Text-MediumItalic", "Text-Regular", |
| 173 |
"Display-Black", "Display-BlackItalic", "Display-Bold", "Display-BoldItalic", |
| 174 |
"Display-Italic", "Display-Medium", "Display-MediumItalic", "Display-Regular", |
| 175 |
"Mono-Bold", "Mono-BoldItalic", "Mono-Italic", "Mono-Medium", "Mono-MediumItalic", "Mono-Regular", |
| 176 |
].map(name => { |
| 177 |
const subdir = 'RedHat' + name.split('-')[0]; |
| 178 |
const fontsdir = '@patternfly/patternfly/assets/fonts'; |
| 179 |
|
| 180 |
return { |
| 181 |
from: path.resolve(nodedir, fontsdir, subdir, 'RedHat' + name + '.woff2'), |
| 182 |
to: 'static/fonts/' |
| 183 |
}; |
| 184 |
}); |
| 185 |
|
| 186 |
// Different directory structure than our redhat_fonts, which makes it easier |
| 187 |
// to use the Patternfly default src and avoid hardcoding our own @font-face. |
| 188 |
// |
| 189 |
// This copies all variable fonts (VF in the name) to subdirectories: |
| 190 |
// static/fonts/ |
| 191 |
// ├── RedHatDisplay |
| 192 |
// │ └── RedHatDisplayVF.woff2 |
| 193 |
// ├── RedHatMono |
| 194 |
// │ ├── RedHatMonoVF-Italic.woff2 |
| 195 |
// │ └── RedHatMonoVF.woff2 |
| 196 |
// ├── RedHatText |
| 197 |
// │ ├── RedHatTextVF-Italic.woff2 |
| 198 |
// │ └── RedHatTextVF.woff2 |
| 199 |
const redhat_fonts_variable_font = [ |
| 200 |
"Text", |
| 201 |
"Display", |
| 202 |
"Mono", |
| 203 |
].flatMap(name => { |
| 204 |
const subdir = 'RedHat' + name; |
| 205 |
const fontsdir = '@patternfly/patternfly/assets/fonts'; |
| 206 |
const fontsDirPath = path.resolve(nodedir, fontsdir, subdir); |
| 207 |
|
| 208 |
return fs.readdirSync(fontsDirPath) |
| 209 |
.filter(file => file.includes('VF') && file.endsWith('.woff2')) |
| 210 |
.map(file => ({ |
| 211 |
from: path.resolve(fontsDirPath, file), |
| 212 |
to: `static/fonts/${subdir}` |
| 213 |
})); |
| 214 |
}); |
| 215 |
|
| 216 |
const pkgfile = suffix => `${srcdir}/pkg/${suffix}`; |
| 217 |
export const getFiles = subdir => { |
| 218 |
/* Qualify all the paths in entries */ |
| 219 |
const entryPoints = []; |
| 220 |
info.entries.forEach(key => { |
| 221 |
if (subdir && key.indexOf(subdir) !== 0) |
| 222 |
return; |
| 223 |
|
| 224 |
entryPoints.push(pkgfile(key)); |
| 225 |
}); |
| 226 |
|
| 227 |
/* Qualify all the paths in files listed */ |
| 228 |
const files = []; |
| 229 |
info.files.forEach(value => { |
| 230 |
if (!subdir || value.indexOf(subdir) === 0) |
| 231 |
files.push({ from: pkgfile(value), to: path.dirname(value) }); |
| 232 |
}); |
| 233 |
if (subdir) { |
| 234 |
const manifest = subdir + "/manifest.json"; |
| 235 |
files.push({ from: pkgfile(manifest), to: subdir }); |
| 236 |
} else { |
| 237 |
all_subdirs.forEach(subdir => { |
| 238 |
const manifest = subdir + "/manifest.json"; |
| 239 |
files.push({ from: pkgfile(manifest), to: subdir }); |
| 240 |
}); |
| 241 |
} |
| 242 |
|
| 243 |
return ({ entryPoints, assetFiles: files, redhat_fonts: redhat_fonts.concat(redhat_fonts_variable_font) }); |
| 244 |
}; |
| 245 |
|
| 246 |
export const getTestFiles = () => info.tests; |