@nomac/cli 0.11.3 → 0.11.5
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 +1 -1
- package/src/hosted-sessions.mjs +11 -4
- package/src/session-transfer.mjs +3 -0
- package/src/sessions.mjs +2 -2
package/package.json
CHANGED
package/src/hosted-sessions.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { parseArgs } from "node:util";
|
|
|
5
5
|
import { api, CliError } from "./api.mjs";
|
|
6
6
|
import { sessionStore } from "./session-store.mjs";
|
|
7
7
|
import { forwardingArg, isShellLine, runProcess, sshArgs, workspaceCommand } from "./session-ssh.mjs";
|
|
8
|
-
import { pullProject, syncProject } from "./session-transfer.mjs";
|
|
8
|
+
import { describePull, describeSync, pullProject, syncProject } from "./session-transfer.mjs";
|
|
9
9
|
import { macRequest, sessionId, transportOptions } from "./mac-transport.mjs";
|
|
10
10
|
import { copyToClipboard, desktop, DESKTOP_HELP, screenSharing } from "./desktop.mjs";
|
|
11
11
|
import { screenshot, startRecording, stopRecording } from "./mac-screen.mjs";
|
|
@@ -299,7 +299,10 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
|
|
|
299
299
|
: `Cost so far: $${(Number(result.session?.cost?.accrued_microunits ?? 0) / 1_000_000).toFixed(2)} ($0.80/hour, billed by the minute while the Mac is ready). Credit left: nomac credits`;
|
|
300
300
|
const next = result.session.state === "ready" ? "Next: nomac sync . → nomac ssh"
|
|
301
301
|
: result.session.failure_code === "capacity_unavailable" ? "No Mac was free within 5 minutes; nothing was charged. Run nomac start again in a few minutes."
|
|
302
|
-
: result.session.state === "queued" ? "Waiting for a free Mac (waiting is free). Check again: nomac start"
|
|
302
|
+
: result.session.state === "queued" ? "Waiting for a free Mac (waiting is free). Check again: nomac start"
|
|
303
|
+
: ["stopped", "failed"].includes(result.session.state) ? `${result.session.drive ? "The drive saves in the background (nomac drive shows it). " : ""}Start another: nomac start`
|
|
304
|
+
: result.session.state === "stopping" ? "Stopping. Check: nomac status"
|
|
305
|
+
: "Check: nomac status";
|
|
303
306
|
print(`${result.attached ? `${result.attached}\n` : ""}${result.session.id}: ${result.session.state}\n${next}\n${usage}${result.warning ? `\n${result.warning}` : ""}`);
|
|
304
307
|
return result;
|
|
305
308
|
};
|
|
@@ -583,11 +586,15 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
|
|
|
583
586
|
await ready(local);
|
|
584
587
|
if (command === "sync") {
|
|
585
588
|
if (positionals.length > 1 || (positionals[0] && resolve(positionals[0]) !== store.project)) throw new CliError("Run nomac sync . from the attached project.");
|
|
586
|
-
|
|
589
|
+
const result = await syncProject(local, store, { overwrite: values.overwrite, dryRun: values["dry-run"], run });
|
|
590
|
+
if (!values.json) { print(describeSync(result)); return result; }
|
|
591
|
+
return output(result);
|
|
587
592
|
}
|
|
588
593
|
if (command === "pull") {
|
|
589
594
|
if (positionals.length !== 1) throw new CliError("Usage: nomac pull LOCAL_PATH [--from REMOTE_PATH]");
|
|
590
|
-
|
|
595
|
+
const result = await pullProject(local, store, positionals[0], { from: values.from ?? positionals[0], overwrite: values.overwrite, dryRun: values["dry-run"], run });
|
|
596
|
+
if (!values.json) { print(describePull(result)); return result; }
|
|
597
|
+
return output(result);
|
|
591
598
|
}
|
|
592
599
|
throw new CliError("Unknown cloud session command.");
|
|
593
600
|
});
|
package/src/session-transfer.mjs
CHANGED
|
@@ -186,6 +186,9 @@ export function describeSync(result) {
|
|
|
186
186
|
return lines.join("\n");
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
+
/** The human summary of a pull. */
|
|
190
|
+
export const describePull = (result) => `${result.dry_run ? "Would retrieve" : "Retrieved"} ${result.changed.length} changed files (${result.files} considered).${result.recovery_directory ? `\nPrevious local files: ${result.recovery_directory}` : ""}`;
|
|
191
|
+
|
|
189
192
|
const transferEnv = (session, remoteDirectory = ".") => ({ ...process.env, NOMAC_TRANSFER_SESSION: JSON.stringify({ ...session, remoteDirectory }) });
|
|
190
193
|
|
|
191
194
|
function conflictError(paths, side) {
|
package/src/sessions.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { parseArgs } from "node:util";
|
|
|
5
5
|
import { CliError } from "./api.mjs";
|
|
6
6
|
import { sessionStore } from "./session-store.mjs";
|
|
7
7
|
import { forwardingArg, prepareWorkspace, runProcess, shellQuote, sshArgs, validateTarget, workspaceCommand } from "./session-ssh.mjs";
|
|
8
|
-
import { describeSync, pullProject, syncProject } from "./session-transfer.mjs";
|
|
8
|
+
import { describePull, describeSync, pullProject, syncProject } from "./session-transfer.mjs";
|
|
9
9
|
|
|
10
10
|
export const SESSION_HELP = `Nomac 2.0 — SSH workspace preview
|
|
11
11
|
|
|
@@ -137,7 +137,7 @@ export async function sessionCommand(command, argv, { store: suppliedStore, run
|
|
|
137
137
|
if (command === "pull") {
|
|
138
138
|
if (positionals.length !== 1) throw new CliError("pull usage", "Usage: nomac pull LOCAL_DIRECTORY [--from REMOTE_DIRECTORY] [--dry-run] [--overwrite]");
|
|
139
139
|
const result = await pullProject(session, store, positionals[0], { from: values.from ?? positionals[0], overwrite: values.overwrite, dryRun: values["dry-run"], run });
|
|
140
|
-
return output(result,
|
|
140
|
+
return output(result, describePull(result));
|
|
141
141
|
}
|
|
142
142
|
throw new CliError("unknown session command");
|
|
143
143
|
});
|