Skip to content

microsoft/power-platform-skills / plugins/power-pages/skills/create-site

create-site

Verified

Creates a new Power Pages site from an SPA or non-SPA template, or scaffolds an SPA from scratch using React, Angular, Vue, or Astro. Guides requirements discovery, template selection, provisioning, design, validation, and deployment. Use when the user wants to create, build, use a template for, or scaffold a new Power Pages website or portal.

FileKindSize
SKILL.mdskill md155.6 KB
assets/angular/angular.jsonconfig1.6 KB
assets/angular/gitignoreother484 B
assets/angular/package.jsonmanifest743 B
assets/angular/powerpages.config.jsonconfig187 B
assets/angular/public/.gitkeepother0 B
assets/angular/src/app/app.component.tsscript365 B
assets/angular/src/app/app.config.tsscript319 B
assets/angular/src/app/app.routes.tsscript278 B
assets/angular/src/app/components/layout.component.tsscript167 B
assets/angular/src/app/pages/about.component.tsscript151 B
assets/angular/src/app/pages/home.component.tsscript24.0 KB
assets/angular/src/index.htmlother703 B
assets/angular/src/main.tsscript208 B
assets/angular/src/styles.cssother333 B
assets/angular/tsconfig.app.jsonconfig153 B
assets/angular/tsconfig.jsonconfig542 B
assets/astro/astro.config.mjsscript139 B
assets/astro/gitignoreother358 B
assets/astro/package.jsonmanifest285 B
assets/astro/powerpages.config.jsonconfig264 B
assets/astro/public/.gitkeepother0 B
assets/astro/src/components/Footer.astroother70 B
assets/astro/src/components/Header.astroother70 B
assets/astro/src/layouts/Layout.astroother946 B
assets/astro/src/pages/about.astroother87 B
assets/astro/src/pages/index.astroother22.6 KB
assets/astro/src/styles/theme.cssother333 B
assets/astro/tsconfig.jsonconfig42 B
assets/create-site-plan.htmlother30.2 KB
assets/non-spa-creation-status-template.htmlother35.0 KB
assets/react/gitignoreother419 B
assets/react/index.htmlother759 B
assets/react/package.jsonmanifest488 B
assets/react/powerpages.config.jsonconfig165 B
assets/react/src/App.tsxother362 B
assets/react/src/components/Layout.tsxother139 B
assets/react/src/main.tsxother325 B
assets/react/src/pages/About.tsxother50 B
assets/react/src/pages/Home.tsxother23.9 KB
assets/react/src/styles/theme.cssother333 B
assets/react/tsconfig.jsonconfig509 B
assets/react/vite.config.tsscript169 B
assets/shared/power-pages-icon.pngbinary22.2 KB
assets/template-browser.htmlother6.5 KB
assets/vue/env.d.tsscript186 B
assets/vue/gitignoreother419 B
assets/vue/index.htmlother757 B
assets/vue/package.jsonmanifest412 B
assets/vue/powerpages.config.jsonconfig165 B
assets/vue/src/App.vueother146 B
assets/vue/src/components/Layout.vueother34 B
assets/vue/src/main.tsscript160 B
assets/vue/src/pages/About.vueother37 B
assets/vue/src/pages/Home.vueother23.2 KB
assets/vue/src/router/index.tsscript319 B
assets/vue/src/styles/theme.cssother333 B
assets/vue/tsconfig.jsonconfig560 B
assets/vue/vite.config.tsscript163 B
references/design-aesthetics.mdmarkdown617 B
scripts/list-site-templates.jsscript4.6 KB
scripts/render-non-spa-status.jsscript14.0 KB
scripts/resolve-non-spa-context.jsscript5.6 KB
scripts/validate-site.jsscript15.7 KB
workflows/non-spa-site.mdmarkdown36.3 KB

scripts/validate-site.js

View on GitHub
#!/usr/bin/env node

// Validates either a generated SPA site or a PAC-downloaded non-SPA site.
// The PostToolUse hook uses structural checks; the non-SPA workflow also passes the
// expected website record ID and optional Bootstrap major before creating the Git baseline.

