Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2aa0f8f
feat(package): revamp plugin-tab
bmuenzenmeyer Jul 3, 2018
4ae13ce
fix(cli): support scoped plugins
bmuenzenmeyer Jul 3, 2018
0f227a3
fix(docs): update event info with tab example
bmuenzenmeyer Jul 3, 2018
0850fd6
feat(API): remove reliance on patternlab object during plugin install
bmuenzenmeyer Jul 3, 2018
197fc35
chore(core): WIP initialize plugins
bmuenzenmeyer Jul 3, 2018
44f0f8e
fix(plugins): support scoped packages
bmuenzenmeyer Jul 3, 2018
066e6c9
chore(core): WIP initialize plugins
bmuenzenmeyer Jul 3, 2018
0071a85
Merge branch 'dev' into plugin-work
bmuenzenmeyer Jul 3, 2018
5293975
chore(package): code cleanup
bmuenzenmeyer Jul 3, 2018
45583f8
fix(package): fix pathing and naming issues
bmuenzenmeyer Jul 3, 2018
bc2a0d3
chore(package): cleanup
bmuenzenmeyer Jul 3, 2018
29f0bb4
Make default config directory agnostic. Fix kepabCasing beaking installs
raphaelokon Jul 9, 2018
5a58824
feat(core): remove plugin install / disable / enable logic
bmuenzenmeyer Jul 17, 2018
0abfb7b
chore(cli): remove kebabbing of plugin name
bmuenzenmeyer Jul 17, 2018
3a6582c
refactor(cli): always use same options when writing JSON
bmuenzenmeyer Jul 17, 2018
88cce3f
fix(cli): set initialized to false during plugin installation
bmuenzenmeyer Jul 17, 2018
be68cff
Merge branch 'dev' into plugin-work
bmuenzenmeyer Jul 17, 2018
992ebce
chore(utils): fix merge booboo
bmuenzenmeyer Jul 17, 2018
6c8af4f
chore(package): pin dependencies
bmuenzenmeyer Jul 17, 2018
a1a9779
fix(postinstall): fix typo in name
bmuenzenmeyer Jul 17, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 7 additions & 32 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,102 +4,77 @@ All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="0.0.1-alpha.22"></a>

## [0.0.1-alpha.22](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.21...@pattern-lab/cli@0.0.1-alpha.22) (2018-07-06)

**Note:** Version bump only for package @pattern-lab/cli





<a name="0.0.1-alpha.21"></a>
## [0.0.1-alpha.21](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.20...@pattern-lab/cli@0.0.1-alpha.21) (2018-07-06)

## [0.0.1-alpha.21](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.20...@pattern-lab/cli@0.0.1-alpha.21) (2018-07-06)

### Bug Fixes

* **install:** add break statements to install edition command ([3b1813c](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/3b1813c))
* **install:** use process to find package.json ([200c7cb](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/200c7cb))


### Features

* **package:** add npmrc file ([55f5bc2](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/55f5bc2))
* **package:** pin all dependencies ([415698e](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/415698e))
* **package:** remove package-lock.json files ([5ab3995](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/5ab3995))





<a name="0.0.1-alpha.20"></a>
## [0.0.1-alpha.20](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.19...@pattern-lab/cli@0.0.1-alpha.20) (2018-07-05)

## [0.0.1-alpha.20](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.19...@pattern-lab/cli@0.0.1-alpha.20) (2018-07-05)

### Bug Fixes

* **cli:** change whitespace to spaces per standard ([4556fc7](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/4556fc7))
* **tests:** change test command name similar to live-server until this passes CI ([5c39be1](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/5c39be1))


### Features

* **serve:** change calling method ([3b86a0d](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/3b86a0d))
* **tests:** use lerna run test at the monorepo level ([38a01b1](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/38a01b1))




<a name="0.0.1-alpha.19"></a>
## [0.0.1-alpha.19](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.18...@pattern-lab/cli@0.0.1-alpha.19) (2018-05-19)

## [0.0.1-alpha.19](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.18...@pattern-lab/cli@0.0.1-alpha.19) (2018-05-19)

### Bug Fixes

* **cli:** change line-endings of cli entrypoint ([3fc86c2](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/3fc86c2))
* **wording:** reconcile Pattern Lab vs PatternLab ([f3d1e0d](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/f3d1e0d))




<a name="0.0.1-alpha.18"></a>
## [0.0.1-alpha.18](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.17...@pattern-lab/cli@0.0.1-alpha.18) (2018-05-04)

## [0.0.1-alpha.18](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.17...@pattern-lab/cli@0.0.1-alpha.18) (2018-05-04)

### Bug Fixes

* **version:** use static core method getVersion ([f9dcd4d](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/f9dcd4d))




<a name="0.0.1-alpha.17"></a>
## [0.0.1-alpha.17](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.16...@pattern-lab/cli@0.0.1-alpha.17) (2018-05-04)

## [0.0.1-alpha.17](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.16...@pattern-lab/cli@0.0.1-alpha.17) (2018-05-04)

### Bug Fixes

* **package:** update publish config and installation target ([27d2c8f](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/27d2c8f))




