Commit a5fce30
authored
feat(cli): self update preserves install scope (local vs global) (#1132)
* feat(cli): self update preserves install scope (local vs global)
Detect whether agentv was invoked from a local project dependency
(process.argv[1] contains node_modules) versus a global install, and
run the package manager install command with matching scope:
- Global (default): `npm install -g agentv@latest` / `bun add -g agentv@latest`
- Local: `npm install agentv@latest` / `bun add agentv@latest`
The `self update` command surfaces the detected scope in its console
output so users can see where the update is being applied.
Closes #1127
* test(cli): tighten node_modules path check and cover getInstallArgs
Address review feedback:
- Match `/node_modules/` (POSIX) or `\node_modules\` (Windows) as an
actual path segment so paths that merely embed the substring
(e.g. `/opt/my_node_modules_tool/`) aren't misclassified as local.
- Export `getInstallArgs` and assert the `-g` flag is present for
global and absent for local, for both npm and bun.
- Add a Windows path case for `detectInstallScopeFromPath`.
- Reword the scope label in the console log to avoid nested parens.1 parent ef22041 commit a5fce30
3 files changed
Lines changed: 132 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
6 | | - | |
| 11 | + | |
7 | 12 | | |
8 | 13 | | |
9 | 14 | | |
| |||
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
43 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
44 | 51 | | |
45 | | - | |
| 52 | + | |
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
38 | 61 | | |
39 | 62 | | |
40 | 63 | | |
| |||
83 | 106 | | |
84 | 107 | | |
85 | 108 | | |
86 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
87 | 114 | | |
88 | | - | |
| 115 | + | |
| 116 | + | |
89 | 117 | | |
90 | 118 | | |
91 | 119 | | |
92 | | - | |
93 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
94 | 123 | | |
95 | 124 | | |
96 | 125 | | |
97 | 126 | | |
98 | 127 | | |
99 | 128 | | |
| 129 | + | |
| 130 | + | |
100 | 131 | | |
101 | 132 | | |
102 | 133 | | |
103 | 134 | | |
104 | 135 | | |
105 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
106 | 143 | | |
107 | 144 | | |
108 | 145 | | |
| 146 | + | |
109 | 147 | | |
110 | | - | |
| 148 | + | |
111 | 149 | | |
112 | 150 | | |
113 | 151 | | |
114 | 152 | | |
115 | 153 | | |
116 | | - | |
| 154 | + | |
117 | 155 | | |
118 | 156 | | |
119 | 157 | | |
| |||
125 | 163 | | |
126 | 164 | | |
127 | 165 | | |
128 | | - | |
| 166 | + | |
129 | 167 | | |
130 | 168 | | |
131 | 169 | | |
| |||
135 | 173 | | |
136 | 174 | | |
137 | 175 | | |
138 | | - | |
| 176 | + | |
139 | 177 | | |
140 | 178 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
| |||
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
0 commit comments