@vee-stack/delta-cli 2.0.8 → 2.0.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.
Files changed (183) hide show
  1. package/dist/adapters/analysis.adapter.d.ts +29 -0
  2. package/dist/analyzer/commands/analyze.d.ts +14 -0
  3. package/dist/analyzer/commands/config.d.ts +12 -0
  4. package/dist/analyzer/commands/report.d.ts +11 -0
  5. package/dist/analyzer/generators/report.generator.d.ts +43 -0
  6. package/dist/analyzer/index.d.ts +8 -0
  7. package/dist/analyzer/scanners/project.scanner.d.ts +29 -0
  8. package/dist/analyzer/validators/contracts.validator.d.ts +27 -0
  9. package/dist/analyzer/validators/maintainability.validator.d.ts +27 -0
  10. package/dist/analyzer/validators/observability.validator.d.ts +27 -0
  11. package/dist/analyzer/validators/performance.validator.d.ts +27 -0
  12. package/dist/analyzer/validators/security.validator.d.ts +27 -0
  13. package/dist/analyzer/validators/soc.validator.d.ts +27 -0
  14. package/dist/auth/device-auth.d.ts +18 -0
  15. package/dist/auth/secure-auth.d.ts +35 -0
  16. package/dist/bundle.mjs +422 -0
  17. package/dist/commands/analyze.d.ts +12 -0
  18. package/dist/commands/auth-new.d.ts +6 -0
  19. package/dist/commands/auth.d.ts +17 -0
  20. package/dist/commands/config.d.ts +8 -0
  21. package/dist/commands/deploy.d.ts +5 -0
  22. package/dist/commands/init.d.ts +7 -0
  23. package/dist/commands/logout.d.ts +2 -0
  24. package/dist/commands/plugins.d.ts +7 -0
  25. package/dist/commands/status.d.ts +5 -0
  26. package/dist/commands/sync.d.ts +5 -0
  27. package/dist/commands/whoami.d.ts +4 -0
  28. package/dist/components/Dashboard.d.ts +8 -0
  29. package/dist/components/DeltaApp.d.ts +13 -0
  30. package/dist/components/UnifiedManager.d.ts +10 -0
  31. package/dist/core/audit.d.ts +60 -0
  32. package/dist/core/completion.d.ts +79 -0
  33. package/dist/core/contracts.d.ts +127 -0
  34. package/dist/core/engine.d.ts +26 -0
  35. package/dist/core/exit-codes.d.ts +19 -0
  36. package/dist/core/hooks.d.ts +50 -0
  37. package/dist/{apps/cli/src/core/index.js → core/index.d.ts} +1 -1
  38. package/dist/core/policy.d.ts +24 -0
  39. package/dist/core/profiles.d.ts +45 -0
  40. package/dist/core/wizard.d.ts +28 -0
  41. package/dist/interactive/index.d.ts +5 -0
  42. package/dist/plugins/GitStatusPlugin.d.ts +25 -0
  43. package/dist/providers/ai-provider.d.ts +21 -0
  44. package/dist/providers/local-provider.d.ts +21 -0
  45. package/dist/providers/remote-provider.d.ts +15 -0
  46. package/dist/telemetry/wrapper.d.ts +18 -0
  47. package/dist/types/api.d.ts +46 -0
  48. package/dist/ui.d.ts +52 -0
  49. package/dist/welcome.d.ts +8 -0
  50. package/package.json +8 -8
  51. package/dist/analyzer/commands/analyze.js +0 -260
  52. package/dist/analyzer/commands/config.js +0 -83
  53. package/dist/analyzer/commands/report.js +0 -38
  54. package/dist/analyzer/generators/report.generator.js +0 -123
  55. package/dist/analyzer/index.js +0 -44
  56. package/dist/analyzer/scanners/project.scanner.js +0 -92
  57. package/dist/analyzer/validators/contracts.validator.js +0 -42
  58. package/dist/analyzer/validators/maintainability.validator.js +0 -40
  59. package/dist/analyzer/validators/observability.validator.js +0 -39
  60. package/dist/analyzer/validators/performance.validator.js +0 -42
  61. package/dist/analyzer/validators/security.validator.js +0 -66
  62. package/dist/analyzer/validators/soc.validator.js +0 -75
  63. package/dist/apps/cli/src/analyzer/commands/analyze.js +0 -256
  64. package/dist/apps/cli/src/analyzer/commands/config.js +0 -83
  65. package/dist/apps/cli/src/analyzer/commands/report.js +0 -38
  66. package/dist/apps/cli/src/analyzer/generators/report.generator.js +0 -123
  67. package/dist/apps/cli/src/analyzer/index.js +0 -44
  68. package/dist/apps/cli/src/analyzer/scanners/project.scanner.js +0 -92
  69. package/dist/apps/cli/src/analyzer/validators/contracts.validator.js +0 -42
  70. package/dist/apps/cli/src/analyzer/validators/maintainability.validator.js +0 -40
  71. package/dist/apps/cli/src/analyzer/validators/observability.validator.js +0 -39
  72. package/dist/apps/cli/src/analyzer/validators/performance.validator.js +0 -42
  73. package/dist/apps/cli/src/analyzer/validators/security.validator.js +0 -66
  74. package/dist/apps/cli/src/analyzer/validators/soc.validator.js +0 -75
  75. package/dist/apps/cli/src/auth/secure-auth.js +0 -312
  76. package/dist/apps/cli/src/commands/analyze.js +0 -286
  77. package/dist/apps/cli/src/commands/auth-new.js +0 -37
  78. package/dist/apps/cli/src/commands/auth.js +0 -122
  79. package/dist/apps/cli/src/commands/config.js +0 -49
  80. package/dist/apps/cli/src/commands/deploy.js +0 -6
  81. package/dist/apps/cli/src/commands/init.js +0 -47
  82. package/dist/apps/cli/src/commands/logout.js +0 -23
  83. package/dist/apps/cli/src/commands/plugins.js +0 -21
  84. package/dist/apps/cli/src/commands/status.js +0 -80
  85. package/dist/apps/cli/src/commands/sync.js +0 -6
  86. package/dist/apps/cli/src/commands/whoami.js +0 -115
  87. package/dist/apps/cli/src/components/Dashboard.js +0 -168
  88. package/dist/apps/cli/src/components/DeltaApp.js +0 -56
  89. package/dist/apps/cli/src/components/UnifiedManager.js +0 -324
  90. package/dist/apps/cli/src/core/audit.js +0 -184
  91. package/dist/apps/cli/src/core/completion.js +0 -294
  92. package/dist/apps/cli/src/core/contracts.js +0 -6
  93. package/dist/apps/cli/src/core/engine.js +0 -124
  94. package/dist/apps/cli/src/core/exit-codes.js +0 -71
  95. package/dist/apps/cli/src/core/hooks.js +0 -181
  96. package/dist/apps/cli/src/core/policy.js +0 -115
  97. package/dist/apps/cli/src/core/profiles.js +0 -161
  98. package/dist/apps/cli/src/core/wizard.js +0 -203
  99. package/dist/apps/cli/src/index.js +0 -636
  100. package/dist/apps/cli/src/interactive/index.js +0 -11
  101. package/dist/apps/cli/src/plugins/GitStatusPlugin.js +0 -99
  102. package/dist/apps/cli/src/providers/ai-provider.js +0 -74
  103. package/dist/apps/cli/src/providers/local-provider.js +0 -302
  104. package/dist/apps/cli/src/providers/remote-provider.js +0 -100
  105. package/dist/apps/cli/src/types/api.js +0 -3
  106. package/dist/apps/cli/src/ui.js +0 -219
  107. package/dist/apps/cli/src/welcome.js +0 -81
  108. package/dist/auth/secure-auth.js +0 -372
  109. package/dist/bundle.js +0 -504
  110. package/dist/commands/analyze.js +0 -390
  111. package/dist/commands/auth-new.js +0 -37
  112. package/dist/commands/auth.js +0 -134
  113. package/dist/commands/config.js +0 -51
  114. package/dist/commands/deploy.js +0 -6
  115. package/dist/commands/init.js +0 -47
  116. package/dist/commands/logout.js +0 -31
  117. package/dist/commands/plugins.js +0 -21
  118. package/dist/commands/status.js +0 -82
  119. package/dist/commands/sync.js +0 -6
  120. package/dist/commands/whoami.js +0 -72
  121. package/dist/components/Dashboard.js +0 -169
  122. package/dist/components/DeltaApp.js +0 -57
  123. package/dist/components/UnifiedManager.js +0 -344
  124. package/dist/core/audit.js +0 -184
  125. package/dist/core/completion.js +0 -294
  126. package/dist/core/contracts.js +0 -6
  127. package/dist/core/engine.js +0 -124
  128. package/dist/core/exit-codes.js +0 -71
  129. package/dist/core/hooks.js +0 -181
  130. package/dist/core/index.js +0 -7
  131. package/dist/core/policy.js +0 -115
  132. package/dist/core/profiles.js +0 -161
  133. package/dist/core/wizard.js +0 -203
  134. package/dist/index.js +0 -387
  135. package/dist/interactive/index.js +0 -11
  136. package/dist/packages/domain/src/constitution/contracts/index.js +0 -43
  137. package/dist/packages/domain/src/constitution/contracts/ts.rules.js +0 -268
  138. package/dist/packages/domain/src/constitution/index.js +0 -139
  139. package/dist/packages/domain/src/constitution/maintainability/index.js +0 -43
  140. package/dist/packages/domain/src/constitution/maintainability/ts.rules.js +0 -344
  141. package/dist/packages/domain/src/constitution/observability/index.js +0 -43
  142. package/dist/packages/domain/src/constitution/observability/ts.rules.js +0 -307
  143. package/dist/packages/domain/src/constitution/performance/index.js +0 -43
  144. package/dist/packages/domain/src/constitution/performance/ts.rules.js +0 -325
  145. package/dist/packages/domain/src/constitution/security/index.js +0 -50
  146. package/dist/packages/domain/src/constitution/security/ts.rules.js +0 -267
  147. package/dist/packages/domain/src/constitution/soc/index.js +0 -43
  148. package/dist/packages/domain/src/constitution/soc/ts.rules.js +0 -360
  149. package/dist/packages/domain/src/contracts/analysis.contract.js +0 -18
  150. package/dist/packages/domain/src/contracts/index.js +0 -7
  151. package/dist/packages/domain/src/contracts/projects.contract.js +0 -18
  152. package/dist/packages/domain/src/control/registry/rules.registry.js +0 -29
  153. package/dist/packages/domain/src/control/schemas/policies.js +0 -6
  154. package/dist/packages/domain/src/core/analysis/discovery.js +0 -163
  155. package/dist/packages/domain/src/core/analysis/engine.contract.js +0 -298
  156. package/dist/packages/domain/src/core/analysis/engine.js +0 -77
  157. package/dist/packages/domain/src/core/analysis/index.js +0 -14
  158. package/dist/packages/domain/src/core/analysis/orchestrator.js +0 -242
  159. package/dist/packages/domain/src/core/comparison/engine.js +0 -29
  160. package/dist/packages/domain/src/core/comparison/index.js +0 -5
  161. package/dist/packages/domain/src/core/documentation/index.js +0 -5
  162. package/dist/packages/domain/src/core/documentation/pipeline.js +0 -41
  163. package/dist/packages/domain/src/core/fs/adapter.js +0 -111
  164. package/dist/packages/domain/src/core/fs/index.js +0 -5
  165. package/dist/packages/domain/src/core/parser/unified-parser.js +0 -166
  166. package/dist/packages/domain/src/index.js +0 -33
  167. package/dist/packages/domain/src/plugin/registry.js +0 -195
  168. package/dist/packages/domain/src/plugin/types.js +0 -6
  169. package/dist/packages/domain/src/ports/analysis.engine.js +0 -7
  170. package/dist/packages/domain/src/ports/audit.logger.js +0 -7
  171. package/dist/packages/domain/src/ports/project.repository.js +0 -7
  172. package/dist/packages/domain/src/rules/index.js +0 -134
  173. package/dist/packages/domain/src/types/analysis.js +0 -6
  174. package/dist/packages/domain/src/types/errors.js +0 -53
  175. package/dist/packages/domain/src/types/fs.js +0 -6
  176. package/dist/packages/domain/src/types/index.js +0 -7
  177. package/dist/plugins/GitStatusPlugin.js +0 -93
  178. package/dist/providers/ai-provider.js +0 -74
  179. package/dist/providers/local-provider.js +0 -304
  180. package/dist/providers/remote-provider.js +0 -100
  181. package/dist/types/api.js +0 -3
  182. package/dist/ui.js +0 -219
  183. package/dist/welcome.js +0 -81
