@penskemediacorp/larva 1.25.0 → 1.28.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 (82) hide show
  1. package/__tests__/fixtures/larva.config.js +9 -16
  2. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.aia.js +2 -2
  3. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.js +2 -2
  4. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.js +1 -1
  5. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.prototype.js +2 -2
  6. package/__tests__/fixtures/src/patterns/components/c-tagline/c-tagline.prototype.js +2 -2
  7. package/__tests__/fixtures/src/patterns/modules/_also-ignored/_also-ignored.prototype.js +2 -2
  8. package/__tests__/fixtures/src/patterns/modules/test-module/test-module.featured.js +2 -2
  9. package/__tests__/fixtures/src/patterns/modules/test-module/test-module.prototype.js +2 -2
  10. package/__tests__/fixtures/src/patterns/one-offs/newswire/newswire.prototype.js +2 -2
  11. package/__tests__/lib/generateStatic.test.js +120 -86
  12. package/__tests__/lib/utils/clonePatternData.test.js +17 -10
  13. package/__tests__/lib/utils/getAllPatternsObj.test.js +14 -29
  14. package/__tests__/lib/utils/getAppConfiguration.test.js +5 -5
  15. package/__tests__/lib/utils/getModuleNamesFromDirectory.test.js +29 -10
  16. package/__tests__/lib/utils/getPatternData.test.js +36 -23
  17. package/__tests__/lib/utils/getPatternPathsToLoad.test.js +5 -5
  18. package/__tests__/lib/utils/getPatternRoutes.test.js +4 -6
  19. package/__tests__/lib/utils/getPatternType.test.js +4 -4
  20. package/__tests__/lib/utils/getPatternVariants.test.js +7 -12
  21. package/__tests__/lib/utils/getPatternsIndexPath.test.js +9 -4
  22. package/__tests__/lib/utils/getSubDirectoryNames.test.js +16 -6
  23. package/__tests__/lib/utils/isCoreTheme.test.js +5 -3
  24. package/__tests__/lib/utils/writeJsonToFile.test.js +8 -10
  25. package/__tests__/lib/writeJson.test.js +39 -21
  26. package/bin/larva.js +6 -6
  27. package/build/css/larva-important.css +1 -1
  28. package/build/css/larva.css +1 -1
  29. package/build/css/larva.inline-important.css +1 -1
  30. package/build/css/larva.inline.css +1 -1
  31. package/build/js/standalone/video-showcase.js +7 -7
  32. package/build/svg/defs/sprite.defs.html +1 -1
  33. package/build/tokens/spy-2022.custom-properties.css +1 -0
  34. package/build/tokens/spy-2022.json +521 -0
  35. package/build/tokens/spy-2022.map.scss +536 -0
  36. package/build/tokens/spy-2022.raw.json +4039 -0
  37. package/index.js +1 -1
  38. package/lib/generateStatic.js +67 -63
  39. package/lib/server.js +139 -117
  40. package/lib/start.js +1 -1
  41. package/lib/utils/clonePatternData.js +1 -1
  42. package/lib/utils/copySyncHelper.js +5 -6
  43. package/lib/utils/getAllPatternsObj.js +14 -9
  44. package/lib/utils/getAppConfiguration.js +17 -15
  45. package/lib/utils/getArgsFromCli.js +2 -2
  46. package/lib/utils/getModuleNamesFromDirectory.js +13 -6
  47. package/lib/utils/getPatternData.js +19 -11
  48. package/lib/utils/getPatternPathsToLoad.js +5 -5
  49. package/lib/utils/getPatternRoutes.js +29 -27
  50. package/lib/utils/getPatternType.js +3 -3
  51. package/lib/utils/getPatternVariants.js +5 -6
  52. package/lib/utils/getPatternsIndexPath.js +3 -3
  53. package/lib/utils/getSubDirectoryNames.js +5 -5
  54. package/lib/utils/isCoreTheme.js +1 -2
  55. package/lib/utils/renderSass.js +17 -14
  56. package/lib/utils/spawnScript.js +4 -9
  57. package/lib/utils/writeJsonToFile.js +2 -2
  58. package/lib/writeJson.js +34 -15
  59. package/package.json +15 -12
  60. package/scripts/build-html.js +21 -14
  61. package/scripts/build-icons.js +38 -26
  62. package/scripts/build-scss.js +1 -1
  63. package/scripts/config/.eslintrc.json +2 -1
  64. package/scripts/config/gulpfile.js +0 -1
  65. package/scripts/config/stylelint.config.js +1 -1
  66. package/scripts/config/webpack.config.js +22 -20
  67. package/scripts/dev-js.js +1 -1
  68. package/scripts/dev-scss.js +2 -7
  69. package/scripts/help.js +9 -7
  70. package/scripts/init.js +4 -2
  71. package/scripts/larva/larva.config.js +1 -1
  72. package/scripts/link-all.js +2 -2
  73. package/scripts/lint-js.js +1 -4
  74. package/scripts/lint-scss.js +5 -7
  75. package/scripts/lint.js +4 -4
  76. package/scripts/prod-js.js +1 -4
  77. package/scripts/prod-scss.js +5 -2
  78. package/scripts/prod.js +16 -22
  79. package/scripts/server.js +1 -3
  80. package/scripts/start.js +3 -3
  81. package/scripts/upgrade.js +10 -14
  82. package/scripts/write-json.js +4 -2
