Skip to content

Commit

Permalink
Create plugins API and add preprocessor plugin support (#888)
Browse files Browse the repository at this point in the history
* fix broken menu specs

* extract browserify code and create preprocessor abstraction

* server: remove unused code

* server: implement logic for importing preprocessor

* server: add eslintrc and ignore test fixtures

* server: implement plugins API

* server: add node_cache module to manage clearing a package and its dependencies

* server: clear plugins file from cache to re-require it

* server: set pluginsFile to absolute path

* server: add debug logging to plugins

* server: watch pluginsFile

* server: throw the right error when requiring plugins file

* server: organize config folders and keys visually

* server: scaffold plugins file

* server: require plugins file via nodeCache.require

* server: update browserify preprocessor name and point to github for now

* server: remove redundant integration tests

* server: always scaffold plugins file, except when falsey

* server: add plugins file test to scaffold spec

* server: always provide util.fileUpdated to preprocessor

* server: update browserify-preprocessor dep

* server: fix integration tests

* server: remove redundant logic

* server: catch errors thrown synchronously by plugins function

* server: reduce chances of flakyness in async test

* driver: fix broken spec

* server: don’t check for dirname of supportFile and pluginFile when we know they’re already a directory

* driver: there is no dist

* server: update default options sent to browserify preprocessor

* server: send config into browserify instead of options

* server: add test around default preprocessor

* server: update browserify preprocessor

* server: refactor events spec to better handle multiple calls to handleEvent

* server: add tests around project:open events

* server/desktop-gui: handle errors when plugins file changes

* server: fix events spec

* server: allow any file types to be spec files

* server: validate config.pluginsFile

* server: remove link to error doc

* server: improve plugins error message

* server: simplify example plugins file

* server: on:spec:file:preprocessor -> file:preprocessor

* server: wrap plugins in a child process

* server: rename specsGlob to testFiles

* server: bump browserify-preprocessor ‘version’

* server: fix references left by merge

* server: fix incorrect function names

* server: fix plugin error serialization

* server: display error if plugins process has an uncaught exception or unhandled rejection

* server: reset domain on reset

* server: exit early on plugin error headlessly

* server: add e2e tests for plugins/preprocessors

* server: remove obselete node cache file

* server: fix integration tests

* server: log plugins error before exiting

* server: use npm version of browserify preprocessor

* server: extract string-splitting function

* socket: use path.join in spec

* server: eslint ignore scaffold files

* server: fix scaffolded plugins file links, add snapshot test

* server: if app_spec runs, cause a failure [skip ci]

- tested locally
  • Loading branch information
chrisbreiding authored and brian-mann committed Nov 20, 2017
1 parent a888f89 commit 1ec6f78
Show file tree
Hide file tree
Showing 85 changed files with 9,051 additions and 7,691 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__snapshots__
packages/server/lib/scaffold/index.js
packages/server/lib/scaffold/plugins/index.js
packages/server/lib/scaffold/support/index.js
packages/server/lib/scaffold/support/commands.js
packages/example/cypress
1 change: 1 addition & 0 deletions packages/desktop-gui/cypress.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"projectId": "fas5qd",
"pluginsFile": false,
"viewportWidth": 800,
"viewportHeight": 550
}
8 changes: 8 additions & 0 deletions packages/desktop-gui/cypress/integration/project_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ describe "Project", ->
.should("contain", @err.message)
.and("contain", "To fix")

it "displays miscellaneous project error", ->
cy.stub(@ipc, "onProjectError").yields(null, @err)
@start()
cy
.get(".error")
.should("contain", @err.message)
.and("contain", "To fix")

it "word wraps long error message plus update bar", ->
@updaterCheck.resolve("1.3.4")
@longErrMessage = "Morbileorisus,portaacconsecteturac,vestibulumateros.Nullamquisrisusegeturnamollis ornare vel eu leo. Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Etiam porta sem malesuada magna mollis euismod. Maecenas faucibus mollis interdum. Nullam id dolor id nibh ultricies vehicula ut id elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Vestibulum id ligula porta felis euismod semper. Vestibulum id ligula porta felis euismod semper.Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec id elit non mi porta gravida at eget metus. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cras justo odio, dapibus ac facilisis in, egestas eget quam.Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Maecenas faucibus mollis interdum. Etiam porta sem malesuada magna mollis euismod."
Expand Down
1 change: 1 addition & 0 deletions packages/desktop-gui/src/lib/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ register('open:finder')
register('open:project', false)
register('on:config:changed', false)
register('on:spec:changed', false)
register('on:project:error', false)
register('on:project:warning', false)
register('ping:api:server')
register('remove:project')
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-gui/src/project/project.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Project extends Component {
<div className='full-alert alert alert-danger error'>
<p>
<i className='fa fa-warning'></i>{' '}
<strong>Can't start server</strong>
<strong>{err.title || 'Can\'t start server'}</strong>
</p>
<p dangerouslySetInnerHTML={{
__html: err.message.split('\n').join('<br />'),
Expand Down
4 changes: 4 additions & 0 deletions packages/desktop-gui/src/projects/projects-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ const openProject = (project) => {
reopenProject(project)
})

ipc.onProjectError((__, error) => {
project.setError(error)
})

ipc.onProjectWarning((__, warning) => {
project.setWarning(warning)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop-gui/src/specs/spec-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default class Spec {
this.displayName = displayName
this.isExpanded = true
}
hasChildren() {

hasChildren () {
return this.children.specs && this.children.specs.length;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-gui/src/specs/specs-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class SpecsStore {

this.isLoading = false
}

@action setChosenSpec (specPath) {
this.chosenSpecPath = specPath
}
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/test/cypress/fixtures/app.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{foo: "bar"}
{ 'bar' }
Loading

0 comments on commit 1ec6f78

Please sign in to comment.