All files / cli/src/build-tools utils.js

50% Statements 6/12
50% Branches 2/4
50% Functions 2/4
50% Lines 6/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44            1x             1x 1x 1x         1x                 1x                            
/**
 * Build Utilities for Coherent.js
 */
 
import { readFileSync } from 'fs';
 
let packageVersion = null;
 
/**
 * Version of the installed @coherent.js/cli. build-tools ships as source
 * next to package.json (src/build-tools/ → ../../package.json).
 */
function getPackageVersion() {
  Eif (packageVersion === null) {
    try {
      packageVersion = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).version ?? 'unknown';
    } catch {
      packageVersion = 'unknown';
    }
  }
  return packageVersion;
}
 
export function optimizeComponents(components) {
  // Component optimization logic
  return components;
}
 
export function generateManifest(components) {
  return {
    components: Object.keys(components),
    version: getPackageVersion(),
    build: Date.now()
  };
}
 
export function createAssetMap(assets) {
  const map = new Map();
  for (const asset of assets) {
    map.set(asset.id, asset);
  }
  return map;
}