CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

adobe/aem-cloud-service

All AEM as a Cloud Service skills: component development, Workflow model design, development, triggering, launchers, debugging, and triaging, Dispatcher config authoring, advisory, incident response, performance tuning, and security hardening, Rapid Development Environment (RDE) deployment, log inspection, snapshots, and troubleshooting via `aio aem rde`, Jackrabbit Oak query/index tuning (property, Lucene index definitions), and extracting/inventorying JCR queries (XPath, SQL2, QueryBuilder) across a codebase.

Quality

85%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

mapping.jsskills/migration/scripts/validate-migration/check/patterns/custom-templates/

'use strict';

const { execFileSync } = require('child_process');

const LAYOUT_KINDS = new Set(['parsys', 'responsivegrid', 'container']);

function componentKind(resourceType) {
  const segments = resourceType.split('/').filter((segment) => !/^v\d+$/.test(segment));
  return segments[segments.length - 1];
}

// Elements carrying sling:resourceType, in document order.
function resourceNodes(xml) {
  return [...xml.matchAll(/<([\w:.-]+)\s([^>]*?)\/?>/g)].flatMap(([, name, attrs]) => {
    const type = attrs.match(/sling:resourceType="([^"]+)"/);
    return type ? [{ name, resourceType: type[1], editable: /editable="\{Boolean\}true"/.test(attrs) }] : [];
  });
}

function components(nodes) {
  return nodes.filter((node) => node.name !== 'jcr:content' && !LAYOUT_KINDS.has(componentKind(node.resourceType)));
}

/**
 * Compare the pre-migration static template (read from Git, never the working tree)
 * with the packaged editable template's structure and initial content.
 */
function verifyComponentMapping({ artifactPath, template, projectDir, staticTemplate, baselineRef = 'HEAD' }) {
  const staticPath = staticTemplate || template.replace(/^\/conf\/([^/]+)\/settings\/wcm\/templates\//, '/apps/$1/templates/');
  if (!/^\/apps\/[\w.-]+(\/[\w.-]+)*$/.test(staticPath)) return { verified: false, reason: `invalid --static-template ${JSON.stringify(staticPath)}` };
  let staticXml;
  if (typeof baselineRef !== 'string' || !baselineRef || baselineRef.startsWith('-')) {
    return { verified: false, reason: `invalid --baseline-ref ${JSON.stringify(baselineRef)}` };
  }
  try {
    const git = (...args) => execFileSync('git', args, { cwd: projectDir || process.cwd(), encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
    const commit = git('rev-parse', '--verify', `${baselineRef}^{commit}`).trim();
    const suffix = `/jcr_root${staticPath}/.content.xml`;
    const file = git('ls-tree', '-r', '--full-tree', '--name-only', commit).split('\n').find((name) => name.endsWith(suffix));
    if (!file) return { verified: false, reason: `static template ${staticPath} not found at ${baselineRef}` };
    staticXml = git('show', `${commit}:${file}`);
  } catch {
    return { verified: false, reason: `cannot read static template ${staticPath} from Git ref ${baselineRef}` };
  }
  const read = (child) => {
    try {
      return execFileSync('unzip', ['-p', artifactPath, `jcr_root${template}/${child}/.content.xml`], { encoding: 'utf8' });
    } catch {
      return '';
    }
  };
  const staticNodes = resourceNodes(staticXml);
  const structureNodes = resourceNodes(read('structure'));
  const editableTypes = components([...structureNodes, ...resourceNodes(read('initial'))]).map((node) => componentKind(node.resourceType));
  const missing = [];
  for (const node of components(staticNodes)) {
    const index = editableTypes.indexOf(componentKind(node.resourceType));
    if (index >= 0) editableTypes.splice(index, 1);
    else missing.push(`${node.name} (${node.resourceType})`);
  }
  const staticHasParsys = staticNodes.some((node) => ['parsys', 'responsivegrid'].includes(componentKind(node.resourceType)));
  if (staticHasParsys && !structureNodes.some((node) => node.editable)) missing.push('editable container for the static parsys');
  return { verified: true, ok: !missing.length, staticPath, missing };
}

module.exports = { verifyComponentMapping };

skills

migration

README.md

SKILL.md

README.md

tile.json