-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
438 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
.tmp | ||
/.dist | ||
/.npm | ||
/.build | ||
/.logs | ||
/.generated | ||
/.www | ||
/scripts/deploy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
> [email protected] test-unit /Users/adam.putinski/Development/github/design-system-internal | ||
> mocha --compilers js:babel-register --require scripts/helpers/setup.js --reporter min 'test/unit/**/*.js' "--color" | ||
|
||
|
||
36 passing (241ms) | ||
|
||
|
||
> [email protected] test-integration /Users/adam.putinski/Development/github/design-system-internal | ||
> mocha --compilers js:babel-register --require scripts/helpers/setup.js --reporter min 'test/integration/**/*.js' "--color" | ||
|
||
|
||
2 passing (430ms) | ||
|
||
|
||
> [email protected] test-browser /Users/adam.putinski/Development/github/design-system-internal | ||
> karma start "--color" | ||
|
||
ERROR LOG: 'Warning: ReactDOMComponent: Do not access .props of a DOM node; instead, recreate the props as `render` did originally or read the DOM properties/attributes directly from this node (e.g., this.refs.box.className). This DOM node was rendered by `BreadCrumbs`.' | ||
|
||
Chrome 50.0.2661 (Mac OS X 10.11.5): Executed 3247 of 3247 SUCCESS (0.888 secs / 0.236 secs) | ||
TOTAL: 3247 SUCCESS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,7 @@ install: | |
- bundle install --path vendor/bundle | ||
- npm install | ||
script: | ||
- npm run lint | ||
- npm run test | ||
- npm run build-travis | ||
after_success: | ||
- export SHA=`git rev-parse --short HEAD` | ||
- if [ -n $TRAVIS_PULL_REQUEST ] ; then curl https://$VISUALTEST_USERNAME:[email protected]/ci/$SHA ; fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,22 +23,24 @@ | |
}, | ||
"scripts": { | ||
"postinstall": "babel-node scripts/npm/postinstall.js", | ||
"pretest": "npm run gulp -- build:test", | ||
"test": "npm run test-unit && npm run test-browser && npm run test-integration", | ||
"test": "babel-node scripts/npm/test.js", | ||
"test-unit": "mocha --compilers js:babel-register --require scripts/helpers/setup.js --reporter min 'test/unit/**/*.js'", | ||
"test-browser": "karma start", | ||
"test-integration": "mocha --compilers js:babel-register --require scripts/helpers/setup.js --reporter min 'test/integration/**/*.js'", | ||
"start": "npm run gulp", | ||
"build": "npm run gulp -- build", | ||
"build-prod": "npm run gulp -- build", | ||
"build-server": "babel-node scripts/npm/build-server.js", | ||
"build-travis": "babel-node scripts/npm/build-travis.js", | ||
"dist": "babel-node scripts/dist.js", | ||
"dist-npm": "babel-node scripts/dist.js --npm", | ||
"lint": "npm run gulp -- lint", | ||
"install-ruby-dependencies": "babel-node scripts/install-ruby-dependencies.js", | ||
"gulp": "gulp" | ||
}, | ||
"dependencies": { | ||
"@salesforce-ux/design-tokens": "git+ssh://[email protected]:salesforce-ux/design-tokens-internal.git#v2.0.5", | ||
"@salesforce-ux/build-server-api": "1.3.4", | ||
"@salesforce-ux/design-tokens": "2.0.5", | ||
"@salesforce-ux/icons": "3.4.0", | ||
"app-module-path": "1.0.5", | ||
"async": "1.5.2", | ||
|
@@ -115,13 +117,16 @@ | |
}, | ||
"devDependencies": { | ||
"chai": "3.5.0", | ||
"cssstats": "^3.0.0-beta.1", | ||
"karma": "0.13.21", | ||
"karma-chai": "0.1.0", | ||
"karma-chrome-launcher": "0.2.2", | ||
"karma-mocha": "0.2.2", | ||
"karma-spec-reporter": "0.0.24", | ||
"karma-webpack": "1.7.0", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "2.4.5", | ||
"sinon": "1.17.3" | ||
"sinon": "1.17.3", | ||
"strip-ansi": "^3.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
Copyright (c) 2015, salesforce.com, inc. All rights reserved. | ||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import fs from 'fs'; | ||
import gulp from 'gulp'; | ||
import gutil from 'gulp-util'; | ||
import path from 'path'; | ||
import through from 'through2'; | ||
import beautify from 'js-beautify'; | ||
import { renderToStaticMarkup } from 'react-dom/server'; | ||
|
||
import { resolve } from 'path'; | ||
import { assign, flatMap } from 'lodash'; | ||
import { generateUI } from './generate-ui'; | ||
|
||
const prettyHTML = html => beautify.html(html, { | ||
'indent_size': 2, | ||
'indent_char': ' ', | ||
'unformatted': ['a'], | ||
'wrap_line_length ': 78, | ||
'indent_inner_html': true | ||
}); | ||
|
||
const toStates = (ex, k) => | ||
[{ id: k, element: ex[k] }]; | ||
|
||
const getStates = file => | ||
file.preview ? toStates(file, 'preview') | ||
: file.default ? toStates(file, 'default') | ||
: file.states; | ||
|
||
const requireExample = flavor => | ||
require(resolve(__PATHS__.ui, flavor.examplePath)); | ||
|
||
export const addExamples = comps => | ||
comps.map(c => assign(c, { | ||
flavors: c.flavors | ||
.filter(f => f.examplePath) | ||
.map(f => assign(f, { examples: getStates(requireExample(f)) })) | ||
}) | ||
); | ||
|
||
export const getComponents = schema => | ||
flatMap(generateUI(schema), 'components'); | ||
|
||
const getName = (component, flavor, example) => | ||
`${component.id}_${flavor.id}_${example.id}`; | ||
|
||
const flattenExamples = comps => | ||
flatMap(comps, comp => | ||
flatMap(comp.flavors, flavor => | ||
flatMap(flavor.examples, ex => | ||
assign(ex, { uid: getName(comp, flavor, ex) })))); | ||
|
||
const toHtml = el => | ||
prettyHTML(renderToStaticMarkup(el)); | ||
|
||
gulp.task('generate:examples', ['generate:whitelist'], () => { | ||
const stream = through.obj(); | ||
const examples = flattenExamples(addExamples(getComponents())); | ||
examples.forEach(ex => | ||
stream.write(new gutil.File({ | ||
path: `${ex.uid}.html`, | ||
contents: new Buffer(toHtml(ex.element)) | ||
}))); | ||
stream.end(); | ||
return stream | ||
.pipe(gulp.dest(resolve(__PATHS__.generated, 'examples'))); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
Copyright (c) 2015, salesforce.com, inc. All rights reserved. | ||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import './setup'; | ||
import _ from 'lodash'; | ||
import async from 'async'; | ||
import cssstats from 'cssstats'; | ||
import { exec } from 'child_process'; | ||
import fs from 'fs'; | ||
import gulp from 'gulp'; | ||
import gulpzip from 'gulp-zip'; | ||
import path from 'path'; | ||
import buildServerApi from '@salesforce-ux/build-server-api'; | ||
|
||
const { publish } = buildServerApi(process.env.BUILD_SERVER_HOST_NEW); | ||
|
||
const packageJSON = require('../../package.json'); | ||
|
||
const CSS_PATH = 'assets/styles/salesforce-lightning-design-system.css'; | ||
|
||
const paths = { | ||
build: path.resolve.bind(path, __PATHS__.build), | ||
buildDist: path.resolve.bind(path, __PATHS__.build, 'dist') | ||
}; | ||
|
||
const execute = (cmd, done) => | ||
exec(cmd, { cwd: __PATHS__.root, stdio: 'inherit' }, (err, out, stderr) => { | ||
if (err) return done(err); | ||
done(null, out.trim()); | ||
}); | ||
|
||
const getDependencies = (done) => { | ||
const deps = _.assign({}, | ||
packageJSON.devDependencies, packageJSON.dependencies); | ||
done(null, _.keys(deps) | ||
.filter(k => k.match(/@salesforce/i)) | ||
.reduce((acc, k) => | ||
_.assign(acc, { [k.split('/')[1]]: deps[k] }), {})); | ||
}; | ||
|
||
const formatStats = stats => ({ | ||
kbSize: stats.size, | ||
gzipSize: stats.gzipSize, | ||
ruleCount: stats.rules.total, | ||
selectorCount: stats.selectors.total, | ||
declarationCount: stats.declarations.total | ||
}); | ||
|
||
const formatTestCounts = out => { | ||
const matches = out.match(/(\d+)\s+(SUCCESS|passing)/ig); | ||
if (!matches) return {}; | ||
return { | ||
unitTests: parseInt(matches[0]), | ||
integrationTests: parseInt(matches[1]), | ||
allyTests: parseInt(matches[2]) | ||
}; | ||
}; | ||
|
||
const zip = (src, done) => | ||
gulp.src(paths.build(`${src}/**/*`)) | ||
.pipe(gulpzip(`${src}.zip`)) | ||
.on('error', done) | ||
.pipe(gulp.dest(paths.build())) | ||
.on('error', done) | ||
.on('finish', done); | ||
|
||
const prepare = (done) => { | ||
console.log('[BUILD:PREPARE]'); | ||
return async.series([ | ||
// clean | ||
(done) => async.series([ | ||
async.apply(execute, `rm -rf ${__PATHS__.build}`), | ||
async.apply(execute, `mkdir ${__PATHS__.build}`) | ||
], done), | ||
// dist | ||
(done) => async.series([ | ||
async.apply(execute, 'npm run dist-npm'), | ||
async.apply(execute, `cp -a ${__PATHS__.npm}/. ${__PATHS__.build}/dist`), | ||
async.apply(execute, `rm -rf ${__PATHS__.build}/dist/*.zip`) | ||
], done), | ||
// examples | ||
async.apply(execute, `cp -a ${__PATHS__.generated}/examples/. ${__PATHS__.build}/examples`), | ||
// website | ||
async.apply(execute, `cp -a ${__PATHS__.www}/. ${__PATHS__.build}/www`), | ||
// git info | ||
async.apply(execute, 'git show --format="%an|%ae|%ad|%s" | head -n 1'), | ||
// stats | ||
(done) => async.series([ | ||
(done) => { | ||
let counts = fs.readFileSync(`${__PATHS__.logs}/test.txt`, 'utf-8') || ''; | ||
done(null, formatTestCounts(counts)); | ||
}, | ||
(done) => { | ||
let css = fs.readFileSync(paths.buildDist(CSS_PATH), 'utf8'); | ||
let stats = cssstats(css); | ||
done(null, formatStats(stats)); | ||
} | ||
], (err, [counts, tests]) => { | ||
if (err) return done(err); | ||
done(null, _.assign({}, counts, tests)); | ||
}), | ||
// SHA | ||
async.apply(execute, 'git rev-parse HEAD'), | ||
// Dependencies | ||
getDependencies, | ||
// zip | ||
async.apply(zip, 'dist'), | ||
async.apply(zip, 'examples'), | ||
async.apply(zip, 'www') | ||
], (err, [_prepare, _dist, _examples, _website, info, stats, sha, dependencies, _zip]) => { | ||
if (err) return done(err); | ||
let result = _.assign({}, { sha, info, stats, dependencies }, { | ||
tag: process.env.TRAVIS_TAG || '', | ||
pullRequest: process.env.TRAVIS_PULL_REQUEST || '', | ||
branch: process.env.TRAVIS_BRANCH || '', | ||
version: packageJSON.version | ||
}); | ||
done(null, result); | ||
}); | ||
}; | ||
|
||
module.exports = (done) => prepare((err, result) => { | ||
if (err) return done(err); | ||
publish({ | ||
result, | ||
zips: ['dist.zip', 'examples.zip', 'www.zip'] | ||
.map((p) => paths.build(p)), | ||
project: 'design-system' | ||
}, done); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
Copyright (c) 2015, salesforce.com, inc. All rights reserved. | ||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import publish from '../helpers/publish'; | ||
|
||
if (process.env.BUILD_SERVER_HOST_NEW) { | ||
publish((err, res) => { | ||
if (err) throw err; | ||
console.log('Successfully published build', res); | ||
}); | ||
} |
Oops, something went wrong.