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

chore(build): add script to stop exporting demos in built files #10063

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
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.9",
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);
});
Loading