const fs = require('fs');
const path = require('path');
const {
  approve,
  block,
  runValidation,
  findProjectRoot,
  UUID_REGEX,
} = require('../../../scripts/lib/validation-helpers');
const { detectFramework } = require('../../../scripts/lib/framework-detection');
const { inspectSite } = require('../../../scripts/lib/non-spa-site-style-context');
const {
  normalizeBootstrapVersion,
  parseBootstrapVersionArgs,
} = require('../../../scripts/lib/site-templates');
const {
  resolveLocale,
  resolveSiteLanguageContext,
} = require('../../../scripts/lib/localization-config');

const PLACEHOLDER_RE = /__[A-Z][A-Z_]{2,}__/;
const DECLARATIVE_COMPONENT_DIRS = new Set([
  'ad-placements',
  'advanced-forms',
  'basic-forms',
  'bot-consumers',
  'cloud-flow-definitions',
  'content-snippets',
  'lists',
  'page-templates',
  'poll-placements',
  'publishing-state-transition-rules',
  'site-settings',
  'table-permissions',
  'web-files',
  'web-link-sets',
  'web-pages',
  'web-roles',
  'web-templates',
]);

function findPlaceholdersInFile(filePath) {
  const results = [];
  try {
    const lines = fs.readFileSync(filePath, 'utf8').split('\n');
    for (let index = 0; index < lines.length; index += 1) {
      if (PLACEHOLDER_RE.test(lines[index])) {
        results.push(`${path.basename(filePath)}:${index + 1}: ${lines[index].trim()}`);
      }
    }
  } catch {}
  return results;
}

function findPlaceholders(dir) {
  const results = [];
  try {
    for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
      const fullPath = path.join(dir, entry.name);
      if (entry.isDirectory() && entry.name !== 'node_modules') {
        results.push(...findPlaceholders(fullPath));
      } else if (entry.isFile()) {
        results.push(...findPlaceholdersInFile(fullPath));
      }
    }
  } catch {}
  return results;
}

