easegit-cli 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -14,11 +14,13 @@ EaseGit creates automatic safety checkpoints before dangerous Git operations and
14
14
  ## Installation
15
15
 
16
16
  ```bash
17
- npm install -g easegit
17
+ npm install -g easegit-cli # installs command names: easegit (preferred) and easegit-cli
18
18
  cd my-repo
19
- easegit init
19
+ easegit init # or: easegit-cli init
20
20
  ```
21
21
 
22
+ No global install? Use `npx easegit init` (or `npx easegit-cli init`). On Windows ensure your global npm bin (e.g., `%AppData%\npm`) is on `PATH`.
23
+
22
24
  ## Usage
23
25
 
24
26
  ### Setup (one time)
package/dist/init.js CHANGED
@@ -57,14 +57,17 @@ async function init() {
57
57
  // Get the hooks template directory (from installed package)
58
58
  // This will be in node_modules/easegit/hooks or local hooks/ during development
59
59
  const packageHooksDir = path.join(__dirname, '..', 'hooks');
60
+ const packageRoot = path.join(__dirname, '..');
60
61
  // Install hooks
61
62
  for (const hookName of hooks) {
62
63
  const hookPath = path.join(hooksDir, hookName);
63
64
  const templatePath = path.join(packageHooksDir, hookName);
64
65
  if (fs.existsSync(templatePath)) {
65
- // Copy the hook template
66
+ // Copy the hook template and stamp in the absolute package root so hooks work even when the
67
+ // package is installed globally (no node_modules in the target repo).
66
68
  const hookContent = fs.readFileSync(templatePath, 'utf8');
67
- fs.writeFileSync(hookPath, hookContent, { mode: 0o755 });
69
+ const stampedContent = hookContent.replace(/__EASEGIT_PACKAGE_ROOT__/g, packageRoot.replace(/\\/g, '/'));
70
+ fs.writeFileSync(hookPath, stampedContent, { mode: 0o755 });
68
71
  }
69
72
  }
70
73
  console.log('EaseGit initialized successfully');
@@ -3,9 +3,11 @@
3
3
  // Post-checkout hook - creates checkpoint after checkout
4
4
  // Also detects failures and warns user
5
5
  const path = require('path');
6
- const mainPath = path.join(__dirname, '..', '..');
7
- const { createCheckpoint } = require(path.join(mainPath, 'dist', 'snapshot', 'create'));
8
- const { hasMergeConflicts, isDetachedHead, isDirty } = require(path.join(mainPath, 'dist', 'git', 'plumbing'));
6
+ const defaultRoot = path.join(__dirname, '..', '..');
7
+ const configuredRoot = process.env.EASEGIT_PACKAGE_ROOT || "__EASEGIT_PACKAGE_ROOT__";
8
+ const packageRoot = configuredRoot.startsWith('__EASEGIT_PACKAGE_ROOT__') ? defaultRoot : configuredRoot;
9
+ const { createCheckpoint } = require(path.join(packageRoot, 'dist', 'snapshot', 'create'));
10
+ const { hasMergeConflicts, isDetachedHead, isDirty } = require(path.join(packageRoot, 'dist', 'git', 'plumbing'));
9
11
 
10
12
  // Create checkpoint for the new state
11
13
  createCheckpoint('checkout');
@@ -2,7 +2,9 @@
2
2
 
3
3
  // Pre-merge hook - creates checkpoint before merge
4
4
  const path = require('path');
5
- const mainPath = path.join(__dirname, '..', '..');
6
- const { createCheckpoint } = require(path.join(mainPath, 'dist', 'snapshot', 'create'));
5
+ const defaultRoot = path.join(__dirname, '..', '..');
6
+ const configuredRoot = process.env.EASEGIT_PACKAGE_ROOT || "__EASEGIT_PACKAGE_ROOT__";
7
+ const packageRoot = configuredRoot.startsWith('__EASEGIT_PACKAGE_ROOT__') ? defaultRoot : configuredRoot;
8
+ const { createCheckpoint } = require(path.join(packageRoot, 'dist', 'snapshot', 'create'));
7
9
 
8
10
  createCheckpoint('merge');
package/hooks/pre-push CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  // Pre-push hook - creates checkpoint before push
4
4
  const path = require('path');
5
- const mainPath = path.join(__dirname, '..', '..');
6
- const { createCheckpoint } = require(path.join(mainPath, 'dist', 'snapshot', 'create'));
5
+ const defaultRoot = path.join(__dirname, '..', '..');
6
+ const configuredRoot = process.env.EASEGIT_PACKAGE_ROOT || "__EASEGIT_PACKAGE_ROOT__";
7
+ const packageRoot = configuredRoot.startsWith('__EASEGIT_PACKAGE_ROOT__') ? defaultRoot : configuredRoot;
8
+ const { createCheckpoint } = require(path.join(packageRoot, 'dist', 'snapshot', 'create'));
7
9
 
8
10
  createCheckpoint('push');
package/hooks/pre-rebase CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  // Pre-rebase hook - creates checkpoint before rebase
4
4
  const path = require('path');
5
- const mainPath = path.join(__dirname, '..', '..');
6
- const { createCheckpoint } = require(path.join(mainPath, 'dist', 'snapshot', 'create'));
5
+ const defaultRoot = path.join(__dirname, '..', '..');
6
+ const configuredRoot = process.env.EASEGIT_PACKAGE_ROOT || "__EASEGIT_PACKAGE_ROOT__";
7
+ const packageRoot = configuredRoot.startsWith('__EASEGIT_PACKAGE_ROOT__') ? defaultRoot : configuredRoot;
8
+ const { createCheckpoint } = require(path.join(packageRoot, 'dist', 'snapshot', 'create'));
7
9
 
8
10
  createCheckpoint('rebase');
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "easegit-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Automatic checkpoints before Git can hurt you",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
- "easegit": "./bin/easegit"
7
+ "easegit": "./bin/easegit",
8
+ "easegit-cli": "./bin/easegit"
8
9
  },
9
10
  "files": [
10
11
  "dist",