<a name="0.0.1-alpha.16"></a>
## [0.0.1-alpha.16](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.15...@pattern-lab/cli@0.0.1-alpha.16) (2018-05-04)

## [0.0.1-alpha.16](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.15...@pattern-lab/cli@0.0.1-alpha.16) (2018-05-04)

### Features

* **API:** standardize v() and version() into a single call ([6309e69](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/commit/6309e69))


### BREAKING CHANGES

* **API:** change `version()` to return a string representation of the version, removing `v()`




<a name="0.0.1-alpha.15"></a>

## [0.0.1-alpha.15](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/@pattern-lab/cli@0.0.1-alpha.14...@pattern-lab/cli@0.0.1-alpha.15) (2018-03-21)
Expand Down
20 changes: 19 additions & 1 deletion packages/cli/bin/install-plugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const path = require('path');

const _ = require('lodash');

const checkAndInstallPackage = require('./utils').checkAndInstallPackage;
const wrapAsync = require('./utils').wrapAsync;

Expand All @@ -8,7 +12,21 @@ const installPlugin = (plugin, config) =>
const name = plugin.name || plugin;
yield checkAndInstallPackage(name);
// Put the installed plugin in the patternlab-config.json
_.set(config, `plugins[${name}]['enabled']`, false);
_.set(config, `plugins[${name}]['enabled']`, true);
_.set(config, `plugins[${name}]['initialized']`, false);

// Get the options from the plugin, if any
const pluginPathConfig = path.resolve(
path.join(process.cwd(), 'node_modules', name, 'config.json')
);
try {
const pluginConfigJSON = require(pluginPathConfig);
if (!_.has(config.plugins[name].options)) {
_.set(config, `plugins[${name}]['options]`, pluginConfigJSON);
}
} catch (ex) {
//a config.json file is not required at this time
}
return name;
});

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/bin/patternlab.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
'use strict';
const cli = require('commander');
const path = require('path');
const build = require('./cli-actions/build');
const disable = require('./cli-actions/disable');
const enable = require('./cli-actions/enable');
Expand Down Expand Up @@ -42,7 +43,7 @@ cli
'-c, --config <path>',
'Specify config file. Default looks up the project dir',
val => val.trim(),
'./patternlab-config.json'
path.resolve(process.cwd(), 'patternlab-config.json')
)
.option('-v, --verbose', 'Show verbose console logs', verboseLogs)
.option('--silent', 'Turn off console logs', silenceLogs);
Expand Down
24 changes: 21 additions & 3 deletions packages/cli/bin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,39 @@ const checkAndInstallPackage = (packageName, url) =>
*/
const noop = () => {};

/**
* @func writeJsonAsync
* Wrapper for fs.writeJsonAsync with consistent spacing
* @param {string} filePath
* @param {object} data
*/
const writeJsonAsync = (filePath, data) =>
wrapAsync(function*() {
yield fs.outputJSON(filePath, data, { spaces: 2 });
});

