Skip to content

Commit

Permalink
fix(pkg)!: update peer dependency
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This package now has a peer dependency of `[email protected]` or newer.
  • Loading branch information
boneskull committed Oct 14, 2024
1 parent 8614168 commit 9c84904
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"test:types": "tsc -p tsconfig.tsc.json"
},
"peerDependencies": {
"xstate": ">=5.14.0"
"xstate": ">=5.17.4"
},
"devDependencies": {
"@commitlint/cli": "19.5.0",
Expand Down
35 changes: 21 additions & 14 deletions test/xstate-compat.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#!/usr/bin/env tsx

import {parse} from 'semver';
import {$} from 'zx';

/**
* This script runs the test suite against all versions of `xstate` greater than
* or equal to the {@link KNOWN_MINIMUM known minimum version}.
Expand All @@ -19,10 +15,15 @@ import {$} from 'zx';
* @packageDocumentation
*/

import {minVersion, parse, Range} from 'semver';
import {$, type ProcessOutput} from 'zx';

import {peerDependencies} from '../package.json' with {type: 'json'};

/**
* The known minimum version of `xstate` that works with `xstate-audition`.
*/
const KNOWN_MINIMUM = '5.14.0';
const KNOWN_MINIMUM = minVersion(new Range(peerDependencies.xstate))!.format();

/**
* All versions of `xstate` available on npm
Expand Down Expand Up @@ -64,15 +65,20 @@ process
process.stderr.write(' done\n');
});

const unexpectedFailures: string[] = [];
type Failure = {
error: ProcessOutput;
version: string;
};

const unexpectedFailures: Failure[] = [];

// unfortunately this must run in serial
for (const version of versionsUnderTest) {
if (signal.aborted) {
continue;
}
try {
await $({signal})`npm i xstate@${version} --no-save`;
await $({quiet: true, signal})`npm i xstate@${version} --no-save`;
} catch (err) {
if (signal.aborted) {
continue;
Expand All @@ -82,28 +88,29 @@ for (const version of versionsUnderTest) {
}
try {
process.stderr.write(`xstate@${version} …`);
await $({signal})`npm test`;
await $({quiet: true, signal})`npm run build && npm test`;
foundMinimum ||= version;
process.stderr.write(` OK\n`);
} catch (err) {
if (signal.aborted) {
continue;
}
process.stderr.write(` NOT OK\n`);
console.error(err);
if (foundMinimum) {
unexpectedFailures.push(version);
}
unexpectedFailures.push({error: err as ProcessOutput, version});
}
}

if (!signal.aborted) {
if (unexpectedFailures.length) {
console.error('Unexpected failures:', unexpectedFailures.join(', '));
console.error('Unexpected failures:');
for (const {error, version} of unexpectedFailures) {
console.error(`xstate@${version}:`);
console.error(error);
}
process.exitCode = 1;
}
if (foundMinimum) {
console.log(foundMinimum);
console.log('Minimum compatible version:', foundMinimum);
} else {
console.error('No passing versions found!');
process.exitCode = 1;
Expand Down

0 comments on commit 9c84904

Please sign in to comment.