Skip to content

Commit 586a440

Browse files
committed
Expose default command configuration and update readme
1 parent def29b3 commit 586a440

File tree

5 files changed

+89
-75
lines changed

5 files changed

+89
-75
lines changed

bin/default.js

Lines changed: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,48 @@
44
* Dependencies
55
*/
66

7-
const concurrently = require('concurrently');
8-
9-
/**
10-
* Args
11-
*/
12-
13-
const arguments = require(`${__dirname}/util/args`);
14-
const args = arguments.args;
15-
const dict = arguments.dict;
16-
17-
const flags = dict.map(d => (args[d.name]) ? d.flags[0] : '')
18-
.filter(f => f != '').join(' ');
19-
20-
/**
21-
* Constants
22-
*/
23-
24-
const scripts = [
25-
'styles',
26-
'rollup',
27-
'slm',
28-
'svgs'
29-
];
30-
31-
const opts = {
32-
prefix: 'none',
33-
raw: true
34-
};
35-
36-
/**
37-
* Main task
38-
*/
39-
const main = () => {
40-
concurrently(scripts.map(s => `${__dirname}/cli.js ${s} ${flags}`), opts)
41-
};
42-
43-
/**
44-
* Runner
45-
*/
46-
const run = () => {
47-
main();
48-
};
49-
50-
/**
51-
* Export our methods
52-
*
53-
* @type {Object}
54-
*/
55-
module.exports = {
56-
main: main,
57-
run: run
58-
};
7+
const concurrently = require('concurrently');
8+
const resolve = require(`${__dirname}/util/resolve`);
9+
10+
/**
11+
* Args
12+
*/
13+
14+
const config = resolve('config/default.js');
15+
const arguments = require(`${__dirname}/util/args`);
16+
const args = arguments.args;
17+
const dict = arguments.dict;
18+
19+
const flags = dict.map(d => (args[d.name]) ? d.flags[0] : '')
20+
.filter(f => f != '').join(' ');
21+
22+
/**
23+
* Constants
24+
*/
25+
26+
const scripts = config.commands;
27+
const opts = config.concurrently;
28+
29+
/**
30+
* Main task
31+
*/
32+
const main = () => {
33+
concurrently(scripts.map(s => `${__dirname}/cli.js ${s} ${flags}`), opts);
34+
};
35+
36+
/**
37+
* Runner
38+
*/
39+
const run = () => {
40+
main();
41+
};
42+
43+
/**
44+
* Export our methods
45+
*
46+
* @type {Object}
47+
*/
48+
module.exports = {
49+
main: main,
50+
run: run
51+
};

config/default.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Default configuration
3+
*
4+
* @type {Object}
5+
*/
6+
module.exports = {
7+
commands: [
8+
'styles',
9+
'rollup',
10+
'slm',
11+
'svgs'
12+
],
13+
concurrently: {
14+
prefix: 'none',
15+
raw: true
16+
}
17+
};

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nycopportunity/pttrn",
33
"nice": "Patterns CLI",
4-
"version": "1.1.0",
4+
"version": "1.2.0",
55
"description": "A front-end CLI for building and managing design pattern libraries",
66
"author": "[email protected]",
77
"license": "GPL-3.0+",

readme.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ A front-end CLI for managing static design pattern libraries. Created and mainta
1818

1919
#### Background
2020