@@ -13,36 +13,41 @@ const config = getAppConfiguration( 'patterns' );
13
13
  * return an object representing all the pattern types, patterns, and their variants.
14
14
  *
15
15
  * @param {string} startPath - Path to look in for all patterns. Should be assets/src/patterns.
16
- * @return {object} - Object representing all patterns and variants
16
+ * @return {Object} - Object representing all patterns and variants
17
17
  */
18
18
 
19
19
  module.exports = function getAllPatternsObj( startPath ) {
20
-
21
20
  const patternDirs = getSubDirectoryNames( startPath );
22
21
 
23
- let obj = {};
22
+ const obj = {};
24
23
 
25
24
  try {
26
25
  patternDirs.map( ( patternType ) => {
27
26
  let patterns = [];
28
- obj[patternType] = {};
27
+ obj[ patternType ] = {};
29
28
 
30
29
  // Modules can be ignored, which maybe is unecessary
31
30
  // but for now continue on that path.
32
31
  if ( 'modules' === patternType ) {
33
- patterns = getModuleNamesFromDirectory( startPath, config.ignoredModules );
32
+ patterns = getModuleNamesFromDirectory(
33
+ startPath,
34
+ config.ignoredModules
35
+ );
34
36
  } else {
35
- patterns = getSubDirectoryNames( path.join( startPath, patternType ) );
37
+ patterns = getSubDirectoryNames(
38
+ path.join( startPath, patternType )
39
+ );
36
40
  }
37
41
 
38
42
  patterns.map( ( pattern ) => {
39
- obj[patternType][pattern] = getPatternVariants( path.join( startPath, `${patternType}/${pattern}` ) );
43
+ obj[ patternType ][ pattern ] = getPatternVariants(
44
+ path.join( startPath, `${ patternType }/${ pattern }` )
45
+ );
40
46
  } );
41
-
42
47
  } );
43
48
  } catch ( e ) {
44
49
  console.error( e );
45
50
  }
46
51
 
47
52
  return obj;
48
- }
53
+ };
@@ -18,64 +18,66 @@ const path = require( 'path' );
18
18
  */
19
19
 
