coderifts 1.7.0 → 1.7.1

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.
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ const { program } = require('commander');
6
+ const pkg = require('../package.json');
7
+
8
+ program
9
+ .name('coderifts')
10
+ .description('Detect breaking API changes between OpenAPI specs')
11
+ .version(pkg.version, '-v, --version');
12
+
13
+ // ── diff command ──
14
+ program
15
+ .command('diff <old-spec> <new-spec>')
16
+ .description('Compare two OpenAPI specs and report breaking changes')
17
+ .option('-f, --format <format>', 'Output format: terminal (default), json, markdown', 'terminal')
18
+ .option('--ci', 'CI mode — exit with code 1 if breaking changes exceed threshold')
19
+ .option('--threshold <number>', 'Risk score threshold for CI mode (0-100)', '50')
20
+ .option('--cloud', 'Use the CodeRifts cloud API instead of local analysis')
21
+ .option('-c, --config <path>', 'Path to .coderifts.yml config file')
22
+ .option('--no-normalize', 'Skip spec normalization (raw diff mode)')
23
+ .action(async (oldSpec, newSpec, options) => {
24
+ const { diff } = require('../src/commands/diff');
25
+ await diff(oldSpec, newSpec, options);
26
+ });
27
+
28
+ // ── init command ──
29
+ program
30
+ .command('init [template]')
31
+ .description('Generate a .coderifts.yml from a policy template (startup, growth, fintech, public-api, microservices)')
32
+ .action(async (template) => {
33
+ const { init } = require('../src/commands/init');
34
+ await init(template);
35
+ });
36
+
37
+ // ── login command ──
38
+ program
39
+ .command('login')
40
+ .description('Save your API key for cloud features')
41
+ .action(async () => {
42
+ const { login } = require('../src/commands/login');
43
+ await login();
44
+ });
45
+
46
+ // ── hook command group ──
47
+ const hookCmd = program
48
+ .command('hook')
49
+ .description('Manage the CodeRifts pre-push Git hook');
50
+
51
+ hookCmd
52
+ .command('install')
53
+ .description('Install the CodeRifts pre-push hook in the current Git repo')
54
+ .action(() => {
55
+ const { install } = require('../src/commands/hook');
56
+ install();
57
+ });
58
+
59
+ hookCmd
60
+ .command('uninstall')
61
+ .description('Remove the CodeRifts pre-push hook from the current Git repo')
62
+ .action(() => {
63
+ const { uninstall } = require('../src/commands/hook');
64
+ uninstall();
65
+ });
66
+
67
+ hookCmd
68
+ .command('status')
69
+ .description('Show whether the CodeRifts pre-push hook is installed and configured')
70
+ .action(() => {
71
+ const { status } = require('../src/commands/hook');
72
+ status();
73
+ });
74
+
75
+ program.parse();
package/dist/cli.js CHANGED
@@ -3003,7 +3003,7 @@ var require_package = __commonJS({
3003
3003
  "package.json"(exports2, module2) {
3004
3004
  module2.exports = {
3005
3005
  name: "coderifts",
3006
- version: "1.7.0",
3006
+ version: "1.7.1",
3007
3007
  description: "Detect breaking API changes from the command line. Works locally or with the CodeRifts cloud API.",
3008
3008
  author: "CodeRifts <hello@coderifts.com>",
3009
3009
  license: "MIT",
@@ -3013,6 +3013,8 @@ var require_package = __commonJS({
3013
3013
  main: "dist/cli.js",
3014
3014
  files: [
3015
3015
  "dist/",
3016
+ "bin/",
3017
+ "scripts/",
3016
3018
  "README.md"
3017
3019
  ],
3018
3020
  keywords: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coderifts",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
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",
@@ -10,6 +10,8 @@
10
10
  "main": "dist/cli.js",
11
11
  "files": [
12
12
  "dist/",
13
+ "bin/",
14
+ "scripts/",
13
15
  "README.md"
14
16
  ],
15
17
  "keywords": [
@@ -0,0 +1,53 @@
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
+ let patched = false;
14
+ if (!content.includes('_ZSchema')) {
15
+ content = content.replace(
16
+ 'const ZSchema = require("z-schema");',
17
+ 'const _ZSchema = require("z-schema"); const ZSchema = _ZSchema.default || _ZSchema;'
18
+ );
19
+ patched = true;
20
+ }
21
+ // z-schema v10+ requires ZSchema.create() instead of new ZSchema()
22
+ if (content.includes('new ZSchema(') && !content.includes('ZSchema.create')) {
23
+ content = content.replace(
24
+ /return new ZSchema\(/g,
25
+ 'return (typeof ZSchema.create === "function" ? ZSchema.create : (opts) => new ZSchema(opts))('
26
+ );
27
+ patched = true;
28
+ }
29
+ if (patched) {
30
+ fs.writeFileSync(schemaPath, content);
31
+ console.log('postinstall: patched z-schema import/constructor in swagger-parser');
32
+ }
33
+ } catch (err) {
34
+ console.log('postinstall: skipping z-schema patch:', err.message);
35
+ }
36
+
37
+ // Patch 2: json-schema-ref-parser v11+ exports { default: $RefParser } instead of $RefParser directly
38
+ // json-schema-diff uses `new RefParser()` which breaks with the new export style
39
+ try {
40
+ const derefPath = require.resolve('json-schema-diff/dist/json-schema-diff/diff-schemas/dereference-schema.js');
41
+ let content2 = fs.readFileSync(derefPath, 'utf8');
42
+
43
+ if (!content2.includes('_RefParser')) {
44
+ content2 = content2.replace(
45
+ 'const RefParser = require("json-schema-ref-parser");',
46
+ 'const _RefParser = require("json-schema-ref-parser"); const RefParser = _RefParser.default || _RefParser;'
47
+ );
48
+ fs.writeFileSync(derefPath, content2);
49
+ console.log('postinstall: patched json-schema-ref-parser import in json-schema-diff');
50
+ }
51
+ } catch (err) {
52
+ console.log('postinstall: skipping ref-parser patch:', err.message);
53
+ }