@@ -1,286 +0,0 @@
1
- /**
2
- * Analyze Command - Run local analysis with optional upload to cloud
3
- */
4
- import * as fs from 'fs/promises';
5
- import * as path from 'path';
6
- import * as crypto from 'crypto';
7
- import { loadConfig } from './auth.js';
8
- export async function analyzeCommand(projectPath, options) {
9
- const targetPath = path.resolve(projectPath);
10
- console.log('🔍 Running analysis...');
11
- console.log(` Path: ${targetPath}`);
12
- // Simple file discovery
13
- const files = await discoverFiles(targetPath, {
14
- include: options.include ? [options.include] : ['**/*.{ts,tsx,js,jsx}'],
15
- exclude: options.exclude ? [options.exclude].concat(['node_modules', 'dist', '.git']) : ['node_modules', 'dist', '.git'],
16
- maxSize: parseInt(options.maxSize, 10),
17
- });
18
- console.log(` Found ${files.length} files to analyze`);
19
- // Run analysis
20
- const startTime = Date.now();
21
- const summary = {
22
- totalFiles: files.length,
23
- successfulParses: files.length,
24
- failedParses: 0,
25
- totalLines: 0,
26
- totalFunctions: 0,
27
- totalClasses: 0,
28
- totalDuration: 0,
29
- errors: [],
30
- };
31
- const findings = [];
32
- for (const file of files) {
33
- try {
34
- const content = await fs.readFile(file, 'utf-8');
35
- const lines = content.split('\n');
36
- summary.totalLines += lines.length;
37
- // Simple heuristics for demo
38
- if (content.includes('function '))
39
- summary.totalFunctions++;
40
- if (content.includes('class '))
41
- summary.totalClasses++;
42
- // Find potential issues
43
- if (content.includes('eval(')) {
44
- findings.push({
45
- file: path.relative(targetPath, file),
46
- type: 'security',
47
- severity: 'high',
48
- message: 'Use of eval() detected',
49
- });
50
- }
51
- if (content.includes('console.log')) {
52
- findings.push({
53
- file: path.relative(targetPath, file),
54
- type: 'maintainability',
55
- severity: 'low',
56
- message: 'Console.log statement found',
57
- });
58
- }
59
- }
60
- catch (error) {
61
- summary.failedParses++;
62
- summary.successfulParses--;
63
- summary.errors.push({
64
- file: path.relative(targetPath, file),
65
- error: error instanceof Error ? error.message : String(error),
66
- });
67
- }
68
- }
69
- summary.totalDuration = Date.now() - startTime;
70
- // Build report
71
- const report = {
72
- schema_version: '1.0',
73
- engine_version: '0.5.0',
74
- created_at: new Date().toISOString(),
75
- project: {
76
- name: options.projectName || path.basename(targetPath),
77
- root_fingerprint: '',
78
- path: targetPath,
79
- },
80
- tools_used: [
81
- { id: 'delta-core', version: '0.5.0', adapter_version: '0.5.0' },
82
- ],
83
- summary: {
84
- total: findings.length,
85
- high: findings.filter(f => f.severity === 'high').length,
86
- medium: findings.filter(f => f.severity === 'medium').length,
87
- low: findings.filter(f => f.severity === 'low').length,
88
- },
89
- findings,
90
- metadata: summary,
91
- };
92
- // Save report to file
93
- const outputDir = path.resolve(options.output);
94
- await fs.mkdir(outputDir, { recursive: true });
95
- const reportFile = path.join(outputDir, `report-${Date.now()}.json`);
96
- await fs.writeFile(reportFile, JSON.stringify(report, null, 2));
97
- console.log('\n✅ Analysis complete');
98
- console.log(` Files analyzed: ${summary.totalFiles}`);
99
- console.log(` Total lines: ${summary.totalLines.toLocaleString()}`);
100
- console.log(` Functions: ${summary.totalFunctions}`);
101
- console.log(` Classes: ${summary.totalClasses}`);
102
- console.log(` Duration: ${(summary.totalDuration / 1000).toFixed(2)}s`);
103
- console.log(` Findings: ${findings.length} (${report.summary.high} high, ${report.summary.medium} medium, ${report.summary.low} low)`);
104
- console.log(` Report saved: ${reportFile}`);
105
- // Upload to cloud if requested
106
- if (options.upload) {
107
- console.log('\n☁️ Uploading report to Delta cloud...');
108
- await uploadReport(report);
109
- }
110
- }
111
- async function uploadReport(report) {
112
- const config = await loadConfig();
113
- if (!config.pat) {
114
- console.error('❌ Error: Not authenticated. Run: delta login --token <pat>');
115
- process.exit(1);
116
- }
117
- const apiUrl = process.env.DELTA_API_URL || config.apiUrl || 'https://api.delta.dev';
118
- const reportJson = JSON.stringify(report);
119
- const reportHash = crypto.createHash('sha256').update(reportJson).digest('hex');
120
- try {
121
- // Step 1: Init upload session
122
- const initResponse = await fetch(`${apiUrl}/api/upload/init`, {
123
- method: 'POST',
124
- headers: {
125
- 'Authorization': `Bearer ${config.pat}`,
126
- 'Content-Type': 'application/json',
127
- 'Idempotency-Key': crypto.randomUUID(),
128
- },
129
- body: JSON.stringify({
130
- schemaVersion: '1.0',
131
- engineVersion: '0.5.0',
132
- reportHash: reportHash,
133
- reportSizeBytes: Buffer.byteLength(reportJson),
134
- toolsUsed: [{ id: 'delta-core', version: '0.5.0', adapterVersion: '0.5.0' }],
135
- }),
136
- });
137
- if (!initResponse.ok) {
138
- let payload = undefined;
139
- try {
140
- payload = await initResponse.json();
141
- }
142
- catch {
143
- payload = await initResponse.text().catch(() => undefined);
144
- }
145
- const details = payload?.error?.details ? `\nDetails: ${JSON.stringify(payload.error.details)}` : '';
146
- const message = payload?.error?.message || `Init failed: ${initResponse.status}`;
147
- throw new Error(message + details);
148
- }
149
- const initData = await initResponse.json();
150
- if (!initData.success) {
151
- throw new Error(initData.error?.message || 'Upload init failed');
152
- }
153
- const uploadId = initData.data.uploadId;
154
- const secret = initData.data.signing.secret;
155
- console.log(` Upload session: ${uploadId}`);
156
- // Step 2: Sign and upload report
157
- const signature = crypto.createHmac('sha256', secret).update(reportJson).digest('hex');
158
- const uploadResponse = await fetch(`${apiUrl}/api/upload/${uploadId}`, {
159
- method: 'PUT',
160
- headers: {
161
- 'Authorization': `Bearer ${config.pat}`,
162
- 'Content-Type': 'application/json',
163
- },
164
- body: JSON.stringify({
165
- report: Object.assign({}, report, {
166
- integrity: {
167
- report_hash: reportHash,
168
- signature: signature,
169
- algorithm: 'HMAC-SHA256',
170
- },
171
- }),
172
- }),
173
- });
174
- if (!uploadResponse.ok) {
175
- let payload = undefined;
176
- try {
177
- payload = await uploadResponse.json();
178
- }
179
- catch {
180
- payload = await uploadResponse.text().catch(() => undefined);
181
- }
182
- const details = payload?.error?.details ? `\nDetails: ${JSON.stringify(payload.error.details)}` : '';
183
- const message = payload?.error?.message || `Upload failed: ${uploadResponse.status}`;
184
- throw new Error(message + details);
185
- }
186
- console.log(' Report uploaded');
187
- // Step 3: Finalize
188
- const finalizeResponse = await fetch(`${apiUrl}/api/upload/${uploadId}/finalize`, {
189
- method: 'POST',
190
- headers: {
191
- 'Authorization': `Bearer ${config.pat}`,
192
- 'Content-Type': 'application/json',
193
- 'Idempotency-Key': crypto.randomUUID(),
194
- },
195
- body: '{}',
196
- });
197
- if (!finalizeResponse.ok) {
198
- let payload = undefined;
199
- try {
200
- payload = await finalizeResponse.json();
201
- }
202
- catch {
203
- payload = await finalizeResponse.text().catch(() => undefined);
204
- }
205
- const details = payload?.error?.details ? `\nDetails: ${JSON.stringify(payload.error.details)}` : '';
206
- const message = payload?.error?.message || `Finalize failed: ${finalizeResponse.status}`;
207
- throw new Error(message + details);
208
- }
209
- const finalizeData = await finalizeResponse.json();
210
- if (!finalizeData.success) {
211
- throw new Error(finalizeData.error?.message || 'Upload finalize failed');
212
- }
213
- console.log(`✅ Report finalized: ${finalizeData.data.reportId}`);
214
- console.log(` Quota updated`);
215
- }
216
- catch (error) {
217
- console.error('❌ Upload failed:', error instanceof Error ? error.message : String(error));
218
- process.exit(1);
219
- }
220
- }
221
- async function discoverFiles(rootPath, options) {
222
- const files = [];
223
- async function walk(dir) {
224
- const entries = await fs.readdir(dir, { withFileTypes: true });
225
- for (const entry of entries) {
226
- const fullPath = path.join(dir, entry.name);
227
- if (entry.isDirectory()) {
228
- // Skip excluded directories
229
- if (options.exclude.some(e => entry.name.includes(e)))
230
- continue;
231
- await walk(fullPath);
232
- }
233
- else if (entry.isFile()) {
234
- // Check include patterns - support glob patterns like **/*.{ts,tsx}
235
- const shouldInclude = options.include.some(pattern => {
236
- // Handle brace expansion: **/*.{ts,tsx} → match **/*.ts or **/*.tsx
237
- if (pattern.includes('{') && pattern.includes('}')) {
238
- const braceMatch = pattern.match(/\{([^}]+)\}/);
239
- if (braceMatch) {
240
- const extensions = braceMatch[1].split(',');
241
- const basePattern = pattern.replace(/\{[^}]+\}/, '');
242
- return extensions.some(ext => {
243
- const fullPattern = basePattern + ext;
244
- return matchGlob(fullPath, fullPattern);
245
- });
246
- }
247
- }
248
- return matchGlob(fullPath, pattern);
249
- });
250
- if (shouldInclude) {
251
- // Check file size
252
- try {
253
- const stats = await fs.stat(fullPath);
254
- if (stats.size <= options.maxSize) {
255
- files.push(fullPath);
256
- }
257
- }
258
- catch {
259
- // Skip files we can't stat
260
- }
261
- }
262
- }
263
- }
264
- }
265
- await walk(rootPath);
266
- return files;
267
- }
268
- function matchGlob(filePath, pattern) {
269
- // Convert glob pattern to regex
270
- // **/*.ts → matches any .ts file in any directory
271
- // *.ts → matches .ts files in current directory
272
- const fileName = filePath.split(/[/\\]/).pop() || '';
273
- if (pattern.includes('**')) {
274
- // Match any directory depth
275
- const ext = pattern.replace('**/*', '');
276
- return fileName.endsWith(ext);
277
- }
278
- else if (pattern.includes('*')) {
279
- // Simple wildcard
280
- const ext = pattern.replace('*', '');
281
- return fileName.endsWith(ext);
282
- }
283
- // Exact match
284
- return filePath.includes(pattern);
285
- }
286
- //# sourceMappingURL=analyze.js.map
@@ -1,37 +0,0 @@
1
- import chalk from 'chalk';
2
- import { startOAuthFlow, authenticateWithPAT, SecureTokenStore } from '../auth/secure-auth.js';
3
- import { printSuccess, printInfo } from '../ui.js';
4
- import prompts from 'prompts';
5
- export async function loginCommand(options) {
6
- // Check if already authenticated
7
- if (await SecureTokenStore.hasTokens()) {
8
- const overwrite = await prompts({
9
- type: 'confirm',
10
- name: 'value',
11
- message: chalk.yellow('Already authenticated. Overwrite existing credentials?'),
12
- initial: false,
13
- });
14
- if (!overwrite.value) {
15
- printInfo('Login cancelled');
16
- return;
17
- }
18
- }
19
- if (options.token) {
20
- // PAT authentication
21
- await authenticateWithPAT(options.token);
22
- }
23
- else {
24
- // OAuth2 flow
25
- const method = options.method || 'oauth';
26
- const success = await startOAuthFlow(method);
27
- if (success) {
28
- printSuccess('You are now logged in!');
29
- printInfo('Run "delta whoami" to see your account info');
30
- }
31
- }
32
- }
33
- export async function logoutCommand() {
34
- const { logout } = await import('../auth/secure-auth.js');
35
- await logout();
36
- }
37
- //# sourceMappingURL=auth-new.js.map
@@ -1,122 +0,0 @@
1
- /**
2
- * Enhanced Auth Commands - Professional CLI with interactive prompts
3
- */
4
- import * as fs from 'fs/promises';
5
- import * as path from 'path';
6
- import * as os from 'os';
7
- import { icons, startSpinner, stopSpinner, printHeader, printSection, printSuccess, printError, printInfo, printKeyValue, printCommandHint, createTable, password, printWelcome, } from '../ui.js';
8
- const CONFIG_DIR = path.join(os.homedir(), '.delta');
9
- const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
10
- async function loadConfig() {
11
- try {
12
- const data = await fs.readFile(CONFIG_FILE, 'utf-8');
13
- return JSON.parse(data);
14
- }
15
- catch {
16
- return {};
17
- }
18
- }
19
- async function saveConfig(config) {
20
- await fs.mkdir(CONFIG_DIR, { recursive: true });
21
- await fs.writeFile(CONFIG_FILE, JSON.stringify(config, null, 2));
22
- }
23
- export const authCommands = {
24
- async login(options) {
25
- printWelcome();
26
- printHeader('Authentication');
27
- let token = options.token || process.env.DELTA_PAT;
28
- // Interactive prompt if no token provided
29
- if (!token) {
30
- printInfo('No token provided. Please enter your PAT (Personal Access Token).');
31
- printCommandHint('delta login --token <your-token>', 'to skip this prompt');
32
- console.log();
33
- const tokenInput = await password('Enter PAT (starts with delta_pat_):');
34
- if (!tokenInput) {
35
- printError('Authentication cancelled');
36
- process.exit(1);
37
- }
38
- token = tokenInput;
39
- }
40
- // Validate token format
41
- if (!token.startsWith('delta_pat_')) {
42
- printError('Invalid PAT token format', 'Token should start with "delta_pat_"');
43
- console.log();
44
- printInfo('You can get your PAT from:');
45
- printCommandHint('https://app.delta.dev/settings/tokens', '');
46
- process.exit(1);
47
- }
48
- // Load existing config to get custom apiUrl if set
49
- const existingConfig = await loadConfig();
50
- const apiUrl = process.env.DELTA_API_URL || existingConfig.apiUrl || 'https://api.delta.dev';
51
- printSection('Connecting to Platform');
52
- printKeyValue('API Endpoint', apiUrl);
53
- console.log();
54
- startSpinner('Verifying credentials...');
55
- try {
56
- const controller = new AbortController();
57
- const timeout = setTimeout(() => controller.abort(), 10000);
58
- const response = await fetch(`${apiUrl}/api/me/entitlements`, {
59
- headers: {
60
- 'Authorization': `Bearer ${token}`,
61
- 'Content-Type': 'application/json',
62
- },
63
- signal: controller.signal,
64
- });
65
- clearTimeout(timeout);
66
- if (!response.ok) {
67
- const errorText = await response.text().catch(() => response.statusText);
68
- throw new Error(`HTTP ${response.status}: ${errorText}`);
69
- }
70
- const data = await response.json();
71
- if (!data.success) {
72
- throw new Error(data.error?.message || 'Authentication failed');
73
- }
74
- // Save config
75
- await saveConfig({
76
- pat: token,
77
- apiUrl,
78
- lastUsedAt: new Date().toISOString(),
79
- });
80
- stopSpinner(true, 'Authentication successful!');
81
- console.log();
82
- const user = data.data.user;
83
- const quota = data.data.quota;
84
- printHeader('Account Overview');
85
- // User info table
86
- const userTable = createTable(['Property', 'Value']);
87
- userTable.push([icons.user + ' Email', user.email], [icons.package + ' Plan', user.plan], [icons.chart + ' Quota Used', `${quota.used}/${quota.limit} reports`], [icons.lock + ' Config', CONFIG_FILE]);
88
- console.log(userTable.toString());
89
- console.log();
90
- printSuccess(`Welcome back, ${user.email.split('@')[0]}! 🎉`);
91
- console.log();
92
- printCommandHint('delta whoami', 'to see full account details');
93
- printCommandHint('delta analyze', 'to start analyzing code');
94
- }
95
- catch (error) {
96
- stopSpinner(false, 'Authentication failed');
97
- console.log();
98
- if (error instanceof Error && error.name === 'AbortError') {
99
- printError('Request timeout (10s)', 'Check if the server is running and accessible');
100
- }
101
- else {
102
- const message = error instanceof Error ? error.message : String(error);
103
- if (message.includes('401')) {
104
- printError('Invalid or expired token', 'Generate a new token from the web app');
105
- }
106
- else if (message.includes('ENOTFOUND') || message.includes('ECONNREFUSED')) {
107
- printError('Cannot connect to server', 'Check your internet connection and API URL');
108
- }
109
- else {
110
- printError(message);
111
- }
112
- }
113
- console.log();
114
- printInfo('Need help? Visit: https://docs.delta.dev/cli/authentication');
115
- process.exit(1);
116
- }
117
- },
118
- };
119
- // Export individual commands for direct import
120
- export const loginCommand = authCommands.login;
121
- export { loadConfig, saveConfig, CONFIG_FILE };
122
- //# sourceMappingURL=auth.js.map
@@ -1,49 +0,0 @@
1
- /**
2
- * Config Command - Manage CLI configuration
3
- */
4
- import { loadConfig, saveConfig, CONFIG_FILE } from './auth.js';
5
- export async function configCommand(options) {
6
- const config = await loadConfig();
7
- if (options.get) {
8
- const value = config[options.get];
9
- if (value !== undefined) {
10
- console.log(`${options.get}: ${value}`);
11
- }
12
- else {
13
- console.log(`${options.get}: (not set)`);
14
- }
15
- return;
16
- }
17
- if (options.set) {
18
- const [key, value] = options.set.split('=');
19
- if (!key || value === undefined) {
20
- console.error('❌ Error: Invalid format. Use: key=value');
21
- process.exit(1);
22
- }
23
- const newConfig = {
24
- ...config,
25
- pat: config.pat || '',
26
- apiUrl: config.apiUrl || 'https://api.delta.dev',
27
- [key]: value,
28
- };
29
- await saveConfig(newConfig);
30
- console.log(`✅ Set ${key} = ${value}`);
31
- return;
32
- }
33
- if (options.list || (!options.get && !options.set)) {
34
- console.log('🔧 Delta CLI Configuration');
35
- console.log(` Config file: ${CONFIG_FILE}`);
36
- console.log();
37
- if (config.pat) {
38
- console.log(' PAT: ✅ Set (hidden)');
39
- }
40
- else {
41
- console.log(' PAT: ❌ Not set');
42
- }
43
- console.log(` API URL: ${config.apiUrl || 'https://api.delta.dev (default)'}`);
44
- if (config.lastUsedAt) {
45
- console.log(` Last used: ${new Date(config.lastUsedAt).toLocaleString()}`);
46
- }
47
- }
48
- }
49
- //# sourceMappingURL=config.js.map
@@ -1,6 +0,0 @@
1
- import { printSuccess, printInfo } from '../ui.js';
2
- export async function deployCommand(_options) {
3
- printInfo('Deploying documentation site...');
4
- printSuccess('Deploy completed successfully');
5
- }
6
- //# sourceMappingURL=deploy.js.map
@@ -1,47 +0,0 @@
1
- /**
2
- * Init Command - Initialize a new Delta project
3
- */
4
- import * as fs from 'fs/promises';
5
- import * as path from 'path';
6
- export async function initCommand(projectPath, options) {
7
- const targetPath = path.resolve(projectPath);
8
- const configPath = path.join(targetPath, 'delta.config.json');
9
- try {
10
- // Check if directory exists
11
- await fs.access(targetPath);
12
- }
13
- catch {
14
- console.log(`📁 Creating directory: ${targetPath}`);
15
- await fs.mkdir(targetPath, { recursive: true });
16
- }
17
- // Check if config already exists
18
- try {
19
- await fs.access(configPath);
20
- if (!options.force) {
21
- console.log('⚠️ Delta config already exists');
22
- console.log(' Use --force to overwrite');
23
- return;
24
- }
25
- }
26
- catch {
27
- // Config doesn't exist, continue
28
- }
29
- // Create default config
30
- const config = {
31
- name: path.basename(targetPath),
32
- version: '1.0.0',
33
- template: options.template || 'default',
34
- createdAt: new Date().toISOString(),
35
- settings: {
36
- include: ['src/**/*'],
37
- exclude: ['node_modules', 'dist', '.git'],
38
- maxFileSize: 10485760,
39
- },
40
- };
41
- await fs.writeFile(configPath, JSON.stringify(config, null, 2));
42
- console.log('✅ Project initialized');
43
- console.log(` Path: ${targetPath}`);
44
- console.log(` Config: ${configPath}`);
45
- console.log(` Template: ${config.template}`);
46
- }
47
- //# sourceMappingURL=init.js.map
@@ -1,23 +0,0 @@
1
- /**
2
- * Logout Command - Remove stored authentication
3
- */
4
- import * as fs from 'fs/promises';
5
- import { CONFIG_FILE, loadConfig } from './auth.js';
6
- export async function logoutCommand() {
7
- try {
8
- const config = await loadConfig();
9
- if (!config.pat) {
10
- console.log('ℹ️ Not currently authenticated');
11
- return;
12
- }
13
- // Remove the config file
14
- await fs.unlink(CONFIG_FILE);
15
- console.log('✅ Successfully logged out');
16
- console.log(' Authentication data removed');
17
- }
18
- catch (error) {
19
- console.error('❌ Error during logout:', error instanceof Error ? error.message : String(error));
20
- process.exit(1);
21
- }
22
- }
23
- //# sourceMappingURL=logout.js.map
@@ -1,21 +0,0 @@
1
- import { printSuccess, printInfo } from '../ui.js';
2
- export async function pluginsCommand(options) {
3
- if (options.list) {
4
- printInfo('Installed plugins:');
5
- }
6
- else if (options.install) {
7
- printInfo(`Installing plugin: ${options.install}`);
8
- printSuccess('Plugin installed successfully');
9
- }
10
- else if (options.uninstall) {
11
- printInfo(`Uninstalling plugin: ${options.uninstall}`);
12
- printSuccess('Plugin uninstalled successfully');
13
- }
14
- else if (options.search) {
15
- printInfo(`Searching for plugins: ${options.search}`);
16
- }
17
- else {
18
- printInfo('Use --list, --install, --uninstall, or --search');
19
- }
20
- }
21
- //# sourceMappingURL=plugins.js.map
@@ -1,80 +0,0 @@
1
- /**
2
- * Enhanced Status Command - Professional project and connection status
3
- */
4
- import * as fs from 'fs/promises';
5
- import * as path from 'path';
6
- import { loadConfig } from './auth.js';
7
- import { icons, startSpinner, stopSpinner, printWelcome, printHeader, printSection, printSuccess, printError, printWarning, printInfo, printKeyValue, printCommandHint, createTable, printDivider, confirm, } from '../ui.js';
8
- export async function statusCommand(projectPath, _options) {
9
- const targetPath = path.resolve(projectPath);
10
- printWelcome();
11
- printHeader('Project Status Check');
12
- printKeyValue('Path', targetPath);
13
- console.log();
14
- // Check for delta config
15
- printSection('Project Configuration');
16
- const configPath = path.join(targetPath, 'delta.config.json');
17
- try {
18
- await fs.access(configPath);
19
- const config = JSON.parse(await fs.readFile(configPath, 'utf-8'));
20
- printSuccess('Configuration found');
21
- const configTable = createTable(['Property', 'Value']);
22
- configTable.push([icons.folder + ' Name', config.name || 'Unnamed'], [icons.folder + ' Type', config.type || 'default'], [icons.gear + ' Version', config.version || 'N/A'], [icons.info + ' Config File', configPath]);
23
- console.log(configTable.toString());
24
- }
25
- catch {
26
- printWarning('No Delta project found');
27
- printInfo('Initialize a new project:');
28
- printCommandHint(`delta init ${projectPath}`, 'to create a new project');
29
- const shouldInit = await confirm('Would you like to initialize now?', true);
30
- if (shouldInit) {
31
- console.log();
32
- printInfo('Run: delta init ' + projectPath);
33
- }
34
- }
35
- console.log();
36
- printDivider();
37
- // Check auth status
38
- printSection('Authentication');
39
- const auth = await loadConfig();
40
- if (auth.pat) {
41
- printSuccess('Authenticated');
42
- printKeyValue('API URL', auth.apiUrl || 'default');
43
- // Test connection
44
- const apiUrl = auth.apiUrl || process.env.DELTA_API_URL || 'https://api.delta.dev';
45
- startSpinner('Testing connection...');
46
- try {
47
- const response = await fetch(`${apiUrl}/api/me/entitlements`, {
48
- headers: { 'Authorization': `Bearer ${auth.pat}` },
49
- });
50
- if (response.ok) {
51
- stopSpinner(true, 'Connection active');
52
- const data = await response.json();
53
- if (data.success) {
54
- printKeyValue('User', data.data.user.email);
55
- printKeyValue('Plan', data.data.user.plan);
56
- }
57
- }
58
- else {
59
- stopSpinner(false, 'Authentication expired');
60
- printError('Your session has expired');
61
- printCommandHint('delta login --token <new-pat>', 'to re-authenticate');
62
- }
63
- }
64
- catch {
65
- stopSpinner(false, 'API unreachable');
66
- printError('Cannot connect to Delta API');
67
- printInfo('Check your internet connection or API URL configuration');
68
- }
69
- }
70
- else {
71
- printError('Not authenticated');
72
- printInfo('Please login to access cloud features:');
73
- printCommandHint('delta login --token <pat>', 'to authenticate');
74
- }
75
- console.log();
76
- printDivider();
77
- printCommandHint('delta analyze', 'to analyze your project');
78
- printCommandHint('delta whoami', 'to see account details');
79
- }
80
- //# sourceMappingURL=status.js.map