@code-pushup/axe-plugin 0.123.0 → 0.125.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/axe-plugin",
3
- "version": "0.123.0",
3
+ "version": "0.125.0",
4
4
  "license": "MIT",
5
5
  "description": "Code PushUp plugin for detecting accessibility issues using Axe 🌐",
6
6
  "homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-axe#readme",
@@ -42,8 +42,8 @@
42
42
  "type": "module",
43
43
  "dependencies": {
44
44
  "@axe-core/playwright": "^4.11.0",
45
- "@code-pushup/models": "0.123.0",
46
- "@code-pushup/utils": "0.123.0",
45
+ "@code-pushup/models": "0.125.0",
46
+ "@code-pushup/utils": "0.125.0",
47
47
  "axe-core": "^4.11.0",
48
48
  "playwright-core": "^1.56.1",
49
49
  "zod": "^4.2.1"
package/src/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export type { AxePluginOptions, AxePreset } from './lib/config.js';
4
4
  export type { AxeGroupSlug } from './lib/groups.js';
5
5
  export { axeAuditRef, axeAuditRefs, axeGroupRef, axeGroupRefs, } from './lib/utils.js';
6
6
  export { axeCategories } from './lib/categories.js';
7
+ export { axeSetupBinding } from './lib/binding.js';
package/src/index.js CHANGED
@@ -2,4 +2,5 @@ import { axePlugin } from './lib/axe-plugin.js';
2
2
  export default axePlugin;
3
3
  export { axeAuditRef, axeAuditRefs, axeGroupRef, axeGroupRefs, } from './lib/utils.js';
4
4
  export { axeCategories } from './lib/categories.js';
5
+ export { axeSetupBinding } from './lib/binding.js';
5
6
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,eAAe,SAAS,CAAC;AAKzB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,eAAe,SAAS,CAAC;AAKzB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { CategoryCodegenConfig, PluginAnswer, PluginSetupTree } from '@code-pushup/models';
2
+ export declare const axeSetupBinding: {
3
+ slug: string;
4
+ title: string;
5
+ packageName: string;
6
+ prompts: () => Promise<({
7
+ key: string;
8
+ message: string;
9
+ type: "input";
10
+ default: string;
11
+ choices?: undefined;
12
+ } | {
13
+ key: string;
14
+ message: string;
15
+ type: "select";
16
+ choices: {
17
+ name: string;
18
+ value: string;
19
+ }[];
20
+ default: string;
21
+ } | {
22
+ key: string;
23
+ message: string;
24
+ type: "confirm";
25
+ default: false;
26
+ choices?: undefined;
27
+ } | {
28
+ key: string;
29
+ message: string;
30
+ type: "confirm";
31
+ default: true;
32
+ choices?: undefined;
33
+ })[]>;
34
+ generateConfig: (answers: Record<string, PluginAnswer>, tree: PluginSetupTree) => Promise<{
35
+ imports: {
36
+ namedImports?: string[] | undefined;
37
+ moduleSpecifier: string;
38
+ defaultImport: string;
39
+ }[];
40
+ pluginInit: string[];
41
+ pluginDeclaration?: undefined;
42
+ categories?: undefined;
43
+ } | {
44
+ imports: {
45
+ namedImports?: string[] | undefined;
46
+ moduleSpecifier: string;
47
+ defaultImport: string;
48
+ }[];
49
+ pluginDeclaration: {
50
+ identifier: string;
51
+ expression: string;
52
+ };
53
+ pluginInit: string[];
54
+ categories: CategoryCodegenConfig[];
55
+ }>;
56
+ };
@@ -0,0 +1,110 @@
1
+ import { createRequire } from 'node:module';
2
+ import { answerBoolean, answerNonEmptyArray, answerString, singleQuote, } from '@code-pushup/utils';
3
+ import { AXE_DEFAULT_PRESET, AXE_PLUGIN_SLUG, AXE_PLUGIN_TITLE, AXE_PRESET_NAMES, } from './constants.js';
4
+ const { name: PACKAGE_NAME } = createRequire(import.meta.url)('../../package.json');
5
+ const DEFAULT_URL = 'http://localhost:4200';
6
+ const PLUGIN_VAR = 'axe';
7
+ const SETUP_SCRIPT_PATH = './axe-setup.ts';
8
+ const CATEGORIES = [
9
+ {
10
+ slug: 'a11y',
11
+ title: 'Accessibility',
12
+ description: 'Tests website **accessibility** in accordance with WCAG',
13
+ refsExpression: `axeGroupRefs(${PLUGIN_VAR})`,
14
+ },
15
+ ];
16
+ const PRESET_CHOICES = Object.entries(AXE_PRESET_NAMES).map(([value, name]) => ({ name, value }));
17
+ const SETUP_SCRIPT_CONTENT = `import type { Page } from 'playwright-core';
18
+
19
+ export default async function (page: Page): Promise<void> {
20
+ // ... add your custom logic here ...
21
+ }
22
+ `;
23
+ export const axeSetupBinding = {
24
+ slug: AXE_PLUGIN_SLUG,
25
+ title: AXE_PLUGIN_TITLE,
26
+ packageName: PACKAGE_NAME,
27
+ prompts: async () => [
28
+ {
29
+ key: 'axe.urls',
30
+ message: 'Target URL(s) (comma-separated)',
31
+ type: 'input',
32
+ default: DEFAULT_URL,
33
+ },
34
+ {
35
+ key: 'axe.preset',
36
+ message: 'Accessibility preset',
37
+ type: 'select',
38
+ choices: [...PRESET_CHOICES],
39
+ default: AXE_DEFAULT_PRESET,
40
+ },
41
+ {
42
+ key: 'axe.setupScript',
43
+ message: 'Create setup script for auth-protected app?',
44
+ type: 'confirm',
45
+ default: false,
46
+ },
47
+ {
48
+ key: 'axe.categories',
49
+ message: 'Add Axe categories?',
50
+ type: 'confirm',
51
+ default: true,
52
+ },
53
+ ],
54
+ generateConfig: async (answers, tree) => {
55
+ const options = parseAnswers(answers);
56
+ if (options.setupScript) {
57
+ await tree.write(SETUP_SCRIPT_PATH, SETUP_SCRIPT_CONTENT);
58
+ }
59
+ const hasCategories = options.categories;
60
+ const imports = [
61
+ {
62
+ moduleSpecifier: PACKAGE_NAME,
63
+ defaultImport: 'axePlugin',
64
+ ...(hasCategories ? { namedImports: ['axeGroupRefs'] } : {}),
65
+ },
66
+ ];
67
+ const pluginCall = formatPluginCall(options);
68
+ if (!hasCategories) {
69
+ return {
70
+ imports,
71
+ pluginInit: [`${pluginCall},`],
72
+ };
73
+ }
74
+ return {
75
+ imports,
76
+ pluginDeclaration: {
77
+ identifier: PLUGIN_VAR,
78
+ expression: pluginCall,
79
+ },
80
+ pluginInit: [`${PLUGIN_VAR},`],
81
+ categories: CATEGORIES,
82
+ };
83
+ },
84
+ };
85
+ function parseAnswers(answers) {
86
+ return {
87
+ urls: answerNonEmptyArray(answers, 'axe.urls', DEFAULT_URL),
88
+ preset: answerString(answers, 'axe.preset') || AXE_DEFAULT_PRESET,
89
+ setupScript: answerBoolean(answers, 'axe.setupScript'),
90
+ categories: answerBoolean(answers, 'axe.categories'),
91
+ };
92
+ }
93
+ function formatPluginCall({ urls, preset, setupScript }) {
94
+ const formattedUrls = formatUrls(urls);
95
+ const options = [
96
+ preset !== AXE_DEFAULT_PRESET && `preset: ${singleQuote(preset)}`,
97
+ setupScript && `setupScript: ${singleQuote(SETUP_SCRIPT_PATH)}`,
98
+ ].filter(Boolean);
99
+ if (options.length === 0) {
100
+ return `axePlugin(${formattedUrls})`;
101
+ }
102
+ return `axePlugin(${formattedUrls}, { ${options.join(', ')} })`;
103
+ }
104
+ function formatUrls([first, ...rest]) {
105
+ if (rest.length === 0) {
106
+ return singleQuote(first);
107
+ }
108
+ return `[${[first, ...rest].map(singleQuote).join(', ')}]`;
109
+ }
110
+ //# sourceMappingURL=binding.js.map
@@ -0,0 +1 @@
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