Skip to content
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- packages/patternfly-4/react-charts/node_modules
- packages/patternfly-4/react-styles/node_modules
- packages/patternfly-3/patternfly-react/node_modules
- .cache # Incremental builds
key: v{{ .Environment.CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
- run:
name: Build Dist
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ cache:
- packages/patternfly-4/react-tokens/dist
- packages/patternfly-4/react-inline-edit-extension/dist
- packages/patternfly-4/react-docs/public # To cache PF4 docs
- .cache # For incremental builds
git:
depth: 10
branches:
Expand Down
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@
},
"scripts": {
"bootstrap": "lerna bootstrap",
"build": "lerna run build --stream",
"build": "node scripts/incrementalBuild.js",
"build:pf3": "yarn build pf3",
"build:pf4": "yarn build pf4",
"build:docs": "lerna run build:docs --stream",
"build:storybook": "build-storybook -c storybook -o .out",
"clean": "lerna run clean --parallel",
"clean": "yarn clean:build && lerna run clean --parallel",
"clean:build": "shx rm -rf .cache",
"commit": "git-cz",
"generate": "yarn plop",
"lint": "lerna run lint --parallel",
Expand All @@ -106,7 +109,7 @@
"prettier": "prettier --write 'storybook/**/*.js' 'packages/**/*.js' 'scripts/**/*.js'",
"start": "yarn start:pf3",
"start:pf3": "concurrently 'yarn storybook' 'yarn storybook:openurl'",
"start:pf4": "lerna run develop --scope='@patternfly/react-docs' --scope='@patternfly/react-core' --parallel --stream",
"start:pf4": "yarn build:pf4 && lerna run develop --parallel --stream",
"storybook:openurl": "node ./storybook/openBrowser.js",
"storybook": "start-storybook -c storybook -p 6006",
"test": "jest packages",
Expand All @@ -127,5 +130,8 @@
"packages": [
"packages/**"
]
},
"dependencies": {
"folder-hash": "^3.0.0"
}
}
}
3 changes: 2 additions & 1 deletion packages/patternfly-4/react-charts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"build:babel": "concurrently 'yarn build:babel:cjs' 'yarn build:babel:esm'",
"build:babel:cjs": "cross-env BABEL_ENV=production:cjs babel src --out-dir dist/js",
"build:babel:esm": "cross-env BABEL_ENV=production:esm babel src --out-dir dist/esm",
"clean": "rimraf dist"
"clean": "rimraf dist",
"develop": "yarn build:babel:esm --skip-initial-build --watch --verbose"
},
"optionalDependencies": {
"@types/victory": "^0.9.19",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"build:babel:cjs": "cross-env BABEL_ENV=production:cjs babel src --out-dir dist/js",
"build:babel:esm": "cross-env BABEL_ENV=production:esm babel src --out-dir dist/esm",
"build:ts": "node ./scripts/copyTS.js",
"develop": "yarn build:babel:esm --skip-initial-build --watch --verbose",
"postbuild": "node ./build/copyStyles.js"
},
"optionalDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/patternfly-4/react-styled-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"build:babel": "concurrently 'yarn build:babel:cjs' 'yarn build:babel:esm'",
"build:babel:cjs": "cross-env BABEL_ENV=production:cjs babel src --out-dir dist/js",
"build:babel:esm": "cross-env BABEL_ENV=production:esm babel src --out-dir dist/esm",
"clean": "rimraf dist"
"clean": "rimraf dist",
"develop": "yarn build:babel:esm --skip-initial-build --watch --verbose"
},
"dependencies": {
"@patternfly/react-styles": "^3.0.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/patternfly-4/react-styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"build:babel:cjs": "cross-env BABEL_ENV=production:cjs babel src --out-dir dist/js",
"build:babel:esm": "cross-env BABEL_ENV=production:esm babel src --out-dir dist/esm",
"build:babel:umd": "cross-env BABEL_ENV=production:umd babel dist/esm --out-dir dist/umd --plugins transform-es2015-modules-umd",
"clean": "rimraf dist"
"clean": "rimraf dist",
"develop": "yarn build:babel:esm --skip-initial-build --watch --verbose"
},
"dependencies": {
"@babel/helper-plugin-utils": "^7.0.0-beta.48",
Expand Down
3 changes: 2 additions & 1 deletion packages/patternfly-4/react-table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"build:babel": "concurrently 'yarn build:babel:cjs' 'yarn build:babel:esm'",
"build:babel:cjs": "cross-env BABEL_ENV=production:cjs babel src --out-dir dist/js",
"build:babel:esm": "cross-env BABEL_ENV=production:esm babel src --out-dir dist/esm",
"clean": "rimraf dist"
"clean": "rimraf dist",
"develop": "yarn build:babel:esm --skip-initial-build --watch --verbose"
},
"devDependencies": {
"@patternfly/react-tokens": "^2.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/patternfly-4/react-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"homepage": "https://github.com/patternfly/patternfly-react#readme",
"scripts": {
"build": "node build/generateTokens.js && yarn build:babel:umd",
"build": "node src/generateTokens.js && yarn build:babel:umd",
"build:babel:umd": "cross-env BABEL_ENV=production:umd babel dist/esm --out-dir dist/umd --plugins transform-es2015-modules-umd",
"clean": "rimraf dist"
},
Expand Down
72 changes: 72 additions & 0 deletions scripts/incrementalBuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const fs = require('fs');
const { hashElement } = require("folder-hash");
const Project = require('@lerna/project');
const RunCommand = require('@lerna/run')

// Load cache
const cacheFile = '.cache/incrementalCache'
let cache = {}
if (fs.existsSync(cacheFile)) {
cache = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
}

// Package filtering
const isPf3 = process.argv.length > 2 && process.argv[2] === 'pf3';
const isPf4 = process.argv.length > 2 && process.argv[2] === 'pf4';

const commonPackages = [
'@patternfly/react-icons'
];
// Assume src directory gets made into dist
const getDir = (packageName) => {
switch(packageName) {
case '@patternfly/react-icons':
return 'build'
default:
return 'src'
}
};

// These are packages we need to rebuild
async function getInvalidPackages() {
const packages = (await new Project(__dirname).getPackages())
.filter(p => p.scripts.build) // Only packages that have a build target
.filter(p => isPf3
? p.location.indexOf('patternfly-3') !== -1 || commonPackages.indexOf(p.name) !== -1
: true) // Based off argv
.filter(p => isPf4
? p.location.indexOf('patternfly-4') !== -1 || commonPackages.indexOf(p.name) !== -1
: true) // Based off argv

for (let p of packages) {
const watchDir = getDir(p.name);
p.hash = (await hashElement(`${p.location}/${watchDir}`)).hash;
p.valid = cache && cache[p.name] === p.hash;
if (p.valid) {
console.info('Skipping', p.name, '(already built).');
}
}

return packages.filter(p => !p.valid);
}

async function incrementalBuild() {
const packages = await getInvalidPackages();

if (packages.length > 0) {
// Run for all invalid packages
await RunCommand({
cwd: '.',
script: 'build',
npmClient: 'yarn',
scope: packages.map(p => p.name)});
// Mark as valid
packages.forEach(p => cache[p.name] = p.hash);
if (!fs.existsSync('.cache')) {
fs.mkdirSync('.cache');
}
fs.writeFileSync(cacheFile, JSON.stringify(cache, null, 4));
}
}

incrementalBuild().then();
15 changes: 12 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7832,7 +7832,7 @@ eslint-plugin-node@^6.0.1:
semver "^5.4.1"

"eslint-plugin-patternfly-react@file:packages/eslint-plugin-patternfly-react":
version "0.2.2"
version "0.2.3"
dependencies:
babel-eslint "^9.0.0"
eslint-config-airbnb "^16.1.0"
Expand Down Expand Up @@ -8784,6 +8784,15 @@ focus-trap@^3.0.0:
tabbable "^3.1.0"
xtend "^4.0.1"

folder-hash@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/folder-hash/-/folder-hash-3.0.0.tgz#ba9489e74044f63a943d74a3be5e10eb0d03b0ab"
integrity sha512-wyAJJO+h09XC7ZUM47RZIefAZlpTmdxidp98aoSd/BapfjFIx3Z7bJOO3cPy/WNep5WtX7vjBJhdTPKhFfRKMQ==
dependencies:
debug "^4.1.1"
graceful-fs "~4.1.11"
minimatch "~3.0.4"

follow-redirects@^1.0.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.7.0.tgz#489ebc198dc0e7f64167bd23b03c4c19b5784c76"
Expand Down Expand Up @@ -9668,7 +9677,7 @@ got@^8.3.2:
url-parse-lax "^3.0.0"
url-to-options "^1.0.1"

graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6:
graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6, graceful-fs@~4.1.11:
version "4.1.15"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"

Expand Down Expand Up @@ -13128,7 +13137,7 @@ minimatch@3.0.3:
dependencies:
brace-expansion "^1.0.0"

minimatch@3.0.4, minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.2:
minimatch@3.0.4, minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.2, minimatch@~3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
Expand Down