@scheduler-systems/gal-run 0.0.247 → 0.0.253
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/LICENSE +75 -9
- package/dist/index.cjs +92613 -215081
- package/dist/postinstall.cjs +906 -2533
- package/dist/preuninstall.cjs +224 -345
- package/package.json +2 -2
package/dist/preuninstall.cjs
CHANGED
|
@@ -1,358 +1,237 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
/**
|
|
3
|
+
* GAL CLI Preuninstall Script
|
|
4
|
+
*
|
|
5
|
+
* Automatically cleans up GAL-installed files when the CLI is uninstalled via pnpm.
|
|
6
|
+
* This script runs as a package lifecycle hook before package removal.
|
|
7
|
+
*
|
|
8
|
+
* What it cleans:
|
|
9
|
+
* 1. Hook files → ~/.claude/hooks/gal-*.js
|
|
10
|
+
* 2. Status line script → ~/.claude/status_lines/gal-sync-status.py
|
|
11
|
+
* 3. Rules file → ~/.claude/rules/gal-cli.md
|
|
12
|
+
* 4. Hook entries in ~/.claude/settings.json (preserves file and other hooks)
|
|
13
|
+
* 5. GAL config directory → ~/.gal/ (auth tokens, sync state, telemetry queue)
|
|
14
|
+
*
|
|
15
|
+
* Cleanup scope:
|
|
16
|
+
* - User-level files only (not project-level .gal directories)
|
|
17
|
+
* - GAL-specific entries only (preserves user's other Claude configs)
|
|
18
|
+
* - Silent fail strategy (won't prevent uninstall on errors)
|
|
19
|
+
*
|
|
20
|
+
* When it runs:
|
|
21
|
+
* - Automatically during `pnpm rm -g @scheduler-systems/gal-run`
|
|
22
|
+
* - Before package files are removed from node_modules
|
|
23
|
+
* - Can be manually triggered via `pnpm run preuninstall` in the CLI package directory
|
|
24
|
+
*
|
|
25
|
+
* Prerequisites:
|
|
26
|
+
* - Node.js 18+ (CommonJS module)
|
|
27
|
+
* - Runs with user's file system permissions
|
|
28
|
+
*
|
|
29
|
+
* Related files:
|
|
30
|
+
* - apps/cli/scripts/postinstall.cjs - Installation script
|
|
31
|
+
* - apps/cli/package.json - package lifecycle hooks configuration
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
const fs = require('fs');
|
|
35
|
+
const path = require('path');
|
|
36
|
+
const os = require('os');
|
|
37
|
+
|
|
38
|
+
// =============================================================================
|
|
39
|
+
// Cleanup Functions - settings.json
|
|
40
|
+
// =============================================================================
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Remove GAL hook entries from settings.json without deleting the file.
|
|
44
|
+
*
|
|
45
|
+
* This function surgically removes only GAL-specific hook entries while
|
|
46
|
+
* preserving the user's other hooks and settings. It handles:
|
|
47
|
+
* - Filtering GAL hooks from UserPromptSubmit array
|
|
48
|
+
* - Filtering GAL hooks from SessionStart array (v2.x)
|
|
49
|
+
* - Removing empty hook arrays after filtering
|
|
50
|
+
* - Preserving the settings.json file structure
|
|
51
|
+
*
|
|
52
|
+
* @param {string} settingsPath - Full path to ~/.claude/settings.json
|
|
53
|
+
* @returns {boolean} True if any GAL entries were removed, false otherwise
|
|
54
|
+
*/
|
|
55
|
+
function removeGalHookEntries(settingsPath) {
|
|
56
|
+
try {
|
|
57
|
+
if (!fs.existsSync(settingsPath)) {
|
|
58
|
+
return false;
|
|
27
59
|
}
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
'DxqGDw4',
|
|
50
|
-
'BNbTige',
|
|
51
|
-
'C1DPDgG',
|
|
52
|
-
'C1n5BMm',
|
|
53
|
-
'icHhquW',
|
|
54
|
-
'CgfYC2u',
|
|
55
|
-
'ChvZAa',
|
|
56
|
-
'AM9PBG',
|
|
57
|
-
'CM9TChq',
|
|
58
|
-
'rMLSzvm',
|
|
59
|
-
'DgfSBca',
|
|
60
|
-
'lMDHBa',
|
|
61
|
-
'C2v0DgK',
|
|
62
|
-
'mZiYmJK4AvbRzLfz',
|
|
63
|
-
'mJmXEwPZtvnN',
|
|
64
|
-
'y29TBwe',
|
|
65
|
-
'zgvZ',
|
|
66
|
-
'AgfZigi',
|
|
67
|
-
'l2DHBc8',
|
|
68
|
-
'zxmGzM8',
|
|
69
|
-
'yw4GDxa',
|
|
70
|
-
'BIbLCNi',
|
|
71
|
-
'z2fSlxi',
|
|
72
|
-
'Ew5J',
|
|
73
|
-
'Ag9Tzwq',
|
|
74
|
-
'B2nLzwq',
|
|
75
|
-
'AxjtEw4',
|
|
76
|
-
'ntC4nJKWmvjTufv5ta',
|
|
77
|
-
'DxaGr0e',
|
|
78
|
-
'C3rYAw4',
|
|
79
|
-
'z2fSlq',
|
|
80
|
-
'Cgf0Aa',
|
|
81
|
-
'AwXLu3K',
|
|
82
|
-
'B3zLzcK',
|
|
83
|
-
'zwr1Bgu',
|
|
84
|
-
'BgW6iha',
|
|
85
|
-
'Dw5Kihq',
|
|
86
|
-
'C29U',
|
|
87
|
-
'ndC5mti0CwrgDMXM',
|
|
88
|
-
'CM1tEw4',
|
|
89
|
-
'otuYndbgq3r3sgW',
|
|
90
|
-
'zxm6',
|
|
91
|
-
'DgvTCY8',
|
|
92
|
-
'Ag9VA3m',
|
|
93
|
-
'nJa0mdngr1zND3u',
|
|
94
|
-
'CI1ZExm',
|
|
95
|
-
'CMvHzey',
|
|
96
|
-
'mxPRve50CW',
|
|
97
|
-
'lMnSyxu',
|
|
98
|
-
'tM8Gr0e',
|
|
99
|
-
'C3rHCNq',
|
|
100
|
-
'Aw5JBhu',
|
|
101
|
-
'mJi0mtq3nfPxwMr1CG',
|
|
102
|
-
'Bg9N',
|
|
103
|
-
'cUkvKokvKokvKokvKa',
|
|
104
|
-
'B3vUDgu',
|
|
105
|
-
'icaTia',
|
|
106
|
-
'4Pwq4Pwq4Pwq4Pwq4Pwq',
|
|
107
|
-
'z2LMEq',
|
|
108
|
-
'A2v5CW',
|
|
109
|
-
'BgvHBNu',
|
|
110
|
-
'zxjYB3i',
|
|
111
|
-
'igHVB2S',
|
|
112
|
-
'zMLSDgu',
|
|
113
|
-
'4PYtienSzq',
|
|
114
|
-
'B3iSigi',
|
|
115
|
-
'A1n5BMm',
|
|
116
|
-
'BgWGD2K',
|
|
117
|
-
'CcbLBMm',
|
|
118
|
-
'ienmssa',
|
|
119
|
-
'BYbJBgu',
|
|
120
|
-
'Dw5SAw4',
|
|
121
|
-
'zgqGlwC',
|
|
122
|
-
'zxHPC3q',
|
|
123
|
-
'CMvKige',
|
|
124
|
-
'mZe0mgr2vhbArW',
|
|
125
|
-
'CMvHzgq',
|
|
126
|
-
'Aw5ZDge',
|
|
127
|
-
'BgvUz3q',
|
|
128
|
-
'ywXSzwq',
|
|
129
|
-
'CYbYzw0',
|
|
130
|
-
'Dw4k',
|
|
131
|
-
'D3jPDgu'
|
|
132
|
-
];
|
|
133
|
-
_0x3152 = function () {
|
|
134
|
-
return _0x5cc352;
|
|
135
|
-
};
|
|
136
|
-
return _0x3152();
|
|
137
|
-
}
|
|
138
|
-
function removeGalHookEntries(_0x9f2cad) {
|
|
139
|
-
const _0x4f9b6e = {
|
|
140
|
-
_0xd972c: 0x236,
|
|
141
|
-
_0xb98c61: 0x1f0,
|
|
142
|
-
_0x118c84: 0x1f2,
|
|
143
|
-
_0x28dc0c: 0x21b,
|
|
144
|
-
_0x4b4212: 0x20d,
|
|
145
|
-
_0x234a74: 0x1e4,
|
|
146
|
-
_0x3a0617: 0x218,
|
|
147
|
-
_0x1db4ab: 0x1dd,
|
|
148
|
-
_0x4462e8: 0x1f5,
|
|
149
|
-
_0x3dbb62: 0x1eb,
|
|
150
|
-
_0x3fccbf: 0x1eb,
|
|
151
|
-
_0x49a2b6: 0x23b,
|
|
152
|
-
_0x2c1505: 0x1dd,
|
|
153
|
-
_0x563329: 0x1eb,
|
|
154
|
-
_0x213229: 0x22c,
|
|
155
|
-
_0x3613fa: 0x218,
|
|
156
|
-
_0x215310: 0x1dd,
|
|
157
|
-
_0x293fb8: 0x1f5,
|
|
158
|
-
_0x47c66a: 0x1eb,
|
|
159
|
-
_0x51ca4b: 0x23b,
|
|
160
|
-
_0x578389: 0x1dd,
|
|
161
|
-
_0x4b28a8: 0x228,
|
|
162
|
-
_0x4287c5: 0x218,
|
|
163
|
-
_0x3ffbf3: 0x218,
|
|
164
|
-
_0x1d94dd: 0x1eb,
|
|
165
|
-
_0x1c1e98: 0x23b,
|
|
166
|
-
_0x3c5d41: 0x23f,
|
|
167
|
-
_0x1172e3: 0x1f6,
|
|
168
|
-
_0x2cd4d5: 0x204,
|
|
169
|
-
_0x83c3ba: 0x20a,
|
|
170
|
-
_0x5a2118: 0x227
|
|
171
|
-
}, _0x50d3f4 = {
|
|
172
|
-
_0x42af26: 0x218,
|
|
173
|
-
_0x5c571c: 0x218,
|
|
174
|
-
_0x12ef9c: 0x218,
|
|
175
|
-
_0x41a9d1: 0x22c,
|
|
176
|
-
_0x2d138f: 0x23b
|
|
177
|
-
}, _0x1444b1 = _0x3af2;
|
|
178
|
-
try {
|
|
179
|
-
if (!fs[_0x1444b1(_0x4f9b6e._0xd972c) + _0x1444b1(_0x4f9b6e._0xb98c61)](_0x9f2cad))
|
|
180
|
-
return ![];
|
|
181
|
-
const _0x423946 = JSON[_0x1444b1(_0x4f9b6e._0x118c84)](fs[_0x1444b1(_0x4f9b6e._0x28dc0c) + _0x1444b1(_0x4f9b6e._0x4b4212) + 'nc'](_0x9f2cad, _0x1444b1(_0x4f9b6e._0x234a74)));
|
|
182
|
-
if (!_0x423946[_0x1444b1(_0x4f9b6e._0x3a0617)]?.[_0x1444b1(_0x4f9b6e._0x1db4ab) + _0x1444b1(_0x4f9b6e._0x4462e8) + _0x1444b1(_0x4f9b6e._0x3dbb62) + 't'])
|
|
183
|
-
return ![];
|
|
184
|
-
const _0x2c0c5b = _0x423946[_0x1444b1(_0x4f9b6e._0x3a0617)][_0x1444b1(_0x4f9b6e._0x1db4ab) + _0x1444b1(_0x4f9b6e._0x4462e8) + _0x1444b1(_0x4f9b6e._0x3fccbf) + 't'][_0x1444b1(_0x4f9b6e._0x49a2b6) + 'h'];
|
|
185
|
-
_0x423946[_0x1444b1(_0x4f9b6e._0x3a0617)][_0x1444b1(_0x4f9b6e._0x1db4ab) + _0x1444b1(_0x4f9b6e._0x4462e8) + _0x1444b1(_0x4f9b6e._0x3dbb62) + 't'] = _0x423946[_0x1444b1(_0x4f9b6e._0x3a0617)][_0x1444b1(_0x4f9b6e._0x2c1505) + _0x1444b1(_0x4f9b6e._0x4462e8) + _0x1444b1(_0x4f9b6e._0x563329) + 't'][_0x1444b1(_0x4f9b6e._0x213229) + 'r'](_0xd4e35f => {
|
|
186
|
-
const _0x3e7ca7 = _0x3af2;
|
|
187
|
-
if (!_0xd4e35f[_0x3e7ca7(_0x50d3f4._0x42af26)])
|
|
188
|
-
return !![];
|
|
189
|
-
return _0xd4e35f[_0x3e7ca7(_0x50d3f4._0x5c571c)] = _0xd4e35f[_0x3e7ca7(_0x50d3f4._0x12ef9c)][_0x3e7ca7(_0x50d3f4._0x41a9d1) + 'r'](_0x3a9ecf => !_0x3a9ecf[_0x3e7ca7(0x1fc) + 'nd']?.[_0x3e7ca7(0x220) + _0x3e7ca7(0x1fd)](_0x3e7ca7(0x20b)) && !_0x3a9ecf[_0x3e7ca7(0x1fc) + 'nd']?.[_0x3e7ca7(0x220) + _0x3e7ca7(0x1fd)](_0x3e7ca7(0x1ff))), _0xd4e35f[_0x3e7ca7(_0x50d3f4._0x5c571c)][_0x3e7ca7(_0x50d3f4._0x2d138f) + 'h'] > 0x0;
|
|
190
|
-
});
|
|
191
|
-
_0x423946[_0x1444b1(_0x4f9b6e._0x3613fa)][_0x1444b1(_0x4f9b6e._0x215310) + _0x1444b1(_0x4f9b6e._0x293fb8) + _0x1444b1(_0x4f9b6e._0x47c66a) + 't'][_0x1444b1(_0x4f9b6e._0x51ca4b) + 'h'] === 0x0 && delete _0x423946[_0x1444b1(_0x4f9b6e._0x3a0617)][_0x1444b1(_0x4f9b6e._0x578389) + _0x1444b1(_0x4f9b6e._0x293fb8) + _0x1444b1(_0x4f9b6e._0x47c66a) + 't'];
|
|
192
|
-
Object[_0x1444b1(_0x4f9b6e._0x4b28a8)](_0x423946[_0x1444b1(_0x4f9b6e._0x4287c5)])[_0x1444b1(_0x4f9b6e._0x51ca4b) + 'h'] === 0x0 && delete _0x423946[_0x1444b1(_0x4f9b6e._0x3ffbf3)];
|
|
193
|
-
if (_0x423946[_0x1444b1(_0x4f9b6e._0x3a0617)]?.[_0x1444b1(_0x4f9b6e._0x215310) + _0x1444b1(_0x4f9b6e._0x4462e8) + _0x1444b1(_0x4f9b6e._0x1d94dd) + 't']?.[_0x1444b1(_0x4f9b6e._0x1c1e98) + 'h'] !== _0x2c0c5b)
|
|
194
|
-
return fs[_0x1444b1(_0x4f9b6e._0x3c5d41) + _0x1444b1(_0x4f9b6e._0x1172e3) + _0x1444b1(_0x4f9b6e._0x2cd4d5)](_0x9f2cad, JSON[_0x1444b1(_0x4f9b6e._0x83c3ba) + _0x1444b1(_0x4f9b6e._0x5a2118)](_0x423946, null, 0x2)), !![];
|
|
195
|
-
return ![];
|
|
196
|
-
} catch {
|
|
197
|
-
return ![];
|
|
60
|
+
|
|
61
|
+
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
|
|
62
|
+
|
|
63
|
+
if (!settings.hooks?.UserPromptSubmit) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Filter out GAL hooks while preserving user's other hooks
|
|
68
|
+
const originalLength = settings.hooks.UserPromptSubmit.length;
|
|
69
|
+
settings.hooks.UserPromptSubmit = settings.hooks.UserPromptSubmit.filter((entry) => {
|
|
70
|
+
if (!entry.hooks) return true;
|
|
71
|
+
// Keep entry only if it has non-GAL hooks
|
|
72
|
+
entry.hooks = entry.hooks.filter((hook) =>
|
|
73
|
+
!hook.command?.includes('gal-') && !hook.command?.includes('/gal/')
|
|
74
|
+
);
|
|
75
|
+
return entry.hooks.length > 0;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Remove empty hooks array
|
|
79
|
+
if (settings.hooks.UserPromptSubmit.length === 0) {
|
|
80
|
+
delete settings.hooks.UserPromptSubmit;
|
|
198
81
|
}
|
|
82
|
+
|
|
83
|
+
// Remove empty hooks object
|
|
84
|
+
if (Object.keys(settings.hooks).length === 0) {
|
|
85
|
+
delete settings.hooks;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (settings.hooks?.UserPromptSubmit?.length !== originalLength) {
|
|
89
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return false;
|
|
94
|
+
} catch {
|
|
95
|
+
// Silent fail - don't prevent uninstall if settings.json is corrupted
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
199
98
|
}
|
|
99
|
+
|
|
100
|
+
// =============================================================================
|
|
101
|
+
// Cleanup Functions - User-Level Files
|
|
102
|
+
// =============================================================================
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Clean up GAL-installed files from user's home directory.
|
|
106
|
+
*
|
|
107
|
+
* Removes:
|
|
108
|
+
* - Hook files: ~/.claude/hooks/gal-*.js
|
|
109
|
+
* - Status line script: ~/.claude/status_lines/gal-sync-status.py
|
|
110
|
+
* - Rules file: ~/.claude/rules/gal-cli.md
|
|
111
|
+
* - Hook entries from settings.json
|
|
112
|
+
*
|
|
113
|
+
* Uses silent fail strategy - logs removed files but doesn't throw errors.
|
|
114
|
+
* This ensures uninstall proceeds even if individual files are missing or
|
|
115
|
+
* have permission issues.
|
|
116
|
+
*
|
|
117
|
+
* @returns {string[]} Array of paths to files that were successfully removed
|
|
118
|
+
*/
|
|
200
119
|
function cleanupUserLevel() {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
_0x221c8d: 0x1f1,
|
|
221
|
-
_0x34ac81: 0x22b,
|
|
222
|
-
_0x15d318: 0x23d,
|
|
223
|
-
_0x5a5646: 0x20e
|
|
224
|
-
}, _0x25e26e = _0x3af2, _0x1de8bc = path[_0x25e26e(_0x38bdbe._0x184865)](os[_0x25e26e(_0x38bdbe._0x42f7f0) + 'ir'](), _0x25e26e(_0x38bdbe._0x3c89df) + 'de'), _0x324261 = path[_0x25e26e(_0x38bdbe._0x589151)](_0x1de8bc, _0x25e26e(_0x38bdbe._0x456e1f)), _0x36392a = path[_0x25e26e(_0x38bdbe._0x589151)](_0x1de8bc, _0x25e26e(_0x38bdbe._0x4c848c) + _0x25e26e(_0x38bdbe._0x379388) + _0x25e26e(_0x38bdbe._0x2df830));
|
|
225
|
-
let _0x51f029 = [];
|
|
226
|
-
if (fs[_0x25e26e(_0x38bdbe._0xd7b942) + _0x25e26e(_0x38bdbe._0x5d23f2)](_0x324261))
|
|
227
|
-
try {
|
|
228
|
-
const _0x100a91 = fs[_0x25e26e(_0x38bdbe._0xe38df0) + _0x25e26e(_0x38bdbe._0x364a56) + 'c'](_0x324261);
|
|
229
|
-
for (const _0x58b359 of _0x100a91) {
|
|
230
|
-
if (_0x58b359[_0x25e26e(_0x38bdbe._0x4d11b6) + _0x25e26e(_0x38bdbe._0x4ddf2f)](_0x25e26e(_0x38bdbe._0x276bbb))) {
|
|
231
|
-
const _0xcae323 = path[_0x25e26e(_0x38bdbe._0x184865)](_0x324261, _0x58b359);
|
|
232
|
-
try {
|
|
233
|
-
fs[_0x25e26e(_0x38bdbe._0x49fe6e) + _0x25e26e(_0x38bdbe._0x2cbe04)](_0xcae323), _0x51f029[_0x25e26e(_0x38bdbe._0x2840bd)](_0xcae323);
|
|
234
|
-
} catch (_0x2441d5) {
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
} catch (_0x3874f7) {
|
|
120
|
+
const claudeDir = path.join(os.homedir(), '.claude');
|
|
121
|
+
const hooksDir = path.join(claudeDir, 'hooks');
|
|
122
|
+
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
123
|
+
|
|
124
|
+
let removed = [];
|
|
125
|
+
|
|
126
|
+
// Remove GAL hook files
|
|
127
|
+
if (fs.existsSync(hooksDir)) {
|
|
128
|
+
try {
|
|
129
|
+
const files = fs.readdirSync(hooksDir);
|
|
130
|
+
for (const file of files) {
|
|
131
|
+
if (file.startsWith('gal-')) {
|
|
132
|
+
const hookPath = path.join(hooksDir, file);
|
|
133
|
+
try {
|
|
134
|
+
fs.unlinkSync(hookPath);
|
|
135
|
+
removed.push(hookPath);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
// Silent fail
|
|
138
|
+
}
|
|
239
139
|
}
|
|
240
|
-
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
// Silent fail
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Remove GAL hook entries from settings.json
|
|
147
|
+
if (removeGalHookEntries(settingsPath)) {
|
|
148
|
+
removed.push(`${settingsPath} (GAL hooks removed)`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return removed;
|
|
241
152
|
}
|
|
153
|
+
|
|
154
|
+
// =============================================================================
|
|
155
|
+
// Cleanup Functions - GAL Config Directory
|
|
156
|
+
// =============================================================================
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Clean up GAL config directory from user's home directory.
|
|
160
|
+
*
|
|
161
|
+
* Removes entire ~/.gal directory, including:
|
|
162
|
+
* - config.json (auth token, default org)
|
|
163
|
+
* - telemetry-pending-events.json (queued telemetry events)
|
|
164
|
+
* - Any other GAL-specific cache or state files
|
|
165
|
+
*
|
|
166
|
+
* Note: Does NOT remove project-level .gal directories (those belong to repos)
|
|
167
|
+
*
|
|
168
|
+
* Uses silent fail strategy to ensure uninstall proceeds even if directory
|
|
169
|
+
* is missing or has permission issues.
|
|
170
|
+
*
|
|
171
|
+
* @returns {string[]} Array containing the removed directory path, or empty array
|
|
172
|
+
*/
|
|
242
173
|
function cleanupGalConfig() {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
try {
|
|
253
|
-
return fs[_0x47ab13(_0x1c8e6e._0x596e92) + 'c'](_0x408434, {
|
|
254
|
-
'recursive': !![],
|
|
255
|
-
'force': !![]
|
|
256
|
-
}), [_0x408434];
|
|
257
|
-
} catch (_0x44b7c0) {
|
|
258
|
-
return [];
|
|
259
|
-
}
|
|
260
|
-
return [];
|
|
261
|
-
}
|
|
262
|
-
function _0x3af2(_0xb029eb, _0x4e9d1f) {
|
|
263
|
-
_0xb029eb = _0xb029eb - 0x1dc;
|
|
264
|
-
const _0x315215 = _0x3152();
|
|
265
|
-
let _0x3af285 = _0x315215[_0xb029eb];
|
|
266
|
-
if (_0x3af2['cxjLiQ'] === undefined) {
|
|
267
|
-
var _0x10353c = function (_0x44a12e) {
|
|
268
|
-
const _0x58e1ec = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';
|
|
269
|
-
let _0x9f2cad = '', _0x423946 = '';
|
|
270
|
-
for (let _0x2c0c5b = 0x0, _0xd4e35f, _0x3a9ecf, _0x1de8bc = 0x0; _0x3a9ecf = _0x44a12e['charAt'](_0x1de8bc++); ~_0x3a9ecf && (_0xd4e35f = _0x2c0c5b % 0x4 ? _0xd4e35f * 0x40 + _0x3a9ecf : _0x3a9ecf, _0x2c0c5b++ % 0x4) ? _0x9f2cad += String['fromCharCode'](0xff & _0xd4e35f >> (-0x2 * _0x2c0c5b & 0x6)) : 0x0) {
|
|
271
|
-
_0x3a9ecf = _0x58e1ec['indexOf'](_0x3a9ecf);
|
|
272
|
-
}
|
|
273
|
-
for (let _0x324261 = 0x0, _0x36392a = _0x9f2cad['length']; _0x324261 < _0x36392a; _0x324261++) {
|
|
274
|
-
_0x423946 += '%' + ('00' + _0x9f2cad['charCodeAt'](_0x324261)['toString'](0x10))['slice'](-0x2);
|
|
275
|
-
}
|
|
276
|
-
return decodeURIComponent(_0x423946);
|
|
277
|
-
};
|
|
278
|
-
_0x3af2['CvBWhs'] = _0x10353c, _0x3af2['NFDeeu'] = {}, _0x3af2['cxjLiQ'] = !![];
|
|
174
|
+
const galConfigDir = path.join(os.homedir(), '.gal');
|
|
175
|
+
|
|
176
|
+
if (fs.existsSync(galConfigDir)) {
|
|
177
|
+
try {
|
|
178
|
+
fs.rmSync(galConfigDir, { recursive: true, force: true });
|
|
179
|
+
return [galConfigDir];
|
|
180
|
+
} catch (err) {
|
|
181
|
+
// Silent fail
|
|
182
|
+
return [];
|
|
279
183
|
}
|
|
280
|
-
|
|
281
|
-
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return [];
|
|
282
187
|
}
|
|
188
|
+
|
|
189
|
+
// =============================================================================
|
|
190
|
+
// Main Cleanup Orchestration
|
|
191
|
+
// =============================================================================
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Main cleanup orchestration function.
|
|
195
|
+
*
|
|
196
|
+
* Coordinates all cleanup operations and provides user feedback.
|
|
197
|
+
* Runs both user-level and config directory cleanups, then reports results.
|
|
198
|
+
*
|
|
199
|
+
* @returns {void}
|
|
200
|
+
*/
|
|
283
201
|
function cleanup() {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
_0xadeecc: 0x209,
|
|
306
|
-
_0x3dc264: 0x1ec,
|
|
307
|
-
_0x521309: 0x216,
|
|
308
|
-
_0xc53a69: 0x222,
|
|
309
|
-
_0x725a32: 0x225,
|
|
310
|
-
_0x301d6b: 0x21e,
|
|
311
|
-
_0x587024: 0x200,
|
|
312
|
-
_0xbcb290: 0x211,
|
|
313
|
-
_0x43753d: 0x233,
|
|
314
|
-
_0x5cbaf3: 0x201,
|
|
315
|
-
_0x403a19: 0x222,
|
|
316
|
-
_0x456ca7: 0x223,
|
|
317
|
-
_0x59a1ab: 0x226,
|
|
318
|
-
_0x4b8325: 0x226,
|
|
319
|
-
_0x4900bd: 0x226,
|
|
320
|
-
_0x27fd13: 0x1e7,
|
|
321
|
-
_0x4cc03a: 0x1fe,
|
|
322
|
-
_0x15d3e0: 0x1e8,
|
|
323
|
-
_0x5a672a: 0x1e1,
|
|
324
|
-
_0x4a33c4: 0x23c,
|
|
325
|
-
_0x308b19: 0x226,
|
|
326
|
-
_0x424d83: 0x226,
|
|
327
|
-
_0x3894eb: 0x222,
|
|
328
|
-
_0x5e5de9: 0x1e3,
|
|
329
|
-
_0x591aba: 0x23a,
|
|
330
|
-
_0x40b227: 0x210,
|
|
331
|
-
_0x4f2a14: 0x1ee,
|
|
332
|
-
_0x1bc057: 0x235,
|
|
333
|
-
_0x2a3b50: 0x1e0,
|
|
334
|
-
_0x5ed204: 0x20f,
|
|
335
|
-
_0x3616f5: 0x21a,
|
|
336
|
-
_0x624716: 0x217,
|
|
337
|
-
_0x3f3ab3: 0x203,
|
|
338
|
-
_0x3ad056: 0x23e
|
|
339
|
-
}, _0x1d330a = _0x3af2;
|
|
340
|
-
console[_0x1d330a(_0x2edebc._0x79ff16)](_0x1d330a(_0x2edebc._0x31f732) + _0x1d330a(_0x2edebc._0x8c7f41) + _0x1d330a(_0x2edebc._0x8c7f41) + _0x1d330a(_0x2edebc._0x8c7f41) + _0x1d330a(_0x2edebc._0x8c7f41) + _0x1d330a(_0x2edebc._0x3aa1e8) + _0x1d330a(_0x2edebc._0x1c1b95) + _0x1d330a(_0x2edebc._0x3aa1e8) + _0x1d330a(_0x2edebc._0x8c7f41) + _0x1d330a(_0x2edebc._0x3aa1e8) + '══'), console[_0x1d330a(_0x2edebc._0x79ff16)](_0x1d330a(_0x2edebc._0x1055a1) + _0x1d330a(_0x2edebc._0x3ded70) + _0x1d330a(_0x2edebc._0x1320c7) + _0x1d330a(_0x2edebc._0x3b81f6) + _0x1d330a(_0x2edebc._0x22dc71) + 'up'), console[_0x1d330a(_0x2edebc._0x363566)](_0x1d330a(_0x2edebc._0x549680) + _0x1d330a(_0x2edebc._0x8c7f41) + _0x1d330a(_0x2edebc._0x8c7f41) + _0x1d330a(_0x2edebc._0x549680) + _0x1d330a(_0x2edebc._0x29d86e) + _0x1d330a(_0x2edebc._0x3acc6a) + _0x1d330a(_0x2edebc._0x3acc6a) + _0x1d330a(_0x2edebc._0x4046d1) + _0x1d330a(_0x2edebc._0x4d2410) + _0x1d330a(_0x2edebc._0x2930f8) + '═\x0a');
|
|
341
|
-
const _0x5090c9 = cleanupUserLevel(), _0x3d1751 = cleanupGalConfig(), _0x22f1fe = [
|
|
342
|
-
..._0x5090c9,
|
|
343
|
-
..._0x3d1751
|
|
344
|
-
];
|
|
345
|
-
if (_0x22f1fe[_0x1d330a(_0x2edebc._0x32cd8b) + 'h'] > 0x0) {
|
|
346
|
-
console[_0x1d330a(_0x2edebc._0x79ff16)](_0x1d330a(_0x2edebc._0x16772c) + _0x1d330a(_0x2edebc._0x1ef46c) + _0x1d330a(_0x2edebc._0xadeecc) + _0x1d330a(_0x2edebc._0x3dc264) + _0x1d330a(_0x2edebc._0x521309));
|
|
347
|
-
for (const _0x1dfd6b of _0x22f1fe) {
|
|
348
|
-
console[_0x1d330a(_0x2edebc._0xc53a69)](_0x1d330a(_0x2edebc._0x725a32) + _0x1dfd6b);
|
|
349
|
-
}
|
|
350
|
-
} else
|
|
351
|
-
console[_0x1d330a(_0x2edebc._0x363566)](_0x1d330a(_0x2edebc._0x301d6b) + _0x1d330a(_0x2edebc._0x3dc264) + _0x1d330a(_0x2edebc._0x587024) + _0x1d330a(_0x2edebc._0xbcb290) + _0x1d330a(_0x2edebc._0x43753d) + _0x1d330a(_0x2edebc._0x5cbaf3) + '.');
|
|
352
|
-
console[_0x1d330a(_0x2edebc._0x403a19)](_0x1d330a(_0x2edebc._0x456ca7) + _0x1d330a(_0x2edebc._0x59a1ab) + _0x1d330a(_0x2edebc._0x549680) + _0x1d330a(_0x2edebc._0x1c1b95) + _0x1d330a(_0x2edebc._0x3aa1e8) + _0x1d330a(_0x2edebc._0x4046d1) + _0x1d330a(_0x2edebc._0x4b8325) + _0x1d330a(_0x2edebc._0x3acc6a) + _0x1d330a(_0x2edebc._0x4900bd) + _0x1d330a(_0x2edebc._0x4d2410) + '══'), console[_0x1d330a(_0x2edebc._0xc53a69)](_0x1d330a(_0x2edebc._0x27fd13) + _0x1d330a(_0x2edebc._0x3ded70) + _0x1d330a(_0x2edebc._0x4cc03a) + _0x1d330a(_0x2edebc._0x15d3e0) + _0x1d330a(_0x2edebc._0x5a672a) + _0x1d330a(_0x2edebc._0x4a33c4)), console[_0x1d330a(_0x2edebc._0x403a19)](_0x1d330a(_0x2edebc._0x29d86e) + _0x1d330a(_0x2edebc._0x2930f8) + _0x1d330a(_0x2edebc._0x3acc6a) + _0x1d330a(_0x2edebc._0x1c1b95) + _0x1d330a(_0x2edebc._0x4900bd) + _0x1d330a(_0x2edebc._0x308b19) + _0x1d330a(_0x2edebc._0x424d83) + _0x1d330a(_0x2edebc._0x59a1ab) + _0x1d330a(_0x2edebc._0x4900bd) + _0x1d330a(_0x2edebc._0x308b19) + '═\x0a'), console[_0x1d330a(_0x2edebc._0x3894eb)](_0x1d330a(_0x2edebc._0x5e5de9) + _0x1d330a(_0x2edebc._0x591aba) + _0x1d330a(_0x2edebc._0x40b227) + _0x1d330a(_0x2edebc._0x4f2a14) + _0x1d330a(_0x2edebc._0x1bc057) + _0x1d330a(_0x2edebc._0x2a3b50) + _0x1d330a(_0x2edebc._0x5ed204) + _0x1d330a(_0x2edebc._0x3616f5) + _0x1d330a(_0x2edebc._0x624716) + _0x1d330a(_0x2edebc._0x3f3ab3) + _0x1d330a(_0x2edebc._0x3ad056));
|
|
202
|
+
console.log('\n═══════════════════════════════════════════════════');
|
|
203
|
+
console.log(' GAL CLI Uninstall Cleanup');
|
|
204
|
+
console.log('═══════════════════════════════════════════════════\n');
|
|
205
|
+
|
|
206
|
+
const userLevelFiles = cleanupUserLevel();
|
|
207
|
+
const galConfigFiles = cleanupGalConfig();
|
|
208
|
+
const allRemoved = [...userLevelFiles, ...galConfigFiles];
|
|
209
|
+
|
|
210
|
+
if (allRemoved.length > 0) {
|
|
211
|
+
console.log('✓ Cleaned up GAL files:');
|
|
212
|
+
for (const file of allRemoved) {
|
|
213
|
+
console.log(` - ${file}`);
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
console.log('No GAL files found to clean up.');
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
console.log('\n═══════════════════════════════════════════════════');
|
|
220
|
+
console.log(' GAL CLI has been uninstalled');
|
|
221
|
+
console.log('═══════════════════════════════════════════════════\n');
|
|
222
|
+
console.log('To reinstall: pnpm add -g @scheduler-systems/gal-run\n');
|
|
353
223
|
}
|
|
224
|
+
|
|
225
|
+
// =============================================================================
|
|
226
|
+
// Entry Point
|
|
227
|
+
// =============================================================================
|
|
228
|
+
|
|
229
|
+
// Run cleanup with silent fail strategy
|
|
230
|
+
// Even if cleanup fails, we don't prevent npm uninstall from proceeding
|
|
354
231
|
try {
|
|
355
|
-
|
|
356
|
-
} catch (
|
|
357
|
-
|
|
358
|
-
|
|
232
|
+
cleanup();
|
|
233
|
+
} catch (error) {
|
|
234
|
+
// Log error but allow uninstall to continue
|
|
235
|
+
console.error('GAL cleanup encountered an error, but uninstall will proceed.');
|
|
236
|
+
// Note: We don't process.exit(1) here - uninstall should always succeed
|
|
237
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scheduler-systems/gal-run",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.253",
|
|
4
4
|
"description": "GAL CLI - Command-line tool for managing AI agent configurations across your organization",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "Elastic-2.0",
|
|
6
6
|
"private": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/index.cjs",
|