Skip to content

Commit 2ea43a9

Browse files
refactor: updated dependency commander (#1400)
* refactor: updated dependency commander * fix: downgraded the major version update of commander again * refactor: updated dependency commander * refactor: updated dependency commander * refactor: updated dependency commander * refactor: updated dependency commander * refactor: updated dependency commander * build: regenerated yarn.lock * refactor: adapted "global" options example tj/commander.js#1708 * refactor: updated to the latest version Co-authored-by: Josef Bredreck <13408112+JosefBredereck@users.noreply.github.com>
1 parent 8e16c59 commit 2ea43a9

File tree

9 files changed

+29
-22
lines changed

9 files changed

+29
-22
lines changed

packages/cli/bin/cli-actions/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { error, info, wrapAsync } = require('../utils');
66
const build = (options) =>
77
wrapAsync(function* () {
88
try {
9-
const config = yield resolveConfig(options.parent.config);
9+
const config = yield resolveConfig(options.config);
1010
yield buildPatterns(config, options);
1111
info(`build: Yay, your Pattern Lab project was successfully built ☺`);
1212
} catch (err) {

packages/cli/bin/cli-actions/disable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const enable = (options) =>
3535
}
3636
});
3737
}
38-
yield writeJsonAsync(options.parent.config, config);
38+
yield writeJsonAsync(options.config, config);
3939
spinner.succeed(`⊙ patternlab → Updated config`);
4040
});
4141

packages/cli/bin/cli-actions/enable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const enable = (options) =>
3333
}
3434
});
3535
}
36-
yield writeJsonAsync(options.parent.config, config);
36+
yield writeJsonAsync(options.config, config);
3737
spinner.succeed(`⊙ patternlab → Updated config`);
3838
});
3939

packages/cli/bin/cli-actions/export.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const wrapAsync = require('../utils').wrapAsync;
55

66
const _export = (options) =>
77
wrapAsync(function* () {
8-
const config = yield resolveConfig(options.parent.config);
8+
const config = yield resolveConfig(options.config);
99
archive(config);
1010
});
1111

packages/cli/bin/cli-actions/install.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const writeJsonAsync = require('../utils').writeJsonAsync;
1313
*/
1414
const install = (options) =>
1515
wrapAsync(function* () {
16-
const config = yield resolveConfig(options.parent.config);
16+
const config = yield resolveConfig(options.config);
1717

1818
const spinner = ora(
1919
`⊙ patternlab → Installing additional resources …`
@@ -58,7 +58,7 @@ const install = (options) =>
5858
`⊙ patternlab → Installed following plugins: ${plugins.join(', ')}`
5959
);
6060
}
61-
yield writeJsonAsync(options.parent.config, config);
61+
yield writeJsonAsync(options.config, config);
6262
spinner.succeed(`⊙ patternlab → Updated config`);
6363
});
6464

packages/cli/bin/cli-actions/serve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const wrapAsync = require('../utils').wrapAsync;
55

66
const serve = (options) =>
77
wrapAsync(function* () {
8-
const config = yield resolveConfig(options.parent.config);
8+
const config = yield resolveConfig(options.config);
99
servePatterns(config, options);
1010
});
1111

packages/cli/bin/patternlab.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env node
22
/* eslint-disable no-unused-vars */
33
'use strict';
4-
const cli = require('commander');
4+
const { Command } = require('commander');
5+
const cli = new Command();
56
const path = require('path');
67
const build = require('./cli-actions/build');
78
const disable = require('./cli-actions/disable');
@@ -38,15 +39,7 @@ const list = (val) => val.split(',');
3839
cli
3940
.version(version(pkg), '-V, --version')
4041
.usage('<cmd> [options]')
41-
.arguments('<cmd> [options]')
42-
.option(
43-
'-c, --config <path>',
44-
'Specify config file. Default looks up the project dir',
45-
(val) => val.trim(),
46-
path.resolve(process.cwd(), 'patternlab-config.json')
47-
)
48-
.option('-v, --verbose', 'Show verbose console logs', verboseLogs)
49-
.option('--silent', 'Turn off console logs', silenceLogs);
42+
.arguments('<cmd> [options]');
5043

5144
/**
5245
* build
@@ -134,6 +127,20 @@ cli
134127
.option('--no-watch', 'Start watching for changes')
135128
.action(serve);
136129

130+
// Common options can be added manually after setting up program and subcommands.
131+
// If the options are unsorted in the help, these will appear last.
132+
cli.commands.forEach((command) => {
133+
command
134+
.option(
135+
'-c, --config <path>',
136+
'Specify config file. Default looks up the project dir',
137+
(val) => val.trim(),
138+
path.resolve(process.cwd(), 'patternlab-config.json')
139+
)
140+
.option('-v, --verbose', 'Show verbose console logs', verboseLogs)
141+
.option('--silent', 'Turn off console logs', silenceLogs);
142+
});
143+
137144
// Show additional help
138145
cli.on('--help', help);
139146

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@pattern-lab/core": "^5.17.0",
1313
"archiver": "5.3.0",
1414
"chalk": "4.1.0",
15-
"commander": "6.2.1",
15+
"commander": "9.4.1",
1616
"deepmerge": "^4.2.2",
1717
"execa": "5.0.0",
1818
"fs-extra": "10.0.0",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4676,10 +4676,10 @@ commander@2.17.x:
46764676
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
46774677
integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==
46784678

4679-
commander@6.2.1:
4680-
version "6.2.1"
4681-
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c"
4682-
integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==
4679+
commander@9.4.1:
4680+
version "9.4.1"
4681+
resolved "https://registry.yarnpkg.com/commander/-/commander-9.4.1.tgz#d1dd8f2ce6faf93147295c0df13c7c21141cfbdd"
4682+
integrity sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==
46834683

46844684
commander@^2.19.0, commander@^2.2.0, commander@^2.20.0:
46854685
version "2.20.3"

0 commit comments

Comments
 (0)