Skip to content

Commit

Permalink
chore(build): add script to stop exporting demos in built files (#10063)
Browse files Browse the repository at this point in the history
* chore(build): add script to stop exporting demos in built files

* chore(build): update to remove demo exports from shipped TS files also

* chore(ci): update deployment to clean exports of demos
  • Loading branch information
wise-king-sullyman authored Feb 2, 2024
1 parent ef5fc38 commit 07a7ec3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,22 +335,8 @@ jobs:
key: ${{ runner.os }}-yarn-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile
if: steps.yarn-cache.outputs.cache-hit != 'true'
- uses: actions/cache@v2
id: dist
name: Cache dist
with:
path: |
packages/*/dist
packages/*/next
packages/*/deprecated
packages/*/components
packages/react-styles/css
packages/react-core/layouts
packages/react-core/helpers
key: ${{ runner.os }}-dist-14-${{ secrets.CACHE_VERSION }}-${{ hashFiles('yarn.lock', 'package.json', 'packages/*/*', '!packages/*/dist', '!packages/*/node_modules') }}
- name: Build dist
run: yarn build && yarn build:umd
run: yarn build && yarn build:umd && yarn clean:exports
if: steps.dist.outputs.cache-hit != 'true'
- name: Deploy to NPM and Github
run: .github/release.sh

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"build:single:packages": "lerna run build:single:packages",
"clean": "yarn clean:build && lerna run clean --parallel",
"clean:build": "rimraf .cache .eslintcache coverage",
"clean:exports": "lerna run clean:exports --parallel --stream",
"generate": "yarn plop",
"lint": "node --max-old-space-size=4096 node_modules/.bin/eslint --ext js,jsx,ts,tsx --cache",
"lint:all": "yarn lint:md && yarn lint:versions && yarn lint:ts",
Expand Down
3 changes: 2 additions & 1 deletion packages/react-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"build:single:packages": "node ../../scripts/build-single-packages.js --config single-packages.config.json",
"clean": "rimraf dist components layouts helpers next deprecated node_modules",
"generate": "node scripts/copyStyles.js",
"subpaths": "node ../../scripts/exportSubpaths.js --config subpaths.config.json"
"subpaths": "node ../../scripts/exportSubpaths.js --config subpaths.config.json",
"clean:exports": "node scripts/cleanDistExports.js"
},
"dependencies": {
"@patternfly/react-icons": "^5.2.0-prerelease.10",
Expand Down
14 changes: 14 additions & 0 deletions packages/react-core/scripts/cleanDistExports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require('fs');
const path = require('path');

const distIndexFiles = ['esm', 'js'].map((dir) => path.join(process.cwd(), 'dist', dir, 'index.js'));
const distIndexDeclarationFiles = ['esm', 'js'].map((dir) => path.join(process.cwd(), 'dist', dir, 'index.d.ts'));

[...distIndexFiles, ...distIndexDeclarationFiles].forEach((file) => {
const fileContents = fs.readFileSync(file, 'utf8');
const newFileContents = fileContents
.split('\n')
.filter((line) => !line.includes('demos'))
.join('\n');
fs.writeFileSync(file, newFileContents);
});

0 comments on commit 07a7ec3

Please sign in to comment.