@grepr/cli 1.1.0
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 +21 -0
- package/README.md +71 -0
- package/build/dist/commands/base-command.d.ts +13 -0
- package/build/dist/commands/base-command.d.ts.map +1 -0
- package/build/dist/commands/base-command.js +28 -0
- package/build/dist/commands/base-command.js.map +1 -0
- package/build/dist/commands/config-command.d.ts +19 -0
- package/build/dist/commands/config-command.d.ts.map +1 -0
- package/build/dist/commands/config-command.js +108 -0
- package/build/dist/commands/config-command.js.map +1 -0
- package/build/dist/commands/crud-command.d.ts +117 -0
- package/build/dist/commands/crud-command.d.ts.map +1 -0
- package/build/dist/commands/crud-command.js +264 -0
- package/build/dist/commands/crud-command.js.map +1 -0
- package/build/dist/commands/dataset-command.d.ts +45 -0
- package/build/dist/commands/dataset-command.d.ts.map +1 -0
- package/build/dist/commands/dataset-command.js +139 -0
- package/build/dist/commands/dataset-command.js.map +1 -0
- package/build/dist/commands/integration-command.d.ts +30 -0
- package/build/dist/commands/integration-command.d.ts.map +1 -0
- package/build/dist/commands/integration-command.js +80 -0
- package/build/dist/commands/integration-command.js.map +1 -0
- package/build/dist/commands/job-command.d.ts +92 -0
- package/build/dist/commands/job-command.d.ts.map +1 -0
- package/build/dist/commands/job-command.js +294 -0
- package/build/dist/commands/job-command.js.map +1 -0
- package/build/dist/commands/list-command.d.ts +69 -0
- package/build/dist/commands/list-command.d.ts.map +1 -0
- package/build/dist/commands/list-command.js +130 -0
- package/build/dist/commands/list-command.js.map +1 -0
- package/build/dist/commands/query-command.d.ts +20 -0
- package/build/dist/commands/query-command.d.ts.map +1 -0
- package/build/dist/commands/query-command.js +167 -0
- package/build/dist/commands/query-command.js.map +1 -0
- package/build/dist/grepr.d.ts +3 -0
- package/build/dist/grepr.d.ts.map +1 -0
- package/build/dist/grepr.js +155 -0
- package/build/dist/grepr.js.map +1 -0
- package/build/dist/lib/api-client-factory.d.ts +21 -0
- package/build/dist/lib/api-client-factory.d.ts.map +1 -0
- package/build/dist/lib/api-client-factory.js +23 -0
- package/build/dist/lib/api-client-factory.js.map +1 -0
- package/build/dist/lib/api-client.d.ts +2 -0
- package/build/dist/lib/api-client.d.ts.map +1 -0
- package/build/dist/lib/api-client.js +3 -0
- package/build/dist/lib/api-client.js.map +1 -0
- package/build/dist/lib/auth.d.ts +104 -0
- package/build/dist/lib/auth.d.ts.map +1 -0
- package/build/dist/lib/auth.js +312 -0
- package/build/dist/lib/auth.js.map +1 -0
- package/build/dist/lib/command-registry.d.ts +35 -0
- package/build/dist/lib/command-registry.d.ts.map +1 -0
- package/build/dist/lib/command-registry.js +33 -0
- package/build/dist/lib/command-registry.js.map +1 -0
- package/build/dist/lib/config.d.ts +40 -0
- package/build/dist/lib/config.d.ts.map +1 -0
- package/build/dist/lib/config.js +114 -0
- package/build/dist/lib/config.js.map +1 -0
- package/build/dist/lib/grepr-api-client.d.ts +216 -0
- package/build/dist/lib/grepr-api-client.d.ts.map +1 -0
- package/build/dist/lib/grepr-api-client.js +424 -0
- package/build/dist/lib/grepr-api-client.js.map +1 -0
- package/build/dist/lib/heartbeat.d.ts +17 -0
- package/build/dist/lib/heartbeat.d.ts.map +1 -0
- package/build/dist/lib/heartbeat.js +56 -0
- package/build/dist/lib/heartbeat.js.map +1 -0
- package/build/dist/lib/json-formatter.d.ts +135 -0
- package/build/dist/lib/json-formatter.d.ts.map +1 -0
- package/build/dist/lib/json-formatter.js +658 -0
- package/build/dist/lib/json-formatter.js.map +1 -0
- package/build/dist/lib/parser.d.ts +26 -0
- package/build/dist/lib/parser.d.ts.map +1 -0
- package/build/dist/lib/parser.js +95 -0
- package/build/dist/lib/parser.js.map +1 -0
- package/build/dist/lib/streaming-job-executor.d.ts +31 -0
- package/build/dist/lib/streaming-job-executor.d.ts.map +1 -0
- package/build/dist/lib/streaming-job-executor.js +281 -0
- package/build/dist/lib/streaming-job-executor.js.map +1 -0
- package/build/dist/lib/time-utils.d.ts +28 -0
- package/build/dist/lib/time-utils.d.ts.map +1 -0
- package/build/dist/lib/time-utils.js +87 -0
- package/build/dist/lib/time-utils.js.map +1 -0
- package/build/dist/openapi/openApiTypes.d.ts +10430 -0
- package/build/dist/openapi/openApiTypes.d.ts.map +1 -0
- package/build/dist/openapi/openApiTypes.js +571 -0
- package/build/dist/openapi/openApiTypes.js.map +1 -0
- package/build/dist/types.d.ts +168 -0
- package/build/dist/types.d.ts.map +1 -0
- package/build/dist/types.js +20 -0
- package/build/dist/types.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import { randomBytes, createHash } from 'crypto';
|
|
5
|
+
import { createServer } from 'http';
|
|
6
|
+
import { URL } from 'url';
|
|
7
|
+
import open from 'open';
|
|
8
|
+
import axios from 'axios';
|
|
9
|
+
const AUTH_CACHE_DIR = path.join(os.homedir(), '.grepr', 'auth');
|
|
10
|
+
/**
|
|
11
|
+
* Header-based authentication for testing (no OAuth required)
|
|
12
|
+
*/
|
|
13
|
+
export class HeaderAuth {
|
|
14
|
+
config;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.config = this.buildConfig(options);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build configuration from command-line options
|
|
20
|
+
*/
|
|
21
|
+
buildConfig(options) {
|
|
22
|
+
const { orgName, userId } = options;
|
|
23
|
+
if (!orgName) {
|
|
24
|
+
throw new Error('Organization name is required. Use --org-name option.');
|
|
25
|
+
}
|
|
26
|
+
if (!userId) {
|
|
27
|
+
throw new Error('User ID is required for header authentication. Use --user-id option.');
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
...options,
|
|
31
|
+
userId,
|
|
32
|
+
authMethod: 'header',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get authentication headers for API requests
|
|
37
|
+
*/
|
|
38
|
+
async getAuthHeaders() {
|
|
39
|
+
return {
|
|
40
|
+
'X-Grepr-Auth-Enable': 'true',
|
|
41
|
+
'X-Grepr-Auth-User': this.config.userId,
|
|
42
|
+
'X-Grepr-Auth-Org-Name': this.config.orgName
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* OAuth-based authentication (simplified version for now)
|
|
48
|
+
*/
|
|
49
|
+
export class GreprAuth {
|
|
50
|
+
config;
|
|
51
|
+
constructor(options) {
|
|
52
|
+
this.config = this.buildConfig(options);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the path to the token cache file
|
|
56
|
+
*/
|
|
57
|
+
get tokenCachePath() {
|
|
58
|
+
return path.join(AUTH_CACHE_DIR, `${this.config.orgId}.json`);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Build configuration from command-line options
|
|
62
|
+
*/
|
|
63
|
+
buildConfig(options) {
|
|
64
|
+
const { orgName, authBaseUrl, } = options;
|
|
65
|
+
if (!orgName) {
|
|
66
|
+
throw new Error('Organization name is required. Use --org-name option.');
|
|
67
|
+
}
|
|
68
|
+
const orgId = orgName.toLowerCase().replace(/[^a-z0-9]/g, '-');
|
|
69
|
+
const oauthConf = {
|
|
70
|
+
...options,
|
|
71
|
+
authMethod: 'oauth',
|
|
72
|
+
authUrl: `${authBaseUrl}/authorize`,
|
|
73
|
+
tokenUrl: `${authBaseUrl}/oauth/token`,
|
|
74
|
+
redirectUrl: `http://${orgId}.app.localhost:3000`,
|
|
75
|
+
audience: 'service',
|
|
76
|
+
orgId
|
|
77
|
+
};
|
|
78
|
+
if (options.debug) {
|
|
79
|
+
console.log('OAuth configuration:', oauthConf);
|
|
80
|
+
}
|
|
81
|
+
return oauthConf;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get authentication headers for API requests (OAuth uses Bearer token)
|
|
85
|
+
*/
|
|
86
|
+
async getAuthHeaders() {
|
|
87
|
+
const token = await this.getAccessToken();
|
|
88
|
+
return {
|
|
89
|
+
'Authorization': `Bearer ${token}`
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get a valid access token, refreshing if necessary
|
|
94
|
+
*/
|
|
95
|
+
async getAccessToken() {
|
|
96
|
+
// Skip cache if --no-auth-cache option is set
|
|
97
|
+
if (!this.config.authCache) {
|
|
98
|
+
console.log('Forcing fresh authentication (--no-auth-cache option enabled)');
|
|
99
|
+
return await this.performFreshAuthentication();
|
|
100
|
+
}
|
|
101
|
+
const cachedToken = await this.loadCachedToken();
|
|
102
|
+
if (cachedToken && !this.isTokenExpired(cachedToken)) {
|
|
103
|
+
return cachedToken.access_token;
|
|
104
|
+
}
|
|
105
|
+
if (cachedToken?.refresh_token && this.isTokenExpired(cachedToken)) {
|
|
106
|
+
try {
|
|
107
|
+
const refreshedToken = await this.refreshToken(cachedToken.refresh_token);
|
|
108
|
+
await this.saveCachedToken(refreshedToken);
|
|
109
|
+
return refreshedToken.access_token;
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
console.warn('Token refresh failed, starting new authentication flow');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Start new OAuth flow and cache the result
|
|
116
|
+
return await this.performFreshAuthentication();
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Perform fresh OAuth authentication and optionally cache the result
|
|
120
|
+
*/
|
|
121
|
+
async performFreshAuthentication() {
|
|
122
|
+
const newToken = await this.authenticateWithPKCE();
|
|
123
|
+
// Only save to cache if caching is enabled
|
|
124
|
+
if (this.config.authCache) {
|
|
125
|
+
await this.saveCachedToken(newToken);
|
|
126
|
+
}
|
|
127
|
+
return newToken.access_token;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* OAuth 2.0 PKCE flow with local callback server
|
|
131
|
+
*/
|
|
132
|
+
async authenticateWithPKCE() {
|
|
133
|
+
const { codeVerifier, codeChallenge } = this.generatePKCEPair();
|
|
134
|
+
const state = randomBytes(16).toString('hex');
|
|
135
|
+
// Build authorization URL with custom parameters
|
|
136
|
+
const authParams = {
|
|
137
|
+
client_id: this.config.clientId,
|
|
138
|
+
response_type: 'code',
|
|
139
|
+
redirect_uri: this.config.redirectUrl,
|
|
140
|
+
scope: 'profile email offline_access',
|
|
141
|
+
code_challenge: codeChallenge,
|
|
142
|
+
code_challenge_method: 'S256',
|
|
143
|
+
state: state,
|
|
144
|
+
// Auth0 custom parameters
|
|
145
|
+
audience: this.config.audience,
|
|
146
|
+
organization: this.config.orgName,
|
|
147
|
+
};
|
|
148
|
+
const authUrl = `${this.config.authUrl}?${new URLSearchParams(authParams).toString()}`;
|
|
149
|
+
console.log('Opening browser for authentication...');
|
|
150
|
+
console.log(`If the browser doesn't open automatically, visit: ${authUrl}`);
|
|
151
|
+
// Start local callback server
|
|
152
|
+
const authCode = await this.startCallbackServer(state, authUrl);
|
|
153
|
+
console.log('Authorization code received, exchanging for access token...');
|
|
154
|
+
// Exchange authorization code for access token
|
|
155
|
+
const tokenResponse = await this.exchangeCodeForToken(authCode, codeVerifier);
|
|
156
|
+
console.log('Authentication successful!');
|
|
157
|
+
return tokenResponse;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Generate PKCE code verifier and challenge
|
|
161
|
+
*/
|
|
162
|
+
generatePKCEPair() {
|
|
163
|
+
const codeVerifier = randomBytes(32).toString('base64url');
|
|
164
|
+
const codeChallenge = createHash('sha256')
|
|
165
|
+
.update(codeVerifier)
|
|
166
|
+
.digest('base64url');
|
|
167
|
+
return { codeVerifier, codeChallenge };
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Start local HTTP server to receive OAuth callback
|
|
171
|
+
*/
|
|
172
|
+
async startCallbackServer(expectedState, authUrl) {
|
|
173
|
+
return new Promise((resolve, reject) => {
|
|
174
|
+
const server = createServer((req, res) => {
|
|
175
|
+
const url = new URL(req.url || '', `http://${this.config.orgId}.app.localhost:3000`);
|
|
176
|
+
const code = url.searchParams.get('code');
|
|
177
|
+
const state = url.searchParams.get('state');
|
|
178
|
+
const error = url.searchParams.get('error');
|
|
179
|
+
if (error) {
|
|
180
|
+
res.writeHead(400, { 'Content-Type': 'text/html' });
|
|
181
|
+
res.end(`<h1>Authentication Error</h1><p>${error}</p>`);
|
|
182
|
+
server.close();
|
|
183
|
+
reject(new Error(`OAuth error: ${error}`));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (state !== expectedState) {
|
|
187
|
+
res.writeHead(400, { 'Content-Type': 'text/html' });
|
|
188
|
+
res.end('<h1>Authentication Error</h1><p>Invalid state parameter</p>');
|
|
189
|
+
server.close();
|
|
190
|
+
reject(new Error('Invalid state parameter'));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (!code) {
|
|
194
|
+
res.writeHead(400, { 'Content-Type': 'text/html' });
|
|
195
|
+
res.end('<h1>Authentication Error</h1><p>No authorization code received</p>');
|
|
196
|
+
server.close();
|
|
197
|
+
reject(new Error('No authorization code received'));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
201
|
+
res.end('<h1>Authentication Successful</h1><p>You can close this window.</p>');
|
|
202
|
+
server.close();
|
|
203
|
+
resolve(code);
|
|
204
|
+
});
|
|
205
|
+
server.listen(3000, () => {
|
|
206
|
+
console.log(`Callback server started on http://${this.config.orgId}.app.localhost:3000`);
|
|
207
|
+
if (!this.config.browser) {
|
|
208
|
+
console.log('Browser auto-launch disabled (--no-browser option enabled)');
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
open(authUrl).catch(err => {
|
|
212
|
+
console.warn('Failed to open browser automatically:', err.message);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
server.on('error', (err) => {
|
|
217
|
+
reject(new Error(`Callback server error: ${err.message}`));
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Exchange authorization code for access token
|
|
223
|
+
*/
|
|
224
|
+
async exchangeCodeForToken(authCode, codeVerifier) {
|
|
225
|
+
const tokenParams = {
|
|
226
|
+
grant_type: 'authorization_code',
|
|
227
|
+
client_id: this.config.clientId,
|
|
228
|
+
code: authCode,
|
|
229
|
+
redirect_uri: `http://${this.config.orgId}.app.localhost:3000`,
|
|
230
|
+
code_verifier: codeVerifier
|
|
231
|
+
};
|
|
232
|
+
try {
|
|
233
|
+
const response = await axios.post(this.config.tokenUrl, tokenParams, {
|
|
234
|
+
headers: {
|
|
235
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
const tokenData = response.data;
|
|
239
|
+
tokenData.expires_at = Date.now() + (tokenData['expires_in'] * 1000);
|
|
240
|
+
return tokenData;
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
244
|
+
const errorData = error?.response?.data;
|
|
245
|
+
throw new Error(`Token exchange failed: ${errorData?.error_description || errorMessage}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Refresh access token using refresh token
|
|
250
|
+
*/
|
|
251
|
+
async refreshToken(refreshToken) {
|
|
252
|
+
const refreshParams = {
|
|
253
|
+
grant_type: 'refresh_token',
|
|
254
|
+
client_id: this.config.clientId,
|
|
255
|
+
refresh_token: refreshToken
|
|
256
|
+
};
|
|
257
|
+
try {
|
|
258
|
+
const response = await axios.post(this.config.tokenUrl, refreshParams, {
|
|
259
|
+
headers: {
|
|
260
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
const tokenData = response.data;
|
|
264
|
+
tokenData.expires_at = Date.now() + (tokenData['expires_in'] * 1000);
|
|
265
|
+
return tokenData;
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
269
|
+
const errorData = error?.response?.data;
|
|
270
|
+
throw new Error(`Token refresh failed: ${errorData?.error_description || errorMessage}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Load cached token from file system
|
|
275
|
+
*/
|
|
276
|
+
async loadCachedToken() {
|
|
277
|
+
try {
|
|
278
|
+
if (await fs.pathExists(this.tokenCachePath)) {
|
|
279
|
+
return await fs.readJson(this.tokenCachePath);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
284
|
+
console.warn('Failed to load cached token:', errorMessage);
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Save token to cache
|
|
290
|
+
*/
|
|
291
|
+
async saveCachedToken(tokenData) {
|
|
292
|
+
try {
|
|
293
|
+
await fs.ensureDir(AUTH_CACHE_DIR, { mode: 0o700 });
|
|
294
|
+
await fs.writeJson(this.tokenCachePath, tokenData, { spaces: 2, mode: 0o600 });
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
298
|
+
console.warn('Failed to save token to cache:', errorMessage);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Check if token is expired (with 5 minute buffer)
|
|
303
|
+
*/
|
|
304
|
+
isTokenExpired(tokenData) {
|
|
305
|
+
if (!tokenData.expires_at) {
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
const buffer = 5 * 60 * 1000; // 5 minutes
|
|
309
|
+
return Date.now() >= (tokenData.expires_at - buffer);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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ACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe,CAAC,SAAoB;QACxC,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YACpD,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACjF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC9E,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,YAAY,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,SAAoB;QACjC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;QAC1C,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for self-registering CLI commands
|
|
4
|
+
*/
|
|
5
|
+
export interface ICommand {
|
|
6
|
+
/**
|
|
7
|
+
* Add this command and its subcommands to the program
|
|
8
|
+
* @param program - The main commander program
|
|
9
|
+
* @param mergeConfiguration - Function to merge CLI options with configuration
|
|
10
|
+
*/
|
|
11
|
+
addToProgram(program: Command, mergeConfiguration: (options: any) => Promise<any>): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Registry for managing CLI commands
|
|
15
|
+
*/
|
|
16
|
+
export declare class CommandRegistry {
|
|
17
|
+
private commands;
|
|
18
|
+
/**
|
|
19
|
+
* Register a command with the registry
|
|
20
|
+
*/
|
|
21
|
+
register(command: ICommand): void;
|
|
22
|
+
/**
|
|
23
|
+
* Register all commands with the program
|
|
24
|
+
*/
|
|
25
|
+
registerAll(program: Command, mergeConfiguration: (options: any) => Promise<any>): void;
|
|
26
|
+
/**
|
|
27
|
+
* Get all registered commands
|
|
28
|
+
*/
|
|
29
|
+
getCommands(): ICommand[];
|
|
30
|
+
/**
|
|
31
|
+
* Clear all registered commands (useful for testing)
|
|
32
|
+
*/
|
|
33
|
+
clear(): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=command-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-registry.d.ts","sourceRoot":"","sources":["../../../src/main/typescript/lib/command-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;OAIG;IACH,YAAY,CACV,OAAO,EAAE,OAAO,EAChB,kBAAkB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GACjD,IAAI,CAAC;CACT;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAkB;IAElC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAIjC;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI;IAMvF;;OAEG;IACH,WAAW,IAAI,QAAQ,EAAE;IAIzB;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry for managing CLI commands
|
|
3
|
+
*/
|
|
4
|
+
export class CommandRegistry {
|
|
5
|
+
commands = [];
|
|
6
|
+
/**
|
|
7
|
+
* Register a command with the registry
|
|
8
|
+
*/
|
|
9
|
+
register(command) {
|
|
10
|
+
this.commands.push(command);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Register all commands with the program
|
|
14
|
+
*/
|
|
15
|
+
registerAll(program, mergeConfiguration) {
|
|
16
|
+
this.commands.forEach(command => {
|
|
17
|
+
command.addToProgram(program, mergeConfiguration);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get all registered commands
|
|
22
|
+
*/
|
|
23
|
+
getCommands() {
|
|
24
|
+
return [...this.commands];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Clear all registered commands (useful for testing)
|
|
28
|
+
*/
|
|
29
|
+
clear() {
|
|
30
|
+
this.commands = [];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=command-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-registry.js","sourceRoot":"","sources":["../../../src/main/typescript/lib/command-registry.ts"],"names":[],"mappings":"AAiBA;;GAEG;AACH,MAAM,OAAO,eAAe;IAClB,QAAQ,GAAe,EAAE,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,OAAiB;QACxB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAAgB,EAAE,kBAAkD;QAC9E,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC9B,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CliOptions, SavedCliConfig, CliConfigFile } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration manager for CLI settings
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConfigManager {
|
|
6
|
+
/**
|
|
7
|
+
* Load configuration from file
|
|
8
|
+
*/
|
|
9
|
+
loadConfigFile(): Promise<CliConfigFile | null>;
|
|
10
|
+
/**
|
|
11
|
+
* Save configuration to file
|
|
12
|
+
*/
|
|
13
|
+
saveConfigFile(config: CliConfigFile): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Get a specific configuration by name
|
|
16
|
+
*/
|
|
17
|
+
getConfig(configName: string): Promise<SavedCliConfig | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Set a configuration by name
|
|
20
|
+
*/
|
|
21
|
+
setConfig(configName: string, config: SavedCliConfig): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* List all available configurations
|
|
24
|
+
*/
|
|
25
|
+
listConfigs(): Promise<string[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete a configuration by name
|
|
28
|
+
*/
|
|
29
|
+
deleteConfig(configName: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Merge saved configuration with CLI options
|
|
32
|
+
* CLI options take precedence over saved config
|
|
33
|
+
*/
|
|
34
|
+
static mergeConfigWithOptions(savedConfig: SavedCliConfig, cliOptions: Partial<CliOptions>): Partial<CliOptions>;
|
|
35
|
+
/**
|
|
36
|
+
* Extract saveable configuration from CLI options
|
|
37
|
+
*/
|
|
38
|
+
static extractSaveableConfig(cliOptions: CliOptions): SavedCliConfig;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/main/typescript/lib/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKxE;;GAEG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAYrD;;OAEG;IACG,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1D;;OAEG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAcnE;;OAEG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1E;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKtC;;OAEG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUrD;;;OAGG;IACH,MAAM,CAAC,sBAAsB,CAAC,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAWhH;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc;CAuBrE"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
const CONFIG_DIR = path.join(os.homedir(), '.grepr');
|
|
5
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'cli-config.json');
|
|
6
|
+
/**
|
|
7
|
+
* Configuration manager for CLI settings
|
|
8
|
+
*/
|
|
9
|
+
export class ConfigManager {
|
|
10
|
+
/**
|
|
11
|
+
* Load configuration from file
|
|
12
|
+
*/
|
|
13
|
+
async loadConfigFile() {
|
|
14
|
+
try {
|
|
15
|
+
if (await fs.pathExists(CONFIG_FILE)) {
|
|
16
|
+
return await fs.readJson(CONFIG_FILE);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
21
|
+
console.warn(`Warning: Failed to load CLI config file: ${errorMessage}`);
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Save configuration to file
|
|
27
|
+
*/
|
|
28
|
+
async saveConfigFile(config) {
|
|
29
|
+
try {
|
|
30
|
+
await fs.ensureDir(CONFIG_DIR, { mode: 0o700 });
|
|
31
|
+
await fs.writeJson(CONFIG_FILE, config, { spaces: 2, mode: 0o600 });
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
35
|
+
throw new Error(`Failed to save CLI config file: ${errorMessage}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get a specific configuration by name
|
|
40
|
+
*/
|
|
41
|
+
async getConfig(configName) {
|
|
42
|
+
const configFile = await this.loadConfigFile();
|
|
43
|
+
if (!configFile) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const config = configFile[configName];
|
|
47
|
+
if (!config) {
|
|
48
|
+
throw new Error(`Configuration '${configName}' not found. Available configurations: ${Object.keys(configFile).join(', ')}`);
|
|
49
|
+
}
|
|
50
|
+
return config;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Set a configuration by name
|
|
54
|
+
*/
|
|
55
|
+
async setConfig(configName, config) {
|
|
56
|
+
const configFile = await this.loadConfigFile() || {};
|
|
57
|
+
configFile[configName] = config;
|
|
58
|
+
await this.saveConfigFile(configFile);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* List all available configurations
|
|
62
|
+
*/
|
|
63
|
+
async listConfigs() {
|
|
64
|
+
const configFile = await this.loadConfigFile();
|
|
65
|
+
return configFile ? Object.keys(configFile) : [];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Delete a configuration by name
|
|
69
|
+
*/
|
|
70
|
+
async deleteConfig(configName) {
|
|
71
|
+
const configFile = await this.loadConfigFile();
|
|
72
|
+
if (!configFile || !configFile[configName]) {
|
|
73
|
+
throw new Error(`Configuration '${configName}' not found`);
|
|
74
|
+
}
|
|
75
|
+
delete configFile[configName];
|
|
76
|
+
await this.saveConfigFile(configFile);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Merge saved configuration with CLI options
|
|
80
|
+
* CLI options take precedence over saved config
|
|
81
|
+
*/
|
|
82
|
+
static mergeConfigWithOptions(savedConfig, cliOptions) {
|
|
83
|
+
return {
|
|
84
|
+
// Saved config provides defaults
|
|
85
|
+
...savedConfig,
|
|
86
|
+
// CLI options override saved config
|
|
87
|
+
...Object.fromEntries(Object.entries(cliOptions).filter(([, value]) => value !== undefined))
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Extract saveable configuration from CLI options
|
|
92
|
+
*/
|
|
93
|
+
static extractSaveableConfig(cliOptions) {
|
|
94
|
+
const config = {
|
|
95
|
+
orgName: cliOptions.orgName,
|
|
96
|
+
authBaseUrl: cliOptions.authBaseUrl,
|
|
97
|
+
authMethod: cliOptions.authMethod,
|
|
98
|
+
userId: cliOptions.userId,
|
|
99
|
+
clientId: cliOptions.clientId,
|
|
100
|
+
authCache: cliOptions.authCache !== false,
|
|
101
|
+
browser: cliOptions.browser !== false,
|
|
102
|
+
};
|
|
103
|
+
// Only include apiBaseUrl if it's defined
|
|
104
|
+
if (cliOptions.apiBaseUrl) {
|
|
105
|
+
config.apiBaseUrl = cliOptions.apiBaseUrl;
|
|
106
|
+
}
|
|
107
|
+
// Only include timezone if it's defined and not the default
|
|
108
|
+
if (cliOptions.timezone && cliOptions.timezone !== 'system') {
|
|
109
|
+
config.timezone = cliOptions.timezone;
|
|
110
|
+
}
|
|
111
|
+
return config;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/main/typescript/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;AACrD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,aAAa;IACxB;;OAEG;IACH,KAAK,CAAC,cAAc;QAClB,IAAI,CAAC;YACH,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;gBACrC,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC9E,OAAO,CAAC,IAAI,CAAC,4CAA4C,YAAY,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,MAAqB;QACxC,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YAChD,MAAM,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,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