function validateCodeProject(projectRoot, expectedLanguage) {
  const errors = [];
  const configPath = path.join(projectRoot, 'powerpages.config.json');
  const framework = detectFramework(projectRoot);

  for (const file of ['package.json', '.gitignore', 'powerpages.config.json']) {
    if (!fs.existsSync(path.join(projectRoot, file))) {
      errors.push(`Missing required file: ${file}`);
    }
  }

  try {
    const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
    if (!config.$schema) errors.push('powerpages.config.json: missing $schema');
    if (!config.compiledPath) errors.push('powerpages.config.json: missing compiledPath');
    if (!config.siteName) errors.push('powerpages.config.json: missing siteName');
    if (!config.defaultLandingPage) {
      errors.push('powerpages.config.json: missing defaultLandingPage');
    }
    if (framework.framework === 'astro' && !framework.ambiguous) {
      if (config.framework?.name !== 'astro') {
        errors.push('powerpages.config.json: Astro sites require framework.name "astro"');
      }
      if (config.framework?.options?.buildFormat !== 'directory') {
        errors.push(
          'powerpages.config.json: Astro sites require ' +
          'framework.options.buildFormat "directory"',
        );
      }
    }
  } catch {
    errors.push('powerpages.config.json: invalid JSON');
  }

  try {
    const pkg = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'));
    if (!pkg.scripts || !pkg.scripts.build) errors.push('package.json: missing "build" script');
    if (!pkg.scripts || !pkg.scripts.dev) errors.push('package.json: missing "dev" script');
  } catch {}

  const placeholders = [];
  const sourceDir = path.join(projectRoot, 'src');
  if (fs.existsSync(sourceDir)) placeholders.push(...findPlaceholders(sourceDir));
  const indexPath = path.join(projectRoot, 'index.html');
  if (fs.existsSync(indexPath)) placeholders.push(...findPlaceholdersInFile(indexPath));
  if (placeholders.length > 0) {
    errors.push(`Unreplaced placeholders found:\n  ${placeholders.slice(0, 5).join('\n  ')}`);
    if (placeholders.length > 5) {
      errors.push(`  ...and ${placeholders.length - 5} more`);
    }
  }

  if (!fs.existsSync(path.join(projectRoot, '.git'))) {
    errors.push('Git repository not initialized');
  }
  if (!fs.existsSync(sourceDir)) errors.push('Missing src/ directory');

  if (!framework.framework || framework.ambiguous) {
    errors.push('Unable to determine one supported framework for language validation');
  } else {
    const siteLanguage = resolveSiteLanguageContext(projectRoot, framework.framework);
    if (!siteLanguage.detected) {
      const expected = siteLanguage.expectedSources?.length
        ? ` Expected: ${siteLanguage.expectedSources.join(', ')}.`
        : '';
      if (siteLanguage.reason === 'document-not-found') {
        errors.push(`Root document was not found.${expected}`);
      } else if (siteLanguage.reason === 'html-root-not-found') {
        errors.push(`Root html element was not found in the discovered document.${expected}`);
      } else if (
        siteLanguage.reason === 'document-ambiguous' ||
        siteLanguage.reason === 'document-configuration-invalid'
      ) {
        errors.push(
          `Root document configuration is invalid:\n  ${siteLanguage.conflicts.join('\n  ')}`,
        );
      } else {
        errors.push(`Document language could not be determined.${expected}`);
      }
    } else if (!siteLanguage.valid) {
      errors.push(`Document language is invalid:\n  ${siteLanguage.conflicts.join('\n  ')}`);
    } else if (expectedLanguage !== undefined) {
      const expectedLocale = resolveLocale(expectedLanguage?.locale);
      const expectedDirection = expectedLanguage?.direction;
      if (!expectedLocale.valid || !['ltr', 'rtl'].includes(expectedDirection)) {
        errors.push(
          'Expected site language is invalid: provide a valid locale and ltr or rtl direction',
        );
      } else if (expectedDirection !== expectedLocale.direction) {
        errors.push(
          `Expected site direction "${expectedDirection}" does not match ` +
          `${expectedLocale.locale}, which resolves to "${expectedLocale.direction}"`,
        );
      } else {
        const source = siteLanguage.source || 'site language configuration';
        if (siteLanguage.locale !== expectedLocale.locale) {
          errors.push(
            `${source} uses locale "${siteLanguage.locale}", but the approved site locale is ` +
            `"${expectedLocale.locale}"`,
          );
        }
        if (siteLanguage.direction !== expectedDirection) {
          errors.push(
            `${source} uses direction "${siteLanguage.direction}", but the approved site ` +
            `direction is "${expectedDirection}"`,
          );
        }
      }
    }
  }

  return errors;
}

function readWebsiteIdentity(websitePath) {
  const raw = fs.readFileSync(websitePath, 'utf8');
  // PAC exports use either "id: <guid>" or "adx_websiteid: <guid>".
  // Read only top-level identity keys, never an indented block's sample value;
  // conflicting aliases must not select whichever website happens to come first.
  const matches = [...raw.matchAll(/^(?:\uFEFF)?(id|adx_websiteid)[ \t]*:[ \t]*(.*?)[ \t]*$/gim)];
  const ids = matches.map((match) => {
    let id = match[2].replace(/\s+#.*$/, '').trim();
    if (
      (id.startsWith('"') && id.endsWith('"')) ||
      (id.startsWith("'") && id.endsWith("'"))
    ) {
      id = id.slice(1, -1);
    }
    return id;
  });
  const duplicateKey = new Set(matches.map((match) => match[1].toLowerCase())).size !== matches.length;
  const consistent = ids.length > 0 && ids.every((id) => id.toLowerCase() === ids[0].toLowerCase());
  return { raw, id: !duplicateKey && consistent ? ids[0] : null };
}

function listNonSpaAssetFiles(siteDir) {
  const files = [];
  const walk = (dir) => {
    for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
      const fullPath = path.join(dir, entry.name);
      if (entry.isDirectory()) {
        walk(fullPath);
      } else if (entry.isFile() && /\.(?:ya?ml|html?|css|js|liquid)$/i.test(entry.name)) {
        files.push(fullPath);
      }
    }
  };
  // A direct-root download can also contain project documentation. Count only known
  // PAC component directories so docs/current-plan.html cannot make an empty site valid.
  for (const entry of fs.readdirSync(siteDir, { withFileTypes: true })) {
    if (entry.isDirectory() && DECLARATIVE_COMPONENT_DIRS.has(entry.name)) {
      walk(path.join(siteDir, entry.name));
    }
  }
  return files;
}

