replicas-cli 0.2.130 → 0.2.132
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/index.mjs +44 -6
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2356,11 +2356,15 @@ async function engineFetch(path5, options) {
|
|
|
2356
2356
|
}
|
|
2357
2357
|
|
|
2358
2358
|
// src/commands/preview.ts
|
|
2359
|
-
|
|
2359
|
+
function parsePort(port) {
|
|
2360
2360
|
const portNum = parseInt(port, 10);
|
|
2361
2361
|
if (isNaN(portNum) || portNum < 1 || portNum > 65535) {
|
|
2362
2362
|
throw new Error("Port must be a number between 1 and 65535");
|
|
2363
2363
|
}
|
|
2364
|
+
return portNum;
|
|
2365
|
+
}
|
|
2366
|
+
async function previewCreateCommand(port, options) {
|
|
2367
|
+
const portNum = parsePort(port);
|
|
2364
2368
|
if (isAgentMode()) {
|
|
2365
2369
|
const result = await agentFetch("/v1/previews", {
|
|
2366
2370
|
method: "POST",
|
|
@@ -2398,10 +2402,7 @@ async function previewListCommand(workspaceId) {
|
|
|
2398
2402
|
}
|
|
2399
2403
|
}
|
|
2400
2404
|
async function previewAddCommand(workspaceId, options) {
|
|
2401
|
-
const portNum =
|
|
2402
|
-
if (isNaN(portNum) || portNum < 1 || portNum > 65535) {
|
|
2403
|
-
throw new Error("Port must be a number between 1 and 65535");
|
|
2404
|
-
}
|
|
2405
|
+
const portNum = parsePort(options.port);
|
|
2405
2406
|
const result = await orgAuthenticatedFetch(
|
|
2406
2407
|
`/v1/workspaces/${workspaceId}/previews`,
|
|
2407
2408
|
{
|
|
@@ -2411,6 +2412,21 @@ async function previewAddCommand(workspaceId, options) {
|
|
|
2411
2412
|
);
|
|
2412
2413
|
console.log(chalk17.green(`Preview created: ${result.preview.publicUrl}`));
|
|
2413
2414
|
}
|
|
2415
|
+
async function previewDeleteCommand(port) {
|
|
2416
|
+
const portNum = parsePort(port);
|
|
2417
|
+
await agentFetch(`/v1/previews/${portNum}`, {
|
|
2418
|
+
method: "DELETE"
|
|
2419
|
+
});
|
|
2420
|
+
console.log(`Preview deleted on port ${portNum}`);
|
|
2421
|
+
}
|
|
2422
|
+
async function previewRemoveCommand(workspaceId, options) {
|
|
2423
|
+
const portNum = parsePort(options.port);
|
|
2424
|
+
await orgAuthenticatedFetch(
|
|
2425
|
+
`/v1/workspaces/${workspaceId}/previews/${portNum}`,
|
|
2426
|
+
{ method: "DELETE" }
|
|
2427
|
+
);
|
|
2428
|
+
console.log(chalk17.green(`Preview deleted on port ${portNum}`));
|
|
2429
|
+
}
|
|
2414
2430
|
|
|
2415
2431
|
// src/commands/media.ts
|
|
2416
2432
|
import fs3 from "fs";
|
|
@@ -2525,7 +2541,7 @@ async function interactiveCommand() {
|
|
|
2525
2541
|
}
|
|
2526
2542
|
|
|
2527
2543
|
// src/index.ts
|
|
2528
|
-
var CLI_VERSION = "0.2.
|
|
2544
|
+
var CLI_VERSION = "0.2.132";
|
|
2529
2545
|
var program = new Command();
|
|
2530
2546
|
program.name("replicas").description("CLI for managing Replicas workspaces").version(CLI_VERSION);
|
|
2531
2547
|
program.command("login").description("Authenticate with your Replicas account").action(async () => {
|
|
@@ -2908,6 +2924,16 @@ if (isAgentMode()) {
|
|
|
2908
2924
|
process.exit(1);
|
|
2909
2925
|
}
|
|
2910
2926
|
});
|
|
2927
|
+
preview.command("delete <port>").description("Unregister a preview port").action(async (port) => {
|
|
2928
|
+
try {
|
|
2929
|
+
await previewDeleteCommand(port);
|
|
2930
|
+
} catch (error) {
|
|
2931
|
+
if (error instanceof Error) {
|
|
2932
|
+
console.error(`Error: ${error.message}`);
|
|
2933
|
+
}
|
|
2934
|
+
process.exit(1);
|
|
2935
|
+
}
|
|
2936
|
+
});
|
|
2911
2937
|
} else {
|
|
2912
2938
|
preview.command("add <workspaceId>").description("Register a preview port for a workspace").requiredOption("-p, --port <port>", "Port number to preview").option(
|
|
2913
2939
|
"-a, --authenticated",
|
|
@@ -2931,6 +2957,18 @@ if (isAgentMode()) {
|
|
|
2931
2957
|
if (error instanceof Error) {
|
|
2932
2958
|
console.error(chalk19.red(`
|
|
2933
2959
|
\u2717 ${error.message}
|
|
2960
|
+
`));
|
|
2961
|
+
}
|
|
2962
|
+
process.exit(1);
|
|
2963
|
+
}
|
|
2964
|
+
});
|
|
2965
|
+
preview.command("remove <workspaceId>").description("Unregister a preview port from a workspace").requiredOption("-p, --port <port>", "Port number to unregister").action(async (workspaceId, options) => {
|
|
2966
|
+
try {
|
|
2967
|
+
await previewRemoveCommand(workspaceId, options);
|
|
2968
|
+
} catch (error) {
|
|
2969
|
+
if (error instanceof Error) {
|
|
2970
|
+
console.error(chalk19.red(`
|
|
2971
|
+
\u2717 ${error.message}
|
|
2934
2972
|
`));
|
|
2935
2973
|
}
|
|
2936
2974
|
process.exit(1);
|