@edcalderon/versioning 1.5.0 โ†’ 1.5.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  # Changelog
2
4
 
3
5
  All notable changes to this project will be documented in this file.
@@ -5,6 +7,17 @@ All notable changes to this project will be documented in this file.
5
7
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
8
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
9
 
10
+ ## [1.5.1](https://github.com/edcalderon/my-second-brain/tree/main/packages/versioning) (2026-03-19)
11
+
12
+ ### Fixed
13
+ - ๐Ÿ”ง Fixed `secrets-check` extension to use Husky v9 hook format (removed deprecated `._/husky.sh` sourcing)
14
+ - ๐Ÿ”ง Fixed `cleanup-repo` extension to use Husky v9 hook format
15
+ - ๐Ÿ”„ Enhanced `init` command to automatically set up husky and add `prepare` script to package.json
16
+ - โœจ Added optional `postinstall` hook to versioning package that conditionally sets up husky when consumed
17
+
18
+ ### Changed
19
+ - ๐Ÿ“ Updated hook generation to be compatible with Husky v9+ (eliminates deprecation warnings in v10)
20
+
8
21
  ## [1.5.0](https://github.com/edcalderon/my-second-brain/tree/main/packages/versioning) (2026-03-19)
9
22
 
10
23
  ### Added
package/README.md CHANGED
@@ -8,15 +8,16 @@ A comprehensive versioning and changelog management tool designed for monorepos
8
8
 
9
9
  ---
10
10
 
11
- ## ๐Ÿ“‹ Latest Changes (v1.5.0)
12
-
13
- ### Added
14
- - โœจ New `workspace-env` extension (v1.0.0)
15
- - `versioning env sync` to generate per-target `.env.local` and `.env.example` files from one canonical manifest
16
- - `versioning env doctor` to report missing required variables and unknown root env keys
17
- - `versioning env validate` for CI-friendly required variable validation with non-zero exit on missing vars
18
- - Supports manifest sources, aliases, canonical variable metadata, and target key mapping
19
- - ๐Ÿงช Added unit coverage for env parsing, sync generation, validation logic, and command registration
11
+ ## ๐Ÿ“‹ Latest Changes (v1.5.1)
12
+
13
+ ### Fixed
14
+ - ๐Ÿ”ง Fixed `secrets-check` extension to use Husky v9 hook format (removed deprecated `._/husky.sh` sourcing)
15
+ - ๐Ÿ”ง Fixed `cleanup-repo` extension to use Husky v9 hook format
16
+ - ๐Ÿ”„ Enhanced `init` command to automatically set up husky and add `prepare` script to package.json
17
+ - โœจ Added optional `postinstall` hook to versioning package that conditionally sets up husky when consumed
18
+
19
+ ### Changed
20
+ - ๐Ÿ“ Updated hook generation to be compatible with Husky v9+ (eliminates deprecation warnings in v10)
20
21
 
21
22
  For full version history, see [CHANGELOG.md](./CHANGELOG.md) and [GitHub releases](https://github.com/edcalderon/my-second-brain/releases)
22
23
 
package/dist/cli.js CHANGED
@@ -35,7 +35,9 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  const commander_1 = require("commander");
38
+ const path = __importStar(require("path"));
38
39
  const fs = __importStar(require("fs-extra"));
40
+ const child_process_1 = require("child_process");
39
41
  const versioning_1 = require("./versioning");
40
42
  const changelog_1 = require("./changelog");
41
43
  const sync_1 = require("./sync");
@@ -406,6 +408,26 @@ program
406
408
  };
407
409
  await fs.writeJson(configPath, defaultConfig, { spaces: 2 });
408
410
  console.log('โœ… Initialized versioning config at versioning.config.json');