function validateNonSpaProject(
  projectRoot,
  { expectedWebsiteRecordId = null, expectedBootstrapMajor = null, skipGit = false } = {},
) {
  const errors = [];
  // Create-site stores its download under `.powerpages-site`, while users who download
  // manually can open the PAC site root itself. Both layouts carry the same non-SPA
  // markers, so validate the selected site rather than requiring one wrapper directory.
  const nestedSiteDir = path.join(projectRoot, '.powerpages-site');
  const siteDir = fs.existsSync(nestedSiteDir) ? nestedSiteDir : projectRoot;
  const displayPrefix = siteDir === projectRoot ? '' : '.powerpages-site/';
  const portalConfigDir = path.join(siteDir, '.portalconfig');
  const websitePath = path.join(siteDir, 'website.yml');

  if (!fs.existsSync(portalConfigDir) || !fs.statSync(portalConfigDir).isDirectory()) {
    errors.push(`Missing non-SPA marker: ${displayPrefix}.portalconfig/`);
  }
  if (!fs.existsSync(websitePath) || fs.statSync(websitePath).size === 0) {
    errors.push(`Missing or empty identity file: ${displayPrefix}website.yml`);
  } else {
    const identity = readWebsiteIdentity(websitePath);
    if (!identity.id || !UUID_REGEX.test(identity.id)) {
      errors.push(`${displayPrefix}website.yml: missing, invalid or conflicting id/adx_websiteid`);
    } else if (
      expectedWebsiteRecordId &&
      identity.id.toLowerCase() !== expectedWebsiteRecordId.toLowerCase()
    ) {
      errors.push(
        `${displayPrefix}website.yml id ${identity.id} does not match created website ` +
          `${expectedWebsiteRecordId}`,
      );
    }
  }

  try {
    if (fs.existsSync(siteDir) && listNonSpaAssetFiles(siteDir).length === 0) {
      errors.push('Downloaded non-SPA tree contains no site assets beyond identity metadata');
    }
  } catch (error) {
    errors.push(`Could not inspect non-SPA site assets: ${error.message}`);
  }

  if (expectedBootstrapMajor !== null) {
    try {
      const expected = normalizeBootstrapVersion(expectedBootstrapMajor);
      // Inspect the same selected download as the structural/identity checks.
      // The shared inspector requires asset evidence and reconciles settings with
      // it; an Enhanced model or Site/BootstrapV5Enabled alone is not proof.
      const { bootstrap } = inspectSite(siteDir);
      if (!bootstrap.major || !bootstrap.evidence.some((entry) => entry.kind === 'asset')) {
        errors.push(
          `Could not verify expected Bootstrap ${expected}: downloaded Bootstrap asset evidence ` +
          'is missing, conflicting, or unsupported.',
        );
      } else if (bootstrap.major !== expected) {
        errors.push(`Downloaded site uses Bootstrap ${bootstrap.major}; expected Bootstrap ${expected}.`);
      }
    } catch (error) {
      errors.push(`Could not verify downloaded Bootstrap version: ${error.message}`);
    }
  }

  if (!skipGit && !fs.existsSync(path.join(projectRoot, '.git'))) {
    errors.push('Git repository not initialized');
  }

  return errors;
}

function validateProject(projectRoot, options = {}) {
  const missingProject = () => ({
    siteType: null,
    errors: options.expectedBootstrapMajor == null
      ? [] : ['Cannot verify Bootstrap without a non-SPA Power Pages project.'],
  });
  if (!projectRoot) return missingProject();
  if (fs.existsSync(path.join(projectRoot, 'powerpages.config.json'))) {
    const errors = validateCodeProject(projectRoot, options.expectedSiteLanguage);
    if (options.expectedBootstrapMajor != null) {
      errors.push('--bootstrapVersion is only supported for non-SPA sites, not SPA sites.');
    }
    return { siteType: 'spa', errors };
  }
  if (
    fs.existsSync(path.join(projectRoot, '.powerpages-site')) ||
    (
      fs.existsSync(path.join(projectRoot, '.portalconfig')) &&
      fs.existsSync(path.join(projectRoot, 'website.yml'))
    )
  ) {
    return {
      siteType: 'non-spa',
      errors: validateNonSpaProject(projectRoot, options),
    };
  }
  return missingProject();
}

