Skip to content

Commit 6309e69

Browse files
committed
feat(API): standardize v() and version() into a single call
BREAKING CHANGE: change `version()` to return a string representation of the version, removing `v()`
1 parent f5b60b2 commit 6309e69

File tree

5 files changed

+11
-28
lines changed

5 files changed

+11
-28
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ const config = Object.assign(patternlab.getDefaultConfig(), {
55
});
66

77
module.exports = ({ version }) =>
8-
`${version} (PatternLab Node Core version: ${patternlab(config).v()})`;
8+
`${version} (PatternLab Node Core version: ${patternlab(config).version()})`;

packages/core/docs/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ Many of these functions are exposed to users within [Editions](https://github.co
2626
Returns the standardized default config used to run Pattern Lab. This method can be called statically or after instantiation.
2727

2828
**Returns**: <code>object</code> - Returns the object representation of the `patternlab-config.json`
29-
## `version()` ⇒ <code>void</code>
30-
31-
Logs current version to standard output
32-
33-
**Returns**: <code>void</code> - current patternlab-node version as defined in `package.json`
34-
## `v()` ⇒ <code>string</code>
29+
## `version()` ⇒ <code>string</code>
3530

3631
Returns current version
3732

@@ -63,7 +58,7 @@ Many of these functions are exposed to users within [Editions](https://github.co
6358

6459
Logs usage to standard output
6560

66-
**Returns**: <code>void</code> - pattern lab API usage, as console output
61+
**Returns**: <code>void</code> - Pattern Lab API usage, as console output
6762
## `installplugin(pluginName)` ⇒ <code>void</code>
6863

6964
Installs plugin already available via `node_modules/`

packages/core/src/index.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
const updateNotifier = require('update-notifier');
1414

1515
const packageInfo = require('../package.json');
16-
const buildPatterns = require('./lib/buildPatterns');
1716
const help = require('./lib/help');
1817
const events = require('./lib/events');
19-
const loaduikits = require('./lib/loaduikits');
20-
const logger = require('./lib/log');
2118
const pe = require('./lib/pattern_exporter');
2219

2320
const defaultConfig = require('../patternlab-config.json');
2421

22+
let buildPatterns = require('./lib/buildPatterns'); // eslint-disable-line
23+
let loaduikits = require('./lib/loaduikits'); // eslint-disable-line
24+
let logger = require('./lib/log'); // eslint-disable-line
2525
let fs = require('fs-extra'); // eslint-disable-line
2626
let ui_builder = require('./lib/ui_builder'); // eslint-disable-line
2727
let copier = require('./lib/copier'); // eslint-disable-line
@@ -44,25 +44,16 @@ const getDefaultConfig = function() {
4444
};
4545

4646
const patternlab_module = function(config) {
47-
const PatternLab = require('./lib/patternlab');
48-
const patternlab = new PatternLab(config);
47+
const PatternLabClass = require('./lib/patternlab');
48+
const patternlab = new PatternLabClass(config);
4949

5050
return {
51-
/**
52-
* Logs current version to standard output
53-
*
54-
* @returns {void} current patternlab-node version as defined in `package.json`
55-
*/
56-
version: function() {
57-
return patternlab.logVersion();
58-
},
59-
6051
/**
6152
* Returns current version
6253
*
6354
* @returns {string} current patternlab-node version as defined in `package.json`, as string
6455
*/
65-
v: function() {
56+
version: function() {
6657
return patternlab.getVersion();
6758
},
6859

@@ -155,7 +146,7 @@ const patternlab_module = function(config) {
155146
/**
156147
* Logs usage to standard output
157148
*
158-
* @returns {void} pattern lab API usage, as console output
149+
* @returns {void} Pattern Lab API usage, as console output
159150
*/
160151
help: function() {
161152
logger.info(help(patternlab.package.version));

packages/core/src/lib/patternlab.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@ module.exports = class PatternLab {
225225
getVersion() {
226226
return this.package.version;
227227
}
228-
logVersion() {
229-
logger.info(this.package.version);
230-
}
231228
getSupportedTemplateExtensions() {
232229
return this.engines.getSupportedFileExtensions();
233230
}

packages/edition-node-gulp/gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function serve() {
3434
}
3535

3636
gulp.task('patternlab:version', function() {
37-
patternlab.version();
37+
console.log(patternlab.version());
3838
});
3939

4040
gulp.task('patternlab:help', function() {

0 commit comments

Comments
 (0)