Skip to content

Commit 4135ce3

Browse files
committed
add cli options support
1 parent e8652bc commit 4135ce3

File tree

10 files changed

+1215
-1191
lines changed

10 files changed

+1215
-1191
lines changed

packages/vest/types/vest.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,6 @@ declare const _default: typeof testBase & {
341341
};
342342
};
343343
declare const test: typeof _default;
344-
declare const VERSION = '1.0.31';
344+
declare const VERSION = '3.2.3';
345345
export { test, create, only, skip, warn, group, optional, enforce, VERSION };
346346
//# sourceMappingURL=vest.d.ts.map

packages/vest/types/vest.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

vx/cli.js

+27-8
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@ const glob = require('glob');
66
const { hideBin } = require('yargs/helpers');
77
const yargs = require('yargs/yargs');
88

9-
const packageNames = require('./util/packageNames');
9+
const packageNames = require('vx/packageNames');
1010
const vxPath = require('vx/vxPath');
1111

12-
require('./scripts/genTsConfig');
13-
14-
const { _: args, ...options } = yargs(hideBin(process.argv)).argv;
15-
16-
const [command, target = insidePackageDir()] = args;
17-
1812
const commands = glob
1913
.sync(`./commands/*.js`, {
2014
cwd: vxPath.VX_ROOT_PATH,
@@ -27,11 +21,36 @@ const commands = glob
2721
{}
2822
);
2923

24+
require('./scripts/genTsConfig');
25+
26+
const argv = hideBin(process.argv);
27+
28+
const cli = yargs(argv)
29+
.command('$0 <command> [options..]', 'Run vx monorepo utility', yargs => {
30+
yargs.positional('command', {
31+
describe: 'Command to run',
32+
choices: Object.keys(commands),
33+
demandOption: true,
34+
});
35+
})
36+
.option('packageName', {
37+
alias: 'p',
38+
choices: packageNames.list,
39+
demandOption: false,
40+
describe: 'Optional. Package to run the command on.',
41+
})
42+
.help().argv;
43+
44+
// is there a better way of doing this?
45+
const options = argv.slice(cli.packageName ? 3 : 1).join(' ');
46+
47+
const { packageName = insidePackageDir(), command } = cli;
48+
3049
if (!commands[command]) {
3150
throw new Error(`Command ${command} not found.`);
3251
}
3352

34-
commands[command](target, options);
53+
commands[command](packageName, options);
3554

3655
function insidePackageDir() {
3756
if (!process.cwd().includes(vxPath.PACKAGES_PATH)) {

vx/commands/build.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const exec = require('vx/exec');
22

3-
function build(packageName, { watch } = {}) {
3+
function build(packageName, options) {
44
if (!packageName) {
5-
exec([`yarn workspaces run vx buildPackage`, watch && '--watch']);
5+
exec([`yarn workspaces run vx buildPackage`, options]);
66
} else {
7-
exec([`yarn workspace ${packageName} vx buildPackage`, watch && '--watch']);
7+
exec([`yarn workspace ${packageName} vx buildPackage`, options]);
88
}
99
}
1010

vx/commands/test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const configOpt = `--config ${path.resolve(
88
'jest.config.js'
99
)}`;
1010

11-
function test(packageName, { watch }) {
11+
function test(packageName, options) {
1212
if (!packageName) {
13-
exec([`jest ./packages/*`, configOpt, watch && '--watch']);
13+
exec([`jest ./packages/*`, configOpt, options]);
1414
} else {
15-
exec([`yarn workspace ${packageName} jest`, configOpt, watch && '--watch']);
15+
exec([`yarn workspace ${packageName} jest`, configOpt, options]);
1616
}
1717
}
1818

File renamed without changes.

vx/scripts/build/buildPackage.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ const logger = require('vx/logger');
77
const packageName = require('vx/packageName');
88
const vxPath = require('vx/vxPath');
99

10-
function buildPackage(name = packageName(), { watch } = {}) {
10+
function buildPackage(name = packageName(), options) {
1111
logger.info(`🛠 Building package: ${name}`);
1212

1313
fse.removeSync(vxPath.packageDist());
1414

15-
exec([`rollup -c`, vxPath.ROLLUP_CONFIG_PATH, watch && '--watch']);
15+
exec([`rollup -c`, vxPath.ROLLUP_CONFIG_PATH, options]);
1616

1717
writeMainTemplate(packageName(), vxPath.packageDist(packageName()));
1818
}

vx/scripts/release/steps/pushToLatestBranch.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ const path = require('path');
22

33
const { sample } = require('lodash');
44

5-
const exec = require('vx/exec');
6-
const logger = require('vx/logger');
75
const packageJson = require('../../../util/packageJson');
8-
const packageNames = require('../../../util/packageNames');
9-
const vxPath = require('vx/vxPath');
106
const listAllChangesSinceStableBranch = require('../github/listAllChangesSinceStableBranch');
117
const matchPackageNameInCommit = require('../github/matchPackageNameInCommit');
128

9+
const exec = require('vx/exec');
10+
const logger = require('vx/logger');
11+
const packageNames = require('vx/packageNames');
12+
const vxPath = require('vx/vxPath');
13+
1314
const SCRIPT_PATH = path.resolve(
1415
vxPath.ROOT_PATH,
1516
'scripts',

vx/scripts/release/steps/updateDocs.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ const path = require('path');
22

33
const fse = require('fs-extra');
44

5-
const packageNames = require('../../../util/packageNames');
6-
75
const logger = require('vx/logger');
6+
const packageNames = require('vx/packageNames');
87
const vxPath = require('vx/vxPath');
98

109
const DOCS = 'docs';

0 commit comments

Comments
 (0)