@vee-stack/delta-cli 2.0.4 â 2.0.5
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/dist/analyzer/commands/analyze.js +260 -0
- package/dist/analyzer/commands/config.js +83 -0
- package/dist/analyzer/commands/report.js +38 -0
- package/dist/analyzer/generators/report.generator.js +123 -0
- package/dist/analyzer/index.js +44 -0
- package/dist/analyzer/scanners/project.scanner.js +92 -0
- package/dist/analyzer/validators/contracts.validator.js +42 -0
- package/dist/analyzer/validators/maintainability.validator.js +40 -0
- package/dist/analyzer/validators/observability.validator.js +39 -0
- package/dist/analyzer/validators/performance.validator.js +42 -0
- package/dist/analyzer/validators/security.validator.js +66 -0
- package/dist/analyzer/validators/soc.validator.js +75 -0
- package/dist/apps/cli/src/analyzer/commands/analyze.js +256 -0
- package/dist/apps/cli/src/analyzer/commands/config.js +83 -0
- package/dist/apps/cli/src/analyzer/commands/report.js +38 -0
- package/dist/apps/cli/src/analyzer/generators/report.generator.js +123 -0
- package/dist/apps/cli/src/analyzer/index.js +44 -0
- package/dist/apps/cli/src/analyzer/scanners/project.scanner.js +92 -0
- package/dist/apps/cli/src/analyzer/validators/contracts.validator.js +42 -0
- package/dist/apps/cli/src/analyzer/validators/maintainability.validator.js +40 -0
- package/dist/apps/cli/src/analyzer/validators/observability.validator.js +39 -0
- package/dist/apps/cli/src/analyzer/validators/performance.validator.js +42 -0
- package/dist/apps/cli/src/analyzer/validators/security.validator.js +66 -0
- package/dist/apps/cli/src/analyzer/validators/soc.validator.js +75 -0
- package/dist/apps/cli/src/auth/secure-auth.js +312 -0
- package/dist/apps/cli/src/commands/analyze.js +286 -0
- package/dist/apps/cli/src/commands/auth-new.js +37 -0
- package/dist/apps/cli/src/commands/auth.js +122 -0
- package/dist/apps/cli/src/commands/config.js +49 -0
- package/dist/apps/cli/src/commands/deploy.js +6 -0
- package/dist/apps/cli/src/commands/init.js +47 -0
- package/dist/apps/cli/src/commands/logout.js +23 -0
- package/dist/apps/cli/src/commands/plugins.js +21 -0
- package/dist/apps/cli/src/commands/status.js +80 -0
- package/dist/apps/cli/src/commands/sync.js +6 -0
- package/dist/apps/cli/src/commands/whoami.js +115 -0
- package/dist/apps/cli/src/components/Dashboard.js +168 -0
- package/dist/apps/cli/src/components/DeltaApp.js +56 -0
- package/dist/apps/cli/src/components/UnifiedManager.js +324 -0
- package/dist/apps/cli/src/core/audit.js +184 -0
- package/dist/apps/cli/src/core/completion.js +294 -0
- package/dist/apps/cli/src/core/contracts.js +6 -0
- package/dist/apps/cli/src/core/engine.js +124 -0
- package/dist/apps/cli/src/core/exit-codes.js +71 -0
- package/dist/apps/cli/src/core/hooks.js +181 -0
- package/dist/apps/cli/src/core/index.js +7 -0
- package/dist/apps/cli/src/core/policy.js +115 -0
- package/dist/apps/cli/src/core/profiles.js +161 -0
- package/dist/apps/cli/src/core/wizard.js +203 -0
- package/dist/apps/cli/src/index.js +636 -0
- package/dist/apps/cli/src/interactive/index.js +11 -0
- package/dist/apps/cli/src/plugins/GitStatusPlugin.js +99 -0
- package/dist/apps/cli/src/providers/ai-provider.js +74 -0
- package/dist/apps/cli/src/providers/local-provider.js +302 -0
- package/dist/apps/cli/src/providers/remote-provider.js +100 -0
- package/dist/apps/cli/src/types/api.js +3 -0
- package/dist/apps/cli/src/ui.js +219 -0
- package/dist/apps/cli/src/welcome.js +81 -0
- package/dist/auth/secure-auth.js +418 -0
- package/dist/bundle.js +45 -45
- package/dist/commands/analyze.js +363 -0
- package/dist/commands/auth-new.js +37 -0
- package/dist/commands/auth.js +133 -0
- package/dist/commands/config.js +50 -0
- package/dist/commands/deploy.js +6 -0
- package/dist/commands/init.js +47 -0
- package/dist/commands/logout.js +30 -0
- package/dist/commands/plugins.js +21 -0
- package/dist/commands/status.js +82 -0
- package/dist/commands/sync.js +6 -0
- package/dist/commands/whoami.js +71 -0
- package/dist/components/Dashboard.js +169 -0
- package/dist/components/DeltaApp.js +57 -0
- package/dist/components/UnifiedManager.js +344 -0
- package/dist/core/audit.js +184 -0
- package/dist/core/completion.js +294 -0
- package/dist/core/contracts.js +6 -0
- package/dist/core/engine.js +124 -0
- package/dist/core/exit-codes.js +71 -0
- package/dist/core/hooks.js +181 -0
- package/dist/core/index.js +7 -0
- package/dist/core/policy.js +115 -0
- package/dist/core/profiles.js +161 -0
- package/dist/core/wizard.js +203 -0
- package/dist/index.js +387 -0
- package/dist/interactive/index.js +11 -0
- package/dist/packages/domain/src/constitution/contracts/index.js +43 -0
- package/dist/packages/domain/src/constitution/contracts/ts.rules.js +268 -0
- package/dist/packages/domain/src/constitution/index.js +139 -0
- package/dist/packages/domain/src/constitution/maintainability/index.js +43 -0
- package/dist/packages/domain/src/constitution/maintainability/ts.rules.js +344 -0
- package/dist/packages/domain/src/constitution/observability/index.js +43 -0
- package/dist/packages/domain/src/constitution/observability/ts.rules.js +307 -0
- package/dist/packages/domain/src/constitution/performance/index.js +43 -0
- package/dist/packages/domain/src/constitution/performance/ts.rules.js +325 -0
- package/dist/packages/domain/src/constitution/security/index.js +50 -0
- package/dist/packages/domain/src/constitution/security/ts.rules.js +267 -0
- package/dist/packages/domain/src/constitution/soc/index.js +43 -0
- package/dist/packages/domain/src/constitution/soc/ts.rules.js +360 -0
- package/dist/packages/domain/src/contracts/analysis.contract.js +18 -0
- package/dist/packages/domain/src/contracts/index.js +7 -0
- package/dist/packages/domain/src/contracts/projects.contract.js +18 -0
- package/dist/packages/domain/src/control/registry/rules.registry.js +29 -0
- package/dist/packages/domain/src/control/schemas/policies.js +6 -0
- package/dist/packages/domain/src/core/analysis/discovery.js +163 -0
- package/dist/packages/domain/src/core/analysis/engine.contract.js +298 -0
- package/dist/packages/domain/src/core/analysis/engine.js +77 -0
- package/dist/packages/domain/src/core/analysis/index.js +14 -0
- package/dist/packages/domain/src/core/analysis/orchestrator.js +242 -0
- package/dist/packages/domain/src/core/comparison/engine.js +29 -0
- package/dist/packages/domain/src/core/comparison/index.js +5 -0
- package/dist/packages/domain/src/core/documentation/index.js +5 -0
- package/dist/packages/domain/src/core/documentation/pipeline.js +41 -0
- package/dist/packages/domain/src/core/fs/adapter.js +111 -0
- package/dist/packages/domain/src/core/fs/index.js +5 -0
- package/dist/packages/domain/src/core/parser/unified-parser.js +166 -0
- package/dist/packages/domain/src/index.js +33 -0
- package/dist/packages/domain/src/plugin/registry.js +195 -0
- package/dist/packages/domain/src/plugin/types.js +6 -0
- package/dist/packages/domain/src/ports/analysis.engine.js +7 -0
- package/dist/packages/domain/src/ports/audit.logger.js +7 -0
- package/dist/packages/domain/src/ports/project.repository.js +7 -0
- package/dist/packages/domain/src/rules/index.js +134 -0
- package/dist/packages/domain/src/types/analysis.js +6 -0
- package/dist/packages/domain/src/types/errors.js +53 -0
- package/dist/packages/domain/src/types/fs.js +6 -0
- package/dist/packages/domain/src/types/index.js +7 -0
- package/dist/plugins/GitStatusPlugin.js +93 -0
- package/dist/providers/ai-provider.js +74 -0
- package/dist/providers/local-provider.js +304 -0
- package/dist/providers/remote-provider.js +100 -0
- package/dist/types/api.js +3 -0
- package/dist/ui.js +219 -0
- package/dist/welcome.js +81 -0
- package/package.json +18 -18
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Execution Policy
|
|
3
|
+
* Determines how tasks are executed and which provider to use
|
|
4
|
+
*/
|
|
5
|
+
import { ExitCode } from './exit-codes.js';
|
|
6
|
+
export class DefaultExecutionPolicy {
|
|
7
|
+
config;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
// Validate if a task can be executed
|
|
12
|
+
validate(request) {
|
|
13
|
+
// Check if provider is specified and valid
|
|
14
|
+
if (request.options.provider) {
|
|
15
|
+
const allowedProviders = ['local', 'remote', 'ai'];
|
|
16
|
+
if (!allowedProviders.includes(request.options.provider)) {
|
|
17
|
+
return {
|
|
18
|
+
valid: false,
|
|
19
|
+
reason: `Invalid provider '${request.options.provider}'. Allowed: local, remote, ai`,
|
|
20
|
+
exitCode: ExitCode.VALIDATION_ERROR,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// Check if AI is requested but not available
|
|
24
|
+
if (request.options.provider === 'ai' && !this.config.providers.ai?.enabled) {
|
|
25
|
+
return {
|
|
26
|
+
valid: false,
|
|
27
|
+
reason: 'AI provider is not enabled. Use --provider=local or --provider=remote',
|
|
28
|
+
exitCode: ExitCode.POLICY_BLOCKED,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Validate task type
|
|
33
|
+
const validTypes = ['analyze', 'init', 'status', 'sync', 'deploy', 'config', 'auth', 'plugin'];
|
|
34
|
+
if (!validTypes.includes(request.type)) {
|
|
35
|
+
return {
|
|
36
|
+
valid: false,
|
|
37
|
+
reason: `Invalid task type '${request.type}'`,
|
|
38
|
+
exitCode: ExitCode.VALIDATION_ERROR,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return { valid: true };
|
|
42
|
+
}
|
|
43
|
+
// Select appropriate provider for a task
|
|
44
|
+
selectProvider(request, providers) {
|
|
45
|
+
// If user explicitly specified a provider, use it
|
|
46
|
+
if (request.options.provider) {
|
|
47
|
+
const provider = providers.get(request.options.provider);
|
|
48
|
+
if (provider && provider.capabilities.commands.includes(request.type)) {
|
|
49
|
+
return provider;
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
// Auto-select based on task type and availability
|
|
54
|
+
const preferredProvider = this.getPreferredProvider(request.type);
|
|
55
|
+
const provider = providers.get(preferredProvider);
|
|
56
|
+
if (provider && provider.capabilities.commands.includes(request.type)) {
|
|
57
|
+
return provider;
|
|
58
|
+
}
|
|
59
|
+
// Fallback to any provider that supports this command
|
|
60
|
+
for (const [, provider] of providers) {
|
|
61
|
+
if (provider.capabilities.commands.includes(request.type)) {
|
|
62
|
+
return provider;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
// Get preferred provider based on task type
|
|
68
|
+
getPreferredProvider(taskType) {
|
|
69
|
+
switch (taskType) {
|
|
70
|
+
case 'analyze':
|
|
71
|
+
// Prefer remote for heavy analysis if available
|
|
72
|
+
if (this.config.providers.remote?.enabled) {
|
|
73
|
+
return 'remote';
|
|
74
|
+
}
|
|
75
|
+
return 'local';
|
|
76
|
+
case 'sync':
|
|
77
|
+
case 'deploy':
|
|
78
|
+
// These require remote/cloud
|
|
79
|
+
if (this.config.providers.remote?.enabled) {
|
|
80
|
+
return 'remote';
|
|
81
|
+
}
|
|
82
|
+
return 'local';
|
|
83
|
+
case 'init':
|
|
84
|
+
case 'status':
|
|
85
|
+
case 'config':
|
|
86
|
+
case 'auth':
|
|
87
|
+
default:
|
|
88
|
+
// Default to local for simple operations
|
|
89
|
+
return 'local';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Transform request before execution
|
|
93
|
+
transform(request) {
|
|
94
|
+
// Add non-interactive mode detection
|
|
95
|
+
const isNonTTY = !process.stdout.isTTY;
|
|
96
|
+
if (isNonTTY && !request.options.json) {
|
|
97
|
+
// Force JSON output in non-TTY mode for better piping
|
|
98
|
+
return {
|
|
99
|
+
...request,
|
|
100
|
+
options: {
|
|
101
|
+
...request.options,
|
|
102
|
+
nonInteractive: true,
|
|
103
|
+
json: true,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return request;
|
|
108
|
+
}
|
|
109
|
+
// Check if user has capability to execute (placeholder for future auth checks)
|
|
110
|
+
checkCapabilities(_request) {
|
|
111
|
+
// For now, always allow
|
|
112
|
+
return { allowed: true };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile Management System
|
|
3
|
+
* Manage multiple environments: dev, staging, prod
|
|
4
|
+
* Auto-select provider and settings based on active profile
|
|
5
|
+
*/
|
|
6
|
+
import { promises as fs } from 'fs';
|
|
7
|
+
import { homedir } from 'os';
|
|
8
|
+
import { join } from 'path';
|
|
9
|
+
const PROFILES_FILE = join(homedir(), '.delta', 'profiles.json');
|
|
10
|
+
const DEFAULT_PROFILES = {
|
|
11
|
+
dev: {
|
|
12
|
+
name: 'dev',
|
|
13
|
+
provider: 'local',
|
|
14
|
+
timeout: 30000,
|
|
15
|
+
retries: 1,
|
|
16
|
+
features: {
|
|
17
|
+
analytics: false,
|
|
18
|
+
caching: false,
|
|
19
|
+
autoSync: false,
|
|
20
|
+
},
|
|
21
|
+
env: {
|
|
22
|
+
NODE_ENV: 'development',
|
|
23
|
+
DELTA_LOG_LEVEL: 'debug',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
staging: {
|
|
27
|
+
name: 'staging',
|
|
28
|
+
provider: 'remote',
|
|
29
|
+
apiUrl: 'https://api-staging.delta.dev',
|
|
30
|
+
timeout: 60000,
|
|
31
|
+
retries: 2,
|
|
32
|
+
features: {
|
|
33
|
+
analytics: true,
|
|
34
|
+
caching: true,
|
|
35
|
+
autoSync: true,
|
|
36
|
+
},
|
|
37
|
+
env: {
|
|
38
|
+
NODE_ENV: 'staging',
|
|
39
|
+
DELTA_LOG_LEVEL: 'info',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
prod: {
|
|
43
|
+
name: 'prod',
|
|
44
|
+
provider: 'remote',
|
|
45
|
+
apiUrl: 'https://api.delta.dev',
|
|
46
|
+
timeout: 120000,
|
|
47
|
+
retries: 3,
|
|
48
|
+
features: {
|
|
49
|
+
analytics: true,
|
|
50
|
+
caching: true,
|
|
51
|
+
autoSync: true,
|
|
52
|
+
},
|
|
53
|
+
env: {
|
|
54
|
+
NODE_ENV: 'production',
|
|
55
|
+
DELTA_LOG_LEVEL: 'warn',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
export class ProfileManager {
|
|
60
|
+
data;
|
|
61
|
+
loaded = false;
|
|
62
|
+
constructor() {
|
|
63
|
+
this.data = {
|
|
64
|
+
activeProfile: 'dev',
|
|
65
|
+
profiles: { ...DEFAULT_PROFILES },
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async load() {
|
|
69
|
+
if (this.loaded)
|
|
70
|
+
return;
|
|
71
|
+
try {
|
|
72
|
+
const data = await fs.readFile(PROFILES_FILE, 'utf-8');
|
|
73
|
+
const parsed = JSON.parse(data);
|
|
74
|
+
this.data = {
|
|
75
|
+
activeProfile: parsed.activeProfile || 'dev',
|
|
76
|
+
profiles: { ...DEFAULT_PROFILES, ...parsed.profiles },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Use defaults
|
|
81
|
+
await this.save();
|
|
82
|
+
}
|
|
83
|
+
this.loaded = true;
|
|
84
|
+
}
|
|
85
|
+
async save() {
|
|
86
|
+
await fs.mkdir(join(homedir(), '.delta'), { recursive: true });
|
|
87
|
+
await fs.writeFile(PROFILES_FILE, JSON.stringify(this.data, null, 2), 'utf-8');
|
|
88
|
+
}
|
|
89
|
+
getActiveProfile() {
|
|
90
|
+
return this.data.profiles[this.data.activeProfile] || this.data.profiles.dev;
|
|
91
|
+
}
|
|
92
|
+
getProfile(name) {
|
|
93
|
+
return this.data.profiles[name];
|
|
94
|
+
}
|
|
95
|
+
async setActiveProfile(name) {
|
|
96
|
+
if (!this.data.profiles[name]) {
|
|
97
|
+
throw new Error(`Profile '${name}' not found. Create it first.`);
|
|
98
|
+
}
|
|
99
|
+
this.data.activeProfile = name;
|
|
100
|
+
await this.save();
|
|
101
|
+
}
|
|
102
|
+
async createProfile(name, config) {
|
|
103
|
+
this.data.profiles[name] = {
|
|
104
|
+
name,
|
|
105
|
+
provider: config.provider || 'local',
|
|
106
|
+
apiUrl: config.apiUrl,
|
|
107
|
+
apiKey: config.apiKey,
|
|
108
|
+
timeout: config.timeout || 30000,
|
|
109
|
+
retries: config.retries || 1,
|
|
110
|
+
features: config.features || { analytics: false, caching: false, autoSync: false },
|
|
111
|
+
env: config.env || {},
|
|
112
|
+
};
|
|
113
|
+
await this.save();
|
|
114
|
+
}
|
|
115
|
+
async deleteProfile(name) {
|
|
116
|
+
if (name === this.data.activeProfile) {
|
|
117
|
+
throw new Error('Cannot delete active profile');
|
|
118
|
+
}
|
|
119
|
+
if (DEFAULT_PROFILES[name]) {
|
|
120
|
+
throw new Error(`Cannot delete default profile '${name}'`);
|
|
121
|
+
}
|
|
122
|
+
delete this.data.profiles[name];
|
|
123
|
+
await this.save();
|
|
124
|
+
}
|
|
125
|
+
listProfiles() {
|
|
126
|
+
return Object.keys(this.data.profiles).map(name => ({
|
|
127
|
+
name,
|
|
128
|
+
active: name === this.data.activeProfile,
|
|
129
|
+
provider: this.data.profiles[name].provider,
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
applyToEnvironment() {
|
|
133
|
+
const profile = this.getActiveProfile();
|
|
134
|
+
// Apply environment variables
|
|
135
|
+
for (const [key, value] of Object.entries(profile.env)) {
|
|
136
|
+
process.env[key] = value;
|
|
137
|
+
}
|
|
138
|
+
// Set provider preference
|
|
139
|
+
process.env.DELTA_PROVIDER = profile.provider;
|
|
140
|
+
if (profile.apiUrl) {
|
|
141
|
+
process.env.DELTA_API_URL = profile.apiUrl;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
getProviderForCommand(command) {
|
|
145
|
+
const profile = this.getActiveProfile();
|
|
146
|
+
// Some commands should always use local in dev
|
|
147
|
+
if (profile.name === 'dev' && ['init', 'config', 'status'].includes(command)) {
|
|
148
|
+
return 'local';
|
|
149
|
+
}
|
|
150
|
+
return profile.provider;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Singleton instance
|
|
154
|
+
let profileManager = null;
|
|
155
|
+
export function getProfileManager() {
|
|
156
|
+
if (!profileManager) {
|
|
157
|
+
profileManager = new ProfileManager();
|
|
158
|
+
}
|
|
159
|
+
return profileManager;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=profiles.js.map
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive Wizard Mode
|
|
3
|
+
* Step-by-step guided experience for complex commands
|
|
4
|
+
*/
|
|
5
|
+
import prompts from 'prompts';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
// Init Wizard Steps
|
|
8
|
+
const initWizardSteps = [
|
|
9
|
+
{
|
|
10
|
+
name: 'projectName',
|
|
11
|
+
message: 'What is your project name?',
|
|
12
|
+
type: 'text',
|
|
13
|
+
initial: 'my-delta-project',
|
|
14
|
+
validate: (value) => value.length > 0 || 'Project name is required',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'template',
|
|
18
|
+
message: 'Choose a project template:',
|
|
19
|
+
type: 'select',
|
|
20
|
+
choices: [
|
|
21
|
+
{ title: 'Default', value: 'default', description: 'Basic Delta project structure' },
|
|
22
|
+
{ title: 'Next.js', value: 'nextjs', description: 'Next.js app with Delta integration' },
|
|
23
|
+
{ title: 'React', value: 'react', description: 'React SPA with Delta support' },
|
|
24
|
+
{ title: 'Node.js', value: 'node', description: 'Node.js backend service' },
|
|
25
|
+
{ title: 'Python', value: 'python', description: 'Python project with Delta CLI' },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'features',
|
|
30
|
+
message: 'Select features to enable:',
|
|
31
|
+
type: 'multiselect',
|
|
32
|
+
choices: [
|
|
33
|
+
{ title: 'Code Analysis', value: 'analysis', description: 'Auto-analyze on commits' },
|
|
34
|
+
{ title: 'Documentation', value: 'docs', description: 'Auto-generate docs' },
|
|
35
|
+
{ title: 'CI/CD Config', value: 'cicd', description: 'GitHub Actions workflow' },
|
|
36
|
+
{ title: 'Docker', value: 'docker', description: 'Docker configuration' },
|
|
37
|
+
{ title: 'TypeScript', value: 'typescript', description: 'TypeScript setup' },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'initializeGit',
|
|
42
|
+
message: 'Initialize Git repository?',
|
|
43
|
+
type: 'confirm',
|
|
44
|
+
initial: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'installDependencies',
|
|
48
|
+
message: 'Install dependencies now?',
|
|
49
|
+
type: 'confirm',
|
|
50
|
+
initial: true,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
// Run Init Wizard
|
|
54
|
+
export async function runInitWizard() {
|
|
55
|
+
console.log(chalk.bold.cyan('\nđ Delta Project Wizard\n'));
|
|
56
|
+
console.log(chalk.gray('Answer a few questions to set up your project.\n'));
|
|
57
|
+
const answers = {};
|
|
58
|
+
for (const step of initWizardSteps) {
|
|
59
|
+
const response = await prompts({
|
|
60
|
+
type: step.type,
|
|
61
|
+
name: step.name,
|
|
62
|
+
message: step.message,
|
|
63
|
+
choices: step.choices,
|
|
64
|
+
initial: step.initial,
|
|
65
|
+
validate: step.validate,
|
|
66
|
+
}, {
|
|
67
|
+
onCancel: () => {
|
|
68
|
+
console.log(chalk.yellow('\nâ ď¸ Wizard cancelled'));
|
|
69
|
+
process.exit(0);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
answers[step.name] = response[step.name];
|
|
73
|
+
}
|
|
74
|
+
// Derive project path from name
|
|
75
|
+
const projectPath = `./${answers.projectName}`;
|
|
76
|
+
return {
|
|
77
|
+
projectName: answers.projectName,
|
|
78
|
+
projectPath,
|
|
79
|
+
template: answers.template,
|
|
80
|
+
initializeGit: answers.initializeGit,
|
|
81
|
+
installDependencies: answers.installDependencies,
|
|
82
|
+
features: answers.features || [],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Execute wizard actions
|
|
86
|
+
export async function executeWizardActions(result) {
|
|
87
|
+
console.log(chalk.bold.cyan('\nđŚ Creating Project...\n'));
|
|
88
|
+
const steps = [
|
|
89
|
+
{ name: 'Creating directory', action: () => `mkdir -p ${result.projectPath}` },
|
|
90
|
+
{ name: 'Writing config', action: () => 'config' },
|
|
91
|
+
{ name: 'Setting up template', action: () => result.template },
|
|
92
|
+
];
|
|
93
|
+
if (result.initializeGit) {
|
|
94
|
+
steps.push({ name: 'Initializing Git', action: () => 'git init' });
|
|
95
|
+
}
|
|
96
|
+
if (result.features.includes('docker')) {
|
|
97
|
+
steps.push({ name: 'Creating Dockerfile', action: () => 'docker' });
|
|
98
|
+
}
|
|
99
|
+
if (result.features.includes('cicd')) {
|
|
100
|
+
steps.push({ name: 'Creating CI/CD workflow', action: () => 'cicd' });
|
|
101
|
+
}
|
|
102
|
+
// Simulate progress
|
|
103
|
+
for (let i = 0; i < steps.length; i++) {
|
|
104
|
+
const step = steps[i];
|
|
105
|
+
process.stdout.write(chalk.gray(` [${i + 1}/${steps.length}] ${step.name}... `));
|
|
106
|
+
// Simulate work
|
|
107
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
108
|
+
console.log(chalk.green('â'));
|
|
109
|
+
}
|
|
110
|
+
// Summary
|
|
111
|
+
console.log(chalk.bold.green('\nâ
Project created successfully!\n'));
|
|
112
|
+
console.log(chalk.cyan('Next steps:'));
|
|
113
|
+
console.log(chalk.gray(` cd ${result.projectPath}`));
|
|
114
|
+
console.log(chalk.gray(' delta /analyze # Analyze your code'));
|
|
115
|
+
console.log(chalk.gray(' delta /status # Check project status'));
|
|
116
|
+
console.log();
|
|
117
|
+
}
|
|
118
|
+
// Quick wizard for other commands
|
|
119
|
+
export async function runQuickWizard(command) {
|
|
120
|
+
switch (command) {
|
|
121
|
+
case 'analyze':
|
|
122
|
+
return runAnalyzeWizard();
|
|
123
|
+
case 'deploy':
|
|
124
|
+
return runDeployWizard();
|
|
125
|
+
default:
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function runAnalyzeWizard() {
|
|
130
|
+
console.log(chalk.bold.cyan('\nđ Analysis Wizard\n'));
|
|
131
|
+
const response = await prompts([
|
|
132
|
+
{
|
|
133
|
+
type: 'text',
|
|
134
|
+
name: 'path',
|
|
135
|
+
message: 'Path to analyze?',
|
|
136
|
+
initial: '.',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
type: 'multiselect',
|
|
140
|
+
name: 'scans',
|
|
141
|
+
message: 'Select scans to run:',
|
|
142
|
+
choices: [
|
|
143
|
+
{ title: 'Security', value: 'security', selected: true },
|
|
144
|
+
{ title: 'Performance', value: 'performance', selected: true },
|
|
145
|
+
{ title: 'Code Quality', value: 'quality', selected: true },
|
|
146
|
+
{ title: 'AI Insights', value: 'ai', selected: false },
|
|
147
|
+
],
|
|
148
|
+
hint: 'Space to select, Enter to confirm',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: 'select',
|
|
152
|
+
name: 'format',
|
|
153
|
+
message: 'Output format?',
|
|
154
|
+
choices: [
|
|
155
|
+
{ title: 'JSON', value: 'json' },
|
|
156
|
+
{ title: 'HTML Report', value: 'html' },
|
|
157
|
+
{ title: 'Markdown', value: 'markdown' },
|
|
158
|
+
],
|
|
159
|
+
initial: 0,
|
|
160
|
+
},
|
|
161
|
+
], {
|
|
162
|
+
onCancel: () => {
|
|
163
|
+
console.log(chalk.yellow('\nâ ď¸ Wizard cancelled'));
|
|
164
|
+
process.exit(0);
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
return response;
|
|
168
|
+
}
|
|
169
|
+
async function runDeployWizard() {
|
|
170
|
+
console.log(chalk.bold.cyan('\nđ Deploy Wizard\n'));
|
|
171
|
+
const response = await prompts([
|
|
172
|
+
{
|
|
173
|
+
type: 'select',
|
|
174
|
+
name: 'target',
|
|
175
|
+
message: 'Deploy target?',
|
|
176
|
+
choices: [
|
|
177
|
+
{ title: 'Delta Cloud', value: 'delta' },
|
|
178
|
+
{ title: 'Vercel', value: 'vercel' },
|
|
179
|
+
{ title: 'Netlify', value: 'netlify' },
|
|
180
|
+
{ title: 'Custom Server', value: 'custom' },
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
type: 'confirm',
|
|
185
|
+
name: 'buildFirst',
|
|
186
|
+
message: 'Build before deploy?',
|
|
187
|
+
initial: true,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
type: 'confirm',
|
|
191
|
+
name: 'runTests',
|
|
192
|
+
message: 'Run tests before deploy?',
|
|
193
|
+
initial: true,
|
|
194
|
+
},
|
|
195
|
+
], {
|
|
196
|
+
onCancel: () => {
|
|
197
|
+
console.log(chalk.yellow('\nâ ď¸ Wizard cancelled'));
|
|
198
|
+
process.exit(0);
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
return response;
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=wizard.js.map
|