Skip to content
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
18 changes: 13 additions & 5 deletions .github/workflows/publish-public-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,32 @@ jobs:

cd build-repo

# Clear old dist
rm -rf dist
# Clear old dist and patches
rm -rf dist patches

# Copy new build
# Copy new build, Lexical patches, and the postinstall script
cp -r ../dist ./
cp -r ../patches ./
cp ../apply-patches.cjs ./

# Update version in package.json
# Update version in package.json and keep the postinstall
# setup in sync so consumers get the Lexical patches applied
VERSION=$(node -p "require('../package.json').version")
node -e "
const pkg = require('./package.json');
const src = require('../package.json');
pkg.version = process.argv[1];
pkg.scripts = pkg.scripts || {};
pkg.scripts.postinstall = src.scripts.postinstall;
pkg.dependencies = pkg.dependencies || {};
pkg.dependencies['patch-package'] = src.dependencies['patch-package'];
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));
" "$VERSION"

# Commit and tag
git config user.name github-actions
git config user.email github-actions@github.com
git add dist package.json
git add dist patches apply-patches.cjs package.json
git commit -m "Release v$VERSION - build artifacts only"
git tag v$VERSION
git push origin master
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Using Force UI as a dependency in package.json -

```json
"dependencies": {
"@bsf/force-ui": "git+https://github.com/brainstormforce/force-ui#1.7.12"
"@bsf/force-ui": "git+https://github.com/brainstormforce/force-ui#1.7.13"
}
```

Expand All @@ -28,7 +28,7 @@ npm install
Or you can directly run the following command to install the package -

```bash
npm i -S @bsf/force-ui@git+https://github.com/brainstormforce/force-ui.git#1.7.12
npm i -S @bsf/force-ui@git+https://github.com/brainstormforce/force-ui.git#1.7.13
```

<br />
Expand Down
54 changes: 54 additions & 0 deletions apply-patches.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env node
/**
* Applies the bundled Lexical patches via patch-package.
*
* Runs in two contexts:
* 1. Local development checkout — patches apply to this package's own
* node_modules.
* 2. Installed as a dependency of a host project — npm hoists lexical to the
* host's node_modules, so patch-package must run from the host project

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What: Consider adding error handling for filesystem operations.

Why: While the current implementation will exit gracefully if the patch directory does not exist or if 'patch-package' is unavailable, it lacks detailed feedback. Proper error handling can help in understanding the failure points during execution.

How: Use console.error() to log specific error messages before process.exit. This can provide context on issues for future debugging.

* root with --patch-dir pointing back at this package's patches directory.
* Running it from this package's own directory would look for
* node_modules/@bsf/force-ui/node_modules/lexical, which doesn't exist.
*/
const fs = require( 'fs' );
const path = require( 'path' );
const { spawnSync } = require( 'child_process' );

const pkgDir = __dirname;
const patchDir = path.join( pkgDir, 'patches' );

if ( ! fs.existsSync( patchDir ) ) {
process.exit( 0 );
}

const segments = pkgDir.split( path.sep );
const nmIndex = segments.lastIndexOf( 'node_modules' );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What: Validate the existence of the patch binary before attempting to execute it.

Why: Directly constructing the path to the 'patch-package' binary without validating its existence increases the chance of runtime errors. This would enhance the robustness of the script.

How: Add a check after defining patchPackageBin to ensure the file exists using fs.existsSync(patchPackageBin). If it does not exist, log an error and exit.

const appRoot =
nmIndex === -1
? pkgDir
: segments.slice( 0, nmIndex ).join( path.sep ) || path.sep;

let patchPackageBin;
try {
const manifestPath = require.resolve( 'patch-package/package.json', {
paths: [ appRoot, pkgDir ],
} );
const manifest = JSON.parse( fs.readFileSync( manifestPath, 'utf8' ) );
const binEntry =
typeof manifest.bin === 'string'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What: Consider using spawn with proper callbacks instead of spawnSync.

Why: Using synchronous calls might block the event loop, especially if this script is executed in a larger context, which could lead to performance bottlenecks.

How: Switch to using spawn from 'child_process', and implement appropriate callback functions to handle output and errors asynchronously.

? manifest.bin
: manifest.bin[ 'patch-package' ];
patchPackageBin = path.join( path.dirname( manifestPath ), binEntry );
} catch ( error ) {
// patch-package is unavailable; skip rather than break the host install.
process.exit( 0 );
}

const result = spawnSync(
process.execPath,
[ patchPackageBin, '--patch-dir', path.relative( appRoot, patchDir ) ],
{ cwd: appRoot, stdio: 'inherit' }
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What: Ensure the exit status checks are handled properly after executing the patch command.

Why: While the current implementation checks the result of the command execution, it is beneficial to provide specific behavior based on different exit statuses (e.g., 0 for success, others for failure) to offer better context.

How: Instead of exiting with a direct mapping to result.status, consider logging a message about the success or failure of the command and correlate it with specific exit codes for clarity.


process.exit( result.status === null ? 1 : result.status );
2 changes: 2 additions & 0 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ echo "Creating archive... 🎁"

zip -r force-ui.zip \
dist \
patches \
apply-patches.cjs \
package.json \
version.json \
changelog.txt
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 1.7.13 - 11th June, 2026
- Fix: Resolved `patch-package: command not found` install failure when the library is consumed as a git dependency. `patch-package` is now a runtime dependency so the bundled Lexical Shadow DOM patches are applied in consumer projects, which is required for the Editor Input mention menu Shadow DOM fix to work.

Version 1.7.12 - 10th June, 2026
- Improvement: Atom - Textarea: Added `autoResize`, `minHeight`, and `maxHeight` props. When `autoResize` is enabled, the textarea height auto-adjusts to fit its content and stops growing at `maxHeight` (default 160px), at which point it becomes scrollable. `minHeight` and `maxHeight` apply as CSS constraints regardless of `autoResize`.
- Improvement: Organism - Line Chart: Added `seriesLabels` prop to map data keys to custom display names in the tooltip, useful for translated labels. Falls back to the data key when no label is provided.
Expand Down
Loading
Loading