decoupled-cli 2.0.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/README.md +416 -0
- package/bin/decoupled-cli +3 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +386 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +84 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/content.d.ts +3 -0
- package/dist/commands/content.d.ts.map +1 -0
- package/dist/commands/content.js +199 -0
- package/dist/commands/content.js.map +1 -0
- package/dist/commands/download.d.ts +4 -0
- package/dist/commands/download.d.ts.map +1 -0
- package/dist/commands/download.js +127 -0
- package/dist/commands/download.js.map +1 -0
- package/dist/commands/health.d.ts +3 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +28 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/org.d.ts +3 -0
- package/dist/commands/org.d.ts.map +1 -0
- package/dist/commands/org.js +73 -0
- package/dist/commands/org.js.map +1 -0
- package/dist/commands/spaces.d.ts +3 -0
- package/dist/commands/spaces.d.ts.map +1 -0
- package/dist/commands/spaces.js +613 -0
- package/dist/commands/spaces.js.map +1 -0
- package/dist/commands/tokens.d.ts +3 -0
- package/dist/commands/tokens.d.ts.map +1 -0
- package/dist/commands/tokens.js +90 -0
- package/dist/commands/tokens.js.map +1 -0
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +104 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +40 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +162 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/config.d.ts +63 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +317 -0
- package/dist/lib/config.js.map +1 -0
- package/examples/.cursorrules +189 -0
- package/examples/CLAUDE.md +1080 -0
- package/examples/GEMINI.md +1056 -0
- package/examples/content-import-sample.json +114 -0
- package/package.json +55 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.authCommand = void 0;
|
|
40
|
+
const commander_1 = require("commander");
|
|
41
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
42
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
43
|
+
const child_process_1 = require("child_process");
|
|
44
|
+
const config_1 = require("../lib/config");
|
|
45
|
+
const api_1 = require("../lib/api");
|
|
46
|
+
// Helper function to open browser
|
|
47
|
+
function openBrowser(url) {
|
|
48
|
+
const platform = process.platform;
|
|
49
|
+
let command;
|
|
50
|
+
switch (platform) {
|
|
51
|
+
case 'darwin': // macOS
|
|
52
|
+
command = 'open';
|
|
53
|
+
break;
|
|
54
|
+
case 'win32': // Windows
|
|
55
|
+
command = 'start';
|
|
56
|
+
break;
|
|
57
|
+
default: // Linux and others
|
|
58
|
+
command = 'xdg-open';
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
(0, child_process_1.spawn)(command, [url], { detached: true, stdio: 'ignore' });
|
|
62
|
+
}
|
|
63
|
+
// Helper function for manual token login
|
|
64
|
+
async function handleManualLogin(url, token, profile = 'default') {
|
|
65
|
+
if (!token) {
|
|
66
|
+
const answers = await inquirer_1.default.prompt([
|
|
67
|
+
{
|
|
68
|
+
type: 'password',
|
|
69
|
+
name: 'token',
|
|
70
|
+
message: 'Personal Access Token:',
|
|
71
|
+
validate: (input) => {
|
|
72
|
+
if (!input.startsWith('dc_tok_')) {
|
|
73
|
+
return 'Token should start with "dc_tok_"';
|
|
74
|
+
}
|
|
75
|
+
if (input.length < 20) {
|
|
76
|
+
return 'Token appears to be too short';
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]);
|
|
82
|
+
token = answers.token;
|
|
83
|
+
}
|
|
84
|
+
console.log(chalk_1.default.blue('🔍 Testing authentication...'));
|
|
85
|
+
try {
|
|
86
|
+
const { ApiClient } = await Promise.resolve().then(() => __importStar(require('../lib/api')));
|
|
87
|
+
const testClient = new ApiClient(url, token);
|
|
88
|
+
const result = await testClient.testAuth();
|
|
89
|
+
if (!result.success) {
|
|
90
|
+
throw new Error(result.error);
|
|
91
|
+
}
|
|
92
|
+
console.log(chalk_1.default.green('✅ Authentication successful!'));
|
|
93
|
+
config_1.configManager.setProfile(profile, { baseUrl: url, useOAuth: false });
|
|
94
|
+
config_1.configManager.setCurrentProfile(profile);
|
|
95
|
+
await config_1.configManager.storeToken(profile, token);
|
|
96
|
+
console.log(chalk_1.default.green(`✅ Profile '${profile}' configured successfully`));
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
throw new Error(`Authentication failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Helper function for browser-based login
|
|
103
|
+
async function handleBrowserLogin(url, profile = 'default') {
|
|
104
|
+
console.log(chalk_1.default.blue('🚀 Starting browser-based login...'));
|
|
105
|
+
try {
|
|
106
|
+
// Generate a unique session ID for this CLI login attempt
|
|
107
|
+
const sessionId = Math.random().toString(36).substring(2, 15);
|
|
108
|
+
const loginUrl = `${url}/cli-auth?session=${sessionId}`;
|
|
109
|
+
console.log(chalk_1.default.yellow('\nA browser window will open where you can log in and authorize this CLI.'));
|
|
110
|
+
console.log(chalk_1.default.gray(`If the browser doesn't open automatically, visit: ${loginUrl}`));
|
|
111
|
+
// Ask for confirmation before opening browser
|
|
112
|
+
const { openBrowser: shouldOpen } = await inquirer_1.default.prompt([
|
|
113
|
+
{
|
|
114
|
+
type: 'confirm',
|
|
115
|
+
name: 'openBrowser',
|
|
116
|
+
message: 'Continue login in the browser?',
|
|
117
|
+
default: true
|
|
118
|
+
}
|
|
119
|
+
]);
|
|
120
|
+
if (shouldOpen) {
|
|
121
|
+
console.log(chalk_1.default.blue('🌐 Opening browser...'));
|
|
122
|
+
openBrowser(loginUrl);
|
|
123
|
+
}
|
|
124
|
+
console.log(chalk_1.default.yellow('\nAfter authorizing in the browser:'));
|
|
125
|
+
console.log(chalk_1.default.gray('1. Copy the personal access token from the browser'));
|
|
126
|
+
console.log(chalk_1.default.gray('2. Paste it below when prompted'));
|
|
127
|
+
console.log(chalk_1.default.gray('3. Press Enter to complete authentication\n'));
|
|
128
|
+
// Prompt for the token that user will copy from browser
|
|
129
|
+
const answers = await inquirer_1.default.prompt([
|
|
130
|
+
{
|
|
131
|
+
type: 'password',
|
|
132
|
+
name: 'token',
|
|
133
|
+
message: 'Paste your Personal Access Token:',
|
|
134
|
+
validate: (input) => {
|
|
135
|
+
if (!input.startsWith('dc_tok_')) {
|
|
136
|
+
return 'Token should start with "dc_tok_"';
|
|
137
|
+
}
|
|
138
|
+
if (input.length < 20) {
|
|
139
|
+
return 'Token appears to be too short';
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
]);
|
|
145
|
+
console.log(chalk_1.default.blue('🔍 Testing authentication...'));
|
|
146
|
+
// Test the token
|
|
147
|
+
const { ApiClient } = await Promise.resolve().then(() => __importStar(require('../lib/api')));
|
|
148
|
+
const testClient = new ApiClient(url, answers.token);
|
|
149
|
+
const result = await testClient.testAuth();
|
|
150
|
+
if (!result.success) {
|
|
151
|
+
throw new Error(result.error);
|
|
152
|
+
}
|
|
153
|
+
// Store the token
|
|
154
|
+
config_1.configManager.setProfile(profile, { baseUrl: url, useOAuth: false });
|
|
155
|
+
config_1.configManager.setCurrentProfile(profile);
|
|
156
|
+
await config_1.configManager.storeToken(profile, answers.token);
|
|
157
|
+
// Display success message
|
|
158
|
+
console.log(chalk_1.default.green('\n✅ Authentication successful!'));
|
|
159
|
+
console.log('');
|
|
160
|
+
console.log(chalk_1.default.cyan('📋 Personal Access Token:'));
|
|
161
|
+
console.log(chalk_1.default.gray(` ${answers.token.substring(0, 20)}...`));
|
|
162
|
+
console.log('');
|
|
163
|
+
console.log(chalk_1.default.cyan('💾 Configuration saved to:'));
|
|
164
|
+
console.log(chalk_1.default.gray(` ${config_1.configManager.getConfigPath()}`));
|
|
165
|
+
console.log('');
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
throw new Error(`Browser login failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
exports.authCommand = new commander_1.Command('auth')
|
|
172
|
+
.description('Authentication management');
|
|
173
|
+
exports.authCommand
|
|
174
|
+
.command('login')
|
|
175
|
+
.description('Login with personal access token')
|
|
176
|
+
.option('--url <url>', 'API base URL (default: https://dashboard.decoupled.io)')
|
|
177
|
+
.option('--token <token>', 'Personal access token (for direct entry)')
|
|
178
|
+
.option('--profile <name>', 'Profile name', 'default')
|
|
179
|
+
.option('--manual', 'Enter token manually instead of opening browser')
|
|
180
|
+
.action(async (options) => {
|
|
181
|
+
try {
|
|
182
|
+
let { url, token, profile } = options;
|
|
183
|
+
// Always use platform URL for PAT login, ignore existing profile baseUrl
|
|
184
|
+
if (!url) {
|
|
185
|
+
url = 'https://dashboard.decoupled.io';
|
|
186
|
+
}
|
|
187
|
+
// If manual flag or token provided, use manual token entry
|
|
188
|
+
if (options.manual || token) {
|
|
189
|
+
return await handleManualLogin(url, token, profile);
|
|
190
|
+
}
|
|
191
|
+
// Default to browser-assisted login (opens browser, user copies token)
|
|
192
|
+
return await handleBrowserLogin(url, profile);
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
console.error(chalk_1.default.red('❌ Login failed:'), error instanceof Error ? error.message : String(error));
|
|
196
|
+
process.exit(1);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
exports.authCommand
|
|
200
|
+
.command('status')
|
|
201
|
+
.description('Show current authentication status')
|
|
202
|
+
.option('--profile <name>', 'Check specific profile')
|
|
203
|
+
.action(async (options) => {
|
|
204
|
+
try {
|
|
205
|
+
const config = config_1.configManager.getConfig();
|
|
206
|
+
const profileName = options.profile || config.currentProfile;
|
|
207
|
+
const profile = config.profiles[profileName];
|
|
208
|
+
if (!profile) {
|
|
209
|
+
console.log(chalk_1.default.yellow(`❌ Profile '${profileName}' not found`));
|
|
210
|
+
console.log(chalk_1.default.gray('Run "dcloud auth login" to set up authentication'));
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const token = await config_1.configManager.getToken(profileName);
|
|
214
|
+
const authMethod = profile.useOAuth ? 'OAuth (from .env.local)' : 'Personal Access Token';
|
|
215
|
+
const hasOAuth = config_1.configManager.hasOAuthCredentials();
|
|
216
|
+
console.log(chalk_1.default.bold('\n📋 Authentication Status'));
|
|
217
|
+
console.log('────────────────────────────');
|
|
218
|
+
console.log(`Profile: ${chalk_1.default.cyan(profileName)} ${profileName === config.currentProfile ? chalk_1.default.green('(current)') : ''}`);
|
|
219
|
+
console.log(`Base URL: ${chalk_1.default.cyan(profile.baseUrl)}`);
|
|
220
|
+
console.log(`Auth Method: ${chalk_1.default.cyan(authMethod)}`);
|
|
221
|
+
console.log(`Token: ${token ? chalk_1.default.green('✅ Available') : chalk_1.default.red('❌ Missing')}`);
|
|
222
|
+
if (profile.useOAuth) {
|
|
223
|
+
console.log(`OAuth Env: ${hasOAuth ? chalk_1.default.green('✅ Found') : chalk_1.default.red('❌ Missing')}`);
|
|
224
|
+
}
|
|
225
|
+
if (token) {
|
|
226
|
+
console.log(chalk_1.default.blue('\n🔍 Testing connection...'));
|
|
227
|
+
try {
|
|
228
|
+
const client = await (0, api_1.createApiClient)(profileName);
|
|
229
|
+
// Use different test endpoints based on auth method
|
|
230
|
+
if (profile.useOAuth) {
|
|
231
|
+
// Test Drupal content import API for OAuth profiles
|
|
232
|
+
const response = await client.client.get('/api/dcloud-import/status');
|
|
233
|
+
if (response.status === 200 && response.data.success) {
|
|
234
|
+
console.log(chalk_1.default.green('✅ Connection successful'));
|
|
235
|
+
console.log(chalk_1.default.gray(` Connected to: ${response.data.service} v${response.data.version}`));
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
console.log(chalk_1.default.red('❌ Connection failed: Drupal API not responding properly'));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
// Test platform API for PAT profiles
|
|
243
|
+
const result = await client.testAuth();
|
|
244
|
+
if (result.success) {
|
|
245
|
+
console.log(chalk_1.default.green('✅ Connection successful'));
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
console.log(chalk_1.default.red('❌ Connection failed:'), result.error);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
console.log(chalk_1.default.red('❌ Connection failed:'), error instanceof Error ? error.message : String(error));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
console.error(chalk_1.default.red('❌ Error checking status:'), error instanceof Error ? error.message : String(error));
|
|
259
|
+
process.exit(1);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
exports.authCommand
|
|
263
|
+
.command('logout')
|
|
264
|
+
.description('Remove stored credentials')
|
|
265
|
+
.option('--profile <name>', 'Logout specific profile')
|
|
266
|
+
.option('--all', 'Logout all profiles')
|
|
267
|
+
.action(async (options) => {
|
|
268
|
+
try {
|
|
269
|
+
const config = config_1.configManager.getConfig();
|
|
270
|
+
if (options.all) {
|
|
271
|
+
const profiles = config_1.configManager.listProfiles();
|
|
272
|
+
for (const profile of profiles) {
|
|
273
|
+
await config_1.configManager.deleteToken(profile);
|
|
274
|
+
config_1.configManager.deleteProfile(profile);
|
|
275
|
+
}
|
|
276
|
+
console.log(chalk_1.default.green('✅ All profiles logged out'));
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
const profileName = options.profile || config.currentProfile;
|
|
280
|
+
await config_1.configManager.deleteToken(profileName);
|
|
281
|
+
if (profileName !== 'default') {
|
|
282
|
+
config_1.configManager.deleteProfile(profileName);
|
|
283
|
+
}
|
|
284
|
+
console.log(chalk_1.default.green(`✅ Profile '${profileName}' logged out`));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
console.error(chalk_1.default.red('❌ Logout failed:'), error instanceof Error ? error.message : String(error));
|
|
289
|
+
process.exit(1);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
exports.authCommand
|
|
293
|
+
.command('oauth')
|
|
294
|
+
.description('Configure OAuth authentication using Drupal credentials from .env.local')
|
|
295
|
+
.option('--profile <name>', 'Profile name', 'default')
|
|
296
|
+
.action(async (options) => {
|
|
297
|
+
try {
|
|
298
|
+
const { profile } = options;
|
|
299
|
+
// Check if Drupal OAuth credentials are available
|
|
300
|
+
if (!config_1.configManager.hasOAuthCredentials()) {
|
|
301
|
+
console.error(chalk_1.default.red('❌ No Drupal OAuth credentials found in environment variables'));
|
|
302
|
+
console.log(chalk_1.default.yellow('Add these to your .env.local:'));
|
|
303
|
+
console.log(chalk_1.default.gray(' NEXT_PUBLIC_DRUPAL_BASE_URL=https://your-drupal-site.com'));
|
|
304
|
+
console.log(chalk_1.default.gray(' DRUPAL_CLIENT_ID=your_client_id'));
|
|
305
|
+
console.log(chalk_1.default.gray(' DRUPAL_CLIENT_SECRET=your_client_secret'));
|
|
306
|
+
process.exit(1);
|
|
307
|
+
}
|
|
308
|
+
// Get Drupal base URL from environment
|
|
309
|
+
const drupalBaseUrl = config_1.configManager.getDrupalBaseUrl();
|
|
310
|
+
if (!drupalBaseUrl) {
|
|
311
|
+
console.error(chalk_1.default.red('❌ NEXT_PUBLIC_DRUPAL_BASE_URL not found in environment'));
|
|
312
|
+
process.exit(1);
|
|
313
|
+
}
|
|
314
|
+
console.log(chalk_1.default.blue('🔍 Testing OAuth authentication with Drupal...'));
|
|
315
|
+
console.log(chalk_1.default.gray(` Drupal URL: ${drupalBaseUrl}`));
|
|
316
|
+
// Create profile with OAuth enabled using Drupal URL
|
|
317
|
+
config_1.configManager.setProfile(profile, { baseUrl: drupalBaseUrl, useOAuth: true });
|
|
318
|
+
config_1.configManager.setCurrentProfile(profile);
|
|
319
|
+
// Test the OAuth connection with Drupal API
|
|
320
|
+
const client = await (0, api_1.createApiClient)(profile);
|
|
321
|
+
// Test against Drupal's dcloud-import status endpoint instead of spaces
|
|
322
|
+
try {
|
|
323
|
+
const response = await client.client.get('/api/dcloud-import/status');
|
|
324
|
+
if (response.data.success) {
|
|
325
|
+
console.log(chalk_1.default.green('✅ Drupal dcloud-import API accessible!'));
|
|
326
|
+
console.log(chalk_1.default.gray(` Service: ${response.data.service} v${response.data.version}`));
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
throw new Error(`Drupal API test failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
331
|
+
}
|
|
332
|
+
console.log(chalk_1.default.green('✅ Drupal OAuth authentication successful!'));
|
|
333
|
+
console.log(chalk_1.default.green(`✅ Profile '${profile}' configured for Drupal OAuth`));
|
|
334
|
+
console.log(chalk_1.default.cyan('\n📋 Configuration:'));
|
|
335
|
+
console.log(chalk_1.default.gray(` Profile: ${profile}`));
|
|
336
|
+
console.log(chalk_1.default.gray(` Drupal URL: ${drupalBaseUrl}`));
|
|
337
|
+
console.log(chalk_1.default.gray(` Auth Method: OAuth2 Client Credentials (from .env.local)`));
|
|
338
|
+
console.log(chalk_1.default.gray(` Client ID: ${process.env.DRUPAL_CLIENT_ID}`));
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
console.error(chalk_1.default.red('❌ OAuth setup failed:'), error instanceof Error ? error.message : String(error));
|
|
342
|
+
process.exit(1);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
exports.authCommand
|
|
346
|
+
.command('test')
|
|
347
|
+
.description('Test API connection and permissions')
|
|
348
|
+
.option('--profile <name>', 'Test specific profile')
|
|
349
|
+
.option('--permissions', 'Test specific permissions')
|
|
350
|
+
.action(async (options) => {
|
|
351
|
+
try {
|
|
352
|
+
const client = await (0, api_1.createApiClient)(options.profile);
|
|
353
|
+
console.log(chalk_1.default.blue('🔍 Testing API connection...'));
|
|
354
|
+
const result = await client.testAuth();
|
|
355
|
+
if (result.success) {
|
|
356
|
+
console.log(chalk_1.default.green('✅ Authentication successful'));
|
|
357
|
+
if (options.permissions) {
|
|
358
|
+
console.log(chalk_1.default.blue('\n🔑 Testing permissions...'));
|
|
359
|
+
// Test various endpoints to check permissions
|
|
360
|
+
const tests = [
|
|
361
|
+
{ name: 'Get Usage', test: () => client.getUsage() },
|
|
362
|
+
{ name: 'List Spaces', test: () => client.getSpaces() },
|
|
363
|
+
{ name: 'Get Organization', test: () => client.getOrganization() }
|
|
364
|
+
];
|
|
365
|
+
for (const { name, test } of tests) {
|
|
366
|
+
try {
|
|
367
|
+
await test();
|
|
368
|
+
console.log(chalk_1.default.green(` ✅ ${name}`));
|
|
369
|
+
}
|
|
370
|
+
catch (error) {
|
|
371
|
+
console.log(chalk_1.default.red(` ❌ ${name}: ${error instanceof Error ? error.message : String(error)}`));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
console.log(chalk_1.default.red('❌ Authentication failed:'), result.error);
|
|
378
|
+
process.exit(1);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
catch (error) {
|
|
382
|
+
console.error(chalk_1.default.red('❌ Test failed:'), error instanceof Error ? error.message : String(error));
|
|
383
|
+
process.exit(1);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;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CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;oBACnG,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,0BAA0B,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IAEH,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACnG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,aAAa,SACgB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.configCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const config_1 = require("../lib/config");
|
|
10
|
+
exports.configCommand = new commander_1.Command('config')
|
|
11
|
+
.description('Configuration management');
|
|
12
|
+
exports.configCommand
|
|
13
|
+
.command('show')
|
|
14
|
+
.description('Show current configuration')
|
|
15
|
+
.action(() => {
|
|
16
|
+
const config = config_1.configManager.getConfig();
|
|
17
|
+
console.log(chalk_1.default.bold('\n⚙️ Configuration'));
|
|
18
|
+
console.log('─────────────────');
|
|
19
|
+
console.log(JSON.stringify(config, null, 2));
|
|
20
|
+
});
|
|
21
|
+
exports.configCommand
|
|
22
|
+
.command('set <key> <value>')
|
|
23
|
+
.description('Set configuration value')
|
|
24
|
+
.action((key, value) => {
|
|
25
|
+
try {
|
|
26
|
+
// Parse boolean and number values
|
|
27
|
+
let parsedValue = value;
|
|
28
|
+
if (value === 'true')
|
|
29
|
+
parsedValue = true;
|
|
30
|
+
else if (value === 'false')
|
|
31
|
+
parsedValue = false;
|
|
32
|
+
else if (!isNaN(Number(value)))
|
|
33
|
+
parsedValue = Number(value);
|
|
34
|
+
config_1.configManager.setSetting(key, parsedValue);
|
|
35
|
+
console.log(chalk_1.default.green(`✅ Set ${key} = ${parsedValue}`));
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error(chalk_1.default.red('❌ Failed to set configuration:'), error instanceof Error ? error.message : String(error));
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
exports.configCommand
|
|
43
|
+
.command('reset')
|
|
44
|
+
.description('Reset configuration to defaults')
|
|
45
|
+
.option('--confirm', 'Skip confirmation prompt')
|
|
46
|
+
.action(async (options) => {
|
|
47
|
+
try {
|
|
48
|
+
// Show current config before reset
|
|
49
|
+
console.log(chalk_1.default.bold('\n⚙️ Current Configuration'));
|
|
50
|
+
console.log('─────────────────────────');
|
|
51
|
+
const currentConfig = config_1.configManager.getConfig();
|
|
52
|
+
console.log(JSON.stringify(currentConfig, null, 2));
|
|
53
|
+
// Confirmation prompt unless --confirm flag is used
|
|
54
|
+
if (!options.confirm) {
|
|
55
|
+
const readline = require('readline');
|
|
56
|
+
const rl = readline.createInterface({
|
|
57
|
+
input: process.stdin,
|
|
58
|
+
output: process.stdout
|
|
59
|
+
});
|
|
60
|
+
const answer = await new Promise((resolve) => {
|
|
61
|
+
rl.question(chalk_1.default.yellow('\n⚠️ This will reset all configuration to defaults and clear all profiles and tokens. Continue? (y/N) '), resolve);
|
|
62
|
+
});
|
|
63
|
+
rl.close();
|
|
64
|
+
if (answer.toLowerCase() !== 'y' && answer.toLowerCase() !== 'yes') {
|
|
65
|
+
console.log(chalk_1.default.gray('Configuration reset cancelled.'));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Reset configuration
|
|
70
|
+
await config_1.configManager.resetConfig();
|
|
71
|
+
console.log(chalk_1.default.green('\n✅ Configuration has been reset to defaults'));
|
|
72
|
+
console.log(chalk_1.default.gray('All profiles, tokens, and settings have been cleared.'));
|
|
73
|
+
// Show new default config
|
|
74
|
+
console.log(chalk_1.default.bold('\n⚙️ New Configuration'));
|
|
75
|
+
console.log('──────────────────────');
|
|
76
|
+
const newConfig = config_1.configManager.getConfig();
|
|
77
|
+
console.log(JSON.stringify(newConfig, null, 2));
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.error(chalk_1.default.red('❌ Failed to reset configuration:'), error instanceof Error ? error.message : String(error));
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,kDAA0B;AAC1B,0CAA8C;AAEjC,QAAA,aAAa,GAAG,IAAI,mBAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,0BAA0B,CAAC,CAAC;AAE3C,qBAAa;KACV,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,GAAG,EAAE;IACX,MAAM,MAAM,GAAG,sBAAa,C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