@paulduvall/claude-dev-toolkit 0.0.1-alpha.11 → 0.0.1-alpha.13
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 +7 -7
- package/bin/claude-commands +72 -9
- package/commands/active/xcontinue.md +92 -0
- package/commands/active/xexplore.md +94 -0
- package/commands/active/xverify.md +80 -0
- package/commands/experiments/xdevcontainer.md +238 -0
- package/commands/experiments/xnew.md +5 -0
- package/hooks/README.md +32 -0
- package/hooks/file-logger.sh +4 -2
- package/hooks/lib/argument-parser.sh +7 -2
- package/hooks/lib/config-constants.sh +4 -4
- package/hooks/lib/context-manager.sh +19 -8
- package/hooks/lib/error-handler.sh +21 -10
- package/hooks/lib/execution-engine.sh +11 -194
- package/hooks/lib/execution-results.sh +113 -0
- package/hooks/lib/execution-simulation.sh +114 -0
- package/hooks/lib/field-validators.sh +104 -0
- package/hooks/lib/file-utils.sh +49 -26
- package/hooks/lib/subagent-discovery.sh +9 -6
- package/hooks/lib/subagent-validator.sh +19 -209
- package/hooks/lib/validation-reporter.sh +134 -0
- package/hooks/on-error-debug.sh +16 -11
- package/hooks/pre-commit-test-runner.sh +132 -0
- package/hooks/pre-write-security.sh +14 -6
- package/hooks/prevent-credential-exposure.sh +55 -45
- package/hooks/subagent-trigger-simple.sh +17 -8
- package/hooks/verify-before-edit.sh +135 -0
- package/lib/oidc-command.js +385 -8
- package/lib/setup-wizard.js +155 -262
- package/lib/uninstall-command.js +100 -0
- package/package.json +2 -2
- package/scripts/postinstall.js +168 -171
- package/subagents/debug-specialist.md +6 -0
- package/templates/README.md +15 -0
- package/templates/basic-settings.json +33 -19
- package/templates/comprehensive-settings.json +68 -171
- package/templates/global-claude.md +344 -0
- package/templates/security-focused-settings.json +58 -41
- package/lib/installation-instruction-generator-backup.js +0 -579
- package/lib/package-manager-service.js +0 -270
- package/subagents/debug-context.md +0 -197
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"// Security-focused Claude Code settings.json template": "Copy to ~/.claude/settings.json",
|
|
3
|
-
"//
|
|
3
|
+
"// Based on official Claude Code documentation": "https://docs.anthropic.com/en/docs/claude-code/settings",
|
|
4
|
+
"// Includes comprehensive security controls and governance": "",
|
|
4
5
|
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
"// Restrictive tool permissions for security": "",
|
|
7
|
+
"permissions": {
|
|
8
|
+
"allow": [
|
|
9
|
+
"Read(*)",
|
|
10
|
+
"Edit(*.md)",
|
|
11
|
+
"Edit(*.txt)",
|
|
12
|
+
"Edit(*.json)",
|
|
13
|
+
"Edit(*.yml)",
|
|
14
|
+
"Edit(*.yaml)",
|
|
15
|
+
"Bash(git *)",
|
|
16
|
+
"Bash(npm run *)",
|
|
17
|
+
"Bash(python -m *)",
|
|
18
|
+
"Bash(node *)",
|
|
19
|
+
"MultiEdit(*)"
|
|
20
|
+
],
|
|
21
|
+
"deny": [
|
|
22
|
+
"Bash(curl *)",
|
|
23
|
+
"Bash(wget *)",
|
|
24
|
+
"Bash(ssh *)",
|
|
25
|
+
"Bash(sudo *)",
|
|
26
|
+
"Bash(rm -rf *)",
|
|
27
|
+
"Bash(*production*)",
|
|
28
|
+
"Bash(*admin*)",
|
|
29
|
+
"Edit(/etc/*)",
|
|
30
|
+
"Edit(/root/*)",
|
|
31
|
+
"Edit(~/.ssh/*)",
|
|
32
|
+
"Read(/etc/passwd)",
|
|
33
|
+
"Read(/etc/shadow)",
|
|
34
|
+
"Read(~/.aws/*)",
|
|
35
|
+
"Read(~/.ssh/id_*)"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
19
38
|
|
|
20
|
-
"//
|
|
39
|
+
"// Comprehensive security hooks": "",
|
|
21
40
|
"hooks": {
|
|
22
41
|
"PreToolUse": [
|
|
23
42
|
{
|
|
@@ -25,38 +44,36 @@
|
|
|
25
44
|
"hooks": [
|
|
26
45
|
{
|
|
27
46
|
"type": "command",
|
|
28
|
-
"command": "~/.claude/hooks/prevent-credential-exposure.sh"
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
"command": "~/.claude/hooks/prevent-credential-exposure.sh"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"type": "command",
|
|
51
|
+
"command": "~/.claude/hooks/verify-before-edit.sh"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"matcher": "Bash",
|
|
57
|
+
"hooks": [
|
|
58
|
+
{
|
|
59
|
+
"type": "command",
|
|
60
|
+
"command": "~/.claude/hooks/pre-commit-test-runner.sh"
|
|
31
61
|
}
|
|
32
62
|
]
|
|
33
63
|
}
|
|
34
64
|
]
|
|
35
65
|
},
|
|
36
66
|
|
|
37
|
-
"//
|
|
67
|
+
"// Standard Claude Code environment variables": "",
|
|
38
68
|
"env": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"SECURITY_WEBHOOK_URL": "https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK",
|
|
42
|
-
"CLAUDE_SECURITY_OVERRIDE": "false"
|
|
69
|
+
"DISABLE_TELEMETRY": "1",
|
|
70
|
+
"ANTHROPIC_LOG": "error"
|
|
43
71
|
},
|
|
44
72
|
|
|
45
|
-
"//
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"Edit(*)",
|
|
52
|
-
"Read(*)",
|
|
53
|
-
"Write(*)"
|
|
54
|
-
],
|
|
55
|
-
"deny": [
|
|
56
|
-
"Bash(curl *)",
|
|
57
|
-
"Bash(wget *)",
|
|
58
|
-
"Bash(ssh *)",
|
|
59
|
-
"Bash(sudo *)"
|
|
60
|
-
]
|
|
61
|
-
}
|
|
73
|
+
"// Security-focused settings": "",
|
|
74
|
+
"includeCoAuthoredBy": false,
|
|
75
|
+
"cleanupPeriodDays": 7,
|
|
76
|
+
|
|
77
|
+
"// Disable auto-approval of MCP servers for security": "",
|
|
78
|
+
"enableAllProjectMcpServers": false
|
|
62
79
|
}
|
|
@@ -1,579 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Installation Instruction Generator
|
|
3
|
-
*
|
|
4
|
-
* Orchestrator for generating platform-specific installation instructions and recovery guidance.
|
|
5
|
-
* Refactored to use focused services following Single Responsibility Principle.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Cross-platform installation instructions via PlatformInstructionService
|
|
9
|
-
* - Package manager integration via PackageManagerService
|
|
10
|
-
* - Recovery and troubleshooting guidance via RecoveryInstructionService
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const PlatformInstructionService = require('./services/platform-instruction-service');
|
|
14
|
-
const PackageManagerService = require('./services/package-manager-service');
|
|
15
|
-
const RecoveryInstructionService = require('./services/recovery-instruction-service');
|
|
16
|
-
const LoggerService = require('./services/logger-service');
|
|
17
|
-
|
|
18
|
-
class InstallationInstructionGenerator {
|
|
19
|
-
constructor(logger = null) {
|
|
20
|
-
this.platformService = new PlatformInstructionService();
|
|
21
|
-
this.packageManagerService = new PackageManagerService();
|
|
22
|
-
this.recoveryService = new RecoveryInstructionService();
|
|
23
|
-
this.logger = logger || new LoggerService();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Create download links for common tools
|
|
28
|
-
* @returns {Object} Download links by tool and platform
|
|
29
|
-
* @private
|
|
30
|
-
*/
|
|
31
|
-
_createDownloadLinks() {
|
|
32
|
-
return {
|
|
33
|
-
git: {
|
|
34
|
-
linux: 'https://git-scm.com/download/linux',
|
|
35
|
-
darwin: 'https://git-scm.com/download/mac',
|
|
36
|
-
win32: 'https://git-scm.com/download/win'
|
|
37
|
-
},
|
|
38
|
-
node: {
|
|
39
|
-
all: 'https://nodejs.org/en/download/'
|
|
40
|
-
},
|
|
41
|
-
python: {
|
|
42
|
-
all: 'https://www.python.org/downloads/'
|
|
43
|
-
},
|
|
44
|
-
docker: {
|
|
45
|
-
linux: 'https://docs.docker.com/engine/install/',
|
|
46
|
-
darwin: 'https://docs.docker.com/desktop/install/mac-install/',
|
|
47
|
-
win32: 'https://docs.docker.com/desktop/install/windows-install/'
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Generate installation instructions for missing dependency
|
|
54
|
-
* @param {Object} dependency - Missing dependency
|
|
55
|
-
* @param {string} platform - Target platform (optional)
|
|
56
|
-
* @returns {Object} Installation instructions
|
|
57
|
-
*/
|
|
58
|
-
generateInstallationInstructions(dependency, platform = process.platform) {
|
|
59
|
-
this.logger.debug('Generating installation instructions', {
|
|
60
|
-
dependency: dependency.name,
|
|
61
|
-
platform
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
// Get platform-specific instructions
|
|
66
|
-
const platformInstructions = this.platformService.generatePlatformInstructions(platform, dependency);
|
|
67
|
-
|
|
68
|
-
// Get package manager instructions
|
|
69
|
-
const packageManagerInstructions = this.packageManagerService.generateInstallationInstructions(
|
|
70
|
-
dependency.packageName || dependency.name,
|
|
71
|
-
{
|
|
72
|
-
global: dependency.global,
|
|
73
|
-
version: dependency.version
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
// Combine instructions
|
|
78
|
-
const instructions = {
|
|
79
|
-
dependency: dependency.name,
|
|
80
|
-
platform,
|
|
81
|
-
packageManagers: packageManagerInstructions,
|
|
82
|
-
downloadLinks: platformInstructions.downloadLinks,
|
|
83
|
-
notes: platformInstructions.notes,
|
|
84
|
-
troubleshooting: platformInstructions.troubleshooting
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
this.logger.debug('Generated installation instructions', {
|
|
88
|
-
managersCount: packageManagerInstructions.length,
|
|
89
|
-
notesCount: instructions.notes.length
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
return instructions;
|
|
93
|
-
} catch (error) {
|
|
94
|
-
this.logger.error('Failed to generate installation instructions', error, {
|
|
95
|
-
dependency: dependency.name,
|
|
96
|
-
platform
|
|
97
|
-
});
|
|
98
|
-
throw error;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Generate recovery suggestions for failed dependencies
|
|
104
|
-
* @param {Object} failedDependency - Dependency that failed validation
|
|
105
|
-
* @returns {Object} Recovery suggestions
|
|
106
|
-
*/
|
|
107
|
-
generateRecoverySuggestions(failedDependency) {
|
|
108
|
-
this.logger.debug('Generating recovery suggestions', {
|
|
109
|
-
dependency: failedDependency.name,
|
|
110
|
-
errorCode: failedDependency.error?.code
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
try {
|
|
114
|
-
const suggestions = this.recoveryService.generateRecoverySuggestions(failedDependency);
|
|
115
|
-
|
|
116
|
-
this.logger.debug('Generated recovery suggestions', {
|
|
117
|
-
immediate: suggestions.immediate.length,
|
|
118
|
-
alternative: suggestions.alternative.length,
|
|
119
|
-
troubleshooting: suggestions.troubleshooting.length
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
return suggestions;
|
|
123
|
-
} catch (error) {
|
|
124
|
-
this.logger.error('Failed to generate recovery suggestions', error, {
|
|
125
|
-
dependency: failedDependency.name
|
|
126
|
-
});
|
|
127
|
-
throw error;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Generate installation instructions for multiple dependencies
|
|
133
|
-
* @param {Array} dependencies - List of dependencies to install
|
|
134
|
-
* @param {string} platform - Target platform
|
|
135
|
-
* @returns {Object} Batch installation instructions
|
|
136
|
-
*/
|
|
137
|
-
generateBatchInstallationInstructions(dependencies, platform = process.platform) {
|
|
138
|
-
this.logger.info('Generating batch installation instructions', {
|
|
139
|
-
count: dependencies.length,
|
|
140
|
-
platform
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
const batchInstructions = {
|
|
145
|
-
platform,
|
|
146
|
-
dependencies: dependencies.map(dep => dep.name),
|
|
147
|
-
individualInstructions: [],
|
|
148
|
-
bulkRecovery: null
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
// Generate individual instructions
|
|
152
|
-
for (const dependency of dependencies) {
|
|
153
|
-
const instructions = this.generateInstallationInstructions(dependency, platform);
|
|
154
|
-
batchInstructions.individualInstructions.push({
|
|
155
|
-
dependency: dependency.name,
|
|
156
|
-
instructions
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
this.logger.debug('Generated batch instructions', {
|
|
161
|
-
processedCount: batchInstructions.individualInstructions.length
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
return batchInstructions;
|
|
165
|
-
} catch (error) {
|
|
166
|
-
this.logger.error('Failed to generate batch installation instructions', error, {
|
|
167
|
-
dependencyCount: dependencies.length,
|
|
168
|
-
platform
|
|
169
|
-
});
|
|
170
|
-
throw error;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Generate upgrade instructions for outdated dependencies
|
|
176
|
-
* @param {Object} dependency - Dependency to upgrade
|
|
177
|
-
* @param {string} currentVersion - Current version
|
|
178
|
-
* @param {string} targetVersion - Target version
|
|
179
|
-
* @param {string} platform - Target platform
|
|
180
|
-
* @returns {Object} Upgrade instructions
|
|
181
|
-
*/
|
|
182
|
-
generateUpgradeInstructions(dependency, currentVersion, targetVersion, platform = process.platform) {
|
|
183
|
-
const upgradeInstructions = {
|
|
184
|
-
dependency: dependency.name,
|
|
185
|
-
currentVersion: currentVersion,
|
|
186
|
-
targetVersion: targetVersion,
|
|
187
|
-
platform: platform,
|
|
188
|
-
upgradeSteps: [],
|
|
189
|
-
verificationSteps: [],
|
|
190
|
-
backupRecommendations: [],
|
|
191
|
-
troubleshootingTips: []
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
// Add backup recommendations
|
|
195
|
-
upgradeInstructions.backupRecommendations = [
|
|
196
|
-
`Backup current ${dependency.name} configuration if applicable`,
|
|
197
|
-
'Document current working setup before upgrading',
|
|
198
|
-
'Ensure you can rollback if needed'
|
|
199
|
-
];
|
|
200
|
-
|
|
201
|
-
// Generate upgrade commands
|
|
202
|
-
const packageManagers = this.packageManagerService.getAvailablePackageManagers(platform);
|
|
203
|
-
for (const pm of packageManagers) {
|
|
204
|
-
const upgradeCommand = this._generateUpgradeCommand(pm, dependency.name, platform);
|
|
205
|
-
if (upgradeCommand) {
|
|
206
|
-
upgradeInstructions.upgradeSteps.push({
|
|
207
|
-
packageManager: pm.name,
|
|
208
|
-
command: upgradeCommand,
|
|
209
|
-
description: `Upgrade ${dependency.name} using ${pm.name}`
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Add verification steps
|
|
215
|
-
upgradeInstructions.verificationSteps = [
|
|
216
|
-
`Run: ${dependency.name} --version`,
|
|
217
|
-
`Verify version shows ${targetVersion} or higher`,
|
|
218
|
-
'Test basic functionality to ensure upgrade was successful'
|
|
219
|
-
];
|
|
220
|
-
|
|
221
|
-
// Add troubleshooting tips
|
|
222
|
-
upgradeInstructions.troubleshootingTips = [
|
|
223
|
-
'Clear package manager cache if upgrade fails',
|
|
224
|
-
'Check for dependency conflicts',
|
|
225
|
-
'Restart terminal/shell after upgrade',
|
|
226
|
-
'Verify PATH environment variable is correct'
|
|
227
|
-
];
|
|
228
|
-
|
|
229
|
-
return upgradeInstructions;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Generate platform-specific installation guidance
|
|
234
|
-
* @param {string} platform - Target platform
|
|
235
|
-
* @returns {Object} Platform-specific guidance
|
|
236
|
-
*/
|
|
237
|
-
generatePlatformGuidance(platform) {
|
|
238
|
-
const guidance = {
|
|
239
|
-
platform: platform,
|
|
240
|
-
platformName: this.platformUtils.getPlatformName(platform),
|
|
241
|
-
packageManagers: [],
|
|
242
|
-
commonIssues: [],
|
|
243
|
-
bestPractices: [],
|
|
244
|
-
systemRequirements: {}
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
// Get package managers for platform
|
|
248
|
-
guidance.packageManagers = this.packageManagerService.getPackageManagersForPlatform(platform)
|
|
249
|
-
.map(pm => ({
|
|
250
|
-
name: pm.name,
|
|
251
|
-
description: this._getPackageManagerDescription(pm.name),
|
|
252
|
-
installationUrl: this._getPackageManagerInstallUrl(pm.name, platform)
|
|
253
|
-
}));
|
|
254
|
-
|
|
255
|
-
// Platform-specific guidance
|
|
256
|
-
switch (platform) {
|
|
257
|
-
case 'win32':
|
|
258
|
-
guidance.commonIssues = [
|
|
259
|
-
'PATH environment variable not updated',
|
|
260
|
-
'PowerShell execution policy restrictions',
|
|
261
|
-
'Windows Defender blocking downloads',
|
|
262
|
-
'Missing Visual C++ redistributables'
|
|
263
|
-
];
|
|
264
|
-
guidance.bestPractices = [
|
|
265
|
-
'Run commands as Administrator when necessary',
|
|
266
|
-
'Use PowerShell instead of Command Prompt',
|
|
267
|
-
'Install package manager first (Chocolatey, Winget)',
|
|
268
|
-
'Check Windows version compatibility'
|
|
269
|
-
];
|
|
270
|
-
break;
|
|
271
|
-
|
|
272
|
-
case 'darwin':
|
|
273
|
-
guidance.commonIssues = [
|
|
274
|
-
'Xcode Command Line Tools missing',
|
|
275
|
-
'System Integrity Protection (SIP) restrictions',
|
|
276
|
-
'Homebrew not installed or outdated',
|
|
277
|
-
'Architecture mismatch (Intel vs Apple Silicon)'
|
|
278
|
-
];
|
|
279
|
-
guidance.bestPractices = [
|
|
280
|
-
'Install Xcode Command Line Tools first',
|
|
281
|
-
'Use Homebrew for package management',
|
|
282
|
-
'Check architecture compatibility (x86_64 vs arm64)',
|
|
283
|
-
'Update shell profile (.zshrc) for PATH changes'
|
|
284
|
-
];
|
|
285
|
-
break;
|
|
286
|
-
|
|
287
|
-
case 'linux':
|
|
288
|
-
guidance.commonIssues = [
|
|
289
|
-
'Missing package repositories',
|
|
290
|
-
'Insufficient permissions',
|
|
291
|
-
'Outdated package lists',
|
|
292
|
-
'Missing dependencies'
|
|
293
|
-
];
|
|
294
|
-
guidance.bestPractices = [
|
|
295
|
-
'Update package lists before installing',
|
|
296
|
-
'Use distribution-specific package manager',
|
|
297
|
-
'Install development tools if compiling from source',
|
|
298
|
-
'Check distribution version compatibility'
|
|
299
|
-
];
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return guidance;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Create instruction generation context
|
|
308
|
-
* @param {Object} dependency - Dependency information
|
|
309
|
-
* @param {string} platform - Target platform
|
|
310
|
-
* @returns {Object} Instruction context
|
|
311
|
-
* @private
|
|
312
|
-
*/
|
|
313
|
-
_createInstructionContext(dependency, platform) {
|
|
314
|
-
return {
|
|
315
|
-
dependency,
|
|
316
|
-
platform,
|
|
317
|
-
platformManagers: this.packageManagerService.getPackageManagersForPlatform(platform),
|
|
318
|
-
dependencyMapping: this.packageManagerService.config.dependencyMappings[dependency.name]
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Initialize empty instructions object
|
|
324
|
-
* @param {string} platform - Target platform
|
|
325
|
-
* @returns {Object} Empty instructions object
|
|
326
|
-
* @private
|
|
327
|
-
*/
|
|
328
|
-
_initializeInstructions(platform) {
|
|
329
|
-
return {
|
|
330
|
-
platform: platform,
|
|
331
|
-
packageManager: null,
|
|
332
|
-
commands: [],
|
|
333
|
-
packageManagerOptions: [],
|
|
334
|
-
globalInstall: null,
|
|
335
|
-
localInstall: null,
|
|
336
|
-
alternativeOptions: []
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Add platform-specific package managers to instructions
|
|
342
|
-
* @param {Object} instructions - Instructions object to modify
|
|
343
|
-
* @param {Object} context - Instruction context
|
|
344
|
-
* @private
|
|
345
|
-
*/
|
|
346
|
-
_addPlatformPackageManagers(instructions, context) {
|
|
347
|
-
for (const pm of context.platformManagers) {
|
|
348
|
-
const packageName = this._resolvePackageName(pm, context);
|
|
349
|
-
const packageManagerOption = this._createPackageManagerOption(pm, packageName);
|
|
350
|
-
instructions.packageManagerOptions.push(packageManagerOption);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Resolve package name for specific package manager
|
|
356
|
-
* @param {Object} pm - Package manager configuration
|
|
357
|
-
* @param {Object} context - Instruction context
|
|
358
|
-
* @returns {string} Resolved package name
|
|
359
|
-
* @private
|
|
360
|
-
*/
|
|
361
|
-
_resolvePackageName(pm, context) {
|
|
362
|
-
const { dependency, platform, dependencyMapping } = context;
|
|
363
|
-
|
|
364
|
-
if (dependencyMapping && dependencyMapping[platform] && dependencyMapping[platform][pm.name]) {
|
|
365
|
-
return dependencyMapping[platform][pm.name];
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
return dependency.name;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Create package manager option object
|
|
373
|
-
* @param {Object} pm - Package manager configuration
|
|
374
|
-
* @param {string} packageName - Resolved package name
|
|
375
|
-
* @returns {Object} Package manager option
|
|
376
|
-
* @private
|
|
377
|
-
*/
|
|
378
|
-
_createPackageManagerOption(pm, packageName) {
|
|
379
|
-
return {
|
|
380
|
-
name: pm.name,
|
|
381
|
-
command: pm.install.replace('{package}', packageName),
|
|
382
|
-
check: pm.check.replace('{package}', packageName),
|
|
383
|
-
packageName: packageName
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Set default package manager from available options
|
|
389
|
-
* @param {Object} instructions - Instructions object to modify
|
|
390
|
-
* @private
|
|
391
|
-
*/
|
|
392
|
-
_setDefaultPackageManager(instructions) {
|
|
393
|
-
if (instructions.packageManagerOptions.length > 0) {
|
|
394
|
-
const defaultPM = instructions.packageManagerOptions[0];
|
|
395
|
-
instructions.packageManager = defaultPM.name;
|
|
396
|
-
instructions.commands.push(defaultPM.command);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Handle npm package-specific instructions
|
|
402
|
-
* @param {Object} instructions - Instructions object to modify
|
|
403
|
-
* @param {Object} context - Instruction context
|
|
404
|
-
* @private
|
|
405
|
-
*/
|
|
406
|
-
_handleNpmPackageSpecific(instructions, context) {
|
|
407
|
-
if (context.dependency.type !== 'npm_package') return;
|
|
408
|
-
|
|
409
|
-
this._addNpmInstallOptions(instructions, context.dependency.name);
|
|
410
|
-
this._ensureNpmInOptions(instructions, context.dependency.name);
|
|
411
|
-
this._addNpmAlternatives(instructions, context.dependency.name);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Add npm install options (global/local)
|
|
416
|
-
* @param {Object} instructions - Instructions object to modify
|
|
417
|
-
* @param {string} packageName - Package name
|
|
418
|
-
* @private
|
|
419
|
-
*/
|
|
420
|
-
_addNpmInstallOptions(instructions, packageName) {
|
|
421
|
-
instructions.globalInstall = `npm install -g ${packageName}`;
|
|
422
|
-
instructions.localInstall = `npm install ${packageName}`;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Ensure npm is in package manager options
|
|
427
|
-
* @param {Object} instructions - Instructions object to modify
|
|
428
|
-
* @param {string} packageName - Package name
|
|
429
|
-
* @private
|
|
430
|
-
*/
|
|
431
|
-
_ensureNpmInOptions(instructions, packageName) {
|
|
432
|
-
const hasNpm = instructions.packageManagerOptions.some(pm => pm.name === 'npm');
|
|
433
|
-
if (!hasNpm) {
|
|
434
|
-
instructions.packageManagerOptions.unshift({
|
|
435
|
-
name: 'npm',
|
|
436
|
-
command: `npm install -g ${packageName}`
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* Add npm alternatives (yarn, pnpm)
|
|
443
|
-
* @param {Object} instructions - Instructions object to modify
|
|
444
|
-
* @param {string} packageName - Package name
|
|
445
|
-
* @private
|
|
446
|
-
*/
|
|
447
|
-
_addNpmAlternatives(instructions, packageName) {
|
|
448
|
-
instructions.packageManagerOptions.push(
|
|
449
|
-
{ name: 'yarn', command: `yarn global add ${packageName}` },
|
|
450
|
-
{ name: 'pnpm', command: `pnpm add -g ${packageName}` }
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Add alternative installation methods (private)
|
|
456
|
-
* @param {Object} instructions - Instructions to enhance
|
|
457
|
-
* @param {Object} dependency - Dependency information
|
|
458
|
-
* @param {string} platform - Target platform
|
|
459
|
-
* @private
|
|
460
|
-
*/
|
|
461
|
-
_addAlternativeInstallationMethods(instructions, dependency, platform) {
|
|
462
|
-
this._addDownloadLinks(instructions, dependency, platform);
|
|
463
|
-
this._addDockerAlternative(instructions, dependency);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* Add download links for dependencies (private)
|
|
468
|
-
* @param {Object} instructions - Instructions to enhance
|
|
469
|
-
* @param {Object} dependency - Dependency information
|
|
470
|
-
* @param {string} platform - Target platform
|
|
471
|
-
* @private
|
|
472
|
-
*/
|
|
473
|
-
_addDownloadLinks(instructions, dependency, platform) {
|
|
474
|
-
const links = this.config.downloadLinks[dependency.name];
|
|
475
|
-
if (!links) return;
|
|
476
|
-
|
|
477
|
-
if (links.all) {
|
|
478
|
-
instructions.alternativeOptions.push(`Download from: ${links.all}`);
|
|
479
|
-
} else if (links[platform]) {
|
|
480
|
-
instructions.alternativeOptions.push(`Download from: ${links[platform]}`);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Add Docker alternative for tools (private)
|
|
486
|
-
* @param {Object} instructions - Instructions to enhance
|
|
487
|
-
* @param {Object} dependency - Dependency information
|
|
488
|
-
* @private
|
|
489
|
-
*/
|
|
490
|
-
_addDockerAlternative(instructions, dependency) {
|
|
491
|
-
if (dependency.type === 'tool') {
|
|
492
|
-
instructions.alternativeOptions.push(`Use Docker container with ${dependency.name} pre-installed`);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Generate bulk install command for multiple packages
|
|
498
|
-
* @param {Object} packageManager - Package manager configuration
|
|
499
|
-
* @param {Array<string>} packages - List of packages
|
|
500
|
-
* @returns {string} Bulk install command
|
|
501
|
-
* @private
|
|
502
|
-
*/
|
|
503
|
-
_generateBulkInstallCommand(packageManager, packages) {
|
|
504
|
-
const packageList = packages.join(' ');
|
|
505
|
-
return packageManager.install.replace('{package}', packageList);
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* Generate upgrade command for a specific package
|
|
510
|
-
* @param {Object} packageManager - Package manager configuration
|
|
511
|
-
* @param {string} packageName - Package to upgrade
|
|
512
|
-
* @param {string} platform - Target platform
|
|
513
|
-
* @returns {string} Upgrade command
|
|
514
|
-
* @private
|
|
515
|
-
*/
|
|
516
|
-
_generateUpgradeCommand(packageManager, packageName, platform) {
|
|
517
|
-
const resolvedName = this.packageManagerService.getPackageName(packageName, packageManager.name, platform);
|
|
518
|
-
|
|
519
|
-
// Map package manager to upgrade commands
|
|
520
|
-
const upgradeCommands = {
|
|
521
|
-
'apt': `sudo apt-get update && sudo apt-get upgrade ${resolvedName}`,
|
|
522
|
-
'yum': `sudo yum update ${resolvedName}`,
|
|
523
|
-
'dnf': `sudo dnf update ${resolvedName}`,
|
|
524
|
-
'pacman': `sudo pacman -S ${resolvedName}`,
|
|
525
|
-
'brew': `brew upgrade ${resolvedName}`,
|
|
526
|
-
'chocolatey': `choco upgrade ${resolvedName}`,
|
|
527
|
-
'winget': `winget upgrade ${resolvedName}`,
|
|
528
|
-
'npm': `npm update -g ${resolvedName}`,
|
|
529
|
-
'yarn': `yarn global upgrade ${resolvedName}`,
|
|
530
|
-
'pnpm': `pnpm update -g ${resolvedName}`
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
return upgradeCommands[packageManager.name] || null;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
/**
|
|
538
|
-
* Get package manager description
|
|
539
|
-
* @param {string} packageManagerName - Package manager name
|
|
540
|
-
* @returns {string} Description
|
|
541
|
-
* @private
|
|
542
|
-
*/
|
|
543
|
-
_getPackageManagerDescription(packageManagerName) {
|
|
544
|
-
const descriptions = {
|
|
545
|
-
'apt': 'Advanced Package Tool - Debian/Ubuntu package manager',
|
|
546
|
-
'yum': 'Yellowdog Updater Modified - Red Hat package manager',
|
|
547
|
-
'dnf': 'Dandified YUM - Modern Red Hat package manager',
|
|
548
|
-
'pacman': 'Package Manager - Arch Linux package manager',
|
|
549
|
-
'brew': 'Homebrew - macOS package manager',
|
|
550
|
-
'chocolatey': 'Chocolatey - Windows package manager',
|
|
551
|
-
'winget': 'Windows Package Manager - Microsoft package manager',
|
|
552
|
-
'npm': 'Node Package Manager - JavaScript package manager',
|
|
553
|
-
'yarn': 'Yarn - Fast JavaScript package manager',
|
|
554
|
-
'pnpm': 'pnpm - Efficient JavaScript package manager'
|
|
555
|
-
};
|
|
556
|
-
return descriptions[packageManagerName] || `${packageManagerName} package manager`;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Get package manager installation URL
|
|
561
|
-
* @param {string} packageManagerName - Package manager name
|
|
562
|
-
* @param {string} platform - Target platform
|
|
563
|
-
* @returns {string} Installation URL
|
|
564
|
-
* @private
|
|
565
|
-
*/
|
|
566
|
-
_getPackageManagerInstallUrl(packageManagerName, platform) {
|
|
567
|
-
const installUrls = {
|
|
568
|
-
'brew': 'https://brew.sh/',
|
|
569
|
-
'chocolatey': 'https://chocolatey.org/install',
|
|
570
|
-
'winget': 'https://docs.microsoft.com/en-us/windows/package-manager/winget/',
|
|
571
|
-
'npm': 'https://nodejs.org/en/download/',
|
|
572
|
-
'yarn': 'https://yarnpkg.com/getting-started/install',
|
|
573
|
-
'pnpm': 'https://pnpm.io/installation'
|
|
574
|
-
};
|
|
575
|
-
return installUrls[packageManagerName] || null;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
module.exports = InstallationInstructionGenerator;
|