@trigger.dev/build 0.0.0-re2-20250508091848 → 0.0.0-re2-20250513104542
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/extensions/playwright.d.ts +50 -0
- package/dist/commonjs/extensions/playwright.js +285 -0
- package/dist/commonjs/extensions/playwright.js.map +1 -0
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/extensions/playwright.d.ts +50 -0
- package/dist/esm/extensions/playwright.js +282 -0
- package/dist/esm/extensions/playwright.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/package.json +18 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { BuildContext, BuildExtension } from "@trigger.dev/core/v3/build";
|
|
2
|
+
import type { BuildManifest, BuildTarget } from "@trigger.dev/core/v3";
|
|
3
|
+
type PlaywrightBrowser = "chromium" | "firefox" | "webkit";
|
|
4
|
+
interface PlaywrightExtensionOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Browsers to install. Select only needed browsers to optimize build time and size.
|
|
7
|
+
* @default ["chromium"]
|
|
8
|
+
*/
|
|
9
|
+
browsers?: PlaywrightBrowser[];
|
|
10
|
+
/**
|
|
11
|
+
* Run the browsers in headless mode (Recommended)
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
headless?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Playwright version override. If not provided, we will try to detect the version automatically.
|
|
17
|
+
*/
|
|
18
|
+
version?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a Playwright extension for trigger.dev
|
|
22
|
+
* @param options Configuration options
|
|
23
|
+
*/
|
|
24
|
+
export declare function playwright(options?: PlaywrightExtensionOptions): PlaywrightExtension;
|
|
25
|
+
/**
|
|
26
|
+
* Background:
|
|
27
|
+
*
|
|
28
|
+
* Running `npx playwright install --with-deps` normally will install the browsers and the dependencies.
|
|
29
|
+
* However, this is not possible in a build context, because we don't have sudo access.
|
|
30
|
+
*
|
|
31
|
+
* So we need to install the dependencies manually and then download and install the browsers.
|
|
32
|
+
* This has a few challenges:
|
|
33
|
+
* 1. We don't want to download all browsers, only the ones we need with it's dependencies
|
|
34
|
+
* The less dependencies we have to install, the faster the build, and the smaller the image.
|
|
35
|
+
* 2. We need to know where to download the browsers from
|
|
36
|
+
* while we can hardcode the download url it might change over time (as it has in the past)
|
|
37
|
+
* so we need to download the browser info first and then parse the output to get the download url.
|
|
38
|
+
*
|
|
39
|
+
* Note: While this looks like we are downloading & installing a lot of stuff, it's actually not that bad
|
|
40
|
+
* since running `npx playwright install --with-deps` will result in the same amount of downloads.
|
|
41
|
+
*/
|
|
42
|
+
declare class PlaywrightExtension implements BuildExtension {
|
|
43
|
+
readonly name = "PlaywrightExtension";
|
|
44
|
+
private moduleExternals;
|
|
45
|
+
private readonly options;
|
|
46
|
+
constructor({ browsers, headless, version, }?: PlaywrightExtensionOptions);
|
|
47
|
+
externalsForTarget(target: BuildTarget): string[];
|
|
48
|
+
onBuildComplete(context: BuildContext, manifest: BuildManifest): void;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.playwright = playwright;
|
|
4
|
+
/**
|
|
5
|
+
* This list is from the official playwright registry.
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/registry/nativeDeps.ts
|
|
8
|
+
*/
|
|
9
|
+
const debian12Deps = {
|
|
10
|
+
tools: [
|
|
11
|
+
"xvfb",
|
|
12
|
+
"fonts-noto-color-emoji",
|
|
13
|
+
"fonts-unifont",
|
|
14
|
+
"libfontconfig1",
|
|
15
|
+
"libfreetype6",
|
|
16
|
+
"xfonts-scalable",
|
|
17
|
+
"fonts-liberation",
|
|
18
|
+
"fonts-ipafont-gothic",
|
|
19
|
+
"fonts-wqy-zenhei",
|
|
20
|
+
"fonts-tlwg-loma-otf",
|
|
21
|
+
"fonts-freefont-ttf",
|
|
22
|
+
],
|
|
23
|
+
chromium: [
|
|
24
|
+
"libasound2",
|
|
25
|
+
"libatk-bridge2.0-0",
|
|
26
|
+
"libatk1.0-0",
|
|
27
|
+
"libatspi2.0-0",
|
|
28
|
+
"libcairo2",
|
|
29
|
+
"libcups2",
|
|
30
|
+
"libdbus-1-3",
|
|
31
|
+
"libdrm2",
|
|
32
|
+
"libgbm1",
|
|
33
|
+
"libglib2.0-0",
|
|
34
|
+
"libnspr4",
|
|
35
|
+
"libnss3",
|
|
36
|
+
"libpango-1.0-0",
|
|
37
|
+
"libx11-6",
|
|
38
|
+
"libxcb1",
|
|
39
|
+
"libxcomposite1",
|
|
40
|
+
"libxdamage1",
|
|
41
|
+
"libxext6",
|
|
42
|
+
"libxfixes3",
|
|
43
|
+
"libxkbcommon0",
|
|
44
|
+
"libxrandr2",
|
|
45
|
+
],
|
|
46
|
+
firefox: [
|
|
47
|
+
"libasound2",
|
|
48
|
+
"libatk1.0-0",
|
|
49
|
+
"libcairo-gobject2",
|
|
50
|
+
"libcairo2",
|
|
51
|
+
"libdbus-1-3",
|
|
52
|
+
"libdbus-glib-1-2",
|
|
53
|
+
"libfontconfig1",
|
|
54
|
+
"libfreetype6",
|
|
55
|
+
"libgdk-pixbuf-2.0-0",
|
|
56
|
+
"libglib2.0-0",
|
|
57
|
+
"libgtk-3-0",
|
|
58
|
+
"libharfbuzz0b",
|
|
59
|
+
"libpango-1.0-0",
|
|
60
|
+
"libpangocairo-1.0-0",
|
|
61
|
+
"libx11-6",
|
|
62
|
+
"libx11-xcb1",
|
|
63
|
+
"libxcb-shm0",
|
|
64
|
+
"libxcb1",
|
|
65
|
+
"libxcomposite1",
|
|
66
|
+
"libxcursor1",
|
|
67
|
+
"libxdamage1",
|
|
68
|
+
"libxext6",
|
|
69
|
+
"libxfixes3",
|
|
70
|
+
"libxi6",
|
|
71
|
+
"libxrandr2",
|
|
72
|
+
"libxrender1",
|
|
73
|
+
"libxtst6",
|
|
74
|
+
],
|
|
75
|
+
webkit: [
|
|
76
|
+
"libsoup-3.0-0",
|
|
77
|
+
"gstreamer1.0-libav",
|
|
78
|
+
"gstreamer1.0-plugins-bad",
|
|
79
|
+
"gstreamer1.0-plugins-base",
|
|
80
|
+
"gstreamer1.0-plugins-good",
|
|
81
|
+
"libatk-bridge2.0-0",
|
|
82
|
+
"libatk1.0-0",
|
|
83
|
+
"libcairo2",
|
|
84
|
+
"libdbus-1-3",
|
|
85
|
+
"libdrm2",
|
|
86
|
+
"libegl1",
|
|
87
|
+
"libenchant-2-2",
|
|
88
|
+
"libepoxy0",
|
|
89
|
+
"libevdev2",
|
|
90
|
+
"libfontconfig1",
|
|
91
|
+
"libfreetype6",
|
|
92
|
+
"libgbm1",
|
|
93
|
+
"libgdk-pixbuf-2.0-0",
|
|
94
|
+
"libgles2",
|
|
95
|
+
"libglib2.0-0",
|
|
96
|
+
"libglx0",
|
|
97
|
+
"libgstreamer-gl1.0-0",
|
|
98
|
+
"libgstreamer-plugins-base1.0-0",
|
|
99
|
+
"libgstreamer1.0-0",
|
|
100
|
+
"libgtk-4-1",
|
|
101
|
+
"libgudev-1.0-0",
|
|
102
|
+
"libharfbuzz-icu0",
|
|
103
|
+
"libharfbuzz0b",
|
|
104
|
+
"libhyphen0",
|
|
105
|
+
"libicu72",
|
|
106
|
+
"libjpeg62-turbo",
|
|
107
|
+
"liblcms2-2",
|
|
108
|
+
"libmanette-0.2-0",
|
|
109
|
+
"libnotify4",
|
|
110
|
+
"libopengl0",
|
|
111
|
+
"libopenjp2-7",
|
|
112
|
+
"libopus0",
|
|
113
|
+
"libpango-1.0-0",
|
|
114
|
+
"libpng16-16",
|
|
115
|
+
"libproxy1v5",
|
|
116
|
+
"libsecret-1-0",
|
|
117
|
+
"libwayland-client0",
|
|
118
|
+
"libwayland-egl1",
|
|
119
|
+
"libwayland-server0",
|
|
120
|
+
"libwebp7",
|
|
121
|
+
"libwebpdemux2",
|
|
122
|
+
"libwoff1",
|
|
123
|
+
"libx11-6",
|
|
124
|
+
"libxcomposite1",
|
|
125
|
+
"libxdamage1",
|
|
126
|
+
"libxkbcommon0",
|
|
127
|
+
"libxml2",
|
|
128
|
+
"libxslt1.1",
|
|
129
|
+
"libatomic1",
|
|
130
|
+
"libevent-2.1-7",
|
|
131
|
+
"libavif15",
|
|
132
|
+
],
|
|
133
|
+
lib2package: {
|
|
134
|
+
"libavif.so.15": "libavif15",
|
|
135
|
+
"libsoup-3.0.so.0": "libsoup-3.0-0",
|
|
136
|
+
"libasound.so.2": "libasound2",
|
|
137
|
+
"libatk-1.0.so.0": "libatk1.0-0",
|
|
138
|
+
"libatk-bridge-2.0.so.0": "libatk-bridge2.0-0",
|
|
139
|
+
"libatspi.so.0": "libatspi2.0-0",
|
|
140
|
+
"libcairo.so.2": "libcairo2",
|
|
141
|
+
"libcups.so.2": "libcups2",
|
|
142
|
+
"libdbus-1.so.3": "libdbus-1-3",
|
|
143
|
+
"libdrm.so.2": "libdrm2",
|
|
144
|
+
"libgbm.so.1": "libgbm1",
|
|
145
|
+
"libgio-2.0.so.0": "libglib2.0-0",
|
|
146
|
+
"libglib-2.0.so.0": "libglib2.0-0",
|
|
147
|
+
"libgobject-2.0.so.0": "libglib2.0-0",
|
|
148
|
+
"libnspr4.so": "libnspr4",
|
|
149
|
+
"libnss3.so": "libnss3",
|
|
150
|
+
"libnssutil3.so": "libnss3",
|
|
151
|
+
"libpango-1.0.so.0": "libpango-1.0-0",
|
|
152
|
+
"libsmime3.so": "libnss3",
|
|
153
|
+
"libX11.so.6": "libx11-6",
|
|
154
|
+
"libxcb.so.1": "libxcb1",
|
|
155
|
+
"libXcomposite.so.1": "libxcomposite1",
|
|
156
|
+
"libXdamage.so.1": "libxdamage1",
|
|
157
|
+
"libXext.so.6": "libxext6",
|
|
158
|
+
"libXfixes.so.3": "libxfixes3",
|
|
159
|
+
"libxkbcommon.so.0": "libxkbcommon0",
|
|
160
|
+
"libXrandr.so.2": "libxrandr2",
|
|
161
|
+
"libgtk-4.so.1": "libgtk-4-1",
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Creates a Playwright extension for trigger.dev
|
|
166
|
+
* @param options Configuration options
|
|
167
|
+
*/
|
|
168
|
+
function playwright(options = {}) {
|
|
169
|
+
return new PlaywrightExtension(options);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Background:
|
|
173
|
+
*
|
|
174
|
+
* Running `npx playwright install --with-deps` normally will install the browsers and the dependencies.
|
|
175
|
+
* However, this is not possible in a build context, because we don't have sudo access.
|
|
176
|
+
*
|
|
177
|
+
* So we need to install the dependencies manually and then download and install the browsers.
|
|
178
|
+
* This has a few challenges:
|
|
179
|
+
* 1. We don't want to download all browsers, only the ones we need with it's dependencies
|
|
180
|
+
* The less dependencies we have to install, the faster the build, and the smaller the image.
|
|
181
|
+
* 2. We need to know where to download the browsers from
|
|
182
|
+
* while we can hardcode the download url it might change over time (as it has in the past)
|
|
183
|
+
* so we need to download the browser info first and then parse the output to get the download url.
|
|
184
|
+
*
|
|
185
|
+
* Note: While this looks like we are downloading & installing a lot of stuff, it's actually not that bad
|
|
186
|
+
* since running `npx playwright install --with-deps` will result in the same amount of downloads.
|
|
187
|
+
*/
|
|
188
|
+
class PlaywrightExtension {
|
|
189
|
+
name = "PlaywrightExtension";
|
|
190
|
+
moduleExternals;
|
|
191
|
+
options;
|
|
192
|
+
constructor({ browsers = ["chromium"], headless = true, version, } = {}) {
|
|
193
|
+
if (browsers && browsers.length === 0) {
|
|
194
|
+
throw new Error("At least one browser must be specified");
|
|
195
|
+
}
|
|
196
|
+
this.options = { browsers, headless, version };
|
|
197
|
+
this.moduleExternals = ["playwright"];
|
|
198
|
+
}
|
|
199
|
+
externalsForTarget(target) {
|
|
200
|
+
if (target === "dev") {
|
|
201
|
+
return [];
|
|
202
|
+
}
|
|
203
|
+
return this.moduleExternals;
|
|
204
|
+
}
|
|
205
|
+
onBuildComplete(context, manifest) {
|
|
206
|
+
if (context.target === "dev")
|
|
207
|
+
return;
|
|
208
|
+
// Detect Playwright version from manifest.externals or use override
|
|
209
|
+
const playwrightExternal = manifest.externals?.find((external) => external.name === "playwright" || external.name === "@playwright/test");
|
|
210
|
+
const version = playwrightExternal?.version ?? this.options.version;
|
|
211
|
+
if (!version) {
|
|
212
|
+
throw new Error("PlaywrightExtension could not determine the version of playwright. Please provide a version in the PlaywrightExtension options.");
|
|
213
|
+
}
|
|
214
|
+
context.logger.debug(`Adding ${this.name} to the build with browsers: ${this.options.browsers.join(", ")}, version: ${version}`);
|
|
215
|
+
const instructions = [
|
|
216
|
+
// Base dependencies, we need these to download the browsers
|
|
217
|
+
`RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
218
|
+
curl \
|
|
219
|
+
unzip \
|
|
220
|
+
jq \
|
|
221
|
+
grep \
|
|
222
|
+
sed \
|
|
223
|
+
npm \
|
|
224
|
+
&& apt-get clean && rm -rf /var/lib/apt/lists/*`,
|
|
225
|
+
// Install Playwright globally with detected version
|
|
226
|
+
`RUN npm install -g playwright@${version}`,
|
|
227
|
+
];
|
|
228
|
+
const deps = [...debian12Deps.tools, ...Object.values(debian12Deps.lib2package)];
|
|
229
|
+
if (this.options.browsers.includes("chromium"))
|
|
230
|
+
deps.push(...debian12Deps.chromium);
|
|
231
|
+
if (this.options.browsers.includes("firefox"))
|
|
232
|
+
deps.push(...debian12Deps.firefox);
|
|
233
|
+
if (this.options.browsers.includes("webkit"))
|
|
234
|
+
deps.push(...debian12Deps.webkit);
|
|
235
|
+
instructions.push(`RUN apt-get update && apt-get install -y --no-install-recommends ${deps.join(" ")} \
|
|
236
|
+
&& apt-get clean && rm -rf /var/lib/apt/lists/*`);
|
|
237
|
+
// Setup directory for playwright browsers
|
|
238
|
+
instructions.push(`RUN mkdir -p /ms-playwright`);
|
|
239
|
+
/**
|
|
240
|
+
* `npx playwright install --dry-run` prints the download urls for the browsers.
|
|
241
|
+
* We save this output to a file and then parse it to get the download urls for the browsers.
|
|
242
|
+
*/
|
|
243
|
+
instructions.push(`RUN npx playwright install --dry-run > /tmp/browser-info.txt`);
|
|
244
|
+
this.options.browsers.forEach((browser) => {
|
|
245
|
+
const browserType = browser === "chromium" ? "chromium-headless-shell" : browser;
|
|
246
|
+
instructions.push(`RUN grep -A5 "browser: ${browserType}" /tmp/browser-info.txt > /tmp/${browser}-info.txt`, `RUN INSTALL_DIR=$(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs) && \
|
|
247
|
+
DIR_NAME=$(basename "$INSTALL_DIR") && \
|
|
248
|
+
if [ -z "$DIR_NAME" ]; then echo "Failed to extract installation directory for ${browser}"; exit 1; fi && \
|
|
249
|
+
MS_DIR="/ms-playwright/$DIR_NAME" && \
|
|
250
|
+
mkdir -p "$MS_DIR"`, `RUN DOWNLOAD_URL=$(grep "Download url:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs | sed "s/mac-arm64/linux/g" | sed "s/mac-15-arm64/ubuntu-20.04/g") && \
|
|
251
|
+
if [ -z "$DOWNLOAD_URL" ]; then echo "Failed to extract download URL for ${browser}"; exit 1; fi && \
|
|
252
|
+
echo "Downloading ${browser} from $DOWNLOAD_URL" && \
|
|
253
|
+
curl -L -o /tmp/${browser}.zip "$DOWNLOAD_URL" && \
|
|
254
|
+
if [ $? -ne 0 ]; then echo "Failed to download ${browser}"; exit 1; fi && \
|
|
255
|
+
unzip -q /tmp/${browser}.zip -d "/ms-playwright/$(basename $(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs))" && \
|
|
256
|
+
if [ $? -ne 0 ]; then echo "Failed to extract ${browser}"; exit 1; fi && \
|
|
257
|
+
chmod -R +x "/ms-playwright/$(basename $(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs))" && \
|
|
258
|
+
rm /tmp/${browser}.zip`);
|
|
259
|
+
});
|
|
260
|
+
// Environment variables
|
|
261
|
+
const envVars = {
|
|
262
|
+
PLAYWRIGHT_BROWSERS_PATH: "/ms-playwright", // where playwright will find the browsers
|
|
263
|
+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1", // we already downloaded the browsers
|
|
264
|
+
PLAYWRIGHT_SKIP_BROWSER_VALIDATION: "1", // we already downloaded the browsers
|
|
265
|
+
};
|
|
266
|
+
if (!this.options.headless) {
|
|
267
|
+
instructions.push(`RUN echo '#!/bin/sh' > /usr/local/bin/xvfb-exec`, `RUN echo 'Xvfb :99 -screen 0 1024x768x24 &' >> /usr/local/bin/xvfb-exec`, `RUN echo 'exec "$@"' >> /usr/local/bin/xvfb-exec`, `RUN chmod +x /usr/local/bin/xvfb-exec`);
|
|
268
|
+
envVars.DISPLAY = ":99"; // Virtual display for the browsers
|
|
269
|
+
}
|
|
270
|
+
context.addLayer({
|
|
271
|
+
id: "playwright",
|
|
272
|
+
image: {
|
|
273
|
+
instructions,
|
|
274
|
+
},
|
|
275
|
+
deploy: {
|
|
276
|
+
env: envVars,
|
|
277
|
+
override: true,
|
|
278
|
+
},
|
|
279
|
+
dependencies: {
|
|
280
|
+
playwright: version,
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=playwright.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright.js","sourceRoot":"","sources":["../../../src/extensions/playwright.ts"],"names":[],"mappings":";;AA6LA,gCAEC;AAvKD;;;;GAIG;AACH,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE;QACL,MAAM;QACN,wBAAwB;QACxB,eAAe;QACf,gBAAgB;QAChB,cAAc;QACd,iBAAiB;QACjB,kBAAkB;QAClB,sBAAsB;QACtB,kBAAkB;QAClB,qBAAqB;QACrB,oBAAoB;KACrB;IACD,QAAQ,EAAE;QACR,YAAY;QACZ,oBAAoB;QACpB,aAAa;QACb,eAAe;QACf,WAAW;QACX,UAAU;QACV,aAA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AC;QAEF,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC3B,YAAY,CAAC,IAAI,CACf,iDAAiD,EACjD,yEAAyE,EACzE,kDAAkD,EAClD,uCAAuC,CACxC,CAAC;YAEF,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,mCAAmC;QAC9D,CAAC;QAED,OAAO,CAAC,QAAQ,CAAC;YACf,EAAE,EAAE,YAAY;YAChB,KAAK,EAAE;gBACL,YAAY;aACb;YACD,MAAM,EAAE;gBACN,GAAG,EAAE,OAAO;gBACZ,QAAQ,EAAE,IAAI;aACf;YACD,YAAY,EAAE;gBACZ,UAAU,EAAE,OAAO;aACpB;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/commonjs/version.js
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { BuildContext, BuildExtension } from "@trigger.dev/core/v3/build";
|
|
2
|
+
import type { BuildManifest, BuildTarget } from "@trigger.dev/core/v3";
|
|
3
|
+
type PlaywrightBrowser = "chromium" | "firefox" | "webkit";
|
|
4
|
+
interface PlaywrightExtensionOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Browsers to install. Select only needed browsers to optimize build time and size.
|
|
7
|
+
* @default ["chromium"]
|
|
8
|
+
*/
|
|
9
|
+
browsers?: PlaywrightBrowser[];
|
|
10
|
+
/**
|
|
11
|
+
* Run the browsers in headless mode (Recommended)
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
headless?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Playwright version override. If not provided, we will try to detect the version automatically.
|
|
17
|
+
*/
|
|
18
|
+
version?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a Playwright extension for trigger.dev
|
|
22
|
+
* @param options Configuration options
|
|
23
|
+
*/
|
|
24
|
+
export declare function playwright(options?: PlaywrightExtensionOptions): PlaywrightExtension;
|
|
25
|
+
/**
|
|
26
|
+
* Background:
|
|
27
|
+
*
|
|
28
|
+
* Running `npx playwright install --with-deps` normally will install the browsers and the dependencies.
|
|
29
|
+
* However, this is not possible in a build context, because we don't have sudo access.
|
|
30
|
+
*
|
|
31
|
+
* So we need to install the dependencies manually and then download and install the browsers.
|
|
32
|
+
* This has a few challenges:
|
|
33
|
+
* 1. We don't want to download all browsers, only the ones we need with it's dependencies
|
|
34
|
+
* The less dependencies we have to install, the faster the build, and the smaller the image.
|
|
35
|
+
* 2. We need to know where to download the browsers from
|
|
36
|
+
* while we can hardcode the download url it might change over time (as it has in the past)
|
|
37
|
+
* so we need to download the browser info first and then parse the output to get the download url.
|
|
38
|
+
*
|
|
39
|
+
* Note: While this looks like we are downloading & installing a lot of stuff, it's actually not that bad
|
|
40
|
+
* since running `npx playwright install --with-deps` will result in the same amount of downloads.
|
|
41
|
+
*/
|
|
42
|
+
declare class PlaywrightExtension implements BuildExtension {
|
|
43
|
+
readonly name = "PlaywrightExtension";
|
|
44
|
+
private moduleExternals;
|
|
45
|
+
private readonly options;
|
|
46
|
+
constructor({ browsers, headless, version, }?: PlaywrightExtensionOptions);
|
|
47
|
+
externalsForTarget(target: BuildTarget): string[];
|
|
48
|
+
onBuildComplete(context: BuildContext, manifest: BuildManifest): void;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This list is from the official playwright registry.
|
|
3
|
+
*
|
|
4
|
+
* @see https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/registry/nativeDeps.ts
|
|
5
|
+
*/
|
|
6
|
+
const debian12Deps = {
|
|
7
|
+
tools: [
|
|
8
|
+
"xvfb",
|
|
9
|
+
"fonts-noto-color-emoji",
|
|
10
|
+
"fonts-unifont",
|
|
11
|
+
"libfontconfig1",
|
|
12
|
+
"libfreetype6",
|
|
13
|
+
"xfonts-scalable",
|
|
14
|
+
"fonts-liberation",
|
|
15
|
+
"fonts-ipafont-gothic",
|
|
16
|
+
"fonts-wqy-zenhei",
|
|
17
|
+
"fonts-tlwg-loma-otf",
|
|
18
|
+
"fonts-freefont-ttf",
|
|
19
|
+
],
|
|
20
|
+
chromium: [
|
|
21
|
+
"libasound2",
|
|
22
|
+
"libatk-bridge2.0-0",
|
|
23
|
+
"libatk1.0-0",
|
|
24
|
+
"libatspi2.0-0",
|
|
25
|
+
"libcairo2",
|
|
26
|
+
"libcups2",
|
|
27
|
+
"libdbus-1-3",
|
|
28
|
+
"libdrm2",
|
|
29
|
+
"libgbm1",
|
|
30
|
+
"libglib2.0-0",
|
|
31
|
+
"libnspr4",
|
|
32
|
+
"libnss3",
|
|
33
|
+
"libpango-1.0-0",
|
|
34
|
+
"libx11-6",
|
|
35
|
+
"libxcb1",
|
|
36
|
+
"libxcomposite1",
|
|
37
|
+
"libxdamage1",
|
|
38
|
+
"libxext6",
|
|
39
|
+
"libxfixes3",
|
|
40
|
+
"libxkbcommon0",
|
|
41
|
+
"libxrandr2",
|
|
42
|
+
],
|
|
43
|
+
firefox: [
|
|
44
|
+
"libasound2",
|
|
45
|
+
"libatk1.0-0",
|
|
46
|
+
"libcairo-gobject2",
|
|
47
|
+
"libcairo2",
|
|
48
|
+
"libdbus-1-3",
|
|
49
|
+
"libdbus-glib-1-2",
|
|
50
|
+
"libfontconfig1",
|
|
51
|
+
"libfreetype6",
|
|
52
|
+
"libgdk-pixbuf-2.0-0",
|
|
53
|
+
"libglib2.0-0",
|
|
54
|
+
"libgtk-3-0",
|
|
55
|
+
"libharfbuzz0b",
|
|
56
|
+
"libpango-1.0-0",
|
|
57
|
+
"libpangocairo-1.0-0",
|
|
58
|
+
"libx11-6",
|
|
59
|
+
"libx11-xcb1",
|
|
60
|
+
"libxcb-shm0",
|
|
61
|
+
"libxcb1",
|
|
62
|
+
"libxcomposite1",
|
|
63
|
+
"libxcursor1",
|
|
64
|
+
"libxdamage1",
|
|
65
|
+
"libxext6",
|
|
66
|
+
"libxfixes3",
|
|
67
|
+
"libxi6",
|
|
68
|
+
"libxrandr2",
|
|
69
|
+
"libxrender1",
|
|
70
|
+
"libxtst6",
|
|
71
|
+
],
|
|
72
|
+
webkit: [
|
|
73
|
+
"libsoup-3.0-0",
|
|
74
|
+
"gstreamer1.0-libav",
|
|
75
|
+
"gstreamer1.0-plugins-bad",
|
|
76
|
+
"gstreamer1.0-plugins-base",
|
|
77
|
+
"gstreamer1.0-plugins-good",
|
|
78
|
+
"libatk-bridge2.0-0",
|
|
79
|
+
"libatk1.0-0",
|
|
80
|
+
"libcairo2",
|
|
81
|
+
"libdbus-1-3",
|
|
82
|
+
"libdrm2",
|
|
83
|
+
"libegl1",
|
|
84
|
+
"libenchant-2-2",
|
|
85
|
+
"libepoxy0",
|
|
86
|
+
"libevdev2",
|
|
87
|
+
"libfontconfig1",
|
|
88
|
+
"libfreetype6",
|
|
89
|
+
"libgbm1",
|
|
90
|
+
"libgdk-pixbuf-2.0-0",
|
|
91
|
+
"libgles2",
|
|
92
|
+
"libglib2.0-0",
|
|
93
|
+
"libglx0",
|
|
94
|
+
"libgstreamer-gl1.0-0",
|
|
95
|
+
"libgstreamer-plugins-base1.0-0",
|
|
96
|
+
"libgstreamer1.0-0",
|
|
97
|
+
"libgtk-4-1",
|
|
98
|
+
"libgudev-1.0-0",
|
|
99
|
+
"libharfbuzz-icu0",
|
|
100
|
+
"libharfbuzz0b",
|
|
101
|
+
"libhyphen0",
|
|
102
|
+
"libicu72",
|
|
103
|
+
"libjpeg62-turbo",
|
|
104
|
+
"liblcms2-2",
|
|
105
|
+
"libmanette-0.2-0",
|
|
106
|
+
"libnotify4",
|
|
107
|
+
"libopengl0",
|
|
108
|
+
"libopenjp2-7",
|
|
109
|
+
"libopus0",
|
|
110
|
+
"libpango-1.0-0",
|
|
111
|
+
"libpng16-16",
|
|
112
|
+
"libproxy1v5",
|
|
113
|
+
"libsecret-1-0",
|
|
114
|
+
"libwayland-client0",
|
|
115
|
+
"libwayland-egl1",
|
|
116
|
+
"libwayland-server0",
|
|
117
|
+
"libwebp7",
|
|
118
|
+
"libwebpdemux2",
|
|
119
|
+
"libwoff1",
|
|
120
|
+
"libx11-6",
|
|
121
|
+
"libxcomposite1",
|
|
122
|
+
"libxdamage1",
|
|
123
|
+
"libxkbcommon0",
|
|
124
|
+
"libxml2",
|
|
125
|
+
"libxslt1.1",
|
|
126
|
+
"libatomic1",
|
|
127
|
+
"libevent-2.1-7",
|
|
128
|
+
"libavif15",
|
|
129
|
+
],
|
|
130
|
+
lib2package: {
|
|
131
|
+
"libavif.so.15": "libavif15",
|
|
132
|
+
"libsoup-3.0.so.0": "libsoup-3.0-0",
|
|
133
|
+
"libasound.so.2": "libasound2",
|
|
134
|
+
"libatk-1.0.so.0": "libatk1.0-0",
|
|
135
|
+
"libatk-bridge-2.0.so.0": "libatk-bridge2.0-0",
|
|
136
|
+
"libatspi.so.0": "libatspi2.0-0",
|
|
137
|
+
"libcairo.so.2": "libcairo2",
|
|
138
|
+
"libcups.so.2": "libcups2",
|
|
139
|
+
"libdbus-1.so.3": "libdbus-1-3",
|
|
140
|
+
"libdrm.so.2": "libdrm2",
|
|
141
|
+
"libgbm.so.1": "libgbm1",
|
|
142
|
+
"libgio-2.0.so.0": "libglib2.0-0",
|
|
143
|
+
"libglib-2.0.so.0": "libglib2.0-0",
|
|
144
|
+
"libgobject-2.0.so.0": "libglib2.0-0",
|
|
145
|
+
"libnspr4.so": "libnspr4",
|
|
146
|
+
"libnss3.so": "libnss3",
|
|
147
|
+
"libnssutil3.so": "libnss3",
|
|
148
|
+
"libpango-1.0.so.0": "libpango-1.0-0",
|
|
149
|
+
"libsmime3.so": "libnss3",
|
|
150
|
+
"libX11.so.6": "libx11-6",
|
|
151
|
+
"libxcb.so.1": "libxcb1",
|
|
152
|
+
"libXcomposite.so.1": "libxcomposite1",
|
|
153
|
+
"libXdamage.so.1": "libxdamage1",
|
|
154
|
+
"libXext.so.6": "libxext6",
|
|
155
|
+
"libXfixes.so.3": "libxfixes3",
|
|
156
|
+
"libxkbcommon.so.0": "libxkbcommon0",
|
|
157
|
+
"libXrandr.so.2": "libxrandr2",
|
|
158
|
+
"libgtk-4.so.1": "libgtk-4-1",
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Creates a Playwright extension for trigger.dev
|
|
163
|
+
* @param options Configuration options
|
|
164
|
+
*/
|
|
165
|
+
export function playwright(options = {}) {
|
|
166
|
+
return new PlaywrightExtension(options);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Background:
|
|
170
|
+
*
|
|
171
|
+
* Running `npx playwright install --with-deps` normally will install the browsers and the dependencies.
|
|
172
|
+
* However, this is not possible in a build context, because we don't have sudo access.
|
|
173
|
+
*
|
|
174
|
+
* So we need to install the dependencies manually and then download and install the browsers.
|
|
175
|
+
* This has a few challenges:
|
|
176
|
+
* 1. We don't want to download all browsers, only the ones we need with it's dependencies
|
|
177
|
+
* The less dependencies we have to install, the faster the build, and the smaller the image.
|
|
178
|
+
* 2. We need to know where to download the browsers from
|
|
179
|
+
* while we can hardcode the download url it might change over time (as it has in the past)
|
|
180
|
+
* so we need to download the browser info first and then parse the output to get the download url.
|
|
181
|
+
*
|
|
182
|
+
* Note: While this looks like we are downloading & installing a lot of stuff, it's actually not that bad
|
|
183
|
+
* since running `npx playwright install --with-deps` will result in the same amount of downloads.
|
|
184
|
+
*/
|
|
185
|
+
class PlaywrightExtension {
|
|
186
|
+
name = "PlaywrightExtension";
|
|
187
|
+
moduleExternals;
|
|
188
|
+
options;
|
|
189
|
+
constructor({ browsers = ["chromium"], headless = true, version, } = {}) {
|
|
190
|
+
if (browsers && browsers.length === 0) {
|
|
191
|
+
throw new Error("At least one browser must be specified");
|
|
192
|
+
}
|
|
193
|
+
this.options = { browsers, headless, version };
|
|
194
|
+
this.moduleExternals = ["playwright"];
|
|
195
|
+
}
|
|
196
|
+
externalsForTarget(target) {
|
|
197
|
+
if (target === "dev") {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
return this.moduleExternals;
|
|
201
|
+
}
|
|
202
|
+
onBuildComplete(context, manifest) {
|
|
203
|
+
if (context.target === "dev")
|
|
204
|
+
return;
|
|
205
|
+
// Detect Playwright version from manifest.externals or use override
|
|
206
|
+
const playwrightExternal = manifest.externals?.find((external) => external.name === "playwright" || external.name === "@playwright/test");
|
|
207
|
+
const version = playwrightExternal?.version ?? this.options.version;
|
|
208
|
+
if (!version) {
|
|
209
|
+
throw new Error("PlaywrightExtension could not determine the version of playwright. Please provide a version in the PlaywrightExtension options.");
|
|
210
|
+
}
|
|
211
|
+
context.logger.debug(`Adding ${this.name} to the build with browsers: ${this.options.browsers.join(", ")}, version: ${version}`);
|
|
212
|
+
const instructions = [
|
|
213
|
+
// Base dependencies, we need these to download the browsers
|
|
214
|
+
`RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
215
|
+
curl \
|
|
216
|
+
unzip \
|
|
217
|
+
jq \
|
|
218
|
+
grep \
|
|
219
|
+
sed \
|
|
220
|
+
npm \
|
|
221
|
+
&& apt-get clean && rm -rf /var/lib/apt/lists/*`,
|
|
222
|
+
// Install Playwright globally with detected version
|
|
223
|
+
`RUN npm install -g playwright@${version}`,
|
|
224
|
+
];
|
|
225
|
+
const deps = [...debian12Deps.tools, ...Object.values(debian12Deps.lib2package)];
|
|
226
|
+
if (this.options.browsers.includes("chromium"))
|
|
227
|
+
deps.push(...debian12Deps.chromium);
|
|
228
|
+
if (this.options.browsers.includes("firefox"))
|
|
229
|
+
deps.push(...debian12Deps.firefox);
|
|
230
|
+
if (this.options.browsers.includes("webkit"))
|
|
231
|
+
deps.push(...debian12Deps.webkit);
|
|
232
|
+
instructions.push(`RUN apt-get update && apt-get install -y --no-install-recommends ${deps.join(" ")} \
|
|
233
|
+
&& apt-get clean && rm -rf /var/lib/apt/lists/*`);
|
|
234
|
+
// Setup directory for playwright browsers
|
|
235
|
+
instructions.push(`RUN mkdir -p /ms-playwright`);
|
|
236
|
+
/**
|
|
237
|
+
* `npx playwright install --dry-run` prints the download urls for the browsers.
|
|
238
|
+
* We save this output to a file and then parse it to get the download urls for the browsers.
|
|
239
|
+
*/
|
|
240
|
+
instructions.push(`RUN npx playwright install --dry-run > /tmp/browser-info.txt`);
|
|
241
|
+
this.options.browsers.forEach((browser) => {
|
|
242
|
+
const browserType = browser === "chromium" ? "chromium-headless-shell" : browser;
|
|
243
|
+
instructions.push(`RUN grep -A5 "browser: ${browserType}" /tmp/browser-info.txt > /tmp/${browser}-info.txt`, `RUN INSTALL_DIR=$(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs) && \
|
|
244
|
+
DIR_NAME=$(basename "$INSTALL_DIR") && \
|
|
245
|
+
if [ -z "$DIR_NAME" ]; then echo "Failed to extract installation directory for ${browser}"; exit 1; fi && \
|
|
246
|
+
MS_DIR="/ms-playwright/$DIR_NAME" && \
|
|
247
|
+
mkdir -p "$MS_DIR"`, `RUN DOWNLOAD_URL=$(grep "Download url:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs | sed "s/mac-arm64/linux/g" | sed "s/mac-15-arm64/ubuntu-20.04/g") && \
|
|
248
|
+
if [ -z "$DOWNLOAD_URL" ]; then echo "Failed to extract download URL for ${browser}"; exit 1; fi && \
|
|
249
|
+
echo "Downloading ${browser} from $DOWNLOAD_URL" && \
|
|
250
|
+
curl -L -o /tmp/${browser}.zip "$DOWNLOAD_URL" && \
|
|
251
|
+
if [ $? -ne 0 ]; then echo "Failed to download ${browser}"; exit 1; fi && \
|
|
252
|
+
unzip -q /tmp/${browser}.zip -d "/ms-playwright/$(basename $(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs))" && \
|
|
253
|
+
if [ $? -ne 0 ]; then echo "Failed to extract ${browser}"; exit 1; fi && \
|
|
254
|
+
chmod -R +x "/ms-playwright/$(basename $(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs))" && \
|
|
255
|
+
rm /tmp/${browser}.zip`);
|
|
256
|
+
});
|
|
257
|
+
// Environment variables
|
|
258
|
+
const envVars = {
|
|
259
|
+
PLAYWRIGHT_BROWSERS_PATH: "/ms-playwright", // where playwright will find the browsers
|
|
260
|
+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1", // we already downloaded the browsers
|
|
261
|
+
PLAYWRIGHT_SKIP_BROWSER_VALIDATION: "1", // we already downloaded the browsers
|
|
262
|
+
};
|
|
263
|
+
if (!this.options.headless) {
|
|
264
|
+
instructions.push(`RUN echo '#!/bin/sh' > /usr/local/bin/xvfb-exec`, `RUN echo 'Xvfb :99 -screen 0 1024x768x24 &' >> /usr/local/bin/xvfb-exec`, `RUN echo 'exec "$@"' >> /usr/local/bin/xvfb-exec`, `RUN chmod +x /usr/local/bin/xvfb-exec`);
|
|
265
|
+
envVars.DISPLAY = ":99"; // Virtual display for the browsers
|
|
266
|
+
}
|
|
267
|
+
context.addLayer({
|
|
268
|
+
id: "playwright",
|
|
269
|
+
image: {
|
|
270
|
+
instructions,
|
|
271
|
+
},
|
|
272
|
+
deploy: {
|
|
273
|
+
env: envVars,
|
|
274
|
+
override: true,
|
|
275
|
+
},
|
|
276
|
+
dependencies: {
|
|
277
|
+
playwright: version,
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=playwright.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright.js","sourceRoot":"","sources":["../../../src/extensions/playwright.ts"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE;QACL,MAAM;QACN,wBAAwB;QACxB,eAAe;QACf,gBAAgB;QAChB,cAAc;QACd,iBAAiB;QACjB,kBAAkB;QAClB,sBAAsB;QACtB,kBAAkB;QAClB,qBAAqB;QACrB,oBAAoB;KACrB;IACD,QAAQ,EAAE;QACR,YAAY;QACZ,oBAAoB;QACpB,aAAa;QACb,eAAe;QACf,WAAW;QACX,UAA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AAqC;SAC/E,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC3B,YAAY,CAAC,IAAI,CACf,iDAAiD,EACjD,yEAAyE,EACzE,kDAAkD,EAClD,uCAAuC,CACxC,CAAC;YAEF,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,mCAAmC;QAC9D,CAAC;QAED,OAAO,CAAC,QAAQ,CAAC;YACf,EAAE,EAAE,YAAY;YAChB,KAAK,EAAE;gBACL,YAAY;aACb;YACD,MAAM,EAAE;gBACN,GAAG,EAAE,OAAO;gBACZ,QAAQ,EAAE,IAAI;aACf;YACD,YAAY,EAAE;gBACZ,UAAU,EAAE,OAAO;aACpB;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "0.0.0-re2-
|
|
1
|
+
export const VERSION = "0.0.0-re2-20250513104542";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trigger.dev/build",
|
|
3
|
-
"version": "0.0.0-re2-
|
|
3
|
+
"version": "0.0.0-re2-20250513104542",
|
|
4
4
|
"description": "trigger.dev build extensions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"./extensions/prisma": "./src/extensions/prisma.ts",
|
|
30
30
|
"./extensions/audioWaveform": "./src/extensions/audioWaveform.ts",
|
|
31
31
|
"./extensions/typescript": "./src/extensions/typescript.ts",
|
|
32
|
-
"./extensions/puppeteer": "./src/extensions/puppeteer.ts"
|
|
32
|
+
"./extensions/puppeteer": "./src/extensions/puppeteer.ts",
|
|
33
|
+
"./extensions/playwright": "./src/extensions/playwright.ts"
|
|
33
34
|
},
|
|
34
35
|
"sourceDialects": [
|
|
35
36
|
"@triggerdotdev/source"
|
|
@@ -57,11 +58,14 @@
|
|
|
57
58
|
],
|
|
58
59
|
"extensions/puppeteer": [
|
|
59
60
|
"dist/commonjs/extensions/puppeteer.d.ts"
|
|
61
|
+
],
|
|
62
|
+
"extensions/playwright": [
|
|
63
|
+
"dist/commonjs/extensions/playwright.d.ts"
|
|
60
64
|
]
|
|
61
65
|
}
|
|
62
66
|
},
|
|
63
67
|
"dependencies": {
|
|
64
|
-
"@trigger.dev/core": "0.0.0-re2-
|
|
68
|
+
"@trigger.dev/core": "0.0.0-re2-20250513104542",
|
|
65
69
|
"pkg-types": "^1.1.3",
|
|
66
70
|
"tinyglobby": "^0.2.2",
|
|
67
71
|
"tsconfck": "3.1.3"
|
|
@@ -165,6 +169,17 @@
|
|
|
165
169
|
"types": "./dist/commonjs/extensions/puppeteer.d.ts",
|
|
166
170
|
"default": "./dist/commonjs/extensions/puppeteer.js"
|
|
167
171
|
}
|
|
172
|
+
},
|
|
173
|
+
"./extensions/playwright": {
|
|
174
|
+
"import": {
|
|
175
|
+
"@triggerdotdev/source": "./src/extensions/playwright.ts",
|
|
176
|
+
"types": "./dist/esm/extensions/playwright.d.ts",
|
|
177
|
+
"default": "./dist/esm/extensions/playwright.js"
|
|
178
|
+
},
|
|
179
|
+
"require": {
|
|
180
|
+
"types": "./dist/commonjs/extensions/playwright.d.ts",
|
|
181
|
+
"default": "./dist/commonjs/extensions/playwright.js"
|
|
182
|
+
}
|
|
168
183
|
}
|
|
169
184
|
},
|
|
170
185
|
"main": "./dist/commonjs/index.js",
|