@penskemediacorp/larva 1.2.1-alpha.0 → 1.3.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.
Files changed (236) hide show
  1. package/.eslintignore +6 -0
  2. package/LICENSE +21 -0
  3. package/README.md +119 -4
  4. package/__tests__/fixtures/build/css/common.inline.css +1 -0
  5. package/__tests__/fixtures/build/images/test.png +0 -0
  6. package/__tests__/fixtures/build/js/larva-ui.js +1 -0
  7. package/__tests__/fixtures/build/svg/defs/sprite.svg +1 -0
  8. package/__tests__/fixtures/larva.config.js +43 -0
  9. package/__tests__/fixtures/public/some-library.js +1 -0
  10. package/__tests__/fixtures/src/patterns/__tests__/.gitkeep +0 -0
  11. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.aia.js +3 -0
  12. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.js +3 -0
  13. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.js +1 -0
  14. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.json +3 -0
  15. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.prototype.js +3 -0
  16. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.twig +3 -0
  17. package/__tests__/fixtures/src/patterns/components/c-tagline/c-tagline.prototype.js +3 -0
  18. package/__tests__/fixtures/src/patterns/modules/_also-ignored/_also-ignored.prototype.js +3 -0
  19. package/__tests__/fixtures/src/patterns/modules/_also-ignored/_also-ignored.twig +3 -0
  20. package/__tests__/fixtures/src/patterns/modules/ignore-me/ignore-me.prototype.js +0 -0
  21. package/__tests__/fixtures/src/patterns/modules/ignore-me/ignore-me.twig +0 -0
  22. package/__tests__/fixtures/src/patterns/modules/test-module/test-module.featured.js +3 -0
  23. package/__tests__/fixtures/src/patterns/modules/test-module/test-module.prototype.js +3 -0
  24. package/__tests__/fixtures/src/patterns/modules/test-module/test-module.twig +0 -0
  25. package/__tests__/fixtures/src/patterns/objects/_objects.scss +0 -0
  26. package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.json +3 -0
  27. package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.scss +0 -0
  28. package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.twig +1 -0
  29. package/__tests__/fixtures/src/patterns/objects/o-nav/o-nav.twig +14 -0
  30. package/__tests__/fixtures/src/patterns/one-offs/newswire/newswire.html +1 -0
  31. package/__tests__/fixtures/src/patterns/one-offs/newswire/newswire.prototype.js +3 -0
  32. package/__tests__/fixtures/template-parts/some-template.php +3 -0
  33. package/__tests__/lib/generateStatic.test.js +140 -0
  34. package/__tests__/lib/utils/clonePatternData.test.js +23 -0
  35. package/__tests__/lib/utils/getAllPatternsObj.test.js +45 -0
  36. package/__tests__/lib/utils/getAppConfiguration.test.js +13 -0
  37. package/__tests__/lib/utils/getModuleNamesFromDirectory.test.js +23 -0
  38. package/__tests__/lib/utils/getPatternData.test.js +55 -0
  39. package/__tests__/lib/utils/getPatternPathsToLoad.test.js +13 -0
  40. package/__tests__/lib/utils/getPatternRoutes.test.js +29 -0
  41. package/__tests__/lib/utils/getPatternType.test.js +16 -0
  42. package/__tests__/lib/utils/getPatternVariants.test.js +20 -0
  43. package/__tests__/lib/utils/getPatternsIndexPath.test.js +9 -0
  44. package/__tests__/lib/utils/getSubDirectoryNames.test.js +17 -0
  45. package/__tests__/lib/utils/isCoreTheme.test.js +12 -0
  46. package/__tests__/lib/utils/writeJsonToFile.test.js +29 -0
  47. package/__tests__/lib/writeJson.test.js +83 -0
  48. package/bin/larva.js +25 -0
  49. package/build/css/larva-important.css +1 -0
  50. package/build/css/larva-ui.css +1 -0
  51. package/build/css/larva.css +1 -0
  52. package/build/css/larva.inline-important.css +1 -0
  53. package/build/css/larva.inline.css +1 -0
  54. package/build/css/variety.compat-important.css +1 -0
  55. package/build/css/variety.compat.css +1 -0
  56. package/build/js/common.js +26 -0
  57. package/build/js/larva-ui.js +1 -0
  58. package/build/js/standalone/video-showcase.js +26 -0
  59. package/build/svg/brand-logo-white.svg +1 -0
  60. package/build/svg/brand-logo.svg +1 -0
  61. package/build/svg/defs/sprite.defs.html +852 -0
  62. package/build/svg/defs/sprite.defs.svg +1 -0
  63. package/build/tokens/artinamerica.custom-properties.css +546 -0
  64. package/build/tokens/artinamerica.json +533 -0
  65. package/build/tokens/artinamerica.map.scss +546 -0
  66. package/build/tokens/artinamerica.raw.json +4341 -0
  67. package/build/tokens/artnews.custom-properties.css +550 -0
  68. package/build/tokens/artnews.json +536 -0
  69. package/build/tokens/artnews.map.scss +550 -0
  70. package/build/tokens/artnews.raw.json +4373 -0
  71. package/build/tokens/bbpro.custom-properties.css +96 -0
  72. package/build/tokens/bbpro.json +80 -0
  73. package/build/tokens/bbpro.map.scss +96 -0
  74. package/build/tokens/bbpro.raw.json +789 -0
  75. package/build/tokens/billboard.custom-properties.css +96 -0
  76. package/build/tokens/billboard.json +80 -0
  77. package/build/tokens/billboard.map.scss +96 -0
  78. package/build/tokens/billboard.raw.json +789 -0
  79. package/build/tokens/deadline.custom-properties.css +533 -0
  80. package/build/tokens/deadline.json +517 -0
  81. package/build/tokens/deadline.map.scss +533 -0
  82. package/build/tokens/deadline.raw.json +4204 -0
  83. package/build/tokens/default.custom-properties.css +533 -0
  84. package/build/tokens/default.json +517 -0
  85. package/build/tokens/default.map.scss +533 -0
  86. package/build/tokens/default.raw.json +4204 -0
  87. package/build/tokens/dirt.custom-properties.css +81 -0
  88. package/build/tokens/dirt.json +66 -0
  89. package/build/tokens/dirt.map.scss +81 -0
  90. package/build/tokens/dirt.raw.json +690 -0
  91. package/build/tokens/indiewire.custom-properties.css +536 -0
  92. package/build/tokens/indiewire.json +520 -0
  93. package/build/tokens/indiewire.map.scss +536 -0
  94. package/build/tokens/indiewire.raw.json +4221 -0
  95. package/build/tokens/rivet.custom-properties.css +82 -0
  96. package/build/tokens/rivet.json +68 -0
  97. package/build/tokens/rivet.map.scss +82 -0
  98. package/build/tokens/rivet.raw.json +703 -0
  99. package/build/tokens/robbreport.custom-properties.css +536 -0
  100. package/build/tokens/robbreport.json +518 -0
  101. package/build/tokens/robbreport.map.scss +536 -0
  102. package/build/tokens/robbreport.raw.json +4215 -0
  103. package/build/tokens/rollingstone-2022.custom-properties.css +534 -0
  104. package/build/tokens/rollingstone-2022.json +519 -0
  105. package/build/tokens/rollingstone-2022.map.scss +534 -0
  106. package/build/tokens/rollingstone-2022.raw.json +4035 -0
  107. package/build/tokens/rollingstone.custom-properties.css +530 -0
  108. package/build/tokens/rollingstone.json +518 -0
  109. package/build/tokens/rollingstone.map.scss +530 -0
  110. package/build/tokens/rollingstone.raw.json +4207 -0
  111. package/build/tokens/sheknows.custom-properties.css +92 -0
  112. package/build/tokens/sheknows.json +76 -0
  113. package/build/tokens/sheknows.map.scss +92 -0
  114. package/build/tokens/sheknows.raw.json +761 -0
  115. package/build/tokens/sourcingjournal.custom-properties.css +87 -0
  116. package/build/tokens/sourcingjournal.json +70 -0
  117. package/build/tokens/sourcingjournal.map.scss +87 -0
  118. package/build/tokens/sourcingjournal.raw.json +720 -0
  119. package/build/tokens/sportico.custom-properties.css +73 -0
  120. package/build/tokens/sportico.json +59 -0
  121. package/build/tokens/sportico.map.scss +73 -0
  122. package/build/tokens/sportico.raw.json +640 -0
  123. package/build/tokens/thr.custom-properties.css +83 -0
  124. package/build/tokens/thr.json +67 -0
  125. package/build/tokens/thr.map.scss +83 -0
  126. package/build/tokens/thr.raw.json +698 -0
  127. package/build/tokens/variety-compat.custom-properties.css +36 -0
  128. package/build/tokens/variety-compat.json +33 -0
  129. package/build/tokens/variety-compat.map.scss +36 -0
  130. package/build/tokens/variety-compat.raw.json +224 -0
  131. package/build/tokens/variety-vip.custom-properties.css +532 -0
  132. package/build/tokens/variety-vip.json +521 -0
  133. package/build/tokens/variety-vip.map.scss +532 -0
  134. package/build/tokens/variety-vip.raw.json +4223 -0
  135. package/build/tokens/variety.custom-properties.css +534 -0
  136. package/build/tokens/variety.json +521 -0
  137. package/build/tokens/variety.map.scss +534 -0
  138. package/build/tokens/variety.raw.json +4225 -0
  139. package/build/tokens/vibe.custom-properties.css +77 -0
  140. package/build/tokens/vibe.json +63 -0
  141. package/build/tokens/vibe.map.scss +77 -0
  142. package/build/tokens/vibe.raw.json +668 -0
  143. package/build/tokens/wwd-2021.custom-properties.css +82 -0
  144. package/build/tokens/wwd-2021.json +67 -0
  145. package/build/tokens/wwd-2021.map.scss +82 -0
  146. package/build/tokens/wwd-2021.raw.json +701 -0
  147. package/build/tokens/wwd-beauty.custom-properties.css +86 -0
  148. package/build/tokens/wwd-beauty.json +70 -0
  149. package/build/tokens/wwd-beauty.map.scss +86 -0
  150. package/build/tokens/wwd-beauty.raw.json +719 -0
  151. package/build/tokens/wwd-dd.custom-properties.css +18 -0
  152. package/build/tokens/wwd-dd.json +13 -0
  153. package/build/tokens/wwd-dd.map.scss +18 -0
  154. package/build/tokens/wwd-dd.raw.json +90 -0
  155. package/build/tokens/wwd.custom-properties.css +70 -0
  156. package/build/tokens/wwd.json +60 -0
  157. package/build/tokens/wwd.map.scss +70 -0
  158. package/build/tokens/wwd.raw.json +643 -0
  159. package/index.js +7 -0
  160. package/lib/generateStatic.js +133 -0
  161. package/lib/server.js +284 -0
  162. package/lib/start.js +7 -0
  163. package/lib/utils/clonePatternData.js +13 -0
  164. package/lib/utils/copySyncHelper.js +33 -0
  165. package/lib/utils/getAllPatternsObj.js +48 -0
  166. package/lib/utils/getAppConfiguration.js +82 -0
  167. package/lib/utils/getArgsFromCli.js +3 -0
  168. package/lib/utils/getModuleNamesFromDirectory.js +11 -0
  169. package/lib/utils/getPatternData.js +34 -0
  170. package/lib/utils/getPatternPathsToLoad.js +20 -0
  171. package/lib/utils/getPatternRoutes.js +58 -0
  172. package/lib/utils/getPatternType.js +15 -0
  173. package/lib/utils/getPatternVariants.js +24 -0
  174. package/lib/utils/getPatternsIndexPath.js +11 -0
  175. package/lib/utils/getSubDirectoryNames.js +23 -0
  176. package/lib/utils/isCoreTheme.js +8 -0
  177. package/lib/utils/renderSass.js +20 -0
  178. package/lib/utils/spawnScript.js +26 -0
  179. package/lib/utils/writeJsonToFile.js +6 -0
  180. package/lib/writeJson.js +53 -0
  181. package/package.json +72 -5
  182. package/public/webfontloader.js +22 -0
  183. package/scripts/build-html.js +52 -0
  184. package/scripts/build-icons.js +80 -0
  185. package/scripts/build-scss.js +15 -0
  186. package/scripts/config/.eslintrc.json +11 -0
  187. package/scripts/config/gulpfile.js +191 -0
  188. package/scripts/config/stylelint.config.js +5 -0
  189. package/scripts/config/svgo-config.json +67 -0
  190. package/scripts/config/webpack.config.js +95 -0
  191. package/scripts/dev-js.js +13 -0
  192. package/scripts/dev-scss.js +20 -0
  193. package/scripts/help.js +65 -0
  194. package/scripts/init.js +21 -0
  195. package/scripts/larva/.nvmrc +1 -0
  196. package/scripts/larva/README.md +29 -0
  197. package/scripts/larva/larva.config.js +3 -0
  198. package/scripts/larva/src/patterns/README.md +3 -0
  199. package/scripts/larva/src/patterns/base.html +6 -0
  200. package/scripts/larva/src/patterns/components/README.md +3 -0
  201. package/scripts/larva/src/patterns/modules/README.md +3 -0
  202. package/scripts/larva/src/patterns/objects/README.md +3 -0
  203. package/scripts/larva/src/patterns/one-offs/README.md +3 -0
  204. package/scripts/link-all.js +40 -0
  205. package/scripts/lint-js.js +11 -0
  206. package/scripts/lint-scss.js +13 -0
  207. package/scripts/lint.js +73 -0
  208. package/scripts/prod-js.js +12 -0
  209. package/scripts/prod-scss.js +24 -0
  210. package/scripts/prod.js +122 -0
  211. package/scripts/server.js +11 -0
  212. package/scripts/start.js +36 -0
  213. package/scripts/upgrade.js +99 -0
  214. package/scripts/write-json.js +14 -0
  215. package/.DS_Store +0 -0
  216. package/__tests__/larva.test.js +0 -7
  217. package/lib/larva.js +0 -7
  218. package/lib/patterns.js +0 -48
  219. package/setup.scss +0 -1
  220. package/src/02-generic/breakpoint-label.scss +0 -33
  221. package/src/06-algorithms/a-glue/a-glue.html +0 -4
  222. package/src/06-algorithms/a-glue/a-glue.scss +0 -56
  223. package/src/06-algorithms/a-glue/index.js +0 -1
  224. package/src/06-algorithms/a-grid.scss +0 -29
  225. package/src/07-utilities/u-background.scss +0 -5
  226. package/src/07-utilities/u-color.scss +0 -5
  227. package/src/07-utilities/u-crop.scss +0 -5
  228. package/src/07-utilities/u-flex.scss +0 -35
  229. package/src/07-utilities/u-margin.scss +0 -5
  230. package/src/07-utilities/u-padding.scss +0 -5
  231. package/src/07-utilities/u-text.scss +0 -33
  232. package/src/07-utilities/utilities.scss +0 -5
  233. package/static/css/components.css +0 -4
  234. package/static/css/objects.css +0 -21
  235. package/static/css/prism.css +0 -126
  236. package/static/js/prism.js +0 -8
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Pattern Routes
3
+ *
4
+ * Given an object containing two levels of keys, the first for pattern types,
5
+ * and the second for pattern names of that type with a value of an array
6
+ * containing the variants - e.g.:
7
+ *
8
+ * {
9
+ * components: {
10
+ * 'c-button': [ 'brand-basic', 'prototype' ]
11
+ * },
12
+ * objects: {
13
+ * 'o-nav': [ 'prototype' ]
14
+ * }
15
+ * }
16
+ *
17
+ * Return an array with routes for every pattern in the object.
18
+ *
19
+ * @param {object} patternsObj - An object with two levels of keys where patternObj['components']['c-link'] is an array of c-link variants.
20
+ * @return {array} - An array of string routes e.g. [ '/components/c-link/', '/components/c-link/sponsored' ]
21
+ */
22
+
23
+ const chalk = require( 'chalk' );
24
+
25
+ module.exports = function getPatternRoutes( patterns ) {
26
+
27
+ let patternRoutes = [];
28
+
29
+ try {
30
+
31
+ patternRoutes = Object.keys( patterns ).map( ( type ) => {
32
+
33
+ return Object.keys( patterns[type] ).map( ( name ) => {
34
+ let path = `${type}/${name}`;
35
+
36
+ if ( patterns[type][name].length > 1 ) {
37
+
38
+ return patterns[type][name].map( ( variant ) => {
39
+ if ( 'prototype' !== variant ) {
40
+ return path + '/' + variant;
41
+ } else {
42
+ return path;
43
+ }
44
+ } );
45
+
46
+ } else {
47
+ return path;
48
+ }
49
+
50
+ } ).flat();
51
+
52
+ } ).flat();
53
+ } catch ( error ) {
54
+ console.error( chalk.red( 'Could not build the pattern routes. Is the pattern object structure correct?' ), error );
55
+ }
56
+
57
+ return patternRoutes;
58
+ }
@@ -0,0 +1,15 @@
1
+ // Note 4/6/20 - This might not be necessary since we can use the directory name.
2
+ module.exports = function getPatternType ( patternName ) {
3
+ const patternNamespace = patternName.substring( 0, 2 );
4
+ let patternType = 'modules';
5
+
6
+ if ( 'o-' === patternNamespace ) {
7
+ patternType = 'objects';
8
+ }
9
+
10
+ if ( 'c-' === patternNamespace ) {
11
+ patternType = 'components';
12
+ }
13
+
14
+ return patternType;
15
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Return an array of "variants", or the pattern.XX.js from a
3
+ * given directory.
4
+ *
5
+ * @param {string} startPath - the pattern directory to search.
6
+ */
7
+
8
+ const fs = require( 'fs' );
9
+
10
+ // https://regex101.com/r/DgnTR4/2
11
+ const regex = new RegExp( '(.[^.]+)\.(.+)\.js$' );
12
+
13
+ module.exports = function getPatternVariants( startPath ) {
14
+
15
+ // Only return Node prototype files that follow pattern name.XX.js
16
+ const files = fs.readdirSync( startPath ).filter( ( file ) => {
17
+ if ( /.+\..*\.js$/.test( file ) ) {
18
+ return file;
19
+ }
20
+ } );
21
+
22
+ // Return array of the name of the variant e.g. XX in name.XX.js
23
+ return files.map( ( file ) => file.match( regex )[2] );
24
+ };
@@ -0,0 +1,11 @@
1
+ const isCoreTheme = require( './isCoreTheme' );
2
+
3
+ module.exports = function getPatternsIndexPath( config ) {
4
+ // TODO: add parent/child-esque logic for Larva patterns will occur i.e. the app
5
+ // should look first in the theme, then in larvaPatternsDir.
6
+ // if ( isCoreTheme( config ) ) {
7
+ return config.larvaPatternsDir;
8
+ // } else {
9
+ // return config.projectPatternsDir;
10
+ // }
11
+ }
@@ -0,0 +1,23 @@
1
+ const fs = require( 'fs' );
2
+ const chalk = require( 'chalk' );
3
+
4
+ /**
5
+ * Get Subdirectory names
6
+ *
7
+ * @param {string} path path to a directory containing subdirectories.
8
+ * @return {array} array of strings representing names of subdirectories.
9
+ *
10
+ * @link: https://stackoverflow.com/questions/18112204/get-all-directories-within-directory-nodejs
11
+ **/
12
+
13
+ module.exports = function getSubDirectoryNames( path ) {
14
+ try {
15
+ return fs.readdirSync( path ).filter( function( file ) {
16
+ if ( 'node_modules' !== file && 'fixtures' !== file ) {
17
+ return fs.statSync( path + '/' + file ).isDirectory();
18
+ }
19
+ });
20
+ } catch {
21
+ console.error( path + ' doesn\'t exist.' );
22
+ }
23
+ }
@@ -0,0 +1,8 @@
1
+
2
+ module.exports = function isCoreTheme( config ) {
3
+ if ( undefined === config.themePatternsDir ) {
4
+ return true;
5
+ }
6
+
7
+ return false;
8
+ }
@@ -0,0 +1,20 @@
1
+ const sass = require( 'node-sass' );
2
+ const path = require( 'path' );
3
+
4
+ module.exports = function renderSass( sassData ) {
5
+ return new Promise( ( resolve, reject ) => {
6
+ sass.render( {
7
+ data: sassData,
8
+ includePaths: [
9
+ path.resolve( process.cwd(), './node_modules'), // Command should be run from same directory as node_modules
10
+ path.resolve( process.cwd(), './src')
11
+ ]
12
+ }, ( err, result ) => {
13
+ if ( err ) {
14
+ reject( err );
15
+ }
16
+
17
+ resolve( result );
18
+ });
19
+ });
20
+ }
@@ -0,0 +1,26 @@
1
+ const spawn = require( 'cross-spawn' );
2
+
3
+ const getArgsFromCli = require( './getArgsFromCli' );
4
+
5
+ // Filter out the first CLI argument which is the Larva command,
6
+ // and not needed for the binary.
7
+ const cliArgsWithoutScriptName = ( () => {
8
+ let cliArgs = getArgsFromCli();
9
+
10
+ if ( cliArgs.length ) {
11
+ cliArgs.shift();
12
+ }
13
+
14
+ return cliArgs.length ? cliArgs : [];
15
+ } )();
16
+
17
+ module.exports = function spawnScript( binaryFile, scriptArgs ) {
18
+
19
+ spawn.sync(
20
+ binaryFile,
21
+ [
22
+ ... scriptArgs,
23
+ ... cliArgsWithoutScriptName
24
+ ], { stdio: 'inherit' }
25
+ );
26
+ };
@@ -0,0 +1,6 @@
1
+ const fs = require( 'fs' );
2
+
3
+ module.exports = function writePatternDataToFile( filepath, data ) {
4
+ let json = JSON.stringify( data );
5
+ fs.writeFileSync( filepath, json );
6
+ };
@@ -0,0 +1,53 @@
1
+ const path = require( 'path' );
2
+ const chalk = require( 'chalk' );
3
+ const fs = require( 'fs' );
4
+
5
+ const getPatternData = require( './utils/getPatternData' );
6
+ const getModuleNamesFromDirectory = require( './utils/getModuleNamesFromDirectory' );
7
+ const getPatternVariants = require( './utils/getPatternVariants' );
8
+ const writeJsonToFile = require( './utils/writeJsonToFile' );
9
+
10
+ // The fromLarva flag can come from CLI argument
11
+ module.exports = function writeJson( patternConfig, fromLarva = false ) {
12
+
13
+ const sourceDirectory = ( true === fromLarva ) ? patternConfig.larvaPatternsDir : patternConfig.projectPatternsDir;
14
+ const ignoredModules = patternConfig.ignoredModules ? patternConfig.ignoredModules : [];
15
+ const modulesArr = getModuleNamesFromDirectory( sourceDirectory, ignoredModules );
16
+
17
+ modulesArr.forEach( ( moduleName ) => {
18
+
19
+ const startPath = sourceDirectory + '/modules/' + moduleName;
20
+ const variants = getPatternVariants( startPath );
21
+
22
+ variants.forEach( ( variant ) => {
23
+
24
+ const moduleData = getPatternData( sourceDirectory, {
25
+ type: 'modules',
26
+ name: moduleName,
27
+ variant: variant
28
+ } );
29
+
30
+ const jsonDestPath = path.resolve( patternConfig.projectPatternsDir, '../../build/json/modules/' + moduleName + '.' + variant + '.json' );
31
+
32
+ // If JSON data and module prototype are the same, pass, otherwise write the data to file
33
+ let hasChanged = true;
34
+ try {
35
+ if ( fs.existsSync( jsonDestPath ) && JSON.stringify( require( jsonDestPath ) ) === JSON.stringify( moduleData ) ) {
36
+ hasChanged = false;
37
+ }
38
+ } catch ( error ) {
39
+ console.warn( error );
40
+ }
41
+
42
+ if ( hasChanged ) {
43
+ writeJsonToFile( jsonDestPath, moduleData );
44
+ console.log( chalk.green.bold( `Wrote JSON for ${moduleName}.${variant}` ) );
45
+ } else {
46
+ console.log( chalk.grey( `No updates in ${moduleName}.${variant}` ) );
47
+ }
48
+ }
49
+
50
+ );
51
+
52
+ } );
53
+ };
package/package.json CHANGED
@@ -1,17 +1,38 @@
1
1
  {
2
2
  "name": "@penskemediacorp/larva",
3
- "version": "1.2.1-alpha.0",
3
+ "version": "1.3.0",
4
4
  "description": "> TODO: description",
5
5
  "author": "laras126 <laras126@gmail.com>",
6
6
  "homepage": "https://github.com/Penske-Media-Corp/pmc-larva/tree/master/packages/larva#readme",
7
7
  "license": "MIT",
8
- "main": "lib/larva.js",
8
+ "main": "index.js",
9
+ "bin": {
10
+ "larva": "bin/larva.js"
11
+ },
9
12
  "repository": {
10
13
  "type": "git",
11
14
  "url": "git+https://github.com/Penske-Media-Corp/pmc-larva.git"
12
15
  },
13
16
  "scripts": {
14
- "test": "echo \"Error: run tests from root\" && exit 1"
17
+ "test": "echo \"Error: run tests from root\" && exit 1",
18
+ "update-larva-latest": "npm install --save @penskemediacorp/larva-scss@latest @penskemediacorp/larva-css@latest @penskemediacorp/larva-patterns@latest @penskemediacorp/larva-svg@latest @penskemediacorp/twig-to-php-parser@latest @penskemediacorp/larva-tokens@latest @penskemediacorp/larva-js@latest && npm run prod",
19
+ "larva": "bin/larva.js server --watch ../larva-patterns --watch src -e twig,js,html",
20
+ "backstop": "backstop --config=node_modules/@penskemediacorp/backstopjs-config",
21
+ "prod": "bin/larva.js prod-scss && bin/larva.js prod-js",
22
+ "prod:scss": "bin/larva.js prod-scss",
23
+ "prod:js": "bin/larva.js prod-js",
24
+ "dev": "concurrently \"npm:dev:scss\" \"npm:dev:js\" --raw",
25
+ "dev:scss": "bin/larva.js dev-scss",
26
+ "dev:js": "bin/larva.js dev-js",
27
+ "lint": "bin/larva.js lint-scss & larva lint-js",
28
+ "lint:scss": "bin/larva.js lint-scss",
29
+ "lint:js": "bin/larva.js lint-js ./",
30
+ "lint-fix": "bin/larva.js lint-scss --fix && npm run lint:js --fix",
31
+ "lint-fix:scss": "bin/larva.js lint-scss --fix",
32
+ "lint-fix:js": "bin/larva.js lint-js --fix",
33
+ "write-json": "bin/larva.js write-json larva && bin/larva.js write-json",
34
+ "build-icons": "bin/larva.js build-icons",
35
+ "build-html": "bin/larva.js build-html larva && bin/larva.js build-html project"
15
36
  },
16
37
  "publishConfig": {
17
38
  "access": "public"
@@ -20,7 +41,53 @@
20
41
  "url": "https://github.com/Penske-Media-Corp/pmc-larva/issues"
21
42
  },
22
43
  "dependencies": {
23
- "@penskemediacorp/larva-patterns": "^1.2.1-alpha.0"
44
+ "@babel/core": "^7.10.5",
45
+ "@babel/preset-env": "^7.10.4",
46
+ "@penskemediacorp/backstopjs-config": "^1.0.0",
47
+ "@penskemediacorp/eslint-config": "^1.1.1",
48
+ "@penskemediacorp/larva-css": "^1.3.0",
49
+ "@penskemediacorp/larva-js": "^1.0.0",
50
+ "@penskemediacorp/larva-patterns": "^1.3.0",
51
+ "@penskemediacorp/larva-scss": "^1.1.2",
52
+ "@penskemediacorp/larva-svg": "^1.1.3",
53
+ "@penskemediacorp/larva-tokens": "^1.0.0",
54
+ "@penskemediacorp/stylelint-config": "^1.0.0",
55
+ "@penskemediacorp/twig-to-php-parser": "^1.0.0",
56
+ "axios": "^0.21.1",
57
+ "babel-loader": "^8.1.0",
58
+ "chalk": "^4.1.0",
59
+ "clean-webpack-plugin": "^3.0.0",
60
+ "concurrently": "^5.2.0",
61
+ "cross-spawn": "^7.0.3",
62
+ "eslint": "^7.4.0",
63
+ "eslint-webpack-plugin": "^2.5.3",
64
+ "express": "^4.17.1",
65
+ "fibers": "^5.0.0",
66
+ "flickity": "^2.2.1",
67
+ "fs-extra": "^9.0.1",
68
+ "globby": "^11.0.1",
69
+ "gulp": "^4.0.2",
70
+ "gulp-clean": "^0.4.0",
71
+ "gulp-cli": "^2.3.0",
72
+ "gulp-if": "^3.0.0",
73
+ "gulp-ignore": "^3.0.0",
74
+ "gulp-postcss": "^8.0.0",
75
+ "gulp-rename": "^2.0.0",
76
+ "gulp-sass": "^4.1.0",
77
+ "gulp-stylelint": "^13.0.0",
78
+ "lodash.clonedeep": "^4.5.0",
79
+ "marked": "^4.0.10",
80
+ "node-sass-glob-importer": "^5.3.2",
81
+ "nodemon": "^2.0.4",
82
+ "postcss": "^7.0.35",
83
+ "sass": "^1.32.8",
84
+ "shelljs": "^0.8.5",
85
+ "stylelint": "^13.6.1",
86
+ "svg-sprite": "^1.5.0",
87
+ "svgo": "^1.3.2",
88
+ "twing": "5.1.0",
89
+ "webpack": "^4.43.0",
90
+ "webpack-cli": "^3.3.12"
24
91
  },
25
- "gitHead": "8ca5817f221f017210b43aa53a2a7cd1ac55678d"
92
+ "gitHead": "86a5d49bfc6d57168b4e1ffb70c646a5e59e4d6e"
26
93
  }
@@ -0,0 +1,22 @@
1
+
2
+ // Note: this should be in assets/public - added here in order to get webfonts working
3
+ // in pattern library w/o needing to add a theme-level webfontloader.
4
+
5
+ /* Web Font Loader v1.6.28 - (c) Adobe Systems, Google. License: Apache 2.0 */( function () {
6
+ function aa ( a, b, c ) { return a.call.apply( a.bind, arguments ) } function ba ( a, b, c ) { if ( !a ) throw Error(); if ( 2 < arguments.length ) { var d = Array.prototype.slice.call( arguments, 2 ); return function () { var c = Array.prototype.slice.call( arguments ); Array.prototype.unshift.apply( c, d ); return a.apply( b, c ) } } return function () { return a.apply( b, arguments ) } } function p ( a, b, c ) { p = Function.prototype.bind && -1 != Function.prototype.bind.toString().indexOf( "native code" ) ? aa : ba; return p.apply( null, arguments ) } var q = Date.now || function () { return +new Date }; function ca ( a, b ) { this.a = a; this.o = b || a; this.c = this.o.document } var da = !!window.FontFace; function t ( a, b, c, d ) { b = a.c.createElement( b ); if ( c ) for ( var e in c ) c.hasOwnProperty( e ) && ( "style" == e ? b.style.cssText = c[e] : b.setAttribute( e, c[e] ) ); d && b.appendChild( a.c.createTextNode( d ) ); return b } function u ( a, b, c ) { a = a.c.getElementsByTagName( b )[0]; a || ( a = document.documentElement ); a.insertBefore( c, a.lastChild ) } function v ( a ) { a.parentNode && a.parentNode.removeChild( a ) }
7
+ function w(a,b,c){b=b||[];c=c||[];for(var d=a.className.split(/\s+/),e=0;e<b.length;e+=1){for(var f=!1,g=0;g<d.length;g+=1)if(b[e]===d[g]){f=!0;break}f||d.push(b[e])}b=[];for(e=0;e<d.length;e+=1){f=!1;for(g=0;g<c.length;g+=1)if(d[e]===c[g]){f=!0;break}f||b.push(d[e])}a.className=b.join(" ").replace(/\s+/g," ").replace(/^\s+|\s+$/,"")}function y(a,b){for(var c=a.className.split(/\s+/),d=0,e=c.length;d<e;d++)if(c[d]==b)return!0;return!1}
8
+ function ea(a){return a.o.location.hostname||a.a.location.hostname}function z(a,b,c){function d(){m&&e&&f&&(m(g),m=null)}b=t(a,"link",{rel:"stylesheet",href:b,media:"all"});var e=!1,f=!0,g=null,m=c||null;da?(b.onload=function(){e=!0;d()},b.onerror=function(){e=!0;g=Error("Stylesheet failed to load");d()}):setTimeout(function(){e=!0;d()},0);u(a,"head",b)}
9
+ function A(a,b,c,d){var e=a.c.getElementsByTagName("head")[0];if(e){var f=t(a,"script",{src:b}),g=!1;f.onload=f.onreadystatechange=function(){g||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(g=!0,c&&c(null),f.onload=f.onreadystatechange=null,"HEAD"==f.parentNode.tagName&&e.removeChild(f))};e.appendChild(f);setTimeout(function(){g||(g=!0,c&&c(Error("Script load timeout")))},d||5E3);return f}return null};function B(){this.a=0;this.c=null}function C(a){a.a++;return function(){a.a--;D(a)}}function E(a,b){a.c=b;D(a)}function D(a){0==a.a&&a.c&&(a.c(),a.c=null)};function F(a){this.a=a||"-"}F.prototype.c=function(a){for(var b=[],c=0;c<arguments.length;c++)b.push(arguments[c].replace(/[\W_]+/g,"").toLowerCase());return b.join(this.a)};function G(a,b){this.c=a;this.f=4;this.a="n";var c=(b||"n4").match(/^([nio])([1-9])$/i);c&&(this.a=c[1],this.f=parseInt(c[2],10))}function fa(a){return H(a)+" "+(a.f+"00")+" 300px "+I(a.c)}function I(a){var b=[];a=a.split(/,\s*/);for(var c=0;c<a.length;c++){var d=a[c].replace(/['"]/g,"");-1!=d.indexOf(" ")||/^\d/.test(d)?b.push("'"+d+"'"):b.push(d)}return b.join(",")}function J(a){return a.a+a.f}function H(a){var b="normal";"o"===a.a?b="oblique":"i"===a.a&&(b="italic");return b}
10
+ function ga(a){var b=4,c="n",d=null;a&&((d=a.match(/(normal|oblique|italic)/i))&&d[1]&&(c=d[1].substr(0,1).toLowerCase()),(d=a.match(/([1-9]00|normal|bold)/i))&&d[1]&&(/bold/i.test(d[1])?b=7:/[1-9]00/.test(d[1])&&(b=parseInt(d[1].substr(0,1),10))));return c+b};function ha(a,b){this.c=a;this.f=a.o.document.documentElement;this.h=b;this.a=new F("-");this.j=!1!==b.events;this.g=!1!==b.classes}function ia(a){a.g&&w(a.f,[a.a.c("wf","loading")]);K(a,"loading")}function L(a){if(a.g){var b=y(a.f,a.a.c("wf","active")),c=[],d=[a.a.c("wf","loading")];b||c.push(a.a.c("wf","inactive"));w(a.f,c,d)}K(a,"inactive")}function K(a,b,c){if(a.j&&a.h[b])if(c)a.h[b](c.c,J(c));else a.h[b]()};function ja(){this.c={}}function ka(a,b,c){var d=[],e;for(e in b)if(b.hasOwnProperty(e)){var f=a.c[e];f&&d.push(f(b[e],c))}return d};function M(a,b){this.c=a;this.f=b;this.a=t(this.c,"span",{"aria-hidden":"true"},this.f)}function N(a){u(a.c,"body",a.a)}function O(a){return"display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:"+I(a.c)+";"+("font-style:"+H(a)+";font-weight:"+(a.f+"00")+";")};function P(a,b,c,d,e,f){this.g=a;this.j=b;this.a=d;this.c=c;this.f=e||3E3;this.h=f||void 0}P.prototype.start=function(){var a=this.c.o.document,b=this,c=q(),d=new Promise(function(d,e){function f(){q()-c>=b.f?e():a.fonts.load(fa(b.a),b.h).then(function(a){1<=a.length?d():setTimeout(f,25)},function(){e()})}f()}),e=null,f=new Promise(function(a,d){e=setTimeout(d,b.f)});Promise.race([f,d]).then(function(){e&&(clearTimeout(e),e=null);b.g(b.a)},function(){b.j(b.a)})};function Q(a,b,c,d,e,f,g){this.v=a;this.B=b;this.c=c;this.a=d;this.s=g||"BESbswy";this.f={};this.w=e||3E3;this.u=f||null;this.m=this.j=this.h=this.g=null;this.g=new M(this.c,this.s);this.h=new M(this.c,this.s);this.j=new M(this.c,this.s);this.m=new M(this.c,this.s);a=new G(this.a.c+",serif",J(this.a));a=O(a);this.g.a.style.cssText=a;a=new G(this.a.c+",sans-serif",J(this.a));a=O(a);this.h.a.style.cssText=a;a=new G("serif",J(this.a));a=O(a);this.j.a.style.cssText=a;a=new G("sans-serif",J(this.a));a=
11
+ O(a);this.m.a.style.cssText=a;N(this.g);N(this.h);N(this.j);N(this.m)}var R={D:"serif",C:"sans-serif"},S=null;function T(){if(null===S){var a=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);S=!!a&&(536>parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}return S}Q.prototype.start=function(){this.f.serif=this.j.a.offsetWidth;this.f["sans-serif"]=this.m.a.offsetWidth;this.A=q();U(this)};
12
+ function la(a,b,c){for(var d in R)if(R.hasOwnProperty(d)&&b===a.f[R[d]]&&c===a.f[R[d]])return!0;return!1}function U(a){var b=a.g.a.offsetWidth,c=a.h.a.offsetWidth,d;(d=b===a.f.serif&&c===a.f["sans-serif"])||(d=T()&&la(a,b,c));d?q()-a.A>=a.w?T()&&la(a,b,c)&&(null===a.u||a.u.hasOwnProperty(a.a.c))?V(a,a.v):V(a,a.B):ma(a):V(a,a.v)}function ma(a){setTimeout(p(function(){U(this)},a),50)}function V(a,b){setTimeout(p(function(){v(this.g.a);v(this.h.a);v(this.j.a);v(this.m.a);b(this.a)},a),0)};function W(a,b,c){this.c=a;this.a=b;this.f=0;this.m=this.j=!1;this.s=c}var X=null;W.prototype.g=function(a){var b=this.a;b.g&&w(b.f,[b.a.c("wf",a.c,J(a).toString(),"active")],[b.a.c("wf",a.c,J(a).toString(),"loading"),b.a.c("wf",a.c,J(a).toString(),"inactive")]);K(b,"fontactive",a);this.m=!0;na(this)};
13
+ W.prototype.h=function(a){var b=this.a;if(b.g){var c=y(b.f,b.a.c("wf",a.c,J(a).toString(),"active")),d=[],e=[b.a.c("wf",a.c,J(a).toString(),"loading")];c||d.push(b.a.c("wf",a.c,J(a).toString(),"inactive"));w(b.f,d,e)}K(b,"fontinactive",a);na(this)};function na(a){0==--a.f&&a.j&&(a.m?(a=a.a,a.g&&w(a.f,[a.a.c("wf","active")],[a.a.c("wf","loading"),a.a.c("wf","inactive")]),K(a,"active")):L(a.a))};function oa(a){this.j=a;this.a=new ja;this.h=0;this.f=this.g=!0}oa.prototype.load=function(a){this.c=new ca(this.j,a.context||this.j);this.g=!1!==a.events;this.f=!1!==a.classes;pa(this,new ha(this.c,a),a)};
14
+ function qa(a,b,c,d,e){var f=0==--a.h;(a.f||a.g)&&setTimeout(function(){var a=e||null,m=d||null||{};if(0===c.length&&f)L(b.a);else{b.f+=c.length;f&&(b.j=f);var h,l=[];for(h=0;h<c.length;h++){var k=c[h],n=m[k.c],r=b.a,x=k;r.g&&w(r.f,[r.a.c("wf",x.c,J(x).toString(),"loading")]);K(r,"fontloading",x);r=null;if(null===X)if(window.FontFace){var x=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),xa=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);
15
+ X=x?42<parseInt(x[1],10):xa?!1:!0}else X=!1;X?r=new P(p(b.g,b),p(b.h,b),b.c,k,b.s,n):r=new Q(p(b.g,b),p(b.h,b),b.c,k,b.s,a,n);l.push(r)}for(h=0;h<l.length;h++)l[h].start()}},0)}function pa(a,b,c){var d=[],e=c.timeout;ia(b);var d=ka(a.a,c,a.c),f=new W(a.c,b,e);a.h=d.length;b=0;for(c=d.length;b<c;b++)d[b].load(function(b,d,c){qa(a,f,b,d,c)})};function ra(a,b){this.c=a;this.a=b}
16
+ ra.prototype.load=function(a){function b(){if(f["__mti_fntLst"+d]){var c=f["__mti_fntLst"+d](),e=[],h;if(c)for(var l=0;l<c.length;l++){var k=c[l].fontfamily;void 0!=c[l].fontStyle&&void 0!=c[l].fontWeight?(h=c[l].fontStyle+c[l].fontWeight,e.push(new G(k,h))):e.push(new G(k))}a(e)}else setTimeout(function(){b()},50)}var c=this,d=c.a.projectId,e=c.a.version;if(d){var f=c.c.o;A(this.c,(c.a.api||"https://fast.fonts.net/jsapi")+"/"+d+".js"+(e?"?v="+e:""),function(e){e?a([]):(f["__MonotypeConfiguration__"+
17
+ d]=function(){return c.a},b())}).id="__MonotypeAPIScript__"+d}else a([])};function sa(a,b){this.c=a;this.a=b}sa.prototype.load=function(a){var b,c,d=this.a.urls||[],e=this.a.families||[],f=this.a.testStrings||{},g=new B;b=0;for(c=d.length;b<c;b++)z(this.c,d[b],C(g));var m=[];b=0;for(c=e.length;b<c;b++)if(d=e[b].split(":"),d[1])for(var h=d[1].split(","),l=0;l<h.length;l+=1)m.push(new G(d[0],h[l]));else m.push(new G(d[0]));E(g,function(){a(m,f)})};function ta(a,b){a?this.c=a:this.c=ua;this.a=[];this.f=[];this.g=b||""}var ua="https://fonts.googleapis.com/css";function va(a,b){for(var c=b.length,d=0;d<c;d++){var e=b[d].split(":");3==e.length&&a.f.push(e.pop());var f="";2==e.length&&""!=e[1]&&(f=":");a.a.push(e.join(f))}}
18
+ function wa(a){if(0==a.a.length)throw Error("No fonts to load!");if(-1!=a.c.indexOf("kit="))return a.c;for(var b=a.a.length,c=[],d=0;d<b;d++)c.push(a.a[d].replace(/ /g,"+"));b=a.c+"?family="+c.join("%7C");0<a.f.length&&(b+="&subset="+a.f.join(","));0<a.g.length&&(b+="&text="+encodeURIComponent(a.g));return b};function ya(a){this.f=a;this.a=[];this.c={}}
19
+ var za={latin:"BESbswy","latin-ext":"\u00e7\u00f6\u00fc\u011f\u015f",cyrillic:"\u0439\u044f\u0416",greek:"\u03b1\u03b2\u03a3",khmer:"\u1780\u1781\u1782",Hanuman:"\u1780\u1781\u1782"},Aa={thin:"1",extralight:"2","extra-light":"2",ultralight:"2","ultra-light":"2",light:"3",regular:"4",book:"4",medium:"5","semi-bold":"6",semibold:"6","demi-bold":"6",demibold:"6",bold:"7","extra-bold":"8",extrabold:"8","ultra-bold":"8",ultrabold:"8",black:"9",heavy:"9",l:"3",r:"4",b:"7"},Ba={i:"i",italic:"i",n:"n",normal:"n"},
20
+ Ca=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/;
21
+ function Da(a){for(var b=a.f.length,c=0;c<b;c++){var d=a.f[c].split(":"),e=d[0].replace(/\+/g," "),f=["n4"];if(2<=d.length){var g;var m=d[1];g=[];if(m)for(var m=m.split(","),h=m.length,l=0;l<h;l++){var k;k=m[l];if(k.match(/^[\w-]+$/)){var n=Ca.exec(k.toLowerCase());if(null==n)k="";else{k=n[2];k=null==k||""==k?"n":Ba[k];n=n[1];if(null==n||""==n)n="4";else var r=Aa[n],n=r?r:isNaN(n)?"4":n.substr(0,1);k=[k,n].join("")}}else k="";k&&g.push(k)}0<g.length&&(f=g);3==d.length&&(d=d[2],g=[],d=d?d.split(","):
22
+ g,0<d.length&&(d=za[d[0]])&&(a.c[e]=d))}a.c[e]||(d=za[e])&&(a.c[e]=d);for(d=0;d<f.length;d+=1)a.a.push(new G(e,f[d]))}};function Ea(a,b){this.c=a;this.a=b}var Fa={Arimo:!0,Cousine:!0,Tinos:!0};Ea.prototype.load=function(a){var b=new B,c=this.c,d=new ta(this.a.api,this.a.text),e=this.a.families;va(d,e);var f=new ya(e);Da(f);z(c,wa(d),C(b));E(b,function(){a(f.a,f.c,Fa)})};function Ga(a,b){this.c=a;this.a=b}Ga.prototype.load=function(a){var b=this.a.id,c=this.c.o;b?A(this.c,(this.a.api||"https://use.typekit.net")+"/"+b+".js",function(b){if(b)a([]);else if(c.Typekit&&c.Typekit.config&&c.Typekit.config.fn){b=c.Typekit.config.fn;for(var e=[],f=0;f<b.length;f+=2)for(var g=b[f],m=b[f+1],h=0;h<m.length;h++)e.push(new G(g,m[h]));try{c.Typekit.load({events:!1,classes:!1,async:!0})}catch(l){}a(e)}},2E3):a([])};function Ha(a,b){this.c=a;this.f=b;this.a=[]}Ha.prototype.load=function(a){var b=this.f.id,c=this.c.o,d=this;b?(c.__webfontfontdeckmodule__||(c.__webfontfontdeckmodule__={}),c.__webfontfontdeckmodule__[b]=function(b,c){for(var g=0,m=c.fonts.length;g<m;++g){var h=c.fonts[g];d.a.push(new G(h.name,ga("font-weight:"+h.weight+";font-style:"+h.style)))}a(d.a)},A(this.c,(this.f.api||"https://f.fontdeck.com/s/css/js/")+ea(this.c)+"/"+b+".js",function(b){b&&a([])})):a([])};var Y=new oa(window);Y.a.c.custom=function(a,b){return new sa(b,a)};Y.a.c.fontdeck=function(a,b){return new Ha(b,a)};Y.a.c.monotype=function(a,b){return new ra(b,a)};Y.a.c.typekit=function(a,b){return new Ga(b,a)};Y.a.c.google=function(a,b){return new Ea(b,a)};var Z={load:p(Y.load,Y)};"function"===typeof define&&define.amd?define(function(){return Z}):"undefined"!==typeof module&&module.exports?module.exports=Z:(window.WebFont=Z,window.WebFontConfig&&Y.load(window.WebFontConfig));}());
@@ -0,0 +1,52 @@
1
+ const chalk = require( 'chalk' );
2
+ const path = require( 'path' );
3
+
4
+ const getAppConfiguration = require( '../lib/utils/getAppConfiguration' );
5
+ const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
6
+ const generateStatic = require( '../lib/generateStatic' );
7
+ const getPatternRoutes = require( '../lib/utils/getPatternRoutes' );
8
+ const getAllPatternsObj = require( '../lib/utils/getAllPatternsObj' );
9
+
10
+ const config = getAppConfiguration( 'patterns' );
11
+ const cliArgs = getArgsFromCli();
12
+ const source = 'larva' === cliArgs[1] ? 'larva' : 'project';
13
+ const port = process.env.NODE_PORT || '3000' ;
14
+
15
+ const urlBase = 'http://localhost:' + port + '/' + source;
16
+ const buildPath = path.join( process.cwd(), './build/html/' + source );
17
+
18
+ const patternsObj = ( () => {
19
+ const patternDir = 'larva' === source ? config.larvaPatternsDir : config.projectPatternsDir;
20
+ return getAllPatternsObj( patternDir );
21
+ } )();
22
+
23
+ const routesArr = getPatternRoutes( patternsObj );
24
+
25
+ // Add a static, non-pattern paths.
26
+ const staticPaths = [
27
+ 'css',
28
+ 'style-guide',
29
+ 'components',
30
+ 'objects',
31
+ 'modules',
32
+ '',
33
+ ];
34
+
35
+ staticPaths.forEach( p => {
36
+ // Only build these paths for the larva source.
37
+ if ( p === 'style-guide' || p === 'css' ) {
38
+ if ( 'larva' !== source ) {
39
+ return;
40
+ }
41
+ }
42
+
43
+ routesArr.push( p )
44
+ });
45
+
46
+ generateStatic( routesArr, buildPath, ( message ) => {
47
+
48
+ // TODO: copy assets into build path
49
+ // copy assets from larva package to static
50
+ // copy assets from project to assets
51
+ console.log( message );
52
+ }, urlBase );
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ const SVGSpriter = require('svg-sprite');
4
+ const path = require('path');
5
+ const mkdirp = require('mkdirp');
6
+ const globby = require('globby');
7
+ const fs = require('fs');
8
+ const svgoConfig = require( './config/svgo-config.json' );
9
+
10
+ const projectIconsPath = path.join( process.cwd(), './src/svg/icons' );
11
+ const larvaIconsPath = path.join( process.cwd(), './node_modules/@penskemediacorp/larva-svg/src' );
12
+
13
+ // TODO: unfinished feature
14
+ // const getSassVarsString = require( './lib/getSassVarsString' );
15
+
16
+ const config = {
17
+ dest: 'build/svg',
18
+ log: null, // No logging
19
+ mode: {
20
+ defs: {
21
+ example: true,
22
+ sprite: 'sprite.defs.svg'
23
+ }
24
+ },
25
+ shape: {
26
+ id: {
27
+ separator: '',
28
+ },
29
+ transform: {
30
+ svgo: svgoConfig
31
+ }
32
+ },
33
+ svg: {
34
+ dimensionAttributes: false,
35
+ }
36
+ };
37
+
38
+ const spriter = new SVGSpriter( config );
39
+
40
+ const svgFiles = globby.sync( [ larvaIconsPath, projectIconsPath ], {
41
+ expandDirectories: {
42
+ extensions: [ 'svg' ],
43
+ }
44
+ });
45
+
46
+ // TODO: unfinished feature
47
+ // let scssIcons = {};
48
+
49
+ console.log( `Looking for icon SVGs in ${path.relative( process.cwd(), larvaIconsPath )} and ${path.relative( process.cwd(), projectIconsPath )}...` );
50
+
51
+ svgFiles.forEach( file => {
52
+ // TODO: unfinished feature.
53
+ // Build Sass vars object
54
+ // scssIcons[ path.basename( file, '.svg' ) ] = fs.readFileSync( file, { encoding: 'utf-8' } );
55
+
56
+ spriter.add( file, path.basename( file ), fs.readFileSync( file, { encoding: 'utf-8' } ) );
57
+ });
58
+
59
+ console.log( 'Building SVG icon sprite...' );
60
+
61
+ // Write the Sass variables.
62
+ // TODO: unfinished feature.
63
+ // fs.writeFileSync( path.join( process.cwd(), './build/a-icon-svg.scss' ), getSassVarsString( scssIcons ) );
64
+
65
+ // Compile the sprite
66
+ spriter.compile( function( error, result, cssData ) {
67
+
68
+ // Run through all configured output modes
69
+ for ( var mode in result ) {
70
+
71
+ // Run through all created resources and write them to disk
72
+ for ( var type in result[mode] ) {
73
+ mkdirp.sync( path.dirname( result[mode][type].path ) );
74
+ fs.writeFileSync( result[mode][type].path, result[mode][type].contents );
75
+ }
76
+
77
+ }
78
+
79
+ console.log( 'Completed building SVG icon sprite.' );
80
+ });
@@ -0,0 +1,15 @@
1
+ const path = require( 'path' );
2
+
3
+ const spawnScript = require( '../lib/utils/spawnScript' );
4
+
5
+ const gulpfilePath = path.join( __dirname, './config/gulpfile.js' );
6
+
7
+ const args = [
8
+ 'build-scss',
9
+ '--gulpfile',
10
+ gulpfilePath,
11
+ '--cwd',
12
+ process.cwd()
13
+ ];
14
+
15
+ spawnScript( './node_modules/.bin/gulp', args );
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "@penskemediacorp/eslint-config",
3
+ "overrides": [ {
4
+ "files": [
5
+ "**/*.js"
6
+ ],
7
+ "rules": {
8
+ "import/no-unresolved": "off"
9
+ }
10
+ } ]
11
+ }