
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
@xec-sh/core
Advanced tools
Universal execution engine providing a unified API for running commands across local, SSH, Docker, and Kubernetes environments.
npm install @xec-sh/core
import { $ } from '@xec-sh/core';
// Local execution
await $`echo "Hello, World!"`;
// Variables are automatically escaped
const filename = "file with spaces.txt";
await $`touch ${filename}`;
// Error handling
const result = await $`grep pattern file.txt`.nothrow();
if (!result.ok) {
console.log('Pattern not found');
}
const ssh = $.ssh({ host: 'server.com', username: 'user' });
// Execute commands
await ssh`uname -a`;
await ssh`df -h`;
// File transfer
await ssh.uploadFile('./local.txt', '/remote/path.txt');
await ssh.downloadFile('/remote/file.txt', './local-copy.txt');
// SSH tunnels
const tunnel = await ssh.tunnel({
localPort: 5433,
remoteHost: 'localhost',
remotePort: 5432
});
// Execute in existing container
const docker = $.docker({ container: 'my-app' });
await docker`ps aux`;
// Create new container
const container = await $.docker({
image: 'node:18',
name: 'test-container'
}).start();
await container.exec`npm test`;
await container.stop();
await container.remove();
const k8s = $.k8s({ namespace: 'default' });
const pod = k8s.pod('my-app-pod');
// Execute commands
await pod.exec`hostname`;
// Stream logs
await pod.follow(line => console.log(line));
// Port forwarding
const forward = await pod.portForward(8080, 80);
console.log(`Access at localhost:${forward.localPort}`);
import { parallel } from '@xec-sh/core';
const results = await parallel([
$`npm install`,
$`npm run build`,
$`npm test`
], { maxConcurrent: 2 });
// Global configuration
import { configure } from '@xec-sh/core';
configure({
shell: '/bin/bash',
timeout: 30000,
env: { NODE_ENV: 'production' }
});
// Per-command configuration
await $`npm test`
.cwd('/app')
.env({ NODE_ENV: 'test' })
.timeout(60000)
.retry(3);
$.on('command:start', (event) => {
console.log(`Starting: ${event.command}`);
});
$.on('command:error', (event) => {
console.error(`Failed: ${event.error.message}`);
});
$
- Main execution function$.ssh()
- SSH adapter$.docker()
- Docker adapter$.k8s()
- Kubernetes adapterconfigure()
- Global configurationparallel()
- Parallel executionescapeShellArg()
- Shell argument escapingquoteShellArg()
- Shell argument quotingRuntimeDetector
- Runtime detectionProcessPromise
- Promise-based process handlingMIT © Xec Contributors
FAQs
Universal shell execution engine
The npm package @xec-sh/core receives a total of 252 weekly downloads. As such, @xec-sh/core popularity was classified as not popular.
We found that @xec-sh/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.