411
+ // Set up husky if in a git repo with a package.json
412
+ const pkgJsonPath = path.resolve('package.json');
413
+ if (await fs.pathExists(pkgJsonPath)) {
414
+ const pkgJson = await fs.readJson(pkgJsonPath);
415
+ // Add prepare script if missing
416
+ if (!pkgJson.scripts?.prepare) {
417
+ pkgJson.scripts = pkgJson.scripts || {};
418
+ pkgJson.scripts.prepare = 'husky';
419
+ await fs.writeJson(pkgJsonPath, pkgJson, { spaces: 2 });
420
+ console.log('โœ… Added "prepare": "husky" to package.json');
421
+ }
422
+ // Run husky to set core.hooksPath
423
+ try {
424
+ (0, child_process_1.execSync)('npx husky', { stdio: 'ignore' });
425
+ console.log('โœ… Husky hooks initialized (.husky/)');
426
+ }
427
+ catch {
428
+ console.log('โš ๏ธ Could not initialize husky. Run "npx husky" manually.');
429
+ }
430
+ }
409
431
  }
410
432
  catch (error) {
411
433
  console.error('โŒ Error:', error instanceof Error ? error.message : String(error));
@@ -599,7 +599,6 @@ const extension = {
599
599
  else {
600
600
  const content = [
601
601
  '#!/bin/sh',
602
- '. "$(dirname "$0")/_/husky.sh"',
603
602
  '',
604
603
  cleanupBlock
605
604
  ].join('\n');
@@ -187,7 +187,6 @@ const extension = {
187
187
  else {
188
188
  const content = [
189
189
  '#!/bin/sh',
190
- '. "$(dirname "$0")/_/husky.sh"',
191
190
  '',
192
191
  block
193
192
  ].join('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edcalderon/versioning",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "A comprehensive versioning and changelog management tool for monorepos",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -13,6 +13,7 @@
13
13
  "test:watch": "jest --watch",
14
14
  "test:coverage": "jest --coverage",
15
15
  "lint": "eslint src/**/*.ts",
16
+ "postinstall": "node scripts/post-install.js",
16
17
  "prepublishOnly": "npm run build && npm run test",
17
18
  "version:patch": "node dist/cli.js patch --no-commit --no-tag",
18
19
  "version:minor": "node dist/cli.js minor --no-commit --no-tag",
@@ -80,4 +81,4 @@
80
81
  "url": "git+https://github.com/edcalderon/my-second-brain.git",
81
82
  "directory": "packages/versioning"
82
83
  }
83
- }
84
+ }
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Post-install script: Optionally set up husky if git is available
5
+ * This allows consumers of the versioning package to automatically
6
+ * set up git hooks when git is present.
7
+ */
8
+
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const { execSync } = require('child_process');
12
+
13
+ function isGitRepo() {
14
+ try {
15
+ execSync('git rev-parse --git-dir', { stdio: 'ignore' });
16
+ return true;
17
+ } catch {
18
+ return false;
19
+ }
20
+ }
21
+
22
+ function hasHusky() {
23
+ try {
24
+ const rootDir = process.cwd();
25
+ // Check if husky is in node_modules
26
+ const huskyPath = path.join(rootDir, 'node_modules', 'husky');
27
+ return fs.existsSync(huskyPath);
28
+ } catch {
29
+ return false;
30
+ }
31
+ }
32
+
33
+ function setupHusky() {
34
+ try {
35
+ const rootDir = process.cwd();
36
+ const pkgJsonPath = path.join(rootDir, 'package.json');
37
+
38
+ if (!fs.existsSync(pkgJsonPath)) {
39
+ return; // Not in a package directory
40
+ }
41
+
42
+ const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
43
+
44
+ // Add prepare script if not present
45
+ if (!pkgJson.scripts) {
46
+ pkgJson.scripts = {};
47
+ }
48
+
49
+ if (!pkgJson.scripts.prepare) {
50
+ pkgJson.scripts.prepare = 'husky';
51
+ fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\n');
52
+ }
53
+
54
+ // Try to initialize husky
55
+ execSync('npx husky', { stdio: 'ignore' });
56
+ } catch {
57
+ // Silently fail - husky setup is optional
58
+ }
59
+ }
60
+
61
+ // Main logic
62
+ if (isGitRepo() && hasHusky()) {
63
+ setupHusky();
64
+ }