20
20
  const defaultConfig = {
21
-
22
21
  eslint: {
23
- configFile: path.join( __dirname, '../../scripts/config/.eslintrc.json' ),
22
+ configFile: path.join(
23
+ __dirname,
24
+ '../../scripts/config/.eslintrc.json'
25
+ ),
24
26
  },
25
27
 
26
28
  webpack: {
27
29
  aliases: {
28
30
  '@js': path.resolve( './src/js' ),
29
31
  '@npm': path.resolve( './node_modules' ),
30
- '@larva-js': path.resolve( './node_modules/@penskemediacorp/larva-js/src' ),
32
+ '@larva-js': path.resolve(
33
+ './node_modules/@penskemediacorp/larva-js/src'
34
+ ),
31
35
  },
32
36
  entries: {
33
37
  'larva-ui': path.resolve( './entries/larva-ui.entry.js' ),
34
- common: path.resolve( './entries/common.entry.js' )
35
- }
38
+ common: path.resolve( './entries/common.entry.js' ),
39
+ },
36
40
  },
37
41
 
38
42
  patterns: {
39
- larvaPatternsDir: path.resolve( './node_modules/@penskemediacorp/larva-patterns' ),
43
+ larvaPatternsDir: path.resolve(
44
+ './node_modules/@penskemediacorp/larva-patterns'
45
+ ),
40
46
  projectPatternsDir: path.resolve( './src/patterns' ),
41
47
  },
42
48
 
43
49
  assets: {
44
50
  path: ( () => {
45
-
46
51
  // Fragile way to detect existing Larva sites
47
52
  if ( fs.existsSync( path.resolve( './build/css' ) ) ) {
48
53
  return path.resolve( './' );
49
54
  }
50
55
 
51
56
  return path.resolve( './node_modules/@penskemediacorp/larva' );
52
- })(),
57
+ } )(),
53
58
  },
54
59
 
55
60
  themeAssets: {},
56
61
  };
57
62
 
58
63
  module.exports = function getAppConfiguration( key, usePackageDefault = true ) {
59
-
60
64
  try {
61
-
62
65
  let appRoot = process.cwd();
63
66
 
64
67
  if ( 'test' === process.env.NODE_ENV ) {
65
68
  appRoot = path.join( __dirname, '../../__tests__/fixtures/' );
66
69
  }
67
70
 
68
- let config = require( `${appRoot}/larva.config.js` );
71
+ const config = require( `${ appRoot }/larva.config.js` );
69
72
 
70
73
  // If config not found in approot, fallback to package default in root
71
- if ( undefined === config[key] && usePackageDefault ) {
74
+ if ( undefined === config[ key ] && usePackageDefault ) {
72
75
  return defaultConfig[ key ];
73
76
  }
74
77
 
75
- return config[key];
76
-
78
+ return config[ key ];
77
79
  } catch ( error ) {
78
- console.warn( 'Using default configuration. ');
80
+ console.warn( 'Using default configuration. ' );
79
81
 
80
82
  return defaultConfig[ key ];
81
83
  }
@@ -1,3 +1,3 @@
1
1
  module.exports = function getArgsFromCli() {
2
- return process.argv.slice(2);
3
- }
2
+ return process.argv.slice( 2 );
3
+ };
@@ -1,11 +1,18 @@
1
1
  const getSubDirectoryNames = require( './getSubDirectoryNames' );
2
2
  const path = require( 'path' );
3
3
 
4
- module.exports = function getModuleNamesFromDirectory( directory, ignoredModules = [] ) {
5
- let moduleNames = getSubDirectoryNames( path.join( directory , 'modules' ) );
4
+ module.exports = function getModuleNamesFromDirectory(
5
+ directory,
6
+ ignoredModules = []
7
+ ) {
8
+ const moduleNames = getSubDirectoryNames(
9
+ path.join( directory, 'modules' )
10
+ );
6
11
 
7
12
  return moduleNames.filter( ( moduleName ) => {
8
- return ! moduleName.startsWith( '_' ) && -1 === ignoredModules.indexOf( moduleName );
9
- });
10
-
11
- }
13
+ return (
14
+ ! moduleName.startsWith( '_' ) &&
15
+ -1 === ignoredModules.indexOf( moduleName )
16
+ );
17
+ } );
18
+ };
@@ -4,31 +4,39 @@ const path = require( 'path' );
4
4
  * Get Pattern Data
5
5
  *
6
6
  * @param {string} patternsPath
