@penskemediacorp/larva 1.7.0-alpha.0 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +6 -0
- package/LICENSE +21 -0
- package/README.md +96 -37
- package/__tests__/fixtures/build/css/common.inline.css +1 -2
- package/__tests__/fixtures/{src/patterns/05-objects/_objects.scss → build/images/test.png} +0 -0
- package/__tests__/fixtures/build/js/larva-ui.js +1 -0
- package/__tests__/fixtures/build/svg/defs/sprite.svg +1 -0
- package/__tests__/fixtures/larva.config.js +18 -9
- package/__tests__/fixtures/public/some-library.js +1 -0
- package/__tests__/fixtures/src/patterns/{05-objects/o-crap/o-crap.scss → __tests__/.gitkeep} +0 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.aia.js +3 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.js +3 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.js +1 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.prototype.js +1 -1
- package/__tests__/fixtures/src/patterns/components/c-tagline/c-tagline.prototype.js +3 -0
- package/__tests__/fixtures/src/patterns/modules/_also-ignored/_also-ignored.prototype.js +3 -0
- package/__tests__/fixtures/src/patterns/modules/_also-ignored/_also-ignored.twig +3 -0
- package/__tests__/fixtures/src/patterns/modules/ignore-me/ignore-me.prototype.js +0 -0
- package/__tests__/fixtures/src/patterns/modules/ignore-me/ignore-me.twig +0 -0
- package/__tests__/fixtures/src/patterns/modules/test-module/test-module.featured.js +3 -0
- package/__tests__/fixtures/src/patterns/modules/test-module/test-module.prototype.js +3 -0
- package/__tests__/fixtures/src/patterns/modules/test-module/test-module.twig +0 -0
- package/__tests__/fixtures/src/patterns/one-offs/newswire/newswire.html +1 -0
- package/__tests__/fixtures/src/patterns/one-offs/newswire/newswire.prototype.js +3 -0
- package/__tests__/lib/generateStatic.test.js +140 -0
- package/__tests__/lib/utils/clonePatternData.test.js +16 -12
- package/__tests__/lib/utils/getAllPatternsObj.test.js +45 -0
- package/__tests__/lib/utils/getAppConfiguration.test.js +13 -0
- package/__tests__/lib/utils/getModuleNamesFromDirectory.test.js +23 -0
- package/__tests__/lib/utils/getPatternData.test.js +32 -5
- package/__tests__/lib/utils/getPatternRoutes.test.js +29 -0
- package/__tests__/lib/utils/getPatternVariants.test.js +20 -0
- package/__tests__/lib/utils/getSubDirectoryNames.test.js +17 -0
- package/__tests__/lib/writeJson.test.js +83 -0
- package/bin/larva.js +21 -6
- package/build/css/larva-important.css +1 -0
- package/build/css/larva-ui.css +1 -0
- package/build/css/larva.css +1 -0
- package/build/css/larva.inline-important.css +1 -0
- package/build/css/larva.inline.css +1 -0
- package/build/css/variety.compat-important.css +1 -0
- package/build/css/variety.compat.css +1 -0
- package/build/js/common.js +26 -0
- package/build/js/larva-ui.js +1 -0
- package/build/js/standalone/video-showcase.js +26 -0
- package/build/svg/brand-logo-white.svg +1 -0
- package/build/svg/brand-logo.svg +1 -0
- package/build/svg/defs/sprite.defs.html +852 -0
- package/build/svg/defs/sprite.defs.svg +1 -0
- package/build/svg/logo-404.svg +1 -0
- package/build/tokens/artinamerica.custom-properties.css +546 -0
- package/build/tokens/artinamerica.json +533 -0
- package/build/tokens/artinamerica.map.scss +546 -0
- package/build/tokens/artinamerica.raw.json +4341 -0
- package/build/tokens/artnews.custom-properties.css +550 -0
- package/build/tokens/artnews.json +536 -0
- package/build/tokens/artnews.map.scss +550 -0
- package/build/tokens/artnews.raw.json +4373 -0
- package/build/tokens/bbpro.custom-properties.css +96 -0
- package/build/tokens/bbpro.json +80 -0
- package/build/tokens/bbpro.map.scss +96 -0
- package/build/tokens/bbpro.raw.json +789 -0
- package/build/tokens/billboard.custom-properties.css +96 -0
- package/build/tokens/billboard.json +80 -0
- package/build/tokens/billboard.map.scss +96 -0
- package/build/tokens/billboard.raw.json +789 -0
- package/build/tokens/deadline.custom-properties.css +533 -0
- package/build/tokens/deadline.json +517 -0
- package/build/tokens/deadline.map.scss +533 -0
- package/build/tokens/deadline.raw.json +4204 -0
- package/build/tokens/default.custom-properties.css +533 -0
- package/build/tokens/default.json +517 -0
- package/build/tokens/default.map.scss +533 -0
- package/build/tokens/default.raw.json +4204 -0
- package/build/tokens/dirt.custom-properties.css +81 -0
- package/build/tokens/dirt.json +66 -0
- package/build/tokens/dirt.map.scss +81 -0
- package/build/tokens/dirt.raw.json +690 -0
- package/build/tokens/indiewire.custom-properties.css +536 -0
- package/build/tokens/indiewire.json +520 -0
- package/build/tokens/indiewire.map.scss +536 -0
- package/build/tokens/indiewire.raw.json +4221 -0
- package/build/tokens/rivet.custom-properties.css +82 -0
- package/build/tokens/rivet.json +68 -0
- package/build/tokens/rivet.map.scss +82 -0
- package/build/tokens/rivet.raw.json +703 -0
- package/build/tokens/robbreport.custom-properties.css +536 -0
- package/build/tokens/robbreport.json +518 -0
- package/build/tokens/robbreport.map.scss +536 -0
- package/build/tokens/robbreport.raw.json +4215 -0
- package/build/tokens/rollingstone-2022.custom-properties.css +534 -0
- package/build/tokens/rollingstone-2022.json +519 -0
- package/build/tokens/rollingstone-2022.map.scss +534 -0
- package/build/tokens/rollingstone-2022.raw.json +4035 -0
- package/build/tokens/rollingstone.custom-properties.css +530 -0
- package/build/tokens/rollingstone.json +518 -0
- package/build/tokens/rollingstone.map.scss +530 -0
- package/build/tokens/rollingstone.raw.json +4207 -0
- package/build/tokens/sheknows.custom-properties.css +92 -0
- package/build/tokens/sheknows.json +76 -0
- package/build/tokens/sheknows.map.scss +92 -0
- package/build/tokens/sheknows.raw.json +761 -0
- package/build/tokens/sourcingjournal.custom-properties.css +87 -0
- package/build/tokens/sourcingjournal.json +70 -0
- package/build/tokens/sourcingjournal.map.scss +87 -0
- package/build/tokens/sourcingjournal.raw.json +720 -0
- package/build/tokens/sportico.custom-properties.css +73 -0
- package/build/tokens/sportico.json +59 -0
- package/build/tokens/sportico.map.scss +73 -0
- package/build/tokens/sportico.raw.json +640 -0
- package/build/tokens/thr.custom-properties.css +83 -0
- package/build/tokens/thr.json +67 -0
- package/build/tokens/thr.map.scss +83 -0
- package/build/tokens/thr.raw.json +698 -0
- package/build/tokens/variety-compat.custom-properties.css +36 -0
- package/build/tokens/variety-compat.json +33 -0
- package/build/tokens/variety-compat.map.scss +36 -0
- package/build/tokens/variety-compat.raw.json +224 -0
- package/build/tokens/variety-vip.custom-properties.css +532 -0
- package/build/tokens/variety-vip.json +521 -0
- package/build/tokens/variety-vip.map.scss +532 -0
- package/build/tokens/variety-vip.raw.json +4223 -0
- package/build/tokens/variety.custom-properties.css +534 -0
- package/build/tokens/variety.json +521 -0
- package/build/tokens/variety.map.scss +534 -0
- package/build/tokens/variety.raw.json +4225 -0
- package/build/tokens/vibe.custom-properties.css +77 -0
- package/build/tokens/vibe.json +63 -0
- package/build/tokens/vibe.map.scss +77 -0
- package/build/tokens/vibe.raw.json +668 -0
- package/build/tokens/wwd-2021.custom-properties.css +82 -0
- package/build/tokens/wwd-2021.json +67 -0
- package/build/tokens/wwd-2021.map.scss +82 -0
- package/build/tokens/wwd-2021.raw.json +701 -0
- package/build/tokens/wwd-beauty.custom-properties.css +86 -0
- package/build/tokens/wwd-beauty.json +70 -0
- package/build/tokens/wwd-beauty.map.scss +86 -0
- package/build/tokens/wwd-beauty.raw.json +719 -0
- package/build/tokens/wwd-dd.custom-properties.css +18 -0
- package/build/tokens/wwd-dd.json +13 -0
- package/build/tokens/wwd-dd.map.scss +18 -0
- package/build/tokens/wwd-dd.raw.json +90 -0
- package/build/tokens/wwd.custom-properties.css +70 -0
- package/build/tokens/wwd.json +60 -0
- package/build/tokens/wwd.map.scss +70 -0
- package/build/tokens/wwd.raw.json +643 -0
- package/index.js +2 -1
- package/lib/generateStatic.js +133 -0
- package/lib/server.js +262 -28
- package/lib/start.js +7 -0
- package/lib/utils/clonePatternData.js +12 -3
- package/lib/utils/copySyncHelper.js +33 -0
- package/lib/utils/getAllPatternsObj.js +48 -0
- package/lib/utils/getAppConfiguration.js +65 -7
- package/lib/utils/getArgsFromCli.js +3 -0
- package/lib/utils/getModuleNamesFromDirectory.js +11 -0
- package/lib/utils/getPatternData.js +19 -13
- package/lib/utils/getPatternPathsToLoad.js +5 -6
- package/lib/utils/getPatternRoutes.js +58 -0
- package/lib/utils/getPatternType.js +3 -2
- package/lib/utils/getPatternVariants.js +24 -0
- package/lib/utils/getSubDirectoryNames.js +23 -0
- package/lib/utils/spawnScript.js +26 -0
- package/lib/writeJson.js +53 -0
- package/package.json +67 -5
- package/public/webfontloader.js +22 -0
- package/scripts/build-html.js +52 -0
- package/scripts/build-icons.js +80 -0
- package/scripts/build-scss.js +15 -0
- package/scripts/config/.eslintrc.json +11 -0
- package/scripts/config/gulpfile.js +191 -0
- package/scripts/config/stylelint.config.js +5 -0
- package/scripts/config/svgo-config.json +67 -0
- package/scripts/config/webpack.config.js +95 -0
- package/scripts/dev-js.js +13 -0
- package/scripts/dev-scss.js +20 -0
- package/scripts/help.js +65 -0
- package/scripts/init.js +21 -0
- package/scripts/larva/.nvmrc +1 -0
- package/scripts/larva/README.md +29 -0
- package/scripts/larva/larva.config.js +3 -0
- package/scripts/larva/src/patterns/README.md +3 -0
- package/scripts/larva/src/patterns/base.html +6 -0
- package/scripts/larva/src/patterns/components/README.md +3 -0
- package/scripts/larva/src/patterns/modules/README.md +3 -0
- package/scripts/larva/src/patterns/objects/README.md +3 -0
- package/scripts/larva/src/patterns/one-offs/README.md +3 -0
- package/scripts/link-all.js +40 -0
- package/scripts/lint-js.js +11 -0
- package/scripts/lint-scss.js +13 -0
- package/scripts/lint.js +73 -0
- package/scripts/prod-js.js +12 -0
- package/scripts/prod-scss.js +24 -0
- package/scripts/prod.js +122 -0
- package/scripts/server.js +11 -0
- package/scripts/start.js +36 -0
- package/scripts/upgrade.js +99 -0
- package/scripts/write-json.js +14 -0
- package/.DS_Store +0 -0
- package/__tests__/.DS_Store +0 -0
- package/__tests__/_test-boilerplate.js +0 -12
- package/__tests__/fixtures/src/patterns/04-components/c-nav-link/c-nav-link.json +0 -3
- package/__tests__/fixtures/src/patterns/04-components/c-nav-link/c-nav-link.prototype.js +0 -3
- package/__tests__/fixtures/src/patterns/04-components/c-nav-link/c-nav-link.twig +0 -3
- package/__tests__/fixtures/src/patterns/05-objects/o-crap/o-crap.json +0 -3
- package/__tests__/fixtures/src/patterns/05-objects/o-crap/o-crap.twig +0 -1
- package/__tests__/fixtures/src/patterns/05-objects/o-nav/o-nav.twig +0 -14
- package/__tests__/fixtures/src/patterns/06-algorithms/a-icon/a-icon.common.inline.scss +0 -3
- package/__tests__/fixtures/src/patterns/06-algorithms/a-wrapper/a-wrapper.common.inline.scss +0 -3
- package/__tests__/fixtures/src/patterns/07-utilities/u-test-three.common.async.scss +0 -3
- package/__tests__/fixtures/src/patterns/07-utilities/u-test-two.common.inline.scss +0 -8
- package/__tests__/fixtures/src/patterns/07-utilities/u-test.common.inline.scss +0 -8
- package/__tests__/fixtures/src/patterns/08-modules/breadcrumbs/breadcrumbs.twig +0 -1
- package/__tests__/lib/build.test.js +0 -20
- package/__tests__/lib/utils/buildPatternFilePath.test.js +0 -18
- package/__tests__/lib/utils/concatenateFileData.test.js +0 -26
- package/__tests__/lib/utils/getPatternDataPath.test.js +0 -19
- package/__tests__/lib/utils/getPatternDigit.test.js +0 -13
- package/__tests__/lib/utils/getScssPathsWithExtension.test.js +0 -29
- package/__tests__/lib/utils/getScssResultCss.test.js +0 -16
- package/__tests__/lib/utils/getScssResultFilePath.test.js +0 -14
- package/lib/.DS_Store +0 -0
- package/lib/build.js +0 -16
- package/lib/utils/buildPatternFilePath.js +0 -13
- package/lib/utils/concatenateFileData.js +0 -19
- package/lib/utils/getPatternDataPath.js +0 -16
- package/lib/utils/getPatternDigit.js +0 -15
- package/lib/utils/getScssPathsWithExtension.js +0 -23
- package/lib/utils/getScssResultCss.js +0 -18
- package/lib/utils/getScssResultFilePath.js +0 -11
- package/lib/utils/utils.js +0 -16
- package/lib/watch.js +0 -33
- package/lib/writeData.js +0 -22
- package/static/css/components.css +0 -4
- package/static/css/objects.css +0 -21
- package/static/css/prism.css +0 -126
- package/static/js/prism.js +0 -8
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
|
|
3
|
+
const spawnScript = require( '../lib/utils/spawnScript' );
|
|
4
|
+
|
|
5
|
+
const configPath = path.join( __dirname, './config/webpack.config.js' );
|
|
6
|
+
|
|
7
|
+
const args = [
|
|
8
|
+
`--config=${ configPath }`,
|
|
9
|
+
'--mode=production'
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
spawnScript( './node_modules/.bin/webpack', args );
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
|
|
3
|
+
const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
|
|
4
|
+
const spawnScript = require( '../lib/utils/spawnScript' );
|
|
5
|
+
|
|
6
|
+
const gulpfilePath = path.join( __dirname, './config/gulpfile.js' );
|
|
7
|
+
|
|
8
|
+
const cliArgs = getArgsFromCli();
|
|
9
|
+
const generateImportantVariants = '--generate-important-variants' === cliArgs[1];
|
|
10
|
+
|
|
11
|
+
// Remove our arg so Gulp doesn't complain about an undefined task.
|
|
12
|
+
if ( generateImportantVariants ) {
|
|
13
|
+
process.argv.pop();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const args = [
|
|
17
|
+
generateImportantVariants ? 'prod-scss-with-important-variants' : 'prod-scss',
|
|
18
|
+
'--gulpfile',
|
|
19
|
+
gulpfilePath,
|
|
20
|
+
'--cwd',
|
|
21
|
+
process.cwd(),
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
spawnScript( './node_modules/.bin/gulp', args );
|
package/scripts/prod.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run a production ready build in a Larva project.
|
|
3
|
+
*
|
|
4
|
+
* ## OPTIONS
|
|
5
|
+
*
|
|
6
|
+
* [--help]
|
|
7
|
+
* : Display usage and examples for this command.
|
|
8
|
+
*
|
|
9
|
+
* [--parse]
|
|
10
|
+
* : Run the Twig-to-PHP parser.
|
|
11
|
+
*
|
|
12
|
+
* [--parser]
|
|
13
|
+
* : Alias for --parse.
|
|
14
|
+
*
|
|
15
|
+
* [--json]
|
|
16
|
+
* : Run the write-json script.
|
|
17
|
+
*
|
|
18
|
+
* [--write-json]
|
|
19
|
+
* : Alias for --json.
|
|
20
|
+
*
|
|
21
|
+
* [--css]
|
|
22
|
+
* : Build CSS assets.
|
|
23
|
+
*
|
|
24
|
+
* [--scss]
|
|
25
|
+
* : Alias for --css.
|
|
26
|
+
*
|
|
27
|
+
* [--js]
|
|
28
|
+
* : Build JavaScript assets.
|
|
29
|
+
*
|
|
30
|
+
* [--svg]
|
|
31
|
+
* : Build SVG assets.
|
|
32
|
+
*
|
|
33
|
+
* ## EXAMPLES
|
|
34
|
+
*
|
|
35
|
+
* # Run a full build
|
|
36
|
+
* $ npx @penskemediacorp/larva prod
|
|
37
|
+
*
|
|
38
|
+
* # Only run the write-json script.
|
|
39
|
+
* $ npx @penskemediacorp/larva prod --write-json
|
|
40
|
+
*
|
|
41
|
+
* # Run builds for CSS & JavaScript.
|
|
42
|
+
* $ npx @penskemediacorp/larva prod --css --js
|
|
43
|
+
*
|
|
44
|
+
* # Help command.
|
|
45
|
+
* $ npx @penskemediacorp/larva prod --help
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
// Dependencies.
|
|
49
|
+
const path = require( 'path' );
|
|
50
|
+
const shell = require( 'shelljs' );
|
|
51
|
+
|
|
52
|
+
// Construct some paths to point our scripts at.
|
|
53
|
+
const binPath = path.resolve( __dirname, '../bin/larva.js' ); // For sibling scripts.
|
|
54
|
+
|
|
55
|
+
// CLI arguments.
|
|
56
|
+
const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
|
|
57
|
+
const cliArgs = getArgsFromCli();
|
|
58
|
+
|
|
59
|
+
// Handle help command.
|
|
60
|
+
if ( cliArgs.includes( '--help' ) ) {
|
|
61
|
+
shell.exec( `npx @penskemediacorp/larva help prod` );
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Run the Twig-to-PHP parser.
|
|
66
|
+
if (
|
|
67
|
+
1 === cliArgs.length
|
|
68
|
+
|| cliArgs.includes( '--parser' )
|
|
69
|
+
|| cliArgs.includes( '--parse' )
|
|
70
|
+
) {
|
|
71
|
+
console.log( 'Parsing Twig templates\n\n' );
|
|
72
|
+
shell.exec( `npx @penskemediacorp/twig-to-php-parser` );
|
|
73
|
+
} else {
|
|
74
|
+
console.log( 'Skipping Twig templates\n' );
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Run the write-json script.
|
|
78
|
+
if (
|
|
79
|
+
1 === cliArgs.length
|
|
80
|
+
|| cliArgs.includes( '--json' )
|
|
81
|
+
|| cliArgs.includes( '--write-json' )
|
|
82
|
+
) {
|
|
83
|
+
console.log( 'Building JSON assets\n\n' );
|
|
84
|
+
shell.exec( `${binPath} write-json` );
|
|
85
|
+
} else {
|
|
86
|
+
console.log( 'Skipping write-json\n' );
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Build CSS/SCSS.
|
|
90
|
+
if (
|
|
91
|
+
1 === cliArgs.length
|
|
92
|
+
|| cliArgs.includes( '--css' )
|
|
93
|
+
|| cliArgs.includes( '--scss' )
|
|
94
|
+
) {
|
|
95
|
+
console.log( 'Building CSS assets\n\n' );
|
|
96
|
+
shell.exec( `${binPath} prod-scss` );
|
|
97
|
+
} else {
|
|
98
|
+
console.log( 'Skipping building CSS\n' );
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Build JS.
|
|
102
|
+
if (
|
|
103
|
+
1 === cliArgs.length
|
|
104
|
+
|| cliArgs.includes( '--js' )
|
|
105
|
+
) {
|
|
106
|
+
console.log( 'Building JavaScript assets\n\n' );
|
|
107
|
+
shell.exec( `${binPath} prod-js` );
|
|
108
|
+
} else {
|
|
109
|
+
console.log( 'Skipping building JavaScript\n' );
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Build SVG.
|
|
113
|
+
if (
|
|
114
|
+
1 === cliArgs.length
|
|
115
|
+
|| cliArgs.includes( '--svg' )
|
|
116
|
+
) {
|
|
117
|
+
console.log( 'Building SVG assets\n\n' );
|
|
118
|
+
shell.exec( `${binPath} build-icons` );
|
|
119
|
+
shell.exec( "npx svgo -f src/svg -o build/svg" );
|
|
120
|
+
} else {
|
|
121
|
+
console.log( 'Skipping building the SVGs\n' );
|
|
122
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
|
|
3
|
+
const spawnScript = require( '../lib/utils/spawnScript' );
|
|
4
|
+
|
|
5
|
+
const scriptLocation = path.join( __dirname, '../lib/start.js' );
|
|
6
|
+
|
|
7
|
+
const args = [
|
|
8
|
+
scriptLocation
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
spawnScript( './node_modules/.bin/nodemon', args );
|
package/scripts/start.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Start the Larva server.
|
|
3
|
+
*
|
|
4
|
+
* ## OPTIONS
|
|
5
|
+
*
|
|
6
|
+
* [--help]
|
|
7
|
+
* : Display usage and examples for this command.
|
|
8
|
+
*
|
|
9
|
+
* ## EXAMPLES
|
|
10
|
+
*
|
|
11
|
+
* # Start server.
|
|
12
|
+
* $ npx @penskemediacorp/larva start
|
|
13
|
+
*
|
|
14
|
+
* # Help command.
|
|
15
|
+
* $ npx @penskemediacorp/larva start --help
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// Dependencies.
|
|
19
|
+
const path = require( 'path' );
|
|
20
|
+
const shell = require( 'shelljs' );
|
|
21
|
+
|
|
22
|
+
// CLI arguments.
|
|
23
|
+
const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
|
|
24
|
+
const cliArgs = getArgsFromCli();
|
|
25
|
+
|
|
26
|
+
// Handle help command.
|
|
27
|
+
if ( cliArgs.includes( '--help' ) ) {
|
|
28
|
+
shell.exec( `npx @penskemediacorp/larva help start` );
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Construct some paths to point our scripts at.
|
|
33
|
+
const binPath = path.resolve( __dirname, '../bin/larva.js' ); // For sibling scripts.
|
|
34
|
+
const patternsPath = path.resolve( process.cwd(), './src/patterns' ); // Relative path to the patterns.
|
|
35
|
+
|
|
36
|
+
shell.exec( `${binPath} server --watch ${patternsPath} -e twig,html,js` );
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lint JavaScript and CSS files in a Larva project.
|
|
3
|
+
*
|
|
4
|
+
* ## OPTIONS
|
|
5
|
+
*
|
|
6
|
+
* [--help]
|
|
7
|
+
* : Display usage and examples for this command.
|
|
8
|
+
*
|
|
9
|
+
* [--version]
|
|
10
|
+
* : Optional. Version of Larva to install. Defaults to 'latest'.
|
|
11
|
+
*
|
|
12
|
+
* [--skip-css]
|
|
13
|
+
* : Skip building CSS assets.
|
|
14
|
+
*
|
|
15
|
+
* [--skip-js]
|
|
16
|
+
* : Skip building JavaScript assets.
|
|
17
|
+
*
|
|
18
|
+
* [--skip-build]
|
|
19
|
+
* : Skip building any assets.
|
|
20
|
+
*
|
|
21
|
+
* ## EXAMPLES
|
|
22
|
+
*
|
|
23
|
+
* # Upgrade to latest and kickoff a build.
|
|
24
|
+
* $ npx @penskemediacorp/larva upgrade
|
|
25
|
+
*
|
|
26
|
+
* # Skip building CSS assets.
|
|
27
|
+
* $ npx @penskemediacorp/larva upgrade --skip-css
|
|
28
|
+
*
|
|
29
|
+
* # Skip both CSS and JavaScript assets.
|
|
30
|
+
* $ npx @penskemediacorp/larva upgrade --skip-css --skip-js
|
|
31
|
+
*
|
|
32
|
+
* # Skip the entire build.
|
|
33
|
+
* $ npx @penskemediacorp/larva upgrade --skip-build
|
|
34
|
+
*
|
|
35
|
+
* # Upgrade to a specific version
|
|
36
|
+
* $ npx @penskemediacorp/larva upgrade --version=0.6.0
|
|
37
|
+
*
|
|
38
|
+
* # Help command.
|
|
39
|
+
* $ npx @penskemediacorp/larva upgrade --help
|
|
40
|
+
*/
|
|
41
|
+
// Dependencies.
|
|
42
|
+
const path = require( 'path' );
|
|
43
|
+
const shell = require( 'shelljs' );
|
|
44
|
+
|
|
45
|
+
// Construct some paths to point our scripts at.
|
|
46
|
+
const binPath = path.resolve( __dirname, '../bin/larva.js' ); // For sibling scripts.
|
|
47
|
+
|
|
48
|
+
// CLI arguments.
|
|
49
|
+
const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
|
|
50
|
+
const cliArgs = getArgsFromCli();
|
|
51
|
+
|
|
52
|
+
// Handle help command.
|
|
53
|
+
if ( cliArgs.includes( '--help' ) ) {
|
|
54
|
+
shell.exec( `npx @penskemediacorp/larva help upgrade` );
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Parse the --version flag. Defaults to 'latest'.
|
|
59
|
+
const getVersionArg = () => {
|
|
60
|
+
|
|
61
|
+
// Loop through our args, looking for `--version=`.
|
|
62
|
+
const versionFlag = cliArgs.find( ( cliArg ) => {
|
|
63
|
+
if ( ! cliArg.includes( '--version=' ) ) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
} );
|
|
68
|
+
|
|
69
|
+
// Did not find it.
|
|
70
|
+
if ( ! versionFlag ) {
|
|
71
|
+
return 'latest';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Trip the value down to just the version.
|
|
75
|
+
const version = versionFlag.replace( '--version=', '' );
|
|
76
|
+
return version ? version : 'latest';
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Update Larva version installed.
|
|
80
|
+
console.log( `Installing Larva@${getVersionArg()}\n\n` );
|
|
81
|
+
shell.exec( `npm install @penskemediacorp/larva@${getVersionArg()}` );
|
|
82
|
+
|
|
83
|
+
// Build CSS.
|
|
84
|
+
if (
|
|
85
|
+
! cliArgs.includes( '--skip-css' )
|
|
86
|
+
|| cliArgs.includes( '--skip-build' )
|
|
87
|
+
) {
|
|
88
|
+
console.log( 'Building CSS assets\n\n' );
|
|
89
|
+
shell.exec( `${binPath} prod-scss` );
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Build JavaScript.
|
|
93
|
+
if (
|
|
94
|
+
! cliArgs.includes( '--skip-js' )
|
|
95
|
+
|| cliArgs.includes( '--skip-build' )
|
|
96
|
+
) {
|
|
97
|
+
console.log( 'Building JavaScript assets\n\n' );
|
|
98
|
+
shell.exec( `${binPath} prod-js` );
|
|
99
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const chalk = require( 'chalk' );
|
|
2
|
+
|
|
3
|
+
const getAppConfiguration = require( '../lib/utils/getAppConfiguration' );
|
|
4
|
+
const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
|
|
5
|
+
const writeJson = require( '../lib/writeJson' );
|
|
6
|
+
|
|
7
|
+
const config = getAppConfiguration( 'patterns' );
|
|
8
|
+
const cliArgs = getArgsFromCli();
|
|
9
|
+
|
|
10
|
+
let fromLarva = 'larva' === cliArgs[1] ? true : false;
|
|
11
|
+
|
|
12
|
+
console.log( chalk.bold( `\n---- ${cliArgs[1] || 'Project'} JSON ----\n` ) );
|
|
13
|
+
|
|
14
|
+
writeJson( config, fromLarva );
|
package/.DS_Store
DELETED
|
Binary file
|
package/__tests__/.DS_Store
DELETED
|
Binary file
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const assert = require( 'assert' );
|
|
2
|
-
const path = require( 'path' );
|
|
3
|
-
const fixture = path.join( __dirname, '../../fixtures' );
|
|
4
|
-
|
|
5
|
-
// const { getProjectNodeModulesPath } = require( '../../../lib/utils/utils' );
|
|
6
|
-
// const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )('patterns');
|
|
7
|
-
|
|
8
|
-
describe( 'describe the test', () => {
|
|
9
|
-
it( 'does a thing', () => {
|
|
10
|
-
// assert.equal( 1, 1);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<p class="o-crap {{ modifier_class }} {{ o_crap_classes }}">{{ o_crap_text }}</p>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<nav class="o-nav {{ modifier_class }} {{ o_nav_classes }}" data-dropdown="{{ o_nav_data_attributes }}">
|
|
2
|
-
|
|
3
|
-
{% if o_nav_title_text %}
|
|
4
|
-
<h4 class="o-nav__title {{ o_nav_title_classes }}" data-dropdown-list-item="{{ o_nav_title_data_attributes }}"> {{ o_nav_title_text }}</h4>
|
|
5
|
-
{% endif %}
|
|
6
|
-
|
|
7
|
-
<ul class="o-nav__list {{ o_nav_list_classes }}" data-dropdown-list="{{ o_nav_list_data_attributes }}">
|
|
8
|
-
{% for item in o_nav_list_items %}
|
|
9
|
-
<li class="o-nav__list-item {{ o_nav_list_item_classes }}" data-dropdown-list-item="{{ o_nav_list_item_data_attributes }}">
|
|
10
|
-
{% include "../../04-components/c-nav-link/c-nav-link.twig" with item %}
|
|
11
|
-
</li>
|
|
12
|
-
{% endfor %}
|
|
13
|
-
</ul>
|
|
14
|
-
</nav>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{% include "@larva/o-nav.twig" with o_nav %}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const fs = require( 'fs' );
|
|
2
|
-
const assert = require( 'assert' );
|
|
3
|
-
const path = require( 'path' );
|
|
4
|
-
const build = require( '../../lib/build' );
|
|
5
|
-
const fixture = path.join( __dirname, '../fixtures' );
|
|
6
|
-
const getScssResultFilePath = require( '../../lib/utils/getScssResultFilePath' );
|
|
7
|
-
|
|
8
|
-
const changedFilePathStub = path.join( fixture, './src/patterns/06-algorithms/a-wrapper/a-wrapper.common.inline.scss' );
|
|
9
|
-
const resultFileStub = getScssResultFilePath( changedFilePathStub, 'common.inline' );
|
|
10
|
-
|
|
11
|
-
const beforeStat = fs.statSync( resultFileStub ).atime;
|
|
12
|
-
|
|
13
|
-
describe( 'build', () => {
|
|
14
|
-
|
|
15
|
-
// Not a great test, but better than nothing?
|
|
16
|
-
it( 'accesses the file to build', () => {
|
|
17
|
-
build( 'common.inline', changedFilePathStub );
|
|
18
|
-
assert.notEqual( fs.statSync( resultFileStub ).atime, beforeStat );
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const assert = require( 'assert' );
|
|
2
|
-
const path = require( 'path' );
|
|
3
|
-
const fixture = path.resolve( __dirname, '../../fixtures' );
|
|
4
|
-
const buildPatternFilePath = require( '../../../lib/utils/buildPatternFilePath' );
|
|
5
|
-
|
|
6
|
-
const expectedPathForLarva = fixture + '/src/patterns/objects/o-nav/o-nav.json';
|
|
7
|
-
const expectedPathForProject = '/assets/src/patterns/objects/o-nav/o-nav.json';
|
|
8
|
-
|
|
9
|
-
describe( 'buildPatternFilePath', () => {
|
|
10
|
-
|
|
11
|
-
it( 'builds a path for o-nav json in larva', () => {
|
|
12
|
-
assert.equal( buildPatternFilePath( fixture + '/src/patterns', 'o-nav', '.json' ), expectedPathForLarva );
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it( 'builds a path for o-nav json in consuming project', () => {
|
|
16
|
-
assert.equal( buildPatternFilePath( '/assets/src/patterns', 'o-nav', '.json' ), expectedPathForProject );
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const path = require( 'path' );
|
|
4
|
-
const { concatenateFileData } = require( '../../../lib/utils/utils' );
|
|
5
|
-
const fixture = path.resolve( __dirname, '../../fixtures' );
|
|
6
|
-
|
|
7
|
-
describe( 'concatenateFileData', () => {
|
|
8
|
-
it( 'concats data from files in array', () => {
|
|
9
|
-
let paths = [
|
|
10
|
-
path.join( fixture, './src/patterns/07-utilities/u-test.common.inline.scss' ),
|
|
11
|
-
path.join( fixture, './src/patterns/07-utilities/u-test-two.common.inline.scss' ),
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
let stringsExpected = [
|
|
15
|
-
'.test',
|
|
16
|
-
'.test-two'
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
return concatenateFileData( paths ).then( ( result ) => {
|
|
20
|
-
stringsExpected.forEach( string => {
|
|
21
|
-
expect( result ).toContain( string );
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const assert = require( 'assert' );
|
|
2
|
-
const path = require( 'path' );
|
|
3
|
-
const fixture = path.join( __dirname, '../../fixtures' );
|
|
4
|
-
const getPatternDataPath = require( '../../../lib/utils/getPatternDataPath' );
|
|
5
|
-
|
|
6
|
-
const expectedPrototypePath = path.join( fixture, 'src/patterns/components/c-nav-link/c-nav-link.prototype.js' );
|
|
7
|
-
const expectedJsonPath = path.join( fixture, 'src/patterns/objects/o-crap/o-crap.json' );
|
|
8
|
-
|
|
9
|
-
describe( 'getPatternDataPath', () => {
|
|
10
|
-
it( 'gets the path to .prototype.js if it exists', () => {
|
|
11
|
-
assert.equal( getPatternDataPath( fixture + '/src/patterns', 'c-nav-link' ), expectedPrototypePath );
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it( 'gets the path to .json if .prototype does not exist', () => {
|
|
15
|
-
assert.equal( getPatternDataPath( fixture + '/src/patterns', 'o-crap' ), expectedJsonPath );
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const assert = require( 'assert' );
|
|
2
|
-
const getPatternDigit = require( '../../../lib/utils/getPatternDigit' );
|
|
3
|
-
|
|
4
|
-
describe( 'getPatternDigit', () => {
|
|
5
|
-
|
|
6
|
-
it( 'returns 05 for objects', () => {
|
|
7
|
-
assert.equal( getPatternDigit( 'o-nav' ), '05-' );
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it( 'returns 08 for no namespace (modules)', () => {
|
|
11
|
-
assert.equal( getPatternDigit( 'breadcrumbs' ), '08-' );
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const path = require( 'path' );
|
|
2
|
-
const { getScssPathsWithExtension } = require( '../../../lib/utils/utils' );
|
|
3
|
-
const fixture = path.resolve( __dirname, '../../fixtures' );
|
|
4
|
-
const changedFilePathStub = path.join( fixture, './src/patterns/06-algorithms/a-wrapper/a-wrapper.common.inline.scss' );
|
|
5
|
-
|
|
6
|
-
describe('getScssPathsWithExtension', () => {
|
|
7
|
-
|
|
8
|
-
it( 'gets files from nested directories', () => {
|
|
9
|
-
return getScssPathsWithExtension( 'common.inline', changedFilePathStub )
|
|
10
|
-
.then( ( result ) => {
|
|
11
|
-
expect( result.length ).toBe( 4 ); // 2 in algorithms, 2 in utilities
|
|
12
|
-
console.log( result );
|
|
13
|
-
|
|
14
|
-
result.forEach( string => {
|
|
15
|
-
expect( path.parse( string ).name ).toContain( 'common.inline' );
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('gets only files with the .common.inline.scss extension', () => {
|
|
21
|
-
return getScssPathsWithExtension( 'common.inline', changedFilePathStub )
|
|
22
|
-
.then( ( result ) => {
|
|
23
|
-
expect( result.length ).toBe( 1 );
|
|
24
|
-
result.forEach( string => {
|
|
25
|
-
expect( path.parse( string ).name ).toContain( 'common.inline' );
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const assert = require( 'assert' );
|
|
2
|
-
const path = require( 'path' );
|
|
3
|
-
const fixture = path.join( __dirname, '../../fixtures' );
|
|
4
|
-
const changedFilePath = path.join( fixture, './src/patterns/06-algorithms/a-wrapper/a-wrapper.common.inline.scss' );
|
|
5
|
-
|
|
6
|
-
const getScssResultCss = require( '../../../lib/utils/getScssResultCss' );
|
|
7
|
-
|
|
8
|
-
describe( 'getScssResultCss', () => {
|
|
9
|
-
it( 'returns css from multiple scss files', () => {
|
|
10
|
-
|
|
11
|
-
return getScssResultCss( 'common.inline', changedFilePath ).then( ( result ) => {
|
|
12
|
-
// This string will be overridden if the files are not concatenating properly.
|
|
13
|
-
expect( result ).toEqual( expect.stringContaining( '.pmc-a-icon' ) );
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const assert = require( 'assert' );
|
|
2
|
-
const path = require( 'path' );
|
|
3
|
-
const fixture = path.join( __dirname, '../../fixtures' );
|
|
4
|
-
const getScssResultFilePath = require( '../../../lib/utils/getScssResultFilePath' );
|
|
5
|
-
|
|
6
|
-
const stubSassFilePath = '/path/to/css-utilities/src/07-utilities/u-thing/u-display.common.inline.scss';
|
|
7
|
-
|
|
8
|
-
const expectedResultFilePath = '/path/to/css-utilities/build/css/common.inline.css';
|
|
9
|
-
|
|
10
|
-
describe( 'getScssResultFilePath', () => {
|
|
11
|
-
it( 'gets the path of the output CSS file path', () => {
|
|
12
|
-
assert.equal( getScssResultFilePath( stubSassFilePath, 'common.inline' ), expectedResultFilePath );
|
|
13
|
-
});
|
|
14
|
-
});
|
package/lib/.DS_Store
DELETED
|
Binary file
|
package/lib/build.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const chalk = require( 'chalk' );
|
|
4
|
-
const fs = require( 'fs' );
|
|
5
|
-
const path = require( 'path' );
|
|
6
|
-
const getScssResultFilePath = require( './utils/getScssResultFilePath' );
|
|
7
|
-
const getScssResultCss = require( './utils/getScssResultCss' );
|
|
8
|
-
|
|
9
|
-
module.exports = function build( extension, changedFilePath ) {
|
|
10
|
-
let resultFile = getScssResultFilePath( changedFilePath, extension );
|
|
11
|
-
|
|
12
|
-
getScssResultCss( extension, changedFilePath ).then( ( resultCss ) => {
|
|
13
|
-
fs.writeFileSync( resultFile, resultCss );
|
|
14
|
-
}).catch( e => console.error( e ) );
|
|
15
|
-
|
|
16
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const getPatternType = require( './getPatternType' );
|
|
2
|
-
const getPatternDigit = require( './getPatternDigit' );
|
|
3
|
-
|
|
4
|
-
module.exports = function buildPatternFilePath( patternsPath, name, ext ) {
|
|
5
|
-
const patternType = getPatternType( name );
|
|
6
|
-
let patternDigit = getPatternDigit( name );
|
|
7
|
-
|
|
8
|
-
// if ( patternsPath.includes( 'larva' ) ) {
|
|
9
|
-
patternDigit = '';
|
|
10
|
-
// }
|
|
11
|
-
|
|
12
|
-
return patternsPath + '/' + patternDigit + patternType + '/' + name +'/' + name + ext;
|
|
13
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const fs = require( 'fs' );
|
|
2
|
-
const path = require( 'path' );
|
|
3
|
-
|
|
4
|
-
module.exports = function concatenateFileData( filePaths ) {
|
|
5
|
-
|
|
6
|
-
return new Promise( ( resolve, reject ) => {
|
|
7
|
-
let data = '';
|
|
8
|
-
|
|
9
|
-
filePaths.forEach( filePath => {
|
|
10
|
-
data += fs.readFileSync( filePath ).toString();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
if ( data === '' ) {
|
|
14
|
-
reject( 'No content with this file extension.' );
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
resolve( data );
|
|
18
|
-
});
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const fs = require( 'fs' );
|
|
2
|
-
const chalk = require( 'chalk' );
|
|
3
|
-
const buildPatternFilePath = require( './buildPatternFilePath' );
|
|
4
|
-
|
|
5
|
-
module.exports = function getPatternDataPath( patternsPath, patternName ) {
|
|
6
|
-
const protoPath = buildPatternFilePath( patternsPath, patternName, '.prototype.js' ).toString();
|
|
7
|
-
const jsonPath = buildPatternFilePath( patternsPath, patternName, '.json' ).toString();
|
|
8
|
-
|
|
9
|
-
if ( fs.existsSync( protoPath ) ) {
|
|
10
|
-
return protoPath;
|
|
11
|
-
} else if ( fs.existsSync( jsonPath ) ) {
|
|
12
|
-
return jsonPath;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
throw new Error( chalk.red( `Couldn\'t find a .prototype.js or .json file for ${patternName}.\nLooked in ${patternsPath}.` ) );
|
|
16
|
-
}
|