@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.
- package/__tests__/fixtures/larva.config.js +9 -16
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.aia.js +2 -2
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.js +2 -2
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.js +1 -1
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.prototype.js +2 -2
- package/__tests__/fixtures/src/patterns/components/c-tagline/c-tagline.prototype.js +2 -2
- package/__tests__/fixtures/src/patterns/modules/_also-ignored/_also-ignored.prototype.js +2 -2
- package/__tests__/fixtures/src/patterns/modules/test-module/test-module.featured.js +2 -2
- package/__tests__/fixtures/src/patterns/modules/test-module/test-module.prototype.js +2 -2
- package/__tests__/fixtures/src/patterns/one-offs/newswire/newswire.prototype.js +2 -2
- package/__tests__/lib/generateStatic.test.js +120 -86
- package/__tests__/lib/utils/clonePatternData.test.js +17 -10
- package/__tests__/lib/utils/getAllPatternsObj.test.js +14 -29
- package/__tests__/lib/utils/getAppConfiguration.test.js +5 -5
- package/__tests__/lib/utils/getModuleNamesFromDirectory.test.js +29 -10
- package/__tests__/lib/utils/getPatternData.test.js +36 -23
- package/__tests__/lib/utils/getPatternPathsToLoad.test.js +5 -5
- package/__tests__/lib/utils/getPatternRoutes.test.js +4 -6
- package/__tests__/lib/utils/getPatternType.test.js +4 -4
- package/__tests__/lib/utils/getPatternVariants.test.js +7 -12
- package/__tests__/lib/utils/getPatternsIndexPath.test.js +9 -4
- package/__tests__/lib/utils/getSubDirectoryNames.test.js +16 -6
- package/__tests__/lib/utils/isCoreTheme.test.js +5 -3
- package/__tests__/lib/utils/writeJsonToFile.test.js +8 -10
- package/__tests__/lib/writeJson.test.js +39 -21
- package/bin/larva.js +6 -6
- package/build/css/larva-important.css +1 -1
- package/build/css/larva.css +1 -1
- package/build/css/larva.inline-important.css +1 -1
- package/build/css/larva.inline.css +1 -1
- package/build/js/standalone/video-showcase.js +7 -7
- package/build/svg/defs/sprite.defs.html +1 -1
- package/build/tokens/spy-2022.custom-properties.css +1 -0
- package/build/tokens/spy-2022.json +521 -0
- package/build/tokens/spy-2022.map.scss +536 -0
- package/build/tokens/spy-2022.raw.json +4039 -0
- package/index.js +1 -1
- package/lib/generateStatic.js +67 -63
- package/lib/server.js +139 -117
- package/lib/start.js +1 -1
- package/lib/utils/clonePatternData.js +1 -1
- package/lib/utils/copySyncHelper.js +5 -6
- package/lib/utils/getAllPatternsObj.js +14 -9
- package/lib/utils/getAppConfiguration.js +17 -15
- package/lib/utils/getArgsFromCli.js +2 -2
- package/lib/utils/getModuleNamesFromDirectory.js +13 -6
- package/lib/utils/getPatternData.js +19 -11
- package/lib/utils/getPatternPathsToLoad.js +5 -5
- package/lib/utils/getPatternRoutes.js +29 -27
- package/lib/utils/getPatternType.js +3 -3
- package/lib/utils/getPatternVariants.js +5 -6
- package/lib/utils/getPatternsIndexPath.js +3 -3
- package/lib/utils/getSubDirectoryNames.js +5 -5
- package/lib/utils/isCoreTheme.js +1 -2
- package/lib/utils/renderSass.js +17 -14
- package/lib/utils/spawnScript.js +4 -9
- package/lib/utils/writeJsonToFile.js +2 -2
- package/lib/writeJson.js +34 -15
- package/package.json +15 -12
- package/scripts/build-html.js +21 -14
- package/scripts/build-icons.js +38 -26
- package/scripts/build-scss.js +1 -1
- package/scripts/config/.eslintrc.json +2 -1
- package/scripts/config/gulpfile.js +0 -1
- package/scripts/config/stylelint.config.js +1 -1
- package/scripts/config/webpack.config.js +22 -20
- package/scripts/dev-js.js +1 -1
- package/scripts/dev-scss.js +2 -7
- package/scripts/help.js +9 -7
- package/scripts/init.js +4 -2
- package/scripts/larva/larva.config.js +1 -1
- package/scripts/link-all.js +2 -2
- package/scripts/lint-js.js +1 -4
- package/scripts/lint-scss.js +5 -7
- package/scripts/lint.js +4 -4
- package/scripts/prod-js.js +1 -4
- package/scripts/prod-scss.js +5 -2
- package/scripts/prod.js +16 -22
- package/scripts/server.js +1 -3
- package/scripts/start.js +3 -3
- package/scripts/upgrade.js +10 -14
- 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 {
|
|
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
|
-
|
|
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(
|
|
32
|
+
patterns = getModuleNamesFromDirectory(
|
|
33
|
+
startPath,
|
|
34
|
+
config.ignoredModules
|
|
35
|
+
);
|
|
34
36
|
} else {
|
|
35
|
-
patterns = getSubDirectoryNames(
|
|
37
|
+
patterns = getSubDirectoryNames(
|
|
38
|
+
path.join( startPath, patternType )
|
|
39
|
+
);
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
patterns.map( ( pattern ) => {
|
|
39
|
-
obj[patternType][pattern] = getPatternVariants(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
5
|
-
|
|
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
|
|
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 {
|
|
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(
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
20
|
-
* @return {
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} ).flat();
|
|
51
|
-
|
|
52
|
-
} ).flat();
|
|
45
|
+
return path;
|
|
46
|
+
} )
|
|
47
|
+
.flat();
|
|
48
|
+
} )
|
|
49
|
+
.flat();
|
|
53
50
|
} catch ( error ) {
|
|
54
|
-
console.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
|
|
2
|
+
module.exports = function getPatternType( patternName ) {
|
|
3
3
|
const patternNamespace = patternName.substring( 0, 2 );
|
|
4
4
|
let patternType = 'modules';
|
|
5
5
|
|
|
6
|
-
if ( 'o-' ===
|
|
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( '(.[^.]+)
|
|
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
|
-
|
|
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 {
|
|
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 +
|
|
21
|
+
console.error( path + " doesn't exist." );
|
|
22
22
|
}
|
|
23
|
-
}
|
|
23
|
+
};
|
package/lib/utils/isCoreTheme.js
CHANGED
package/lib/utils/renderSass.js
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
19
|
+
resolve( result );
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
} );
|
|
23
|
+
};
|
package/lib/utils/spawnScript.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
[
|
|
22
|
-
... scriptArgs,
|
|
23
|
-
... cliArgsWithoutScriptName
|
|
24
|
-
], { stdio: 'inherit' }
|
|
25
|
-
);
|
|
18
|
+
spawn.sync( binaryFile, [ ...scriptArgs, ...cliArgsWithoutScriptName ], {
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
} );
|
|
26
21
|
};
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
32
|
+
variant,
|
|
28
33
|
} );
|
|
29
34
|
|
|
30
|
-
const jsonDestPath = path.resolve(
|
|
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 (
|
|
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(
|
|
60
|
+
console.log(
|
|
61
|
+
chalk.green.bold(
|
|
62
|
+
`Wrote JSON for ${ moduleName }.${ variant }`
|
|
63
|
+
)
|
|
64
|
+
);
|
|
45
65
|
} else {
|
|
46
|
-
console.log(
|
|
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.
|
|
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.
|
|
47
|
-
"@penskemediacorp/eslint-config": "^1.
|
|
48
|
-
"@penskemediacorp/larva-css": "^1.
|
|
49
|
-
"@penskemediacorp/larva-js": "^1.
|
|
50
|
-
"@penskemediacorp/larva-patterns": "^1.
|
|
51
|
-
"@penskemediacorp/larva-scss": "^1.
|
|
52
|
-
"@penskemediacorp/larva-svg": "^1.
|
|
53
|
-
"@penskemediacorp/larva-tokens": "^1.
|
|
54
|
-
"@penskemediacorp/stylelint-config": "^1.
|
|
55
|
-
"@penskemediacorp/twig-to-php-parser": "^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
|
-
"
|
|
92
|
+
"devDependencies": {
|
|
93
|
+
"prettier": "npm:wp-prettier@^2.6.2"
|
|
94
|
+
},
|
|
95
|
+
"gitHead": "36e335324c72395c8ef8f1d98b204d19b53a23e2"
|
|
93
96
|
}
|