Skip to content

Commit 022de2a

Browse files
committed
Convert scripts to ES modules
Signed-off-by: Jon Koops <jonkoops@gmail.com>
1 parent 2e6837e commit 022de2a

35 files changed

Lines changed: 111 additions & 147 deletions

.github/split.js renamed to .github/split.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable no-console */
2-
const fs = require('fs');
3-
const path = require('path');
2+
import fs from 'node:fs';
3+
import path from 'node:path';
44

5-
const BASE_DIR = path.join(__dirname, '../packages/react-integration/cypress/integration');
5+
const BASE_DIR = path.resolve(import.meta.dirname, '../packages/react-integration/cypress/integration');
66
const WORKER_NUM = +process.env.WORKER_NUM;
77
const WORKER_COUNT = +process.env.WORKER_COUNT;
88

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* eslint-disable no-console, camelcase */
2-
const path = require('path');
3-
const { Octokit } = require('@octokit/rest');
2+
import { Octokit } from '@octokit/rest';
3+
import path from 'node:path';
4+
import surge from 'surge';
5+
46
const octokit = new Octokit({ auth: process.env.GH_PR_TOKEN });
5-
const surge = require('surge');
67
const publishFn = surge().publish();
78

89
// From github actions

.github/workflows/documentation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939

4040
- name: Upload documentation
4141
if: always()
42-
run: node .github/upload-preview.js packages/react-docs/public
42+
run: node .github/upload-preview.mjs packages/react-docs/public
4343

4444
- name: Run accessibility tests
4545
run: yarn serve:docs & yarn test:a11y
4646

4747
- name: Upload accessibility results
4848
if: always()
49-
run: node .github/upload-preview.js packages/react-docs/coverage
49+
run: node .github/upload-preview.mjs packages/react-docs/coverage

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
run: printenv
9494

9595
- name: Run Cypress tests
96-
run: yarn serve:integration & yarn test:integration -s $(node .github/split.js)
96+
run: yarn serve:integration & yarn test:integration -s $(node .github/split.mjs)
9797
env:
9898
WORKER_NUM: ${{ matrix.worker }}
9999
WORKER_COUNT: 5

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
"build:single:packages": "lerna run build:single:packages",
9191
"clean": "yarn clean:build && lerna run clean --parallel",
9292
"clean:build": "rimraf .cache .eslintcache coverage",
93-
"clean:exports": "lerna run clean:exports --parallel --stream",
9493
"generate": "yarn plop",
9594
"lint": "eslint . --cache --cache-strategy content",
9695
"lint:all": "yarn lint:md && yarn lint:ts",

packages/react-charts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
},
5959
"scripts": {
6060
"clean": "rimraf dist",
61-
"build:single:packages": "node ../../scripts/build-single-packages.js --config single-packages.config.json"
61+
"build:single:packages": "node ../../scripts/build-single-packages.mjs --config single-packages.config.json"
6262
},
6363
"devDependencies": {
6464
"@types/lodash": "^4.17.5",

packages/react-core/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@
4040
"homepage": "https://github.com/patternfly/patternfly-react#readme",
4141
"scripts": {
4242
"build:umd": "rollup -c --environment IS_PRODUCTION",
43-
"build:single:packages": "node ../../scripts/build-single-packages.js --config single-packages.config.json",
43+
"build:single:packages": "node ../../scripts/build-single-packages.mjs --config single-packages.config.json",
4444
"clean": "rimraf dist components layouts helpers next deprecated",
45-
"generate": "node scripts/copyStyles.js",
46-
"subpaths": "node ../../scripts/exportSubpaths.js --config subpaths.config.json",
47-
"clean:exports": "node scripts/cleanDistExports.js"
45+
"generate": "node scripts/copyStyles.mjs",
46+
"subpaths": "node ../../scripts/exportSubpaths.mjs --config subpaths.config.json"
4847
},
4948
"dependencies": {
5049
"@patternfly/react-icons": "workspace:^",

packages/react-core/scripts/cleanDistExports.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/react-core/scripts/copyStyles.js renamed to packages/react-core/scripts/copyStyles.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
const { copySync, readFileSync, writeFileSync } = require('fs-extra');
2-
const { resolve, dirname, join } = require('path');
3-
const { parse: parseCSS, stringify: stringifyCSS } = require('css');
1+
import { copySync } from 'fs-extra/esm';
2+
import { readFileSync, writeFileSync } from 'node:fs';
3+
import { createRequire } from 'node:module';
4+
import { resolve, dirname, join } from 'node:path';
5+
import { parse as parseCSS, stringify as stringifyCSS } from 'css';
46

5-
const stylesDir = resolve(__dirname, '../dist/styles');
7+
const require = createRequire(import.meta.url);
8+
const stylesDir = resolve(import.meta.dirname, '../dist/styles');
69
const pfDir = dirname(require.resolve('@patternfly/patternfly/patternfly.css'));
710

811
const unusedSelectorRegEx = /(\.fas?|\.sr-only)/;

packages/react-core/src/helpers/safeHTMLElement.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)