Skip to content

Commit

Permalink
feat: update to node 18 (#993)
Browse files Browse the repository at this point in the history
Update the CLI to make it compatible with Node 18
  • Loading branch information
louis-bompart authored Nov 7, 2022
1 parent cf45e29 commit 335a026
Show file tree
Hide file tree
Showing 27 changed files with 107 additions and 72 deletions.
1 change: 0 additions & 1 deletion .github/actions/e2e-clean/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ runs:
steps:
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: 16
cache: 'npm'
- run: npm ci
shell: bash
Expand Down
1 change: 0 additions & 1 deletion .github/actions/e2e-run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ runs:
git config --global core.eol lf
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: ${{inputs.node}}
cache: 'npm'
- uses: actions/setup-python@b55428b1882923874294fa556849718a1d7f2ca5 # tag=v4
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ jobs:
# pulls all commits (needed for finding the @coveo/cli version to release)
fetch-depth: 0
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: '16'
- name: Setup
run: npm i
- name: Get tags
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ jobs:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: 16
cache: 'npm'

- name: Setup repo
run: npm ci
- name: Check linting
Expand All @@ -48,7 +46,6 @@ jobs:
fail-fast: true
matrix:
os: ['ubuntu-latest', 'windows-latest']
node: [16]
steps:
- name: Setup runner
if: ${{matrix.os == 'ubuntu-latest'}}
Expand All @@ -62,7 +59,6 @@ jobs:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: ${{matrix.node}}
cache: 'npm'
- name: Setup repo
run: npm ci
Expand All @@ -83,7 +79,6 @@ jobs:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: ${{matrix.node}}
cache: 'npm'
- uses: ./.github/actions/e2e-login
id: setup
Expand All @@ -105,7 +100,6 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: ${{matrix.node}}
cache: 'npm'
- uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 # tag=v3
if: ${{matrix.os == 'ubuntu-latest'}}
Expand Down Expand Up @@ -135,7 +129,6 @@ jobs:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest']
node: [16]
spec:
[
'angular.specs.ts',
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/daily-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ jobs:
run: git checkout $(git describe --abbrev=0 --tags)
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: ${{matrix.node}}
cache: 'npm'

- name: Install Coveo CLI
run: npm i -g @coveo/cli@latest
- uses: ./.github/actions/e2e-login
Expand All @@ -56,7 +54,7 @@ jobs:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest']
node: [16]
node: [18]
spec:
[
'angular.specs.ts',
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/delete-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: '16'
cache: 'npm'
- run: npm ci
- name: Resume org
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/prbot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@ jobs:
with:
fetch-depth: 0
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: '16'
- run: npm i
- run: npm run pr:report
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: '16'
- name: Install dependencies
run: |
npm ci
Expand Down Expand Up @@ -56,7 +54,6 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
43 changes: 30 additions & 13 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"**/*.ts": "eslint --fix"
},
"engines": {
"node": ">=16",
"node": ">=18",
"npm": ">=8.5.4"
},
"engineStrict": true,
Expand Down
1 change: 1 addition & 0 deletions packages/cli-e2e/__tests__/auth.specs.ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('auth', () => {
port: 9222,
userDataDir: false,
maxConnectionRetries: 240, //equivalent to 2 minutes with the default pollrate of 500ms
logLevel: 'verbose',
});

browser = await connectToChromeBrowser();
Expand Down
12 changes: 12 additions & 0 deletions packages/cli-e2e/__tests__/orgList.specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ describe('org:list', () => {
const proxyProcessManager = new ProcessManager();
processManagers.push(proxyProcessManager);
proxyTerminal = startMitmProxy(proxyProcessManager);
await Promise.race([
proxyTerminal
.when(/listening/)
.on('stdout')
.do()
.once(),
proxyTerminal
.when(/listening/)
.on('stderr')
.do()
.once(),
]);
await waitForMitmProxy();
}, 2 * 60e3);

Expand Down
7 changes: 5 additions & 2 deletions packages/cli-e2e/__tests__/orgResources.specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {getTestOrg} from '../utils/testOrgSetup';
import {readdirSync} from 'fs';
import {cwd} from 'process';
import {EOL} from 'os';
import retry from 'async-retry';
config({path: getEnvFilePath()});

describe('org:resources', () => {
Expand Down Expand Up @@ -210,8 +211,10 @@ describe('org:resources', () => {
const getResourceFolderContent = (projectPath: string) =>
readdirSync(join(projectPath, 'resources'));

beforeEach(() => {
rmSync(destinationPath, {recursive: true, force: true});
beforeEach(async () => {
await retry(() => {
rmSync(destinationPath, {recursive: true, force: true});
});
ensureDirSync(destinationPath);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/cli-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"url": "https://github.com/coveo/cli/issues"
},
"engines": {
"node": ">=14.16.1"
"node": ">=18"
},
"devDependencies": {
"@actions/core": "1.9.1",
Expand Down
19 changes: 14 additions & 5 deletions packages/cli-e2e/utils/browser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import axios from 'axios';
import {resolve} from 'path';

import {resolve} from 'node:path';
import {Agent as HttpAgent} from 'node:http';
import {promises as dnsPromises} from 'node:dns';
import {URL} from 'node:url';
import puppeteer from 'puppeteer';
import type {Browser, Page} from 'puppeteer';
const CHROME_JSON_DEBUG_URL = 'http://localhost:9222/json/version';
Expand Down Expand Up @@ -32,9 +34,13 @@ export async function closeAllPages(browser: Browser) {

async function getWsUrl(): Promise<string> {
const chromeDebugInfoRaw = (
await axios.get<JsonVersionFile>(CHROME_JSON_DEBUG_URL)
await axios.get<JsonVersionFile>(CHROME_JSON_DEBUG_URL, {
httpAgent: new HttpAgent({family: 4}),
})
).data;
return chromeDebugInfoRaw.webSocketDebuggerUrl;
const wsUrl = new URL(chromeDebugInfoRaw.webSocketDebuggerUrl);
wsUrl.hostname = (await dnsPromises.resolve4(wsUrl.hostname))[0];
return wsUrl.toString();
}

function getChromeDefaultOptions() {
Expand All @@ -45,7 +51,10 @@ function getChromeDefaultOptions() {
*/
export async function connectToChromeBrowser(): Promise<Browser> {
const wsURL = await getWsUrl();
return puppeteer.connect({browserWSEndpoint: wsURL});
console.error('WS_URL:' + wsURL);
return puppeteer.connect({
browserWSEndpoint: wsURL,
});
}

export async function getNewBrowser(): Promise<Browser> {
Expand Down
11 changes: 10 additions & 1 deletion packages/cli-e2e/utils/mitmproxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ export const startMitmProxy = (
const mitmScript = join(__dirname, '..', 'mitmproxy', 'main.py');
const serverTerminal = new Terminal(
'python',
[mitmScript, '-p', '8080'],
[
'-u',
mitmScript,
'-p',
'8080',
'--listen-host',
'localhost',
'--flow-detail',
'1',
],
undefined,
processManager,
terminalDebugName
Expand Down
1 change: 0 additions & 1 deletion packages/cli-e2e/verdaccio/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ logs:

listen:
- localhost:4873 # default value
- '[::1]:4873' # ipv6
Loading

0 comments on commit 335a026

Please sign in to comment.