@penskemediacorp/larva 1.2.1-alpha.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +6 -0
- package/LICENSE +21 -0
- package/README.md +119 -4
- package/__tests__/fixtures/build/css/common.inline.css +1 -0
- package/__tests__/fixtures/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 +43 -0
- package/__tests__/fixtures/public/some-library.js +1 -0
- package/__tests__/fixtures/src/patterns/__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.json +3 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.prototype.js +3 -0
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.twig +3 -0
- 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/objects/_objects.scss +0 -0
- package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.json +3 -0
- package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.scss +0 -0
- package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.twig +1 -0
- package/__tests__/fixtures/src/patterns/objects/o-nav/o-nav.twig +14 -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__/fixtures/template-parts/some-template.php +3 -0
- package/__tests__/lib/generateStatic.test.js +140 -0
- package/__tests__/lib/utils/clonePatternData.test.js +23 -0
- 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 +55 -0
- package/__tests__/lib/utils/getPatternPathsToLoad.test.js +13 -0
- package/__tests__/lib/utils/getPatternRoutes.test.js +29 -0
- package/__tests__/lib/utils/getPatternType.test.js +16 -0
- package/__tests__/lib/utils/getPatternVariants.test.js +20 -0
- package/__tests__/lib/utils/getPatternsIndexPath.test.js +9 -0
- package/__tests__/lib/utils/getSubDirectoryNames.test.js +17 -0
- package/__tests__/lib/utils/isCoreTheme.test.js +12 -0
- package/__tests__/lib/utils/writeJsonToFile.test.js +29 -0
- package/__tests__/lib/writeJson.test.js +83 -0
- package/bin/larva.js +25 -0
- 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/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 +7 -0
- package/lib/generateStatic.js +133 -0
- package/lib/server.js +284 -0
- package/lib/start.js +7 -0
- package/lib/utils/clonePatternData.js +13 -0
- package/lib/utils/copySyncHelper.js +33 -0
- package/lib/utils/getAllPatternsObj.js +48 -0
- package/lib/utils/getAppConfiguration.js +82 -0
- package/lib/utils/getArgsFromCli.js +3 -0
- package/lib/utils/getModuleNamesFromDirectory.js +11 -0
- package/lib/utils/getPatternData.js +34 -0
- package/lib/utils/getPatternPathsToLoad.js +20 -0
- package/lib/utils/getPatternRoutes.js +58 -0
- package/lib/utils/getPatternType.js +15 -0
- package/lib/utils/getPatternVariants.js +24 -0
- package/lib/utils/getPatternsIndexPath.js +11 -0
- package/lib/utils/getSubDirectoryNames.js +23 -0
- package/lib/utils/isCoreTheme.js +8 -0
- package/lib/utils/renderSass.js +20 -0
- package/lib/utils/spawnScript.js +26 -0
- package/lib/utils/writeJsonToFile.js +6 -0
- package/lib/writeJson.js +53 -0
- package/package.json +72 -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__/larva.test.js +0 -7
- package/lib/larva.js +0 -7
- package/lib/patterns.js +0 -48
- package/setup.scss +0 -1
- package/src/02-generic/breakpoint-label.scss +0 -33
- package/src/06-algorithms/a-glue/a-glue.html +0 -4
- package/src/06-algorithms/a-glue/a-glue.scss +0 -56
- package/src/06-algorithms/a-glue/index.js +0 -1
- package/src/06-algorithms/a-grid.scss +0 -29
- package/src/07-utilities/u-background.scss +0 -5
- package/src/07-utilities/u-color.scss +0 -5
- package/src/07-utilities/u-crop.scss +0 -5
- package/src/07-utilities/u-flex.scss +0 -35
- package/src/07-utilities/u-margin.scss +0 -5
- package/src/07-utilities/u-padding.scss +0 -5
- package/src/07-utilities/u-text.scss +0 -33
- package/src/07-utilities/utilities.scss +0 -5
- 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,191 @@
|
|
|
1
|
+
const gulp = require( 'gulp' );
|
|
2
|
+
const gulpClean = require( 'gulp-clean' );
|
|
3
|
+
const gulpIf = require( 'gulp-if' );
|
|
4
|
+
const gulpIgnore = require( 'gulp-ignore' );
|
|
5
|
+
const gulpPostCss = require( 'gulp-postcss' );
|
|
6
|
+
const gulpRename = require( 'gulp-rename' );
|
|
7
|
+
const gulpStylelint = require( 'gulp-stylelint' );
|
|
8
|
+
|
|
9
|
+
const Fibers = require( 'fibers' );
|
|
10
|
+
const globImporter = require( 'node-sass-glob-importer' );
|
|
11
|
+
const { mkdirpSync } = require( 'fs-extra' );
|
|
12
|
+
const path = require( 'path' );
|
|
13
|
+
const postCss = require( 'postcss' );
|
|
14
|
+
const sass = require( 'gulp-sass' );
|
|
15
|
+
|
|
16
|
+
const stylelintConfig = require( './stylelint.config' );
|
|
17
|
+
|
|
18
|
+
/**************
|
|
19
|
+
Config
|
|
20
|
+
**************/
|
|
21
|
+
|
|
22
|
+
const cssDest = './build/css/';
|
|
23
|
+
|
|
24
|
+
sass.compiler = require( 'sass' );
|
|
25
|
+
|
|
26
|
+
const sassOpts = {
|
|
27
|
+
fiber: Fibers,
|
|
28
|
+
includePaths: [
|
|
29
|
+
path.resolve( './node_modules' ),
|
|
30
|
+
path.resolve( './src/scss' ),
|
|
31
|
+
],
|
|
32
|
+
importer: globImporter(),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const stylelintOpts = {
|
|
36
|
+
failAfterError: false,
|
|
37
|
+
config: stylelintConfig,
|
|
38
|
+
reporters: [
|
|
39
|
+
{
|
|
40
|
+
formatter: 'string',
|
|
41
|
+
console: true,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**************
|
|
47
|
+
Functions
|
|
48
|
+
**************/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Build CSS.
|
|
52
|
+
*
|
|
53
|
+
* Used for both prod and dev commands.
|
|
54
|
+
*
|
|
55
|
+
* Consider updating the name 'minify' to 'post' if/when
|
|
56
|
+
* more Post CSS functionality is added.
|
|
57
|
+
*
|
|
58
|
+
* @param {Function} done Post-build callback.
|
|
59
|
+
* @param {boolean} minify Run post CSS and minify output.
|
|
60
|
+
* @param {boolean} generateImportantVariants Whether to build variations with
|
|
61
|
+
* `!important` added to all rules.
|
|
62
|
+
*/
|
|
63
|
+
const buildScss = (
|
|
64
|
+
done,
|
|
65
|
+
minify = false,
|
|
66
|
+
generateImportantVariants = false
|
|
67
|
+
) => {
|
|
68
|
+
|
|
69
|
+
if ( minify ) {
|
|
70
|
+
sassOpts.outputStyle = 'compressed';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
gulp.src( './entries/*.scss' )
|
|
74
|
+
.pipe( gulpStylelint( stylelintOpts ) )
|
|
75
|
+
.pipe( sass( sassOpts ).on( 'error', sass.logError ) )
|
|
76
|
+
.pipe( gulp.dest( cssDest ) )
|
|
77
|
+
.pipe( gulpIgnore.exclude( 'larva-ui.css' ) )
|
|
78
|
+
.pipe(
|
|
79
|
+
gulpIf(
|
|
80
|
+
generateImportantVariants,
|
|
81
|
+
gulpPostCss( [ declareImportanceForAll ] )
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
.pipe(
|
|
85
|
+
gulpIf(
|
|
86
|
+
generateImportantVariants,
|
|
87
|
+
gulpRename( { suffix: '-important' } )
|
|
88
|
+
)
|
|
89
|
+
)
|
|
90
|
+
.pipe( gulpIf( generateImportantVariants, gulp.dest( cssDest ) ) );
|
|
91
|
+
|
|
92
|
+
done();
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Prepare destination directory.
|
|
97
|
+
*
|
|
98
|
+
* @param {Function} done Function called upon completion.
|
|
99
|
+
*/
|
|
100
|
+
const clean = ( done ) => {
|
|
101
|
+
gulp.src( cssDest, { read: false } ).pipe( gulpClean() );
|
|
102
|
+
|
|
103
|
+
mkdirpSync( cssDest );
|
|
104
|
+
done();
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Build a task from dynamic input.
|
|
109
|
+
*
|
|
110
|
+
* @param {Function} done Function called upon completion.
|
|
111
|
+
* @param {boolean} generateImportantVariants Whether to build variations with
|
|
112
|
+
* `!important` added to all rules.
|
|
113
|
+
*/
|
|
114
|
+
const composeTask = ( done, generateImportantVariants = false ) => {
|
|
115
|
+
clean( () => {
|
|
116
|
+
stylelint( './src/**/*.scss' );
|
|
117
|
+
buildScss( done, true, generateImportantVariants );
|
|
118
|
+
} );
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Add `!important` declarations to all rules, for use with older themes that
|
|
123
|
+
* have high specificity.
|
|
124
|
+
*
|
|
125
|
+
* Adapted from the `postcss-importantly` npm package, updated to work with
|
|
126
|
+
* latest version of PostCSS.
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} style PostCSS Root object for current CSS.
|
|
129
|
+
* @param {Object} result PostCSS Result object containing transformed CSS.
|
|
130
|
+
* @return {Result} PostCSS Result object.
|
|
131
|
+
*/
|
|
132
|
+
const declareImportanceForAll = ( style, result ) => {
|
|
133
|
+
const root = postCss.parse( style );
|
|
134
|
+
|
|
135
|
+
root.walkRules( ( rule ) => {
|
|
136
|
+
if ( 'atrule' === rule.parent.type && 'media' !== rule.parent.name ) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return rule.each( ( decl ) => {
|
|
141
|
+
if ( ! decl.value || decl.important ) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
decl.value += '!important';
|
|
146
|
+
|
|
147
|
+
return decl;
|
|
148
|
+
} );
|
|
149
|
+
} );
|
|
150
|
+
|
|
151
|
+
result.root = root;
|
|
152
|
+
|
|
153
|
+
return result;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Run stylelint.
|
|
158
|
+
*
|
|
159
|
+
* @param {string} file Filename or glob to process.
|
|
160
|
+
*/
|
|
161
|
+
const stylelint = ( file ) => {
|
|
162
|
+
gulp.src( file ).pipe( gulpStylelint( stylelintOpts ) );
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**************
|
|
166
|
+
Tasks
|
|
167
|
+
***************/
|
|
168
|
+
|
|
169
|
+
// Watch the changed file, compile and lint when changed.
|
|
170
|
+
exports[ 'dev-scss' ] = () => {
|
|
171
|
+
gulp.watch( [ './src/**/*.scss', './entries/*.scss' ], buildScss ).on(
|
|
172
|
+
'change',
|
|
173
|
+
function ( file ) {
|
|
174
|
+
stylelint( file );
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// Quickly build SCSS.
|
|
180
|
+
exports[ 'build-scss' ] = ( done ) => {
|
|
181
|
+
buildScss( done );
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Run PostCSS on CSS.
|
|
185
|
+
exports[ 'prod-scss' ] = ( done ) => {
|
|
186
|
+
composeTask( done );
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
exports[ 'prod-scss-with-important-variants' ] = ( done ) => {
|
|
190
|
+
composeTask( done, true );
|
|
191
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": [{
|
|
3
|
+
"removeTitle": false
|
|
4
|
+
},
|
|
5
|
+
{
|
|
6
|
+
"removeDoctype": true
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"removeXMLNS": true
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"removeXMLProcInst": true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"removeComments": true
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"removeUselessDefs": true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"removeEmptyAttrs": true
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"removeUselessStrokeAndFill": true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"removeUnknownsAndDefaults": true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"convertPathData": false
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"cleanupIDs": true
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"cleanupNumericValues": {
|
|
37
|
+
"floatPrecision": 3,
|
|
38
|
+
"leadingZero": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"minifyStyles": true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"convertTransform": true
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"cleanupAttrs": true
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"convertPathData": true
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"convertShapeToPath": true
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"convertColors": {
|
|
58
|
+
"shorthex": false
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"removeAttrs": {
|
|
63
|
+
"attrs": "fill"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
3
|
+
|
|
4
|
+
const getConfig = require( '../../index' ).getConfig;
|
|
5
|
+
|
|
6
|
+
const SRC_DIR = path.resolve( './entries' );
|
|
7
|
+
const BUILD_DIR = path.resolve( './build/js' );
|
|
8
|
+
|
|
9
|
+
const entries = getConfig( 'webpack' ).entries;
|
|
10
|
+
|
|
11
|
+
const aliases = {
|
|
12
|
+
'@larva-js': path.resolve( './node_modules/@penskemediacorp/larva-js/src' ),
|
|
13
|
+
'@npm': path.resolve( './node_modules/' ),
|
|
14
|
+
... getConfig( 'webpack' ).aliases
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const eslintConfig = getConfig( 'eslint', true );
|
|
18
|
+
const eslintConfigFile = undefined !== eslintConfig ? eslintConfig.configFile : null;
|
|
19
|
+
|
|
20
|
+
// Tools
|
|
21
|
+
const { CleanWebpackPlugin } = require( 'clean-webpack-plugin' );
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
//=========================================================
|
|
25
|
+
// Rules
|
|
26
|
+
//---------------------------------------------------------
|
|
27
|
+
const rules = {
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* JS Loaders
|
|
31
|
+
*/
|
|
32
|
+
pre: {
|
|
33
|
+
enforce: 'pre',
|
|
34
|
+
test: /\.js$/,
|
|
35
|
+
exclude: /(node_modules|nobundle|vendor)/,
|
|
36
|
+
},
|
|
37
|
+
js: {
|
|
38
|
+
test: /\.js$/,
|
|
39
|
+
include: SRC_DIR,
|
|
40
|
+
exclude: /(node_modules|nobundle|vendor)/,
|
|
41
|
+
loader: 'babel-loader',
|
|
42
|
+
query: {
|
|
43
|
+
presets: [ '@babel/preset-env' ]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const plugins = {
|
|
49
|
+
cleanup: new CleanWebpackPlugin(),
|
|
50
|
+
eslint: new ESLintPlugin({
|
|
51
|
+
overrideConfigFile: eslintConfigFile
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
//=========================================================
|
|
56
|
+
// CONFIG
|
|
57
|
+
//---------------------------------------------------------
|
|
58
|
+
const config = {
|
|
59
|
+
entry: entries,
|
|
60
|
+
output: {
|
|
61
|
+
path: BUILD_DIR,
|
|
62
|
+
filename: '[name].js'
|
|
63
|
+
},
|
|
64
|
+
module: {
|
|
65
|
+
rules: [ rules.js ]
|
|
66
|
+
},
|
|
67
|
+
watch: false,
|
|
68
|
+
watchOptions: {
|
|
69
|
+
ignored: /node_modules/
|
|
70
|
+
},
|
|
71
|
+
resolve: {
|
|
72
|
+
alias: aliases
|
|
73
|
+
},
|
|
74
|
+
optimization: {
|
|
75
|
+
minimize: true
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
module.exports = ( env, argv ) => {
|
|
80
|
+
|
|
81
|
+
if ( 'development' === argv.mode ) {
|
|
82
|
+
config.devtool = 'source-map';
|
|
83
|
+
config.module.rules = ( config.module.rules || [] ).concat( [ rules.pre ] );
|
|
84
|
+
config.plugins = [ plugins.eslint ];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if ( 'production' === argv.mode ) {
|
|
88
|
+
console.log( 'Building Prod JS..' );
|
|
89
|
+
|
|
90
|
+
config.module.rules = ( config.module.rules || [] ).concat( [ rules.pre ] );
|
|
91
|
+
config.plugins = [ plugins.eslint, plugins.cleanup ];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return config;
|
|
95
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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=development',
|
|
10
|
+
'--watch=true'
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
spawnScript( './node_modules/.bin/webpack', args );
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const spawn = require( 'cross-spawn' );
|
|
2
|
+
const path = require( 'path' );
|
|
3
|
+
|
|
4
|
+
const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
|
|
5
|
+
|
|
6
|
+
const cliArgs = getArgsFromCli();
|
|
7
|
+
const gulpfilePath = path.join( __dirname, './config/gulpfile.js' );
|
|
8
|
+
|
|
9
|
+
// TODO: allow local gulpfile override by checking for --cwd and --gulpfile in cliArgs
|
|
10
|
+
|
|
11
|
+
spawn.sync(
|
|
12
|
+
'./node_modules/.bin/gulp',
|
|
13
|
+
[
|
|
14
|
+
'--gulpfile',
|
|
15
|
+
gulpfilePath,
|
|
16
|
+
'--cwd',
|
|
17
|
+
process.cwd(),
|
|
18
|
+
... cliArgs
|
|
19
|
+
], { stdio: 'inherit' }
|
|
20
|
+
);
|
package/scripts/help.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Help command for Larva.
|
|
3
|
+
*
|
|
4
|
+
* ## OPTIONS
|
|
5
|
+
*
|
|
6
|
+
* [<command>]
|
|
7
|
+
* : Slug of a command to display the CLI usage information.
|
|
8
|
+
*
|
|
9
|
+
* ## EXAMPLES
|
|
10
|
+
*
|
|
11
|
+
* # Display a list of available commands.
|
|
12
|
+
* $ npx @penskemediacorp/larva help
|
|
13
|
+
*
|
|
14
|
+
* # Display the prod command docblock.
|
|
15
|
+
* $ npx @penskemediacorp/larva help prod
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// Dependencies.
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const path = require( 'path' );
|
|
21
|
+
const shell = require( 'shelljs' );
|
|
22
|
+
|
|
23
|
+
// CLI arguments.
|
|
24
|
+
const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
|
|
25
|
+
const cliArgs = getArgsFromCli();
|
|
26
|
+
|
|
27
|
+
const allowedCommands = [
|
|
28
|
+
'help',
|
|
29
|
+
'link-all',
|
|
30
|
+
'lint',
|
|
31
|
+
'prod',
|
|
32
|
+
'start',
|
|
33
|
+
'upgrade',
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
// Display a generic help description.
|
|
37
|
+
if ( 2 !== cliArgs.length ) {
|
|
38
|
+
console.log( 'Usage: npx @penskemediacorp/larval <command> [--help]\n' );
|
|
39
|
+
console.log( `Where <command> is one of ${allowedCommands.join( ', ' )}.\n` );
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Check for invalid commands.
|
|
44
|
+
const command = cliArgs[1];
|
|
45
|
+
if ( ! allowedCommands.includes( command ) ) {
|
|
46
|
+
console.log( `Invalid command '${command}'.\n` );
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Display the docblock for a given command.
|
|
51
|
+
const pathToFile = path.resolve( __dirname, `${command}.js` );
|
|
52
|
+
try {
|
|
53
|
+
if ( fs.existsSync( pathToFile ) ) {
|
|
54
|
+
fs.readFile( pathToFile, 'utf8', ( error, data ) => {
|
|
55
|
+
if ( error ) {
|
|
56
|
+
console.error( error );
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const fileParts = data.split( '*/', 1 );
|
|
60
|
+
console.log( fileParts[0] + '*/' );
|
|
61
|
+
} );
|
|
62
|
+
}
|
|
63
|
+
} catch( error ) {
|
|
64
|
+
console.error( error );
|
|
65
|
+
}
|
package/scripts/init.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
const chalk = require( 'chalk' );
|
|
3
|
+
const { copySync } = require( 'fs-extra' );
|
|
4
|
+
|
|
5
|
+
const copyFrom = path.join( __dirname, 'larva' );
|
|
6
|
+
const copyTo = process.cwd();
|
|
7
|
+
|
|
8
|
+
copySync( copyFrom, copyTo );
|
|
9
|
+
|
|
10
|
+
console.log(
|
|
11
|
+
chalk.green( 'Copied folder structure. Now, add the following scripts to package.json:' )
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
console.log( `
|
|
15
|
+
"backstop": "backstop --config=node_modules/@penskemediacorp/backstopjs-config",
|
|
16
|
+
"build-html": "larva build-html",
|
|
17
|
+
"larva": "larva server --watch src -e twig,js,html",
|
|
18
|
+
"parser": "./node_modules/.bin/twig-to-php-parser",
|
|
19
|
+
"update-larva": "npm install @penskemediacorp/larva@latest",
|
|
20
|
+
"write-json": "larva write-json"
|
|
21
|
+
` );
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
14
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# IMPORTANT!!!!
|
|
2
|
+
|
|
3
|
+
After this directory has been copied into a consuming project, [follow these steps](https://confluence.pmcdev.io/x/JQqeAw), delete this section of the readme, and replace the {Project} text below with the name of the brand (in the bright future, this will be automated).
|
|
4
|
+
|
|
5
|
+
# {Project} Larva
|
|
6
|
+
|
|
7
|
+
This is configuration only instance of Larva. There should be no CSS or JS compiled here, only JSON configuration using existing styles from larva.css. If additional styles are needed, they should be [contributed upstream to the Larva packages](https://confluence.pmcdev.io/x/EQNCB).
|
|
8
|
+
|
|
9
|
+
## Links
|
|
10
|
+
|
|
11
|
+
* [{Project} design tokens]().
|
|
12
|
+
* [{Project} style guide on Invision or XD]().
|
|
13
|
+
* [{Project} style guide on the static site]().
|
|
14
|
+
|
|
15
|
+
## Development
|
|
16
|
+
|
|
17
|
+
To start developing:
|
|
18
|
+
|
|
19
|
+
1. Run `npm install` from theme-directory/assets.
|
|
20
|
+
2. Run `npm run larva` to open the Larva server.
|
|
21
|
+
|
|
22
|
+
Add pattern configurations by creating variants for modules.
|
|
23
|
+
|
|
24
|
+
## Larva Commands
|
|
25
|
+
|
|
26
|
+
* `npm run larva` - Start the Larva pattern server. Navigate in the browser to http://localhost:3000.
|
|
27
|
+
* `npm run parser` - Parse recently changed pattern Twig files to PHP.
|
|
28
|
+
* `npm run write-json` - write pattern objects to JSON files.
|
|
29
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This command can be used from within any Larva project to link the Larva
|
|
3
|
+
* packages (from the monorepo) for local development.
|
|
4
|
+
*
|
|
5
|
+
* @see https://github.com/penske-media-corp/pmc-larva/blob/master/README.md#linking-larva-for-local-development
|
|
6
|
+
*
|
|
7
|
+
* ## OPTIONS
|
|
8
|
+
*
|
|
9
|
+
* [--help]
|
|
10
|
+
* : Display usage and examples for this command.
|
|
11
|
+
*
|
|
12
|
+
* ## EXAMPLES
|
|
13
|
+
*
|
|
14
|
+
* # NPM link local packages to Larva monorepo.
|
|
15
|
+
* $ npx @penskemediacorp/larva link-all
|
|
16
|
+
*
|
|
17
|
+
* # Help command.
|
|
18
|
+
* $ npx @penskemediacorp/larva link-all help
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const shell = require( 'shelljs' );
|
|
22
|
+
|
|
23
|
+
// CLI arguments.
|
|
24
|
+
const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
|
|
25
|
+
const cliArgs = getArgsFromCli();
|
|
26
|
+
|
|
27
|
+
// Handle help command.
|
|
28
|
+
if ( cliArgs.includes( '--help' ) ) {
|
|
29
|
+
shell.exec( `npx @penskemediacorp/larva help link-all` );
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
shell.exec( 'npm link @penskemediacorp/larva' );
|
|
34
|
+
shell.exec( 'npm link @penskemediacorp/larva-css' );
|
|
35
|
+
shell.exec( 'npm link @penskemediacorp/larva-js' );
|
|
36
|
+
shell.exec( 'npm link @penskemediacorp/larva-patterns' );
|
|
37
|
+
shell.exec( 'npm link @penskemediacorp/larva-scss' );
|
|
38
|
+
shell.exec( 'npm link @penskemediacorp/larva-svg' );
|
|
39
|
+
shell.exec( 'npm link @penskemediacorp/larva-tokens' );
|
|
40
|
+
shell.exec( 'npm link @penskemediacorp/twig-to-php-parser' );
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const getAppConfiguration = require( '../lib/utils/getAppConfiguration' );
|
|
2
|
+
const spawnScript = require( '../lib/utils/spawnScript' );
|
|
3
|
+
|
|
4
|
+
const { configFile } = getAppConfiguration( 'eslint' );
|
|
5
|
+
|
|
6
|
+
const args = [
|
|
7
|
+
'--c',
|
|
8
|
+
configFile
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
spawnScript( './node_modules/.bin/eslint', args );
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const path = require( 'path' );
|
|
2
|
+
|
|
3
|
+
const stylelintConfigPath = path.join( __dirname, './config/stylelint.config.js' );
|
|
4
|
+
const spawnScript = require( '../lib/utils/spawnScript' );
|
|
5
|
+
|
|
6
|
+
const args = [
|
|
7
|
+
'files',
|
|
8
|
+
'./src/scss',
|
|
9
|
+
'--config',
|
|
10
|
+
stylelintConfigPath
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
spawnScript( './node_modules/.bin/stylelint', args );
|
package/scripts/lint.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
* [--css]
|
|
10
|
+
* : Lint CSS assets.
|
|
11
|
+
*
|
|
12
|
+
* [--js]
|
|
13
|
+
* : Lint JavaScript assets.
|
|
14
|
+
*
|
|
15
|
+
* [--fix]
|
|
16
|
+
* : Try to automatically fix any issues that arise while linting.
|
|
17
|
+
*
|
|
18
|
+
* ## EXAMPLES
|
|
19
|
+
*
|
|
20
|
+
* # Lint CSS and JavaScript assets.
|
|
21
|
+
* $ npx @penskemediacorp/larva lint
|
|
22
|
+
*
|
|
23
|
+
* # Only lint CSS assets.
|
|
24
|
+
* $ npx @penskemediacorp/larva lint --css
|
|
25
|
+
*
|
|
26
|
+
* # Only lint JavaScripot assets.
|
|
27
|
+
* $ npx @penskemediacorp/larva lint --js
|
|
28
|
+
*
|
|
29
|
+
* # Fix CSS and JavaScript assets.
|
|
30
|
+
* $ npx @penskemediacorp/larva lint --fix
|
|
31
|
+
*
|
|
32
|
+
* # Mix and match, fix JavaScript assets.
|
|
33
|
+
* $ npx @penskemediacorp/larva lint --js --fix
|
|
34
|
+
*
|
|
35
|
+
* # Help command.
|
|
36
|
+
* $ npx @penskemediacorp/larva lint --help
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
// Dependencies.
|
|
40
|
+
const path = require( 'path' );
|
|
41
|
+
const shell = require( 'shelljs' );
|
|
42
|
+
|
|
43
|
+
// Construct some paths to point our scripts at.
|
|
44
|
+
const binPath = path.resolve( __dirname, '../bin/larva.js' ); // For sibling scripts.
|
|
45
|
+
const workingDirectory = process.cwd(); // For paths relative to the directory this script was called from.
|
|
46
|
+
|
|
47
|
+
// CLI arguments.
|
|
48
|
+
const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
|
|
49
|
+
const cliArgs = getArgsFromCli();
|
|
50
|
+
|
|
51
|
+
// Handle help command.
|
|
52
|
+
if ( cliArgs.includes( '--help' ) ) {
|
|
53
|
+
shell.exec( `npx @penskemediacorp/larva help lint` );
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Trigger linting when a specific flag is present, or when neither flag is
|
|
58
|
+
// present.
|
|
59
|
+
const lintCSS = cliArgs.includes( '--css' ) || ! cliArgs.includes( '--js' );
|
|
60
|
+
const lintJS = cliArgs.includes( '--js' ) || ! cliArgs.includes( '--css' );
|
|
61
|
+
|
|
62
|
+
// Appends ` fix` to our linting scripts if the flag is present.
|
|
63
|
+
const fix = cliArgs.includes( '--fix' ) ? ' fix' : '';
|
|
64
|
+
|
|
65
|
+
if ( lintCSS ) {
|
|
66
|
+
console.log( 'Linting CSS assets\n\n\n' );
|
|
67
|
+
shell.exec( `${binPath} lint-scss${fix}` );
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if ( lintJS ) {
|
|
71
|
+
console.log( 'Linting JavaScript assets\n\n\n' );
|
|
72
|
+
shell.exec( `${binPath} lint-js ${workingDirectory}${fix}` );
|
|
73
|
+
}
|