7
- * @param {object} params Object containing name of pattern
7
+ * @param {Object} params Object containing name of pattern
8
8
  */
9
9
  function getPatternData( patternsPath, params ) {
10
-
11
10
  const variant = params.variant || 'prototype';
12
- const patternPath = path.join( patternsPath, params.type, params.name, params.name + '.' + variant + '.js' );
13
- const jsonPath = path.join( patternsPath, params.type, params.name, params.name + '.json' )
11
+ const patternPath = path.join(
12
+ patternsPath,
13
+ params.type,
14
+ params.name,
15
+ params.name + '.' + variant + '.js'
16
+ );
17
+ const jsonPath = path.join(
18
+ patternsPath,
19
+ params.type,
20
+ params.name,
21
+ params.name + '.json'
22
+ );
14
23
 
15
24
  try {
16
25
  return require( patternPath );
17
- } catch( e ) {
26
+ } catch ( e ) {
18
27
  const originalError = e;
19
28
 
20
29
  try {
21
30
  // Backwards compat for Deadline when patterns were stored as JSON
22
- let patternData = require( jsonPath );
31
+ const patternData = require( jsonPath );
23
32
  return patternData;
24
33
  } catch ( e ) {
25
34
  return {
26
- message: `Error getting data for "${params.name}".<br>There is likely a problem with ${params.name}.${variant}.js.`,
27
- error: originalError
28
- }
35
+ message: `Error getting data for "${ params.name }".<br>There is likely a problem with ${ params.name }.${ variant }.js.`,
36
+ error: originalError,
37
+ };
29
38
  }
30
39
  }
31
-
32
40
  }
33
41
 
34
- module.exports = getPatternData;
42
+ module.exports = getPatternData;
@@ -1,20 +1,20 @@
1
1
  const fs = require( 'fs' );
2
2
 
3
3
  module.exports = function getPatternPathsToLoad( config ) {
4
- let paths = [];
4
+ const paths = [];
5
5
 
6
6
  if ( undefined === config ) {
7
7
  throw new Error( `Pattern configuration is undefined.` );
8
- };
8
+ }
9
9
 
10
10
  // Look in projectPatternsDir first.
11
- if( fs.existsSync( config.projectPatternsDir ) ) {
11
+ if ( fs.existsSync( config.projectPatternsDir ) ) {
12
12
  paths.push( config.projectPatternsDir );
13
13
  }
14
14
 
15
- if( fs.existsSync( config.larvaPatternsDir ) ) {
15
+ if ( fs.existsSync( config.larvaPatternsDir ) ) {
16
16
  paths.push( config.larvaPatternsDir );
17
17
  }
18
18
 
19
19
  return paths;
20
- }
20
+ };
@@ -16,43 +16,45 @@
16
16
  *
17
17
  * Return an array with routes for every pattern in the object.
18
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' ]
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
21
  */
22
22
 
23
23
  const chalk = require( 'chalk' );
24
24
 
25
25
  module.exports = function getPatternRoutes( patterns ) {
26
-
27
26
  let patternRoutes = [];
28
27
 
29
28
  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;
29
+ patternRoutes = Object.keys( patterns )
30
+ .map( ( type ) => {
31
+ return Object.keys( patterns[ type ] )
32
+ .map( ( name ) => {
33
+ const path = `${ type }/${ name }`;
34
+
35
+ if ( patterns[ type ][ name ].length > 1 ) {
36
+ return patterns[ type ][ name ].map(
37
+ ( variant ) => {
38
+ if ( 'prototype' !== variant ) {
39
+ return path + '/' + variant;
40
+ }
41
+ return path;
42
+ }
43
+ );
43
44
  }
44
- } );
45
-
46
- } else {
47
- return path;
48
- }
49
-
50
- } ).flat();
51
-
52
- } ).flat();
45
+ return path;
46
+ } )
47
+ .flat();
48
+ } )
49
+ .flat();
53
50
  } catch ( error ) {
54
- console.error( chalk.red( 'Could not build the pattern routes. Is the pattern object structure correct?' ), error );
51
+ console.error(
52
+ chalk.red(
53
+ 'Could not build the pattern routes. Is the pattern object structure correct?'
54
+ ),
55
+ error
56
+ );
55
57
  }
56
58
 
57
59
  return patternRoutes;
58
- }
60
+ };
@@ -1,9 +1,9 @@
1
1
  // Note 4/6/20 - This might not be necessary since we can use the directory name.
2
- module.exports = function getPatternType ( patternName ) {
2
+ module.exports = function getPatternType( patternName ) {
3
3
  const patternNamespace = patternName.substring( 0, 2 );
4
4
  let patternType = 'modules';
5
5
 
6
- if ( 'o-' === patternNamespace ) {
6
+ if ( 'o-' === patternNamespace ) {
7
7
  patternType = 'objects';
8
8
  }
9
9
 
@@ -12,4 +12,4 @@ module.exports = function getPatternType ( patternName ) {
12
12
  }
13
13
 
14
14
  return patternType;
15
- }
15
+ };
@@ -1,17 +1,16 @@
1
1
  /**
2
- * Return an array of "variants", or the pattern.XX.js from a
2
+ * Return an array of "variants", or the pattern.XX.js from a
3
3
  * given directory.
4
- *
4
+ *
5
5
  * @param {string} startPath - the pattern directory to search.
6
6
  */
7
7
 
8
8
  const fs = require( 'fs' );
9
9
 
10
10
  // https://regex101.com/r/DgnTR4/2
11
- const regex = new RegExp( '(.[^.]+)\.(.+)\.js$' );
11
+ const regex = new RegExp( '(.[^.]+).(.+).js$' );
12
12
 
13
13
  module.exports = function getPatternVariants( startPath ) {
14
-
15
14
  // Only return Node prototype files that follow pattern name.XX.js
16
15
  const files = fs.readdirSync( startPath ).filter( ( file ) => {
17
16
  if ( /.+\..*\.js$/.test( file ) ) {
@@ -20,5 +19,5 @@ module.exports = function getPatternVariants( startPath ) {
20
19
  } );
21
20
 
22
21
  // 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
- };
22
+ return files.map( ( file ) => file.match( regex )[ 2 ] );
23
+ };
@@ -1,11 +1,11 @@
1
1
  const isCoreTheme = require( './isCoreTheme' );
2
2
 
3
3
  module.exports = function getPatternsIndexPath( config ) {
4
- // TODO: add parent/child-esque logic for Larva patterns will occur i.e. the app
4
+ // TODO: add parent/child-esque logic for Larva patterns will occur i.e. the app
5
5
  // should look first in the theme, then in larvaPatternsDir.
6
6
  // if ( isCoreTheme( config ) ) {
7
- return config.larvaPatternsDir;
7
+ return config.larvaPatternsDir;
8
8
  // } else {
9
9
  // return config.projectPatternsDir;
10
10
  // }
11
- }
11
+ };
@@ -5,19 +5,19 @@ const chalk = require( 'chalk' );
5
5
  * Get Subdirectory names
6
6
  *
7
7
  * @param {string} path path to a directory containing subdirectories.
8
- * @return {array} array of strings representing names of subdirectories.
8
+ * @return {Array} array of strings representing names of subdirectories.
9
9
  *
10
10
  * @link: https://stackoverflow.com/questions/18112204/get-all-directories-within-directory-nodejs
11
11
  **/
12
12
 
13
13
  module.exports = function getSubDirectoryNames( path ) {
14
14
  try {
15
- return fs.readdirSync( path ).filter( function( file ) {
15
+ return fs.readdirSync( path ).filter( function ( file ) {
16
16
  if ( 'node_modules' !== file && 'fixtures' !== file ) {
17
17
  return fs.statSync( path + '/' + file ).isDirectory();
18
18
  }
19
- });
19
+ } );
20
20
  } catch {
21
- console.error( path + ' doesn\'t exist.' );
21
+ console.error( path + " doesn't exist." );
22
22
  }
23
- }
23
+ };
@@ -1,8 +1,7 @@
1
-
2
1
  module.exports = function isCoreTheme( config ) {
3
2
  if ( undefined === config.themePatternsDir ) {
4
3
  return true;
5
4
  }
6
5
 
7
6
  return false;
8
- }
7
+ };
@@ -3,18 +3,21 @@ const path = require( 'path' );
3
3
 
