-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from mvdwg/add_build_features_command
Add build:features command
- Loading branch information
Showing
10 changed files
with
385 additions
and
1 deletion.
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
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,27 @@ | ||
/* jshint node: true */ | ||
'use strict'; | ||
|
||
var Command = require('ember-cli/lib/models/command'); | ||
|
||
module.exports = Command.extend({ | ||
name: 'build:features', | ||
description: 'Build visual documentation site', | ||
works: 'insideProject', | ||
availableOptions: [ | ||
{ name: 'output-path', type: 'Path', default: 'dist/', aliases: ['o'] } | ||
], | ||
|
||
run: function(commandOptions) { | ||
var buildTask = new this.tasks.Build({ | ||
ui: this.ui, | ||
analytics: this.analytics, | ||
project: this.project | ||
}); | ||
|
||
process.env['TELLING_STORIES'] = true; | ||
|
||
return buildTask.run(Object.assign(commandOptions, { | ||
environment: 'test' | ||
})); | ||
} | ||
}); |
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,6 @@ | ||
/* jshint node: true */ | ||
'use strict'; | ||
|
||
module.exports = { | ||
'build:features': require('./build-features') | ||
}; |
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,34 @@ | ||
var Plugin = require('broccoli-plugin'); | ||
var fs = require('fs'); | ||
var glob = require('glob'); | ||
var path = require('path'); | ||
|
||
module.exports = CreateListOfTests; | ||
|
||
CreateListOfTests.prototype = Object.create(Plugin.prototype); | ||
CreateListOfTests.prototype.constructor = CreateListOfTests; | ||
function CreateListOfTests(inputNode, options) { | ||
options = options || {}; | ||
Plugin.call(this, [inputNode], { | ||
annotation: options.annotation | ||
}); | ||
this.options = options; | ||
} | ||
|
||
CreateListOfTests.prototype.build = function() { | ||
var extractMetadata = require('./extract-metadata'); | ||
var inputPath = this.inputPaths[0]; | ||
|
||
var records = glob.sync('**/*-test.js', { cwd: inputPath }) | ||
.map(function(fileName) { | ||
return path.join(inputPath, fileName); | ||
}) | ||
.map(function(file) { | ||
return extractMetadata(fs.readFileSync(file)); | ||
}) | ||
.filter(function(entry) { | ||
return !!entry; | ||
}); | ||
|
||
fs.writeFileSync(path.join(this.outputPath, 'telling-stories.json'), JSON.stringify({ features: records })); | ||
}; |
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,53 @@ | ||
var crypto = require('crypto'); | ||
var logger = require('heimdalljs-logger')('telling-stories-parser'); | ||
|
||
module.exports = extractMetadata; | ||
|
||
function goodEnoughId(module, test) { | ||
return crypto | ||
.createHash('md5') | ||
.update(module) | ||
.update(test) | ||
.digest('base64').replace(/\\\+|=/g,''); // remove \ + = chars | ||
} | ||
|
||
// I'm using functions to create a new instance each time the regexp is used. | ||
// This is to avoid the state change provoked by the `.exec` method. Note that | ||
// moduleTextRegexp doesn't uses the `g` modifier so it shouldn't have any | ||
// problem but we might need to use the `g` modifier in the future so... | ||
function moduleTextRegexp() { | ||
return /moduleForAcceptance\((['"`])((?:.|\\')+)\1/; | ||
} | ||
|
||
function testRegexp() { | ||
return /test\((['"`])((?:.|\\')+)\1.+\)/g | ||
} | ||
|
||
function extractMetadata(content, meta) { | ||
var matches = moduleTextRegexp().exec(content); | ||
var record; | ||
var tests; | ||
var re = testRegexp(); | ||
|
||
if (!matches) { | ||
if (/moduleForAcceptance/.test(content)) { | ||
logger.error("Wow, we couldn't parse the file " + meta.fileName + " correctly. We have a bug in the regexp"); | ||
} | ||
} else if (matches[2]) { | ||
record = { | ||
module: matches[2], | ||
tests: [] | ||
}; | ||
|
||
while ((matches = re.exec(content)) !== null) { | ||
if (matches[2]) { | ||
record.tests.push({ | ||
id: goodEnoughId(record.module, matches[2]), | ||
name: matches[2] | ||
}); | ||
} | ||
} | ||
|
||
return record; | ||
} | ||
} |
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,36 @@ | ||
/*jshint node:true*/ | ||
module.exports = { | ||
name: 'telling-stories-parser', | ||
|
||
included: function(app, addon) { | ||
if (typeof app.import !== 'function' && app.app) { | ||
app = app.app; | ||
} | ||
|
||
this.app = app; | ||
|
||
this._super.included.apply(this, arguments); | ||
}, | ||
|
||
isDevelopingAddon: function() { | ||
return true; | ||
}, | ||
|
||
treeFor(name) { | ||
if (!this.isEnabled()) { | ||
return; | ||
} | ||
|
||
return this._super.treeFor.apply(this, arguments); | ||
}, | ||
|
||
treeForPublic() { | ||
var CreateListOfTests = require('./create-list-of-tests'); | ||
|
||
return new CreateListOfTests('tests'); | ||
}, | ||
|
||
isEnabled: function() { | ||
return this.app.env !== 'development'; | ||
} | ||
}; |
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,109 @@ | ||
html, | ||
body, | ||
.ember-application > .ember-view, | ||
.ember-application > .ember-view > .ember-view { | ||
height: 100%; margin: 0; | ||
} | ||
|
||
.ts { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background: #fff; | ||
display: flex; | ||
flex-flow: row; | ||
height: 100%; | ||
margin: 0; | ||
|
||
color: rgb(102, 102, 102); | ||
font-family: 'Roboto', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif; | ||
font-size: 14px; | ||
font-weight: 300; | ||
letter-spacing: .01em; | ||
line-height: 1.6; | ||
} | ||
|
||
.ts-feature-list { | ||
width: 220px; | ||
border-right: 1px solid #666; | ||
height: 100vh; | ||
overflow: scroll; | ||
} | ||
|
||
.ts-header { | ||
display: block; | ||
color: #FAFAFA; | ||
background-color: #333; | ||
} | ||
|
||
.ts-header h1 { | ||
margin: 0; | ||
text-align: center; | ||
font-weight: 100; | ||
} | ||
|
||
.ts-feature-list__title { | ||
font-size: 110%; | ||
position: relative; | ||
border-radius: 3px; | ||
padding: 0.75em 1em; | ||
margin: 0; | ||
background-color: #FAFAFA; | ||
box-shadow: 1px 1px 4px rgba(0,0,0,0.065); | ||
font-weight: 100; | ||
} | ||
|
||
.ts-feature-item { | ||
display: flex; | ||
background-color: #FAFAFA; | ||
background: linear-gradient(to bottom, #fff, #F2F2F2); | ||
padding: 0.75em 1em; | ||
box-shadow: 1px 1px 4px rgba(0,0,0,0.065); | ||
position: relative; | ||
padding: 10px 20px !important; | ||
list-style: none; | ||
box-sizing: border-box; | ||
text-decoration: none; | ||
cursor: pointer; | ||
border-left: 5px solid #C6E746; | ||
margin-bottom: 3px; | ||
} | ||
|
||
.ts-feature-item:hover, | ||
.ts-feature-item:visited, | ||
.ts-feature-item:active, | ||
.ts-feature-item { | ||
color:#666; | ||
} | ||
|
||
.ts-feature-item:hover, | ||
.ts-feature-item.active { | ||
background: linear-gradient(to bottom, #F2F2F2, #fff); | ||
} | ||
|
||
.ts iframe { | ||
width: 100%; | ||
border: none; | ||
min-height: 400px; | ||
flex: 1 1; | ||
} | ||
|
||
.ts-empty-state { | ||
box-sizing: border-box; | ||
width: calc(100% - 220px); | ||
padding-top: 150px; | ||
text-align: center; | ||
font-size: 200%; | ||
font-weight: bold; | ||
color: white; | ||
text-shadow: 0px 0px 2px black; | ||
|
||
background: url('/telling-stories-dashboard/popcorn.png') 40% 25% no-repeat; | ||
} | ||
|
||
.ts-empty-state--message { | ||
max-width: 450px; | ||
display: inline-block; | ||
} |
Oops, something went wrong.