From 39ec58f7d272277f295cb3196a7839b5e518ed9f Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Sat, 3 Aug 2024 16:58:04 +0200 Subject: [PATCH] Convert scripts to ES modules Signed-off-by: Jon Koops --- .github/{split.js => split.mjs} | 6 +++--- .github/{upload-preview.js => upload-preview.mjs} | 7 ++++--- .github/workflows/documentation.yml | 4 ++-- .github/workflows/main.yml | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) rename .github/{split.js => split.mjs} (65%) rename .github/{upload-preview.js => upload-preview.mjs} (95%) diff --git a/.github/split.js b/.github/split.mjs similarity index 65% rename from .github/split.js rename to .github/split.mjs index 40ed8a0bd66..46e12072955 100644 --- a/.github/split.js +++ b/.github/split.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-console */ -const fs = require('fs'); -const path = require('path'); +import fs from 'node:fs'; +import path from 'node:path'; -const BASE_DIR = path.join(__dirname, '../packages/react-integration/cypress/integration'); +const BASE_DIR = path.resolve(import.meta.dirname, '../packages/react-integration/cypress/integration'); const WORKER_NUM = +process.env.WORKER_NUM; const WORKER_COUNT = +process.env.WORKER_COUNT; diff --git a/.github/upload-preview.js b/.github/upload-preview.mjs similarity index 95% rename from .github/upload-preview.js rename to .github/upload-preview.mjs index bf24050b859..056f705cf1c 100644 --- a/.github/upload-preview.js +++ b/.github/upload-preview.mjs @@ -1,8 +1,9 @@ /* eslint-disable no-console, camelcase */ -const path = require('path'); -const { Octokit } = require('@octokit/rest'); +import { Octokit } from '@octokit/rest'; +import path from 'node:path'; +import surge from 'surge'; + const octokit = new Octokit({ auth: process.env.GH_PR_TOKEN }); -const surge = require('surge'); const publishFn = surge().publish(); // From github actions diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index c013ccb662f..ba9dbe11555 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -39,11 +39,11 @@ jobs: - name: Upload documentation if: always() - run: node .github/upload-preview.js packages/react-docs/public + run: node .github/upload-preview.mjs packages/react-docs/public - name: Run accessibility tests run: yarn serve:docs & yarn test:a11y - name: Upload accessibility results if: always() - run: node .github/upload-preview.js packages/react-docs/coverage + run: node .github/upload-preview.mjs packages/react-docs/coverage diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 64ccb220488..f0e9552023e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -93,7 +93,7 @@ jobs: run: printenv - name: Run Cypress tests - run: yarn serve:integration & yarn test:integration -s $(node .github/split.js) + run: yarn serve:integration & yarn test:integration -s $(node .github/split.mjs) env: WORKER_NUM: ${{ matrix.worker }} WORKER_COUNT: 5