@digigov/cli-metrics 1.1.0-rc.21 → 2.0.0-298cfc51
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,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"../../tooling/cli-metrics": "../../tooling/cli-metrics:
|
|
3
|
-
"/execa@5.0.0": "Missing shrinkwrap entry!",
|
|
2
|
+
"../../tooling/cli-metrics": "../../tooling/cli-metrics:bUy8+Une7YPM8pmMLCKzH8CalO47qVnEyNssbmFJscM=:",
|
|
4
3
|
"/lighthouse@9.6.6(encoding@0.1.13)": "Missing shrinkwrap entry!",
|
|
5
4
|
"/playwright-chromium@1.41.0": "Missing shrinkwrap entry!",
|
|
6
5
|
"/playwright-lighthouse@2.2.2": "Missing shrinkwrap entry!",
|
package/index.js
CHANGED
|
@@ -1,49 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
rc = require(`${project.root}/lighthouse.config.js`)
|
|
30
|
-
}catch(err){
|
|
31
|
-
console.log(err)
|
|
32
|
-
console.log(`No lighthouse.config.js file is found. Fallback to sane defaults.`)
|
|
33
|
-
}
|
|
34
|
-
const browser = await playwright['chromium'].launch({
|
|
35
|
-
args: ['--remote-debugging-port=9222'],
|
|
36
|
-
});
|
|
37
|
-
const page = await browser.newPage();
|
|
38
|
-
await page.goto(argv[0]);
|
|
39
|
-
|
|
40
|
-
await playAudit({
|
|
41
|
-
page: page,
|
|
42
|
-
port: 9222,
|
|
43
|
-
...rc
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
await browser.close();
|
|
47
|
-
// return proc;
|
|
1
|
+
import { DigigovCommand } from "@digigov/cli/lib";
|
|
2
|
+
import { playAudit } from "playwright-lighthouse";
|
|
3
|
+
import playwright from "playwright-chromium";
|
|
4
|
+
import { resolveProject } from "@digigov/cli/lib";
|
|
5
|
+
import { createRequire } from "module";
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
const command = new DigigovCommand("metrics", import.meta.url);
|
|
10
|
+
|
|
11
|
+
command.argument("<url>", "URL to audit").action(getMetrics);
|
|
12
|
+
|
|
13
|
+
export default command;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} url - URL to audit
|
|
17
|
+
*/
|
|
18
|
+
async function getMetrics(url) {
|
|
19
|
+
const project = resolveProject();
|
|
20
|
+
|
|
21
|
+
let rc = require("../lighthouse.config.cjs");
|
|
22
|
+
try {
|
|
23
|
+
rc = require(`${project.root}/lighthouse.config.js`);
|
|
24
|
+
} catch (err) {
|
|
25
|
+
logger.error(err);
|
|
26
|
+
logger.warn(
|
|
27
|
+
`No lighthouse.config.js file is found. Fallback to sane defaults.`,
|
|
28
|
+
);
|
|
48
29
|
}
|
|
30
|
+
|
|
31
|
+
const browser = await playwright["chromium"].launch({
|
|
32
|
+
args: ["--remote-debugging-port=9222"],
|
|
33
|
+
});
|
|
34
|
+
const page = await browser.newPage();
|
|
35
|
+
await page.goto(url);
|
|
36
|
+
|
|
37
|
+
await playAudit({
|
|
38
|
+
page: page,
|
|
39
|
+
port: 9222,
|
|
40
|
+
...rc,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await browser.close();
|
|
49
44
|
}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const lib = require('@digigov/cli/lib');
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const lib = require("@digigov/cli/lib");
|
|
4
3
|
|
|
5
4
|
function makeLighthouseConfig(dir, options) {
|
|
6
5
|
const project = lib.resolveProject(dir);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
6
|
return {
|
|
11
7
|
thresholds: {
|
|
12
8
|
performance: 75,
|
|
13
9
|
accessibility: 75,
|
|
14
|
-
|
|
10
|
+
"best-practices": 75,
|
|
15
11
|
seo: 75,
|
|
16
12
|
pwa: 50,
|
|
17
13
|
},
|
|
@@ -19,7 +15,7 @@ function makeLighthouseConfig(dir, options) {
|
|
|
19
15
|
formats: {
|
|
20
16
|
html: true, //defaults to false
|
|
21
17
|
},
|
|
22
|
-
name:
|
|
18
|
+
name: `lighthouse-${new Date().getTime()}`, //defaults to `lighthouse-${new Date().getTime()}`
|
|
23
19
|
directory: `${project.root}/lighthouse`, //defaults to `${process.cwd()}/lighthouse`
|
|
24
20
|
},
|
|
25
21
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./lighthouse.common.cjs").config;
|
package/lighthouserc.cjs
ADDED
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/cli-metrics",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-298cfc51",
|
|
4
4
|
"description": "Docs plugin for Digigov CLI",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"author": "GRNET Devs <devs@lists.grnet.gr>",
|
|
7
8
|
"license": "BSD-2-Clause",
|
|
8
9
|
"dependencies": {
|
|
@@ -15,8 +16,13 @@
|
|
|
15
16
|
"publint": "0.1.8"
|
|
16
17
|
},
|
|
17
18
|
"peerDependencies": {
|
|
18
|
-
"
|
|
19
|
-
|
|
19
|
+
"@digigov/cli": "2.0.0-298cfc51"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./index.js",
|
|
23
|
+
"./lighthouse.common": "./lighthouse.common.cjs",
|
|
24
|
+
"./lighthouse.config": "./lighthouse.config.cjs",
|
|
25
|
+
"./lighthouserc": "./lighthouserc.cjs"
|
|
20
26
|
},
|
|
21
27
|
"scripts": {
|
|
22
28
|
"publint": "publint"
|
package/lighthouse.config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./lighthouse.common').config
|