Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 4 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ Refer to the [core usage guidelines](https://github.com/pattern-lab/patternlab-n

As of Pattern Lab Node 3.0.0, installation of [Editions](http://patternlab.io/docs/advanced-ecosystem-overview.html) is accomplished via the command line interface.

_0 to 60mph_

The below assume a new directory and project is required.
The below assumes a new directory and project is required. This is likely what you want to do if starting from scratch. You could also run this within an existing project. The CLI will ask you for the installation location.

1. Open a terminal window and following along below:
```bash
Expand All @@ -36,31 +34,10 @@ The below assume a new directory and project is required.
```
> If you get an error stating that `npx` is not installed, ensure you are on `npm 5.2.0` or later by running `npm -v` or install it globally with `npm install -g npx`. [Learn more about npx.](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b)
1. Follow the on-screen prompts to choose your Edition and a Starterkit should you want one.
1. Run `npm install` one last time to ensure any transient packages from the CLI are installed.
1. Open `package.json` and add the following to your `scripts` object
```diff
"scripts": {
+ "patternlab": "patternlab"
},
```
This tells `npm` to look in the local `node_modules/.bin` directory for the `patternlab` CLI.
1. In your terminal, run `npm run patternlab <command>`, where `<command>` is a documented method on the CLI, such as `build`, `serve`, or `help`.


_Established npm projects_
- If you chose `edition-node`, new commands in the "scripts" will be added in your `package.json`.
- If you chose `edition-node-gulp`, a `gulpfile.js` will be added to your project.

1. Run the following command from a terminal:
```bash
npm install @pattern-lab/cli --save-dev
```
1. Open `package.json` and add the following to your `scripts` object
```diff
"scripts": {
+ "patternlab": "patternlab"
},
```
This tells `npm` to look in the local `node_modules/.bin` directory for the `patternlab` CLI.
1. In your terminal, run `npm run patternlab init`. Follow the on-screen prompts to choose your Edition and a Starterkit should you want one.
> Notice that `@pattern-lab/cli` was installed as a depdendency. Learn how to further [use the cli in your own project](https://github.com/pattern-lab/patternlab-node/blob/dev/packages/cli/readme.md#configuring-your-project-to-use-the-cli).


## Ecosystem
Expand All @@ -85,7 +62,6 @@ Pattern Lab / Node wouldn't be what it is today without the support of the commu
* **[Brad Frost](http://bradfrost.com/)**
* [Marcos Peebles](https://twitter.com/marcospeebles)
* [Susan Simkins](https://twitter.com/susanmsimkins)
* [Wilfred Nas](https://twitter.com/wnas)

## Contributing

Expand Down
2 changes: 0 additions & 2 deletions packages/cli/bin/cli-actions/build.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict';
const buildPatterns = require('../build');
const copyFiles = require('../copy-source-files');
const resolveConfig = require('../resolve-config');
const { error, info, wrapAsync } = require('../utils');

const build = options =>
wrapAsync(function*() {
try {
const config = yield resolveConfig(options.parent.config);
yield copyFiles(config.paths);
yield buildPatterns(config, options);
info(`build: Yay, your Pattern Lab project was successfully built ☺`);
} catch (err) {
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/bin/cli-actions/serve.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict';
const resolveConfig = require('../resolve-config');
const build = require('./build');
const servePatterns = require('../serve');
const wrapAsync = require('../utils').wrapAsync;

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

module.exports = serve;
27 changes: 0 additions & 27 deletions packages/cli/bin/copy-source-files.js

This file was deleted.

3 changes: 2 additions & 1 deletion packages/cli/bin/patternlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ cli
.alias('compile')
.description('Build Pattern Lab. Optionally (re-)build only the patterns')
.option('-p, --patterns-only', 'Whether to only build patterns')
.option('--no-watch', 'Start watching for changes')
.action(build);

/**
Expand Down Expand Up @@ -130,7 +131,7 @@ cli
.command('serve')
.alias('browse')
.description('Starts a server to inspect files in browser')
.option('-w, --watch', 'Start watching for changes')
.option('--no-watch', 'Start watching for changes')
.action(serve);

// Show additional help
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/bin/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ const { error, info } = require('./utils');
* @func serve
* @desc Start a browser-sync server in the Pattern Lab public dir
* @param {object} config - The passed Pattern Lab config
* @param {object} options - The passed options at invocation time
*/
function serve(config) {
function serve(config, options) {
if (!isValidConfig) {
throw new TypeError(
'serve: Expects config not to be empty and of type object.'
Expand All @@ -37,7 +38,7 @@ function serve(config) {
try {
info(`serve: Serving your files …`);
const pl = patternlab(config);
pl.server.serve({});
pl.server.serve(options);
} catch (err) {
error(err);
}
Expand Down
43 changes: 38 additions & 5 deletions packages/cli/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,44 @@
#### Via Yarn
`yarn add @pattern-lab/cli --dev`

## Getting Started
1. In order to use Pattern Lab you need to initialize a Pattern Lab project with `patternlab init`. The CLI will ask you some setup question and scaffold your project based on it.
2. Build your patterns use `patternlab build`. The Pattern Lab CLI will assume that the `patternlab-config.json` is in the project root. Othewise specify a custom path to config with `patternlab build --config path/to/config`
3. To view your patterns in the browser preview `patternlab serve` or again specify a custom config location `patternlab serve --config path/to/config`
4. To export your patterns in the browser preview `patternlab export` or again specify a custom config location `patternlab export --config path/to/config`
## Configuring Your Project to Use the CLI

If the CLI is installed globally, you may call commands directly, such as `patternlab --version`.

If the CLI is not installed globally, you need to tell `npm` where to find the executable when invoking commands.

Open `package.json` and add the following to your `scripts` object:

```diff
"scripts": {
+ "patternlab": "patternlab"
},
```
This tells `npm` to look in the local `node_modules/.bin` directory for the `patternlab` CLI.

Subcommands and options can then be forwarded to the CLI like this:

```bash
npm run patternlab -- serve
```

Installing [`edition-node`](https://github.com/pattern-lab/patternlab-node/tree/master/packages/edition-node) will add the following CLI commands for convenience:

```diff
"scripts": {
+ "pl:build": "patternlab build --config ./patternlab-config.json",
+ "pl:help": "patternlab --help",
+ "pl:install": "patternlab install --config ./patternlab-config.json",
+ "pl:serve": "patternlab serve --config ./patternlab-config.json",
+ "pl:version": "patternlab --version"
},
```

Then you can invoke any of these like this:

```
npm run pl:serve
```

## API & Usage
### General usage
Expand Down
34 changes: 17 additions & 17 deletions packages/core/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ Builds patterns, copies assets, and constructs user interface
**Emits**: <code>event:PATTERNLAB_BUILD_START</code>, <code>event:PATTERNLAB_BUILD_END</code>
**See**: [all events](./events.md)

| Param | Type | Description |
| --- | --- | --- |
| options | <code>object</code> | an object used to control build behavior |
| options.cleanPublic | <code>bool</code> | whether or not to delete the configured output location (usually `public/`) before build |
| options.data | <code>object</code> | additional data to be merged with global data prior to build |
| options.watch | <code>bool</code> | whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| options | <code>object</code> | | an object used to control build behavior |
| [options.cleanPublic] | <code>bool</code> | <code>true</code> | whether or not to delete the configured output location (usually `public/`) before build |
| [options.data] | <code>object</code> | <code>{}</code> | additional data to be merged with global data prior to build |
| [options.watch] | <code>bool</code> | <code>true</code> | whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild |

<a name="patternlab+getDefaultConfig"></a>

Expand Down Expand Up @@ -122,11 +122,11 @@ Builds patterns only, leaving existing user interface files intact
**Kind**: instance property of [<code>patternlab</code>](#patternlab)
**Returns**: <code>Promise</code> - a promise fulfilled when build is complete

| Param | Type | Description |
| --- | --- | --- |
| options | <code>object</code> | an object used to control build behavior |
| options.cleanPublic | <code>bool</code> | whether or not to delete the configured output location (usually `public/`) before build |
| options.data | <code>object</code> | additional data to be merged with global data prior to build |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [options.cleanPublic] | <code>bool</code> | <code>true</code> | whether or not to delete the configured output location (usually `public/`) before build |
| [options.data] | <code>object</code> | <code>{}</code> | additional data to be merged with global data prior to build |
| [options.watch] | <code>bool</code> | <code>true</code> | whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild |

<a name="patternlab.getDefaultConfig"></a>

Expand Down Expand Up @@ -162,12 +162,12 @@ Build patterns, copies assets, and constructs user interface. Watches configured
**Kind**: static method of [<code>server</code>](#patternlab.server)
**Returns**: <code>Promise</code> - a promise fulfilled when build is complete

| Param | Type | Description |
| --- | --- | --- |
| options | <code>object</code> | an object used to control build behavior |
| options.cleanPublic | <code>bool</code> | whether or not to delete the configured output location (usually `public/`) before build |
| options.data | <code>object</code> | additional data to be merged with global data prior to build |
| options.watch | <code>bool</code> | **ALWAYS OVERRIDDEN to `true`** whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| options | <code>object</code> | | an object used to control build behavior |
| [options.cleanPublic] | <code>bool</code> | <code>true</code> | whether or not to delete the configured output location (usually `public/`) before build |
| [options.data] | <code>object</code> | <code>{}</code> | additional data to be merged with global data prior to build |
| [options.watch] | <code>bool</code> | <code>true</code> | whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild |

<a name="patternlab.server.reload"></a>

Expand Down
2 changes: 1 addition & 1 deletion packages/core/docs/events.md
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
21 changes: 10 additions & 11 deletions packages/core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ const patternlab_module = function(config) {
* @name build
* @instance
* @param {object} options an object used to control build behavior
* @param {bool} options.cleanPublic whether or not to delete the configured output location (usually `public/`) before build
* @param {object} options.data additional data to be merged with global data prior to build
* @param {bool} options.watch whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
* @param {bool} [options.cleanPublic=true] whether or not to delete the configured output location (usually `public/`) before build
* @param {object} [options.data={}] additional data to be merged with global data prior to build
* @param {bool} [options.watch=true] whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
* @emits PATTERNLAB_BUILD_START
* @emits PATTERNLAB_BUILD_END
* @see {@link ./events.md|all events}
Expand Down Expand Up @@ -231,9 +231,9 @@ const patternlab_module = function(config) {
* @memberof patternlab
* @name patternsonly
* @instance
* @param {object} options an object used to control build behavior
* @param {bool} options.cleanPublic whether or not to delete the configured output location (usually `public/`) before build
* @param {object} options.data additional data to be merged with global data prior to build
* @param {bool} [options.cleanPublic=true] whether or not to delete the configured output location (usually `public/`) before build
* @param {object} [options.data={}] additional data to be merged with global data prior to build
* @param {bool} [options.watch=true] whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
* @returns {Promise} a promise fulfilled when build is complete
*/
patternsonly: function(options) {
Expand Down Expand Up @@ -264,15 +264,14 @@ const patternlab_module = function(config) {
* @method serve
* @memberof patternlab.server
* @param {object} options an object used to control build behavior
* @param {bool} options.cleanPublic whether or not to delete the configured output location (usually `public/`) before build
* @param {object} options.data additional data to be merged with global data prior to build
* @param {bool} options.watch **ALWAYS OVERRIDDEN to `true`** whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
* @param {bool} [options.cleanPublic=true] whether or not to delete the configured output location (usually `public/`) before build
* @param {object} [options.data={}] additional data to be merged with global data prior to build
* @param {bool} [options.watch=true] whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild
* @returns {Promise} a promise fulfilled when build is complete
*/
serve: options => {
const _options = Object.assign({}, options, { watch: true });
return _api
.build(_options)
.build(options)
.then(() => server.serve())
.catch(e =>
logger.error(`error inside core index.js server serve: ${e}`)
Expand Down
9 changes: 9 additions & 0 deletions packages/development-edition-engine-handlebars/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
.DS_Store
patternlab.json
.sass-cache/*
/sass-cache
Thumbs.db
.idea/
public
dependencyGraph.json
2 changes: 2 additions & 0 deletions packages/development-edition-engine-handlebars/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package-lock=false
save-exact=true
12 changes: 12 additions & 0 deletions packages/development-edition-engine-handlebars/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
![Pattern Lab Logo](/patternlab.png "Pattern Lab Logo")

# Pattern Lab Node - Development Edition Engine Handlebars

_here be dragons_

This Development Edition is a variant of [Edition Node](https://github.com/pattern-lab/patternlab-node/tree/master/packages/edition-node) for convience purposes only, loaded with the Handlebars Engine. The goals of this Development Edition are two-fold:

* Develop the [Handlebars Engine](https://github.com/pattern-lab/patternlab-node/tree/master/packages/engine-handlebars)
* Build and test against Handlebars pattern tree

> Development Editions of Pattern Lab provide the ability to work on and commit changes to select packages within the overall Pattern Lab [ecosystem](http://patternlab.io/docs/advanced-ecosystem-overview.html). This Edition is NOT stable.
32 changes: 32 additions & 0 deletions packages/development-edition-engine-handlebars/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@pattern-lab/development-edition-engine-handlebars",
"private": true,
"version": "0.0.0",
"description": "The tree of components we use to test, develop and validate the Handlebars engine",
"scripts": {
"pl:build": "patternlab build --config ./patternlab-config.json",
"pl:help": "patternlab --help",
"pl:install": "patternlab install --config ./patternlab-config.json",
"pl:serve": "patternlab serve --config ./patternlab-config.json",
"pl:version": "patternlab --version"
},
"keywords": ["Pattern Lab",
"Atomic Web Design",
"Node",
"Handlebars",
"Edition"],
"author": "Brian Muenzenmeye",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/pattern-lab/patternlab-node.git"
},
"dependencies": {
"@pattern-lab/cli": "^0.0.1-beta.0",
"@pattern-lab/core": "^3.0.0-beta.0",
"@pattern-lab/engine-handlebars": "^2.0.0-beta.0",
"@pattern-lab/engine-mustache": "^2.0.0-beta.0",
"@pattern-lab/starterkit-mustache-demo": "^5.0.0",
"@pattern-lab/uikit-workshop": "^1.0.0-beta.0"
}
}
Loading