/**
* @func getJSONKey
* Installs package, then returns the value for the given JSON file's key within
* @param {string} packageName - the node_module to install / load
* @param {object} key - the key to find
* @param {object} fileName - the filePath of the JSON
*/
const getJSONKey = (packageName, key, fileName = 'package.json') =>
wrapAsync(function*() {
yield checkAndInstallPackage(packageName);
const packageJSON = yield fs.readJson(
const jsonData = yield fs.readJson(
path.resolve('node_modules', packageName, fileName)
);
return packageJSON[key];
return jsonData[key];
});

module.exports = {
copyWithPattern,
copyAsync: fs.copy,
mkdirsAsync: fs.mkdirs,
moveAsync: fs.move,
writeJsonAsync: fs.outputJson,
writeJsonAsync: writeJsonAsync,
readJsonAsync: fs.readJson,
error,
info,
Expand Down
54 changes: 27 additions & 27 deletions packages/cli/test/cli-init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ const wrapAsync = require('../bin/utils').wrapAsync;
const projectRoot = getUniqueProjectPath();

tap.test('Init ->', t =>
wrapAsync(function*() {
yield spawnCmd([
'init',
'--verbose',
'--project-dir',
projectRoot,
'--edition',
'@pattern-lab/edition-node',
'--starterkit',
'@pattern-lab/starterkit-mustache-base',
]);
t.ok(
exists.sync(path.resolve(projectRoot)),
'should initialize a Pattern Lab project'
);
t.ok(exists.sync(path.resolve(projectRoot, 'source')), 'with a source dir');
t.ok(exists.sync(path.resolve(projectRoot, 'public')), 'with a public dir');
t.ok(
exists.sync(path.resolve(projectRoot, 'pattern_exports')),
'with a pattern_exports dir'
);
t.ok(
exists.sync(path.resolve(projectRoot, 'patternlab-config.json')),
'with a pattern_exports dir'
);
t.end();
})
wrapAsync(function*() {
yield spawnCmd([
'init',
'--verbose',
'--project-dir',
projectRoot,
'--edition',
'@pattern-lab/edition-node',
'--starterkit',
'@pattern-lab/starterkit-mustache-base',
]);
t.ok(
exists.sync(path.resolve(projectRoot)),
'should initialize a Pattern Lab project'
);
t.ok(exists.sync(path.resolve(projectRoot, 'source')), 'with a source dir');
t.ok(exists.sync(path.resolve(projectRoot, 'public')), 'with a public dir');
t.ok(
exists.sync(path.resolve(projectRoot, 'pattern_exports')),
'with a pattern_exports dir'
);
t.ok(
exists.sync(path.resolve(projectRoot, 'patternlab-config.json')),
'with a pattern_exports dir'
);
t.end();
})
);
29 changes: 5 additions & 24 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,24 @@ All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="3.0.0-alpha.16"></a>

# [3.0.0-alpha.16](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.15...@pattern-lab/core@3.0.0-alpha.16) (2018-07-06)

**Note:** Version bump only for package @pattern-lab/core





<a name="3.0.0-alpha.15"></a>
# [3.0.0-alpha.15](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.14...@pattern-lab/core@3.0.0-alpha.15) (2018-07-06)

# [3.0.0-alpha.15](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.14...@pattern-lab/core@3.0.0-alpha.15) (2018-07-06)

### Features

* **package:** add npmrc file ([55f5bc2](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/55f5bc2))
* **package:** pin all dependencies ([415698e](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/415698e))
* **package:** remove package-lock.json files ([5ab3995](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/5ab3995))





<a name="3.0.0-alpha.14"></a>
# [3.0.0-alpha.14](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.13...@pattern-lab/core@3.0.0-alpha.14) (2018-07-05)

# [3.0.0-alpha.14](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.13...@pattern-lab/core@3.0.0-alpha.14) (2018-07-05)

### Bug Fixes

Expand All @@ -38,7 +31,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
* **viewall:** fix viewall generation ([543558a](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/543558a))
* **watch:** wire up serve and watch listeners correctly ([04cd18e](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/04cd18e))


### Features

* **events:** add PATTERNLAB_BUILD_END event and rename BUILD_START ([5b7bfa3](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/5b7bfa3))
Expand All @@ -47,23 +39,17 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
* **server:** continue server refactor ([8f6cd91](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/8f6cd91))
* **watches:** add additional assets to ignore ([18e74c2](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/18e74c2))




<a name="3.0.0-alpha.13"></a>
# [3.0.0-alpha.13](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.12...@pattern-lab/core@3.0.0-alpha.13) (2018-05-04)

# [3.0.0-alpha.13](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.12...@pattern-lab/core@3.0.0-alpha.13) (2018-05-04)

### Features

* **api:** expose getVersion statically ([4683cd0](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/4683cd0))




<a name="3.0.0-alpha.12"></a>
# [3.0.0-alpha.12](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.11...@pattern-lab/core@3.0.0-alpha.12) (2018-05-04)

# [3.0.0-alpha.12](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.11...@pattern-lab/core@3.0.0-alpha.12) (2018-05-04)

### Bug Fixes

Expand All @@ -76,7 +62,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
* **tests:** prevent dependency graph output file from being written ([0d9c57e](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/0d9c57e))
* **uikits:** fix ui_builder_tests ([e75f434](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/e75f434))


### Features

* **API:** standardize v() and version() into a single call ([6309e69](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/6309e69))
Expand All @@ -96,14 +81,10 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
* **uikits:** support watched-asset copying ([4f05311](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/4f05311))
* **uikits:** uikits config to default ([a393851](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/commit/a393851))


### BREAKING CHANGES

* **API:** change `version()` to return a string representation of the version, removing `v()`




<a name="3.0.0-alpha.11"></a>

# [3.0.0-alpha.11](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/@pattern-lab/core@3.0.0-alpha.10...@pattern-lab/core@3.0.0-alpha.11) (2018-03-21)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/scripts/events.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Pattern Lab emits numerous events during the [build](../docs/) process. Some uses of events:

* Core uses `patternlab-pattern-change` events when watching for changes in order to trigger another build
* Plugins such as [plugin-node-tab](https://github.com/pattern-lab/plugin-node-tab) can use an event like `patternlab-pattern-write-end` to define additional code tabs to the pattern viewer / modal
* Plugins such as [plugin-tab](https://github.com/pattern-lab/patternlab-node/tree/master/packages/plugin-tab) can use an event like `patternlab-pattern-write-end` to define additional code tabs to the pattern viewer / modal

Learn more about [Creating Plugins](https://github.com/pattern-lab/patternlab-node/wiki/Creating-Plugins).

Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

'use strict';

const path = require('path');

const updateNotifier = require('update-notifier');

const packageInfo = require('../package.json');
const events = require('./lib/events');
const pe = require('./lib/pattern_exporter');
const pm = require('./lib/plugin_manager');

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

Expand Down Expand Up @@ -189,7 +192,11 @@ const patternlab_module = function(config) {
* @returns {void}
*/
installplugin: function(pluginName) {
patternlab.installPlugin(pluginName);
//get the config
const configPath = path.resolve(process.cwd(), 'patternlab-config.json');
const plugin_manager = new pm(config, configPath);

plugin_manager.install_plugin(pluginName);
},

/**
Expand Down
Loading