vanguard-cli 3.1.7 → 3.1.10

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.
@@ -2,40 +2,24 @@ import fs from 'fs-extra';
2
2
  import path from 'path';
3
3
  import os from 'os';
4
4
  import chalk from 'chalk';
5
+ import { execSync } from 'child_process';
5
6
  import { createSpinner } from '../utils/spinner.js';
6
7
 
7
- const SCRIPTS = {
8
- bash: {
9
- file: '.bashrc',
10
- template: `
8
+ const BASH_ZSH_TEMPLATE = `
11
9
  # --- VANGUARD PROTECTION START ---
12
10
  git() {
13
- if [ "$1" = "clone" ]; then
14
- vanguard clone "$@"
11
+ if [ "$1" = "clone" ] && [ -z "$VANGUARD_INTERNAL" ]; then
12
+ export VANGUARD_INTERNAL=1
13
+ vanguard clone "\${@:2}"
14
+ unset VANGUARD_INTERNAL
15
15
  else
16
16
  command git "$@"
17
17
  fi
18
18
  }
19
19
  # --- VANGUARD PROTECTION END ---
20
- `
21
- },
22
- zsh: {
23
- file: '.zshrc',
24
- template: `
25
- # --- VANGUARD PROTECTION START ---
26
- git() {
27
- if [ "$1" = "clone" ]; then
28
- vanguard clone "$@"
29
- else
30
- command git "$@"
31
- fi
32
- }
33
- # --- VANGUARD PROTECTION END ---
34
- `
35
- },
36
- fish: {
37
- file: '.config/fish/config.fish',
38
- template: `
20
+ `;
21
+
22
+ const FISH_TEMPLATE = `
39
23
  # --- VANGUARD PROTECTION START ---
40
24
  function git
41
25
  if test "$argv[1]" = "clone"
@@ -45,22 +29,30 @@ function git
45
29
  end
46
30
  end
47
31
  # --- VANGUARD PROTECTION END ---
48
- `
49
- },
50
- powershell: {
51
- file: 'Documents/PowerShell/Microsoft.PowerShell_profile.ps1',
52
- template: `
32
+ `;
33
+
34
+ const POWERSHELL_TEMPLATE = `
53
35
  # --- VANGUARD PROTECTION START ---
54
36
  function git {
55
- if ($args[0] -eq "clone") {
56
- vanguard clone @(if ($args.Length -gt 1) { $args[1..($args.Length-1)] })
37
+ if ($args[0] -eq "clone" -and !$env:VANGUARD_INTERNAL) {
38
+ $env:VANGUARD_INTERNAL = "1"
39
+ try {
40
+ vanguard clone @(if ($args.Length -gt 1) { $args[1..($args.Length-1)] })
41
+ } finally {
42
+ $env:VANGUARD_INTERNAL = $null
43
+ }
57
44
  } else {
58
45
  & (Get-Command git -CommandType Application) @args
59
46
  }
60
47
  }
61
48
  # --- VANGUARD PROTECTION END ---
62
- `
63
- }
49
+ `;
50
+
51
+ const SCRIPTS = {
52
+ bash: { file: '.bashrc', template: BASH_ZSH_TEMPLATE },
53
+ zsh: { file: '.zshrc', template: BASH_ZSH_TEMPLATE },
54
+ fish: { file: '.config/fish/config.fish', template: FISH_TEMPLATE },
55
+ powershell: { file: 'Documents/PowerShell/Microsoft.PowerShell_profile.ps1', template: POWERSHELL_TEMPLATE }
64
56
  };
65
57
 
66
58
  export async function runIntegrate() {
@@ -75,14 +67,36 @@ export async function runIntegrate() {
75
67
  if (shell === 'powershell') continue;
76
68
  const profilePath = path.join(home, info.file);
77
69
  if (await fs.pathExists(profilePath)) {
78
- detected.push({ name: shell, path: profilePath, info });
70
+ detected.push({ name: shell, path: profilePath, template: info.template });
79
71
  }
80
72
  }
81
73
 
82
- // Check PowerShell
83
- const psProfile = path.join(home, SCRIPTS.powershell.file);
84
- if (await fs.pathExists(psProfile) || os.platform() === 'win32') {
85
- detected.push({ name: 'powershell', path: psProfile, info: SCRIPTS.powershell });
74
+ // Check PowerShell with robust detection
75
+ const psProfiles = [];
76
+ if (os.platform() === 'win32') {
77
+ const documentsPath = path.join(home, 'Documents');
78
+ const oneDriveDocumentsPath = path.join(home, 'OneDrive', 'Documents');
79
+ const oneDriveBelgelerPath = path.join(home, 'OneDrive', 'Belgeler'); // User specific Turkish path
80
+
81
+ const possibleRoots = [documentsPath, oneDriveDocumentsPath, oneDriveBelgelerPath, home];
82
+ const psFolders = ['PowerShell', 'WindowsPowerShell'];
83
+
84
+ for (const root of possibleRoots) {
85
+ for (const folder of psFolders) {
86
+ const profile = path.join(root, folder, 'Microsoft.PowerShell_profile.ps1');
87
+ psProfiles.push(profile);
88
+ }
89
+ }
90
+ } else {
91
+ psProfiles.push(path.join(home, SCRIPTS.powershell.file));
92
+ }
93
+
94
+ for (const profilePath of psProfiles) {
95
+ if (await fs.pathExists(profilePath) || (os.platform() === 'win32' && profilePath.includes('PowerShell'))) {
96
+ if (!detected.some(d => d.path === profilePath)) {
97
+ detected.push({ name: 'powershell', path: profilePath, template: POWERSHELL_TEMPLATE });
98
+ }
99
+ }
86
100
  }
87
101
 
88
102
  if (detected.length === 0) {
@@ -108,11 +122,13 @@ export async function runIntegrate() {
108
122
 
109
123
  const content = await fs.readFile(profilePath, 'utf-8');
110
124
  if (content.includes('VANGUARD PROTECTION START')) {
111
- console.log(chalk.yellow(`⏩ ${shell.name} already integrated. Skipping.`));
112
- continue;
125
+ // Update existing integration if template differs significantly
126
+ console.log(chalk.yellow(`⏩ ${shell.name} already integrated. Updating wrapper...`));
127
+ const stripped = content.replace(/# --- VANGUARD PROTECTION START ---[\s\S]*?# --- VANGUARD PROTECTION END ---/g, '').trim();
128
+ await fs.writeFile(profilePath, stripped + '\n' + shell.template);
129
+ } else {
130
+ await fs.appendFile(profilePath, '\n' + shell.template);
113
131
  }
114
-
115
- await fs.appendFile(profilePath, shell.info.template);
116
132
  console.log(chalk.green(`✅ Integrated with ${shell.name} (${profilePath})`));
117
133
  } catch (err) {
118
134
  console.log(chalk.red(`❌ Failed to integrate with ${shell.name}: ${err.message}`));
@@ -32,7 +32,7 @@ export class IntelligenceEngine {
32
32
  )
33
33
  );
34
34
  } catch {
35
- console.log(chalk.yellow(' ⚠️ Using Local Rules Only (Offline Fallback)'));
35
+ console.log(chalk.yellow(' ⚠️ Using Local Rules Only (Offline Fallback)'));
36
36
  }
37
37
  }
38
38
 
package/lib/utils/ui.js CHANGED
@@ -53,13 +53,13 @@ export function showFooter() {
53
53
  chalk.dim('\n----------------------------------------------------------------------')
54
54
  );
55
55
  console.log(
56
- chalk.yellow('⭐ Star on GitHub: ') + chalk.underline('https://github.com/bazob/vanguard')
56
+ chalk.yellow('⭐ Star on GitHub: ') + chalk.underline('https://github.com/bazobehram/vanguard')
57
57
  );
58
58
  console.log(
59
- chalk.green('🤝 Contribute: ') + chalk.underline('https://github.com/bazob/vanguard/pulls')
59
+ chalk.green('🤝 Contribute: ') + chalk.underline('https://github.com/bazobehram/vanguard/pulls')
60
60
  );
61
61
  console.log(
62
- chalk.cyan('☕ Support the project: ') +
62
+ chalk.cyan('☕ Support the project: ') +
63
63
  chalk.underline('https://www.buymeacoffee.com/bazobehram')
64
64
  );
65
65
  console.log(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanguard-cli",
3
- "version": "3.1.7",
3
+ "version": "3.1.10",
4
4
  "description": "AI-Powered Supply Chain Firewall for Git",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,7 +19,7 @@
19
19
  "license": "MIT",
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "git+https://github.com/bazob/vanguard.git"
22
+ "url": "git+https://github.com/bazobehram/vanguard.git"
23
23
  },
24
24
  "dependencies": {
25
25
  "@google/generative-ai": "^0.21.0",
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 🚨 THREAT VECTOR: PROJECT_OMEGA (MOCK)
3
+ * This file contains the mock threat signature we added to lib/threats.json.
4
+ */
5
+
6
+ function initializeSystem() {
7
+ console.log("System initializing...");
8
+ }
9
+
10
+ // ALERT: PROJECT_OMEGA sequence initiated
11
+ const secretKey = "SG0uLi4uIHRoaXMgaXMgYSBzZWNyZXQ=";
12
+ initializeSystem();
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "vanguard-malware-lab",
3
+ "version": "1.0.0",
4
+ "description": "Educational test repository for supply chain security auditing.",
5
+ "scripts": {
6
+ "postinstall": "node ./scripts/postinstall.js"
7
+ },
8
+ "dependencies": {
9
+ "axios": "^1.6.0"
10
+ }
11
+ }