From 8538ef3dc74f0ac90cc72374bbcc091bf6eb6927 Mon Sep 17 00:00:00 2001 From: Geoff Pleiss and Matt Royal Date: Wed, 17 Jun 2015 17:10:04 -0700 Subject: [PATCH] feat(contributor-workflow): add command to copy vendored PUI packages to projects - See contributing guidelines for details [Finishes #95551932] --- CONTRIBUTING.md | 19 +++++++++++++++++++ tasks/vendor-package.js | 26 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tasks/vendor-package.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d4e45b668..de1e920f6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -148,6 +148,25 @@ This will ensure our conversation doesn't get lost in email or slack. git push -f origin head ``` +1. While you're waiting for your PR to be accepted, you can use your forked + changes in your project. For example, if you made changes to the react alerts + component, run the following command: + + ```bash + gulp vendor-package --type=react --component=alerts --dest= + ``` + + Similarly, if you made changes to the CSS typography component, run + + ```bash + gulp vendor-package --type=css --component=typography --dest= + ``` + + This creates a vendored version of your modified components + (`pui-react-alerts` or `pui-css-typography`) in your project, and points your + project's package json to these vendored versions. This way, you can use your + forked changes right away, even in production! + 1. Once we accept your pull request, we will publish any new or updated pacakges to NPM. diff --git a/tasks/vendor-package.js b/tasks/vendor-package.js new file mode 100644 index 000000000..cf828e8fd --- /dev/null +++ b/tasks/vendor-package.js @@ -0,0 +1,26 @@ +import {exec} from 'child_process'; +import gulp from 'gulp'; +import path from 'path'; +import {argv} from 'yargs'; + +gulp.task('vendor-package', ['css-build', 'react-build'], (callback) => { + const {type: componentType, component: componentName, dest} = argv; + + function useVendoredPackageInProject() { + console.log('hi'); + const originalDirectory = process.cwd(); + process.chdir(dest); + + exec(`npm install --save ${path.join('pui-vendor', componentType, componentName)}`, (error) => { + if (error) { + new gutil.PluginError('vendor-package', {message: error}); + } + process.chdir(originalDirectory); + callback(); + }); + } + + gulp.src(`dist/${componentType}/${componentName}/*`) + .pipe(gulp.dest(`${dest}/pui-vendor/${componentType}/${componentName}`)) + .on('end', useVendoredPackageInProject); +});