Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ FROM node
COPY . /code-machine
RUN mkdir /code

# NODE_ENV for configurations
ENV NODE_ENV HOM

EXPOSE 8000

CMD ["/bin/sh", "-c", "cd /code-machine && node ."]
# set the working dir to the code machine directory
WORKDIR /code-machine

CMD ["node", "index.js"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ To run the service from a new container

Once the image is on the registry server (and it is accessible), execute:

```docker run -dP <registry_server>/<image_name>```
```docker run -dP -v /path/to/front-end-project:/code <registry_server>/<image_name>```

Running and testing

Expand Down
20 changes: 20 additions & 0 deletions app/controllers/api.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* The MIT License (MIT)
* Copyright (c) 2015 Fabrica de Aplicativos S/A
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
'use strict';
var _ = require('lodash');

Expand Down
26 changes: 26 additions & 0 deletions app/controllers/manipulator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
/**
* The MIT License (MIT)
* Copyright (c) 2015 Fabrica de Aplicativos S/A
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
'use strict';
var CM = require('../lib/code-manipulator');
var Reply = require('../lib/socket-reply');
var Message = require('carbono-json-messages');
var PRM = require('../lib/project-resource-manager');

module.exports = function (app) {

Expand Down Expand Up @@ -110,5 +131,10 @@ module.exports = function (app) {
socket.on('disconnect', cm.removeUpdateListener.bind(cm, emitUpdate));
};

this.registerSocket = function (socket) {
PRM.setSocket(socket);
socket.on('disconnect', PRM.removeSocket.bind(PRM,socket));
};

return this;
};
20 changes: 20 additions & 0 deletions app/controllers/resources.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* The MIT License (MIT)
* Copyright (c) 2015 Fabrica de Aplicativos S/A
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
'use strict';
var createResourcesServer = require('../lib/code-interpreter');

Expand Down
20 changes: 20 additions & 0 deletions app/lib/code-interpreter/clean.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* The MIT License (MIT)
* Copyright (c) 2015 Fabrica de Aplicativos S/A
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
'use strict';
var express = require('express');

Expand Down
20 changes: 20 additions & 0 deletions app/lib/code-interpreter/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* The MIT License (MIT)
* Copyright (c) 2015 Fabrica de Aplicativos S/A
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
'use strict';

// External dependencies
Expand Down
20 changes: 20 additions & 0 deletions app/lib/code-interpreter/marked.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* The MIT License (MIT)
* Copyright (c) 2015 Fabrica de Aplicativos S/A
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
'use strict';

// External dependencies
Expand Down
42 changes: 33 additions & 9 deletions app/lib/code-manipulator/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
/**
* The MIT License (MIT)
* Copyright (c) 2015 Fabrica de Aplicativos S/A
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
'use strict';
var domFs = require('../dom-wrapper');
var bower = require('bower');
var Q = require('q');
var _ = require('lodash');
var fs = require('fs');
var path = require('path');
var projResManager = require('../project-resource-manager');

module.exports = function (options) {

Expand Down Expand Up @@ -63,27 +84,29 @@ module.exports = function (options) {
this.insertElement = function (path, html, components, reply) {
// Install components in sequence, so that the installation
// does not run into filesystem conflicts.
//
//
// TODO: improve this, bower supports multiple component
// paralell installation, we must take advantage of that.
//
//
// Some documentation on how to run sequence of promise returning
// functions.
// https://github.com/kriskowal/q#sequences
// http://stackoverflow.com/questions/17757654/how-to-chain-a-variable-number-of-promises-in-q-in-order
// http://stackoverflow.com/questions/17757654/how-to-chain-a-variable\
// -number-of-promises-in-q-in-order
var installationChain;

if (components.length > 0) {
// only build up an installation chain if there
// Only build up an installation chain if there
// are dependencies to be installed
installationChain = components.reduce(function (previousPromise, component) {
installationChain = components.reduce(
function (previousPromise, component) {
return previousPromise.then(function () {
return installAndImport(component)
return installAndImport(component);
});
}, installAndImport(components.shift()));
} else {
// otherwise, simply make up a promise
installationChain = Q();
// Otherwise, simply make up a promise
installationChain = new Q();
}

installationChain
Expand All @@ -101,7 +124,8 @@ module.exports = function (options) {
this.createEntityFromSchema = function (entityName, schema, reply) {
if (schema) {
try {
entityManager.createEntity(entityName, schema);
var route = projResManager.getCrudRoute();
entityManager.createEntity(entityName, route, schema);
reply.success();
} catch (e) {
reply.error({
Expand Down
20 changes: 20 additions & 0 deletions app/lib/dom-wrapper/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* The MIT License (MIT)
* Copyright (c) 2015 Fabrica de Aplicativos S/A
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
'use strict';

var DomFs = require('dom-fs');
Expand Down
31 changes: 29 additions & 2 deletions app/lib/entity-manager/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* The MIT License (MIT)
* Copyright (c) 2015 Fabrica de Aplicativos S/A
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
'use strict';
var path = require('path');
var fs = require('fs');
Expand All @@ -13,18 +33,25 @@ module.exports = function (options) {
* project's entities.json.
*
* @param {string} entityName - name of entity to create.
* @param {string} route - route to the CRUDr responsible for this entity.
* @param {?Object} schema - entity's schema.
*/
var createEntity = function (entityName, schema) {
var createEntity = function (entityName, route, schema) {
if (entityName in entities) {
throw new Error('Unavailable entity name: ' + entityName);
}
if (!route) {
throw new Error('CRUDr route not provided for entity creation');
}

schema = schema || {};

// Maybe we should validate the schema's sanity here?

entities[entityName] = schema;
entities[entityName] = {
route: route,
schema: schema,
};
saveEntities();
};

Expand Down
Loading