@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
|
@@ -4,13 +4,13 @@ const assert = require( 'assert' );
|
|
|
4
4
|
describe( 'getPatternType', () => {
|
|
5
5
|
it( 'returns components for c-', () => {
|
|
6
6
|
assert.equal( getPatternType( 'c-nav-item' ), 'components' );
|
|
7
|
-
});
|
|
7
|
+
} );
|
|
8
8
|
|
|
9
9
|
it( 'returns objects for o-', () => {
|
|
10
10
|
assert.equal( getPatternType( 'o-nav' ), 'objects' );
|
|
11
|
-
});
|
|
11
|
+
} );
|
|
12
12
|
|
|
13
13
|
it( 'returns modules for no namespace', () => {
|
|
14
14
|
assert.equal( getPatternType( 'breadcrumbs' ), 'modules' );
|
|
15
|
-
});
|
|
16
|
-
});
|
|
15
|
+
} );
|
|
16
|
+
} );
|
|
@@ -5,16 +5,11 @@ const getPatternVariants = require( '../../../lib/utils/getPatternVariants' );
|
|
|
5
5
|
const config = getAppConfiguration( 'patterns' );
|
|
6
6
|
|
|
7
7
|
describe( 'getPatternVariants', () => {
|
|
8
|
-
|
|
9
8
|
it( 'returns an array of variants', () => {
|
|
10
|
-
expect(
|
|
11
|
-
getPatternVariants(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
]
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
9
|
+
expect(
|
|
10
|
+
getPatternVariants(
|
|
11
|
+
path.join( config.projectPatternsDir, 'components/c-nav-link/' )
|
|
12
|
+
)
|
|
13
|
+
).toEqual( [ 'featured.aia', 'featured', 'prototype' ] );
|
|
14
|
+
} );
|
|
15
|
+
} );
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
const assert = require( 'assert' );
|
|
2
|
-
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )(
|
|
2
|
+
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )(
|
|
3
|
+
'patterns'
|
|
4
|
+
);
|
|
3
5
|
const getPatternsIndexPath = require( '../../../lib/utils/getPatternsIndexPath' );
|
|
4
6
|
|
|
5
7
|
describe( 'getPatternsIndexPath', () => {
|
|
6
8
|
it( 'gets the path for larva if it is the core theme', () => {
|
|
7
|
-
assert.equal(
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
assert.equal(
|
|
10
|
+
getPatternsIndexPath( appConfiguration ).includes( 'larva' ),
|
|
11
|
+
true
|
|
12
|
+
);
|
|
13
|
+
} );
|
|
14
|
+
} );
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const assert = require( 'assert' );
|
|
2
2
|
const getPatternsList = require( '../../../lib/utils/getSubDirectoryNames' );
|
|
3
|
-
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )(
|
|
3
|
+
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )(
|
|
4
|
+
'patterns'
|
|
5
|
+
);
|
|
4
6
|
const expectedObjectsList = [ 'o-crap', 'o-nav' ];
|
|
5
7
|
const expectedComponentsList = [ 'c-nav-link', 'c-tagline' ];
|
|
6
8
|
|
|
@@ -8,10 +10,18 @@ console.log( appConfiguration.projectPatternsDir );
|
|
|
8
10
|
|
|
9
11
|
describe( 'getSubDirectoryNames', () => {
|
|
10
12
|
it( 'gets an array of subdir names for objects', () => {
|
|
11
|
-
assert.deepEqual(
|
|
12
|
-
|
|
13
|
+
assert.deepEqual(
|
|
14
|
+
getPatternsList( appConfiguration.projectPatternsDir + '/objects' ),
|
|
15
|
+
expectedObjectsList
|
|
16
|
+
);
|
|
17
|
+
} );
|
|
13
18
|
|
|
14
19
|
it( 'gets an array of subdir names for components', () => {
|
|
15
|
-
assert.deepEqual(
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
assert.deepEqual(
|
|
21
|
+
getPatternsList(
|
|
22
|
+
appConfiguration.projectPatternsDir + '/components'
|
|
23
|
+
),
|
|
24
|
+
expectedComponentsList
|
|
25
|
+
);
|
|
26
|
+
} );
|
|
27
|
+
} );
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const assert = require( 'assert' );
|
|
2
2
|
const isCoreTheme = require( '../../../lib/utils/isCoreTheme' );
|
|
3
|
-
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )(
|
|
3
|
+
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )(
|
|
4
|
+
'patterns'
|
|
5
|
+
);
|
|
4
6
|
|
|
5
7
|
describe( 'isCoreTheme', () => {
|
|
6
8
|
// TODO:
|
|
@@ -8,5 +10,5 @@ describe( 'isCoreTheme', () => {
|
|
|
8
10
|
// and if it is necessary other than in the parser.
|
|
9
11
|
it( 'is the core theme if there is no configuration for themePatternsDir', () => {
|
|
10
12
|
assert.equal( isCoreTheme( appConfiguration ), true );
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
+
} );
|
|
14
|
+
} );
|
|
@@ -8,22 +8,20 @@ const exec = require( 'child_process' ).exec;
|
|
|
8
8
|
const expectedData = '{"o_crap_classes":"hello class here"}';
|
|
9
9
|
|
|
10
10
|
describe( 'writeJsonToFile', () => {
|
|
11
|
-
|
|
12
|
-
let data = getPatternData( fixture, { type: 'objects', name: 'o-crap' } );
|
|
11
|
+
const data = getPatternData( fixture, { type: 'objects', name: 'o-crap' } );
|
|
13
12
|
writeJson( fixture + '/data.json', data );
|
|
14
|
-
|
|
13
|
+
|
|
15
14
|
it( 'writes o-crap json to a file', () => {
|
|
16
|
-
|
|
15
|
+
const data = fs.readFileSync( fixture + '/data.json' ).toString();
|
|
17
16
|
|
|
18
17
|
assert.equal( data, expectedData );
|
|
19
|
-
});
|
|
18
|
+
} );
|
|
20
19
|
|
|
21
20
|
afterAll( () => {
|
|
22
|
-
exec( 'rm ' + fixture + '/data.json', ( err
|
|
21
|
+
exec( 'rm ' + fixture + '/data.json', ( err ) => {
|
|
23
22
|
if ( err ) {
|
|
24
23
|
console.error( err );
|
|
25
24
|
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
});
|
|
25
|
+
} );
|
|
26
|
+
} );
|
|
27
|
+
} );
|
|
@@ -11,10 +11,22 @@ const patternConfig = getAppConfiguration( 'patterns' );
|
|
|
11
11
|
const expectedJsonPath = path.join( fixture, './build/json/modules/' );
|
|
12
12
|
|
|
13
13
|
describe( 'writeJson', () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const testJsonPath = path.join(
|
|
15
|
+
expectedJsonPath,
|
|
16
|
+
'test-module.prototype.json'
|
|
17
|
+
);
|
|
18
|
+
const testPrototypePath = path.join(
|
|
19
|
+
fixture,
|
|
20
|
+
'./src/patterns/modules/test-module/test-module.prototype.js'
|
|
21
|
+
);
|
|
22
|
+
const testVariantJsonPath = path.join(
|
|
23
|
+
expectedJsonPath,
|
|
24
|
+
'test-module.featured.json'
|
|
25
|
+
);
|
|
26
|
+
const testIgnoredJsonPath = path.join(
|
|
27
|
+
expectedJsonPath,
|
|
28
|
+
'ignore-me.prototype.json'
|
|
29
|
+
);
|
|
18
30
|
|
|
19
31
|
beforeAll( ( done ) => {
|
|
20
32
|
exec( 'mkdirp ' + expectedJsonPath, ( err ) => {
|
|
@@ -25,24 +37,27 @@ describe( 'writeJson', () => {
|
|
|
25
37
|
writeJson( patternConfig );
|
|
26
38
|
done();
|
|
27
39
|
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
40
|
+
} );
|
|
41
|
+
} );
|
|
30
42
|
|
|
31
43
|
it( 'creates a JSON file', () => {
|
|
32
44
|
assert.equal( fs.existsSync( testJsonPath ), true );
|
|
33
|
-
});
|
|
45
|
+
} );
|
|
34
46
|
|
|
35
47
|
it( 'prototype JS file equals JSON contents', () => {
|
|
36
|
-
assert.equal(
|
|
37
|
-
|
|
48
|
+
assert.equal(
|
|
49
|
+
JSON.stringify( require( testPrototypePath ) ),
|
|
50
|
+
JSON.stringify( require( testJsonPath ) )
|
|
51
|
+
);
|
|
52
|
+
} );
|
|
38
53
|
|
|
39
54
|
it( 'does not write JSON for ignored modules', () => {
|
|
40
55
|
assert.equal( fs.existsSync( testIgnoredJsonPath ), false );
|
|
41
|
-
});
|
|
56
|
+
} );
|
|
42
57
|
|
|
43
58
|
it( 'creates a variant JSON', () => {
|
|
44
59
|
assert.equal( fs.existsSync( testVariantJsonPath ), true );
|
|
45
|
-
});
|
|
60
|
+
} );
|
|
46
61
|
|
|
47
62
|
afterAll( ( done ) => {
|
|
48
63
|
exec( 'rm -r ' + path.join( expectedJsonPath ), ( err ) => {
|
|
@@ -50,12 +65,15 @@ describe( 'writeJson', () => {
|
|
|
50
65
|
console.error( err );
|
|
51
66
|
}
|
|
52
67
|
done();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
68
|
+
} );
|
|
69
|
+
} );
|
|
70
|
+
} );
|
|
56
71
|
|
|
57
72
|
describe( 'writeJson from Larva', () => {
|
|
58
|
-
|
|
73
|
+
const testJsonPath = path.join(
|
|
74
|
+
expectedJsonPath,
|
|
75
|
+
'pmc-footer.prototype.json'
|
|
76
|
+
);
|
|
59
77
|
|
|
60
78
|
beforeAll( ( done ) => {
|
|
61
79
|
exec( 'mkdirp ' + expectedJsonPath, ( err ) => {
|
|
@@ -65,12 +83,12 @@ describe( 'writeJson from Larva', () => {
|
|
|
65
83
|
writeJson( patternConfig, true );
|
|
66
84
|
done();
|
|
67
85
|
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
86
|
+
} );
|
|
87
|
+
} );
|
|
70
88
|
|
|
71
89
|
it( 'creates a JSON file', () => {
|
|
72
90
|
assert.equal( fs.existsSync( testJsonPath ), true );
|
|
73
|
-
});
|
|
91
|
+
} );
|
|
74
92
|
|
|
75
93
|
afterAll( ( done ) => {
|
|
76
94
|
exec( 'rm -r ' + path.join( expectedJsonPath ), ( err ) => {
|
|
@@ -78,6 +96,6 @@ describe( 'writeJson from Larva', () => {
|
|
|
78
96
|
console.error( err );
|
|
79
97
|
}
|
|
80
98
|
done();
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
99
|
+
} );
|
|
100
|
+
} );
|
|
101
|
+
} );
|
package/bin/larva.js
CHANGED
|
@@ -8,17 +8,17 @@ const chalk = require( 'chalk' );
|
|
|
8
8
|
|
|
9
9
|
const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
|
|
10
10
|
const cliArgs = getArgsFromCli();
|
|
11
|
-
const scriptName = cliArgs[0];
|
|
11
|
+
const scriptName = cliArgs[ 0 ];
|
|
12
12
|
|
|
13
|
-
const hasScriptFile = fs.existsSync(
|
|
13
|
+
const hasScriptFile = fs.existsSync(
|
|
14
|
+
path.join( __dirname, '../scripts/' + scriptName + '.js' )
|
|
15
|
+
);
|
|
14
16
|
|
|
15
17
|
if ( hasScriptFile ) {
|
|
16
18
|
spawn.sync(
|
|
17
19
|
'node',
|
|
18
|
-
[
|
|
19
|
-
|
|
20
|
-
... cliArgs
|
|
21
|
-
], { stdio: 'inherit' }
|
|
20
|
+
[ path.join( __dirname, `../scripts/${ scriptName }.js` ), ...cliArgs ],
|
|
21
|
+
{ stdio: 'inherit' }
|
|
22
22
|
);
|
|
23
23
|
} else {
|
|
24
24
|
console.error( chalk.red( `No file found for "${ scriptName }".` ) );
|