Skip to content

Commit 96eec98

Browse files
committed
fix bug and add run utils
0 parents  commit 96eec98

File tree

10 files changed

+1985
-0
lines changed

10 files changed

+1985
-0
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
39+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.
21+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
* **Please check if the PR fulfills these requirements**
2+
- [ ] The commit message follows our guidelines
3+
- [ ] Tests for the changes have been added (for bug fixes / features)
4+
- [ ] Docs have been added / updated (for bug fixes / features)
5+
6+
7+
* **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)
8+
9+
10+
11+
* **What is the current behavior?** (You can also link to an open issue here)
12+
13+
14+
15+
* **What is the new behavior (if this is a feature change)?**
16+
17+
18+
19+
* **Does this PR introduce a breaking change?** (What changes might users need to make in their application due to this PR?)
20+
21+
22+
23+
* **Other information**:
24+

.gitignore

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# Snowpack dependency directory (https://snowpack.dev/)
45+
web_modules/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
dist
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and not Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# Serverless directories
95+
.serverless/
96+
97+
# FuseBox cache
98+
.fusebox/
99+
100+
# DynamoDB Local files
101+
.dynamodb/
102+
103+
# TernJS port file
104+
.tern-port
105+
106+
# Stores VSCode versions used for testing VSCode extensions
107+
.vscode-test

CODE_OF_CONDUCT.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/
47+

CONTRIBUTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Contributing
2+
3+
First fork this project.
4+
5+
* git clone <your-forked-repo>
6+
* npm install
7+
8+
* git checkout -b my-fix
9+
10+
#### fix some code...
11+
12+
* git commit -m "added this feature"
13+
* git push origin my-fix
14+
15+
Lastly, open a pull request on Github.

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Notes
2+
3+
may need the project to locally install `axe-core`, the resolution is
4+
[a little weird](https://github.com/dequelabs/axe-cli/blob/819eaf299affdcb9e8e9ec76b843e231778612c1/lib/utils.js)
5+
6+
this may be a duplicate of https://github.com/netlify/build/pull/294
7+
8+
# netlify-plugin-fetch-feeds
9+
10+
Run axe-cli and fail build if accessibility failures are found.
11+
12+
13+
> NOTICE: This is an experimental feature. Subject to lots of change.
14+
15+
16+
## Overview
17+
18+
Run axe-cli and fail build if accessibility failures are found.
19+
20+
## Demonstration
21+
22+
See this plugin being used in this simplified demo site:
23+
24+
## Usage
25+
26+
### Prerequisites
27+
28+
- npm and node
29+
- @Netlify/build (later this will be included in the Netlify CLI)
30+
- A free [Netlify account](https://netlify.com)
31+
- Opt-in to Netlify Build Plugin feature support (Not yet publicly available, sorry)
32+
33+
34+
### Including this plugin in a project
35+
36+
This plugin can be included via npm. Install it as a dependency for your project like so:
37+
38+
```
39+
npm install --save netlify-plugin-axe
40+
```
41+
42+
### Configuration
43+
44+
This plugin will fetch the specified feeds and stash their data prior to the execution of the `build` command you have specified in your Netlify configuration. The desired feeds can be specified in the `netlify.toml` config file. For simpler configuration syntax, I recommend using yaml rather than toml by instead including a `netlify.yml` file.
45+
46+
To use plugins, a `plugins` array should be specified in your `netlify.yml`. Each plugin can then be specified with its parameters like so:
47+
48+
```yaml
49+
plugins:
50+
- netlify-plugin-axe:
51+
# type: ./path-to-plugin-file | npm-module-name
52+
type: netlify-plugin-fetch-feeds
53+
config:
54+
site: mycoolsite.netlify.com # your Netlify site url
55+
# https://github.com/dequelabs/axe-cli#running-specific-rules
56+
axeFlags: --tags wcag2a
57+
```
58+
59+
60+
### Execution in Netlify
61+
62+
Once installed and configured, the plugin will automatically run in the Netlify CI during its specified Netlify Build lifecycle event.
63+
64+
### Executing locally
65+
66+
To test the execution of the Netlify Build lifecycle locally, first ensure that netlify-build is installed:
67+
68+
```bash
69+
# Ensure that you have the netlify build command available
70+
# (in future this will be provided via the CLI)
71+
npm install @netlify/build -g
72+
73+
# In the project working directory, run the build as netlify would with the build bot
74+
netlify-build
75+
```

index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const {
2+
cwd,
3+
env: { SITE }
4+
} = require('process');
5+
6+
const execa = require('execa');
7+
const makeDir = require('make-dir');
8+
9+
function netlifyPlugin(conf) {
10+
return {
11+
name: 'netlify-plugin-axe',
12+
async onPostBuild({
13+
pluginConfig: { site, axeFlags },
14+
constants: { CACHE_DIR },
15+
utils: { run }
16+
}) {
17+
const resultsDir = `${CACHE_DIR}/axe-results`;
18+
await makeDir(resultsDir);
19+
20+
const resultsPath = `${resultsDir}/result.json`
21+
.replace(cwd(), '')
22+
.replace(/^\//, '');
23+
24+
await run.command(
25+
`./node_modules/.bin/axe ${site} ${axeFlags} --save ${resultsPath}`
26+
);
27+
28+
let results = require(resultsPath);
29+
if (results && results[0]) {
30+
results = results[0].violations;
31+
}
32+
console.log({ violations: results, len: results.length });
33+
}
34+
};
35+
}
36+
37+
module.exports = netlifyPlugin;

0 commit comments

Comments
 (0)