@computesdk/workbench 3.1.2 → 3.1.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/bin/workbench.js +14 -6
- package/dist/bin/workbench.js.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
package/dist/bin/workbench.js
CHANGED
|
@@ -581,6 +581,7 @@ __export(commands_exports, {
|
|
|
581
581
|
toggleVerbose: () => toggleVerbose
|
|
582
582
|
});
|
|
583
583
|
import { createCompute } from "@computesdk/provider";
|
|
584
|
+
import { escapeArgs } from "@computesdk/cmd";
|
|
584
585
|
import * as readline from "readline";
|
|
585
586
|
async function confirm(question, defaultYes = false) {
|
|
586
587
|
return new Promise((resolve) => {
|
|
@@ -720,7 +721,8 @@ async function runCommand(state, command) {
|
|
|
720
721
|
const startTime = Date.now();
|
|
721
722
|
logCommand(command);
|
|
722
723
|
try {
|
|
723
|
-
const
|
|
724
|
+
const commandString = escapeArgs(command);
|
|
725
|
+
const result = await sandbox.runCommand(commandString);
|
|
724
726
|
const duration = Date.now() - startTime;
|
|
725
727
|
if (result.stdout) {
|
|
726
728
|
console.log(result.stdout.trimEnd());
|
|
@@ -1095,7 +1097,6 @@ function injectCmdContext(replServer) {
|
|
|
1095
1097
|
replServer.context.sha256sum = cmd.sha256sum;
|
|
1096
1098
|
replServer.context.sha1sum = cmd.sha1sum;
|
|
1097
1099
|
replServer.context.compute = cmd.compute;
|
|
1098
|
-
replServer.context.cmd = cmd.cmd;
|
|
1099
1100
|
replServer.context.shell = cmd.shell;
|
|
1100
1101
|
replServer.context.sh = cmd.sh;
|
|
1101
1102
|
replServer.context.bash = cmd.bash;
|
|
@@ -1152,6 +1153,13 @@ function injectWorkbenchCommands(replServer, state) {
|
|
|
1152
1153
|
}
|
|
1153
1154
|
return sandbox.runCode(code, runtime);
|
|
1154
1155
|
};
|
|
1156
|
+
replServer.context.runCommand = async (command, options) => {
|
|
1157
|
+
const sandbox = state.currentSandbox;
|
|
1158
|
+
if (!sandbox) {
|
|
1159
|
+
throw new Error("No active sandbox. Run a command to auto-create one.");
|
|
1160
|
+
}
|
|
1161
|
+
return sandbox.runCommand(command, options);
|
|
1162
|
+
};
|
|
1155
1163
|
replServer.context.create = async (options) => {
|
|
1156
1164
|
if (state.useDirectMode) {
|
|
1157
1165
|
throw new Error('Named sandboxes are only available in gateway mode. Use "mode gateway" to switch.');
|
|
@@ -1363,8 +1371,8 @@ function injectWorkbenchCommands(replServer, state) {
|
|
|
1363
1371
|
function setupSmartEvaluator(replServer, state) {
|
|
1364
1372
|
const originalEval = replServer.eval;
|
|
1365
1373
|
const workbenchCommands = /* @__PURE__ */ new Set(["help", "providers", "info", "env", "restart", "destroy", "mode", "verbose", "sandboxInfo", "connect"]);
|
|
1366
|
-
replServer.eval = function(
|
|
1367
|
-
const trimmedCmd =
|
|
1374
|
+
replServer.eval = function(cmd2, context, filename, callback) {
|
|
1375
|
+
const trimmedCmd = cmd2.trim();
|
|
1368
1376
|
const providerMatch = trimmedCmd.match(/^provider(?:\s+(direct|gateway))?\s+(\w+)$/);
|
|
1369
1377
|
if (providerMatch) {
|
|
1370
1378
|
const mode = providerMatch[1] || null;
|
|
@@ -1398,7 +1406,7 @@ function setupSmartEvaluator(replServer, state) {
|
|
|
1398
1406
|
runCommand(state, command).then((output) => callback(null, output)).catch((error) => callback(error, void 0));
|
|
1399
1407
|
return;
|
|
1400
1408
|
}
|
|
1401
|
-
originalEval.call(this,
|
|
1409
|
+
originalEval.call(this, cmd2, context, filename, async (err, result) => {
|
|
1402
1410
|
if (err) {
|
|
1403
1411
|
callback(err, void 0);
|
|
1404
1412
|
return;
|
|
@@ -1463,7 +1471,7 @@ function setupAutocomplete(replServer, state) {
|
|
|
1463
1471
|
const trimmed = line.trim();
|
|
1464
1472
|
if (!line.includes(" ") && !line.includes(".")) {
|
|
1465
1473
|
const commands = Object.keys(workbenchCommands);
|
|
1466
|
-
const hits = commands.filter((
|
|
1474
|
+
const hits = commands.filter((cmd2) => cmd2.startsWith(trimmed));
|
|
1467
1475
|
if (originalCompleter) {
|
|
1468
1476
|
originalCompleter.call(replServer, line, (err, result) => {
|
|
1469
1477
|
if (err || !result) {
|