Skip to content

Commit f6f8f98

Browse files
committed
chore: replace Playwright installation command in package.json with a custom postinstall script to improve CI performance
1 parent 5050b97 commit f6f8f98

3 files changed

Lines changed: 63 additions & 16 deletions

File tree

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ A Model Context Protocol (MCP) server for [Factifai](https://github.com/presidio
2020
## Table of Contents
2121

2222
- [Factifai MCP Server](#factifai-mcp-server)
23-
- [Table of Contents](#table-of-contents)
24-
- [Requirements](#requirements)
25-
- [Installation](#installation)
26-
- [Installation Note](#installation-note)
27-
- [Pre-Installation Tip](#pre-installation-tip)
28-
- [Configuration](#configuration)
29-
- [Environment Variables](#environment-variables)
30-
- [Model Provider Configuration Examples](#model-provider-configuration-examples)
31-
- [Bedrock Configuration Example](#bedrock-configuration-example)
32-
- [OpenAI Configuration Example](#openai-configuration-example)
33-
- [Factifai MCP integration with popular IDE and extension](#factifai-mcp-integration-with-popular-ide-and-extension)
34-
- [Available Tools](#available-tools)
35-
- [Contributing](#contributing)
36-
- [Security](#security)
37-
- [License](#license)
23+
- [Table of Contents](#table-of-contents)
24+
- [Requirements](#requirements)
25+
- [Installation](#installation)
26+
- [Installation Note](#installation-note)
27+
- [Pre-Installation Tip](#pre-installation-tip)
28+
- [Configuration](#configuration)
29+
- [Environment Variables](#environment-variables)
30+
- [Model Provider Configuration Examples](#model-provider-configuration-examples)
31+
- [Bedrock Configuration Example](#bedrock-configuration-example)
32+
- [OpenAI Configuration Example](#openai-configuration-example)
33+
- [Factifai MCP integration with popular IDE and extension](#factifai-mcp-integration-with-popular-ide-and-extension)
34+
- [Available Tools](#available-tools)
35+
- [Contributing](#contributing)
36+
- [Security](#security)
37+
- [License](#license)
3838

3939
## Requirements
4040

@@ -58,6 +58,7 @@ We recommend `npx` to install the server, but you can use any node package manag
5858
⚠️ **Important**: The first time you install Factifai MCP Server, it will automatically download and install browser dependencies using Playwright. This process may take several minutes depending on your internet connection and system specifications.
5959

6060
The installation includes:
61+
6162
- Downloading browser binaries (Chromium, Firefox, WebKit)
6263
- Installing browser dependencies
6364
- Setting up the necessary environment
@@ -79,6 +80,7 @@ npx --yes @presidio-dev/factifai-mcp-server@latest
7980
```
8081

8182
This pre-installation step:
83+
8284
1. Ensures browsers are downloaded without MCP client timeout constraints
8385
2. Significantly speeds up the MCP server's first-time installation
8486
3. Prevents installation failures due to timeout issues in your IDE or MCP client

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"dev": "concurrently \"npm:dev:watch\" \"npm:dev:mcp\"",
2929
"dev:link": "npm link",
3030
"build": "tsup index.ts --format esm --dts --out-dir dist --clean",
31-
"postinstall": "playwright install --with-deps",
31+
"postinstall": "node postinstall.cjs",
3232
"format": "prettier --write .",
3333
"format:check": "prettier --check .",
3434
"release": "release-it",
@@ -53,6 +53,7 @@
5353
},
5454
"files": [
5555
"dist",
56+
"postinstall.cjs",
5657
"README.md",
5758
"LICENSE",
5859
"package.json"

postinstall.cjs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Postinstall script for @presidio-dev/factifai-mcp-server
5+
*
6+
* This script installs Playwright browsers when the package is installed,
7+
* but skips installation in CI environments to improve build performance.
8+
*/
9+
10+
const { execSync } = require('child_process')
11+
12+
// Check if we're in a CI environment
13+
const isCI =
14+
process.env.CI === 'true' ||
15+
process.env.GITHUB_ACTIONS === 'true' ||
16+
process.env.CONTINUOUS_INTEGRATION === 'true' ||
17+
process.env.TRAVIS === 'true' ||
18+
process.env.CIRCLECI === 'true' ||
19+
process.env.JENKINS_URL ||
20+
process.env.BUILDKITE === 'true' ||
21+
process.env.DRONE === 'true' ||
22+
Boolean(process.env.CI)
23+
24+
if (isCI) {
25+
console.log('ℹ️ CI environment detected, skipping Playwright browser installation')
26+
console.log(' This speeds up your CI builds. Browsers can be installed manually if needed.')
27+
process.exit(0)
28+
}
29+
30+
// Not in CI, install Playwright browsers
31+
try {
32+
console.log('📦 Installing Playwright browsers...')
33+
execSync('npx playwright install --with-deps', {
34+
stdio: 'inherit',
35+
encoding: 'utf8',
36+
})
37+
console.log('✅ Playwright browsers installed successfully')
38+
} catch (error) {
39+
console.error('❌ Failed to install Playwright browsers:', error.message)
40+
console.error(' You may need to run "npx playwright install --with-deps" manually')
41+
// Don't exit with error code to avoid breaking the entire installation
42+
// Users can manually install browsers if needed
43+
console.log('⚠️ Continuing with installation...')
44+
}

0 commit comments

Comments
 (0)