Skip to content

Commit

Permalink
Merge pull request #571 from witheve/app-loading
Browse files Browse the repository at this point in the history
standalone Eve apps
  • Loading branch information
ibdknox authored Nov 30, 2016
2 parents b0f8f6f + df69022 commit d368c32
Show file tree
Hide file tree
Showing 20 changed files with 659 additions and 202 deletions.
Empty file added .npmignore
Empty file.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ or you can [download](https://github.com/witheve/Eve/archive/master.zip) the Eve

```
npm install
npm run build
npm start
```

Then open `http://localhost:8080/` in your browser.

### From npm

Alternatively, you can download Eve directly from npm with the following command:

```
npm install witheve
```

### From Docker

First, [download](https://www.docker.com/products/docker) and install Docker for your platform. To download and install the Eve container, run the following command:
Expand All @@ -46,10 +55,9 @@ You can learn about Eve with the following resources:

*Please let us know what kind of documents would be the most helpful as you begin your journey with Eve*. We want our documentation to be a highlight of the Eve experience, so any suggestions are greatly appreciated.

### Running programs on Node.js
### Running Eve Programs in Server Mode

By default, Eve serves the IDE with the browser as the runtime (executing the program).
To instead have the program execute on the server-side, in Node.js use:
By default, Eve executes on the client browser. To instead execute your program on the server, launch Eve with the `--server` flag:

```
npm start -- --server
Expand Down
61 changes: 61 additions & 0 deletions bin/eve.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env node

var path = require("path");
var fs = require("fs");
var minimist = require("minimist");

var config = require("../build/src/config");
var Owner = config.Owner;
var server = require("../build/src/runtime/server");

const argv = minimist(process.argv.slice(2), {boolean: ["server", "editor"]});

// Since our current development pattern uses npm as its package repository, we treat the nearest ancestor directory with a package.json (inclusive) as the directory's "root".
function findRoot(root) {
var pkg;
root = root.split(path.sep);
while(!pkg && root.length > 1) {
var cur = root.join(path.sep);
if(fs.existsSync(path.join(cur, "package.json"))) {
return cur;
}
root.pop();
}
}


var port = argv["port"] || process.env.PORT || 8080;
var runtimeOwner = argv["server"] ? Owner.server : Owner.client;
var controlOwner = argv["localControl"] ? Owner.client : Owner.server;
var editor = argv["editor"] || false;
var filepath = argv["_"][0];
var internal = false;

var root = findRoot(process.cwd());
var eveRoot = findRoot(__dirname);


// If we're executing within the eve module/repo, we're running internally and should expose our examples, src, etc.
// This should be handled down the road by some sort of a manifest in conjunction with the `root` rather than hardcoding.
if(root === eveRoot) internal = true;
else if(!root) {
internal = true;
// We shouldn't (and when globally installed, *can't*) taint the internal examples when running as an installed binary.
// @TODO: In the future we should have a more flexible solution that can copy out the examples into your current workspace when edited.
controlOwner = Owner.client;
}


// If we're not given an explicit filepath to run, assume the user wanted the editor (rather than a blank page).
// Similarly, if we're running internally, send the user over to the quickstart, since they're likely testing the waters.
if(!filepath) {
editor = true;
if(internal) filepath = eveRoot + "/" + "examples/quickstart.eve";
} else {
filepath = path.resolve(filepath);
}

var opts = {internal: internal, runtimeOwner: runtimeOwner, controlOwner: controlOwner, editor: editor, port: port, path: filepath, internal: internal, root: root, eveRoot: eveRoot};
config.init(opts);

server.run(opts);
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<link href="favicon.png" rel="icon" type="image/png" />
</head>
<body>
<script type="text/javascript" src="build/examples.js"></script>
<script type="text/javascript" src="build/workspaces.js"></script>
<script type="text/javascript" src="build/src/uuid.js"></script>
<script type="text/javascript" src="build/src/codemirror.js"></script>
<script type="text/javascript" src="build/src/simplescrollbars.js"></script>
Expand All @@ -30,7 +30,8 @@
<script>
SystemJS.config({
baseURL: "build/src",
defaultJSExtensions: true,
defaultJSExtensions: true,
map: {fs: "@empty", path: "@empty", glob: "@empty", mkdirp: "@empty"},
meta: {"build/src/codemirror.js": { format: "cjs" }}
});

Expand Down
45 changes: 30 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
{
"name": "witheve",
"version": "0.2.1",
"description": "Programming designed for humans",
"keywords": ["language", "ide", "relational", "database", "dataflow"],
"homepage": "http://witheve.com",
"repository": {
"type": "git",
"url": "https://github.com/witheve/Eve"
},
"bugs": {
"url": "https://github.com/witheve/Eve/issues"
},
"license": "Apache-2.0",

"bin": {
"eve": "./bin/eve.js"
},

"scripts": {
"build": "./node_modules/.bin/tsc && node ./build/scripts/build.js",
"start": "./node_modules/.bin/tsc && node ./bin/eve.js",
"server": "node ./bin/eve.js",

"prepublish": "./node_modules/.bin/tsc && node ./build/scripts/build.js",
"build-dist": "node ./build/scripts/build-dist.js",

"test": "node ./build/test/all.js | faucet"
},

"dependencies": {
"@types/body-parser": "0.0.33",
"@types/commonmark": "^0.22.29",
Expand All @@ -25,19 +54,5 @@
"devDependencies": {
"faucet": "0.0.1",
"tape": "^4.6.0"
},
"scripts": {
"install": "./node_modules/.bin/tsc",
"postinstall": "node ./build/scripts/build.js",
"build": "node ./build/scripts/build.js",
"build-dist": "node ./build/scripts/build-dist.js",
"start": "node ./build/src/runtime/server.js",
"server": "node ./build/src/runtime/server.js",
"test": "node ./build/test/all.js | faucet"
},
"repository": {
"type": "git",
"url": "https://github.com/witheve/Eve.git"
},
"license": "Apache-2.0"
}
}
2 changes: 1 addition & 1 deletion scripts/build-dist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function buildDist(callback:() => void) {
fs.writeFileSync("./dist/index.html", index);

//copy("./index.html", "./dist/index.html", tracker.track("copy index"));
copy("./build/examples.js", "./dist/build/examples.js", tracker.track("copy packaged examples"));
copy("./build/workspaces.js", "./dist/build/workspaces.js", tracker.track("copy packaged workspaces"));


for(let pattern of ["build/src/**/*.js", "build/src/**/*.js.map", "src/**/*.css", "css/**/*.css", "examples/**/*.css"]) {
Expand Down
8 changes: 5 additions & 3 deletions scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as path from "path";
import * as fs from "fs";
import * as glob from "glob";
import {packageExamples} from "./package-examples";
import {packageWorkspaces} from "./package-workspaces";

export function onError(err) {
throw err;
Expand Down Expand Up @@ -70,12 +71,13 @@ export function build(callback:() => void) {
"node_modules/chevrotain/lib/chevrotain.js"
];
for(let dep of deps) {
dep = path.resolve(dep);
let base = dep.split("/").pop();
copy(dep, "build/src/" + base, tracker.track("copy node module files"));
}

// Package examples.
packageExamples(tracker.track("package examples"));
// Package workspaces.
packageWorkspaces(tracker.track("package workspaces"));

tracker.finishedStartingTasks();
}
Expand Down
20 changes: 0 additions & 20 deletions scripts/package-examples.ts

This file was deleted.

16 changes: 16 additions & 0 deletions scripts/package-workspaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as fs from "fs";
import * as path from "path";
import * as eveSource from "../src/runtime/eveSource";

eveSource.add("eve", "./examples");
eveSource.add("examples", "./examples");

export function packageWorkspaces(callback:() => void) {
fs.writeFileSync("build/workspaces.js", eveSource.pack());
callback();
}

if(require.main === module) {
console.log("Packaging...")
packageWorkspaces(() => console.log("done."));
}
Loading

0 comments on commit d368c32

Please sign in to comment.