function parseArgs(argv) {
  const args = {};
  const bootstrapVersion = parseBootstrapVersionArgs(argv);
  for (let index = 0; index < argv.length; index += 1) {
    if (!argv[index].startsWith('--')) continue;
    const key = argv[index].slice(2);
    const value = argv[index + 1];
    if (value && !value.startsWith('--')) {
      args[key] = value;
      index += 1;
    }
  }
  if (bootstrapVersion !== undefined) args.bootstrapVersion = bootstrapVersion;
  return args;
}

function siteTypeLabel(siteType) {
  if (siteType === 'spa') return 'SPA site';
  if (siteType === 'non-spa') return 'non-SPA site';
  return 'site';
}

function validationMessage(result) {
  return `Power Pages ${siteTypeLabel(result.siteType)} validation failed:\n- ${result.errors.join('\n- ')}`;
}

function runHook() {
  runValidation((cwd, input) => {
    const projectRoot = findProjectRoot(cwd);
    const result = validateProject(projectRoot, {
      expectedSiteLanguage: input?.expectedSiteLanguage,
    });
    if (result.errors.length > 0) block(validationMessage(result));
    approve();
  });
}

function runDirect() {
  try {
    const args = parseArgs(process.argv.slice(2));
    const allowedArgs = new Set([
      'projectRoot',
      'websiteRecordId',
      'bootstrapVersion',
      'bootstrap-version',
      'skipGit',
      'expectedLocale',
      'expectedDirection',
    ]);
    const languageArgsComplete = Boolean(args.expectedLocale) === Boolean(args.expectedDirection);
    if (
      Object.keys(args).some((key) => !allowedArgs.has(key)) ||
      !languageArgsComplete
    ) {
      throw new Error(
        'Usage: validate-site.js [--projectRoot <path>] [--websiteRecordId <guid>] ' +
        '[--bootstrapVersion <3|5>] [--skipGit true] ' +
        '[--expectedLocale <canonical-bcp47-tag> --expectedDirection <ltr|rtl>]',
      );
    }
    const cwd = process.cwd();
    const directSite = fs.existsSync(path.join(cwd, '.portalconfig')) &&
      fs.existsSync(path.join(cwd, 'website.yml'));
    const projectRoot = args.projectRoot
      ? path.resolve(args.projectRoot)
      : directSite ? cwd : findProjectRoot(cwd);
    const result = validateProject(projectRoot, {
      expectedWebsiteRecordId: args.websiteRecordId || null,
      expectedBootstrapMajor: args.bootstrapVersion ?? null,
      skipGit: args.skipGit === 'true',
      expectedSiteLanguage: args.expectedLocale
        ? { locale: args.expectedLocale, direction: args.expectedDirection }
        : undefined,
    });
    if (!result.siteType) {
      process.stderr.write('No Power Pages project found.\n');
      process.exitCode = 2;
    } else if (result.errors.length > 0) {
      process.stderr.write(`${validationMessage(result)}\n`);
      process.exitCode = 2;
    } else {
      process.stdout.write(`Power Pages ${siteTypeLabel(result.siteType)} validation passed.\n`);
    }
  } catch (error) {
    process.stderr.write(`${validationMessage({ errors: [error.message] })}\n`);
    process.exitCode = 2;
  }
}

if (require.main === module) {
  if (process.argv.slice(2).length > 0) runDirect();
  else runHook();
}

module.exports = {
  findPlaceholdersInFile,
  findPlaceholders,
  readWebsiteIdentity,
  listNonSpaAssetFiles,
  validateCodeProject,
  validateNonSpaProject,
  validateProject,
  parseArgs,
};
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall