Skip to content

A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.

Declare the Astro directory upload contract in create-site (#742)

Priyanshu Agrawal761aa05ed034
diff --git a/evals/power-pages/create-site/evals.json b/evals/power-pages/create-site/evals.json
index 3a527ad79..c9033b645 100644
--- a/evals/power-pages/create-site/evals.json
+++ b/evals/power-pages/create-site/evals.json
@@ -80,6 +80,7 @@
"expectations": [
"Discovery identifies external audience, influencing site toward landing page appeal, SEO-friendly structure, and marketing-oriented layout",
"Astro template is copied from assets/astro/ directory with all placeholders replaced",
+ "Astro powerpages.config.json keeps framework.name = astro and framework.options.buildFormat = directory so PAC uploads generated route HTML as Power Pages page content",
"Site values: __SITE_NAME__ = 'Aurelia Jewels', __SITE_SLUG__ = 'aurelia-jewels'",
"Dev server starts at localhost:4321 (Astro default) and URL is shared with the user",
"Scaffold verified via Playwright before proceeding to planning",
diff --git a/plugins/power-pages/AGENTS.md b/plugins/power-pages/AGENTS.md
index 48cacd520..6566a30f6 100644
--- a/plugins/power-pages/AGENTS.md
+++ b/plugins/power-pages/AGENTS.md
@@ -334,7 +334,7 @@ There are two template systems:
### `create-site/scripts/validate-site.js`
-Checks generated sites for: required files (`package.json`, `.gitignore`, `powerpages.config.json`), config schema fields (`$schema`, `compiledPath`, `siteName`, `defaultLandingPage`), build/dev scripts in package.json, unreplaced `__PLACEHOLDER__` tokens, git initialization, and `src/` directory existence.
+Checks generated sites for: required files (`package.json`, `.gitignore`, `powerpages.config.json`), config schema fields (`$schema`, `compiledPath`, `siteName`, `defaultLandingPage`), the Astro directory upload contract (`framework.name` and `framework.options.buildFormat`), build/dev scripts in package.json, unreplaced `__PLACEHOLDER__` tokens, git initialization, and `src/` directory existence.
### `setup-datamodel/scripts/validate-datamodel.js`
diff --git a/plugins/power-pages/scripts/tests/create-site-scaffold-loader.test.js b/plugins/power-pages/scripts/tests/create-site-scaffold-loader.test.js
index 8222d309f..3193a21ea 100644
--- a/plugins/power-pages/scripts/tests/create-site-scaffold-loader.test.js
+++ b/plugins/power-pages/scripts/tests/create-site-scaffold-loader.test.js
@@ -42,3 +42,16 @@ test('create-site templates persist the selected content locale and direction',
);
}
});
+
+test('Astro scaffold declares its Power Pages directory build format', () => {
+ const config = JSON.parse(
+ fs.readFileSync(path.join(createSiteRoot, 'astro/powerpages.config.json'), 'utf8')
+ );
+
+ assert.deepEqual(config.framework, {
+ name: 'astro',
+ options: {
+ buildFormat: 'directory',
+ },
+ });
+});
diff --git a/plugins/power-pages/scripts/tests/validate-site.test.js b/plugins/power-pages/scripts/tests/validate-site.test.js
index 7093a4485..8809e8096 100644
--- a/plugins/power-pages/scripts/tests/validate-site.test.js
+++ b/plugins/power-pages/scripts/tests/validate-site.test.js
@@ -60,6 +60,34 @@ function createAngularProject(t, angularConfig, htmlPath, html) {
return projectRoot;
}
+function createAstroProject(t, frameworkConfig) {
+ const projectRoot = createTempProject(t);
+ writeProjectFile(projectRoot, 'powerpages.config.json', JSON.stringify({
+ $schema: 'https://www.schemastore.org/powerpages.config.json',
+ compiledPath: 'dist',
+ siteName: 'Contoso Customer Portal',
+ defaultLandingPage: 'index.html',
+ ...(frameworkConfig === undefined ? {} : { framework: frameworkConfig }),
+ }));
+ writeProjectFile(projectRoot, 'package.json', JSON.stringify({
+ scripts: { build: 'astro build', dev: 'astro dev' },
+ dependencies: { astro: '^7.1.0' },
+ }));
+ writeProjectFile(projectRoot, '.gitignore', 'node_modules\n');
+ writeProjectFile(projectRoot, 'astro.config.mjs', `
+ import { defineConfig } from 'astro/config';
+ export default defineConfig({ output: 'static', build: { format: 'directory' } });
+ `);
+ writeProjectFile(
+ projectRoot,
+ 'src/layouts/Layout.astro',
+ '<html lang="en-US" dir="ltr"><body><slot /></body></html>'
+ );
+ writeProjectFile(projectRoot, 'src/pages/index.astro', '<p>Home</p>');
+ writeProjectFile(projectRoot, '.git/HEAD', 'ref: refs/heads/main\n');
+ return projectRoot;
+}
+
function runValidator(projectRoot) {
return spawnSync(process.execPath, [VALIDATOR_PATH], {
input: JSON.stringify({ cwd: projectRoot }),
@@ -161,6 +189,36 @@ test('create-site validator reports ambiguous Angular index configuration', (t)
assert.match(result.stderr, /multiple application index documents/);
});
+test('create-site validator accepts the Astro directory upload contract', (t) => {
+ const projectRoot = createAstroProject(t, {
+ name: 'astro',
+ options: { buildFormat: 'directory' },
+ });
+
+ const result = runValidator(projectRoot);
+ assert.equal(result.status, 0, result.stderr);
+});
+
+test('create-site validator requires the Astro framework upload contract', (t) => {
+ const missingFramework = runValidator(createAstroProject(t));
+ assert.equal(missingFramework.status, 2);
+ assert.match(missingFramework.stderr, /Astro sites require framework\.name "astro"/);
+ assert.match(
+ missingFramework.stderr,
+ /Astro sites require framework\.options\.buildFormat "directory"/
+ );
+
+ const wrongFormat = runValidator(createAstroProject(t, {
+ name: 'astro',
+ options: { buildFormat: 'file' },
+ }));
+ assert.equal(wrongFormat.status, 2);
+ assert.match(
+ wrongFormat.stderr,
+ /Astro sites require framework\.options\.buildFormat "directory"/
+ );
+});
+
test('create-site validator accepts approved language through direct arguments', (t) => {
const projectRoot = createProject(
t,
diff --git a/plugins/power-pages/skills/create-site/assets/astro/powerpages.config.json b/plugins/power-pages/skills/create-site/assets/astro/powerpages.config.json
index 38b910994..f33fd3f56 100644
--- a/plugins/power-pages/skills/create-site/assets/astro/powerpages.config.json
+++ b/plugins/power-pages/skills/create-site/assets/astro/powerpages.config.json
@@ -2,5 +2,11 @@
"$schema": "https://www.schemastore.org/powerpages.config.json",
"siteName": "__SITE_NAME__",
"compiledPath": "dist",
- "defaultLandingPage": "index.html"
+ "defaultLandingPage": "index.html",
+ "framework": {
+ "name": "astro",
+ "options": {
+ "buildFormat": "directory"
+ }
+ }
}
diff --git a/plugins/power-pages/skills/create-site/scripts/validate-site.js b/plugins/power-pages/skills/create-site/scripts/validate-site.js
index dbeb0226a..795a152ab 100644
--- a/plugins/power-pages/skills/create-site/scripts/validate-site.js
+++ b/plugins/power-pages/skills/create-site/scripts/validate-site.js
@@ -19,6 +19,7 @@ function validateSite(cwd, input = {}) {
const projectRoot = path.dirname(configPath);
const errors = [];
const expectedLanguage = input.expectedSiteLanguage;
+ const framework = detectFramework(projectRoot);
// 1. Required files
for (const file of ['package.json', '.gitignore', 'powerpages.config.json']) {
@@ -34,6 +35,18 @@ function validateSite(cwd, input = {}) {
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) {
+ const astroFramework = config.framework;
+ if (astroFramework?.name !== 'astro') {
+ errors.push('powerpages.config.json: Astro sites require framework.name "astro"');
+ }
+ if (astroFramework?.options?.buildFormat !== 'directory') {
+ errors.push(
+ 'powerpages.config.json: Astro sites require ' +
+ 'framework.options.buildFormat "directory"'
+ );
+ }
+ }
} catch {
errors.push('powerpages.config.json: invalid JSON');
}
@@ -74,7 +87,6 @@ function validateSite(cwd, input = {}) {
}
// 7. The root document is the persisted source of truth for single-site language.
- const framework = detectFramework(projectRoot);
if (!framework.framework || framework.ambiguous) {
errors.push('Unable to determine one supported framework for language validation');
} else {