auto-dev-setup 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +191 -0
- package/bin/auto-setup.js +13 -0
- package/package.json +58 -0
- package/src/cli.js +295 -0
- package/src/config/extensions.js +51 -0
- package/src/index.js +16 -0
- package/src/platform/detector.js +240 -0
- package/src/platform/index.js +36 -0
- package/src/platform/linux.js +412 -0
- package/src/platform/macos.js +348 -0
- package/src/platform/windows.js +334 -0
- package/src/stacks/base.js +47 -0
- package/src/stacks/index.js +16 -0
- package/src/stacks/java.js +232 -0
- package/src/stacks/python.js +433 -0
- package/src/stacks/web.js +208 -0
- package/src/utils/executor.js +227 -0
- package/src/utils/index.js +18 -0
- package/src/utils/logger.js +235 -0
- package/src/utils/postinstall.js +295 -0
- package/src/utils/prompts.js +168 -0
- package/src/utils/verifier.js +204 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Stack Installer
|
|
3
|
+
* Handles base system tools installation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { getPlatformModule } = require('../platform');
|
|
7
|
+
const logger = require('../utils/logger');
|
|
8
|
+
const { verifyBaseTools, displayVerification } = require('../utils/verifier');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Install base system tools
|
|
12
|
+
* @returns {Object} Installation results
|
|
13
|
+
*/
|
|
14
|
+
async function install() {
|
|
15
|
+
logger.section('Step 2: Base System Setup');
|
|
16
|
+
|
|
17
|
+
const platform = getPlatformModule();
|
|
18
|
+
const results = await platform.setupBase();
|
|
19
|
+
|
|
20
|
+
// Handle pending installations (like Xcode CLI tools)
|
|
21
|
+
if (results.pending) {
|
|
22
|
+
logger.warn('Some installations require user action before continuing.');
|
|
23
|
+
logger.info('Please complete the pending installations and run this tool again.');
|
|
24
|
+
return results;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Verify installations
|
|
28
|
+
logger.newline();
|
|
29
|
+
const verification = verifyBaseTools();
|
|
30
|
+
displayVerification(verification);
|
|
31
|
+
|
|
32
|
+
return results;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Check if base tools are already installed
|
|
37
|
+
* @returns {boolean}
|
|
38
|
+
*/
|
|
39
|
+
function isInstalled() {
|
|
40
|
+
const verification = verifyBaseTools();
|
|
41
|
+
return verification.every((tool) => tool.installed);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
install,
|
|
46
|
+
isInstalled
|
|
47
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stacks Index
|
|
3
|
+
* Central export for all stack installers
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const base = require('./base');
|
|
7
|
+
const web = require('./web');
|
|
8
|
+
const python = require('./python');
|
|
9
|
+
const java = require('./java');
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
base,
|
|
13
|
+
web,
|
|
14
|
+
python,
|
|
15
|
+
java
|
|
16
|
+
};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java Stack Installer
|
|
3
|
+
* Installs OpenJDK and configures JAVA_HOME
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { getPlatformModule } = require('../platform');
|
|
7
|
+
const { execCommand, commandExists, getVersion } = require('../utils/executor');
|
|
8
|
+
const logger = require('../utils/logger');
|
|
9
|
+
const { verifyJavaStack, displayVerification } = require('../utils/verifier');
|
|
10
|
+
const { VSCODE_EXTENSIONS } = require('../config/extensions');
|
|
11
|
+
const { installVSCodeExtensions } = require('./web');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if JAVA_HOME is already configured
|
|
15
|
+
* @returns {boolean} True if JAVA_HOME is set
|
|
16
|
+
*/
|
|
17
|
+
function isJavaHomeConfigured() {
|
|
18
|
+
const platform = process.platform;
|
|
19
|
+
|
|
20
|
+
if (platform === 'win32') {
|
|
21
|
+
// Check user environment variable
|
|
22
|
+
const result = execCommand(
|
|
23
|
+
'powershell -Command "[Environment]::GetEnvironmentVariable(\'JAVA_HOME\', \'User\')"',
|
|
24
|
+
{ silent: true, showCommand: false }
|
|
25
|
+
);
|
|
26
|
+
return result.success && result.output && result.output.trim().length > 0;
|
|
27
|
+
} else {
|
|
28
|
+
// Check if JAVA_HOME is set in current environment
|
|
29
|
+
return !!process.env.JAVA_HOME;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Configure JAVA_HOME environment variable
|
|
35
|
+
* @returns {Object} Configuration result
|
|
36
|
+
*/
|
|
37
|
+
async function configureJavaHome() {
|
|
38
|
+
const platform = process.platform;
|
|
39
|
+
|
|
40
|
+
// Check if already configured
|
|
41
|
+
if (isJavaHomeConfigured()) {
|
|
42
|
+
const currentJavaHome = process.env.JAVA_HOME || 'configured in user environment';
|
|
43
|
+
logger.success(`JAVA_HOME already configured: ${currentJavaHome}`);
|
|
44
|
+
return { success: true, skipped: true };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
logger.step('Configuring JAVA_HOME...');
|
|
48
|
+
|
|
49
|
+
if (platform === 'win32') {
|
|
50
|
+
// Windows: Find Java installation path
|
|
51
|
+
const javaPath = execCommand('where java', {
|
|
52
|
+
silent: true,
|
|
53
|
+
showCommand: false
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if (javaPath.success && javaPath.output) {
|
|
57
|
+
const javaExe = javaPath.output.split('\n')[0].trim();
|
|
58
|
+
const javaHome = javaExe.replace(/\\bin\\java\.exe$/i, '');
|
|
59
|
+
|
|
60
|
+
// Set JAVA_HOME for user
|
|
61
|
+
execCommand(`setx JAVA_HOME "${javaHome}"`, {
|
|
62
|
+
silent: true,
|
|
63
|
+
showCommand: false
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
logger.success(`JAVA_HOME set to: ${javaHome}`);
|
|
67
|
+
return { success: true, javaHome };
|
|
68
|
+
}
|
|
69
|
+
} else if (platform === 'darwin') {
|
|
70
|
+
// macOS: Use java_home utility
|
|
71
|
+
const javaHome = execCommand('/usr/libexec/java_home 2>/dev/null', {
|
|
72
|
+
silent: true,
|
|
73
|
+
showCommand: false
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (javaHome.success && javaHome.output) {
|
|
77
|
+
const shellConfig = process.env.SHELL?.includes('zsh')
|
|
78
|
+
? '~/.zshrc'
|
|
79
|
+
: '~/.bash_profile';
|
|
80
|
+
|
|
81
|
+
// Check if already configured
|
|
82
|
+
const alreadySet = execCommand(
|
|
83
|
+
`grep -q 'JAVA_HOME' ${shellConfig} 2>/dev/null`,
|
|
84
|
+
{ silent: true, showCommand: false }
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
if (!alreadySet.success) {
|
|
88
|
+
execCommand(
|
|
89
|
+
`echo 'export JAVA_HOME="$(/usr/libexec/java_home)"' >> ${shellConfig}`,
|
|
90
|
+
{ silent: true, showCommand: false }
|
|
91
|
+
);
|
|
92
|
+
execCommand(
|
|
93
|
+
`echo 'export PATH="$JAVA_HOME/bin:$PATH"' >> ${shellConfig}`,
|
|
94
|
+
{ silent: true, showCommand: false }
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
logger.success(`JAVA_HOME set to: ${javaHome.output}`);
|
|
99
|
+
return { success: true, javaHome: javaHome.output };
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
// Linux: Find Java installation
|
|
103
|
+
const javaPath = execCommand('readlink -f $(which java) 2>/dev/null', {
|
|
104
|
+
silent: true,
|
|
105
|
+
showCommand: false
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (javaPath.success && javaPath.output) {
|
|
109
|
+
// Remove /bin/java from the path
|
|
110
|
+
const javaHome = javaPath.output.replace(/\/bin\/java$/, '');
|
|
111
|
+
|
|
112
|
+
const shellConfig = process.env.SHELL?.includes('zsh')
|
|
113
|
+
? '~/.zshrc'
|
|
114
|
+
: '~/.bashrc';
|
|
115
|
+
|
|
116
|
+
// Check if already configured
|
|
117
|
+
const alreadySet = execCommand(
|
|
118
|
+
`grep -q 'JAVA_HOME' ${shellConfig} 2>/dev/null`,
|
|
119
|
+
{ silent: true, showCommand: false }
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
if (!alreadySet.success) {
|
|
123
|
+
execCommand(
|
|
124
|
+
`echo 'export JAVA_HOME="${javaHome}"' >> ${shellConfig}`,
|
|
125
|
+
{ silent: true, showCommand: false }
|
|
126
|
+
);
|
|
127
|
+
execCommand(
|
|
128
|
+
`echo 'export PATH="$JAVA_HOME/bin:$PATH"' >> ${shellConfig}`,
|
|
129
|
+
{ silent: true, showCommand: false }
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
logger.success(`JAVA_HOME set to: ${javaHome}`);
|
|
134
|
+
return { success: true, javaHome };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
logger.warn('Could not automatically configure JAVA_HOME');
|
|
139
|
+
return { success: false };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Install the Java development stack
|
|
144
|
+
* @returns {Object} Installation results
|
|
145
|
+
*/
|
|
146
|
+
async function install() {
|
|
147
|
+
logger.section('Step 5: Java Development Environment');
|
|
148
|
+
|
|
149
|
+
const platformModule = getPlatformModule();
|
|
150
|
+
const results = {
|
|
151
|
+
installed: [],
|
|
152
|
+
skipped: [],
|
|
153
|
+
failed: []
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// Install OpenJDK
|
|
157
|
+
const javaResult = await platformModule.installJava();
|
|
158
|
+
if (javaResult.success) {
|
|
159
|
+
(javaResult.skipped ? results.skipped : results.installed).push('OpenJDK');
|
|
160
|
+
} else {
|
|
161
|
+
results.failed.push('OpenJDK');
|
|
162
|
+
return results;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Configure JAVA_HOME
|
|
166
|
+
const configResult = await configureJavaHome();
|
|
167
|
+
if (configResult.success) {
|
|
168
|
+
if (configResult.skipped) {
|
|
169
|
+
results.skipped.push('JAVA_HOME configuration');
|
|
170
|
+
} else {
|
|
171
|
+
results.installed.push('JAVA_HOME configuration');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Install Java VS Code extensions
|
|
176
|
+
if (commandExists('code')) {
|
|
177
|
+
const extResults = await installVSCodeExtensions(VSCODE_EXTENSIONS.java);
|
|
178
|
+
results.installed.push(...extResults.installed.map((e) => `VS Code: ${e}`));
|
|
179
|
+
results.skipped.push(...extResults.skipped.map((e) => `VS Code: ${e}`));
|
|
180
|
+
results.failed.push(...extResults.failed.map((e) => `VS Code: ${e}`));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Verify installation
|
|
184
|
+
logger.newline();
|
|
185
|
+
logger.subsection('Java Stack Verification:');
|
|
186
|
+
|
|
187
|
+
const verifyJava = execCommand('java --version', {
|
|
188
|
+
silent: true,
|
|
189
|
+
showCommand: true
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
if (verifyJava.success) {
|
|
193
|
+
const versionLine = verifyJava.output.split('\n')[0];
|
|
194
|
+
logger.success(`Java: ${versionLine}`);
|
|
195
|
+
} else {
|
|
196
|
+
// Try alternative version flag
|
|
197
|
+
const verifyJavaAlt = execCommand('java -version 2>&1', {
|
|
198
|
+
silent: true,
|
|
199
|
+
showCommand: false
|
|
200
|
+
});
|
|
201
|
+
if (verifyJavaAlt.success) {
|
|
202
|
+
const versionLine = verifyJavaAlt.output.split('\n')[0];
|
|
203
|
+
logger.success(`Java: ${versionLine}`);
|
|
204
|
+
} else {
|
|
205
|
+
logger.error('Java: not found');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Check JAVA_HOME
|
|
210
|
+
const javaHome = process.env.JAVA_HOME;
|
|
211
|
+
if (javaHome) {
|
|
212
|
+
logger.success(`JAVA_HOME: ${javaHome}`);
|
|
213
|
+
} else {
|
|
214
|
+
logger.warn('JAVA_HOME: not set (will be available after terminal restart)');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return results;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Check if Java is already installed
|
|
222
|
+
* @returns {boolean}
|
|
223
|
+
*/
|
|
224
|
+
function isInstalled() {
|
|
225
|
+
return commandExists('java');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
module.exports = {
|
|
229
|
+
install,
|
|
230
|
+
isInstalled,
|
|
231
|
+
configureJavaHome
|
|
232
|
+
};
|