coderifts 1.2.0 → 1.3.0
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/package.json +8 -2
- package/scripts/postinstall.js +41 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coderifts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Detect breaking API changes from the command line. Works locally or with the CodeRifts cloud API.",
|
|
5
5
|
"author": "CodeRifts <hello@coderifts.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"bin/",
|
|
13
13
|
"src/",
|
|
14
|
+
"scripts/",
|
|
14
15
|
"README.md"
|
|
15
16
|
],
|
|
16
17
|
"keywords": [
|
|
@@ -35,7 +36,12 @@
|
|
|
35
36
|
"node": ">=18.0.0"
|
|
36
37
|
},
|
|
37
38
|
"scripts": {
|
|
38
|
-
"test": "node --test test/*.test.js"
|
|
39
|
+
"test": "node --test test/*.test.js",
|
|
40
|
+
"postinstall": "node scripts/postinstall.js"
|
|
41
|
+
},
|
|
42
|
+
"overrides": {
|
|
43
|
+
"z-schema": "^8.4.0",
|
|
44
|
+
"json-schema-ref-parser": "npm:@apidevtools/json-schema-ref-parser@^11.0.0"
|
|
39
45
|
},
|
|
40
46
|
"dependencies": {
|
|
41
47
|
"chalk": "^4.1.2",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Postinstall patch: z-schema v8+ exports { default: ZSchema } instead of ZSchema directly.
|
|
4
|
+
* This patches @apidevtools/swagger-parser to handle both export styles.
|
|
5
|
+
*/
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
const schemaPath = require.resolve('@apidevtools/swagger-parser/lib/validators/schema.js');
|
|
11
|
+
let content = fs.readFileSync(schemaPath, 'utf8');
|
|
12
|
+
|
|
13
|
+
if (!content.includes('_ZSchema')) {
|
|
14
|
+
content = content.replace(
|
|
15
|
+
'const ZSchema = require("z-schema");',
|
|
16
|
+
'const _ZSchema = require("z-schema"); const ZSchema = _ZSchema.default || _ZSchema;'
|
|
17
|
+
);
|
|
18
|
+
fs.writeFileSync(schemaPath, content);
|
|
19
|
+
console.log('postinstall: patched z-schema import in swagger-parser');
|
|
20
|
+
}
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.log('postinstall: skipping z-schema patch:', err.message);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Patch 2: json-schema-ref-parser v11+ exports { default: $RefParser } instead of $RefParser directly
|
|
26
|
+
// json-schema-diff uses `new RefParser()` which breaks with the new export style
|
|
27
|
+
try {
|
|
28
|
+
const derefPath = require.resolve('json-schema-diff/dist/json-schema-diff/diff-schemas/dereference-schema.js');
|
|
29
|
+
let content2 = fs.readFileSync(derefPath, 'utf8');
|
|
30
|
+
|
|
31
|
+
if (!content2.includes('_RefParser')) {
|
|
32
|
+
content2 = content2.replace(
|
|
33
|
+
'const RefParser = require("json-schema-ref-parser");',
|
|
34
|
+
'const _RefParser = require("json-schema-ref-parser"); const RefParser = _RefParser.default || _RefParser;'
|
|
35
|
+
);
|
|
36
|
+
fs.writeFileSync(derefPath, content2);
|
|
37
|
+
console.log('postinstall: patched json-schema-ref-parser import in json-schema-diff');
|
|
38
|
+
}
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.log('postinstall: skipping ref-parser patch:', err.message);
|
|
41
|
+
}
|