@contractual/cli 0.1.0-dev.1 → 0.1.0-dev.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"contract.command.d.ts","sourceRoot":"","sources":["../../src/commands/contract.command.ts"],"names":[],"mappings":"AAYA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAsB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAO3E;;GAEG;AACH,UAAU,kBAAmB,SAAQ,aAAa;IAChD,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmGxF;AAsHD;;GAEG;AACH,UAAU,mBAAmB;IAC3B,qBAAqB;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAYD;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAoEf"}
1
+ {"version":3,"file":"contract.command.d.ts","sourceRoot":"","sources":["../../src/commands/contract.command.ts"],"names":[],"mappings":"AAYA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAsB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAO3E;;GAEG;AACH,UAAU,kBAAmB,SAAQ,aAAa;IAChD,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoGxF;AAsHD;;GAEG;AACH,UAAU,mBAAmB;IAC3B,qBAAqB;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAYD;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAoEf"}
@@ -2,7 +2,7 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { join, resolve, extname } from 'node:path';
3
3
  import chalk from 'chalk';
4
4
  import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
5
- import { VersionManager } from '@contractual/changesets';
5
+ import { VersionManager, updateSpecVersion } from '@contractual/changesets';
6
6
  import { loadConfig } from '../config/index.js';
7
7
  import { ensureContractualDir, detectSpecType, CONTRACTUAL_DIR, findContractualDir, } from '../utils/files.js';
8
8
  import { promptInput, promptSelect, promptVersion, CONTRACT_TYPE_CHOICES, } from '../utils/prompts.js';
@@ -78,6 +78,7 @@ export async function contractAddCommand(options = {}) {
78
78
  ensureContractualDir(cwd);
79
79
  const versionManager = new VersionManager(contractualDir);
80
80
  const absolutePath = resolve(cwd, specPath);
81
+ updateSpecVersion(absolutePath, version, contractType);
81
82
  versionManager.setVersion(contractName, version, absolutePath);
82
83
  // Print summary
83
84
  const snapshotExt = extname(specPath) || '.yaml';
@@ -7,6 +7,8 @@ interface VersionOptions extends PromptOptions {
7
7
  dryRun?: boolean;
8
8
  /** Output JSON (implies --yes) */
9
9
  json?: boolean;
10
+ /** Skip updating version field inside spec files */
11
+ syncVersion?: boolean;
10
12
  }
11
13
  /**
12
14
  * Consume changesets and bump versions
@@ -1 +1 @@
1
- {"version":3,"file":"version.command.d.ts","sourceRoot":"","sources":["../../src/commands/version.command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAaxE;;GAEG;AACH,UAAU,cAAe,SAAQ,aAAa;IAC5C,+BAA+B;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kCAAkC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAYD;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsOhF"}
1
+ {"version":3,"file":"version.command.d.ts","sourceRoot":"","sources":["../../src/commands/version.command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAcxE;;GAEG;AACH,UAAU,cAAe,SAAQ,aAAa;IAC5C,+BAA+B;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kCAAkC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAYD;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8OhF"}
@@ -5,7 +5,7 @@ import ora from 'ora';
5
5
  import { loadConfig } from '../config/index.js';
6
6
  import { findContractualDir, CHANGESETS_DIR } from '../utils/files.js';
7
7
  import { promptConfirm } from '../utils/prompts.js';
8
- import { VersionManager, PreReleaseManager, readChangesets, aggregateBumps, extractContractChanges, appendChangelog, incrementVersion, incrementVersionWithPreRelease, } from '@contractual/changesets';
8
+ import { VersionManager, PreReleaseManager, readChangesets, aggregateBumps, extractContractChanges, appendChangelog, incrementVersion, incrementVersionWithPreRelease, updateSpecVersion, } from '@contractual/changesets';
9
9
  /**
10
10
  * Consume changesets and bump versions
11
11
  */
@@ -129,15 +129,22 @@ export async function versionCommand(options = {}) {
129
129
  }
130
130
  const oldVersion = versionManager.getVersion(contractName) ?? '0.0.0';
131
131
  let newVersion;
132
+ const shouldSyncVersion = options.syncVersion !== false && contract.syncVersion !== false;
132
133
  if (preReleaseTag) {
133
134
  // Use pre-release version increment
134
135
  newVersion = incrementVersionWithPreRelease(oldVersion, bumpType, preReleaseTag);
136
+ if (shouldSyncVersion) {
137
+ updateSpecVersion(contract.absolutePath, newVersion, contract.type);
138
+ }
135
139
  versionManager.setVersion(contractName, newVersion, contract.absolutePath);
136
140
  }
137
141
  else {
138
- // Normal bump
139
- const result = versionManager.bump(contractName, bumpType, contract.absolutePath);
140
- newVersion = result.newVersion;
142
+ // Normal bump — compute version first, update spec, then bump (which copies to snapshots)
143
+ newVersion = incrementVersion(oldVersion, bumpType);
144
+ if (shouldSyncVersion) {
145
+ updateSpecVersion(contract.absolutePath, newVersion, contract.type);
146
+ }
147
+ versionManager.bump(contractName, bumpType, contract.absolutePath);
141
148
  }
142
149
  // Extract changes text from changesets for this contract
143
150
  const changes = extractContractChanges(changesets, contractName);
package/dist/commands.js CHANGED
@@ -66,6 +66,7 @@ program
66
66
  .option('-y, --yes', 'Skip confirmation prompt')
67
67
  .option('--dry-run', 'Preview without applying')
68
68
  .option('--json', 'Output JSON (implies --yes)')
69
+ .option('--no-sync-version', 'Skip updating version field inside spec files')
69
70
  .action(versionCommand);
70
71
  const preCmd = program.command('pre').description('Manage pre-release versions');
71
72
  preCmd
@@ -40,6 +40,11 @@
40
40
  { "type": "boolean", "const": false, "description": "Disable breaking change detection" }
41
41
  ]
