Skip to content

Commit

Permalink
feat(cli): allow forcing
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustinMauroy committed Mar 17, 2024
1 parent 4ea556e commit e310fbb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This module is inspired by the now outdated `next-plugin-websocket`, if you are
- [🤔 About](#-about)
- [🏓 Table of Contents](#-table-of-contents)
- [📦 Installation](#-installation)
- [Automated Patching](#automated-patching)
- [🚀 Usage](#-usage)
- [🚓 Verify Patch](#-verify-patch)
- [🌀 Example](#-example)
Expand All @@ -55,14 +56,27 @@ npm install next-ws ws
# ws is a peer dependency, you must install it as well
```

### Automated Patching

If you would like to automate the patching process, you can add the following script to your `package.json` file.

```json
{
"scripts": {
"postinstall": "FORCE_NEXT_WS_PATCH=true npx next-ws-cli@latest patch"
}
}
```

### 🚓 Verify Patch (Optional)

It is recommended to add the following code to the top level of your `next.config.js`.
It is recommended to add the following code to the top level of your `next.config.mjs`.

This will verify that Next WS has been patched correctly, and throw an error if it has not. Preventing you from accidentally deploying a broken setup.

```ts
require('next-ws/server').verifyPatch();
import { verifyPatch } from 'next-ws/server';
verifyPatch();
```

---
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default new Command('patch')
default: false,
}).then((answer) => answer.confirm));

if (confirm) {
if (confirm || process.env.FORCE_NEXT_WS_PATCH) {
patch = patches[patches.length - 1];
log.info('Continuing with the latest patch');
log.info(`If you encounter any issues please report them at
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"outDir": "./dist",
"esModuleInterop": true,
"sourceMap": false
"sourceMap": false,
"noPropertyAccessFromIndexSignature": false,
},
"exclude": ["./node_modules/", "*.d.ts"],
"include": ["./src/**/*.ts"]
Expand Down

0 comments on commit e310fbb

Please sign in to comment.