@rm-industries/create-forge 0.4.0-beta.5 → 0.4.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "ci": {
3
3
  "collect": {
4
- "staticDistDir": "./dist",
5
- "url": [
6
- "http://localhost/",
7
- "http://localhost/articles/",
8
- "http://localhost/articles/designing-a-calm-starting-point/"
9
- ],
4
+ "startServerCommand": "npm run preview -- --host 127.0.0.1",
5
+ "startServerReadyPattern": "Local",
6
+ "startServerReadyTimeout": 30000,
10
7
  "numberOfRuns": 3
11
8
  },
12
9
  "assert": {
@@ -69,7 +69,8 @@ the complete Playwright and axe suite, and Lighthouse budgets in that order.
69
69
  Each stage is joined with `&&`, so the command stops immediately and returns a
70
70
  non-zero status when any stage fails. Browser tests and Lighthouse start from
71
71
  their own production build so they remain independently runnable and cannot
72
- accidentally inspect stale output.
72
+ accidentally inspect stale output. Both use Astro's preview server and derive
73
+ any deployment base path from the configured canonical site URL.
73
74
 
74
75
  The complete command is intentionally high cost. Use `npm run quality:static`
75
76
  for the quickest source-only feedback or `npm run quality:core` for every check
@@ -147,10 +148,12 @@ alternative-text quality.
147
148
 
148
149
  Lighthouse CI runs three times each against the production home, article
149
150
  listing, and article detail pages, then enforces median category scores and
150
- transfer budgets. The measured baseline, headroom, exclusions, and update rules
151
- are documented in `docs/performance-budget.md`. Reports are written to the
152
- generated `.lighthouseci/` directory; CI retains them for seven days even when
153
- an assertion fails.
151
+ transfer budgets. Its typed runner prefixes those routes with a configured
152
+ project path, so local checks exercise GitHub Pages project sites with the same
153
+ asset URLs used in production. The measured baseline, headroom, exclusions, and
154
+ update rules are documented in `docs/performance-budget.md`. Reports are written
155
+ to the generated `.lighthouseci/` directory; CI retains them for seven days even
156
+ when an assertion fails.
154
157
 
155
158
  The configured exclusions cover only generated output, dependency directories,
156
159
  and tool artifacts. Stylelint's exceptions recognize Tailwind and DaisyUI
@@ -3,7 +3,10 @@
3
3
  Lighthouse CI protects the generated site's public-page baseline. Run
4
4
  `npm run lighthouse:ci` after changes that can affect rendering, assets,
5
5
  metadata, or client behavior. The command builds the production site, collects
6
- three reports per route, and evaluates the median result.
6
+ three reports per route from Astro's preview server, and evaluates the median
7
+ result. The typed runner derives Astro's optional deployment base from
8
+ `src/config/site.ts`, ensuring project-path assets and routes are measured at
9
+ their production-relative locations.
7
10
 
8
11
  ## Enforced routes
9
12
 
@@ -9235,9 +9235,9 @@
9235
9235
  }
9236
9236
  },
9237
9237
  "node_modules/fast-uri": {
9238
- "version": "3.1.5",
9239
- "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.5.tgz",
9240
- "integrity": "sha512-gHwA1O9LDIcKunMKhObS/HimwtehO1nPUECKAu5TpKgaO19fcWEl4bliWe1jWxVFvIXztJjjQ4L8XQ1EU9f7Jw==",
9238
+ "version": "3.1.7",
9239
+ "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.7.tgz",
9240
+ "integrity": "sha512-dOvZVzjdZdz7phd9v6jCbwxrBW3fK6n8Rc0CtdmM4bumzMnxywBYhuph6J819RRw/ku+rLbelwfMunktuzVVHg==",
9241
9241
  "dev": true,
9242
9242
  "funding": [
9243
9243
  {
@@ -21,7 +21,8 @@
21
21
  "lint:css:fix": "stylelint --fix \"**/*.css\" --ignore-path .gitignore",
22
22
  "lint:markdown": "markdownlint \"**/*.md\" --ignore-path .gitignore",
23
23
  "lint:markdown:fix": "markdownlint --fix \"**/*.md\" --ignore-path .gitignore",
24
- "lighthouse:ci": "npm run build && lhci autorun",
24
+ "lighthouse:autorun": "lhci autorun",
25
+ "lighthouse:ci": "npm run build && node scripts/run-lighthouse.ts",
25
26
  "spellcheck": "cspell \"**\"",
26
27
  "typecheck": "astro sync && tsc --noEmit",
27
28
  "test": "npm run test:unit",
@@ -0,0 +1,21 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { getLighthouseUrls } from './run-lighthouse';
4
+
5
+ describe('getLighthouseUrls', () => {
6
+ it('audits root deployments from the preview origin', () => {
7
+ expect(getLighthouseUrls('https://example.com')).toEqual([
8
+ 'http://127.0.0.1:4321/',
9
+ 'http://127.0.0.1:4321/articles/',
10
+ 'http://127.0.0.1:4321/articles/designing-a-calm-starting-point/',
11
+ ]);
12
+ });
13
+
14
+ it('audits project deployments below their configured base path', () => {
15
+ expect(getLighthouseUrls('https://example.github.io/example-project')).toEqual([
16
+ 'http://127.0.0.1:4321/example-project/',
17
+ 'http://127.0.0.1:4321/example-project/articles/',
18
+ 'http://127.0.0.1:4321/example-project/articles/designing-a-calm-starting-point/',
19
+ ]);
20
+ });
21
+ });
@@ -0,0 +1,30 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { createRequire } from 'node:module';
3
+ import { pathToFileURL } from 'node:url';
4
+
5
+ import { getDeploymentConfig } from '../src/config/deployment.ts';
6
+ import { site } from '../src/config/site.ts';
7
+ import { resolveSiteHref } from '../src/lib/paths.ts';
8
+
9
+ const previewOrigin = 'http://127.0.0.1:4321';
10
+ const auditedPaths = ['/', '/articles/', '/articles/designing-a-calm-starting-point/'] as const;
11
+
12
+ export const getLighthouseUrls = (siteUrl: string, origin = previewOrigin): string[] => {
13
+ const deployment = getDeploymentConfig(siteUrl);
14
+
15
+ return auditedPaths.map((path) => new URL(resolveSiteHref(path, deployment.base ?? '/'), origin).href);
16
+ };
17
+
18
+ export const runLighthouse = (): void => {
19
+ const lighthouseCli = createRequire(import.meta.url).resolve('@lhci/cli/src/cli.js');
20
+ const urlArguments = getLighthouseUrls(site.url).map((url) => `--collect.url=${url}`);
21
+ const result = spawnSync(process.execPath, [lighthouseCli, 'autorun', ...urlArguments], {
22
+ env: { ...process.env, ASTRO_PREVIEW_BACKGROUND: '0' },
23
+ stdio: 'inherit',
24
+ });
25
+
26
+ if (result.error) throw result.error;
27
+ if (result.status !== 0) process.exitCode = result.status ?? 1;
28
+ };
29
+
30
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) runLighthouse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rm-industries/create-forge",
3
- "version": "0.4.0-beta.5",
3
+ "version": "0.4.0-beta.6",
4
4
  "description": "Create a content-driven Forge website",
5
5
  "keywords": [
6
6
  "astro",