@penskemediacorp/larva 1.2.0-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.
Files changed (236) hide show
  1. package/.eslintignore +6 -0
  2. package/LICENSE +21 -0
  3. package/README.md +119 -4
  4. package/__tests__/fixtures/build/css/common.inline.css +1 -0
  5. package/__tests__/fixtures/build/images/test.png +0 -0
  6. package/__tests__/fixtures/build/js/larva-ui.js +1 -0
  7. package/__tests__/fixtures/build/svg/defs/sprite.svg +1 -0
  8. package/__tests__/fixtures/larva.config.js +43 -0
  9. package/__tests__/fixtures/public/some-library.js +1 -0
  10. package/__tests__/fixtures/src/patterns/__tests__/.gitkeep +0 -0
  11. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.aia.js +3 -0
  12. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.js +3 -0
  13. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.js +1 -0
  14. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.json +3 -0
  15. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.prototype.js +3 -0
  16. package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.twig +3 -0
  17. package/__tests__/fixtures/src/patterns/components/c-tagline/c-tagline.prototype.js +3 -0
  18. package/__tests__/fixtures/src/patterns/modules/_also-ignored/_also-ignored.prototype.js +3 -0
  19. package/__tests__/fixtures/src/patterns/modules/_also-ignored/_also-ignored.twig +3 -0
  20. package/__tests__/fixtures/src/patterns/modules/ignore-me/ignore-me.prototype.js +0 -0
  21. package/__tests__/fixtures/src/patterns/modules/ignore-me/ignore-me.twig +0 -0
  22. package/__tests__/fixtures/src/patterns/modules/test-module/test-module.featured.js +3 -0
  23. package/__tests__/fixtures/src/patterns/modules/test-module/test-module.prototype.js +3 -0
  24. package/__tests__/fixtures/src/patterns/modules/test-module/test-module.twig +0 -0
  25. package/__tests__/fixtures/src/patterns/objects/_objects.scss +0 -0
  26. package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.json +3 -0
  27. package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.scss +0 -0
  28. package/__tests__/fixtures/src/patterns/objects/o-crap/o-crap.twig +1 -0
  29. package/__tests__/fixtures/src/patterns/objects/o-nav/o-nav.twig +14 -0
  30. package/__tests__/fixtures/src/patterns/one-offs/newswire/newswire.html +1 -0
  31. package/__tests__/fixtures/src/patterns/one-offs/newswire/newswire.prototype.js +3 -0
  32. package/__tests__/fixtures/template-parts/some-template.php +3 -0
  33. package/__tests__/lib/generateStatic.test.js +140 -0
  34. package/__tests__/lib/utils/clonePatternData.test.js +23 -0
  35. package/__tests__/lib/utils/getAllPatternsObj.test.js +45 -0
  36. package/__tests__/lib/utils/getAppConfiguration.test.js +13 -0
  37. package/__tests__/lib/utils/getModuleNamesFromDirectory.test.js +23 -0
  38. package/__tests__/lib/utils/getPatternData.test.js +55 -0
  39. package/__tests__/lib/utils/getPatternPathsToLoad.test.js +13 -0
  40. package/__tests__/lib/utils/getPatternRoutes.test.js +29 -0
  41. package/__tests__/lib/utils/getPatternType.test.js +16 -0
  42. package/__tests__/lib/utils/getPatternVariants.test.js +20 -0
  43. package/__tests__/lib/utils/getPatternsIndexPath.test.js +9 -0
  44. package/__tests__/lib/utils/getSubDirectoryNames.test.js +17 -0
  45. package/__tests__/lib/utils/isCoreTheme.test.js +12 -0
  46. package/__tests__/lib/utils/writeJsonToFile.test.js +29 -0
  47. package/__tests__/lib/writeJson.test.js +83 -0
  48. package/bin/larva.js +25 -0
  49. package/build/css/larva-important.css +1 -0
  50. package/build/css/larva-ui.css +1 -0
  51. package/build/css/larva.css +1 -0
  52. package/build/css/larva.inline-important.css +1 -0
  53. package/build/css/larva.inline.css +1 -0
  54. package/build/css/variety.compat-important.css +1 -0
  55. package/build/css/variety.compat.css +1 -0
  56. package/build/js/common.js +26 -0
  57. package/build/js/larva-ui.js +1 -0
  58. package/build/js/standalone/video-showcase.js +26 -0
  59. package/build/svg/brand-logo-white.svg +1 -0
  60. package/build/svg/brand-logo.svg +1 -0
  61. package/build/svg/defs/sprite.defs.html +852 -0
  62. package/build/svg/defs/sprite.defs.svg +1 -0
  63. package/build/tokens/artinamerica.custom-properties.css +546 -0
  64. package/build/tokens/artinamerica.json +533 -0
  65. package/build/tokens/artinamerica.map.scss +546 -0
  66. package/build/tokens/artinamerica.raw.json +4341 -0
  67. package/build/tokens/artnews.custom-properties.css +550 -0
  68. package/build/tokens/artnews.json +536 -0
  69. package/build/tokens/artnews.map.scss +550 -0
  70. package/build/tokens/artnews.raw.json +4373 -0
  71. package/build/tokens/bbpro.custom-properties.css +96 -0
  72. package/build/tokens/bbpro.json +80 -0
  73. package/build/tokens/bbpro.map.scss +96 -0
  74. package/build/tokens/bbpro.raw.json +789 -0
  75. package/build/tokens/billboard.custom-properties.css +96 -0
  76. package/build/tokens/billboard.json +80 -0
  77. package/build/tokens/billboard.map.scss +96 -0
  78. package/build/tokens/billboard.raw.json +789 -0
  79. package/build/tokens/deadline.custom-properties.css +533 -0
  80. package/build/tokens/deadline.json +517 -0
  81. package/build/tokens/deadline.map.scss +533 -0
  82. package/build/tokens/deadline.raw.json +4204 -0
  83. package/build/tokens/default.custom-properties.css +533 -0
  84. package/build/tokens/default.json +517 -0
  85. package/build/tokens/default.map.scss +533 -0
  86. package/build/tokens/default.raw.json +4204 -0
  87. package/build/tokens/dirt.custom-properties.css +81 -0
  88. package/build/tokens/dirt.json +66 -0
  89. package/build/tokens/dirt.map.scss +81 -0
  90. package/build/tokens/dirt.raw.json +690 -0
  91. package/build/tokens/indiewire.custom-properties.css +536 -0
  92. package/build/tokens/indiewire.json +520 -0
  93. package/build/tokens/indiewire.map.scss +536 -0
  94. package/build/tokens/indiewire.raw.json +4221 -0
  95. package/build/tokens/rivet.custom-properties.css +82 -0
  96. package/build/tokens/rivet.json +68 -0
  97. package/build/tokens/rivet.map.scss +82 -0
  98. package/build/tokens/rivet.raw.json +703 -0
  99. package/build/tokens/robbreport.custom-properties.css +536 -0
  100. package/build/tokens/robbreport.json +518 -0
  101. package/build/tokens/robbreport.map.scss +536 -0
  102. package/build/tokens/robbreport.raw.json +4215 -0
  103. package/build/tokens/rollingstone-2022.custom-properties.css +534 -0
  104. package/build/tokens/rollingstone-2022.json +519 -0
  105. package/build/tokens/rollingstone-2022.map.scss +534 -0
  106. package/build/tokens/rollingstone-2022.raw.json +4035 -0
  107. package/build/tokens/rollingstone.custom-properties.css +530 -0
  108. package/build/tokens/rollingstone.json +518 -0
  109. package/build/tokens/rollingstone.map.scss +530 -0
  110. package/build/tokens/rollingstone.raw.json +4207 -0
  111. package/build/tokens/sheknows.custom-properties.css +92 -0
  112. package/build/tokens/sheknows.json +76 -0
  113. package/build/tokens/sheknows.map.scss +92 -0
  114. package/build/tokens/sheknows.raw.json +761 -0
  115. package/build/tokens/sourcingjournal.custom-properties.css +87 -0
  116. package/build/tokens/sourcingjournal.json +70 -0
  117. package/build/tokens/sourcingjournal.map.scss +87 -0
  118. package/build/tokens/sourcingjournal.raw.json +720 -0
  119. package/build/tokens/sportico.custom-properties.css +73 -0
  120. package/build/tokens/sportico.json +59 -0
  121. package/build/tokens/sportico.map.scss +73 -0
  122. package/build/tokens/sportico.raw.json +640 -0
  123. package/build/tokens/thr.custom-properties.css +83 -0
  124. package/build/tokens/thr.json +67 -0
  125. package/build/tokens/thr.map.scss +83 -0
  126. package/build/tokens/thr.raw.json +698 -0
  127. package/build/tokens/variety-compat.custom-properties.css +36 -0
  128. package/build/tokens/variety-compat.json +33 -0
  129. package/build/tokens/variety-compat.map.scss +36 -0
  130. package/build/tokens/variety-compat.raw.json +224 -0
  131. package/build/tokens/variety-vip.custom-properties.css +532 -0
  132. package/build/tokens/variety-vip.json +521 -0
  133. package/build/tokens/variety-vip.map.scss +532 -0
  134. package/build/tokens/variety-vip.raw.json +4223 -0
  135. package/build/tokens/variety.custom-properties.css +534 -0
  136. package/build/tokens/variety.json +521 -0
  137. package/build/tokens/variety.map.scss +534 -0
  138. package/build/tokens/variety.raw.json +4225 -0
  139. package/build/tokens/vibe.custom-properties.css +77 -0
  140. package/build/tokens/vibe.json +63 -0
  141. package/build/tokens/vibe.map.scss +77 -0
  142. package/build/tokens/vibe.raw.json +668 -0
  143. package/build/tokens/wwd-2021.custom-properties.css +82 -0
  144. package/build/tokens/wwd-2021.json +67 -0
  145. package/build/tokens/wwd-2021.map.scss +82 -0
  146. package/build/tokens/wwd-2021.raw.json +701 -0
  147. package/build/tokens/wwd-beauty.custom-properties.css +86 -0
  148. package/build/tokens/wwd-beauty.json +70 -0
  149. package/build/tokens/wwd-beauty.map.scss +86 -0
  150. package/build/tokens/wwd-beauty.raw.json +719 -0
  151. package/build/tokens/wwd-dd.custom-properties.css +18 -0
  152. package/build/tokens/wwd-dd.json +13 -0
  153. package/build/tokens/wwd-dd.map.scss +18 -0
  154. package/build/tokens/wwd-dd.raw.json +90 -0
  155. package/build/tokens/wwd.custom-properties.css +70 -0
  156. package/build/tokens/wwd.json +60 -0
  157. package/build/tokens/wwd.map.scss +70 -0
  158. package/build/tokens/wwd.raw.json +643 -0
  159. package/index.js +7 -0
  160. package/lib/generateStatic.js +133 -0
  161. package/lib/server.js +284 -0
  162. package/lib/start.js +7 -0
  163. package/lib/utils/clonePatternData.js +13 -0
  164. package/lib/utils/copySyncHelper.js +33 -0
  165. package/lib/utils/getAllPatternsObj.js +48 -0
  166. package/lib/utils/getAppConfiguration.js +82 -0
  167. package/lib/utils/getArgsFromCli.js +3 -0
  168. package/lib/utils/getModuleNamesFromDirectory.js +11 -0
  169. package/lib/utils/getPatternData.js +34 -0
  170. package/lib/utils/getPatternPathsToLoad.js +20 -0
  171. package/lib/utils/getPatternRoutes.js +58 -0
  172. package/lib/utils/getPatternType.js +15 -0
  173. package/lib/utils/getPatternVariants.js +24 -0
  174. package/lib/utils/getPatternsIndexPath.js +11 -0
  175. package/lib/utils/getSubDirectoryNames.js +23 -0
  176. package/lib/utils/isCoreTheme.js +8 -0
  177. package/lib/utils/renderSass.js +20 -0
  178. package/lib/utils/spawnScript.js +26 -0
  179. package/lib/utils/writeJsonToFile.js +6 -0
  180. package/lib/writeJson.js +53 -0
  181. package/package.json +72 -5
  182. package/public/webfontloader.js +22 -0
  183. package/scripts/build-html.js +52 -0
  184. package/scripts/build-icons.js +80 -0
  185. package/scripts/build-scss.js +15 -0
  186. package/scripts/config/.eslintrc.json +11 -0
  187. package/scripts/config/gulpfile.js +191 -0
  188. package/scripts/config/stylelint.config.js +5 -0
  189. package/scripts/config/svgo-config.json +67 -0
  190. package/scripts/config/webpack.config.js +95 -0
  191. package/scripts/dev-js.js +13 -0
  192. package/scripts/dev-scss.js +20 -0
  193. package/scripts/help.js +65 -0
  194. package/scripts/init.js +21 -0
  195. package/scripts/larva/.nvmrc +1 -0
  196. package/scripts/larva/README.md +29 -0
  197. package/scripts/larva/larva.config.js +3 -0
  198. package/scripts/larva/src/patterns/README.md +3 -0
  199. package/scripts/larva/src/patterns/base.html +6 -0
  200. package/scripts/larva/src/patterns/components/README.md +3 -0
  201. package/scripts/larva/src/patterns/modules/README.md +3 -0
  202. package/scripts/larva/src/patterns/objects/README.md +3 -0
  203. package/scripts/larva/src/patterns/one-offs/README.md +3 -0
  204. package/scripts/link-all.js +40 -0
  205. package/scripts/lint-js.js +11 -0
  206. package/scripts/lint-scss.js +13 -0
  207. package/scripts/lint.js +73 -0
  208. package/scripts/prod-js.js +12 -0
  209. package/scripts/prod-scss.js +24 -0
  210. package/scripts/prod.js +122 -0
  211. package/scripts/server.js +11 -0
  212. package/scripts/start.js +36 -0
  213. package/scripts/upgrade.js +99 -0
  214. package/scripts/write-json.js +14 -0
  215. package/.DS_Store +0 -0
  216. package/__tests__/larva.test.js +0 -7
  217. package/lib/larva.js +0 -7
  218. package/lib/patterns.js +0 -48
  219. package/setup.scss +0 -1
  220. package/src/02-generic/breakpoint-label.scss +0 -33
  221. package/src/06-algorithms/a-glue/a-glue.html +0 -4
  222. package/src/06-algorithms/a-glue/a-glue.scss +0 -56
  223. package/src/06-algorithms/a-glue/index.js +0 -1
  224. package/src/06-algorithms/a-grid.scss +0 -29
  225. package/src/07-utilities/u-background.scss +0 -5
  226. package/src/07-utilities/u-color.scss +0 -5
  227. package/src/07-utilities/u-crop.scss +0 -5
  228. package/src/07-utilities/u-flex.scss +0 -35
  229. package/src/07-utilities/u-margin.scss +0 -5
  230. package/src/07-utilities/u-padding.scss +0 -5
  231. package/src/07-utilities/u-text.scss +0 -33
  232. package/src/07-utilities/utilities.scss +0 -5
  233. package/static/css/components.css +0 -4
  234. package/static/css/objects.css +0 -21
  235. package/static/css/prism.css +0 -126
  236. package/static/js/prism.js +0 -8
@@ -0,0 +1,29 @@
1
+ const path = require( 'path' );
2
+ const fixture = path.join( __dirname, '../../fixtures' );
3
+
4
+ const getAllPatternsObj = require( '../../../lib/utils/getAllPatternsObj' );
5
+ const getPatternRoutes = require( '../../../lib/utils/getPatternRoutes' );
6
+
7
+ describe( 'getPatternRoutes', () => {
8
+
9
+ it( 'outputs an array of routes from a pattern object', () => {
10
+
11
+ const patterns = getAllPatternsObj( path.join( fixture, 'src/patterns' ) );
12
+
13
+ const expected = [
14
+ 'components/c-nav-link/featured.aia',
15
+ 'components/c-nav-link/featured',
16
+ 'components/c-nav-link',
17
+ 'components/c-tagline',
18
+ 'modules/test-module/featured',
19
+ 'modules/test-module',
20
+ 'objects/o-crap',
21
+ 'objects/o-nav',
22
+ 'one-offs/newswire'
23
+ ];
24
+
25
+ expect( getPatternRoutes( patterns ) ).toStrictEqual( expected );
26
+
27
+ } );
28
+
29
+ } );
@@ -0,0 +1,16 @@
1
+ const getPatternType = require( '../../../lib/utils/getPatternType' );
2
+ const assert = require( 'assert' );
3
+
4
+ describe( 'getPatternType', () => {
5
+ it( 'returns components for c-', () => {
6
+ assert.equal( getPatternType( 'c-nav-item' ), 'components' );
7
+ });
8
+
9
+ it( 'returns objects for o-', () => {
10
+ assert.equal( getPatternType( 'o-nav' ), 'objects' );
11
+ });
12
+
13
+ it( 'returns modules for no namespace', () => {
14
+ assert.equal( getPatternType( 'breadcrumbs' ), 'modules' );
15
+ });
16
+ });
@@ -0,0 +1,20 @@
1
+ const path = require( 'path' );
2
+ const getAppConfiguration = require( '../../../lib/utils/getAppConfiguration' );
3
+ const getPatternVariants = require( '../../../lib/utils/getPatternVariants' );
4
+
5
+ const config = getAppConfiguration( 'patterns' );
6
+
7
+ describe( 'getPatternVariants', () => {
8
+
9
+ it( 'returns an array of variants', () => {
10
+ expect(
11
+ getPatternVariants( path.join( config.projectPatternsDir, 'components/c-nav-link/' ) )
12
+ ).toEqual(
13
+ [
14
+ 'featured.aia',
15
+ 'featured',
16
+ 'prototype'
17
+ ]
18
+ );
19
+ });
20
+ });
@@ -0,0 +1,9 @@
1
+ const assert = require( 'assert' );
2
+ const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )('patterns');
3
+ const getPatternsIndexPath = require( '../../../lib/utils/getPatternsIndexPath' );
4
+
5
+ describe( 'getPatternsIndexPath', () => {
6
+ it( 'gets the path for larva if it is the core theme', () => {
7
+ assert.equal( getPatternsIndexPath( appConfiguration ).includes( 'larva' ), true );
8
+ });
9
+ });
@@ -0,0 +1,17 @@
1
+ const assert = require( 'assert' );
2
+ const getPatternsList = require( '../../../lib/utils/getSubDirectoryNames' );
3
+ const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )('patterns');
4
+ const expectedObjectsList = [ 'o-crap', 'o-nav' ];
5
+ const expectedComponentsList = [ 'c-nav-link', 'c-tagline' ];
6
+
7
+ console.log( appConfiguration.projectPatternsDir );
8
+
9
+ describe( 'getSubDirectoryNames', () => {
10
+ it( 'gets an array of subdir names for objects', () => {
11
+ assert.deepEqual( getPatternsList( appConfiguration.projectPatternsDir + '/objects' ), expectedObjectsList );
12
+ });
13
+
14
+ it( 'gets an array of subdir names for components', () => {
15
+ assert.deepEqual( getPatternsList( appConfiguration.projectPatternsDir + '/components' ), expectedComponentsList );
16
+ });
17
+ });
@@ -0,0 +1,12 @@
1
+ const assert = require( 'assert' );
2
+ const isCoreTheme = require( '../../../lib/utils/isCoreTheme' );
3
+ const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )('patterns');
4
+
5
+ describe( 'isCoreTheme', () => {
6
+ // TODO:
7
+ // Leaving this as a failing test as a reminder to finalize what the core theme logic is,
8
+ // and if it is necessary other than in the parser.
9
+ it( 'is the core theme if there is no configuration for themePatternsDir', () => {
10
+ assert.equal( isCoreTheme( appConfiguration ), true );
11
+ });
12
+ });
@@ -0,0 +1,29 @@
1
+ const assert = require( 'assert' );
2
+ const fs = require( 'fs' );
3
+ const path = require( 'path' );
4
+ const getPatternData = require( '../../../lib/utils/getPatternData' );
5
+ const fixture = path.join( __dirname, '../../fixtures/src/patterns' );
6
+ const writeJson = require( '../../../lib/utils/writeJsonToFile' );
7
+ const exec = require( 'child_process' ).exec;
8
+ const expectedData = '{"o_crap_classes":"hello class here"}';
9
+
10
+ describe( 'writeJsonToFile', () => {
11
+
12
+ let data = getPatternData( fixture, { type: 'objects', name: 'o-crap' } );
13
+ writeJson( fixture + '/data.json', data );
14
+
15
+ it( 'writes o-crap json to a file', () => {
16
+ let data = fs.readFileSync( fixture + '/data.json' ).toString();
17
+
18
+ assert.equal( data, expectedData );
19
+ });
20
+
21
+ afterAll( () => {
22
+ exec( 'rm ' + fixture + '/data.json', ( err ) => {
23
+ if ( err ) {
24
+ console.error( err );
25
+ }
26
+ });
27
+ });
28
+
29
+ });
@@ -0,0 +1,83 @@
1
+ const assert = require( 'assert' );
2
+ const path = require( 'path' );
3
+ const fs = require( 'fs' );
4
+ const exec = require( 'child_process' ).exec;
5
+
6
+ const fixture = path.join( __dirname, '../fixtures' );
7
+ const getAppConfiguration = require( '../../lib/utils/getAppConfiguration' );
8
+ const writeJson = require( '../../lib/writeJson' );
9
+ const patternConfig = getAppConfiguration( 'patterns' );
10
+
11
+ const expectedJsonPath = path.join( fixture, './build/json/modules/' );
12
+
13
+ describe( 'writeJson', () => {
14
+ let testJsonPath = path.join( expectedJsonPath, 'test-module.prototype.json' );
15
+ let testPrototypePath = path.join( fixture, './src/patterns/modules/test-module/test-module.prototype.js' );
16
+ let testVariantJsonPath = path.join( expectedJsonPath, 'test-module.featured.json' );
17
+ let testIgnoredJsonPath = path.join( expectedJsonPath, 'ignore-me.prototype.json' );
18
+
19
+ beforeAll( ( done ) => {
20
+ exec( 'mkdirp ' + expectedJsonPath, ( err ) => {
21
+ if ( err ) {
22
+ console.error( err );
23
+ done();
24
+ } else {
25
+ writeJson( patternConfig );
26
+ done();
27
+ }
28
+ });
29
+ });
30
+
31
+ it( 'creates a JSON file', () => {
32
+ assert.equal( fs.existsSync( testJsonPath ), true );
33
+ });
34
+
35
+ it( 'prototype JS file equals JSON contents', () => {
36
+ assert.equal( JSON.stringify( require( testPrototypePath ) ), JSON.stringify( require( testJsonPath ) ) );
37
+ });
38
+
39
+ it( 'does not write JSON for ignored modules', () => {
40
+ assert.equal( fs.existsSync( testIgnoredJsonPath ), false );
41
+ });
42
+
43
+ it( 'creates a variant JSON', () => {
44
+ assert.equal( fs.existsSync( testVariantJsonPath ), true );
45
+ });
46
+
47
+ afterAll( ( done ) => {
48
+ exec( 'rm -r ' + path.join( expectedJsonPath ), ( err ) => {
49
+ if ( err ) {
50
+ console.error( err );
51
+ }
52
+ done();
53
+ });
54
+ });
55
+ });
56
+
57
+ describe( 'writeJson from Larva', () => {
58
+ let testJsonPath = path.join( expectedJsonPath, 'pmc-footer.prototype.json' );
59
+
60
+ beforeAll( ( done ) => {
61
+ exec( 'mkdirp ' + expectedJsonPath, ( err ) => {
62
+ if ( err ) {
63
+ console.error( err );
64
+ } else {
65
+ writeJson( patternConfig, true );
66
+ done();
67
+ }
68
+ });
69
+ });
70
+
71
+ it( 'creates a JSON file', () => {
72
+ assert.equal( fs.existsSync( testJsonPath ), true );
73
+ });
74
+
75
+ afterAll( ( done ) => {
76
+ exec( 'rm -r ' + path.join( expectedJsonPath ), ( err ) => {
77
+ if ( err ) {
78
+ console.error( err );
79
+ }
80
+ done();
81
+ });
82
+ });
83
+ });
package/bin/larva.js ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require( 'fs' );
5
+ const path = require( 'path' );
6
+ const spawn = require( 'cross-spawn' );
7
+ const chalk = require( 'chalk' );
8
+
9
+ const getArgsFromCli = require( '../lib/utils/getArgsFromCli' );
10
+ const cliArgs = getArgsFromCli();
11
+ const scriptName = cliArgs[0];
12
+
13
+ const hasScriptFile = fs.existsSync( path.join( __dirname, '../scripts/' + scriptName + '.js' ) );
14
+
15
+ if ( hasScriptFile ) {
16
+ spawn.sync(
17
+ 'node',
18
+ [
19
+ path.join( __dirname, `../scripts/${ scriptName }.js` ),
20
+ ... cliArgs
21
+ ], { stdio: 'inherit' }
22
+ );
23
+ } else {
24
+ console.error( chalk.red( `No file found for "${ scriptName }".` ) );
25
+ }