@computesdk/cmd
Advanced tools
+20
-26
@@ -1155,28 +1155,22 @@ "use strict"; | ||
| // src/index.ts | ||
| var cmd = Object.assign( | ||
| // Callable: shell wrapper with sh default | ||
| (command, options) => { | ||
| return buildShellCommand("sh", command, options); | ||
| }, | ||
| { | ||
| // Filesystem | ||
| ...filesystem_exports, | ||
| // Process | ||
| ...process_exports, | ||
| // Package managers | ||
| ...packages_exports, | ||
| // Git | ||
| ...git_exports, | ||
| // Network | ||
| ...network_exports, | ||
| // Text processing | ||
| ...text_exports, | ||
| // Archives | ||
| ...archive_exports, | ||
| // System | ||
| ...system_exports, | ||
| // Compute | ||
| ...compute_exports | ||
| } | ||
| ); | ||
| var cmd = { | ||
| // Filesystem | ||
| ...filesystem_exports, | ||
| // Process | ||
| ...process_exports, | ||
| // Package managers | ||
| ...packages_exports, | ||
| // Git | ||
| ...git_exports, | ||
| // Network | ||
| ...network_exports, | ||
| // Text processing | ||
| ...text_exports, | ||
| // Archives | ||
| ...archive_exports, | ||
| // System | ||
| ...system_exports, | ||
| // Compute | ||
| ...compute_exports | ||
| }; | ||
| var { | ||
@@ -1183,0 +1177,0 @@ mkdir: mkdir2, |
+20
-15
@@ -97,20 +97,25 @@ /** | ||
| /** | ||
| * Command builders for common shell operations - callable with shell wrapper + command methods | ||
| * Command builders for common shell operations | ||
| * | ||
| * @example | ||
| * // As shell wrapper (default: sh) | ||
| * cmd(npm.install(), { cwd: '/app' }) | ||
| * // => ['sh', '-c', 'cd '/app' && npm install'] | ||
| * Namespace containing command builder functions for filesystem operations, | ||
| * package managers, git, network utilities, and more. | ||
| * | ||
| * For shell wrapping with cwd/background options, use `shell()` instead. | ||
| * | ||
| * @example | ||
| * // As command builders | ||
| * // Command builders | ||
| * cmd.npm.install('express') | ||
| * // => ['npm', 'install', 'express'] | ||
| * | ||
| * cmd.mkdir('/app/src') | ||
| * // => ['mkdir', '-p', '/app/src'] | ||
| * | ||
| * @example | ||
| * // For shell wrapping, use shell() instead | ||
| * import { shell, npm } from '@computesdk/cmd'; | ||
| * shell(npm.install(), { cwd: '/app' }) | ||
| * // => ['sh', '-c', 'cd '/app' && npm install'] | ||
| */ | ||
| declare const cmd: ((command: Command, options?: { | ||
| cwd?: string; | ||
| background?: boolean; | ||
| }) => Command) & { | ||
| install: (// Callable: shell wrapper with sh default | ||
| options?: { | ||
| declare const cmd: { | ||
| install: (options?: { | ||
| apiKey?: string; | ||
@@ -199,4 +204,3 @@ version?: string; | ||
| }) => Command; | ||
| du: (path: string, // As command builders | ||
| options?: { | ||
| du: (path: string, options?: { | ||
| human?: boolean; | ||
@@ -261,3 +265,4 @@ summarize?: boolean; | ||
| }) => Command; | ||
| sort: (file: string, options?: { | ||
| sort: (// Compute | ||
| file: string, options?: { | ||
| reverse?: boolean; | ||
@@ -264,0 +269,0 @@ numeric?: boolean; |
+20
-15
@@ -97,20 +97,25 @@ /** | ||
| /** | ||
| * Command builders for common shell operations - callable with shell wrapper + command methods | ||
| * Command builders for common shell operations | ||
| * | ||
| * @example | ||
| * // As shell wrapper (default: sh) | ||
| * cmd(npm.install(), { cwd: '/app' }) | ||
| * // => ['sh', '-c', 'cd '/app' && npm install'] | ||
| * Namespace containing command builder functions for filesystem operations, | ||
| * package managers, git, network utilities, and more. | ||
| * | ||
| * For shell wrapping with cwd/background options, use `shell()` instead. | ||
| * | ||
| * @example | ||
| * // As command builders | ||
| * // Command builders | ||
| * cmd.npm.install('express') | ||
| * // => ['npm', 'install', 'express'] | ||
| * | ||
| * cmd.mkdir('/app/src') | ||
| * // => ['mkdir', '-p', '/app/src'] | ||
| * | ||
| * @example | ||
| * // For shell wrapping, use shell() instead | ||
| * import { shell, npm } from '@computesdk/cmd'; | ||
| * shell(npm.install(), { cwd: '/app' }) | ||
| * // => ['sh', '-c', 'cd '/app' && npm install'] | ||
| */ | ||
| declare const cmd: ((command: Command, options?: { | ||
| cwd?: string; | ||
| background?: boolean; | ||
| }) => Command) & { | ||
| install: (// Callable: shell wrapper with sh default | ||
| options?: { | ||
| declare const cmd: { | ||
| install: (options?: { | ||
| apiKey?: string; | ||
@@ -199,4 +204,3 @@ version?: string; | ||
| }) => Command; | ||
| du: (path: string, // As command builders | ||
| options?: { | ||
| du: (path: string, options?: { | ||
| human?: boolean; | ||
@@ -261,3 +265,4 @@ summarize?: boolean; | ||
| }) => Command; | ||
| sort: (file: string, options?: { | ||
| sort: (// Compute | ||
| file: string, options?: { | ||
| reverse?: boolean; | ||
@@ -264,0 +269,0 @@ numeric?: boolean; |
+20
-26
@@ -1055,28 +1055,22 @@ var __defProp = Object.defineProperty; | ||
| // src/index.ts | ||
| var cmd = Object.assign( | ||
| // Callable: shell wrapper with sh default | ||
| (command, options) => { | ||
| return buildShellCommand("sh", command, options); | ||
| }, | ||
| { | ||
| // Filesystem | ||
| ...filesystem_exports, | ||
| // Process | ||
| ...process_exports, | ||
| // Package managers | ||
| ...packages_exports, | ||
| // Git | ||
| ...git_exports, | ||
| // Network | ||
| ...network_exports, | ||
| // Text processing | ||
| ...text_exports, | ||
| // Archives | ||
| ...archive_exports, | ||
| // System | ||
| ...system_exports, | ||
| // Compute | ||
| ...compute_exports | ||
| } | ||
| ); | ||
| var cmd = { | ||
| // Filesystem | ||
| ...filesystem_exports, | ||
| // Process | ||
| ...process_exports, | ||
| // Package managers | ||
| ...packages_exports, | ||
| // Git | ||
| ...git_exports, | ||
| // Network | ||
| ...network_exports, | ||
| // Text processing | ||
| ...text_exports, | ||
| // Archives | ||
| ...archive_exports, | ||
| // System | ||
| ...system_exports, | ||
| // Compute | ||
| ...compute_exports | ||
| }; | ||
| var { | ||
@@ -1083,0 +1077,0 @@ mkdir: mkdir2, |
+1
-1
| { | ||
| "name": "@computesdk/cmd", | ||
| "version": "0.3.1", | ||
| "version": "0.4.0", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Type-safe shell command builders for ComputeSDK sandboxes", |
+22
-17
@@ -28,32 +28,35 @@ # @computesdk/cmd | ||
| ### Shell Wrapping with `cmd()` | ||
| ### Using with runCommand Options | ||
| Use `cmd()` to wrap commands with `cwd` or `background` options: | ||
| Modern ComputeSDK sandboxes handle `cwd`, `env`, and `background` options directly: | ||
| ```typescript | ||
| import { cmd, npm, node } from '@computesdk/cmd'; | ||
| import { npm, node } from '@computesdk/cmd'; | ||
| // Run in a specific directory | ||
| cmd(npm.install(), { cwd: '/app' }) | ||
| // => ['sh', '-c', 'cd "/app" && npm install'] | ||
| // Run in background | ||
| cmd(node('server.js'), { background: true }) | ||
| // => ['sh', '-c', 'nohup node server.js > /dev/null 2>&1 &'] | ||
| // Both options | ||
| cmd(npm.run('dev'), { cwd: '/app', background: true }) | ||
| // => ['sh', '-c', 'nohup cd "/app" && npm run dev > /dev/null 2>&1 &'] | ||
| // Let the sandbox handle execution options | ||
| await sandbox.runCommand('npm install', { cwd: '/app' }) | ||
| await sandbox.runCommand('node server.js', { background: true }) | ||
| await sandbox.runCommand('npm run dev', { | ||
| cwd: '/app', | ||
| background: true, | ||
| env: { NODE_ENV: 'production' } | ||
| }) | ||
| ``` | ||
| ### Shell-Specific Wrappers | ||
| ### Shell Wrapping (Advanced) | ||
| Use `sh`, `bash`, or `zsh` for explicit shell selection: | ||
| For cases where you need explicit shell wrapping, use `shell()`, `sh()`, `bash()`, or `zsh()`: | ||
| ```typescript | ||
| import { bash, zsh, npm } from '@computesdk/cmd'; | ||
| import { shell, bash, zsh, npm } from '@computesdk/cmd'; | ||
| // Default shell wrapper (sh) | ||
| shell(npm.install(), { cwd: '/app' }) | ||
| // => ['sh', '-c', 'cd "/app" && npm install'] | ||
| // Bash-specific | ||
| bash(npm.install(), { cwd: '/app' }) | ||
| // => ['bash', '-c', 'cd "/app" && npm install'] | ||
| // Zsh with background | ||
| zsh(npm.run('dev'), { background: true }) | ||
@@ -63,2 +66,4 @@ // => ['zsh', '-c', 'nohup npm run dev > /dev/null 2>&1 &'] | ||
| **Note:** Shell wrapping is rarely needed - prefer using `runCommand()` options instead. | ||
| ## Available Commands | ||
@@ -65,0 +70,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
213
2.4%285758
03333
-0.21%