@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 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
@@ -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
- instancePath = getInstancePath(opts);
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.red('Error: This is a server instance. Use ./start.sh to start the server.'));
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
@@ -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
 
@@ -70,7 +70,7 @@ This should display the current version of CLIcraft.
70
70
 
71
71
  ```bash
72
72
  cd clicraft
73
- git pull origin main
73
+ git pull origin live
74
74
  npm install -g
75
75
  ```
76
76
 
package/helpers/config.js CHANGED
@@ -29,6 +29,7 @@ const DEFAULT_SETTINGS = {
29
29
  checkUpdates: true,
30
30
  autoSaveToConfig: true,
31
31
  autoLoadConfigOnLaunch: true,
32
+ lastInstance: "",
32
33
  };
33
34
 
34
35
  // Default game settings to apply to new instances
@@ -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
+ }
@@ -1,17 +1,8 @@
1
1
  const versions = [
2
2
  '0.1.0',
3
- '0.2.0',
4
- '0.2.1',
5
- '0.2.2',
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobschlowinskii/clicraft",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "A simple Minecraft Mod Package Manager written in Node.JS",
5
5
  "main": "index.js",
6
6
  "type": "module",