@simpleapps-com/augur-config 0.1.4 → 0.1.5
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.
- package/package.json +8 -3
- package/src/lighthouse.js +108 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleapps-com/augur-config",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Shared tooling configuration presets for Augur ecommerce sites",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"./tsconfig/base": "./src/tsconfig/base.json",
|
|
18
18
|
"./tsconfig/react": "./src/tsconfig/react.json",
|
|
19
19
|
"./tsconfig/react-native": "./src/tsconfig/react-native.json",
|
|
20
|
-
"./tsconfig/next": "./src/tsconfig/next.json"
|
|
20
|
+
"./tsconfig/next": "./src/tsconfig/next.json",
|
|
21
|
+
"./lighthouse": "./src/lighthouse.js"
|
|
21
22
|
},
|
|
22
23
|
"files": [
|
|
23
24
|
"src"
|
|
@@ -33,7 +34,8 @@
|
|
|
33
34
|
"peerDependencies": {
|
|
34
35
|
"eslint": "^9.0.0",
|
|
35
36
|
"prettier": "^3.0.0",
|
|
36
|
-
"typescript": "^5.0.0"
|
|
37
|
+
"typescript": "^5.0.0",
|
|
38
|
+
"@lhci/cli": "^0.14.0"
|
|
37
39
|
},
|
|
38
40
|
"peerDependenciesMeta": {
|
|
39
41
|
"prettier": {
|
|
@@ -44,6 +46,9 @@
|
|
|
44
46
|
},
|
|
45
47
|
"typescript": {
|
|
46
48
|
"optional": true
|
|
49
|
+
},
|
|
50
|
+
"@lhci/cli": {
|
|
51
|
+
"optional": true
|
|
47
52
|
}
|
|
48
53
|
},
|
|
49
54
|
"scripts": {
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lighthouse CI preset for Augur e-commerce sites.
|
|
3
|
+
*
|
|
4
|
+
* Provides battle-tested Core Web Vitals thresholds tuned for e-commerce.
|
|
5
|
+
* Sites extend this preset and provide their own URLs and server config.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```js
|
|
9
|
+
* // lighthouserc.js
|
|
10
|
+
* const { lighthousePreset } = require("@simpleapps-com/augur-config/lighthouse");
|
|
11
|
+
*
|
|
12
|
+
* module.exports = lighthousePreset({
|
|
13
|
+
* urls: ["/", "/products", "/items/WAFL112", "/cart"],
|
|
14
|
+
* startServerCommand: "npm run start",
|
|
15
|
+
* // override any threshold
|
|
16
|
+
* assertions: {
|
|
17
|
+
* "largest-contentful-paint": ["error", { maxNumericValue: 3000 }],
|
|
18
|
+
* },
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** Default assertion thresholds for Augur e-commerce sites. */
|
|
24
|
+
const defaultAssertions = {
|
|
25
|
+
// Performance — Core Web Vitals
|
|
26
|
+
"first-contentful-paint": ["warn", { maxNumericValue: 2000 }],
|
|
27
|
+
"largest-contentful-paint": ["warn", { maxNumericValue: 2500 }],
|
|
28
|
+
"cumulative-layout-shift": ["warn", { maxNumericValue: 0.1 }],
|
|
29
|
+
"total-blocking-time": ["warn", { maxNumericValue: 300 }],
|
|
30
|
+
"speed-index": ["warn", { maxNumericValue: 3000 }],
|
|
31
|
+
// Accessibility
|
|
32
|
+
"color-contrast": "warn",
|
|
33
|
+
"heading-order": "warn",
|
|
34
|
+
"link-name": "warn",
|
|
35
|
+
"button-name": "warn",
|
|
36
|
+
// Best Practices
|
|
37
|
+
"errors-in-console": "warn",
|
|
38
|
+
deprecations: "warn",
|
|
39
|
+
// SEO
|
|
40
|
+
"document-title": "error",
|
|
41
|
+
"meta-description": "error",
|
|
42
|
+
"http-status-code": "error",
|
|
43
|
+
// PWA — off for e-commerce sites
|
|
44
|
+
"installable-manifest": "off",
|
|
45
|
+
"service-worker": "off",
|
|
46
|
+
"maskable-icon": "off",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates a Lighthouse CI config with Augur e-commerce defaults.
|
|
51
|
+
*
|
|
52
|
+
* @param {object} options
|
|
53
|
+
* @param {string[]} options.urls - Pages to audit (paths appended to baseUrl)
|
|
54
|
+
* @param {string} [options.baseUrl="http://localhost:3000"] - Base URL for the dev server
|
|
55
|
+
* @param {string} [options.startServerCommand] - Command to start the dev server
|
|
56
|
+
* @param {string} [options.startServerReadyPattern="ready on"] - Pattern indicating server is ready
|
|
57
|
+
* @param {number} [options.numberOfRuns=3] - Number of Lighthouse runs per URL
|
|
58
|
+
* @param {"desktop"|"perf"} [options.preset="desktop"] - Lighthouse settings preset
|
|
59
|
+
* @param {object} [options.assertions] - Override or extend default assertion thresholds
|
|
60
|
+
* @param {object} [options.collect] - Override any collect options
|
|
61
|
+
* @param {object} [options.upload] - Override upload config (default: temporary-public-storage)
|
|
62
|
+
* @returns {object} Complete lighthouserc.js config object
|
|
63
|
+
*/
|
|
64
|
+
export function lighthousePreset({
|
|
65
|
+
urls,
|
|
66
|
+
baseUrl = "http://localhost:3000",
|
|
67
|
+
startServerCommand,
|
|
68
|
+
startServerReadyPattern = "ready on",
|
|
69
|
+
numberOfRuns = 3,
|
|
70
|
+
preset = "desktop",
|
|
71
|
+
assertions = {},
|
|
72
|
+
collect = {},
|
|
73
|
+
upload = {},
|
|
74
|
+
} = {}) {
|
|
75
|
+
const resolvedUrls = (urls || ["/"])
|
|
76
|
+
.map((u) => (u.startsWith("http") ? u : `${baseUrl}${u}`));
|
|
77
|
+
|
|
78
|
+
const collectConfig = {
|
|
79
|
+
url: resolvedUrls,
|
|
80
|
+
numberOfRuns,
|
|
81
|
+
settings: { preset },
|
|
82
|
+
...collect,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (startServerCommand) {
|
|
86
|
+
collectConfig.startServerCommand = startServerCommand;
|
|
87
|
+
collectConfig.startServerReadyPattern = startServerReadyPattern;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
ci: {
|
|
92
|
+
collect: collectConfig,
|
|
93
|
+
assert: {
|
|
94
|
+
preset: "lighthouse:recommended",
|
|
95
|
+
assertions: {
|
|
96
|
+
...defaultAssertions,
|
|
97
|
+
...assertions,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
upload: {
|
|
101
|
+
target: "temporary-public-storage",
|
|
102
|
+
...upload,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { defaultAssertions };
|