@powernukkitx/cli 1.0.0 → 1.0.1
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 +186 -203
- package/dist/cli.js +34 -46
- package/dist/commands/backup.d.ts +2 -2
- package/dist/commands/backup.js +23 -24
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +60 -61
- package/dist/commands/console.d.ts +2 -2
- package/dist/commands/console.js +98 -99
- package/dist/commands/doctor.d.ts +2 -2
- package/dist/commands/doctor.js +97 -98
- package/dist/commands/info.d.ts +2 -2
- package/dist/commands/info.js +41 -42
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +87 -66
- package/dist/commands/install.js +45 -0
- package/dist/commands/logs.d.ts +2 -2
- package/dist/commands/logs.js +60 -61
- package/dist/commands/menu.js +94 -86
- package/dist/commands/plugin/index.d.ts +2 -2
- package/dist/commands/plugin/index.js +13 -13
- package/dist/commands/plugin/info.d.ts +2 -2
- package/dist/commands/plugin/info.js +39 -40
- package/dist/commands/plugin/install.d.ts +2 -2
- package/dist/commands/plugin/install.js +56 -57
- package/dist/commands/plugin/installed.d.ts +2 -2
- package/dist/commands/plugin/installed.js +41 -42
- package/dist/commands/plugin/list.d.ts +2 -2
- package/dist/commands/plugin/list.js +47 -49
- package/dist/commands/plugin/remove.d.ts +2 -2
- package/dist/commands/plugin/remove.js +44 -45
- package/dist/commands/plugin/search.d.ts +2 -2
- package/dist/commands/plugin/search.js +11 -12
- package/dist/commands/plugin/update.d.ts +2 -2
- package/dist/commands/plugin/update.js +52 -53
- package/dist/commands/start.d.ts +2 -2
- package/dist/commands/start.js +74 -75
- package/dist/commands/stop.d.ts +2 -2
- package/dist/commands/stop.js +26 -27
- package/dist/commands/update.d.ts +2 -2
- package/dist/commands/update.js +34 -35
- package/dist/commands/use.d.ts +2 -2
- package/dist/commands/use.js +39 -40
- package/dist/infra/http.js +119 -121
- package/dist/infra/paths.js +15 -20
- package/dist/infra/store.js +24 -27
- package/dist/services/backup.js +34 -40
- package/dist/services/plugins.js +139 -111
- package/dist/services/process.js +41 -43
- package/dist/services/release.js +51 -38
- package/dist/services/server.js +81 -89
- package/dist/ui/output.js +67 -71
- package/dist/ui/prompts.js +26 -30
- package/dist/ui/theme.js +16 -18
- package/package.json +44 -46
- package/dist/bundle.js +0 -18
- package/dist/commands/cfg.d.ts +0 -2
- package/dist/commands/cfg.js +0 -61
- package/dist/commands/lang.d.ts +0 -2
- package/dist/commands/lang.js +0 -28
- package/dist/commands/plugin.d.ts +0 -1
- package/dist/commands/plugin.js +0 -1
- package/dist/core/config.d.ts +0 -13
- package/dist/core/config.js +0 -31
- package/dist/core/network.d.ts +0 -13
- package/dist/core/network.js +0 -139
- package/dist/core/output.d.ts +0 -33
- package/dist/core/output.js +0 -75
- package/dist/core/process.d.ts +0 -10
- package/dist/core/process.js +0 -53
- package/dist/i18n/en.json +0 -174
- package/dist/i18n/fr.json +0 -174
- package/dist/i18n/index.js +0 -58
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/lang/en.json +0 -146
- package/dist/lang/fr.json +0 -146
- package/dist/lang/index.d.ts +0 -7
- package/dist/lang/index.js +0 -83
- package/dist/main.d.ts +0 -2
- package/dist/main.js +0 -28
- package/dist/plugins.json +0 -66
- package/dist/types.d.ts +0 -61
- package/dist/types.js +0 -1
- package/dist/utils/api.d.ts +0 -9
- package/dist/utils/api.js +0 -24
- package/dist/utils/github.d.ts +0 -20
- package/dist/utils/github.js +0 -60
- package/dist/utils/logger.d.ts +0 -15
- package/dist/utils/logger.js +0 -72
- package/dist/utils/pause.d.ts +0 -1
- package/dist/utils/pause.js +0 -6
- package/dist/utils/plugins.d.ts +0 -4
- package/dist/utils/plugins.js +0 -34
- package/dist/utils/server.d.ts +0 -3
- package/dist/utils/server.js +0 -32
- package/dist/utils/updater.d.ts +0 -1
- package/dist/utils/updater.js +0 -86
package/dist/utils/logger.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare const logo: string;
|
|
2
|
-
export declare function success(msg: string): void;
|
|
3
|
-
export declare function error(msg: string): void;
|
|
4
|
-
export declare function warn(msg: string): void;
|
|
5
|
-
export declare function info(msg: string): void;
|
|
6
|
-
export declare function step(msg: string): void;
|
|
7
|
-
export declare function header(title: string): void;
|
|
8
|
-
export declare function subheader(title: string): void;
|
|
9
|
-
export declare function table(rows: [string, string][]): void;
|
|
10
|
-
export declare function bullet(items: string[]): void;
|
|
11
|
-
export declare function divider(): void;
|
|
12
|
-
export declare const highlight: import("chalk").ChalkInstance;
|
|
13
|
-
export declare const dim: import("chalk").ChalkInstance;
|
|
14
|
-
export declare const bold: import("chalk").ChalkInstance;
|
|
15
|
-
export declare const code: (s: string) => string;
|
package/dist/utils/logger.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
// ─── palette ──────────────────────────────────────────────────
|
|
3
|
-
const c = {
|
|
4
|
-
primary: chalk.hex('#FF6B35'),
|
|
5
|
-
accent: chalk.hex('#FF8C42'),
|
|
6
|
-
gold: chalk.hex('#FFB347'),
|
|
7
|
-
blue: chalk.hex('#6C8EBF'),
|
|
8
|
-
cyan: chalk.hex('#4ECDC4'),
|
|
9
|
-
green: chalk.hex('#4CAF50'),
|
|
10
|
-
red: chalk.hex('#E53935'),
|
|
11
|
-
yellow: chalk.hex('#FFC107'),
|
|
12
|
-
dim: chalk.dim,
|
|
13
|
-
bold: chalk.bold,
|
|
14
|
-
};
|
|
15
|
-
// ─── logo ─────────────────────────────────────────────────────
|
|
16
|
-
export const logo = `
|
|
17
|
-
${c.primary.bold(' ╭──────────────────────────────────────╮')}
|
|
18
|
-
${c.primary.bold(' │')} ${c.accent.bold('██████╗ ███╗ ██╗██╗ ██╗')} ${c.primary.bold('│')}
|
|
19
|
-
${c.primary.bold(' │')} ${c.accent.bold('██╔══██╗████╗ ██║╚██╗██╔╝')} ${c.primary.bold('│')}
|
|
20
|
-
${c.primary.bold(' │')} ${c.accent.bold('██████╔╝██╔██╗ ██║ ╚███╔╝')} ${c.primary.bold('│')}
|
|
21
|
-
${c.primary.bold(' │')} ${c.accent.bold('██╔═══╝ ██║╚██╗██║ ██╔██╗')} ${c.primary.bold('│')}
|
|
22
|
-
${c.primary.bold(' │')} ${c.accent.bold('██║ ██║ ╚████║██╔╝ ██╗')} ${c.primary.bold('│')}
|
|
23
|
-
${c.primary.bold(' │')} ${c.accent.bold('╚═╝ ╚═╝ ╚═══╝╚═╝ ╚═╝')} ${c.primary.bold('│')}
|
|
24
|
-
${c.primary.bold(' ╰──────────────────────────────────────╯')}
|
|
25
|
-
${c.gold(' PowerNukkitX · Minecraft Bedrock')}
|
|
26
|
-
${c.dim(' Server Management CLI')}
|
|
27
|
-
`;
|
|
28
|
-
// ─── helpers ──────────────────────────────────────────────────
|
|
29
|
-
const pad = (s) => ` ${s}`;
|
|
30
|
-
export function success(msg) {
|
|
31
|
-
console.log(pad(`${c.green('✔')} ${c.bold(msg)}`));
|
|
32
|
-
}
|
|
33
|
-
export function error(msg) {
|
|
34
|
-
console.log(pad(`${c.red('✘')} ${c.bold(msg)}`));
|
|
35
|
-
}
|
|
36
|
-
export function warn(msg) {
|
|
37
|
-
console.log(pad(`${c.yellow('⚠')} ${msg}`));
|
|
38
|
-
}
|
|
39
|
-
export function info(msg) {
|
|
40
|
-
console.log(pad(`${c.blue('ℹ')} ${msg}`));
|
|
41
|
-
}
|
|
42
|
-
export function step(msg) {
|
|
43
|
-
console.log(pad(`${c.dim('▸')} ${c.dim(msg)}`));
|
|
44
|
-
}
|
|
45
|
-
export function header(title) {
|
|
46
|
-
const line = c.primary('─'.repeat(50));
|
|
47
|
-
console.log(`\n ${line}`);
|
|
48
|
-
console.log(` ${c.accent.bold(title)}`);
|
|
49
|
-
console.log(` ${line}`);
|
|
50
|
-
}
|
|
51
|
-
export function subheader(title) {
|
|
52
|
-
console.log(`\n ${c.accent('┃')} ${c.bold(title)}`);
|
|
53
|
-
console.log(` ${c.accent('┃')} ${c.dim('─'.repeat(Math.min(title.length, 40)))}`);
|
|
54
|
-
}
|
|
55
|
-
export function table(rows) {
|
|
56
|
-
const max = Math.max(...rows.map(([l]) => l.length));
|
|
57
|
-
for (const [label, value] of rows) {
|
|
58
|
-
console.log(pad(`${c.accent(label.padEnd(max + 2))}${value}`));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export function bullet(items) {
|
|
62
|
-
for (const item of items) {
|
|
63
|
-
console.log(pad(`${c.cyan('●')} ${item}`));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export function divider() {
|
|
67
|
-
console.log(pad(c.dim('─'.repeat(50))));
|
|
68
|
-
}
|
|
69
|
-
export const highlight = c.gold;
|
|
70
|
-
export const dim = c.dim;
|
|
71
|
-
export const bold = c.bold;
|
|
72
|
-
export const code = (s) => c.cyan(s);
|
package/dist/utils/pause.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function pauseForExit(): Promise<void>;
|
package/dist/utils/pause.js
DELETED
package/dist/utils/plugins.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { InstalledPlugin } from '../types.js';
|
|
2
|
-
export declare function getInstalledPlugins(): Promise<InstalledPlugin[]>;
|
|
3
|
-
export declare function saveInstalledPlugin(plugin: InstalledPlugin): Promise<void>;
|
|
4
|
-
export declare function getPluginVersion(slug: string): Promise<string | null>;
|
package/dist/utils/plugins.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
const CACHE_DIR = join(homedir(), '.pnx-cli');
|
|
6
|
-
const PLUGINS_FILE = join(CACHE_DIR, 'installed-plugins.json');
|
|
7
|
-
export async function getInstalledPlugins() {
|
|
8
|
-
try {
|
|
9
|
-
if (!existsSync(PLUGINS_FILE))
|
|
10
|
-
return [];
|
|
11
|
-
const raw = await readFile(PLUGINS_FILE, 'utf-8');
|
|
12
|
-
return JSON.parse(raw);
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export async function saveInstalledPlugin(plugin) {
|
|
19
|
-
await mkdir(CACHE_DIR, { recursive: true });
|
|
20
|
-
const list = await getInstalledPlugins();
|
|
21
|
-
const idx = list.findIndex(p => p.slug === plugin.slug);
|
|
22
|
-
if (idx >= 0) {
|
|
23
|
-
list[idx] = plugin;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
list.push(plugin);
|
|
27
|
-
}
|
|
28
|
-
await writeFile(PLUGINS_FILE, JSON.stringify(list, null, 2), 'utf-8');
|
|
29
|
-
}
|
|
30
|
-
export async function getPluginVersion(slug) {
|
|
31
|
-
const list = await getInstalledPlugins();
|
|
32
|
-
const p = list.find(x => x.slug === slug);
|
|
33
|
-
return p ? p.version : null;
|
|
34
|
-
}
|
package/dist/utils/server.d.ts
DELETED
package/dist/utils/server.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { join, dirname, resolve } from 'node:path';
|
|
3
|
-
import { cwd } from 'node:process';
|
|
4
|
-
import { getDefaultServer } from '../core/config.js';
|
|
5
|
-
export function detectAllServers(startPath) {
|
|
6
|
-
const found = [];
|
|
7
|
-
const paths = [
|
|
8
|
-
startPath || cwd(),
|
|
9
|
-
join(startPath || cwd(), 'pnx-server'),
|
|
10
|
-
startPath ? dirname(resolve(startPath)) : dirname(cwd()),
|
|
11
|
-
];
|
|
12
|
-
for (const dir of paths) {
|
|
13
|
-
if (existsSync(join(dir, 'powernukkitx.jar')) && !found.includes(dir))
|
|
14
|
-
found.push(dir);
|
|
15
|
-
}
|
|
16
|
-
return found;
|
|
17
|
-
}
|
|
18
|
-
export function detectServer(startPath) {
|
|
19
|
-
return detectAllServers(startPath)[0] ?? null;
|
|
20
|
-
}
|
|
21
|
-
export async function resolveServerDir() {
|
|
22
|
-
const def = await getDefaultServer();
|
|
23
|
-
if (def && existsSync(join(def, 'powernukkitx.jar')))
|
|
24
|
-
return def;
|
|
25
|
-
const all = detectAllServers();
|
|
26
|
-
if (all.length === 0)
|
|
27
|
-
return null;
|
|
28
|
-
if (all.length === 1)
|
|
29
|
-
return all[0];
|
|
30
|
-
const { select } = await import('@inquirer/prompts');
|
|
31
|
-
return select({ message: 'Plusieurs serveurs détectés. Lequel ?', choices: all.map(s => ({ name: s, value: s })) });
|
|
32
|
-
}
|
package/dist/utils/updater.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function checkForUpdates(force?: boolean): Promise<void>;
|
package/dist/utils/updater.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import { warn, dim } from './logger.js';
|
|
7
|
-
import { getLatestRelease, findAsset } from './github.js';
|
|
8
|
-
import { fetchPluginDetail } from './api.js';
|
|
9
|
-
import { getInstalledPlugins } from './plugins.js';
|
|
10
|
-
import { detectServer } from './server.js';
|
|
11
|
-
import { t } from '../lang/index.js';
|
|
12
|
-
const CACHE_DIR = join(homedir(), '.pnx-cli');
|
|
13
|
-
const CHECK_FILE = join(CACHE_DIR, 'last-update-check.json');
|
|
14
|
-
const CHECK_TTL = 3_600_000; // 1h
|
|
15
|
-
async function getLastCheck() {
|
|
16
|
-
try {
|
|
17
|
-
if (existsSync(CHECK_FILE)) {
|
|
18
|
-
const raw = await readFile(CHECK_FILE, 'utf-8');
|
|
19
|
-
return JSON.parse(raw);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch { /* ignore */ }
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
async function saveCheck(data) {
|
|
26
|
-
try {
|
|
27
|
-
await mkdir(CACHE_DIR, { recursive: true });
|
|
28
|
-
await writeFile(CHECK_FILE, JSON.stringify(data), 'utf-8');
|
|
29
|
-
}
|
|
30
|
-
catch { /* ignore */ }
|
|
31
|
-
}
|
|
32
|
-
let notifsShown = false;
|
|
33
|
-
export async function checkForUpdates(force) {
|
|
34
|
-
if (notifsShown && !force)
|
|
35
|
-
return;
|
|
36
|
-
const last = await getLastCheck();
|
|
37
|
-
if (last && !force && Date.now() - last.timestamp < CHECK_TTL) {
|
|
38
|
-
notifsShown = true;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const notifications = [];
|
|
42
|
-
// Check core update
|
|
43
|
-
try {
|
|
44
|
-
const serverPath = detectServer();
|
|
45
|
-
if (serverPath && existsSync(join(serverPath, 'powernukkitx.jar'))) {
|
|
46
|
-
const release = await getLatestRelease();
|
|
47
|
-
const tag = release.tag_name.replace(/^v/, '');
|
|
48
|
-
const asset = await findAsset(release, 'powernukkitx.jar');
|
|
49
|
-
if (asset) {
|
|
50
|
-
// Read current version from jar name or release cache
|
|
51
|
-
const cachedVersion = last?.coreVersion;
|
|
52
|
-
if (cachedVersion && cachedVersion !== tag) {
|
|
53
|
-
notifications.push(`${chalk.yellow('⟳')} ${t('updater.coreUpdate')} ${chalk.bold('v' + tag)} ${dim('(current: v' + cachedVersion + ')')} ${chalk.cyan('pnx update')}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
await saveCheck({ timestamp: Date.now(), coreVersion: tag });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
catch { /* silent */ }
|
|
60
|
-
// Check plugin updates
|
|
61
|
-
try {
|
|
62
|
-
const serverPath = detectServer();
|
|
63
|
-
const pluginsDir = serverPath ? join(serverPath, 'plugins') : join(process.cwd(), 'plugins');
|
|
64
|
-
if (existsSync(pluginsDir)) {
|
|
65
|
-
const installed = await getInstalledPlugins();
|
|
66
|
-
for (const p of installed) {
|
|
67
|
-
try {
|
|
68
|
-
const detail = await fetchPluginDetail(p.slug);
|
|
69
|
-
if (detail.latest_version !== p.version) {
|
|
70
|
-
notifications.push(`${chalk.yellow('⟳')} ${t('updater.pluginUpdate', detail.name, chalk.bold('v' + detail.latest_version), dim('(current: v' + p.version + ')'))} ${chalk.cyan(`pnx plugin update ${p.slug}`)}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
catch { /* skip if plugin not found on marketplace */ }
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch { /* silent */ }
|
|
78
|
-
if (notifications.length > 0) {
|
|
79
|
-
console.log();
|
|
80
|
-
for (const n of notifications) {
|
|
81
|
-
warn(n);
|
|
82
|
-
}
|
|
83
|
-
console.log();
|
|
84
|
-
}
|
|
85
|
-
notifsShown = true;
|
|
86
|
-
}
|