42
42
  },
43
+ "syncVersion": {
44
+ "type": "boolean",
45
+ "description": "Sync version field inside the spec file on version bump (default: true). Set to false to skip.",
46
+ "default": true
47
+ },
43
48
  "generate": {
44
49
  "type": "array",
45
50
  "description": "Output generation commands",
@@ -6,6 +6,6 @@
6
6
  */
7
7
  import '@contractual/governance';
8
8
  export { registerLinter, registerDiffer, getLinter, getDiffer, hasLinter, hasDiffer, getRegisteredLinterTypes, getRegisteredDifferTypes, } from '@contractual/governance';
9
- export { lintOpenAPI, lintJsonSchema, diffOpenAPI, diffJsonSchema } from '@contractual/governance';
9
+ export { lintOpenAPI, lintJsonSchema, diffOpenApi, diffJsonSchema } from '@contractual/governance';
10
10
  export { executeCustomCommand, parseCustomLintOutput, parseCustomDiffOutput, } from '@contractual/governance';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -9,6 +9,6 @@ import '@contractual/governance';
9
9
  // Re-export registry functions
10
10
  export { registerLinter, registerDiffer, getLinter, getDiffer, hasLinter, hasDiffer, getRegisteredLinterTypes, getRegisteredDifferTypes, } from '@contractual/governance';
11
11
  // Re-export individual engines for direct use
12
- export { lintOpenAPI, lintJsonSchema, diffOpenAPI, diffJsonSchema } from '@contractual/governance';
12
+ export { lintOpenAPI, lintJsonSchema, diffOpenApi, diffJsonSchema } from '@contractual/governance';
13
13
  // Re-export runner utilities for custom commands
14
14
  export { executeCustomCommand, parseCustomLintOutput, parseCustomDiffOutput, } from '@contractual/governance';
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { registerLinter, registerDiffer, getLinter, getDiffer } from './governan
3
3
  export { diffContracts } from './core/diff.js';
4
4
  export type { DiffOptions, DiffContractsResult } from './core/diff.js';
5
5
  export { findContractualDir, getSnapshotPath, copyToSnapshots, CONTRACTUAL_DIR, } from './utils/files.js';
6
- export { VersionManager, PreReleaseManager, createChangeset, readChangesets, aggregateBumps, generateChangesetName, extractContractChanges, appendChangelog, incrementVersionWithPreRelease, VERSIONS_FILE, SNAPSHOTS_DIR, CHANGESETS_DIR, PRE_RELEASE_FILE, } from '@contractual/changesets';
6
+ export { VersionManager, PreReleaseManager, createChangeset, readChangesets, aggregateBumps, generateChangesetName, extractContractChanges, appendChangelog, incrementVersion, incrementVersionWithPreRelease, VERSIONS_FILE, SNAPSHOTS_DIR, CHANGESETS_DIR, PRE_RELEASE_FILE, updateSpecVersion, } from '@contractual/changesets';
7
7
  export type { BumpOperationResult } from '@contractual/changesets';
8
8
  export type * from '@contractual/types';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAG7F,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGvE,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,8BAA8B,EAC9B,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,mBAAmB,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAG7F,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGvE,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,8BAA8B,EAC9B,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,mBAAmB,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -6,4 +6,4 @@ export { diffContracts } from './core/diff.js';
6
6
  // File utilities
7
7
  export { findContractualDir, getSnapshotPath, copyToSnapshots, CONTRACTUAL_DIR, } from './utils/files.js';
8
8
  // Re-export from @contractual/changesets
9
- export { VersionManager, PreReleaseManager, createChangeset, readChangesets, aggregateBumps, generateChangesetName, extractContractChanges, appendChangelog, incrementVersionWithPreRelease, VERSIONS_FILE, SNAPSHOTS_DIR, CHANGESETS_DIR, PRE_RELEASE_FILE, } from '@contractual/changesets';
9
+ export { VersionManager, PreReleaseManager, createChangeset, readChangesets, aggregateBumps, generateChangesetName, extractContractChanges, appendChangelog, incrementVersion, incrementVersionWithPreRelease, VERSIONS_FILE, SNAPSHOTS_DIR, CHANGESETS_DIR, PRE_RELEASE_FILE, updateSpecVersion, } from '@contractual/changesets';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contractual/cli",
3
3
  "private": false,
4
- "version": "0.1.0-dev.1",
4
+ "version": "0.1.0-dev.3",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -57,9 +57,9 @@
57
57
  "README.md"
58
58
  ],
