@grnx/sx v0.1.0
Sorry-Nx
Sorry-Nx is a tiny alternative to the Nx Runner CLI, providing comprehensive task running capabilities.
It supports 4 package managers, dependency graphs, custom schemas, multitasking, and more.
The library seamlessly integrates with package.json scripts, making it a flexible choice for your project needs.
Quick Features
- ๐งจ Comprehensive TypeScript support
- ๐คฏ Faster task executions
- ๐ข Out-of-the-box support for npm, yarn, pnpm, and bun
- ๐ฃ Custom configuration
- ๐ฟ Nx-like schemas (project.json)
- ๐ฅ Interactive mode
- ๐ Schema generation
Table of Contents
Installation
You can install sorry-nx via your preferred package manager:
# using pnpm
$ pnpm add -g @grnx/sx
# using yarn
$ bun install -g @grnx/sx
# using npm
$ npm install -g @grnx/sxUsage
sx - Run Target
Execute a command defined in project targets or package.json scripts.
It automatically detects your package manager and is built on the workspaces pattern.
sx serve frontend
# npm run serve --workspace=frontend --silent
# yarn --silent workspace frontend run serve
# pnpm --filter=frontend run serve --silent
# cd ~/my-prj/frontend && bun run frontend --silentFor the root workspace:
sx serve
# with extra options
sx serve --parallel --envFile .env.development
sx serve --cwd ~/dsk/backendInteractive Mode
Running the command without arguments initiates the interactive mode, allowing you to select projects and commands to run.
sx # without argumentssx run-many - Run Multiple Commands
Run multiple targets and multiple projects. (similar to nx/run-many).
sx run-many --parallel=3 projects=frontend,backend
sx run-many --parallel=10 exclude=backend
sx run-many --alltargets.json - Schemas
Define custom configurations for each script, similar to Nx project.json.
Create a targets.json file in the root of each workspace.
.
+-- targets.json
`-- packages
+-- frontend
| `-- targets.json
`-- backend
`-- targets.jsonExample of targets.json
{
"build": "vite build",
"preview": {
"description": "Add description here",
"commands": ["vite preview", "rimraf tmp/logs"],
"args": "--host 127.0.0.1",
"cwd": "packages/frontend",
"parallel": true,
"envFile": ".env.production"
},
"dev": {
"command": "vite dev",
"env": {
"VITE_PORT": 3000
}
}
}sx migrate - Migrate from package.json Scripts
Generate a targets.json file from package.json scripts for the project. Works for all nested projects with the all flag.
sx migrate frontend
sx migrate --all # deep migration to targets.jsonsx show - Show Workspace Projects
Display the dependency graph, structured on workspaces using any package manager.
sx show
sx show --json # json format# output
@nx/react-native - /home/grnx/hub/nx/packages/react-native
@nx/remix - /home/grnx/hub/nx/packages/remix
@nx/rollup - /home/grnx/hub/nx/packages/rollup
@nx/storybook - /home/grnx/hub/nx/packages/storybookConfiguration
; .sxrc
preferredResolvingOrder[] = package-scripts
preferredResolvingOrder[] = targets
; default = targets.json
commandsFile = commands.jsonSet a custom configuration file path:
# ~/.bashrc
export SX_CONFIG_FILE="$HOME/.sxrc"For Windows:
# Set a custom configuration file path in PowerShell accessible within the `$profile` path
$Env:SX_CONFIG_FILE = 'C:\to\your\config\location'Contribution: If you encounter any bugs, please submit an issue.
2 years ago