Socket
Socket
Sign inDemoInstall

wsrun

Package Overview
Dependencies
Maintainers
3
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wsrun - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

build/cmd-process.d.ts

1

build/index.d.ts

@@ -0,1 +1,2 @@

#!/usr/bin/env node
export {};

@@ -5,13 +5,105 @@ #!/usr/bin/env node

const fs = require("fs");
const yargs_1 = require("yargs");
const yargs = require("yargs");
const _ = require("lodash");
const chalk_1 = require("chalk");
const parallelshell_1 = require("./parallelshell");
const run_graph_1 = require("./run-graph");
const workspace_1 = require("./workspace");
const bin = yargs_1.argv.bin || 'yarn';
yargs
.wrap(yargs.terminalWidth() - 1)
.updateStrings({
'Options:': 'Other Options:'
})
.usage('$0 [options] <command> [<arg1> <arg2> ...] ')
// Note: these examples are chained here as they do not show up otherwise
// when the required positional <command> is not specified
.example('$0 clean', 'Runs "yarn clean" in each of the packages in parallel')
.example('$0 -p app -r --stages build', 'Runs "yarn build" in app and all of its dependencies in stages, moving up the dependency tree')
.example('$0 --stages --done-criteria="Finished" watch', 'Runs "yarn watch" in each of the packages in stages, continuing when the process outputs "Finished"')
.example('$0 --exclude-missing test', 'Runs "yarn test" in all packages that have such a script')
.group(['parallel', 'stages', 'serial'], 'Mode (choose one):')
.options({
parallel: {
boolean: true,
describe: 'Fully parallel mode (default)'
},
stages: {
boolean: true,
describe: 'Run in stages: start with packages that have no deps'
},
serial: {
boolean: true,
describe: 'Same as "stages" but with no parallelism at the stage level'
}
})
.group('recursive', 'Package Options:')
.options({
package: {
alias: 'p',
describe: 'Run only for these packages',
type: 'array'
},
recursive: {
alias: 'r',
boolean: true,
describe: 'Execute the same script on all of its dependencies, too'
},
if: {
describe: 'Run main command only if this condition runs successfully'
},
ifDependency: {
describe: 'Run main command only if packages dependencies passed the condition (not available in parallel mode)',
boolean: true
}
})
.group([
'fast-exit',
'collect-logs',
'no-prefix',
'bin',
'done-criteria',
'exclude',
'exclude-missing',
'report'
], 'Misc Options:')
.options({
'fast-exit': {
boolean: true,
describe: 'If at least one script exits with code > 0, abort'
},
'collect-logs': {
boolean: true,
describe: 'Collect per-package output and print it at the end of each script'
},
'no-prefix': {
boolean: true,
describe: "Don't prefix output"
},
bin: {
default: 'yarn',
describe: 'The program to pass the command to',
type: 'string'
},
'done-criteria': {
describe: 'Consider a process "done" when an output line matches the specified RegExp'
},
exclude: {
type: 'string',
describe: 'Skip running the command for that package'
},
'exclude-missing': {
boolean: true,
describe: 'Skip packages which lack the specified command in the scripts section of their package.json'
},
report: {
boolean: true,
describe: 'Show an execution report once the command has finished in each package'
}
});
const argv = yargs.argv;
const bin = argv.bin || 'yarn';
let mode;
if (yargs_1.argv.stages) {
if (argv.stages) {
mode = 'stages';
}
else if (yargs_1.argv.serial) {
else if (argv.serial) {
mode = 'serial';

@@ -23,14 +115,14 @@ }

// should we run the command on all the dependencies, too?
const recursive = yargs_1.argv.recursive || yargs_1.argv.r || false;
const fastExit = yargs_1.argv.fastExit || false;
const collectLogs = yargs_1.argv.collectLogs || false;
const addPrefix = yargs_1.argv.prefix === undefined ? true : false;
const doneCriteria = yargs_1.argv.doneCriteria;
const exclude = (yargs_1.argv.exclude && (Array.isArray(yargs_1.argv.exclude) ? yargs_1.argv.exclude : [yargs_1.argv.exclude])) || [];
const excludeMissing = yargs_1.argv.excludeMissing || false;
const showReport = yargs_1.argv.report || false;
const cmd = yargs_1.argv._[0];
const pkgName = yargs_1.argv._[1];
if (!cmd) {
throw new Error('cmd is undefined');
const recursive = argv.recursive || argv.r || false;
const fastExit = argv.fastExit || false;
const collectLogs = argv.collectLogs || false;
const addPrefix = argv.prefix === undefined ? true : false;
const doneCriteria = argv.doneCriteria;
const exclude = (argv.exclude && (Array.isArray(argv.exclude) ? argv.exclude : [argv.exclude])) || [];
const excludeMissing = argv.excludeMissing || false;
const showReport = argv.report || false;
const cmd = argv._;
if (!cmd.length) {
yargs.showHelp();
process.exit(1);
}

@@ -43,3 +135,3 @@ const packageJsonWorkspaces = JSON.parse(fs.readFileSync('./package.json', 'utf8')).workspaces;

const pkgJsons = _.map(pkgs, pkg => pkg.json);
let runner = new parallelshell_1.RunGraph(pkgJsons, {
let runner = new run_graph_1.RunGraph(pkgJsons, {
bin,

@@ -55,2 +147,4 @@ fastExit,

showReport,
if: argv.if || null,
ifDependency: argv.ifDependency || false,
workspacePath: process.cwd()

@@ -63,3 +157,3 @@ }, pkgPaths);

}
let runlist = yargs_1.argv._.slice(1);
let runlist = argv.package || [];
runner.run(cmd, runlist.length > 0 ? runlist : undefined).then(hadError => {

@@ -66,0 +160,0 @@ if (hadError && fastExit) {

@@ -0,1 +1,4 @@

/**
* Remove me.
*/
export declare type Dict<T> = {

@@ -2,0 +5,0 @@ [key: string]: T;

{
"name": "wsrun",
"version": "3.0.0",
"version": "3.1.0",
"description": "executes commands on packages in parallel, but is aware of the dependencies between them",

@@ -10,6 +10,7 @@ "main": "./build/index.js",

"jest": {
"verbose": false,
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"testRegex": "(/tests/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [

@@ -21,2 +22,12 @@ "ts",

"json"
],
"testPathIgnorePatterns": [
"/src",
"/tmp",
"/node_modules/",
"\\.util\\.ts$"
],
"modulePathIgnorePatterns": [
"/src",
"/tmp"
]

@@ -35,8 +46,15 @@ },

"@types/lodash": "^4.14.85",
"@types/mkdirp": "^0.5.2",
"@types/mz": "^0.0.32",
"@types/node": "^8.0.53",
"@types/rimraf": "^2.0.2",
"@types/split": "^0.3.28",
"@types/yargs": "^8.0.2",
"@types/yargs": "^10.0.0",
"jest": "^21.2.1",
"mkdirp": "^0.5.1",
"mz": "^2.7.0",
"npm-run-all": "^4.1.3",
"rimraf": "^2.6.2",
"ts-jest": "^21.2.3",
"typescript": "^2.7.2"
"typescript": "^3.1.1"
},

@@ -48,6 +66,6 @@ "scripts": {

"test:watch": "jest --watch",
"dev": "run-p test:watch watch",
"prepublish": "tsc"
},
"dependencies": {
"@types/chalk": "^2.2.0",
"bluebird": "^3.5.1",

@@ -54,0 +72,0 @@ "chalk": "^2.3.0",

83

README.md
# Workspace script runner
Run npm scripts in a yarn workspace, like a boss.
Run npm scripts in a yarn workspace.

@@ -8,22 +8,31 @@ ### Usage:

```
wsrun cmd [<package>] [options]
wsrun [options] <command> [<arg1> <arg2> ...]
Options:
Mode (choose one):
--parallel fully parallel mode (default)
--stages run in stages; start with packages that have no deps.
--serial same as "stages", but with no parallelism at the stage level
Mode (choose one):
--parallel Fully parallel mode (default) [boolean]
--stages Run in stages: start with packages that have no deps [boolean]
--serial Same as "stages" but with no parallelism at the stage level [boolean]
Individual package opts:
-r, --recursive execute the same script on all of its dependencies, too
Package Options:
--recursive, -r Execute the same script on all of its dependencies, too [boolean]
Misc:
--fast-exit if at least one script exits with code > 0, abort
--collect-output collect per-package stdout, print everything at the end, grouped
--no-prefix don't prefix output
--bin=yarn which program should we pass the script to (default yarn)
--done-criteria=regex consider the process "done" when output line matches regex
--exclude pkgname skip actually running the script for that package
--exclude-missing skip packages which lack the specified script
--report show an execution report once all scripts are finished
Misc Options:
--fast-exit If at least one script exits with code > 0, abort [boolean]
--collect-logs Collect per-package output and print it at the end of each script [boolean]
--no-prefix Don't prefix output [boolean]
--bin The program to pass the command to [string] [default: "yarn"]
--done-criteria Consider a process "done" when an output line matches the specified RegExp
--exclude Skip running the command for that package [string]
--exclude-missing Skip packages which lack the specified command in the scripts section of their
package.json [boolean]
--report Show an execution report once the command has finished in each package
[boolean]
Other Options:
--help Show help [boolean]
--version Show version number [boolean]
--package, -p Run only for these packages [array]
--if Run main command only if this condition command runs successfully
--ifDependency Run main command only if packages dependencies passed the condition (not
available in parallel mode) [boolean]
```

@@ -35,18 +44,36 @@

`yarn wsrun build --stages` will build all packages, in stages, starting from those that don't
depend on other packages.
`yarn wsrun --stages build` will build all packages, in stages, starting from those that don't depend on other packages.
`yarn wsrun watch planc -r` will watch planc and all of its dependencies.
`yarn wsrun -p planc -r watch` will watch planc and all of its dependencies.
`yarn wsrun watch planc -r --exclude planc` will watch all of planc's dependencies but not planc
`yarn wsrun -p planc --exclude planc -r watch` will watch all of planc's dependencies but not planc
`yarn wsrun build h4zip -r --stages` will build all the deps. in order, then build h4zip
`yarn wsrun -p h4zip -r --stages build` will build all the deps. in order, then build h4zip
`yarn wsrun watch planc -r --stages --done-criteria='Compilation complete'` will watch planc deps,
in order, continuing when command outputs "Compilation complete"
`yarn wsrun -p planc --stages --done-criteria='Compilation complete' -r watch` will watch planc deps, in order, continuing when command outputs "Compilation complete"
`yarn wsrun clean` will remove "build" folders in every package.
`yarn wsrun --exclude-missing test` will run the test script only on packages that have it
`yarn wsrun test` will test every package.
To specify multiple packages, use `-p` several times:
`yarn wsrun test --exclude-missing` will run the test script only on packages that have it
`yarn wsrun -p h4zip -p planc test` - run tests for both h4zip and planc
If you want to pass additional arguments to the command you can do that by separating the command
with `--`:
`yarn wsrun -r --stages -- build -p tsconfig.alternative.json` - build all packages in stages with
an alternative tsconfig.json
When `--skip-missing` is not used, you can pass a command that doesn't exist in the scripts field:
`yarn wsrun -r --stages -- tsc -p tsconfig.alternative.json` - run tsc for all packages with an alternative tsconfig
#### Conditional execution
Conditional execution is supported with `--if` and `--if-dependency`
Examples
`yarn wsrun --stages --if build-needed build` - for each package it will first try `yarn wsrun build-needed` and only if the exit code is zero (success) it will run `yarn wsrun build`
`yarn wsrun --stages --if-build-needed --if-dependency build` - it will run `build` for each package in stages, if either the package's own condition command was success, or any of the dependencies had a successful condition.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc