@penskemediacorp/larva 0.6.2 → 0.6.4-develop.17

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.
@@ -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,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
+ }