@penskemediacorp/larva 1.74.0 → 1.75.1

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 (39) hide show
  1. package/bin/install-hooks.js +122 -0
  2. package/bin/pre-push +215 -0
  3. package/build/css/larva-important.css +1 -1
  4. package/build/css/larva.css +1 -1
  5. package/build/css/larva.inline-important.css +1 -1
  6. package/build/css/larva.inline.css +1 -1
  7. package/build/js/standalone/video-showcase.js +1 -1
  8. package/build/svg/defs/sprite.defs.html +1 -1
  9. package/build/tokens/artinamerica.custom-properties.css +1 -1
  10. package/build/tokens/artnews.custom-properties.css +1 -1
  11. package/build/tokens/bbesp-2025.custom-properties.css +1 -1
  12. package/build/tokens/bbesp.custom-properties.css +1 -1
  13. package/build/tokens/bbpro-2025.custom-properties.css +1 -1
  14. package/build/tokens/bbpro.custom-properties.css +1 -1
  15. package/build/tokens/billboard-2025.custom-properties.css +1 -1
  16. package/build/tokens/billboard.custom-properties.css +1 -1
  17. package/build/tokens/deadline.custom-properties.css +1 -1
  18. package/build/tokens/dirt.custom-properties.css +1 -1
  19. package/build/tokens/indiewire.custom-properties.css +1 -1
  20. package/build/tokens/rivet.custom-properties.css +1 -1
  21. package/build/tokens/rollingstone-2022.custom-properties.css +1 -1
  22. package/build/tokens/rollingstone.custom-properties.css +1 -1
  23. package/build/tokens/sheknows.custom-properties.css +1 -1
  24. package/build/tokens/sheknows.json +6 -0
  25. package/build/tokens/sheknows.map.scss +6 -0
  26. package/build/tokens/sheknows.raw.json +42 -0
  27. package/build/tokens/sourcingjournal.custom-properties.css +1 -1
  28. package/build/tokens/spy-2022.custom-properties.css +1 -1
  29. package/build/tokens/thr.custom-properties.css +1 -1
  30. package/build/tokens/variety-vip.custom-properties.css +1 -1
  31. package/build/tokens/variety.custom-properties.css +1 -1
  32. package/build/tokens/vibe-2024.custom-properties.css +1 -1
  33. package/build/tokens/vibe.custom-properties.css +1 -1
  34. package/build/tokens/wwd-2021.custom-properties.css +1 -1
  35. package/build/tokens/wwd-beauty.custom-properties.css +1 -1
  36. package/build/tokens/wwd-dd.custom-properties.css +1 -1
  37. package/build/tokens/wwd-fn.custom-properties.css +1 -1
  38. package/build/tokens/wwd.custom-properties.css +1 -1
  39. package/package.json +15 -14
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Git Hooks Installation Script
5
+ *
6
+ * Copies pre-push hook from larva package to .git/hooks/ for all team members.
7
+ * Runs automatically via npm postinstall script.
8
+ *
9
+ * Source: node_modules/@penskemediacorp/larva/bin/pre-push
10
+ * Target: root/.git/hooks/pre-push (local, not tracked)
11
+ */
12
+
13
+ const fs = require( 'fs' );
14
+ const path = require( 'path' );
15
+ const { execSync } = require( 'child_process' );
16
+
17
+ const colors = {
18
+ reset: '\x1b[0m',
19
+ green: '\x1b[32m',
20
+ yellow: '\x1b[33m',
21
+ cyan: '\x1b[36m',
22
+ };
23
+
24
+ function log( message, color = 'reset' ) {
25
+ console.log( `${ colors[ color ] }${ message }${ colors.reset }` );
26
+ }
27
+
28
+ function findGitRoot() {
29
+ // Try multiple strategies to find the correct git root
30
+
31
+ // Strategy 1: Check if INIT_CWD is set (npm sets this to original directory)
32
+ if ( process.env.INIT_CWD ) {
33
+ try {
34
+ const gitRoot = execSync( 'git rev-parse --show-toplevel', {
35
+ encoding: 'utf8',
36
+ cwd: process.env.INIT_CWD,
37
+ } ).trim();
38
+ return gitRoot;
39
+ } catch ( e ) {
40
+ // Fall through to next strategy
41
+ }
42
+ }
43
+
44
+ // Strategy 2: Walk up from node_modules to find .git
45
+ let currentDir = __dirname;
46
+ while ( currentDir !== path.parse( currentDir ).root ) {
47
+ // Go up until we find node_modules
48
+ if ( currentDir.includes( 'node_modules' ) ) {
49
+ // Go up from node_modules/@penskemediacorp/larva to the project root
50
+ const parts = currentDir.split( path.sep );
51
+ const nodeModulesIndex = parts.lastIndexOf( 'node_modules' );
52
+ if ( nodeModulesIndex > 0 ) {
53
+ const projectRoot = parts.slice( 0, nodeModulesIndex ).join( path.sep );
54
+ const gitDir = path.join( projectRoot, '.git' );
55
+ if ( fs.existsSync( gitDir ) ) {
56
+ return projectRoot;
57
+ }
58
+ }
59
+ }
60
+
61
+ currentDir = path.dirname( currentDir );
62
+ }
63
+
64
+ // Strategy 3: Use current working directory as fallback
65
+ try {
66
+ return execSync( 'git rev-parse --show-toplevel', {
67
+ encoding: 'utf8',
68
+ cwd: process.cwd(),
69
+ } ).trim();
70
+ } catch ( e ) {
71
+ throw new Error( 'Could not find git repository' );
72
+ }
73
+ }
74
+
75
+ function installHooks() {
76
+ try {
77
+ // Find the correct git root
78
+ const gitRoot = findGitRoot();
79
+
80
+ // Source hook is in bin folder (same directory as this script)
81
+ const sourceHookPath = path.join( __dirname, 'pre-push' );
82
+ const targetHookPath = path.join( gitRoot, '.git', 'hooks', 'pre-push' );
83
+
84
+ if (!fs.existsSync(sourceHookPath)) {
85
+ log( 'āš ļø Larva pre-push hook not found', 'yellow' );
86
+ log( `Looking in: ${ sourceHookPath }`, 'yellow' );
87
+ return false;
88
+ }
89
+
90
+ // Create .git/hooks directory if needed
91
+ const hooksDir = path.dirname( targetHookPath );
92
+ if ( ! fs.existsSync( hooksDir ) ) {
93
+ fs.mkdirSync( hooksDir, { recursive: true } );
94
+ }
95
+
96
+ // Copy the hook
97
+ fs.copyFileSync( sourceHookPath, targetHookPath );
98
+
99
+ // Make executable
100
+ if ( process.platform !== 'win32' ) {
101
+ fs.chmodSync( targetHookPath, '755' );
102
+ }
103
+
104
+ log( 'āœ“ Larva pre-push hook installed successfully!', 'green' );
105
+ log( ` Git root: ${ gitRoot }`, 'cyan' );
106
+ log( ` Source: ${ sourceHookPath }`, 'cyan' );
107
+ log( ` Target: ${ targetHookPath }`, 'cyan' );
108
+ return true;
109
+ } catch ( error ) {
110
+ log( `āš ļø Could not install Larva hook: ${ error.message }`, 'yellow' );
111
+ return false;
112
+ }
113
+ }
114
+
115
+ // Run if called directly
116
+ if ( require.main === module ) {
117
+ log( '\nšŸ“¦ Installing Larva Git hooks...', 'cyan' );
118
+ installHooks();
119
+ log( '' );
120
+ }
121
+
122
+ module.exports = { installHooks };
package/bin/pre-push ADDED
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Pre-Push Git Hook - Larva Version Checker
5
+ *
6
+ * Automatically checks if @penskemediacorp/larva is up-to-date before allowing git push.
7
+ * Blocks push if update is available, unless --force flag is used.
8
+ *
9
+ * Installation: Auto-installed via npm postinstall script
10
+ * Override: Use --force, -f, or --no-verify flags
11
+ */
12
+
13
+ const { execSync } = require( 'child_process' );
14
+ const fs = require( 'fs' );
15
+ const path = require( 'path' );
16
+ const os = require( 'os' );
17
+
18
+ // Cache configuration
19
+ const CACHE_FILE = path.join(os.tmpdir(), 'larva-version-cache.json');
20
+ const CACHE_DURATION = 1000 * 60 * 60 * 24; // 1 Day.
21
+
22
+ // ANSI color codes
23
+ const colors = {
24
+ reset: '\x1b[0m',
25
+ red: '\x1b[31m',
26
+ yellow: '\x1b[33m',
27
+ green: '\x1b[32m',
28
+ cyan: '\x1b[36m',
29
+ bold: '\x1b[1m'
30
+ };
31
+
32
+ function log(message, color = 'reset') {
33
+ console.log(`${colors[color]}${message}${colors.reset}`);
34
+ }
35
+
36
+ function getCurrentLarvaVersion() {
37
+ try {
38
+ // Get git root directory
39
+ const gitRoot = execSync('git rev-parse --show-toplevel', {
40
+ encoding: 'utf8'
41
+ }).trim();
42
+
43
+ // Look for package.json in assets folder
44
+ const packageJsonPath = path.join(gitRoot, 'assets', 'package.json');
45
+
46
+ if (!fs.existsSync(packageJsonPath)) {
47
+ return null;
48
+ }
49
+
50
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
51
+ const larvaVersion = packageJson.dependencies?.['@penskemediacorp/larva'] ||
52
+ packageJson.devDependencies?.['@penskemediacorp/larva'];
53
+
54
+ if (!larvaVersion) {
55
+ return null;
56
+ }
57
+
58
+ // Remove all semver operators and pre-release tags
59
+ return larvaVersion.replace(/^[\^~>=<]+/, '').split('-')[0].split('+')[0];
60
+ } catch (error) {
61
+ log(`Error reading package.json: ${error.message}`, 'red');
62
+ return null;
63
+ }
64
+ }
65
+
66
+ function getLatestLarvaVersion() {
67
+
68
+ // Check cache first
69
+ if ( fs.existsSync( CACHE_FILE ) ) {
70
+ try {
71
+ const cache = JSON.parse( fs.readFileSync( CACHE_FILE, 'utf8' ) );
72
+ const now = Date.now();
73
+
74
+ // Return cached version if still valid
75
+ if ( cache.timestamp && cache.version && ( now - cache.timestamp ) < CACHE_DURATION ) {
76
+ return cache.version;
77
+ }
78
+ } catch ( error ) {
79
+ // Invalid cache file, continue to fetch
80
+ }
81
+ }
82
+
83
+ try {
84
+ const result = execSync('npm view @penskemediacorp/larva version', {
85
+ encoding: 'utf8',
86
+ stdio: ['pipe', 'pipe', 'pipe'],
87
+ timeout: 5000 // 5 second timeout
88
+ });
89
+
90
+ const version = result.trim();
91
+
92
+ // Save to cache
93
+ try {
94
+ fs.writeFileSync( CACHE_FILE, JSON.stringify( {
95
+ version: version,
96
+ timestamp: Date.now()
97
+ } ), 'utf8' );
98
+ } catch ( error ) {
99
+ // Cache write failure is non-critical, ignore
100
+ }
101
+
102
+ return version;
103
+ } catch (error) {
104
+ // Check if it's a timeout error.
105
+ if ( error.killed ) {
106
+ log( 'Warning: npm registry request timed out', 'yellow' );
107
+ } else {
108
+ log( 'Warning: Could not fetch latest @penskemediacorp/larva version from npm', 'yellow' );
109
+ }
110
+ return null;
111
+ }
112
+ }
113
+
114
+ function compareVersions(current, latest) {
115
+ const currentParts = current.split('.').map(Number);
116
+ const latestParts = latest.split('.').map(Number);
117
+
118
+ for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
119
+ const curr = currentParts[i] || 0;
120
+ const lat = latestParts[i] || 0;
121
+
122
+ if (lat > curr) return 1; // Update available
123
+ if (lat < curr) return -1; // Current is newer
124
+ }
125
+
126
+ return 0; // Same version
127
+ }
128
+
129
+ function checkForceFlag() {
130
+ const args = process.argv.slice(2);
131
+ if (args.includes('--force') || args.includes('-f')) {
132
+ return true;
133
+ }
134
+
135
+ try {
136
+ let psCommand;
137
+
138
+ if (process.platform === 'win32') {
139
+ // Try PowerShell first (works on Windows 10/11)
140
+ psCommand = `powershell -Command "Get-WmiObject Win32_Process -Filter \\"ProcessId=${process.ppid}\\" | Select-Object -ExpandProperty CommandLine"`;
141
+ } else {
142
+ // Unix-like systems
143
+ psCommand = `ps -o command= -p ${process.ppid}`;
144
+ }
145
+
146
+ const parentCommand = execSync(psCommand, {
147
+ encoding: 'utf8',
148
+ stdio: ['pipe', 'pipe', 'pipe'],
149
+ timeout: 2000 // Add timeout
150
+ }).trim();
151
+
152
+ if (parentCommand.includes('--force') || parentCommand.match(/\s-[a-z]*f[a-z]*\s/)) {
153
+ return true;
154
+ }
155
+ } catch (error) {
156
+ // Silently fail - parent process inspection failed
157
+ }
158
+
159
+ return false;
160
+ }
161
+
162
+ function main() {
163
+ log('\nšŸ” Checking @penskemediacorp/larva version...', 'cyan');
164
+
165
+ const currentVersion = getCurrentLarvaVersion();
166
+
167
+ if (!currentVersion) {
168
+ log('āœ“ No @penskemediacorp/larva dependency found in this project', 'green');
169
+ process.exit(0);
170
+ }
171
+
172
+ log(`Current version: ${currentVersion}`, 'cyan');
173
+
174
+ const latestVersion = getLatestLarvaVersion();
175
+
176
+ if (!latestVersion) {
177
+ log('⚠ Could not verify latest version, proceeding with push...', 'yellow');
178
+ process.exit(0);
179
+ }
180
+
181
+ log(`Latest version: ${latestVersion}`, 'cyan');
182
+
183
+ const comparison = compareVersions(currentVersion, latestVersion);
184
+
185
+ if (comparison > 0) {
186
+ // Update available (latest is greater than current)
187
+ const forceFlag = checkForceFlag();
188
+
189
+ log('\n' + '='.repeat(60), 'yellow');
190
+ log('āš ļø UPDATE AVAILABLE FOR @penskemediacorp/larva', 'yellow');
191
+ log('='.repeat(60), 'yellow');
192
+ log(`Current: ${currentVersion}`, 'red');
193
+ log(`Latest: ${latestVersion}`, 'green');
194
+ log('\nPlease update @penskemediacorp/larva before pushing:', 'yellow');
195
+ log(' npm install @penskemediacorp/larva@latest', 'cyan');
196
+ log('='.repeat(60) + '\n', 'yellow');
197
+
198
+ if (forceFlag) {
199
+ log('āš ļø Force flag detected - allowing push with outdated version', 'yellow');
200
+ log('Please update @penskemediacorp/larva as soon as possible!\n', 'yellow');
201
+ process.exit(0);
202
+ } else {
203
+ log('āŒ Push blocked. Please update @penskemediacorp/larva before pushing.\n', 'red');
204
+ log('To override this check:', 'yellow');
205
+ log(' git push --force # Try force push', 'cyan');
206
+ log(' git push --no-verify # Skip hook entirely\n', 'cyan');
207
+ process.exit(1);
208
+ }
209
+ } else {
210
+ log('āœ“ @penskemediacorp/larva is up to date!\n', 'green');
211
+ process.exit(0);
212
+ }
213
+ }
214
+
215
+ main();