@studiometa/forge-cli 0.2.3 → 0.2.4
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/dist/cli.js +4 -8
- package/dist/cli.js.map +1 -1
- package/dist/utils/resolve.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as createContext, c as colors, d as deleteToken, i as runCommand, l as setColorEnabled, m as setToken, n as exitWithValidationError, p as getToken, s as OutputFormatter, u as createConfigStore, v as ValidationError } from "./error-handler-BahHMt6t.js";
|
|
3
|
-
import { activateCertificate, createAuditLogger, createBackupConfig, createCommand, createDatabaseUser, createMonitor, createNginxTemplate, createRedirectRule, createScheduledJob, createSecurityRule, deleteBackupConfig, deleteDatabaseUser, deleteMonitor, deleteNginxTemplate, deleteRedirectRule, deleteScheduledJob, deleteSecurityRule, deploySiteAndWait, getBackupConfig, getCertificate, getCommand, getDaemon, getDatabase, getDatabaseUser, getEnv, getFirewallRule, getMonitor, getNginxConfig, getNginxTemplate, getRecipe, getRedirectRule, getScheduledJob, getSecurityRule, getServer, getSite, getSshKey, getUser, listBackupConfigs, listCertificates, listCommands, listDaemons, listDatabaseUsers, listDatabases, listDeployments, listFirewallRules, listMonitors, listNginxTemplates, listRecipes, listRedirectRules, listScheduledJobs, listSecurityRules, listServers, listSites, listSshKeys, rebootServer, restartDaemon, runRecipe, updateEnv, updateNginxConfig, updateNginxTemplate } from "@studiometa/forge-core";
|
|
3
|
+
import { activateCertificate, createAuditLogger, createBackupConfig, createCommand, createDatabaseUser, createMonitor, createNginxTemplate, createRedirectRule, createScheduledJob, createSecurityRule, deleteBackupConfig, deleteDatabaseUser, deleteMonitor, deleteNginxTemplate, deleteRedirectRule, deleteScheduledJob, deleteSecurityRule, deploySiteAndWait, getBackupConfig, getCertificate, getCommand, getDaemon, getDatabase, getDatabaseUser, getEnv, getFirewallRule, getMonitor, getNginxConfig, getNginxTemplate, getRecipe, getRedirectRule, getScheduledJob, getSecurityRule, getServer, getSite, getSshKey, getUser, listBackupConfigs, listCertificates, listCommands, listDaemons, listDatabaseUsers, listDatabases, listDeployments, listFirewallRules, listMonitors, listNginxTemplates, listRecipes, listRedirectRules, listScheduledJobs, listSecurityRules, listServers, listSites, listSshKeys, matchByName, rebootServer, restartDaemon, runRecipe, updateEnv, updateNginxConfig, updateNginxTemplate } from "@studiometa/forge-core";
|
|
4
4
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { homedir } from "node:os";
|
|
6
6
|
import { join } from "node:path";
|
|
@@ -70,10 +70,8 @@ function createCommandRouter(config) {
|
|
|
70
70
|
async function resolveServerId(value, execCtx) {
|
|
71
71
|
if (/^\d+$/.test(value)) return value;
|
|
72
72
|
const servers = (await listServers({}, execCtx)).data;
|
|
73
|
-
const
|
|
74
|
-
const exact = servers.filter((s) => s.name.toLowerCase() === lower);
|
|
73
|
+
const { exact, partial } = matchByName(servers, value, (s) => s.name);
|
|
75
74
|
if (exact.length === 1) return String(exact[0].id);
|
|
76
|
-
const partial = servers.filter((s) => s.name.toLowerCase().includes(lower));
|
|
77
75
|
if (partial.length === 0) {
|
|
78
76
|
const available = servers.map((s) => ` ${s.name} (${s.id})`).join("\n");
|
|
79
77
|
throw new ValidationError(`No server found matching "${value}"`, "server", [`Available servers:\n${available}`]);
|
|
@@ -95,10 +93,8 @@ async function resolveServerId(value, execCtx) {
|
|
|
95
93
|
async function resolveSiteId(value, serverId, execCtx) {
|
|
96
94
|
if (/^\d+$/.test(value)) return value;
|
|
97
95
|
const sites = (await listSites({ server_id: serverId }, execCtx)).data;
|
|
98
|
-
const
|
|
99
|
-
const exact = sites.filter((s) => s.name.toLowerCase() === lower);
|
|
96
|
+
const { exact, partial } = matchByName(sites, value, (s) => s.name);
|
|
100
97
|
if (exact.length === 1) return String(exact[0].id);
|
|
101
|
-
const partial = sites.filter((s) => s.name.toLowerCase().includes(lower));
|
|
102
98
|
if (partial.length === 0) {
|
|
103
99
|
const available = sites.map((s) => ` ${s.name} (${s.id})`).join("\n");
|
|
104
100
|
throw new ValidationError(`No site found matching "${value}" on server ${serverId}`, "site", [`Available sites:\n${available}`]);
|
|
@@ -3214,7 +3210,7 @@ function parseArgs(argv = process.argv.slice(2)) {
|
|
|
3214
3210
|
positional
|
|
3215
3211
|
};
|
|
3216
3212
|
}
|
|
3217
|
-
var VERSION = "0.2.
|
|
3213
|
+
var VERSION = "0.2.4";
|
|
3218
3214
|
function showHelp() {
|
|
3219
3215
|
console.log(`
|
|
3220
3216
|
${colors.bold("forge-cli")} v${VERSION}
|