From 1ef7a9d2fbb9be46afb94cf629ae7418980ca108 Mon Sep 17 00:00:00 2001 From: Morris Allison III Date: Wed, 18 Apr 2018 12:21:01 -0700 Subject: [PATCH 1/6] refactor(babel-preset): Consolidate Babel configs --- packages/babel-preset/build.js | 26 ++++++++++++++++++++++++++ packages/babel-preset/package.json | 23 +++++++++++++++++++++++ packages/babel-preset/test.js | 6 ++++++ packages/banner/.babelrc | 10 +--------- packages/icon/.babelrc | 7 +------ packages/icons/.babelrc | 7 +------ packages/react/.babelrc | 7 +------ packages/scripts/bin/build.js | 26 ++------------------------ packages/skeleton-item/.babelrc | 7 +------ packages/themes/.babelrc | 10 +--------- packages/typography/.babelrc | 7 +------ 11 files changed, 64 insertions(+), 72 deletions(-) create mode 100644 packages/babel-preset/build.js create mode 100644 packages/babel-preset/package.json create mode 100644 packages/babel-preset/test.js diff --git a/packages/babel-preset/build.js b/packages/babel-preset/build.js new file mode 100644 index 0000000000..e1b9f6bf53 --- /dev/null +++ b/packages/babel-preset/build.js @@ -0,0 +1,26 @@ +module.exports = function createBuildPreset() { + return { + exclude: [ + "**/node_modules/**", + "**/*.css", + "**/*.scss", + "**/*.html", + "**/*.svg", + "**/*.json" + ], + presets: [ + [ + "env", + { + modules: false, + targets: { + browser: ">1%" + } + } + ], + "stage-2", + "react" + ], + plugins: ["react-docgen"] + }; +}; diff --git a/packages/babel-preset/package.json b/packages/babel-preset/package.json new file mode 100644 index 0000000000..c6c4d63cab --- /dev/null +++ b/packages/babel-preset/package.json @@ -0,0 +1,23 @@ +{ + "private": true, + "name": "@hig/babel-preset", + "description": "HIG Babel preset", + "author": "Autodesk Inc.", + "license": "Apache-2.0", + "homepage": "https://hig.autodesk.com", + "repository": { + "type": "git", + "url": "https://github.com/Autodesk/hig" + }, + "version": "0.1.0", + "main": "index.js", + "peerDependencies": { + "babel-cli": "^6.26.0", + "babel-core": "^6.26.0", + "babel-loader": "^7.1.4", + "babel-plugin-react-docgen": "^1.8.1", + "babel-preset-env": "^1.6.1", + "babel-preset-react": "^6.24.1", + "babel-preset-stage-2": "^6.24.1" + } +} diff --git a/packages/babel-preset/test.js b/packages/babel-preset/test.js new file mode 100644 index 0000000000..8d17ea85b2 --- /dev/null +++ b/packages/babel-preset/test.js @@ -0,0 +1,6 @@ +module.exports = function createTestPreset() { + return { + presets: [["env", { modules: "umd" }], "react", "stage-2"], + plugins: ["transform-object-rest-spread", "react-docgen"] + }; +}; diff --git a/packages/banner/.babelrc b/packages/banner/.babelrc index 094c59dc41..de1ac19b79 100644 --- a/packages/banner/.babelrc +++ b/packages/banner/.babelrc @@ -1,15 +1,7 @@ { "env": { "test": { - "presets": [ - ["env", { "modules": "umd" }], - "react", - "stage-2" - ], - "plugins": [ - "transform-object-rest-spread", - "react-docgen" - ] + "presets": ["@hig/babel-preset/test"] } } } diff --git a/packages/icon/.babelrc b/packages/icon/.babelrc index d9e5b3fb0d..de1ac19b79 100644 --- a/packages/icon/.babelrc +++ b/packages/icon/.babelrc @@ -1,12 +1,7 @@ { "env": { "test": { - "presets": [ - ["env", { "modules": "umd" }], - "react", - "stage-2" - ], - "plugins": ["react-docgen"] + "presets": ["@hig/babel-preset/test"] } } } diff --git a/packages/icons/.babelrc b/packages/icons/.babelrc index d9e5b3fb0d..de1ac19b79 100644 --- a/packages/icons/.babelrc +++ b/packages/icons/.babelrc @@ -1,12 +1,7 @@ { "env": { "test": { - "presets": [ - ["env", { "modules": "umd" }], - "react", - "stage-2" - ], - "plugins": ["react-docgen"] + "presets": ["@hig/babel-preset/test"] } } } diff --git a/packages/react/.babelrc b/packages/react/.babelrc index 63c56d5285..6e2d175779 100644 --- a/packages/react/.babelrc +++ b/packages/react/.babelrc @@ -1,12 +1,7 @@ { "env": { "test": { - "presets": [ - ["env", { "modules": "umd" }], - "react", - "stage-2" - ], - "plugins": ["react-docgen"] + "presets": ["@hig/babel-preset/test"] } }, "presets": [ diff --git a/packages/scripts/bin/build.js b/packages/scripts/bin/build.js index d289a40724..4aae2466cc 100755 --- a/packages/scripts/bin/build.js +++ b/packages/scripts/bin/build.js @@ -9,6 +9,7 @@ const postcss = require("rollup-plugin-postcss"); const json = require("rollup-plugin-json"); const postcssFuncitons = require("postcss-functions"); const postcssImport = require("postcss-import"); +const createBuildPreset = require('@hig/babel-preset/build'); const packageMeta = require(path.resolve(process.cwd(), "package.json")); @@ -33,30 +34,7 @@ const inputOptions = { nodeResolve(), babel({ babelrc: false, - exclude: [ - "**/node_modules/**", - "**/*.css", - "**/*.scss", - "**/*.html", - "**/*.svg", - "**/*.json" - ], - presets: [ - [ - "env", - { - modules: false, - targets: { - browser: ">1%" - } - } - ], - "stage-2", - "react" - ], - plugins: [ - "react-docgen" - ] + ...createBuildPreset() }), commonjs(), json(), diff --git a/packages/skeleton-item/.babelrc b/packages/skeleton-item/.babelrc index d9e5b3fb0d..de1ac19b79 100644 --- a/packages/skeleton-item/.babelrc +++ b/packages/skeleton-item/.babelrc @@ -1,12 +1,7 @@ { "env": { "test": { - "presets": [ - ["env", { "modules": "umd" }], - "react", - "stage-2" - ], - "plugins": ["react-docgen"] + "presets": ["@hig/babel-preset/test"] } } } diff --git a/packages/themes/.babelrc b/packages/themes/.babelrc index 094c59dc41..de1ac19b79 100644 --- a/packages/themes/.babelrc +++ b/packages/themes/.babelrc @@ -1,15 +1,7 @@ { "env": { "test": { - "presets": [ - ["env", { "modules": "umd" }], - "react", - "stage-2" - ], - "plugins": [ - "transform-object-rest-spread", - "react-docgen" - ] + "presets": ["@hig/babel-preset/test"] } } } diff --git a/packages/typography/.babelrc b/packages/typography/.babelrc index d9e5b3fb0d..de1ac19b79 100644 --- a/packages/typography/.babelrc +++ b/packages/typography/.babelrc @@ -1,12 +1,7 @@ { "env": { "test": { - "presets": [ - ["env", { "modules": "umd" }], - "react", - "stage-2" - ], - "plugins": ["react-docgen"] + "presets": ["@hig/babel-preset/test"] } } } From 2cd5d3b4c8c01700491d1fa2a03581650008f79f Mon Sep 17 00:00:00 2001 From: Morris Allison III Date: Wed, 18 Apr 2018 12:35:50 -0700 Subject: [PATCH 2/6] chore(babel-preset): Add preset package to dependants --- packages/banner/package.json | 1 + packages/icon/package.json | 1 + packages/icons/package.json | 1 + packages/react/package.json | 1 + packages/scripts/package.json | 1 + packages/skeleton-item/package.json | 1 + packages/themes/package.json | 1 + packages/typography/package.json | 1 + 8 files changed, 8 insertions(+) diff --git a/packages/banner/package.json b/packages/banner/package.json index 67bd29fa28..c7cd869cfc 100644 --- a/packages/banner/package.json +++ b/packages/banner/package.json @@ -12,6 +12,7 @@ "style": "build/index.css", "files": ["build/*"], "devDependencies": { + "@hig/babel-preset": "0.1.0", "@hig/scripts": "^0.1.0", "@hig/styles": "^0.1.0-alpha", "@hig/eslint-config": "0.1.0", diff --git a/packages/icon/package.json b/packages/icon/package.json index f118fc23e5..393a280e5f 100644 --- a/packages/icon/package.json +++ b/packages/icon/package.json @@ -16,6 +16,7 @@ "@hig/icons": "^0.1.0-alpha" }, "devDependencies": { + "@hig/babel-preset": "0.1.0", "@hig/scripts": "^0.1.0", "@hig/styles": "^0.1.0-alpha" }, diff --git a/packages/icons/package.json b/packages/icons/package.json index 16020b6720..584413a8b4 100644 --- a/packages/icons/package.json +++ b/packages/icons/package.json @@ -12,6 +12,7 @@ "module": "build/index.es.js", "files": ["build/*"], "devDependencies": { + "@hig/babel-preset": "0.1.0", "@hig/scripts": "^0.1.0", "@hig/styles": "^0.1.0-alpha" }, diff --git a/packages/react/package.json b/packages/react/package.json index 26d331f8b0..04de372c40 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -42,6 +42,7 @@ "react-dom": "^15.4.1" }, "devDependencies": { + "@hig/babel-preset": "0.1.0", "@hig/styles": "^0.1.0-alpha", "@types/jest": "^19.2.3", "@types/node": "^7.0.21", diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 96c3e8b5ab..080caa3121 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -10,6 +10,7 @@ "hig-scripts-build": "bin/build.js" }, "dependencies": { + "@hig/babel-preset": "0.1.0", "babel-plugin-external-helpers": "^6.22.0", "babel-preset-env": "^1.6.1", "babel-preset-react": "^6.24.1", diff --git a/packages/skeleton-item/package.json b/packages/skeleton-item/package.json index fbbc44fdeb..fd9d1645bb 100644 --- a/packages/skeleton-item/package.json +++ b/packages/skeleton-item/package.json @@ -16,6 +16,7 @@ "@hig/themes": "^0.1.0-alpha" }, "devDependencies": { + "@hig/babel-preset": "0.1.0", "@hig/scripts": "^0.1.0", "@hig/styles": "^0.1.0-alpha" }, diff --git a/packages/themes/package.json b/packages/themes/package.json index de7a6da641..d6ee01b62e 100644 --- a/packages/themes/package.json +++ b/packages/themes/package.json @@ -11,6 +11,7 @@ "main": "build/index.js", "module": "build/index.es.js", "devDependencies": { + "@hig/babel-preset": "0.1.0", "@hig/scripts": "^0.1.0", "@hig/styles": "^0.1.0-alpha" }, diff --git a/packages/typography/package.json b/packages/typography/package.json index 700be435cd..5e2bdc3192 100644 --- a/packages/typography/package.json +++ b/packages/typography/package.json @@ -13,6 +13,7 @@ "style": "build/index.css", "files": ["build/*"], "devDependencies": { + "@hig/babel-preset": "0.1.0", "@hig/scripts": "^0.1.0", "@hig/styles": "^0.1.0-alpha" }, From 9835f1e31bb254d85fc6e3a51ff0788f8e21736c Mon Sep 17 00:00:00 2001 From: Morris Allison III Date: Wed, 18 Apr 2018 14:21:04 -0700 Subject: [PATCH 3/6] chore: Add dependency hash for CI --- .circleci/config.yml | 26 +++++++++++++++++--------- .gitignore | 3 +++ package.json | 1 + packages/babel-preset/package.json | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 158b59fc5b..da0bc7f7b2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,14 +8,16 @@ jobs: <<: *defaults steps: - checkout + - run: yarn run create-dependency-hash - restore_cache: - key: hig-dependencies-{{ checksum "yarn.lock" }} + key: hig-dependencies-{{ checksum ".dependency-hash" }} - run: name: Install Dependencies command: yarn - save_cache: - key: hig-dependencies-{{ checksum "yarn.lock" }} + key: hig-dependencies-{{ checksum ".dependency-hash" }} paths: + - .dependency-hash - node_modules - packages/banner/node_modules - packages/eslint-config/node_modules @@ -31,8 +33,9 @@ jobs: <<: *defaults steps: - checkout + - run: yarn run create-dependency-hash - restore_cache: - key: hig-dependencies-{{ checksum "yarn.lock" }} + key: hig-dependencies-{{ checksum ".dependency-hash" }} - run: name: Build all packages command: yarn build @@ -51,8 +54,9 @@ jobs: <<: *defaults steps: - checkout + - run: yarn run create-dependency-hash - restore_cache: - key: hig-dependencies-{{ checksum "yarn.lock" }} + key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: key: package-build-{{ .Revision }} - run: @@ -68,8 +72,9 @@ jobs: <<: *defaults steps: - checkout + - run: yarn run create-dependency-hash - restore_cache: - key: hig-dependencies-{{ checksum "yarn.lock" }} + key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: key: package-build-{{ .Revision }} - run: @@ -96,8 +101,9 @@ jobs: <<: *defaults steps: - checkout + - run: yarn run create-dependency-hash - restore_cache: - key: hig-dependencies-{{ checksum "yarn.lock" }} + key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: key: package-build-{{ .Revision }} - run: @@ -108,8 +114,9 @@ jobs: <<: *defaults steps: - checkout + - run: yarn run create-dependency-hash - restore_cache: - key: hig-dependencies-{{ checksum "yarn.lock" }} + key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: key: package-build-{{ .Revision }} - run: @@ -123,7 +130,7 @@ jobs: steps: - checkout - restore_cache: - key: hig-dependencies-{{ checksum "yarn.lock" }} + key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: key: package-build-{{ .Revision }} - run: @@ -134,8 +141,9 @@ jobs: <<: *defaults steps: - checkout + - run: yarn run create-dependency-hash - restore_cache: - key: hig-dependencies-{{ checksum "yarn.lock" }} + key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: key: package-build-{{ .Revision }} - run: diff --git a/.gitignore b/.gitignore index 6d136a4a60..34acc0433d 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,9 @@ gemini-report/ # Files created by CircleCI nohup.out +# Files generated during CI +.dependency-hash + # Environment Variables .env diff --git a/package.json b/package.json index b580f772e7..b88e6200ea 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "version": "1.0.1", "scripts": { "build": "lerna run build", + "create-dependency-hash": "cat yarn.lock > .dependency-hash && ls ./packages >> .dependency-hash", "lint": "lerna run lint", "publish-canary": "lerna publish --canary --yes --exact", "update-packages": "lerna publish --skip-npm" diff --git a/packages/babel-preset/package.json b/packages/babel-preset/package.json index c6c4d63cab..97a25cd471 100644 --- a/packages/babel-preset/package.json +++ b/packages/babel-preset/package.json @@ -1,6 +1,7 @@ { "private": true, "name": "@hig/babel-preset", + "version": "0.1.0", "description": "HIG Babel preset", "author": "Autodesk Inc.", "license": "Apache-2.0", @@ -9,7 +10,6 @@ "type": "git", "url": "https://github.com/Autodesk/hig" }, - "version": "0.1.0", "main": "index.js", "peerDependencies": { "babel-cli": "^6.26.0", From e3f94266f8956ab12f1ce75512623882aa4c99bd Mon Sep 17 00:00:00 2001 From: Morris Allison III Date: Wed, 18 Apr 2018 14:36:57 -0700 Subject: [PATCH 4/6] refactor(babel-preset): Change peerDependencies to dependencies --- packages/babel-preset/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-preset/package.json b/packages/babel-preset/package.json index 97a25cd471..6ef0194b20 100644 --- a/packages/babel-preset/package.json +++ b/packages/babel-preset/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/Autodesk/hig" }, "main": "index.js", - "peerDependencies": { + "dependencies": { "babel-cli": "^6.26.0", "babel-core": "^6.26.0", "babel-loader": "^7.1.4", From 22de6f03b78a2b372a33e2b2b1a13d2735694bef Mon Sep 17 00:00:00 2001 From: Morris Allison III Date: Wed, 18 Apr 2018 14:45:51 -0700 Subject: [PATCH 5/6] test: Have jest ignore babel-preset/test --- packages/storybook/jest.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/storybook/jest.config.js b/packages/storybook/jest.config.js index 1fceeeebe8..585a7471dc 100644 --- a/packages/storybook/jest.config.js +++ b/packages/storybook/jest.config.js @@ -27,6 +27,6 @@ module.exports = { rootDir: "../../", setupFiles: ["raf/polyfill"], setupTestFrameworkScriptFile: "/packages/storybook/support/jest/setupTests.js", - testPathIgnorePatterns: ["/packages/vanilla"], + testPathIgnorePatterns: ["/packages/vanilla", "/packages/babel-preset"], unmockedModulePathPatterns: ["node_modules"] }; From cdc2ffa4b6059f0653c4010c4360f95b7ecd2c79 Mon Sep 17 00:00:00 2001 From: Morris Allison III Date: Wed, 18 Apr 2018 15:02:37 -0700 Subject: [PATCH 6/6] Fix build --- .circleci/config.yml | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index da0bc7f7b2..8d8e0f7361 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,9 @@ jobs: <<: *defaults steps: - checkout - - run: yarn run create-dependency-hash + - run: + name: Create dependency hash + command: yarn run create-dependency-hash - restore_cache: key: hig-dependencies-{{ checksum ".dependency-hash" }} - run: @@ -33,7 +35,9 @@ jobs: <<: *defaults steps: - checkout - - run: yarn run create-dependency-hash + - run: + name: Create dependency hash + command: yarn run create-dependency-hash - restore_cache: key: hig-dependencies-{{ checksum ".dependency-hash" }} - run: @@ -54,7 +58,9 @@ jobs: <<: *defaults steps: - checkout - - run: yarn run create-dependency-hash + - run: + name: Create dependency hash + command: yarn run create-dependency-hash - restore_cache: key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: @@ -72,7 +78,9 @@ jobs: <<: *defaults steps: - checkout - - run: yarn run create-dependency-hash + - run: + name: Create dependency hash + command: yarn run create-dependency-hash - restore_cache: key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: @@ -101,7 +109,9 @@ jobs: <<: *defaults steps: - checkout - - run: yarn run create-dependency-hash + - run: + name: Create dependency hash + command: yarn run create-dependency-hash - restore_cache: key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: @@ -114,7 +124,9 @@ jobs: <<: *defaults steps: - checkout - - run: yarn run create-dependency-hash + - run: + name: Create dependency hash + command: yarn run create-dependency-hash - restore_cache: key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: @@ -129,6 +141,9 @@ jobs: <<: *defaults steps: - checkout + - run: + name: Create dependency hash + command: yarn run create-dependency-hash - restore_cache: key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: @@ -141,7 +156,9 @@ jobs: <<: *defaults steps: - checkout - - run: yarn run create-dependency-hash + - run: + name: Create dependency hash + command: yarn run create-dependency-hash - restore_cache: key: hig-dependencies-{{ checksum ".dependency-hash" }} - restore_cache: