@bobschlowinskii/clicraft 0.4.5 ā 0.4.6
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/CHANGELOG.md +8 -0
- package/commands/launch.js +24 -4
- package/docs/commands/launch.md +3 -2
- package/docs/installation.md +1 -1
- package/helpers/config.js +1 -0
- package/helpers/server.js +32 -0
- package/helpers/versions.js +3 -12
- package/index.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.4.6] - 2026-02-06
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Added `--last` option to `launch` command**
|
|
9
|
+
- Launches the last ran instance
|
|
10
|
+
- call with `--last` or `-l`
|
|
11
|
+
- **Allow user to launch server with `launch` command**
|
|
12
|
+
|
|
5
13
|
## [0.4.5] - 2026-01-31
|
|
6
14
|
|
|
7
15
|
### Added
|
package/commands/launch.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import { spawn } from 'child_process';
|
|
5
5
|
import { refreshAuth } from './auth.js';
|
|
6
6
|
import { captureGameSettings } from '../commands/config.js';
|
|
7
|
-
import { loadSettings, writeGameSettings, getAliasByName } from '../helpers/config.js';
|
|
7
|
+
import { loadSettings, writeGameSettings, getAliasByName, saveSettings } from '../helpers/config.js';
|
|
8
8
|
import {
|
|
9
9
|
loadConfig,
|
|
10
10
|
getInstancePath,
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
mavenToPath
|
|
13
13
|
} from '../helpers/utils.js';
|
|
14
14
|
import { callPostCommandActions } from '../helpers/post-command.js';
|
|
15
|
+
import { startServer } from '../helpers/server.js';
|
|
15
16
|
|
|
16
17
|
// Find Java executable
|
|
17
18
|
function findJava() {
|
|
@@ -126,7 +127,7 @@ export async function launchInstance(aliasOrOptions, options) {
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
const settings = loadSettings();
|
|
129
|
-
|
|
130
|
+
|
|
130
131
|
// Resolve instance path from alias, --instance flag, or current directory
|
|
131
132
|
let instancePath;
|
|
132
133
|
if (alias) {
|
|
@@ -145,7 +146,23 @@ export async function launchInstance(aliasOrOptions, options) {
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
} else {
|
|
148
|
-
|
|
149
|
+
if (opts.last) {
|
|
150
|
+
if (!settings.lastInstance) {
|
|
151
|
+
console.log(chalk.red('Error: No last instance found in settings.'));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (!fs.existsSync(settings.lastInstance)) {
|
|
156
|
+
console.log(chalk.red('Error: Last instance path does not exist.'));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
instancePath = settings.lastInstance;
|
|
161
|
+
console.log(chalk.gray(`Using last instance ā ${instancePath}`));
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
instancePath = getInstancePath(opts);
|
|
165
|
+
}
|
|
149
166
|
}
|
|
150
167
|
|
|
151
168
|
// Apply saved game settings if enabled
|
|
@@ -163,11 +180,14 @@ export async function launchInstance(aliasOrOptions, options) {
|
|
|
163
180
|
if (!config) return;
|
|
164
181
|
|
|
165
182
|
if (config.type === 'server') {
|
|
166
|
-
console.log(chalk.
|
|
183
|
+
console.log(chalk.yellow(`\n Detected server instance "${config.name}". Starting server...\n`));
|
|
184
|
+
startServer(instancePath);
|
|
167
185
|
return;
|
|
168
186
|
}
|
|
169
187
|
|
|
170
188
|
console.log(chalk.cyan(`\nš® Launching ${config.name}...\n`));
|
|
189
|
+
settings.lastInstance = instancePath;
|
|
190
|
+
saveSettings(settings);
|
|
171
191
|
|
|
172
192
|
try {
|
|
173
193
|
// Get authentication
|
package/docs/commands/launch.md
CHANGED
|
@@ -33,8 +33,9 @@ The `launch` command starts your Minecraft instance with all the correct Java ar
|
|
|
33
33
|
| Option | Description | Default |
|
|
34
34
|
|--------|-------------|---------|
|
|
35
35
|
| `-i, --instance <path>` | Path to instance directory | Current directory |
|
|
36
|
-
| `--offline` | Launch in offline mode (no authentication) | false |
|
|
37
|
-
| `--verbose` | Show detailed launch information | false |
|
|
36
|
+
| `--offline` | Launch in offline mode (no authentication) | `false` |
|
|
37
|
+
| `--verbose` | Show detailed launch information | `false` |
|
|
38
|
+
| `-l, --last` | Launch last ran instance | `false` |
|
|
38
39
|
|
|
39
40
|
## š Examples
|
|
40
41
|
|
package/docs/installation.md
CHANGED
package/helpers/config.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
|
|
6
|
+
export function startServer(instancePath) {
|
|
7
|
+
const startScript = process.platform === 'win32' ? 'start.bat' : 'start.sh';
|
|
8
|
+
const startPath = path.join(instancePath, startScript);
|
|
9
|
+
|
|
10
|
+
if (!fs.existsSync(startPath)) {
|
|
11
|
+
console.error(chalk.red(`Error: Start script not found at ${startPath}`));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const serverProcess = spawn(startPath, [], {
|
|
16
|
+
cwd: instancePath,
|
|
17
|
+
shell: true,
|
|
18
|
+
stdio: 'inherit'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
serverProcess.on('error', (err) => {
|
|
22
|
+
console.error(chalk.red(`Failed to start server: ${err.message}`));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
serverProcess.on('exit', (code) => {
|
|
26
|
+
if (code === 0) {
|
|
27
|
+
console.log(chalk.green('Server stopped successfully.'));
|
|
28
|
+
} else {
|
|
29
|
+
console.error(chalk.red(`Server exited with code ${code}`));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
package/helpers/versions.js
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
const versions = [
|
|
2
2
|
'0.1.0',
|
|
3
|
-
'0.2.0',
|
|
4
|
-
'0.
|
|
5
|
-
'0.
|
|
6
|
-
'0.3.0',
|
|
7
|
-
'0.3.1',
|
|
8
|
-
'0.3.2',
|
|
9
|
-
'0.4.0',
|
|
10
|
-
'0.4.1',
|
|
11
|
-
'0.4.2',
|
|
12
|
-
'0.4.3',
|
|
13
|
-
'0.4.4',
|
|
14
|
-
'0.4.5',
|
|
3
|
+
'0.2.0', '0.2.1', '0.2.2',
|
|
4
|
+
'0.3.0', '0.3.1', '0.3.2',
|
|
5
|
+
'0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6'
|
|
15
6
|
];
|
|
16
7
|
|
|
17
8
|
|
package/index.js
CHANGED
|
@@ -64,6 +64,7 @@ program
|
|
|
64
64
|
.option('-i, --instance <path>', 'Path to the instance directory')
|
|
65
65
|
.option('--offline', 'Launch in offline mode')
|
|
66
66
|
.option('--verbose', 'Enable verbose output')
|
|
67
|
+
.option('-l, --last', 'Launch the last used instance')
|
|
67
68
|
.action(launchInstance);
|
|
68
69
|
|
|
69
70
|
program
|