All files / packages/design-system/scripts/core core-css-artifacts.js

88.88% Statements 32/36
80% Branches 16/20
100% Functions 3/3
86.2% Lines 25/29

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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 1044x                                                                                             28x     9x 2x     7x 7x   7x 33x 1x   32x   32x 1x   31x   31x 31x     31x 1x       30x         30x             4x 28x         4x     4x 28x     4x  
const artifacts = [
  {
    id: 'slds',
    candidatePath: 'shared-slds-impl/resources/assets/css/slds.css',
    gitcorePath: 'shared-slds-impl/resources/assets/css/slds.css',
    storage: 'lfs',
  },
  {
    id: 'scopedSlds',
    candidatePath: 'shared-slds-impl/resources/assets/css/scopedSlds.css',
    gitcorePath: 'shared-slds-impl/resources/assets/css/scopedSlds.css',
    storage: 'lfs',
  },
  {
    id: 'sldsOffline',
    candidatePath: 'shared-slds-impl/resources/assets/css/sldsOffline.css',
    gitcorePath: 'shared-slds-impl/resources/assets/css/sldsOffline.css',
    storage: 'lfs',
  },
  {
    id: 'sldsTemplate',
    candidatePath: 'ui-force-components/components/force/sldsTemplate/sldsTemplate.css',
    gitcorePath: 'ui-force-components/components/force/sldsTemplate/sldsTemplate.css',
    storage: 'lfs',
  },
  {
    id: 'scopedSldsTemplate',
    candidatePath:
      'ui-force-components/components/force/scopedSldsTemplate/scopedSldsTemplate.css',
    gitcorePath:
      'ui-force-components/components/force/scopedSldsTemplate/scopedSldsTemplate.css',
    storage: 'lfs',
  },
  {
    id: 'sldsOfflineComponent',
    candidatePath: 'ui-force-components/components/force/sldsOffline/sldsOffline.css',
    gitcorePath: 'ui-force-components/components/force/sldsOffline/sldsOffline.css',
    storage: 'lfs',
  },
  {
    id: 'sldsTouch',
    candidatePath: 'sfdc/htdocs/_slds/styles/sldsTouch.css',
    gitcorePath: 'sfdc/htdocs/_slds/styles/sldsTouch.css',
    storage: 'git',
  },
];
 
const expectedById = new Map(artifacts.map((artifact) => [artifact.id, artifact]));
 
export function validateCoreCssManifest(manifest) {
  if (!Array.isArray(manifest) || manifest.length !== artifacts.length) {
    throw new Error(`Core CSS manifest must contain exactly ${artifacts.length} artifacts`);
  }
 
  const ids = new Set();
  const gitcorePaths = new Set();
 
  for (const artifact of manifest) {
    if (ids.has(artifact.id)) {
      throw new Error(`Core CSS manifest has duplicate artifact id: ${artifact.id}`);
    }
    ids.add(artifact.id);
 
    if (gitcorePaths.has(artifact.gitcorePath)) {
      throw new Error(`Core CSS manifest has duplicate Gitcore path: ${artifact.gitcorePath}`);
    }
    gitcorePaths.add(artifact.gitcorePath);
 
    const expected = expectedById.get(artifact.id);
    Iif (!expected) {
      throw new Error(`Core CSS manifest has unexpected artifact id: ${artifact.id}`);
    }
    if (artifact.candidatePath !== expected.candidatePath) {
      throw new Error(
        `Core CSS manifest candidate path mismatch for ${artifact.id}: expected ${expected.candidatePath}, received ${artifact.candidatePath}`,
      );
    }
    Iif (artifact.gitcorePath !== expected.gitcorePath) {
      throw new Error(
        `Core CSS manifest Gitcore path mismatch for ${artifact.id}: expected ${expected.gitcorePath}, received ${artifact.gitcorePath}`,
      );
    }
    Iif (artifact.storage !== expected.storage) {
      throw new Error(
        `Core CSS manifest storage mismatch for ${artifact.id}: expected ${expected.storage}, received ${artifact.storage}`,
      );
    }
  }
 
  for (const { id } of artifacts) {
    Iif (!ids.has(id)) {
      throw new Error(`Core CSS manifest is missing artifact: ${id}`);
    }
  }
 
  return manifest;
}
 
export const CORE_CSS_ARTIFACTS = Object.freeze(
  artifacts.map((artifact) => Object.freeze({ ...artifact })),
);
 
validateCoreCssManifest(CORE_CSS_ARTIFACTS);