4
4
  module.exports = function renderSass( sassData ) {
5
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
- }
6
+ sass.render(
7
+ {
8
+ data: sassData,
9
+ includePaths: [
10
+ path.resolve( process.cwd(), './node_modules' ), // Command should be run from same directory as node_modules
11
+ path.resolve( process.cwd(), './src' ),
12
+ ],
13
+ },
14
+ ( err, result ) => {
15
+ if ( err ) {
16
+ reject( err );
17
+ }
16
18
 
17
- resolve( result );
18
- });
19
- });
20
- }
19
+ resolve( result );
20
+ }
21
+ );
22
+ } );
23
+ };
@@ -5,7 +5,7 @@ const getArgsFromCli = require( './getArgsFromCli' );
5
5
  // Filter out the first CLI argument which is the Larva command,
6
6
  // and not needed for the binary.
7
7
  const cliArgsWithoutScriptName = ( () => {
8
- let cliArgs = getArgsFromCli();
8
+ const cliArgs = getArgsFromCli();
9
9
 
10
10
  if ( cliArgs.length ) {
11
11
  cliArgs.shift();
@@ -15,12 +15,7 @@ const cliArgsWithoutScriptName = ( () => {
15
15
  } )();
16
16
 
17
17
  module.exports = function spawnScript( binaryFile, scriptArgs ) {
18
-
19
- spawn.sync(
20
- binaryFile,
21
- [
22
- ... scriptArgs,
23
- ... cliArgsWithoutScriptName
24
- ], { stdio: 'inherit' }
25
- );
18
+ spawn.sync( binaryFile, [ ...scriptArgs, ...cliArgsWithoutScriptName ], {
19
+ stdio: 'inherit',
20
+ } );
26
21
  };
@@ -1,6 +1,6 @@
1
1
  const fs = require( 'fs' );
2
2
 
3
3
  module.exports = function writePatternDataToFile( filepath, data ) {
4
- let json = JSON.stringify( data );
4
+ const json = JSON.stringify( data );
5
5
  fs.writeFileSync( filepath, json );
6
- };
6
+ };
package/lib/writeJson.js CHANGED
@@ -9,30 +9,46 @@ const writeJsonToFile = require( './utils/writeJsonToFile' );
9
9
 
10
10
  // The fromLarva flag can come from CLI argument
11
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 );
12
+ const sourceDirectory =
13
+ true === fromLarva
14
+ ? patternConfig.larvaPatternsDir
15
+ : patternConfig.projectPatternsDir;
16
+ const ignoredModules = patternConfig.ignoredModules
17
+ ? patternConfig.ignoredModules
18
+ : [];
19
+ const modulesArr = getModuleNamesFromDirectory(
20
+ sourceDirectory,
21
+ ignoredModules
22
+ );
16
23
 
17
24
  modulesArr.forEach( ( moduleName ) => {
18
-
19
25
  const startPath = sourceDirectory + '/modules/' + moduleName;
20
26
  const variants = getPatternVariants( startPath );
21
27
 
22
28
  variants.forEach( ( variant ) => {
23
-
24
29
  const moduleData = getPatternData( sourceDirectory, {
25
30
  type: 'modules',
26
31
  name: moduleName,
27
- variant: variant
32
+ variant,
28
33
  } );
29
34
 
30
- const jsonDestPath = path.resolve( patternConfig.projectPatternsDir, '../../build/json/modules/' + moduleName + '.' + variant + '.json' );
35
+ const jsonDestPath = path.resolve(
36
+ patternConfig.projectPatternsDir,
37
+ '../../build/json/modules/' +
38
+ moduleName +
39
+ '.' +
40
+ variant +
41
+ '.json'
42
+ );
31
43
 
32
44
  // If JSON data and module prototype are the same, pass, otherwise write the data to file
33
45
  let hasChanged = true;
34
46
  try {
35
- if ( fs.existsSync( jsonDestPath ) && JSON.stringify( require( jsonDestPath ) ) === JSON.stringify( moduleData ) ) {
47
+ if (
48
+ fs.existsSync( jsonDestPath ) &&
49
+ JSON.stringify( require( jsonDestPath ) ) ===
50
+ JSON.stringify( moduleData )
51
+ ) {
36
52
  hasChanged = false;
37
53
  }
38
54
  } catch ( error ) {
@@ -41,13 +57,16 @@ module.exports = function writeJson( patternConfig, fromLarva = false ) {
41
57
 
42
58
  if ( hasChanged ) {
43
59
  writeJsonToFile( jsonDestPath, moduleData );
44
- console.log( chalk.green.bold( `Wrote JSON for ${moduleName}.${variant}` ) );
60
+ console.log(
61
+ chalk.green.bold(
62
+ `Wrote JSON for ${ moduleName }.${ variant }`
63
+ )
64
+ );
45
65
  } else {
46
- console.log( chalk.grey( `No updates in ${moduleName}.${variant}` ) );
66
+ console.log(
67
+ chalk.grey( `No updates in ${ moduleName }.${ variant }` )
68
+ );
47
69
  }
48
- }
49
-
50
- );
51
-
70
+ } );
52
71
  } );
53
72
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@penskemediacorp/larva",
3
- "version": "1.25.0",
3
+ "version": "1.28.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",
@@ -43,16 +43,16 @@
43
43
  "dependencies": {
44
44
  "@babel/core": "^7.10.5",
45
45
  "@babel/preset-env": "^7.10.4",
46
- "@penskemediacorp/backstopjs-config": "^1.24.1",
47
- "@penskemediacorp/eslint-config": "^1.24.1",
48
- "@penskemediacorp/larva-css": "^1.25.0",
49
- "@penskemediacorp/larva-js": "^1.24.1",
50
- "@penskemediacorp/larva-patterns": "^1.25.0",
51
- "@penskemediacorp/larva-scss": "^1.24.1",
52
- "@penskemediacorp/larva-svg": "^1.24.1",
53
- "@penskemediacorp/larva-tokens": "^1.24.1",
54
- "@penskemediacorp/stylelint-config": "^1.24.1",
55
- "@penskemediacorp/twig-to-php-parser": "^1.24.1",
46
+ "@penskemediacorp/backstopjs-config": "^1.28.0",
47
+ "@penskemediacorp/eslint-config": "^1.28.0",
48
+ "@penskemediacorp/larva-css": "^1.28.0",
49
+ "@penskemediacorp/larva-js": "^1.28.0",
50
+ "@penskemediacorp/larva-patterns": "^1.28.0",
51
+ "@penskemediacorp/larva-scss": "^1.28.0",
52
+ "@penskemediacorp/larva-svg": "^1.28.0",
53
+ "@penskemediacorp/larva-tokens": "^1.28.0",
54
+ "@penskemediacorp/stylelint-config": "^1.28.0",
55
+ "@penskemediacorp/twig-to-php-parser": "^1.28.0",
56
56
  "axios": "^0.21.1",
57
57
  "babel-loader": "^8.1.0",
58
58
  "chalk": "^4.1.0",
@@ -89,5 +89,8 @@
89
89
  "webpack": "^4.43.0",
90
90
  "webpack-cli": "^3.3.12"
91
91
  },
92
- "gitHead": "d9e58ce95222a2ba4a7a8f1659bd34fea88b1911"
92
+ "devDependencies": {
93
+ "prettier": "npm:wp-prettier@^2.6.2"
94
+ },
95
+ "gitHead": "36e335324c72395c8ef8f1d98b204d19b53a23e2"
93
96
  }