Skip to content

Commit 4b2eae1

Browse files
authored
feat: Optimize and simplify the build scripts (#868)
* feat Optimize and simplify the build scripts * feat Update CHANGELOG * feat Reverted all individual component README updates * feat Revert update to generator template
1 parent 2713849 commit 4b2eae1

File tree

36 files changed

+108
-67
lines changed

36 files changed

+108
-67
lines changed

CHANGELOG-prerelease.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Prerelease 47 ( 2020-05-14 )
22

33
- [0323eab](https://github.com/patternfly/patternfly-elements/commit/0323eab2d9dd944cb51dee263056566fe1a14a57) fix: pfe-navigtation-item shouldn't add duplicative event listeners #870
4+
- [](https://github.com/patternfly/patternfly-elements/commit/) feat: Add ability to demo individual components using `demo` and `live-demo` scripts
45

56
## Prerelease 46 ( 2020-05-12 )
67

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,40 @@
1515

1616
The result of these principles is that you can plug one set of components into a wide variety of applications; bringing UX consistency and developer familiarity to any web project.
1717

18-
A Yeoman generator is included for creating Web Components that meets these goals.
18+
A Yeoman generator is included for creating web components that meet these goals.
1919

2020
## Quick start
21-
21+
```
2222
git clone [email protected]:patternfly/patternfly-elements.git
2323
cd patternfly-elements
2424
npm install # this will take a while due to lerna bootstrap
2525
npm run storybook
26+
```
2627

2728
The storybook script will launch the interactive demo pages.
2829

30+
### Additional dependencies
31+
If you will be doing any release work, it is recommended that you install Hugo and Hub.
32+
33+
To install on a MacOS: `brew install hugo hub`.
34+
35+
For other systems, please see documentation:
36+
- [Hub](https://hub.github.com/)
37+
- [Hugo](https://gohugo.io/getting-started/quick-start/)
38+
2939
_Note: You will need to use [Node](https://nodejs.org/en/) v.7 or higher._
3040

3141
## Command Line Helper Scripts
32-
Many commands have an optional argument of a component name, if left off it will assume it should run on all components. These should run from the project root.
42+
Many commands have an optional argument of space-separated component name(s), if left off it will assume it should run on all components. These should run from the project root.
3343

3444
### Compile
3545

3646
```shell
3747
# Run, watch, and build all components
3848
npm run dev
3949

40-
# Run, watch, and build one component
41-
npm run dev [component-name]
50+
# Run, watch, and build one or more component(s)
51+
npm run dev [component-name(s)]
4252
```
4353

4454
### Preview
@@ -58,7 +68,7 @@ npm run demo
5868

5969
```shell
6070
# Runs build, watch, and server processes
61-
npm run live-demo
71+
npm run live-demo [component-name(s)]
6272
```
6373

6474
### Testing
@@ -68,7 +78,7 @@ npm run live-demo
6878
npm run test
6979

7080
# Run tests on one component
71-
npm run test [component-name]
81+
npm run test [component-name(s)]
7282
```
7383

7484
## Support

docs/content/develop/step-1a.md

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -78,41 +78,23 @@ This will add these additional files to the standard set that is being served to
7878

7979
## Compile, watch, & preview
8080

81-
To watch for changes on all components and compile the code when changes are detected, run this from the PatternFly Elements root directory. This command will also launch the preview of the demo files.
81+
To watch for changes on component(s) and compile the code when changes are detected, run the command below from the PatternFly Elements root directory. This command will also launch the preview of the demo files and Storybook.
8282

8383
```
84-
npm run live-demo
84+
npm run live-demo [component-name(s)]
8585
```
8686

87-
## Compile & watch
88-
89-
You may find that you dislike watching all the elements at once. It may start up too slowly, consume too many system resources, or your OS may run out of file descriptors from watching too many files. If any of these are the case, you can shrink the set of elements being watched by running `npm run dev (component-name)`.
90-
91-
For example, to watch only `pfe-icon` and its dependencies:
92-
93-
```
94-
npm run dev pfe-icon
95-
```
96-
97-
*Note that this will also automatically begin watching dependencies of `pfe-icon`, such as `pfelement`.*
98-
9987
You may also specify multiple elements. For example, `pfe-card` and `pfe-cta` are often used together, so you may wish to watching them both.
10088

10189
```
102-
npm run dev pfe-card pfe-cta
90+
npm run live-demo pfe-card pfe-cta
10391
```
10492

105-
## Preview changes
106-
107-
Remember that you may want to simultaneously run compile commands to watch for changes to your code. From the root of the PatternFly Elements repository, run the live-demo command which will open a browser to a listing of all the demo files.
108-
109-
```
110-
npm run live-demo
111-
```
112-
113-
From there you can change the URL to the demo page of the element you're working on. For example, if you want to preview the `pfe-card` component, then navigate in the browser to `http://localhost:1234/elements/pfe-card/demo`.
93+
This command will open the browser to a listing of all the demo files: `http://localhost:8000/examples/`.
11494

95+
From there you can navigate to the demo page of the element you're working on. For example, if you want to preview the `pfe-card` component, then navigate in the browser to `http://localhost:8000/elements/pfe-card/demo`.
11596

97+
This command will also open the browser to the storybook instance. Read more about storybook below.
11698

11799
#### Storybook editor
118100

@@ -121,27 +103,28 @@ Storybook is an interactive tool that allows consumers of the components to see
121103
```
122104
npm run storybook
123105
```
106+
124107
Storybook will launch at [http://localhost:9001](http://localhost:9001).
125108

126109
## Testing
127110

128-
From the directory of the element you're working on, run the test script in the package.json file and Web Component Tester will use Mocha and Chai to execute your tests in the browser.
111+
From the project's root directory, run the test command `npm test` and Web Component Tester will use Mocha and Chai to execute your tests in the browser.
129112

130113
```
131-
npm test
114+
npm test [component-name(s)]
132115
```
133116

134117
## Final build
135118

136-
Prepare your element for distribution by running the build script in the package.json file located at the root of the element you're working on.
119+
Prepare your element for distribution by running the build script at the root of the project.
137120

138121
```
139-
npm run build
122+
npm run build [component-name(s)]
140123
```
141124

142125
The build script will merge the files in the `/src` directory and update the ES6 and ES5 versions of your element in the root of the element. These two files are the files that your applications will either require or import for use.
143126

144-
If you've been running `npm run dev`, the dev script runs the build script every time you save a file in the `/src` directory so running the build script might be redundant, but better safe than sorry.
127+
If you've been running `npm run live-demo`, the script runs the build every time you save a file in the `/src` directory, so running the build script might be redundant, but better safe than sorry.
145128

146129
## Publish
147130

docs/content/develop/step-2a.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,14 @@ tags = [ "develop" ]
1111

1212
Run this command from the project root to start the build, watch, and server processes, see others in the project README.
1313
```shell
14-
npm run live-demo
14+
npm run live-demo [component-name(s)]
1515
```
1616

17-
If you prefer to only watch specific component (this can be quicker), you'll need two terminal processes, start the watch process with:
18-
```shell
19-
# Replace pfe-cool-element with your component's name
20-
npm run dev pfe-cool-element
21-
```
22-
23-
Then run this to start the server:
24-
```shell
25-
npm start
26-
```
27-
28-
The server will load on `localhost:8000` by default.
17+
The server will load on `http://localhost:8000` by default.
2918

3019
![npm start command](/pfe-cool-element-start.png)
3120

32-
Navigate to `http://localhost:1234/elements/pfe-cool-element/demo/` to view your element.
21+
Navigate to `http://localhost:8000/elements/pfe-cool-element/demo/` to view your element.
3322

3423
You're off to a good start! You have a new custom element that extends the base PFElement class, uses shadow DOM, and has a built-in fallback for ShadyCSS in case shadow DOM isn't supported.
3524

docs/content/develop/step-2b.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Here's how it should look in the browser:
5959

6060
![demo page html step](/demo-page-html-step.png)
6161

62-
Remember that any changes we make in the `/src` directory are being watched while the `npm run dev` command runs. When you save changes, the `merge` and `compile` tasks run from the gulpfile to update the ES6 and ES5 versions of the component in the root of your element.
62+
Remember that any changes we make in the `/src` directory are being watched while the `npm run live-demo` command runs. When you save changes, the `merge` and `compile` tasks run from the gulpfile to update the ES6 and ES5 versions of the component in the root of your element.
6363

6464
The ES6 version should now look like this:
6565

elements/pfe-accordion/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"scripts": {
3333
"build": "../../node_modules/.bin/gulp && ../../node_modules/.bin/prettier --ignore-path ../../.prettierignore --write '**/*.{js,json}'",
3434
"dev": "../../node_modules/.bin/gulp dev",
35+
"watch": "../../node_modules/.bin/gulp watch",
3536
"test": "../../node_modules/.bin/wct --configFile ../../wct.conf.json elements/pfe-accordion/test/"
3637
},
3738
"contributors": [

elements/pfe-autocomplete/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"scripts": {
2828
"build": "../../node_modules/.bin/gulp && ../../node_modules/.bin/prettier --ignore-path ../../.prettierignore --write '**/*.{js,json}'",
2929
"dev": "../../node_modules/.bin/gulp dev",
30+
"watch": "../../node_modules/.bin/gulp watch",
3031
"test": "../../node_modules/.bin/wct --configFile ../../wct.conf.json elements/pfe-autocomplete/test/"
3132
},
3233
"contributors": [

elements/pfe-avatar/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"scripts": {
2828
"build": "../../node_modules/.bin/gulp && ../../node_modules/.bin/prettier --ignore-path ../../.prettierignore --write '**/*.{js,json}'",
2929
"dev": "../../node_modules/.bin/gulp dev",
30+
"watch": "../../node_modules/.bin/gulp watch",
3031
"test": "../../node_modules/.bin/wct --configFile ../../wct.conf.json elements/pfe-avatar/test/"
3132
},
3233
"contributors": [

elements/pfe-badge/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"scripts": {
2828
"build": "../../node_modules/.bin/gulp && ../../node_modules/.bin/prettier --ignore-path ../../.prettierignore --write '**/*.{js,json}'",
2929
"dev": "../../node_modules/.bin/gulp dev",
30+
"watch": "../../node_modules/.bin/gulp watch",
3031
"test": "../../node_modules/.bin/wct --configFile ../../wct.conf.json elements/pfe-badge/test/"
3132
},
3233
"author": {

elements/pfe-band/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"scripts": {
3333
"build": "../../node_modules/.bin/gulp && ../../node_modules/.bin/prettier --ignore-path ../../.prettierignore --write '**/*.{js,json}'",
3434
"dev": "../../node_modules/.bin/gulp dev",
35+
"watch": "../../node_modules/.bin/gulp watch",
3536
"test": "../../node_modules/.bin/wct --configFile ../../wct.conf.json elements/pfe-band/test/"
3637
},
3738
"contributors": [

0 commit comments

Comments
 (0)