@pilaf/cli 1.0.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/bin/pilaf.js ADDED
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+ const { program } = require('commander');
3
+ const { loadConfig } = require('../lib/config-loader');
4
+
5
+ program
6
+ .name('pilaf')
7
+ .description('Pure JS testing framework for Minecraft PaperMC plugins')
8
+ .version('1.0.0');
9
+
10
+ program
11
+ .command('test [files...]')
12
+ .description('Run Pilaf tests')
13
+ .option('-w, --watch', 'Watch mode')
14
+ .option('--config <path>', 'Config file path')
15
+ .option('--output <path>', 'Report output path')
16
+ .action(async (files, options) => {
17
+ const config = loadConfig(options.config);
18
+
19
+ // For now, just echo what would be run
20
+ console.log('[Pilaf] Would run tests:', files || config.testMatch);
21
+ console.log('[Pilaf] Report would be saved to:', options.output || config.reportDir);
22
+ console.log('[Pilaf] Full implementation in next tasks');
23
+ });
24
+
25
+ program
26
+ .command('health-check')
27
+ .description('Check backend connectivity')
28
+ .action(async () => {
29
+ const { PilafBackendFactory } = require('@pilaf/backends');
30
+ const config = loadConfig();
31
+
32
+ console.log('[Pilaf] Checking RCON connection...');
33
+ try {
34
+ const rcon = await PilafBackendFactory.create('rcon', config.backend.rcon);
35
+ const result = await rcon.sendCommand('list');
36
+ console.log('[Pilaf] ✓ RCON connected:', result.raw.substring(0, 100));
37
+ await rcon.disconnect();
38
+ } catch (err) {
39
+ console.error('[Pilaf] ✗ RCON connection failed:', err.message);
40
+ }
41
+ });
42
+
43
+ program.parse();
@@ -0,0 +1,41 @@
1
+ // packages/cli/lib/config-loader.js
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ function loadConfig(configPath) {
6
+ const defaultConfig = {
7
+ backend: {
8
+ rcon: {
9
+ host: 'localhost',
10
+ port: 25575,
11
+ password: process.env.RCON_PASSWORD || 'dragon123'
12
+ },
13
+ mineflayer: {
14
+ host: 'localhost',
15
+ port: 25565,
16
+ auth: 'offline'
17
+ }
18
+ },
19
+ testMatch: ['**/*.pilaf.test.js', '**/*.story.test.js'],
20
+ testIgnore: ['**/node_modules/**', '**/dist/**'],
21
+ reportDir: 'target/pilaf-reports',
22
+ timeout: 30000,
23
+ retries: 0,
24
+ verbose: false
25
+ };
26
+
27
+ if (configPath && fs.existsSync(configPath)) {
28
+ const userConfig = require(path.resolve(configPath));
29
+ return { ...defaultConfig, ...userConfig };
30
+ }
31
+
32
+ const defaultPath = path.join(process.cwd(), 'pilaf.config.js');
33
+ if (fs.existsSync(defaultPath)) {
34
+ const userConfig = require(defaultPath);
35
+ return { ...defaultConfig, ...userConfig };
36
+ }
37
+
38
+ return defaultConfig;
39
+ }
40
+
41
+ module.exports = { loadConfig };
package/lib/runner.js ADDED
@@ -0,0 +1,32 @@
1
+ // packages/cli/lib/runner.js
2
+ const { createConfig } = require('@jest/core');
3
+ const { PilafReporter } = require('@pilaf/framework');
4
+
5
+ async function runTests(files, options) {
6
+ const config = createConfig(
7
+ {
8
+ testMatch: options.testMatch || ['**/*.pilaf.test.js'],
9
+ testPathIgnorePatterns: options.testIgnore || ['node_modules'],
10
+ reporters: [
11
+ 'default',
12
+ ['@pilaf/framework', {
13
+ suiteName: options.suiteName || 'Pilaf Tests',
14
+ outputPath: options.outputPath || 'target/pilaf-reports/report.html'
15
+ }]
16
+ ],
17
+ testTimeout: options.timeout || 30000
18
+ },
19
+ null
20
+ );
21
+
22
+ if (files && files.length > 0) {
23
+ config.set('testMatch', files);
24
+ }
25
+
26
+ const { runCLI } = await import('jest');
27
+ const result = await runCLI(config, [process.cwd(), ...config.args]);
28
+
29
+ return result;
30
+ }
31
+
32
+ module.exports = { runTests };
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@pilaf/cli",
3
+ "version": "1.0.0",
4
+ "main": "lib/index.js",
5
+ "bin": {
6
+ "pilaf": "./bin/pilaf.js"
7
+ },
8
+ "files": [
9
+ "bin/**/*",
10
+ "lib/*.js",
11
+ "lib/**/*.js",
12
+ "!lib/**/*.spec.js",
13
+ "!lib/**/*.test.js",
14
+ "README.md",
15
+ "LICENSE"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "dependencies": {
21
+ "commander": "^12.0.0",
22
+ "jest": "^29.7.0",
23
+ "@pilaf/framework": "1.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "@jest/globals": "^29.7.0"
27
+ }
28
+ }