Skip to content

Commit

Permalink
refactor: updated dependency commander (#1400)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
mfranzke and JosefBredereck authored Jan 7, 2023
1 parent 8e16c59 commit 2ea43a9
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/cli/bin/cli-actions/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { error, info, wrapAsync } = require('../utils');
const build = (options) =>
wrapAsync(function* () {
try {
const config = yield resolveConfig(options.parent.config);
const config = yield resolveConfig(options.config);
yield buildPatterns(config, options);
info(`build: Yay, your Pattern Lab project was successfully built ☺`);
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/cli-actions/disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const enable = (options) =>
}
});
}
yield writeJsonAsync(options.parent.config, config);
yield writeJsonAsync(options.config, config);
spinner.succeed(`⊙ patternlab → Updated config`);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/cli-actions/enable.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const enable = (options) =>
}
});
}
yield writeJsonAsync(options.parent.config, config);
yield writeJsonAsync(options.config, config);
spinner.succeed(`⊙ patternlab → Updated config`);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/cli-actions/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const wrapAsync = require('../utils').wrapAsync;

const _export = (options) =>
wrapAsync(function* () {
const config = yield resolveConfig(options.parent.config);
const config = yield resolveConfig(options.config);
archive(config);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/bin/cli-actions/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const writeJsonAsync = require('../utils').writeJsonAsync;
*/
const install = (options) =>
wrapAsync(function* () {
const config = yield resolveConfig(options.parent.config);
const config = yield resolveConfig(options.config);

const spinner = ora(
`⊙ patternlab → Installing additional resources …`
Expand Down Expand Up @@ -58,7 +58,7 @@ const install = (options) =>
`⊙ patternlab → Installed following plugins: ${plugins.join(', ')}`
);
}
yield writeJsonAsync(options.parent.config, config);
yield writeJsonAsync(options.config, config);
spinner.succeed(`⊙ patternlab → Updated config`);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/cli-actions/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const wrapAsync = require('../utils').wrapAsync;

const serve = (options) =>
wrapAsync(function* () {
const config = yield resolveConfig(options.parent.config);
const config = yield resolveConfig(options.config);
servePatterns(config, options);
});

Expand Down
27 changes: 17 additions & 10 deletions packages/cli/bin/patternlab.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node
/* eslint-disable no-unused-vars */
'use strict';
const cli = require('commander');
const { Command } = require('commander');
const cli = new Command();
const path = require('path');
const build = require('./cli-actions/build');
const disable = require('./cli-actions/disable');
Expand Down Expand Up @@ -38,15 +39,7 @@ const list = (val) => val.split(',');
cli
.version(version(pkg), '-V, --version')
.usage('<cmd> [options]')
.arguments('<cmd> [options]')
.option(
'-c, --config <path>',
'Specify config file. Default looks up the project dir',
(val) => val.trim(),
path.resolve(process.cwd(), 'patternlab-config.json')
)
.option('-v, --verbose', 'Show verbose console logs', verboseLogs)
.option('--silent', 'Turn off console logs', silenceLogs);
.arguments('<cmd> [options]');

/**
* build
Expand Down Expand Up @@ -134,6 +127,20 @@ cli
.option('--no-watch', 'Start watching for changes')
.action(serve);

// Common options can be added manually after setting up program and subcommands.
// If the options are unsorted in the help, these will appear last.
cli.commands.forEach((command) => {
command
.option(
'-c, --config <path>',
'Specify config file. Default looks up the project dir',
(val) => val.trim(),
path.resolve(process.cwd(), 'patternlab-config.json')
)
.option('-v, --verbose', 'Show verbose console logs', verboseLogs)
.option('--silent', 'Turn off console logs', silenceLogs);
});

// Show additional help
cli.on('--help', help);

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@pattern-lab/core": "^5.17.0",
"archiver": "5.3.0",
"chalk": "4.1.0",
"commander": "6.2.1",
"commander": "9.4.1",
"deepmerge": "^4.2.2",
"execa": "5.0.0",
"fs-extra": "10.0.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4676,10 +4676,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==

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

commander@^2.19.0, commander@^2.2.0, commander@^2.20.0:
version "2.20.3"
Expand Down

0 comments on commit 2ea43a9

Please sign in to comment.