21-
This project started to make building and documenting accessible, CSS–first, and framework–free pattern libraries quick, easy, and fun, doing so without task runners and a minimal amount of JavaScript to tie it all together. It does this very well, and over time it has grown into a build system of its own, so acknowledging this as an in-house alternative is essential. Other pattern build systems with more extensive community support also exist and are well worth a look. These include [Storybook.js](https://storybook.js.org/), [Fractal](https://fractal.build/), [Pattern Lab](https://patternlab.io/), and possibly more.
21+
The Patterns CLI is the core developer module of the [NYCO User Interface (UI) Patterns Framework](https://nycopportunity.github.io/patterns-framework/). The project started to make building and documenting accessible, CSS–first, and framework–free pattern libraries quick, easy, and fun, doing so without task runners and a minimal amount of JavaScript to tie it all together. It does this very well, and over time it has grown into a build system of its own, so acknowledging this as an in-house alternative is essential. Other pattern build systems with more extensive community support also exist and are well worth a look. These include [Storybook.js](https://storybook.js.org/), [Fractal](https://fractal.build/), [Pattern Lab](https://patternlab.io/), and possibly more.
2222

2323
## I want to
2424

@@ -993,8 +993,6 @@ The basic pattern for commands is as follows:
993993
$ {{ ENVIRONMENT_VARIABLE }}={{ value }} npx pttrn {{ command }} {{ flag }}
994994
```
995995

996-
Every command is configured with one or a series of JavaScript files inside the [./config](config/) directory. The CLI will check to see if there is a custom configuration file in the local **./config** directory of the project first. If it doesn't exist it will use the [default configuration file in the CLI package](config/). Project configurations can be used to pass in additional and custom options to each package that the CLI uses. Below the packages used and default configurations are described in more detail.
997-
998996
- [`default`](#default)
999997
- [`styles`](#styles)
1000998
- [`tokens`](#tokens)
@@ -1010,9 +1008,17 @@ Every command is configured with one or a series of JavaScript files inside the
10101008
- [`serve`](#serve)
10111009
- [`publish`](#publish)
10121010

1011+
### Command Configuration
1012+
1013+
Every command is configured with one or a series of JavaScript files inside the [./config](config/) directory. The CLI will check to see if there is a custom configuration file in the local **./config** directory of your project first. If it doesn't exist it will use the [default configuration file in the CLI package](config/). Project configurations can be used to pass in additional and custom options to each package that the CLI uses. Below the packages used and default configurations are described in more detail.
1014+
1015+
### Command Flags
1016+
10131017
Optional [flags](#flags) can be passed to the commands for signaling watching and log settings. The log settings are universal so they aren't represented in the command tables below.
10141018

1015-
[Custom commands](#custom-commands) have been newly introduced and are described below.
1019+
### Commands
1020+
1021+
[Custom commands](#custom-commands) can be defined in the local project **./bin** are described below.
10161022

10171023
---
10181024

@@ -1022,7 +1028,7 @@ Command | Flags | Configuration | `NODE_ENV`
10221028
-----------------|-------|---------------|-
10231029
`default` or ` ` | `-w` | n/a | `production` or `development`
10241030

1025-
Synchronously runs this series of commands; `styles`, `rollup`, `slm`, and `svgs` respectfully and described below.
1031+
Uses [Concurrently](https://github.com/open-cli-tools/concurrently) to synchronously run this series of commands; [`styles`](#styles), [`rollup`](#rollup), [`slm`](#slm), and [`svgs`](#svgs), respectfully. Each command is described in more detail below. The series of commands can be modified by editing the array of commands defined in a custom [./config/default.js](config/default.js) file. Addionally, the options passed to [Concurrently](https://github.com/open-cli-tools/concurrently#concurrentlycommands-options) can also be
10261032

10271033
Back to [commands ^](#commands) | [table of contents ^](#contents)
10281034

@@ -1034,7 +1040,7 @@ Command | Flags | Configuration | `NODE_ENV`
10341040
---------|-------|---------------|-
10351041
`styles` | `-w` | n/a | `production` or `development`
10361042

1037-
Synchronously runs this series of commands; `tokens`, `sass`, and `postcss` respectfully and described below.
1043+
Asynchronously runs this series of commands; [`tokens`](#tokens), [`sass`](#sass), then [`postcss`](#postcss) respectfully and described below.
10381044

10391045
Back to [commands ^](#commands) | [table of contents ^](#contents)
10401046

@@ -1058,8 +1064,8 @@ Back to [commands ^](#commands) | [table of contents ^](#contents)
10581064

10591065
#### Sass
10601066

1061-
Command | Flags | Configuration | `NODE_ENV`
1062-
--------|-------|----------------------------------------------------------------------------------------------|-
1067+
Command | Flags | Configuration | `NODE_ENV`
1068+
--------|-------|---------------------------|-
10631069
`sass` | `-nl` | [sass.js](config/sass.js) | `production` or `development`
10641070

10651071
Uses [Dart Sass](https://github.com/sass/dart-sass) to compile Sass modules defined in the `sass` configuration into CSS. It will use [Node Sass](https://github.com/sass/node-sass) in place of Dart Sass if it is required in a project's **package.json** file. By default, it will compile the default Sass entry point [./src/scss/default.js](config/scaffold/default.scss). If `NODE_ENV` is set to `development` only the modules with the attribute `devModule: true` will be compiled.
@@ -1378,12 +1384,9 @@ $ npx pttrn custom
13781384
✨ My custom command
13791385
```
13801386

1381-
Custom commands can use [other packages](https://www.npmjs.com/) that are not integrated in this project and reuse the CLI [scripts](bin/), [utilities](bin/util/), or [default configuration](config/). Custom commands can also be packaged, published, and shared between projects. Below are a few published custom command plugins.
1387+
#### Plugins
13821388

1383-
Plugin | Description
1384-
------------------------------------------------------------------------------------|-
1385-
[Patterns Plugin Feather](https://github.com/CityOfNewYork/patterns-plugin-feather) | Compile a [Feather icon](https://feathericons.com/) sprite from the Feather package into the dist directory.
1386-
[Patterns Plugin Twig](https://github.com/CityOfNewYork/patterns-plugin-twig) | Will compile Twig view templates effectively replacing the default Slm compiler with [Twig.js](https://github.com/twigjs/twig.js/).
1389+
Custom commands can use [other packages](https://www.npmjs.com/) that are not integrated in this project and reuse the CLI [scripts](bin/), [utilities](bin/util/), or [default configuration](config/) in different ways. Custom commands can also be packaged, published, and shared between projects as plugins. A few published [custom command plugins](#custom-command-plugins) are described below.
13871390

13881391
[Back to table of contents ^](#contents)
13891392

@@ -1472,7 +1475,7 @@ CSS utilities make it easier for developers who do not actively maintain your pa
14721475
The `scaffold` command creates a [./config/tailwindcss.js](config/tailwindcss.js). If not using the `scaffold` command, create your configuration file:
14731476

14741477
```shell
1475-
$ touch config/taiwindcss.js
1478+
touch config/taiwindcss.js
14761479
```
14771480

14781481
In the configuration file, you can import your **./config/tokens.js** configuration and include design tokens from your project in the Tailwindcss configuration. You may also use the default configuration if desired.
@@ -1512,7 +1515,7 @@ You may notice this does not include the `@tailwind base` tag which adds some ba
15121515
These directives can be added anywhere but we recommend keeping them in the **./src/utilites** directory. The `scaffold` command creates a module directory for these directives automatically: **./src/utilities/tailwindcss**. If not using the `scaffold` command the directory and stylesheet can be added with the following `make` command:
15131516
15141517
```shell
1515-
$ npx pttrn make utility tailwindcss style
1518+
npx pttrn make utility tailwindcss style
15161519
```
15171520
15181521
Below are sample contents of the stylesheet from the `scaffold` command. Copy and paste them into the stylesheet if using the `make` command above.
@@ -1672,7 +1675,7 @@ The CLI ships with several optional dependencies.
16721675
To omit these packages to keep your project lean, use the `--no-optional` flag when installing.
16731676
16741677
```shell
1675-
$ npm install @nycopportunity/pttrn --no-optional
1678+
npm install @nycopportunity/pttrn --no-optional
16761679
```
16771680
16781681
These dependencies are required by the default configuration or recommended npm scripts. If your project is relying on many of the Framework's default configurations or you want to model your project to closely resemble the original configuration then it is recommended to include them in your project.
@@ -1694,10 +1697,11 @@ Package | Descript
16941697
16951698
Refer to [custom commands](#custom-commands) on how to create plugins.
16961699
1697-
Plugin | Description
1698-
------------------------------------------------------------------------------------|-
1699-
[Patterns Plugin Feather](https://github.com/CityOfNewYork/patterns-plugin-feather) | Compile a [Feather icon](https://feathericons.com/) sprite from the Feather package into the dist directory.
1700-
[Patterns Plugin Twig](https://github.com/CityOfNewYork/patterns-plugin-twig) | Will compile Twig view templates effectively replacing the default Slm compiler with [Twig.js](https://github.com/twigjs/twig.js/).
1700+
Plugin | Description
1701+
-------------------------------------------------------------------------------------------|-
1702+
[Patterns Plugin Feather](https://github.com/CityOfNewYork/patterns-plugin-feather) | Compile a [Feather icon](https://feathericons.com/) sprite from the Feather package into the dist directory.
1703+
[Patterns Plugin Twig](https://github.com/CityOfNewYork/patterns-plugin-twig) | Will compile Twig view templates effectively replacing the default Slm compiler with [Twig.js](https://github.com/twigjs/twig.js/).
1704+
[Patterns Plugin Properties](https://github.com/NYCOpportunity/patterns-plugin-properties) | Will compile JSON tokens into CSS Custom Properties using [css-vars-from-json](https://github.com/TimoBechtel/css-vars-from-json).
17011705
17021706
[Back to table of contents ^](#contents)
17031707

0 commit comments

Comments
 (0)