@penskemediacorp/larva 1.0.2-alpha.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +6 -0
- package/LICENSE +21 -0
- package/README.md +119 -4
- package/__tests__/fixtures/build/css/common.inline.css +1 -0
- package/__tests__/fixtures/build/images/test.png +0 -0
- package/__tests__/fixtures/build/js/larva-ui.js +1 -0
- package/__tests__/fixtures/build/svg/defs/sprite.svg +1 -0
- package/__tests__/fixtures/larva.config.js +43 -0
- package/__tests__/fixtures/public/some-library.js +1 -0
- package/__tests__/fixtures/src/patterns/__tests__/.gitkeep +0 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.aia.js +3 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.js +3 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.js +1 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.json +3 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.prototype.js +3 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.twig +3 -0
- package/__tests__/fixtures/src/patterns/components/c-tagline/c-tagline.prototype.js +3 -0
- package/__tests__/fixtures/src/patterns/modules/_also-ignored/_also-ignored.prototype.js +3 -0
- package/__tests__/fixtures/src/patterns/modules/_also-ignored/_also-ignored.twig +3 -0
- package/__tests__/fixtures/src/patterns/modules/ignore-me/ignore-me.prototype.js +0 -0
- package/__tests__/fixtures/src/patterns/modules/ignore-me/ignore-me.twig +0 -0
- package/__tests__/fixtures/src/patterns/modules/test-module/test-module.featured.js +3 -0
- package/__tests__/fixtures/src/patterns/modules/test-module/test-module.prototype.js +3 -0
- package/__tests__/fixtures/src/patterns/modules/test-module/test-module.twig +0 -0
- package/__tests__/fixtures/src/patterns/objects/_objects.scss +0 -0
- package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.json +3 -0
- package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.scss +0 -0
- package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.twig +1 -0
- package/__tests__/fixtures/src/patterns/objects/o-nav/o-nav.twig +14 -0
- package/__tests__/fixtures/src/patterns/one-offs/newswire/newswire.html +1 -0
- package/__tests__/fixtures/src/patterns/one-offs/newswire/newswire.prototype.js +3 -0
- package/__tests__/fixtures/template-parts/some-template.php +3 -0
- package/__tests__/lib/generateStatic.test.js +140 -0
- package/__tests__/lib/utils/clonePatternData.test.js +23 -0
- package/__tests__/lib/utils/getAllPatternsObj.test.js +45 -0
- package/__tests__/lib/utils/getAppConfiguration.test.js +13 -0
- package/__tests__/lib/utils/getModuleNamesFromDirectory.test.js +23 -0
- package/__tests__/lib/utils/getPatternData.test.js +55 -0
- package/__tests__/lib/utils/getPatternPathsToLoad.test.js +13 -0
- package/__tests__/lib/utils/getPatternRoutes.test.js +29 -0
- package/__tests__/lib/utils/getPatternType.test.js +16 -0
- package/__tests__/lib/utils/getPatternVariants.test.js +20 -0
- package/__tests__/lib/utils/getPatternsIndexPath.test.js +9 -0
- package/__tests__/lib/utils/getSubDirectoryNames.test.js +17 -0
- package/__tests__/lib/utils/isCoreTheme.test.js +12 -0
- package/__tests__/lib/utils/writeJsonToFile.test.js +29 -0
- package/__tests__/lib/writeJson.test.js +83 -0
- package/bin/larva.js +25 -0
- package/build/css/larva-important.css +1 -0
- package/build/css/larva-ui.css +1 -0
- package/build/css/larva.css +1 -0
- package/build/css/larva.inline-important.css +1 -0
- package/build/css/larva.inline.css +1 -0
- package/build/css/variety.compat-important.css +1 -0
- package/build/css/variety.compat.css +1 -0
- package/build/js/common.js +26 -0
- package/build/js/larva-ui.js +1 -0
- package/build/js/standalone/video-showcase.js +26 -0
- package/build/svg/brand-logo-white.svg +1 -0
- package/build/svg/brand-logo.svg +1 -0
- package/build/svg/defs/sprite.defs.html +828 -0
- package/build/svg/defs/sprite.defs.svg +1 -0
- package/build/tokens/artinamerica.custom-properties.css +546 -0
- package/build/tokens/artinamerica.json +533 -0
- package/build/tokens/artinamerica.map.scss +546 -0
- package/build/tokens/artinamerica.raw.json +4341 -0
- package/build/tokens/artnews.custom-properties.css +550 -0
- package/build/tokens/artnews.json +536 -0
- package/build/tokens/artnews.map.scss +550 -0
- package/build/tokens/artnews.raw.json +4373 -0
- package/build/tokens/bbpro.custom-properties.css +96 -0
- package/build/tokens/bbpro.json +80 -0
- package/build/tokens/bbpro.map.scss +96 -0
- package/build/tokens/bbpro.raw.json +789 -0
- package/build/tokens/billboard.custom-properties.css +96 -0
- package/build/tokens/billboard.json +80 -0
- package/build/tokens/billboard.map.scss +96 -0
- package/build/tokens/billboard.raw.json +789 -0
- package/build/tokens/deadline.custom-properties.css +533 -0
- package/build/tokens/deadline.json +517 -0
- package/build/tokens/deadline.map.scss +533 -0
- package/build/tokens/deadline.raw.json +4204 -0
- package/build/tokens/default.custom-properties.css +533 -0
- package/build/tokens/default.json +517 -0
- package/build/tokens/default.map.scss +533 -0
- package/build/tokens/default.raw.json +4204 -0
- package/build/tokens/dirt.custom-properties.css +81 -0
- package/build/tokens/dirt.json +66 -0
- package/build/tokens/dirt.map.scss +81 -0
- package/build/tokens/dirt.raw.json +690 -0
- package/build/tokens/indiewire.custom-properties.css +536 -0
- package/build/tokens/indiewire.json +520 -0
- package/build/tokens/indiewire.map.scss +536 -0
- package/build/tokens/indiewire.raw.json +4221 -0
- package/build/tokens/rivet.custom-properties.css +82 -0
- package/build/tokens/rivet.json +68 -0
- package/build/tokens/rivet.map.scss +82 -0
- package/build/tokens/rivet.raw.json +703 -0
- package/build/tokens/robbreport.custom-properties.css +536 -0
- package/build/tokens/robbreport.json +518 -0
- package/build/tokens/robbreport.map.scss +536 -0
- package/build/tokens/robbreport.raw.json +4215 -0
- package/build/tokens/rollingstone-2022.custom-properties.css +534 -0
- package/build/tokens/rollingstone-2022.json +519 -0
- package/build/tokens/rollingstone-2022.map.scss +534 -0
- package/build/tokens/rollingstone-2022.raw.json +4035 -0
- package/build/tokens/rollingstone.custom-properties.css +530 -0
- package/build/tokens/rollingstone.json +518 -0
- package/build/tokens/rollingstone.map.scss +530 -0
- package/build/tokens/rollingstone.raw.json +4207 -0
- package/build/tokens/sheknows.custom-properties.css +92 -0
- package/build/tokens/sheknows.json +76 -0
- package/build/tokens/sheknows.map.scss +92 -0
- package/build/tokens/sheknows.raw.json +761 -0
- package/build/tokens/sourcingjournal.custom-properties.css +87 -0
- package/build/tokens/sourcingjournal.json +70 -0
- package/build/tokens/sourcingjournal.map.scss +87 -0
- package/build/tokens/sourcingjournal.raw.json +720 -0
- package/build/tokens/sportico.custom-properties.css +73 -0
- package/build/tokens/sportico.json +59 -0
- package/build/tokens/sportico.map.scss +73 -0
- package/build/tokens/sportico.raw.json +640 -0
- package/build/tokens/thr.custom-properties.css +83 -0
- package/build/tokens/thr.json +67 -0
- package/build/tokens/thr.map.scss +83 -0
- package/build/tokens/thr.raw.json +698 -0
- package/build/tokens/variety-compat.custom-properties.css +36 -0
- package/build/tokens/variety-compat.json +33 -0
- package/build/tokens/variety-compat.map.scss +36 -0
- package/build/tokens/variety-compat.raw.json +224 -0
- package/build/tokens/variety-vip.custom-properties.css +532 -0
- package/build/tokens/variety-vip.json +521 -0
- package/build/tokens/variety-vip.map.scss +532 -0
- package/build/tokens/variety-vip.raw.json +4223 -0
- package/build/tokens/variety.custom-properties.css +534 -0
- package/build/tokens/variety.json +521 -0
- package/build/tokens/variety.map.scss +534 -0
- package/build/tokens/variety.raw.json +4225 -0
- package/build/tokens/vibe.custom-properties.css +77 -0
- package/build/tokens/vibe.json +63 -0
- package/build/tokens/vibe.map.scss +77 -0
- package/build/tokens/vibe.raw.json +668 -0
- package/build/tokens/wwd-2021.custom-properties.css +82 -0
- package/build/tokens/wwd-2021.json +67 -0
- package/build/tokens/wwd-2021.map.scss +82 -0
- package/build/tokens/wwd-2021.raw.json +701 -0
- package/build/tokens/wwd-beauty.custom-properties.css +86 -0
- package/build/tokens/wwd-beauty.json +70 -0
- package/build/tokens/wwd-beauty.map.scss +86 -0
- package/build/tokens/wwd-beauty.raw.json +719 -0
- package/build/tokens/wwd-dd.custom-properties.css +18 -0
- package/build/tokens/wwd-dd.json +13 -0
- package/build/tokens/wwd-dd.map.scss +18 -0
- package/build/tokens/wwd-dd.raw.json +90 -0
- package/build/tokens/wwd.custom-properties.css +70 -0
- package/build/tokens/wwd.json +60 -0
- package/build/tokens/wwd.map.scss +70 -0
- package/build/tokens/wwd.raw.json +643 -0
- package/index.js +7 -0
- package/lib/generateStatic.js +133 -0
- package/lib/server.js +284 -0
- package/lib/start.js +7 -0
- package/lib/utils/clonePatternData.js +13 -0
- package/lib/utils/copySyncHelper.js +33 -0
- package/lib/utils/getAllPatternsObj.js +48 -0
- package/lib/utils/getAppConfiguration.js +82 -0
- package/lib/utils/getArgsFromCli.js +3 -0
- package/lib/utils/getModuleNamesFromDirectory.js +11 -0
- package/lib/utils/getPatternData.js +34 -0
- package/lib/utils/getPatternPathsToLoad.js +20 -0
- package/lib/utils/getPatternRoutes.js +58 -0
- package/lib/utils/getPatternType.js +15 -0
- package/lib/utils/getPatternVariants.js +24 -0
- package/lib/utils/getPatternsIndexPath.js +11 -0
- package/lib/utils/getSubDirectoryNames.js +23 -0
- package/lib/utils/isCoreTheme.js +8 -0
- package/lib/utils/renderSass.js +20 -0
- package/lib/utils/spawnScript.js +26 -0
- package/lib/utils/writeJsonToFile.js +6 -0
- package/lib/writeJson.js +53 -0
- package/package.json +72 -5
- package/public/webfontloader.js +22 -0
- package/scripts/build-html.js +52 -0
- package/scripts/build-icons.js +80 -0
- package/scripts/build-scss.js +15 -0
- package/scripts/config/.eslintrc.json +11 -0
- package/scripts/config/gulpfile.js +191 -0
- package/scripts/config/stylelint.config.js +5 -0
- package/scripts/config/svgo-config.json +67 -0
- package/scripts/config/webpack.config.js +95 -0
- package/scripts/dev-js.js +13 -0
- package/scripts/dev-scss.js +20 -0
- package/scripts/help.js +65 -0
- package/scripts/init.js +21 -0
- package/scripts/larva/.nvmrc +1 -0
- package/scripts/larva/README.md +29 -0
- package/scripts/larva/larva.config.js +3 -0
- package/scripts/larva/src/patterns/README.md +3 -0
- package/scripts/larva/src/patterns/base.html +6 -0
- package/scripts/larva/src/patterns/components/README.md +3 -0
- package/scripts/larva/src/patterns/modules/README.md +3 -0
- package/scripts/larva/src/patterns/objects/README.md +3 -0
- package/scripts/larva/src/patterns/one-offs/README.md +3 -0
- package/scripts/link-all.js +40 -0
- package/scripts/lint-js.js +11 -0
- package/scripts/lint-scss.js +13 -0
- package/scripts/lint.js +73 -0
- package/scripts/prod-js.js +12 -0
- package/scripts/prod-scss.js +24 -0
- package/scripts/prod.js +122 -0
- package/scripts/server.js +11 -0
- package/scripts/start.js +36 -0
- package/scripts/upgrade.js +99 -0
- package/scripts/write-json.js +14 -0
- package/.DS_Store +0 -0
- package/__tests__/larva.test.js +0 -7
- package/lib/larva.js +0 -7
- package/lib/patterns.js +0 -48
- package/setup.scss +0 -1
- package/src/02-generic/breakpoint-label.scss +0 -33
- package/src/06-algorithms/a-glue/a-glue.html +0 -4
- package/src/06-algorithms/a-glue/a-glue.scss +0 -56
- package/src/06-algorithms/a-glue/index.js +0 -1
- package/src/06-algorithms/a-grid.scss +0 -29
- package/src/07-utilities/u-background.scss +0 -5
- package/src/07-utilities/u-color.scss +0 -5
- package/src/07-utilities/u-crop.scss +0 -5
- package/src/07-utilities/u-flex.scss +0 -35
- package/src/07-utilities/u-margin.scss +0 -5
- package/src/07-utilities/u-padding.scss +0 -5
- package/src/07-utilities/u-text.scss +0 -33
- package/src/07-utilities/utilities.scss +0 -5
- package/static/css/components.css +0 -4
- package/static/css/objects.css +0 -21
- package/static/css/prism.css +0 -126
- package/static/js/prism.js +0 -8
package/.eslintignore
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Penske Media Corporation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,11 +1,126 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Larva
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
_Note:_ This package may eventually be split into separate packages.
|
|
4
|
+
|
|
5
|
+
By nature it is a wrapper package that brings all of the smaller Larva packages together, and provides a sandbox for testing Larva tools. Now, it also contains the `larva` binary build scripts and the Larva UI Express server for patterns development.
|
|
6
|
+
|
|
7
|
+
* An Express server and UI for building project-level patterns and configuring existing patterns
|
|
8
|
+
* Gulp configuration for building SCSS
|
|
9
|
+
* A basic webpack configuration for JS
|
|
10
|
+
* An init command for scaffolding the Larva directory structure
|
|
11
|
+
* The `write-json` script for building the JSON for each pattern
|
|
12
|
+
* A `larva` binary that provides access to all of the above
|
|
4
13
|
|
|
5
14
|
## Usage
|
|
6
15
|
|
|
16
|
+
### If a brand new project:
|
|
17
|
+
|
|
18
|
+
In order to avoid conflicting node versions, Larva should be contained to its own directory.
|
|
19
|
+
|
|
20
|
+
**If you are working in a brand new project**, create a directory called `assets` and follow the below steps from the root of `assets`.
|
|
21
|
+
|
|
22
|
+
**If you are working in an existing project**, create a directory called `larva` and follow the below steps from its root.
|
|
23
|
+
|
|
24
|
+
First we will initialize an npm package, install Larva, and run the init command to scaffold our directory structure:
|
|
25
|
+
|
|
26
|
+
_// TODO: the `npx` workflow needs to be tested once this is released on npm._
|
|
27
|
+
|
|
7
28
|
```
|
|
8
|
-
|
|
29
|
+
# Create an npm package
|
|
30
|
+
$ npm init
|
|
9
31
|
|
|
10
|
-
|
|
32
|
+
# Add Larva and scaffold directory structure
|
|
33
|
+
$ npx @penskemediacorp/larva init
|
|
11
34
|
```
|
|
35
|
+
|
|
36
|
+
This will install the main Larva package and create a directory called larva/ that contains a scaffold of the directory structure. Move the contents of this directory into your current working directory so that the directory structure aligns with the following:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|- pmc-consuming-project/
|
|
40
|
+
|- assets/ (or larva if in an older code-base)
|
|
41
|
+
|- build/
|
|
42
|
+
|- node_modules/
|
|
43
|
+
|- src/
|
|
44
|
+
|- entries/
|
|
45
|
+
|- public/
|
|
46
|
+
|- package.json
|
|
47
|
+
|- larva.config.js
|
|
48
|
+
|- .nvmrc
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Next, check in root README.md from the scaffold and copy the scripts into package.json as directed.
|
|
52
|
+
|
|
53
|
+
Finally, create a directory `template-parts/patterns` to hold the PHP version of patterns. If working from the CLI, you can copy/paste this bash command:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
|- pmc-consuming-project/
|
|
57
|
+
|- template-parts/
|
|
58
|
+
|- patterns/
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## `larva` Binary & Build Scripts
|
|
62
|
+
|
|
63
|
+
Inspired by [@wordpress/scripts](https://github.com/WordPress/gutenberg/tree/master/packages/scripts), this package provides a bindary and several scripts for performing common tasks when building UI with Larva. This code lives in the `scripts` directory of this package.
|
|
64
|
+
|
|
65
|
+
For asset building commands, JS and SCSS can be run at the same time, or separately, in order to minimize the build time for cases where either JS or SCSS, not both, need to be built.
|
|
66
|
+
|
|
67
|
+
### Usage
|
|
68
|
+
|
|
69
|
+
Assuming Larva is installed, make sure the @penskemediacorp/larva package is at least at version 8.0.0-alpha.
|
|
70
|
+
|
|
71
|
+
To use the build scripts, add the following to package.json in a project that uses the [Larva assets directory structure](https://github.com/penske-media-corp/pmc-larva/tree/master/packages/larva#usage):
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
{
|
|
75
|
+
"scripts": {
|
|
76
|
+
"prod": "larva prod-scss & larva prod-js",
|
|
77
|
+
"prod:scss": "larva prod-scss",
|
|
78
|
+
"prod:js": "larva prod-js",
|
|
79
|
+
"dev": "larva dev-js & larva dev-scss",
|
|
80
|
+
"dev:scss": "larva dev-scss",
|
|
81
|
+
"dev:js": "larva dev-js",
|
|
82
|
+
"lint": "larva lint-scss & larva lint-js",
|
|
83
|
+
"lint:scss": "larva lint-scss",
|
|
84
|
+
"lint:js": "larva lint-js ./",
|
|
85
|
+
"lint-fix": "larva lint-scss --fix & npm run lint:js --fix",
|
|
86
|
+
"lint-fix:scss": "larva lint-scss --fix",
|
|
87
|
+
"lint-fix:js": "larva lint-js --fix",
|
|
88
|
+
"larva": "larva server",
|
|
89
|
+
"write-json": "larva write-json larva && larva write-json",
|
|
90
|
+
"build-icons": "larva build-icons",
|
|
91
|
+
"build-html": "larva build-html"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Script Usage Notes
|
|
97
|
+
|
|
98
|
+
**`build-html`**
|
|
99
|
+
|
|
100
|
+
This is the script for building static HTML files for deployment. It accepts two CLI arguments, the first for build source ('project' or 'larva') and the second as an optional port number. The default is 3000.
|
|
101
|
+
|
|
102
|
+
Example of building HTML for project Larva patterns:
|
|
103
|
+
`npm run build-html -- project`.
|
|
104
|
+
|
|
105
|
+
Example of building HTML for Larva patterns with a server on port 2003:
|
|
106
|
+
`npm run build-html -- larva 2003`.
|
|
107
|
+
|
|
108
|
+
**`prod:scss`**
|
|
109
|
+
|
|
110
|
+
This command accepts an optional flag, `--generate-important-variants`, which
|
|
111
|
+
produces a second version of each entrypoint. In these variants, every rule
|
|
112
|
+
includes the `!important` declaration. These stylesheets are used with themes
|
|
113
|
+
that have not fully adopted Larva, allowing Larva to overcome the theme's
|
|
114
|
+
styles' specificity.
|
|
115
|
+
|
|
116
|
+
### Overview of Functionality
|
|
117
|
+
|
|
118
|
+
This operates by way of a single binary, `larva`, and provides a layer of abstraction around CLI commands from various tools. The `larva` binary will point to a default configuration for each command and run its package's associated binary (e.g. `eslint` or `gulp`). The configurations are stored in separate package so as to be available to projects not using Larva.
|
|
119
|
+
|
|
120
|
+
For example, when the below scripts are present in a consuming projects package.json, the following would happen for `npm run dev:scss` (with the `scripts` value: `larva dev-scss`) in this package:
|
|
121
|
+
1. In `bin/larva.js`, get arguments from CLI, and execute a file with name corresponding to the argument.
|
|
122
|
+
2. `dev-scss.js` executes `gulp` CLI with additional arguments defined in the JS file via `spawnScript`, which uses the `cross-spawn` npm package to handle cross-platform inconsistencies.
|
|
123
|
+
|
|
124
|
+
Similarly, `npm run lint:js` (with the `scripts` value: `larva lint-js`) would do the following:
|
|
125
|
+
1. In `bin/larva.js`, get arguments from CLI and execute lint-js.js.
|
|
126
|
+
2. `lint-js.js` executes the `eslint` CLI with both CLI arguments and specific arguments defined in the script.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.testing { color: green; }
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log( 'test js build file' );
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg></svg>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
|
|
5
|
+
webpack: {
|
|
6
|
+
entry: {
|
|
7
|
+
common: './common.entry.js',
|
|
8
|
+
critical: './critical.entry.js',
|
|
9
|
+
special: './special.entry.js',
|
|
10
|
+
great: './great.entry.js'
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
backstop: {
|
|
15
|
+
testBaseUrl: 'https://pmc:for-the-win@deadline-2019.pmcqa.com',
|
|
16
|
+
testPaths: [
|
|
17
|
+
'/',
|
|
18
|
+
'/blog/'
|
|
19
|
+
],
|
|
20
|
+
testScenario: {
|
|
21
|
+
'delay': 5000,
|
|
22
|
+
'misMatchThreshold': 0.5
|
|
23
|
+
},
|
|
24
|
+
larvaModules: [ 'footer', 'mega-menu-content', 'social-share' ]
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
patterns: {
|
|
28
|
+
projectPatternsDir: path.join( __dirname, './src/patterns' ),
|
|
29
|
+
larvaPatternsDir: path.resolve( __dirname, '../../../larva-patterns' ),
|
|
30
|
+
ignoredModules: [
|
|
31
|
+
'ignore-me'
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
assets: {
|
|
36
|
+
path: __dirname
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
parser: {
|
|
40
|
+
isCore: false,
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log( 'test' );
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// this could be JSX or a React component.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p class="o-crap {{ modifier_class }} {{ o_crap_classes }}">{{ o_crap_text }}</p>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<nav class="o-nav {{ modifier_class }} {{ o_nav_classes }}" data-dropdown="{{ o_nav_data_attributes }}">
|
|
2
|
+
|
|
3
|
+
{% if o_nav_title_text %}
|
|
4
|
+
<h4 class="o-nav__title {{ o_nav_title_classes }}" data-dropdown-list-item="{{ o_nav_title_data_attributes }}"> {{ o_nav_title_text }}</h4>
|
|
5
|
+
{% endif %}
|
|
6
|
+
|
|
7
|
+
<ul class="o-nav__list {{ o_nav_list_classes }}" data-dropdown-list="{{ o_nav_list_data_attributes }}">
|
|
8
|
+
{% for item in o_nav_list_items %}
|
|
9
|
+
<li class="o-nav__list-item {{ o_nav_list_item_classes }}" data-dropdown-list-item="{{ o_nav_list_item_data_attributes }}">
|
|
10
|
+
{% include "../../04-components/c-nav-link/c-nav-link.twig" with item %}
|
|
11
|
+
</li>
|
|
12
|
+
{% endfor %}
|
|
13
|
+
</ul>
|
|
14
|
+
</nav>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>Newsire</h1>
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
const exec = require( 'child_process' ).exec;
|
|
3
|
+
const app = require( '../../lib/server' );
|
|
4
|
+
const fs = require( 'fs-extra' );
|
|
5
|
+
|
|
6
|
+
const port = 5555;
|
|
7
|
+
const urlBase = 'http://localhost:' + port + '/larva';
|
|
8
|
+
const generateStatic = require( '../../lib/generateStatic' );
|
|
9
|
+
|
|
10
|
+
const fixture = path.join( __dirname, '../fixtures' );
|
|
11
|
+
const buildPath = path.join( fixture, './build/html/project' );
|
|
12
|
+
|
|
13
|
+
beforeAll( ( done ) => {
|
|
14
|
+
app.listen( port, () => {
|
|
15
|
+
done();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe( 'generateStatic', () => {
|
|
20
|
+
|
|
21
|
+
beforeEach( ( done ) => {
|
|
22
|
+
|
|
23
|
+
exec( 'mkdir -p ' + buildPath, ( err ) => {
|
|
24
|
+
if ( err ) {
|
|
25
|
+
console.error( err );
|
|
26
|
+
}
|
|
27
|
+
done();
|
|
28
|
+
} );
|
|
29
|
+
|
|
30
|
+
} );
|
|
31
|
+
|
|
32
|
+
it( 'creates an index.html file for a prototype pattern', ( done ) => {
|
|
33
|
+
|
|
34
|
+
const routesArr = [
|
|
35
|
+
'components/c-link'
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
generateStatic( routesArr, buildPath, () => {
|
|
39
|
+
expect(
|
|
40
|
+
fs.existsSync( path.join( buildPath, 'components/c-link/index.html' ) )
|
|
41
|
+
).toBe( true );
|
|
42
|
+
done();
|
|
43
|
+
}, urlBase );
|
|
44
|
+
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
it( 'creates an html file for a pattern variant', ( done ) => {
|
|
48
|
+
const routesArr = [
|
|
49
|
+
'components/c-button/brand-basic'
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
generateStatic( routesArr, buildPath, () => {
|
|
53
|
+
expect(
|
|
54
|
+
fs.existsSync( path.join( buildPath, 'components/c-button/brand-basic/index.html' ) )
|
|
55
|
+
).toBe( true );
|
|
56
|
+
done();
|
|
57
|
+
}, urlBase );
|
|
58
|
+
|
|
59
|
+
} );
|
|
60
|
+
|
|
61
|
+
it( 'contains content for the pattern', ( done ) => {
|
|
62
|
+
const routesArr = [
|
|
63
|
+
'modules/footer',
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
generateStatic( routesArr, buildPath, () => {
|
|
67
|
+
expect(
|
|
68
|
+
// Hacky way to test that the response actually contains
|
|
69
|
+
// the content, not an error.
|
|
70
|
+
fs.readFileSync(
|
|
71
|
+
path.join( buildPath, routesArr[0] + '/index.html' ),
|
|
72
|
+
{ encoding: 'utf8' }
|
|
73
|
+
).indexOf( 'footer_classes' )
|
|
74
|
+
).not.toBe( -1 );
|
|
75
|
+
done();
|
|
76
|
+
}, urlBase );
|
|
77
|
+
} );
|
|
78
|
+
|
|
79
|
+
it( 'copies static assets', ( done ) => {
|
|
80
|
+
const routesArr = [
|
|
81
|
+
'components/c-button/brand-basic'
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
generateStatic( routesArr, buildPath, () => {
|
|
85
|
+
|
|
86
|
+
// This is kinda sloppy and may be annoying to maintain, and there is
|
|
87
|
+
// surely a more elegant way to test this functionality than checking
|
|
88
|
+
// if the file exists...
|
|
89
|
+
|
|
90
|
+
// JS
|
|
91
|
+
expect(
|
|
92
|
+
fs.existsSync( path.join( buildPath, '../assets/build/js/larva-ui.js' ) )
|
|
93
|
+
).toBe( true );
|
|
94
|
+
|
|
95
|
+
// CSS
|
|
96
|
+
expect(
|
|
97
|
+
fs.existsSync( path.join( buildPath, '../assets/build/css/common.inline.css' ) )
|
|
98
|
+
).toBe( true );
|
|
99
|
+
|
|
100
|
+
// Images
|
|
101
|
+
expect(
|
|
102
|
+
fs.existsSync( path.join( buildPath, '../assets/build/images/test.png' ) )
|
|
103
|
+
).toBe( true );
|
|
104
|
+
|
|
105
|
+
// SVG
|
|
106
|
+
expect(
|
|
107
|
+
fs.existsSync( path.join( buildPath, '../assets/build/svg/defs/sprite.svg' ) )
|
|
108
|
+
).toBe( true );
|
|
109
|
+
|
|
110
|
+
// Public dir
|
|
111
|
+
expect(
|
|
112
|
+
fs.existsSync( path.join( buildPath, '../assets/public/some-library.js' ) )
|
|
113
|
+
).toBe( true );
|
|
114
|
+
|
|
115
|
+
done();
|
|
116
|
+
|
|
117
|
+
}, urlBase );
|
|
118
|
+
|
|
119
|
+
} );
|
|
120
|
+
|
|
121
|
+
afterEach( ( done ) => {
|
|
122
|
+
|
|
123
|
+
const htmlDir = path.join( buildPath, '../' );
|
|
124
|
+
|
|
125
|
+
exec( 'rm -r ' + htmlDir, ( err ) => {
|
|
126
|
+
if ( err ) {
|
|
127
|
+
console.error( err );
|
|
128
|
+
}
|
|
129
|
+
done();
|
|
130
|
+
} );
|
|
131
|
+
|
|
132
|
+
} );
|
|
133
|
+
|
|
134
|
+
} );
|
|
135
|
+
|
|
136
|
+
afterAll( async ( done ) => {
|
|
137
|
+
const server = app.listen();
|
|
138
|
+
server.close();
|
|
139
|
+
done();
|
|
140
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
const clonePatternData = require( '../../../lib/utils/clonePatternData' );
|
|
3
|
+
const getConfig = require( '../../../lib/utils/getAppConfiguration' );
|
|
4
|
+
const { projectPatternsDir, larvaPatternsDir } = getConfig( 'patterns' );
|
|
5
|
+
|
|
6
|
+
describe( 'clonePatternData', () => {
|
|
7
|
+
|
|
8
|
+
it( 'gets object from project patterns dir first', () => {
|
|
9
|
+
|
|
10
|
+
const expected = require( path.join( projectPatternsDir, '/components/c-tagline/c-tagline.prototype' ) );
|
|
11
|
+
const c_tagline = clonePatternData( 'components/c-tagline/c-tagline.prototype');
|
|
12
|
+
|
|
13
|
+
expect( c_tagline ).toStrictEqual( expected );
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it( 'falls back to object from larva patterns dir', () => {
|
|
17
|
+
const expected = require( path.join( larvaPatternsDir, '/components/c-button/c-button.prototype' ) );
|
|
18
|
+
const c_button = clonePatternData( 'components/c-button/c-button.prototype');
|
|
19
|
+
|
|
20
|
+
expect( c_button ).toStrictEqual( expected );
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
const getAppConfiguration = require( '../../../lib/utils/getAppConfiguration' );
|
|
3
|
+
const getAllPatternsObj = require( '../../../lib/utils/getAllPatternsObj' );
|
|
4
|
+
|
|
5
|
+
const expectedPatterns = {
|
|
6
|
+
'__tests__' : {},
|
|
7
|
+
'components': {
|
|
8
|
+
'c-nav-link': [
|
|
9
|
+
'featured.aia',
|
|
10
|
+
'featured',
|
|
11
|
+
'prototype'
|
|
12
|
+
],
|
|
13
|
+
'c-tagline': [
|
|
14
|
+
'prototype'
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
'modules': {
|
|
18
|
+
'test-module': [
|
|
19
|
+
'featured',
|
|
20
|
+
'prototype'
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
'objects': {
|
|
24
|
+
'o-crap': [],
|
|
25
|
+
'o-nav': []
|
|
26
|
+
},
|
|
27
|
+
'one-offs': {
|
|
28
|
+
'newswire': [
|
|
29
|
+
'prototype'
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const config = getAppConfiguration( 'patterns' );
|
|
34
|
+
|
|
35
|
+
describe( 'getAllPatternsObj', () => {
|
|
36
|
+
|
|
37
|
+
it( 'returns an object containing all patterns and variants', () => {
|
|
38
|
+
|
|
39
|
+
expect(
|
|
40
|
+
getAllPatternsObj( config.projectPatternsDir )
|
|
41
|
+
).toEqual(
|
|
42
|
+
expectedPatterns
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
const fixture = path.join( __dirname, '../../fixtures' );
|
|
3
|
+
|
|
4
|
+
const getAppConfiguration = require( '../../../lib/utils/getAppConfiguration' );
|
|
5
|
+
const expectedLarvaConfig = require( fixture + '/larva.config.js' );
|
|
6
|
+
|
|
7
|
+
describe( 'getAppConfiguration', () => {
|
|
8
|
+
|
|
9
|
+
it( 'Get Larva Configuration', () => {
|
|
10
|
+
expect(getAppConfiguration( 'backstop' )).toStrictEqual( expectedLarvaConfig.backstop );
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const getModuleNamesFromDirectory = require( '../../../lib/utils/getModuleNamesFromDirectory' );
|
|
2
|
+
const getAppConfiguration = require( '../../../lib/utils/getAppConfiguration' );
|
|
3
|
+
|
|
4
|
+
const config = getAppConfiguration( 'patterns' );
|
|
5
|
+
|
|
6
|
+
describe( 'getModuleNamesFromDirectory', () => {
|
|
7
|
+
it( 'gets an array of modules', () => {
|
|
8
|
+
expect( getModuleNamesFromDirectory( config.projectPatternsDir, config.ignoredModules ) ).toEqual( expect.arrayContaining( [ 'test-module' ] ) );
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it( 'ignored modules with underscores', () => {
|
|
12
|
+
expect( getModuleNamesFromDirectory( config.projectPatternsDir, config.ignoredModules ) ).toEqual( expect.not.arrayContaining( [ '_also-ignored' ] ) );
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it( 'ignores modules listed in larva.config.ignoredModules', () => {
|
|
16
|
+
expect( getModuleNamesFromDirectory( config.projectPatternsDir, config.ignoredModules ) ).toEqual( expect.not.arrayContaining( [ 'ignore-me' ] ) );
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it( 'gets module names from larva', () => {
|
|
20
|
+
expect( getModuleNamesFromDirectory( config.larvaPatternsDir, config.ignoredModules ) ).toEqual( expect.arrayContaining( [ 'pmc-footer' ] ) );
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const assert = require( 'assert' );
|
|
2
|
+
const path = require( 'path' );
|
|
3
|
+
const fs = require( 'fs' );
|
|
4
|
+
const fixture = path.join( __dirname, '../../fixtures' );
|
|
5
|
+
|
|
6
|
+
const getPatternData = require( '../../../lib/utils/getPatternData' );
|
|
7
|
+
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )('patterns');
|
|
8
|
+
|
|
9
|
+
const expectedSchema = require( fixture + '/src/patterns/components/c-nav-link/c-nav-link.prototype.js' );
|
|
10
|
+
const expectedVariantSchema = require( fixture + '/src/patterns/components/c-nav-link/c-nav-link.featured.js' );
|
|
11
|
+
const expectedSchemaFromJson = require( fixture + '/src/patterns/objects/o-crap/o-crap.json' );
|
|
12
|
+
const expectedPath = fixture + '/src/patterns/objects/o-nav/o-nav.json';
|
|
13
|
+
const expectedOneOffSchema = require( fixture + '/src/patterns/one-offs/newswire/newswire.prototype.js' );
|
|
14
|
+
|
|
15
|
+
let compStub = {
|
|
16
|
+
name: 'c-nav-link',
|
|
17
|
+
type: 'components',
|
|
18
|
+
variant: 'prototype'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const objStub = {
|
|
22
|
+
name: 'o-crap',
|
|
23
|
+
type: 'objects',
|
|
24
|
+
variant: 'prototype'
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const oneOffStub = {
|
|
28
|
+
name: 'newswire',
|
|
29
|
+
type: 'one-offs',
|
|
30
|
+
variant: 'prototype'
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
describe( 'getPatternData', () => {
|
|
34
|
+
|
|
35
|
+
it( 'first returns the pattern object if the schema is found', () => {
|
|
36
|
+
assert.equal( getPatternData( fixture + '/src/patterns', compStub ), expectedSchema );
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it( 'returns the pattern object for one-offs', () => {
|
|
40
|
+
assert.equal( getPatternData( fixture + '/src/patterns', oneOffStub ), expectedOneOffSchema );
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it( 'returns the pattern json object if no prototype is found', () => {
|
|
44
|
+
assert.equal( getPatternData( fixture + '/src/patterns', objStub ), expectedSchemaFromJson );
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it( 'gets a variant specified in params', () => {
|
|
48
|
+
compStub.variant = 'featured';
|
|
49
|
+
assert.equal( getPatternData( fixture + '/src/patterns', compStub ), expectedVariantSchema );
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const assert = require( 'assert' );
|
|
2
|
+
const path = require( 'path' );
|
|
3
|
+
const fixture = path.join( __dirname, '../../fixtures' );
|
|
4
|
+
const getPatternPathsToLoad = require( '../../../lib/utils/getPatternPathsToLoad' );
|
|
5
|
+
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )('patterns');
|
|
6
|
+
|
|
7
|
+
describe( 'getPatternPathsToLoad', () => {
|
|
8
|
+
|
|
9
|
+
it( 'returns an array of paths loads larvaPath if it is the core theme', () => {
|
|
10
|
+
assert.equal( getPatternPathsToLoad( appConfiguration ).length, 2 );
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
});
|