Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#195) Update .nvmrc file with correct Node Version #215

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/push-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.11.0"
node-version: "20.15.0"
cache: "npm"
- name: Install X11 dependencies for robotjs (needed for unit testing on input-mask tests)
run: sudo apt-get install libxtst-dev libpng++-dev xvfb
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.11.0"
node-version: "20.15.0"
cache: "npm"
- name: Set up JDK 11 for x64
uses: actions/setup-java@v4
Expand All @@ -50,7 +50,7 @@ jobs:
- name: Install latest Chrome er.124 to match chromedriver package version
run: |
apt search '^google-chrome.*' \
&& wget -q -O /tmp/chrome.deb http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_126.0.6478.126-1_amd64.deb \
&& wget -q -O /tmp/chrome.deb http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_128.0.6613.119-1_amd64.deb \
&& sudo apt install -y /tmp/chrome.deb --allow-downgrades \
&& rm /tmp/chrome.deb
- name: Log system details
Expand Down
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
engine-strict=true
chromedriver_force_download=true
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.4.0
v20.15.0
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A place to learn and share with developers what makes web work accessible. This

- nvm: A Node version manager. It allows you to install several versions of node on the same machine and change versions easily.
- [Here are instructions in how to install nvm](https://github.com/nvm-sh/nvm#usage)
- After installing nvm, install a Node version >= 18 using nvm, ideally `nvm install 20.11.0`
- After installing nvm, install a Node version >= 20.15.0 using nvm, ideally `nvm install 20.15.0`
- npm: a Node Package Manager, usually installed alongside Node
- More info: [Downloading and installing Node.js and NPM](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
- Lynx: A text-only browser used for testing for how a website will work without graphics turned on.
Expand Down Expand Up @@ -74,6 +74,17 @@ A place to learn and share with developers what makes web work accessible. This
```sh
git clone [email protected]:PublicisSapient/enable-a11y.git
cd enable-a11y
```

```sh
nvm use
```

This instructs nvm to use the Node version specified in the `.nvmrc` file located in the project root directory.

> Note: If the specified version has not been installed yet, nvm will advise to install it after running the command above.

```sh
npm clean-install
```

Expand Down
53 changes: 53 additions & 0 deletions bin/validate-node-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env node

import chalk from 'chalk';
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';

async function getRunningVersion() {
const terminalCmd = 'node --version';

try {
return execSync(terminalCmd).toString().trim();
} catch (e) {
console.log(chalk.red(`Node version validation failed while running ${terminalCmd}`), e);
}
}

async function validateVersion() {
const directory = path.resolve();
let runningVersion;

try {
const filePath = path.resolve(directory, '.nvmrc');
const fileMetadata = await fs.promises.stat(filePath);
const fileContent = fs.readFileSync(filePath, "utf8");
let specVersion;

if (fileMetadata) {
specVersion = fileContent.startsWith("v") ? fileContent : `v${fileContent};`
runningVersion = (await getRunningVersion()).trim();

if (runningVersion.trim() !== specVersion.trim()) {
console.log(chalk.red(`Your Node version ${runningVersion} does not match the specified version ${specVersion} \rfound in the .nvmrc file in your project root`) );
console.log('\n-------------\n');
console.log(chalk.red('Run command "nvm use" followed by "npm ci" in your terminal before running "npm run start" again.\n'));
process.exit(1);
}
}


} catch (e) {
if (e.code !== "ENOENT") {
console.log(chalk.red('An unexpected error occurred while validating your Node version.\n'));
console.error(e);
process.exit(1);
}
console.log(chalk.red('Make sure the ".nvmrc" file from the Git repository is present in your project root directory\n'));
console.error(e);
process.exit(1);
}
}

validateVersion();
3 changes: 0 additions & 3 deletions js/test/combobox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ const testAutosuggestions = async (
// Assertions to test the autosuggestion options
expect(allContainSubstring).toBeTruthy();
expect(suggestions.length).toBe(expectedCount);
console.log(
`Suggestions after typing '${typeText}': ${suggestions.join(', ')}`,
);
};

describe("All combobox's Attributes Test", () => {
Expand Down
10 changes: 0 additions & 10 deletions js/test/horizontal-scroll.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ describe('Test Horizontal Scrolling on all pages on Enable', () => {
};
});

if (!domInfo.doesPageHorizontallyScroll) {
console.log(
`isWrapChecked: (${domInfo.isWrapChecked}), scrollWidth: ${domInfo.scrollWidth}, clientWidth: ${domInfo.clientWidth}.`,
);
}

expect(domInfo.doesPageHorizontallyScroll).toBe(false);
}

Expand Down Expand Up @@ -72,10 +66,6 @@ describe('Test Horizontal Scrolling on all pages on Enable', () => {
}
});

console.log(
`has checkbox: ${hasCheckbox}, filename: ${filename}, isDesktop: ${isDesktop}`,
);

if (hasCheckbox) {
// press space and check if it's unchecked.
await page.keyboard.press('Space');
Expand Down
113 changes: 57 additions & 56 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading