@lamalibre/portlama-agent 1.0.24 → 2.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/package.json +8 -12
- package/src/commands/deploy.js +2 -2
- package/src/commands/list.js +3 -3
- package/src/commands/logs.js +1 -1
- package/src/commands/panel.js +12 -9
- package/src/commands/plugin.js +16 -12
- package/src/commands/setup.js +18 -8
- package/src/commands/sites.js +2 -2
- package/src/commands/status.js +4 -5
- package/src/commands/switch.js +1 -2
- package/src/commands/uninstall.js +28 -14
- package/src/commands/update.js +7 -7
- package/src/index.js +14 -14
- package/src/lib/cert-store.js +1 -1
- package/src/lib/chisel.js +1 -2
- package/src/lib/keychain.js +3 -1
- package/src/lib/panel-api.js +3 -1
- package/src/lib/panel-service.js +11 -103
- package/src/lib/service-config.js +1 -1
- package/src/lib/ws-helpers.js +3 -1
- package/panel-dist/assets/index--JJrcXFV.js +0 -380
- package/panel-dist/assets/index-DZe4H75z.css +0 -1
- package/panel-dist/assets/index-ZuJ4xZ2V.js +0 -380
- package/panel-dist/index.html +0 -13
- package/src/lib/agent-plugin-router.js +0 -141
- package/src/lib/agent-plugins.js +0 -358
- package/src/lib/config.js +0 -58
- package/src/lib/launchctl.js +0 -67
- package/src/lib/local-host-service.js +0 -289
- package/src/lib/local-plugin-host.js +0 -264
- package/src/lib/local-plugins.js +0 -265
- package/src/lib/panel-api-routes.js +0 -390
- package/src/lib/panel-server.js +0 -203
- package/src/lib/platform.js +0 -307
- package/src/lib/registry.js +0 -458
- package/src/lib/service.js +0 -107
- package/src/local-plugin-host-entry.js +0 -37
- package/src/panel-server-entry.js +0 -45
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lamalibre/portlama-agent",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "CLI tool for Portlama tunnel agent — setup, update, status, and management commands",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
7
|
"author": "Code Lama Software",
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"bin",
|
|
13
|
-
"src"
|
|
14
|
-
"panel-dist"
|
|
13
|
+
"src"
|
|
15
14
|
],
|
|
16
15
|
"scripts": {
|
|
17
16
|
"lint": "eslint ."
|
|
@@ -19,7 +18,7 @@
|
|
|
19
18
|
"repository": {
|
|
20
19
|
"type": "git",
|
|
21
20
|
"url": "https://github.com/lamalibre/portlama.git",
|
|
22
|
-
"directory": "packages/portlama-agent"
|
|
21
|
+
"directory": "packages/agent/portlama-agent"
|
|
23
22
|
},
|
|
24
23
|
"homepage": "https://github.com/lamalibre/portlama#readme",
|
|
25
24
|
"bugs": {
|
|
@@ -34,17 +33,14 @@
|
|
|
34
33
|
"linux",
|
|
35
34
|
"systemd",
|
|
36
35
|
"ubuntu",
|
|
37
|
-
"agent"
|
|
36
|
+
"agent",
|
|
37
|
+
"cli"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"@fastify/rate-limit": "^10.3.0",
|
|
42
|
-
"@fastify/static": "^8.0.0",
|
|
40
|
+
"@lamalibre/portlama": "^2.0.0",
|
|
43
41
|
"chalk": "^5.3.0",
|
|
44
42
|
"execa": "^9.0.0",
|
|
45
|
-
"
|
|
46
|
-
"listr2": "^8.0.0",
|
|
47
|
-
"ws": "^8.18.0"
|
|
43
|
+
"listr2": "^8.0.0"
|
|
48
44
|
},
|
|
49
45
|
"engines": {
|
|
50
46
|
"node": ">=20.0.0"
|
package/src/commands/deploy.js
CHANGED
|
@@ -2,8 +2,8 @@ import chalk from 'chalk';
|
|
|
2
2
|
import { Listr } from 'listr2';
|
|
3
3
|
import { readdir, stat } from 'node:fs/promises';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { assertSupportedPlatform } from '
|
|
6
|
-
import { requireAgentConfig } from '
|
|
5
|
+
import { assertSupportedPlatform } from '@lamalibre/portlama/agent';
|
|
6
|
+
import { requireAgentConfig } from '@lamalibre/portlama/agent';
|
|
7
7
|
import { fetchSites, fetchSiteFiles, deleteSiteFile, uploadSiteFiles } from '../lib/panel-api.js';
|
|
8
8
|
import { formatBytes } from '../lib/format.js';
|
|
9
9
|
import { filterBlockedFiles, runClamAvScan } from '../lib/scan.js';
|
package/src/commands/list.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { assertSupportedPlatform } from '
|
|
3
|
-
import { listAgents, getCurrentLabel } from '
|
|
4
|
-
import { isAgentLoaded, getAgentPid } from '
|
|
2
|
+
import { assertSupportedPlatform } from '@lamalibre/portlama/agent';
|
|
3
|
+
import { listAgents, getCurrentLabel } from '@lamalibre/portlama/agent';
|
|
4
|
+
import { isAgentLoaded, getAgentPid } from '@lamalibre/portlama/agent';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* List all configured agents with their status.
|
package/src/commands/logs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { execa } from 'execa';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
-
import { assertSupportedPlatform, agentLogFile, agentErrorLogFile } from '
|
|
4
|
+
import { assertSupportedPlatform, agentLogFile, agentErrorLogFile } from '@lamalibre/portlama/agent';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Stream chisel logs to the terminal.
|
package/src/commands/panel.js
CHANGED
|
@@ -8,14 +8,17 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import chalk from 'chalk';
|
|
11
|
-
import { loadAgentConfig, saveAgentConfig } from '../lib/config.js';
|
|
12
|
-
import { assertSupportedPlatform } from '../lib/platform.js';
|
|
13
11
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
loadAgentConfig,
|
|
13
|
+
saveAgentConfig,
|
|
14
|
+
assertSupportedPlatform,
|
|
15
|
+
isPanelServiceLoaded,
|
|
17
16
|
loadPanelService,
|
|
18
17
|
unloadPanelService,
|
|
18
|
+
} from '@lamalibre/portlama/agent';
|
|
19
|
+
import {
|
|
20
|
+
generatePanelServiceConfig,
|
|
21
|
+
writePanelServiceConfig,
|
|
19
22
|
removePanelServiceConfig,
|
|
20
23
|
} from '../lib/panel-service.js';
|
|
21
24
|
import { exposePanelTunnel, retractPanelTunnel, fetchPanelTunnelStatus } from '../lib/panel-api.js';
|
|
@@ -62,7 +65,7 @@ export async function runPanel(args, { label, json: globalJson = false }) {
|
|
|
62
65
|
|
|
63
66
|
async function enablePanel(label, config, port, isJson, localOnly = false) {
|
|
64
67
|
// 1. Check if already enabled
|
|
65
|
-
const loaded = await
|
|
68
|
+
const loaded = await isPanelServiceLoaded(label);
|
|
66
69
|
if (loaded) {
|
|
67
70
|
if (isJson) {
|
|
68
71
|
console.log(JSON.stringify({ ok: true, alreadyRunning: true, port: config.panelPort || port }));
|
|
@@ -122,7 +125,7 @@ async function enablePanel(label, config, port, isJson, localOnly = false) {
|
|
|
122
125
|
const { fetchAgentConfig } = await import('../lib/panel-api.js');
|
|
123
126
|
const { generateServiceConfig, writeServiceConfigFile } =
|
|
124
127
|
await import('../lib/service-config.js');
|
|
125
|
-
const { unloadAgent, loadAgent } = await import('
|
|
128
|
+
const { unloadAgent, loadAgent } = await import('@lamalibre/portlama/agent');
|
|
126
129
|
const agentConfig = await fetchAgentConfig(config);
|
|
127
130
|
const serviceContent = generateServiceConfig(agentConfig.chiselArgs, label);
|
|
128
131
|
await writeServiceConfigFile(serviceContent, label);
|
|
@@ -172,7 +175,7 @@ async function disablePanel(label, config, isJson, localOnly = false) {
|
|
|
172
175
|
const { fetchAgentConfig } = await import('../lib/panel-api.js');
|
|
173
176
|
const { generateServiceConfig, writeServiceConfigFile } =
|
|
174
177
|
await import('../lib/service-config.js');
|
|
175
|
-
const { unloadAgent, loadAgent } = await import('
|
|
178
|
+
const { unloadAgent, loadAgent } = await import('@lamalibre/portlama/agent');
|
|
176
179
|
const agentConfig = await fetchAgentConfig(config);
|
|
177
180
|
const serviceContent = generateServiceConfig(agentConfig.chiselArgs, label);
|
|
178
181
|
await writeServiceConfigFile(serviceContent, label);
|
|
@@ -200,7 +203,7 @@ async function disablePanel(label, config, isJson, localOnly = false) {
|
|
|
200
203
|
}
|
|
201
204
|
|
|
202
205
|
async function showStatus(label, config, isJson) {
|
|
203
|
-
const loaded = await
|
|
206
|
+
const loaded = await isPanelServiceLoaded(label);
|
|
204
207
|
let tunnelStatus = { enabled: false, fqdn: null, port: null };
|
|
205
208
|
|
|
206
209
|
try {
|
package/src/commands/plugin.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { assertSupportedPlatform } from '
|
|
3
|
-
import { validateLabel } from '../lib/registry.js';
|
|
2
|
+
import { assertSupportedPlatform, validateLabel } from '@lamalibre/portlama/agent';
|
|
4
3
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
readPluginRegistry,
|
|
5
|
+
installPlugin,
|
|
6
|
+
uninstallPlugin,
|
|
7
|
+
updatePlugin,
|
|
8
|
+
agentPluginConfig,
|
|
9
|
+
} from '@lamalibre/portlama/agent';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Install a plugin locally on the agent.
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
async function installLocal(label, packageName) {
|
|
17
17
|
console.log(chalk.cyan(` Installing ${packageName}...`));
|
|
18
18
|
try {
|
|
19
|
-
const
|
|
19
|
+
const pluginConfig = agentPluginConfig(label);
|
|
20
|
+
const entry = await installPlugin(pluginConfig, packageName);
|
|
20
21
|
console.log(chalk.green(` Plugin "${entry.name}" installed`));
|
|
21
22
|
} catch (err) {
|
|
22
23
|
console.error(chalk.red(` ${err.message}`));
|
|
@@ -31,7 +32,8 @@ async function installLocal(label, packageName) {
|
|
|
31
32
|
*/
|
|
32
33
|
async function uninstallLocal(label, nameOrPackage) {
|
|
33
34
|
// Resolve name from registry if a package name was given
|
|
34
|
-
const
|
|
35
|
+
const pluginConfig = agentPluginConfig(label);
|
|
36
|
+
const registry = await readPluginRegistry(pluginConfig);
|
|
35
37
|
const plugin = registry.plugins.find(
|
|
36
38
|
(p) => p.name === nameOrPackage || p.packageName === nameOrPackage,
|
|
37
39
|
);
|
|
@@ -42,7 +44,7 @@ async function uninstallLocal(label, nameOrPackage) {
|
|
|
42
44
|
|
|
43
45
|
console.log(chalk.cyan(` Uninstalling ${plugin.packageName}...`));
|
|
44
46
|
try {
|
|
45
|
-
await
|
|
47
|
+
await uninstallPlugin(pluginConfig, plugin.name);
|
|
46
48
|
console.log(chalk.green(` Plugin "${plugin.name}" uninstalled`));
|
|
47
49
|
} catch (err) {
|
|
48
50
|
console.error(chalk.red(` ${err.message}`));
|
|
@@ -58,7 +60,8 @@ async function uninstallLocal(label, nameOrPackage) {
|
|
|
58
60
|
async function updateLocal(label, nameOrPackage) {
|
|
59
61
|
console.log(chalk.cyan(` Updating ${nameOrPackage}...`));
|
|
60
62
|
try {
|
|
61
|
-
const
|
|
63
|
+
const pluginConfig = agentPluginConfig(label);
|
|
64
|
+
const plugin = await updatePlugin(pluginConfig, nameOrPackage);
|
|
62
65
|
console.log(chalk.green(` Plugin "${plugin.name}" updated to v${plugin.version}`));
|
|
63
66
|
} catch (err) {
|
|
64
67
|
console.error(chalk.red(` ${err.message}`));
|
|
@@ -71,7 +74,8 @@ async function updateLocal(label, nameOrPackage) {
|
|
|
71
74
|
* @param {string} label - Agent label
|
|
72
75
|
*/
|
|
73
76
|
async function showStatus(label) {
|
|
74
|
-
const
|
|
77
|
+
const pluginConfig = agentPluginConfig(label);
|
|
78
|
+
const registry = await readPluginRegistry(pluginConfig);
|
|
75
79
|
const b = chalk.bold;
|
|
76
80
|
const c = chalk.cyan;
|
|
77
81
|
const d = chalk.dim;
|
package/src/commands/setup.js
CHANGED
|
@@ -8,19 +8,29 @@ import chalk from 'chalk';
|
|
|
8
8
|
import {
|
|
9
9
|
assertSupportedPlatform,
|
|
10
10
|
CHISEL_BIN_DIR,
|
|
11
|
-
|
|
11
|
+
PORTLAMA_DIR,
|
|
12
12
|
agentDataDir,
|
|
13
13
|
agentLogsDir,
|
|
14
|
-
} from '
|
|
15
|
-
import {
|
|
14
|
+
} from '@lamalibre/portlama/agent';
|
|
15
|
+
import {
|
|
16
|
+
saveAgentConfig,
|
|
17
|
+
validateLabel,
|
|
18
|
+
deriveLabel,
|
|
19
|
+
upsertAgent,
|
|
20
|
+
getAgent,
|
|
21
|
+
} from '@lamalibre/portlama/agent';
|
|
16
22
|
import { fetchHealth, fetchAgentConfig, fetchTunnels, curlPostUnauthenticated } from '../lib/panel-api.js';
|
|
17
23
|
import { extractPemFromP12, cleanupPemFiles } from '../lib/ws-helpers.js';
|
|
18
24
|
import { installChisel } from '../lib/chisel.js';
|
|
19
25
|
import { generateServiceConfig, writeServiceConfigFile } from '../lib/service-config.js';
|
|
20
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
isAgentLoaded,
|
|
28
|
+
unloadAgent,
|
|
29
|
+
loadAgent,
|
|
30
|
+
getAgentPid,
|
|
31
|
+
} from '@lamalibre/portlama/agent';
|
|
21
32
|
import { generateKeypairAndCSR, secureDelete } from '../lib/keychain.js';
|
|
22
33
|
import { storeEnrolledCert } from '../lib/cert-store.js';
|
|
23
|
-
import { validateLabel, deriveLabel, upsertAgent, getAgent } from '../lib/registry.js';
|
|
24
34
|
|
|
25
35
|
/**
|
|
26
36
|
* Prompt for user input via readline.
|
|
@@ -195,7 +205,7 @@ async function runTokenSetup(flags) {
|
|
|
195
205
|
{
|
|
196
206
|
title: 'Creating directories',
|
|
197
207
|
task: async () => {
|
|
198
|
-
await mkdir(
|
|
208
|
+
await mkdir(PORTLAMA_DIR, { recursive: true, mode: 0o700 });
|
|
199
209
|
await mkdir(CHISEL_BIN_DIR, { recursive: true });
|
|
200
210
|
// Per-agent dirs created after we know the label (post-enrollment)
|
|
201
211
|
},
|
|
@@ -434,7 +444,7 @@ async function runTokenSetupJson(flags) {
|
|
|
434
444
|
key: 'create_directories',
|
|
435
445
|
title: 'Creating directories',
|
|
436
446
|
fn: async () => {
|
|
437
|
-
await mkdir(
|
|
447
|
+
await mkdir(PORTLAMA_DIR, { recursive: true, mode: 0o700 });
|
|
438
448
|
await mkdir(CHISEL_BIN_DIR, { recursive: true });
|
|
439
449
|
},
|
|
440
450
|
},
|
|
@@ -694,7 +704,7 @@ async function runP12Setup(options = {}) {
|
|
|
694
704
|
{
|
|
695
705
|
title: 'Creating directories',
|
|
696
706
|
task: async () => {
|
|
697
|
-
await mkdir(
|
|
707
|
+
await mkdir(PORTLAMA_DIR, { recursive: true, mode: 0o700 });
|
|
698
708
|
await mkdir(CHISEL_BIN_DIR, { recursive: true });
|
|
699
709
|
const dataDir = agentDataDir(ctx.resolvedLabel);
|
|
700
710
|
const logsDir = agentLogsDir(ctx.resolvedLabel);
|
package/src/commands/sites.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { assertSupportedPlatform } from '
|
|
4
|
-
import { requireAgentConfig } from '
|
|
3
|
+
import { assertSupportedPlatform } from '@lamalibre/portlama/agent';
|
|
4
|
+
import { requireAgentConfig } from '@lamalibre/portlama/agent';
|
|
5
5
|
import { fetchSites, createSite, deleteSite } from '../lib/panel-api.js';
|
|
6
6
|
import { formatBytes } from '../lib/format.js';
|
|
7
7
|
|
package/src/commands/status.js
CHANGED
|
@@ -6,10 +6,9 @@ import {
|
|
|
6
6
|
serviceConfigPath,
|
|
7
7
|
agentLogFile,
|
|
8
8
|
agentDataDir,
|
|
9
|
-
} from '
|
|
10
|
-
import { loadAgentConfig } from '
|
|
11
|
-
import { isAgentLoaded, getAgentPid } from '
|
|
12
|
-
import { isPanelLoaded } from '../lib/panel-service.js';
|
|
9
|
+
} from '@lamalibre/portlama/agent';
|
|
10
|
+
import { loadAgentConfig } from '@lamalibre/portlama/agent';
|
|
11
|
+
import { isAgentLoaded, getAgentPid, isPanelServiceLoaded } from '@lamalibre/portlama/agent';
|
|
13
12
|
import { getInstalledVersion } from '../lib/chisel.js';
|
|
14
13
|
import { fetchTunnels, fetchPanelTunnelStatus } from '../lib/panel-api.js';
|
|
15
14
|
|
|
@@ -72,7 +71,7 @@ export async function runStatus({ label }) {
|
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
// Panel server status
|
|
75
|
-
const panelRunning = await
|
|
74
|
+
const panelRunning = await isPanelServiceLoaded(label);
|
|
76
75
|
console.log(
|
|
77
76
|
` ${b('Web Panel:')} ${panelRunning ? g('running') : d('stopped')}`,
|
|
78
77
|
);
|
package/src/commands/switch.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { assertSupportedPlatform } from '
|
|
3
|
-
import { setCurrentAgent, validateLabel, listAgents } from '../lib/registry.js';
|
|
2
|
+
import { assertSupportedPlatform, setCurrentAgent, validateLabel, listAgents } from '@lamalibre/portlama/agent';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Switch the current (default) agent.
|
|
@@ -3,10 +3,26 @@ import { rm } from 'node:fs/promises';
|
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { Listr } from 'listr2';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import {
|
|
7
|
+
assertSupportedPlatform,
|
|
8
|
+
PORTLAMA_DIR,
|
|
9
|
+
isLinux,
|
|
10
|
+
serviceConfigPath,
|
|
11
|
+
agentDataDir,
|
|
12
|
+
LEGACY_SERVICE_CONFIG_PATH,
|
|
13
|
+
} from '@lamalibre/portlama/agent';
|
|
14
|
+
import {
|
|
15
|
+
isAgentLoaded,
|
|
16
|
+
unloadAgent,
|
|
17
|
+
isPanelServiceLoaded,
|
|
18
|
+
unloadPanelService,
|
|
19
|
+
} from '@lamalibre/portlama/agent';
|
|
20
|
+
import {
|
|
21
|
+
listAgents,
|
|
22
|
+
removeAgent,
|
|
23
|
+
loadRegistry,
|
|
24
|
+
} from '@lamalibre/portlama/agent';
|
|
25
|
+
import { removePanelServiceConfig } from '../lib/panel-service.js';
|
|
10
26
|
|
|
11
27
|
/**
|
|
12
28
|
* Unload the agent, remove the service config, and config.
|
|
@@ -61,7 +77,7 @@ async function uninstallSingle(label) {
|
|
|
61
77
|
{
|
|
62
78
|
title: `Stopping panel server "${label}"`,
|
|
63
79
|
skip: async () => {
|
|
64
|
-
const loaded = await
|
|
80
|
+
const loaded = await isPanelServiceLoaded(label);
|
|
65
81
|
return !loaded && 'Panel not running';
|
|
66
82
|
},
|
|
67
83
|
task: async () => {
|
|
@@ -149,7 +165,7 @@ async function uninstallAll() {
|
|
|
149
165
|
...agents.map((agent) => ({
|
|
150
166
|
title: `Stopping panel server "${agent.label}"`,
|
|
151
167
|
skip: async () => {
|
|
152
|
-
const loaded = await
|
|
168
|
+
const loaded = await isPanelServiceLoaded(agent.label);
|
|
153
169
|
return !loaded && 'Panel not running';
|
|
154
170
|
},
|
|
155
171
|
task: async () => {
|
|
@@ -189,9 +205,9 @@ async function uninstallAll() {
|
|
|
189
205
|
},
|
|
190
206
|
{
|
|
191
207
|
title: 'Removing ~/.portlama directory',
|
|
192
|
-
skip: () => !existsSync(
|
|
208
|
+
skip: () => !existsSync(PORTLAMA_DIR) && 'Directory not found',
|
|
193
209
|
task: async () => {
|
|
194
|
-
await rm(
|
|
210
|
+
await rm(PORTLAMA_DIR, { recursive: true });
|
|
195
211
|
},
|
|
196
212
|
},
|
|
197
213
|
],
|
|
@@ -214,8 +230,6 @@ async function uninstallAll() {
|
|
|
214
230
|
* Legacy uninstall for pre-registry installations.
|
|
215
231
|
*/
|
|
216
232
|
async function uninstallLegacy() {
|
|
217
|
-
const { SERVICE_CONFIG_PATH } = await import('../lib/platform.js');
|
|
218
|
-
|
|
219
233
|
const isTTY = process.stdout.isTTY && process.stderr.isTTY;
|
|
220
234
|
const tasks = new Listr(
|
|
221
235
|
[
|
|
@@ -236,9 +250,9 @@ async function uninstallLegacy() {
|
|
|
236
250
|
},
|
|
237
251
|
{
|
|
238
252
|
title: 'Removing service config',
|
|
239
|
-
skip: () => !existsSync(
|
|
253
|
+
skip: () => !existsSync(LEGACY_SERVICE_CONFIG_PATH) && 'Service config not found',
|
|
240
254
|
task: async () => {
|
|
241
|
-
await rm(
|
|
255
|
+
await rm(LEGACY_SERVICE_CONFIG_PATH);
|
|
242
256
|
if (isLinux()) {
|
|
243
257
|
const { execa } = await import('execa');
|
|
244
258
|
await execa('systemctl', ['daemon-reload']);
|
|
@@ -247,9 +261,9 @@ async function uninstallLegacy() {
|
|
|
247
261
|
},
|
|
248
262
|
{
|
|
249
263
|
title: 'Removing ~/.portlama directory',
|
|
250
|
-
skip: () => !existsSync(
|
|
264
|
+
skip: () => !existsSync(PORTLAMA_DIR) && 'Directory not found',
|
|
251
265
|
task: async () => {
|
|
252
|
-
await rm(
|
|
266
|
+
await rm(PORTLAMA_DIR, { recursive: true });
|
|
253
267
|
},
|
|
254
268
|
},
|
|
255
269
|
],
|
package/src/commands/update.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Listr } from 'listr2';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { assertSupportedPlatform } from '
|
|
4
|
-
import { requireAgentConfig, saveAgentConfig } from '
|
|
5
|
-
import {
|
|
3
|
+
import { assertSupportedPlatform } from '@lamalibre/portlama/agent';
|
|
4
|
+
import { requireAgentConfig, saveAgentConfig } from '@lamalibre/portlama/agent';
|
|
5
|
+
import { isAgentLoaded, unloadAgent, loadAgent, getAgentPid } from '@lamalibre/portlama/agent';
|
|
6
|
+
import { readPluginRegistry, agentPluginConfig } from '@lamalibre/portlama/agent';
|
|
7
|
+
import { fetchAgentConfig, fetchTunnels, curlAuthenticatedJson } from '../lib/panel-api.js';
|
|
6
8
|
import { generateServiceConfig, writeServiceConfigFile } from '../lib/service-config.js';
|
|
7
|
-
import { isAgentLoaded, unloadAgent, loadAgent, getAgentPid } from '../lib/service.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Re-fetch tunnel config from the panel and restart the agent.
|
|
@@ -87,8 +88,8 @@ export async function runUpdate({ label }) {
|
|
|
87
88
|
{
|
|
88
89
|
title: 'Reporting installed plugins',
|
|
89
90
|
task: async (_ctx, task) => {
|
|
90
|
-
const
|
|
91
|
-
const registry = await
|
|
91
|
+
const pluginConfig = agentPluginConfig(label);
|
|
92
|
+
const registry = await readPluginRegistry(pluginConfig);
|
|
92
93
|
const enabledPlugins = registry.plugins.filter((p) => p.status === 'enabled');
|
|
93
94
|
if (enabledPlugins.length === 0) {
|
|
94
95
|
task.skip('No enabled plugins');
|
|
@@ -100,7 +101,6 @@ export async function runUpdate({ label }) {
|
|
|
100
101
|
capabilities: p.capabilities || [],
|
|
101
102
|
}));
|
|
102
103
|
try {
|
|
103
|
-
const { curlAuthenticatedJson } = await import('../lib/panel-api.js');
|
|
104
104
|
await curlAuthenticatedJson(config, [
|
|
105
105
|
'-X', 'POST',
|
|
106
106
|
'-H', 'Content-Type: application/json',
|
package/src/index.js
CHANGED
|
@@ -113,9 +113,9 @@ export async function main() {
|
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
115
|
case 'update': {
|
|
116
|
-
const {
|
|
117
|
-
const { resolveLabel } = await import('./lib/registry.js');
|
|
116
|
+
const { resolveLabel } = await import('@lamalibre/portlama/agent');
|
|
118
117
|
const resolved = await resolveLabel(label);
|
|
118
|
+
const { runUpdate } = await import('./commands/update.js');
|
|
119
119
|
await runUpdate({ label: resolved });
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
@@ -125,44 +125,44 @@ export async function main() {
|
|
|
125
125
|
break;
|
|
126
126
|
}
|
|
127
127
|
case 'status': {
|
|
128
|
-
const {
|
|
129
|
-
const { resolveLabel } = await import('./lib/registry.js');
|
|
128
|
+
const { resolveLabel } = await import('@lamalibre/portlama/agent');
|
|
130
129
|
const resolved = await resolveLabel(label);
|
|
130
|
+
const { runStatus } = await import('./commands/status.js');
|
|
131
131
|
await runStatus({ label: resolved });
|
|
132
132
|
break;
|
|
133
133
|
}
|
|
134
134
|
case 'logs': {
|
|
135
|
-
const {
|
|
136
|
-
const { resolveLabel } = await import('./lib/registry.js');
|
|
135
|
+
const { resolveLabel } = await import('@lamalibre/portlama/agent');
|
|
137
136
|
const resolved = await resolveLabel(label);
|
|
137
|
+
const { runLogs } = await import('./commands/logs.js');
|
|
138
138
|
await runLogs({ label: resolved });
|
|
139
139
|
break;
|
|
140
140
|
}
|
|
141
141
|
case 'sites': {
|
|
142
|
-
const {
|
|
143
|
-
const { resolveLabel } = await import('./lib/registry.js');
|
|
142
|
+
const { resolveLabel } = await import('@lamalibre/portlama/agent');
|
|
144
143
|
const resolved = await resolveLabel(label);
|
|
144
|
+
const { runSites } = await import('./commands/sites.js');
|
|
145
145
|
await runSites(args.slice(1), { label: resolved });
|
|
146
146
|
break;
|
|
147
147
|
}
|
|
148
148
|
case 'deploy': {
|
|
149
|
-
const {
|
|
150
|
-
const { resolveLabel } = await import('./lib/registry.js');
|
|
149
|
+
const { resolveLabel } = await import('@lamalibre/portlama/agent');
|
|
151
150
|
const resolved = await resolveLabel(label);
|
|
151
|
+
const { runDeploy } = await import('./commands/deploy.js');
|
|
152
152
|
await runDeploy(args.slice(1), { label: resolved });
|
|
153
153
|
break;
|
|
154
154
|
}
|
|
155
155
|
case 'plugin': {
|
|
156
|
-
const {
|
|
157
|
-
const { resolveLabel } = await import('./lib/registry.js');
|
|
156
|
+
const { resolveLabel } = await import('@lamalibre/portlama/agent');
|
|
158
157
|
const resolved = await resolveLabel(label);
|
|
158
|
+
const { runPlugin } = await import('./commands/plugin.js');
|
|
159
159
|
await runPlugin(args.slice(1), { label: resolved });
|
|
160
160
|
break;
|
|
161
161
|
}
|
|
162
162
|
case 'panel': {
|
|
163
|
-
const {
|
|
164
|
-
const { resolveLabel } = await import('./lib/registry.js');
|
|
163
|
+
const { resolveLabel } = await import('@lamalibre/portlama/agent');
|
|
165
164
|
const resolved = await resolveLabel(label);
|
|
165
|
+
const { runPanel } = await import('./commands/panel.js');
|
|
166
166
|
await runPanel(args.slice(1), { label: resolved, json });
|
|
167
167
|
break;
|
|
168
168
|
}
|
package/src/lib/cert-store.js
CHANGED
|
@@ -10,7 +10,7 @@ import crypto from 'node:crypto';
|
|
|
10
10
|
import { writeFile, access, constants } from 'node:fs/promises';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { execa } from 'execa';
|
|
13
|
-
import { agentDataDir } from '
|
|
13
|
+
import { agentDataDir } from '@lamalibre/portlama/agent';
|
|
14
14
|
import { secureDelete } from './keychain.js';
|
|
15
15
|
|
|
16
16
|
/**
|
package/src/lib/chisel.js
CHANGED
|
@@ -3,8 +3,7 @@ import { access, constants, mkdir } from 'node:fs/promises';
|
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import crypto from 'node:crypto';
|
|
6
|
-
import { CHISEL_BIN_PATH, CHISEL_BIN_DIR } from '
|
|
7
|
-
import { detectArch } from './platform.js';
|
|
6
|
+
import { CHISEL_BIN_PATH, CHISEL_BIN_DIR, detectArch } from '@lamalibre/portlama/agent';
|
|
8
7
|
|
|
9
8
|
const GITHUB_API = 'https://api.github.com/repos/jpillora/chisel/releases/latest';
|
|
10
9
|
|
package/src/lib/keychain.js
CHANGED
|
@@ -2,7 +2,9 @@ import crypto from 'node:crypto';
|
|
|
2
2
|
import { writeFile, unlink, readFile, stat } from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { execa } from 'execa';
|
|
5
|
-
import {
|
|
5
|
+
import { PORTLAMA_DIR } from '@lamalibre/portlama/agent';
|
|
6
|
+
|
|
7
|
+
const AGENT_DIR = PORTLAMA_DIR;
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Overwrite a file with random bytes, then unlink it.
|
package/src/lib/panel-api.js
CHANGED
|
@@ -3,7 +3,9 @@ import { readdirSync, unlinkSync } from 'node:fs';
|
|
|
3
3
|
import { writeFile, unlink } from 'node:fs/promises';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { execa } from 'execa';
|
|
6
|
-
import {
|
|
6
|
+
import { PORTLAMA_DIR } from '@lamalibre/portlama/agent';
|
|
7
|
+
|
|
8
|
+
const AGENT_DIR = PORTLAMA_DIR;
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Clean up stale curl config temp files left behind by previous crashes.
|