59
59
  "dependencies": {
60
- "@contractual/changesets": "0.1.0-dev.0",
61
- "@contractual/governance": "0.1.0-dev.1",
62
- "@contractual/types": "0.1.0-dev.0",
60
+ "@contractual/changesets": "0.1.0-dev.1",
61
+ "@contractual/governance": "0.1.0-dev.3",
62
+ "@contractual/types": "0.1.0-dev.1",
63
63
  "@inquirer/prompts": "^8.1.0",
64
64
  "ajv": "^8.17.1",
65
65
  "ajv-formats": "^3.0.1",
@@ -77,5 +77,5 @@
77
77
  "@vitest/coverage-v8": "^3.0.0",
78
78
  "vitest": "^3.0.3"
79
79
  },
80
- "gitHead": "cb3d62c2d3d940e90502e5d0222381c2eace2324"
80
+ "gitHead": "99ad70fafdd659510d75c1bd247a59dc6e499355"
81
81
  }
@@ -40,6 +40,11 @@
40
40
  { "type": "boolean", "const": false, "description": "Disable breaking change detection" }
41
41
  ]
42
42
  },
43
+ "syncVersion": {
44
+ "type": "boolean",
45
+ "description": "Sync version field inside the spec file on version bump (default: true). Set to false to skip.",
46
+ "default": true
47
+ },
43
48
  "generate": {
44
49
  "type": "array",
45
50
  "description": "Output generation commands",